Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_attach.c ewl_attach.h ewl_enums.h ewl_widget.c 
        ewl_widget.h 


Log Message:
- make the widget name and widget colour an attachment on the widget instead
  of being part of the struct.

- saves about 1-2 meg on a 3000 entry filedialog

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_attach.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ewl_attach.c        25 Sep 2005 05:02:19 -0000      1.1
+++ ewl_attach.c        28 Sep 2005 20:32:18 -0000      1.2
@@ -81,6 +81,50 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+void
+ewl_attach_other_set(Ewl_Widget *w, Ewl_Attach_Type t, void *data)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("w", w);
+
+       if (!w->attach)
+               ewl_attach_parent_setup(w);
+
+       if (data)
+       {
+               Ewl_Attach *attach;
+
+               attach = ewl_attach_new(t, EWL_ATTACH_DATA_TYPE_COLOR, data);
+               if (!attach)
+                       ewl_attach_list_add(w->attach, w, attach);
+       }
+       else
+               ewl_attach_list_del(w->attach, t);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+void *
+ewl_attach_get(Ewl_Widget *w, Ewl_Attach_Type t)
+{
+       Ewl_Attach *attach;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("w", w, NULL);
+
+       if (!w->attach) 
+       {
+               DRETURN_PTR(NULL, DLEVEL_STABLE);
+       }
+
+       attach = ewl_attach_list_get(w->attach, t);
+       if (attach)
+       {
+               DRETURN_PTR(attach->data, DLEVEL_STABLE);
+       }
+       DRETURN_PTR(NULL, DLEVEL_STABLE);
+}
+
 Ewl_Attach_List *
 ewl_attach_list_new(void)
 {
@@ -192,6 +236,11 @@
                case EWL_ATTACH_TYPE_TOOLTIP:
                        ewl_attach_tooltip_attach(w, attach);
                        break;
+
+               case EWL_ATTACH_TYPE_COLOR:
+               case EWL_ATTACH_TYPE_NAME:
+               default:
+                       break;
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -247,6 +296,45 @@
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
+void *
+ewl_attach_list_get(Ewl_Attach_List *list, Ewl_Attach_Type type)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("list", list, NULL);
+
+       if (!list->len)
+       {
+               DRETURN_PTR(NULL, DLEVEL_STABLE);
+       }
+       else if (list->direct)
+       {
+               Ewl_Attach *tmp;
+
+               tmp = EWL_ATTACH(list->list);
+               if (tmp->type == type)
+               {
+                       DRETURN_PTR(tmp, DLEVEL_STABLE);
+               }
+               DRETURN_PTR(NULL, DLEVEL_STABLE);
+       }
+       else
+       {
+               int i;
+               Ewl_Attach *tmp;
+
+               for (i = 0; i < list->len; i++)
+               {
+                       tmp = EWL_ATTACH(list->list[i]);
+
+                       if (tmp->type == type)
+                       {
+                               DRETURN_PTR(tmp, DLEVEL_STABLE);
+                       }
+               }
+       }
+       DRETURN_PTR(NULL, DLEVEL_STABLE);
+}
+
 Ewl_Attach *
 ewl_attach_new(Ewl_Attach_Type t, Ewl_Attach_Data_Type dt, void *data)
 {
@@ -291,6 +379,12 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("attach", attach);
 
+       /* XXX should we clean up _WIDGET in here? */
+
+       if ((attach->type == EWL_ATTACH_DATA_TYPE_TEXT)
+                       || (attach->type == EWL_ATTACH_DATA_TYPE_COLOR))
+               IF_FREE(attach->data);
+
        IF_FREE(attach);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_attach.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- ewl_attach.h        25 Sep 2005 05:02:19 -0000      1.1
+++ ewl_attach.h        28 Sep 2005 20:32:18 -0000      1.2
@@ -35,8 +35,39 @@
 #define ewl_attach_tooltip_widget_set(w, data) \
        ewl_attach_widget_set(w, EWL_ATTACH_TYPE_TOOLTIP, data)
 
+/**
+ * @def ewl_attach_color_set(w, data)
+ * Convience method to set a colour widget attachment
+ */
+#define ewl_attach_color_set(w, data) \
+       ewl_attach_other_set(w, EWL_ATTACH_TYPE_COLOR, data)
+
+/**
+ * @def ewl_attach_color_get(w) 
+ * Convience method to get a colour attachment back
+ */
+#define ewl_attach_color_get(w) \
+       ewl_attach_get(w, EWL_ATTACH_TYPE_COLOR)
+
+/**
+ * @def ewl_attach_name_set(w, data)
+ * Convience method to set a widget name attachment
+ */
+#define ewl_attach_name_set(w, data) \
+       ewl_attach_text_set(w, EWL_ATTACH_TYPE_NAME, data)
+
+/**
+ * @def ewl_attach_name_get(w)
+ * Convience method to get a widgets name attachment
+ */
+#define ewl_attach_name_get(w) \
+       ewl_attach_get(w, EWL_ATTACH_TYPE_NAME)
+
 void ewl_attach_text_set(Ewl_Widget *w, Ewl_Attach_Type t, const char *data);
 void ewl_attach_widget_set(Ewl_Widget *w, Ewl_Attach_Type t, Ewl_Widget *data);
+void ewl_attach_other_set(Ewl_Widget *w, Ewl_Attach_Type t, void *data);
+
+void *ewl_attach_get(Ewl_Widget *w, Ewl_Attach_Type t);
 
 /* 
  * internal stuff 
@@ -46,6 +77,7 @@
 
 void ewl_attach_list_add(Ewl_Attach_List *list, Ewl_Widget *parent, Ewl_Attach 
*attach);
 void ewl_attach_list_del(Ewl_Attach_List *list, Ewl_Attach_Type type);
+void *ewl_attach_list_get(Ewl_Attach_List *list, Ewl_Attach_Type type);
 
 Ewl_Attach *ewl_attach_new(Ewl_Attach_Type t, Ewl_Attach_Data_Type dt, void 
*data);
 int ewl_attach_init(Ewl_Attach *attach, Ewl_Attach_Type t, 
Ewl_Attach_Data_Type dt, void *data);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_enums.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- ewl_enums.h 27 Sep 2005 05:38:32 -0000      1.11
+++ ewl_enums.h 28 Sep 2005 20:32:18 -0000      1.12
@@ -326,14 +326,17 @@
 
 enum Ewl_Attach_Type 
 {
-       EWL_ATTACH_TYPE_TOOLTIP
+       EWL_ATTACH_TYPE_TOOLTIP,
+       EWL_ATTACH_TYPE_COLOR,
+       EWL_ATTACH_TYPE_NAME
 };
 typedef enum Ewl_Attach_Type Ewl_Attach_Type;
 
 enum Ewl_Attach_Data_Type 
 {
        EWL_ATTACH_DATA_TYPE_TEXT,
-       EWL_ATTACH_DATA_TYPE_WIDGET
+       EWL_ATTACH_DATA_TYPE_WIDGET,
+       EWL_ATTACH_DATA_TYPE_COLOR
 };
 typedef enum Ewl_Attach_Data_Type Ewl_Attach_Data_Type;
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_widget.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ewl_widget.c        27 Sep 2005 03:26:32 -0000      1.16
+++ ewl_widget.c        28 Sep 2005 20:32:18 -0000      1.17
@@ -105,8 +105,6 @@
        ewl_widget_inherit(w, "widget");
        ewl_widget_appearance_set(w, appearance);
 
-       ewl_widget_color_set(w, 255, 255, 255, 255);
-
        DRETURN_INT(TRUE, DLEVEL_STABLE);
 }
 
@@ -118,16 +116,19 @@
  */
 void ewl_widget_name_set(Ewl_Widget * w, const char *name)
 {
+       char *t;
+
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
 
        if (!name_table)
                name_table = ecore_hash_new(ecore_str_hash, ecore_str_compare);
 
-       IF_FREE(w->name);
-       w->name = strdup(name);
+       t = strdup(name);
+       ewl_attach_name_set(w, t);
+
        if (name_table)
-               ecore_hash_set(name_table, w->name, w);
+               ecore_hash_set(name_table, t, w);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -142,7 +143,7 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("w", w, NULL);
 
-       DRETURN_PTR(w->name ? strdup(w->name) : NULL, DLEVEL_STABLE);
+       DRETURN_PTR(ewl_attach_name_get(w), DLEVEL_STABLE);
 }
 
 /**
@@ -1039,13 +1040,18 @@
 void
 ewl_widget_color_set(Ewl_Widget *w, int r, int g, int b, int a)
 {
+       Ewl_Color_Set *color;
+
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
 
-       w->color.r = r;
-       w->color.g = g;
-       w->color.b = b;
-       w->color.a = a;
+       color = NEW(Ewl_Color_Set, 1);
+       color->r = r;
+       color->g = g;
+       color->b = b;
+       color->a = a;
+
+       ewl_attach_color_set(w, color);
 
        if (REALIZED(w))
                evas_object_color_set(w->fx_clip_box, r, g, b, a);
@@ -1065,13 +1071,21 @@
 void
 ewl_widget_color_get(Ewl_Widget *w, int *r, int *g, int *b, int *a)
 {
+       Ewl_Color_Set *color;
+
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("w", w);
 
-       if (r) *r = w->color.r;
-       if (g) *g = w->color.g;
-       if (b) *b = w->color.b;
-       if (a) *a = w->color.a;
+       color = ewl_attach_color_get(w);
+       if (!color) 
+       {
+               DRETURN(DLEVEL_STABLE);
+       }
+
+       if (r) *r = color->r;
+       if (g) *g = color->g;
+       if (b) *b = color->b;
+       if (a) *a = color->a;
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -1102,7 +1116,6 @@
         * Free up appearance related information
         */
        ewl_theme_widget_shutdown(w);
-       IF_FREE(w->name);
        IF_FREE(w->appearance);
 
        if (w->inheritance)
@@ -1110,7 +1123,17 @@
 
        if (w->bit_state)
                ecore_string_release(w->bit_state);
-       
+
+       /* 
+        * cleanup the attachment lists 
+        */
+       if (w->attach)
+       {
+               ewl_attach_list_del(w->attach, EWL_ATTACH_TYPE_TOOLTIP);
+               ewl_attach_list_del(w->attach, EWL_ATTACH_TYPE_COLOR);
+               ewl_attach_list_del(w->attach, EWL_ATTACH_TYPE_NAME);
+       }
+
        /*
         * Clear out the callbacks, this is a bit tricky because we don't want
         * to continue using this widget after the callbacks have been
@@ -1227,13 +1250,16 @@
 
        if (w->fx_clip_box) {
                int sum;
+               int r, g, b, a;
+
                sum = ewl_widget_layer_sum_get(w);
                if (sum > ewl_embed_max_layer_get(emb))
                        ewl_embed_max_layer_set(emb, sum);
                evas_object_layer_set(w->fx_clip_box, sum);
 
-               evas_object_color_set(w->fx_clip_box, w->color.r, w->color.g, 
-                                                       w->color.b, w->color.a);
+               r = g = b = a = 255;
+               ewl_widget_color_get(w, &r, &g, &b, &a);
+               evas_object_color_set(w->fx_clip_box, r, g, b, a);
        }
 
        pc = EWL_CONTAINER(w->parent);
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_widget.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- ewl_widget.h        27 Sep 2005 03:26:32 -0000      1.13
+++ ewl_widget.h        28 Sep 2005 20:32:18 -0000      1.14
@@ -69,14 +69,11 @@
        Evas_Object    *fx_clip_box; /**< Clipping rectangle of widget */
 
        Evas_Object    *theme_object; /**< Appearance shown on canvas */
-       char           *name; /**< Unique identifier for this widget */
        char           *bit_state; /**< State of the appaarance */
        char           *appearance; /**< Key to lookup appearance in theme */
        char           *inheritance; /**< Key to lookup inhertiance of widget */
        int             layer; /**< Current layer of widget on canvas */
 
-       Ewl_Color_Set   color; /**< The colour of the widget */
-
        Ecore_Hash       *theme; /**< Overriding theme settings of this widget 
*/
        Ecore_Hash       *data; /**< Arbitrary data attached to this widget */
 };




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to