widget: Apply color_class parent-child relationship 14/93714/2
authorYoungbok Shin <youngb.shin@samsung.com>
Tue, 25 Oct 2016 10:50:22 +0000 (19:50 +0900)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Mon, 31 Oct 2016 10:52:36 +0000 (03:52 -0700)
It removes color_class hashes from elm_widget.
The color_class hash can be removed if we use the following function
to update color classes of internal objects: edje_object_color_class_parent_set().
But, the color_class hash of Elm_Widget_Item has to be maintained.
Because, the edje object of item could be recreated without recreation of Elm_Widget_Item.

@tizen_feature

Change-Id: I40cabe27a3d4976d47258479a2aac58a27ddac45

src/lib/elm_entry.c
src/lib/elm_entry.eo
src/lib/elm_priv.h
src/lib/elm_widget.c
src/lib/elm_widget.h

index a9f8ce410dc879042e5e534b555a27ffa4e25d7a..faf14d757bf84dca27299f499d9f71493af28e8d 100644 (file)
@@ -562,6 +562,9 @@ _create_cursor_handler(Evas_Object *obj, Elm_Entry_Data *sd)
                                   _cursor_handler_mouse_up_cb, obj);
    evas_object_layer_set(handle, EVAS_LAYER_MAX - 1);
    edje_object_signal_emit(handle, "edje,cursor,handle,show", "edje"); // FOR 2.3 theme
+   /* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
+   _elm_widget_color_class_parent_set(handle, sd->entry_edje);
+   /* END */
 }
 
 static void
@@ -2798,6 +2801,9 @@ _magnifier_create(void *data)
    sd->mgf_bg = edje_object_add(e);
    _elm_theme_object_set(data, sd->mgf_bg, "entry", "magnifier", "default");
    evas_object_show(sd->mgf_bg);
+   /* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
+   _elm_widget_color_class_parent_set(sd->mgf_bg, sd->entry_edje);
+   /* END */
 
    //Proxy
    sd->mgf_proxy = evas_object_image_add(e);
@@ -5299,6 +5305,10 @@ _create_selection_handlers(Evas_Object *obj, Elm_Entry_Data *sd)
                                   _start_handler_mouse_up_cb, obj);
    evas_object_show(handle);
 
+   /* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
+   _elm_widget_color_class_parent_set(handle, sd->entry_edje);
+   /* END */
+
    handle = edje_object_add(evas_object_evas_get(obj));
    sd->end_handler = handle;
    _elm_theme_object_set(obj, handle, "entry", "handler/end", style);
@@ -5315,6 +5325,10 @@ _create_selection_handlers(Evas_Object *obj, Elm_Entry_Data *sd)
    evas_object_event_callback_add(handle, EVAS_CALLBACK_MOUSE_UP,
                                   _end_handler_mouse_up_cb, obj);
    evas_object_show(handle);
+
+   /* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
+   _elm_widget_color_class_parent_set(handle, sd->entry_edje);
+   /* END */
 }
 
 EOLIAN static void
@@ -6615,6 +6629,10 @@ _elm_entry_scrollable_set(Eo *obj, Elm_Entry_Data *sd, Eina_Bool scroll)
                (sd->scr_edje, EVAS_HINT_FILL, EVAS_HINT_FILL);
 
              evas_object_propagate_events_set(sd->scr_edje, EINA_TRUE);
+
+             /* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
+             _elm_widget_color_class_parent_set(sd->scr_edje, sd->entry_edje);
+             /* END */
           }
 
         elm_widget_resize_object_set(obj, sd->scr_edje, EINA_TRUE);
@@ -7635,4 +7653,87 @@ _elm_entry_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED
 }
 //
 
+/* TIZEN_ONLY(20161025): Apply color_class parent-child relationship
+ * The resize object of elm_entry could be switch entry_edje into scr_edje
+ * when only elm_entry is scrollable.
+ * So, we need to update color_class only for entry_edje. */
+EOLIAN static Eina_Bool
+_elm_entry_elm_widget_class_color_set(Eo *obj, Elm_Entry_Data *sd, const char *color_class, int r, int g, int b, int a)
+{
+   Eina_Bool int_ret = EINA_TRUE;
+
+   int_ret &= _elm_widget_color_class_set_internal(obj, sd->entry_edje, color_class,
+                                                   r, g, b, a,
+                                                   -1, -1, -1, -1,
+                                                   -1, -1, -1, -1);
+
+   return int_ret;
+}
+
+EOLIAN static Eina_Bool
+_elm_entry_elm_widget_class_color_get(Eo *obj, Elm_Entry_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
+{
+   Eina_Bool int_ret = EINA_TRUE;
+
+   int_ret &= _elm_widget_color_class_get_internal(obj, sd->entry_edje, color_class,
+                                                   r, g, b, a,
+                                                   NULL, NULL, NULL, NULL,
+                                                   NULL, NULL, NULL, NULL);
+
+   return int_ret;
+}
+
+EOLIAN static Eina_Bool
+_elm_entry_elm_widget_class_color2_set(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const char *color_class, int r, int g, int b, int a)
+{
+   Eina_Bool int_ret = EINA_TRUE;
+
+   int_ret &= _elm_widget_color_class_set_internal(obj, sd->entry_edje, color_class,
+                                                   -1, -1, -1, -1,
+                                                   r, g, b, a,
+                                                   -1, -1, -1, -1);
+
+   return int_ret;
+}
+
+EOLIAN static Eina_Bool
+_elm_entry_elm_widget_class_color2_get(Eo *obj, Elm_Entry_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
+{
+   Eina_Bool int_ret = EINA_TRUE;
+
+   int_ret &= _elm_widget_color_class_get_internal(obj, sd->entry_edje, color_class,
+                                                   NULL, NULL, NULL, NULL,
+                                                   r, g, b, a,
+                                                   NULL, NULL, NULL, NULL);
+
+   return int_ret;
+}
+
+EOLIAN static Eina_Bool
+_elm_entry_elm_widget_class_color3_set(Eo *obj EINA_UNUSED, Elm_Entry_Data *sd, const char *color_class, int r, int g, int b, int a)
+{
+   Eina_Bool int_ret = EINA_TRUE;
+
+   int_ret &= _elm_widget_color_class_set_internal(obj, sd->entry_edje, color_class,
+                                                   -1, -1, -1, -1,
+                                                   -1, -1, -1, -1,
+                                                   r, g, b, a);
+
+   return int_ret;
+}
+
+EOLIAN static Eina_Bool
+_elm_entry_elm_widget_class_color3_get(Eo *obj, Elm_Entry_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
+{
+   Eina_Bool int_ret = EINA_TRUE;
+
+   int_ret &= _elm_widget_color_class_get_internal(obj, sd->entry_edje, color_class,
+                                                   NULL, NULL, NULL, NULL,
+                                                   NULL, NULL, NULL, NULL,
+                                                   r, g, b, a);
+
+   return int_ret;
+}
+/* END */
+
 #include "elm_entry.eo.c"
index 0175fff0d3e5460aa71a476967f4755aa5760a72..9e9b89a6d0ed1013ae9cee12403dc232f2b900b4 100644 (file)
@@ -1345,6 +1345,14 @@ class Elm.Entry (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interface,
       Elm.Widget.disable;
       Elm.Widget.sub_object_del;
       Elm.Widget.focus_next_manager_is;
+      /* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
+      Elm.Widget.class_color.set;
+      Elm.Widget.class_color.get;
+      Elm.Widget.class_color2.set;
+      Elm.Widget.class_color2.get;
+      Elm.Widget.class_color3.set;
+      Elm.Widget.class_color3.get;
+      /* END */
       Elm.Container.content_unset;
       Elm.Container.content_set;
       Elm.Layout.theme_enable;
index e60e064ed698d6323b912d8cb5522f69e5213669..ddeabde26d1defc8a742889722cf8f09caffdec5 100644 (file)
@@ -693,5 +693,15 @@ static inline void _elm_color_unpremul(int a, int *r, int *g, int *b)
 
 Eina_Bool _elm_widget_item_color_class_update(Elm_Widget_Item_Data *sd);
 //
+Eina_Bool _elm_widget_color_class_set_internal(Evas_Object *obj, Evas_Object *edje, const char *color_class,
+                                               int r, int g, int b, int a,
+                                               int r2, int g2, int b2, int a2,
+                                               int r3, int g3, int b3, int a3);
+Eina_Bool _elm_widget_color_class_get_internal(Evas_Object *obj, Evas_Object *edje, const char *color_class,
+                                               int *r, int *g, int *b, int *a,
+                                               int *r2, int *g2, int *b2, int *a2,
+                                               int *r3, int *g3, int *b3, int *a3);
+void _elm_widget_color_class_parent_set(Evas_Object *obj, Evas_Object *parent);
+void _elm_widget_color_class_parent_unset(Evas_Object *obj);
 
 #endif
index 557e62c1521188b3991b246953d5cf1c17897a22..f66b9742677ac6a55893506a30e194d96d870af4 100644 (file)
@@ -6052,10 +6052,6 @@ _elm_widget_eo_base_destructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
    }
    //
 
-   //TIZEN_ONLY(20161013): clean up elm color class feature
-   if (sd->color_classes)
-     ELM_SAFE_FREE(sd->color_classes, eina_hash_free);
-   //
    eo_do_super(obj, ELM_WIDGET_CLASS, eo_destructor());
    sd->on_destroy = EINA_FALSE;
 
@@ -6931,14 +6927,168 @@ _elm_widget_edje_class_get(const Eo_Class *klass, const char *style, const char
    return str;
 }
 
-Eina_Hash *
-_elm_widget_color_classes_get(Eo *obj)
+/* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
+Eina_Bool
+_elm_widget_color_class_set_internal(Evas_Object *obj, Evas_Object *edje, const char *color_class,
+                                     int r, int g, int b, int a,
+                                     int r2, int g2, int b2, int a2,
+                                     int r3, int g3, int b3, int a3)
+{
+   Eina_Bool int_ret = EINA_TRUE;
+   Eina_Stringshare *buf;
+   int temp_color[3][4] = { { r,  g,  b,  a },
+                            { r2, g2, b2, a2 },
+                            { r3, g3, b3, a3 } };
+
+   buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class);
+
+#define TEMP_COLOR(x, y) \
+   ((temp_color[x][y] == -1) ? &temp_color[x][y] : NULL)
+
+   edje_object_color_class_get(edje, buf,
+                               TEMP_COLOR(0, 0), TEMP_COLOR(0, 1), TEMP_COLOR(0, 2), TEMP_COLOR(0, 3),
+                               TEMP_COLOR(1, 0), TEMP_COLOR(1, 1), TEMP_COLOR(1, 2), TEMP_COLOR(1, 3),
+                               TEMP_COLOR(2, 0), TEMP_COLOR(2, 1), TEMP_COLOR(2, 2), TEMP_COLOR(2, 3));
+
+#undef TEMP_COLOR
+
+#define TEMP_COLOR(x, y) \
+   ((temp_color[x][y] == -1) ? 0 : temp_color[x][y])
+
+   int_ret &= edje_object_color_class_set(edje, buf,
+                                          TEMP_COLOR(0, 0), TEMP_COLOR(0, 1), TEMP_COLOR(0, 2), TEMP_COLOR(0, 3),
+                                          TEMP_COLOR(1, 0), TEMP_COLOR(1, 1), TEMP_COLOR(1, 2), TEMP_COLOR(1, 3),
+                                          TEMP_COLOR(2, 0), TEMP_COLOR(2, 1), TEMP_COLOR(2, 2), TEMP_COLOR(2, 3));
+
+#undef TEMP_COLOR
+
+   eina_stringshare_del(buf);
+
+   return int_ret;
+}
+
+Eina_Bool
+_elm_widget_color_class_get_internal(Evas_Object *obj, Evas_Object *edje, const char *color_class,
+                                     int *r, int *g, int *b, int *a,
+                                     int *r2, int *g2, int *b2, int *a2,
+                                     int *r3, int *g3, int *b3, int *a3)
+{
+   Eina_Bool int_ret = EINA_TRUE;
+   Eina_Stringshare *buf;
+
+   buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class);
+
+   int_ret &= edje_object_color_class_get(edje, buf,
+                                          r,  g,  b,  a,
+                                          r2, g2, b2, a2,
+                                          r3, g3, b3, a3);
+
+   eina_stringshare_del(buf);
+
+   return int_ret;
+}
+/* END */
+
+EOLIAN Eina_Bool
+_elm_widget_class_color_set(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int r, int g, int b, int a)
+{
+   Evas_Object *edje;
+   Eina_Bool int_ret = EINA_TRUE;
+
+   if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
+
+   edje = elm_layout_edje_get(obj);
+   int_ret &= _elm_widget_color_class_set_internal(obj, edje, color_class,
+                                                   r, g, b, a,
+                                                   -1, -1, -1, -1,
+                                                   -1, -1, -1, -1);
+
+   return int_ret;
+}
+
+EOLIAN Eina_Bool
+_elm_widget_class_color_get(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int *r, int *g, int *b, int *a)
+{
+   Evas_Object *edje;
+   Eina_Bool int_ret = EINA_TRUE;
+
+   if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
+
+   edje = elm_layout_edje_get(obj);
+   int_ret &= _elm_widget_color_class_get_internal(obj, edje, color_class,
+                                                   r, g, b, a,
+                                                   NULL, NULL, NULL, NULL,
+                                                   NULL, NULL, NULL, NULL);
+
+   return int_ret;
+}
+
+EOLIAN Eina_Bool
+_elm_widget_class_color2_set(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int r, int g, int b, int a)
+{
+   Evas_Object *edje;
+   Eina_Bool int_ret = EINA_TRUE;
+
+   if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
+
+   edje = elm_layout_edje_get(obj);
+   int_ret &= _elm_widget_color_class_set_internal(obj, edje, color_class,
+                                                   -1, -1, -1, -1,
+                                                   r, g, b, a,
+                                                   -1, -1, -1, -1);
+
+   return int_ret;
+}
+
+EOLIAN Eina_Bool
+_elm_widget_class_color2_get(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int *r, int *g, int *b, int *a)
 {
-   Elm_Widget_Smart_Data *sd = eo_data_scope_get(obj, ELM_WIDGET_CLASS);
+   Evas_Object *edje;
+   Eina_Bool int_ret = EINA_TRUE;
 
-   if ((!sd) || (!sd->color_classes)) return NULL;
+   if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
 
-   return sd->color_classes;
+   edje = elm_layout_edje_get(obj);
+   int_ret &= _elm_widget_color_class_get_internal(obj, edje, color_class,
+                                                   NULL, NULL, NULL, NULL,
+                                                   r, g, b, a,
+                                                   NULL, NULL, NULL, NULL);
+
+   return int_ret;
+}
+
+EOLIAN Eina_Bool
+_elm_widget_class_color3_set(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int r, int g, int b, int a)
+{
+   Evas_Object *edje;
+   Eina_Bool int_ret = EINA_TRUE;
+
+   if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
+
+   edje = elm_layout_edje_get(obj);
+   int_ret &= _elm_widget_color_class_set_internal(obj, edje, color_class,
+                                                   -1, -1, -1, -1,
+                                                   -1, -1, -1, -1,
+                                                   r, g, b, a);
+
+   return int_ret;
+}
+
+EOLIAN Eina_Bool
+_elm_widget_class_color3_get(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED, const char *color_class, int *r, int *g, int *b, int *a)
+{
+   Evas_Object *edje;
+   Eina_Bool int_ret = EINA_TRUE;
+
+   if (!eo_isa(obj, ELM_LAYOUT_CLASS)) return EINA_FALSE;
+
+   edje = elm_layout_edje_get(obj);
+   int_ret &= _elm_widget_color_class_get_internal(obj, edje, color_class,
+                                                   NULL, NULL, NULL, NULL,
+                                                   NULL, NULL, NULL, NULL,
+                                                   r, g, b, a);
+
+   return int_ret;
 }
 
 #define ELM_COLOR_CLASS_UPDATE(obj, hash, cond)                                  \
@@ -6963,11 +7113,6 @@ _elm_widget_color_classes_get(Eo *obj)
    eina_iterator_free(itr);                                                      \
    return int_ret
 
-Eina_Bool
-_elm_widget_color_class_update(Eo *obj, Eina_Hash *color_classes)
-{
-   ELM_COLOR_CLASS_UPDATE(obj, color_classes, (!obj) || (!color_classes));
-}
 
 #define CHECK_BOUND(x)                                                           \
    if (x > 0xff) x = 0xff;                                                       \
@@ -7015,16 +7160,6 @@ _elm_widget_color_class_update(Eo *obj, Eina_Hash *color_classes)
    eina_stringshare_del(buf);                                                    \
    return int_ret
 
-EOLIAN Eina_Bool
-_elm_widget_class_color_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *color_class, int r, int g, int b, int a)
-{
-   ELM_COLOR_CLASS_SET_START(obj, r, g, b, a);
-
-   int_ret &= _elm_widget_color_class_update(obj, sd->color_classes);
-
-   ELM_COLOR_CLASS_SET_END();
-}
-
 #define ELM_COLOR_CLASS_GET(obj, cr, cg, cb, ca)                                 \
    Eina_Bool int_ret = EINA_FALSE;                                               \
    Edje_Color_Class *cc;                                                         \
@@ -7052,46 +7187,6 @@ _elm_widget_class_color_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *colo
    eina_stringshare_del(buf);                                                    \
    return int_ret
 
-
-EOLIAN Eina_Bool
-_elm_widget_class_color_get(Eo *obj, Elm_Widget_Smart_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
-{
-   ELM_COLOR_CLASS_GET(obj, r, g, b, a);
-}
-
-EOLIAN Eina_Bool
-_elm_widget_class_color2_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *color_class, int r, int g, int b, int a)
-{
-   ELM_COLOR_CLASS_SET_START(obj, r2, g2, b2, a2);
-
-   int_ret &= _elm_widget_color_class_update(obj, sd->color_classes);
-
-   ELM_COLOR_CLASS_SET_END();
-}
-
-EOLIAN Eina_Bool
-_elm_widget_class_color2_get(Eo *obj, Elm_Widget_Smart_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
-{
-   ELM_COLOR_CLASS_GET(obj, r2, g2, b2, a2);
-}
-
-EOLIAN Eina_Bool
-_elm_widget_class_color3_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *color_class, int r, int g, int b, int a)
-{
-
-   ELM_COLOR_CLASS_SET_START(obj, r3, g3, b3, a3);
-
-   int_ret &= _elm_widget_color_class_update(obj, sd->color_classes);
-
-   ELM_COLOR_CLASS_SET_END();
-}
-
-EOLIAN Eina_Bool
-_elm_widget_class_color3_get(Eo *obj, Elm_Widget_Smart_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
-{
-   ELM_COLOR_CLASS_GET(obj, r3, g3, b3, a3);
-}
-
 Eina_Bool
 _elm_widget_item_color_class_update(Elm_Widget_Item_Data *sd)
 {
@@ -7147,6 +7242,47 @@ _elm_widget_item_class_color3_get(Eo *obj, Elm_Widget_Item_Data *sd, const char
 }
 //
 
+/* TIZEN_ONLY(20161025): Apply color_class parent-child relationship */
+void
+_elm_widget_color_class_parent_set(Evas_Object *obj, Evas_Object *parent)
+{
+   Evas_Object *edje = NULL, *parent_edje = NULL;
+
+   if (!obj || !parent) return;
+
+   if (eo_isa(obj, ELM_LAYOUT_CLASS))
+     edje =  elm_layout_edje_get(obj);
+   else if (eo_isa(obj, EDJE_OBJECT_CLASS))
+     edje = obj;
+
+   if (eo_isa(parent, ELM_LAYOUT_CLASS))
+     parent_edje =  elm_layout_edje_get(parent);
+   else if (eo_isa(parent, EDJE_OBJECT_CLASS))
+     parent_edje = parent;
+
+   if (!edje || !parent_edje) return;
+
+   edje_object_color_class_parent_set(edje, parent_edje);
+}
+
+void
+_elm_widget_color_class_parent_unset(Evas_Object *obj)
+{
+   Evas_Object *edje = NULL;
+
+   if (!obj) return;
+
+   if (eo_isa(obj, ELM_LAYOUT_CLASS))
+     edje =  elm_layout_edje_get(obj);
+   else if (eo_isa(obj, EDJE_OBJECT_CLASS))
+     edje = obj;
+
+   if (!edje) return;
+
+   edje_object_color_class_parent_unset(edje);
+}
+/* END */
+
 //TIZEN_ONLY(20160527): widget: add AtspiAction interface to all widgets and widget_items, add handlers for reading stopped/cancelled
 EOLIAN const Elm_Atspi_Action *
 _elm_widget_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd EINA_UNUSED)
index 41bef6d92c47426730d53c3b5175cc7b5b59c707..4417d20f995790996a2fb462dfebbc76071147d0 100644 (file)
@@ -439,9 +439,6 @@ typedef struct _Elm_Widget_Smart_Data
    int                           orient_mode; /* -1 is disabled */
    Elm_Focus_Move_Policy         focus_move_policy;
    Elm_Focus_Region_Show_Mode    focus_region_show_mode;
-   //TIZEN_ONLY(20161013): clean up elm color class feature
-   Eina_Hash                     *color_classes;
-   //
    /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
    Evas_BiDi_Direction           paragraph_direction : 2;
    Eina_Bool                     inherit_paragraph_direction : 1;
@@ -937,7 +934,6 @@ _elm_widget_sub_object_redirect_to_top(Evas_Object *obj, Evas_Object *sobj)
 }
 
 //TIZEN_ONLY(20161013): clean up elm color class feature
-Eina_Bool _elm_widget_color_class_update(Eo *obj, Eina_Hash *color_classes);
 Eina_Bool _elm_widget_item_color_class_update(Elm_Widget_Item_Data *sd);
 //