edje: Add color class parent-child relationship with APIs 79/93579/5
authorYoungbok Shin <youngb.shin@samsung.com>
Tue, 25 Oct 2016 04:16:24 +0000 (13:16 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Mon, 31 Oct 2016 10:34:24 +0000 (19:34 +0900)
It adds the following APIs
  void edje_object_color_class_parent_set(Evas_Object *obj, Evas_Object *parent)
  void edje_object_color_class_parent_unset(Evas_Object *obj)

If there is a color_class parent object, the color of object will be
follow parent object's color_class.
@tizen_feature

Change-Id: Ia89a26dab596a7dcfcf120dfffcc9787509292c2

src/lib/edje/edje_entry.c
src/lib/edje/edje_object.eo
src/lib/edje/edje_private.h
src/lib/edje/edje_textblock_styles.c
src/lib/edje/edje_util.c

index 9ffecfc..34be4ec 100644 (file)
@@ -709,6 +709,11 @@ _sel_update(Edje *ed, Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o, Entr
                   evas_object_show(ob);
                   sel->obj_fg = ob;
                   _edje_subobj_register(ed, sel->obj_fg);
+
+                  /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+                  edje_object_color_class_parent_set(sel->obj_bg, ed->obj);
+                  edje_object_color_class_parent_set(sel->obj_fg, ed->obj);
+                  /* END */
                }
              else
                {
@@ -1081,6 +1086,11 @@ _anchors_update(Evas_Textblock_Cursor *c EINA_UNUSED, Evas_Object *o, Entry *en)
                        sel->obj_fg = ob;
                        _edje_subobj_register(ed, sel->obj_fg);
 
+                       /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+                       edje_object_color_class_parent_set(sel->obj_bg, ed->obj);
+                       edje_object_color_class_parent_set(sel->obj_fg, ed->obj);
+                       /* END */
+
                        ob = evas_object_rectangle_add(ed->base->evas);
                        evas_object_color_set(ob, 0, 0, 0, 0);
                        evas_object_smart_member_add(ob, smart);
@@ -2766,6 +2776,11 @@ _edje_entry_real_part_init(Edje *ed, Edje_Real_Part *rp, Ecore_IMF_Context *ic)
    evas_object_pass_events_set(en->cursor_fg, EINA_TRUE);
    _edje_subobj_register(ed, en->cursor_fg);
 
+   /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+   edje_object_color_class_parent_set(en->cursor_bg, ed->obj);
+   edje_object_color_class_parent_set(en->cursor_fg, ed->obj);
+   /* END */
+
    /* A proxy to the main cursor. */
    if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE)
      {
@@ -4804,5 +4819,4 @@ void _edje_entry_thaw(Edje_Real_Part *rp)
    _edje_entry_real_part_configure(en->ed, rp);
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////
-
 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
index c1e5661..9b45aa3 100644 (file)
@@ -2571,6 +2571,29 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File)
            @since 1.17.0]]
          return: bool; [[$true, on success or $false, on error]]
       }
+      /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+      color_class_parent_set {
+         [[Sets the parent object for color class.
+
+           \@internal
+           \@if MOBILE \@since_tizen 3.0
+           \@elseif WEARABLE \@since_tizen 3.0
+           \@endif
+         ]]
+         params {
+            @in parent: Evas.Object *; [[The parent object for color class]]
+         }
+      }
+      color_class_parent_unset {
+         [[Unsets the parent object color class.
+
+           \@internal
+           \@if MOBILE \@since_tizen 3.0
+           \@elseif WEARABLE \@since_tizen 3.0
+           \@endif
+         ]]
+      }
+      /* END */
       @property size_class {
          set {
             [[Sets the object size class.
index a486a93..a0bb795 100644 (file)
@@ -1680,6 +1680,11 @@ struct _Edje
    Eina_List            *styles;
    /* END */
 
+   /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+   Evas_Object          *cc_parent;
+   Eina_List            *cc_children;
+   /* END */
+
    Edje_Perspective     *persp;
 
    const Edje_Signal_Callback_Group *callbacks;
@@ -2626,7 +2631,11 @@ void _edje_file_textblock_style_all_update(Edje_File *edf);
 void _edje_textblock_styles_color_class_cache_free(Edje *ed, const char *class_name);
 void _edje_textblock_styles_text_class_cache_free(Edje *ed, const char *class_name);
 /* END */
+/* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs
 void _edje_textblock_style_all_update(Edje *ed);
+ */
+void _edje_textblock_style_all_update(Edje *ed, Eina_Bool force);
+/* END */
 void _edje_textblock_style_parse_and_fix(Edje_File *edf);
 void _edje_textblock_style_cleanup(Edje_File *edf);
 Edje_File *_edje_cache_file_coll_open(const Eina_File *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, Edje *ed);
index 5195352..b50e245 100644 (file)
@@ -484,8 +484,12 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl, Eina_Bool force)
  *
  * @param ed The edje containing styles which need to be updated
  */
+/* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs
 void
 _edje_textblock_style_all_update(Edje *ed)
+ */
+void
+_edje_textblock_style_all_update(Edje *ed, Eina_Bool force)
 {
    Eina_List *l;
    Edje_Style *stl;
@@ -497,7 +501,7 @@ _edje_textblock_style_all_update(Edje *ed)
       _edje_textblock_style_update(ed, stl, EINA_FALSE);
     */
    EINA_LIST_FOREACH(ed->styles, l, stl)
-      _edje_textblock_style_update(ed, stl, EINA_FALSE);
+      _edje_textblock_style_update(ed, stl, force);
    /* END */
 }
 
index 1e8ab1f..6073d0d 100644 (file)
@@ -685,7 +685,7 @@ edje_color_class_set(const char *color_class, int r, int g, int b, int a, int r2
 #endif
         /* TIZEN_ONLY(20161019): update color_class/text_class logic for textblock */
         _edje_textblock_styles_color_class_cache_free(er->ed, color_class);
-        _edje_textblock_style_all_update(er->ed);
+        _edje_textblock_style_all_update(er->ed, EINA_FALSE);
         /* END */
         _edje_recalc(er->ed);
         _edje_emit(er->ed, "color_class,set", color_class);
@@ -764,7 +764,7 @@ edje_color_class_del(const char *color_class)
 #endif
         /* TIZEN_ONLY(20161019): update color_class/text_class logic for textblock */
         _edje_textblock_styles_color_class_cache_free(er->ed, color_class);
-        _edje_textblock_style_all_update(er->ed);
+        _edje_textblock_style_all_update(er->ed, EINA_FALSE);
         /* END */
         _edje_recalc(er->ed);
         _edje_emit(er->ed, "color_class,del", color_class);
@@ -882,6 +882,39 @@ _edje_color_class_list_foreach(const Eina_Hash *hash EINA_UNUSED, const void *ke
    return EINA_TRUE;
 }
 
+/* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+static void
+_edje_color_class_children_update(Edje *ed, const char *color_class)
+{
+   Evas_Object *child;
+   Eina_List *l;
+
+   if (!ed) return;
+
+   EINA_LIST_FOREACH(ed->cc_children, l, child)
+     {
+        Edje *cc_child_ed = _edje_fetch(child);
+
+        cc_child_ed->dirty = EINA_TRUE;
+        cc_child_ed->recalc_call = EINA_TRUE;
+#ifdef EDJE_CALC_CACHE
+        cc_child_ed->all_part_change = EINA_TRUE;
+#endif
+        if (color_class)
+          {
+             _edje_textblock_styles_color_class_cache_free(cc_child_ed, color_class);
+             _edje_textblock_style_all_update(cc_child_ed, EINA_FALSE);
+          }
+        else
+          {
+             _edje_textblock_style_all_update(cc_child_ed, EINA_TRUE);
+          }
+
+        _edje_recalc(cc_child_ed);
+     }
+}
+/* END */
+
 EOLIAN Eina_Bool
 _edje_object_color_class_set(Eo *obj EINA_UNUSED, Edje *ed, 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)
 {
@@ -963,11 +996,15 @@ update_color_class:
 
    /* TIZEN_ONLY(20161019): update color_class/text_class logic for textblock */
    _edje_textblock_styles_color_class_cache_free(ed, color_class);
-   _edje_textblock_style_all_update(ed);
+   _edje_textblock_style_all_update(ed, EINA_FALSE);
    /* END */
    _edje_recalc(ed);
    _edje_emit(ed, "color_class,set", color_class);
 
+   /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+   _edje_color_class_children_update(ed, color_class);
+   /* END */
+
    return EINA_TRUE;
 }
 
@@ -1043,10 +1080,14 @@ edje_object_color_class_del(Evas_Object *obj, const char *color_class)
 #endif
    /* TIZEN_ONLY(20161019): update color_class/text_class logic for textblock */
    _edje_textblock_styles_color_class_cache_free(ed, color_class);
-   _edje_textblock_style_all_update(ed);
+   _edje_textblock_style_all_update(ed, EINA_FALSE);
    /* END */
    _edje_recalc(ed);
    _edje_emit(ed, "color_class,del", color_class);
+
+   /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+   _edje_color_class_children_update(ed, color_class);
+   /* END */
 }
 
 EOLIAN Eina_Bool
@@ -1084,6 +1125,9 @@ _edje_object_color_class_clear(const Eo *obj EINA_UNUSED, Edje *ed)
 #ifdef EDJE_CALC_CACHE
    ed->all_part_change = EINA_TRUE;
 #endif
+   /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+   _edje_textblock_style_all_update(ed, EINA_TRUE);
+   /* END */
    _edje_recalc(ed);
 
    EINA_LIST_FREE(fdata.list, color_class)
@@ -1092,9 +1136,102 @@ _edje_object_color_class_clear(const Eo *obj EINA_UNUSED, Edje *ed)
         free(color_class);
      }
 
+   /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+   _edje_color_class_children_update(ed, NULL);
+   /* END */
+
    return int_ret;
 }
 
+/* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+static void
+_edje_object_color_class_parent_del_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+   Evas_Object *child;
+   Eina_List *l, *ll;
+   Edje *ed = _edje_fetch(obj);
+
+   if (!ed) return;
+
+   EINA_LIST_FOREACH_SAFE(ed->cc_children, l, ll, child)
+      edje_object_color_class_parent_unset(child);
+}
+
+static void
+_edje_object_color_class_child_del_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+   Edje *ed = _edje_fetch(obj);
+
+   if (!ed) return;
+
+   edje_object_color_class_parent_unset(obj);
+}
+
+static void
+_edje_object_color_class_child_add(Evas_Object *obj, Evas_Object *child)
+{
+   Edje *ed = _edje_fetch(obj);
+
+   if (!ed) return;
+
+   if (!ed->cc_children)
+     evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _edje_object_color_class_parent_del_cb, NULL);
+
+   ed->cc_children = eina_list_append(ed->cc_children, child);
+}
+
+static void
+_edje_object_color_class_child_remove(Evas_Object *obj, Evas_Object *child)
+{
+   Edje *ed = _edje_fetch(obj);
+
+   if (!ed) return;
+
+   ed->cc_children = eina_list_remove(ed->cc_children, child);
+
+   if (!ed->cc_children)
+     evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, _edje_object_color_class_parent_del_cb, NULL);
+}
+
+EOLIAN void
+_edje_object_color_class_parent_set(Eo *obj, Edje *ed, Evas_Object *parent)
+{
+   if (!parent) return;
+
+   if (ed->cc_parent) _edje_object_color_class_child_remove(ed->cc_parent, obj);
+
+   if (!ed->cc_parent)
+     evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _edje_object_color_class_child_del_cb, NULL);
+
+   ed->cc_parent = parent;
+   _edje_object_color_class_child_add(parent, obj);
+
+   ed->dirty = EINA_TRUE;
+   ed->recalc_call = EINA_TRUE;
+#ifdef EDJE_CALC_CACHE
+   ed->all_part_change = EINA_TRUE;
+#endif
+   _edje_textblock_style_all_update(ed, EINA_TRUE);
+   _edje_recalc(ed);
+}
+
+EOLIAN void
+_edje_object_color_class_parent_unset(Eo *obj, Edje *ed)
+{
+   if (ed->cc_parent) _edje_object_color_class_child_remove(ed->cc_parent, obj);
+   ed->cc_parent = NULL;
+   evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, _edje_object_color_class_child_del_cb, NULL);
+
+   ed->dirty = EINA_TRUE;
+   ed->recalc_call = EINA_TRUE;
+#ifdef EDJE_CALC_CACHE
+   ed->all_part_change = EINA_TRUE;
+#endif
+   _edje_textblock_style_all_update(ed, EINA_TRUE);
+   _edje_recalc(ed);
+}
+/* END */
+
 typedef struct _Edje_File_Color_Class_Iterator Edje_File_Color_Class_Iterator;
 struct _Edje_File_Color_Class_Iterator
 {
@@ -1227,7 +1364,11 @@ edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size siz
          */
         _edje_textblock_styles_text_class_cache_free(er->ed, text_class);
         /* END */
+        /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs
         _edje_textblock_style_all_update(er->ed);
+         */
+        _edje_textblock_style_all_update(er->ed, EINA_FALSE);
+        /* END */
 #ifdef EDJE_CALC_CACHE
         er->ed->text_part_change = EINA_TRUE;
 #endif
@@ -1294,7 +1435,11 @@ edje_text_class_del(const char *text_class)
          */
         _edje_textblock_styles_text_class_cache_free(er->ed, text_class);
         /* END */
+        /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs
         _edje_textblock_style_all_update(er->ed);
+         */
+        _edje_textblock_style_all_update(er->ed, EINA_FALSE);
+        /* END */
 #ifdef EDJE_CALC_CACHE
         er->ed->text_part_change = EINA_TRUE;
 #endif
@@ -1394,7 +1539,11 @@ _edje_object_text_class_set(Eo *obj EINA_UNUSED, Edje *ed, const char *text_clas
     */
    _edje_textblock_styles_text_class_cache_free(ed, text_class);
    /* END */
+   /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs
    _edje_textblock_style_all_update(ed);
+    */
+   _edje_textblock_style_all_update(ed, EINA_FALSE);
+   /* END */
    _edje_recalc(ed);
 
    return EINA_TRUE;
@@ -5711,6 +5860,52 @@ _edje_color_class_recursive_find(const Edje *ed, const char *color_class)
 }
  */
 
+/* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+/* Get Edje_Color_Class from the most near ancestor */
+static Edje_Color_Class *
+_edje_color_class_parent_find(const Edje *ed, const char *color_class)
+{
+   Edje *cc_parent_ed;
+   Edje_Color_Class *cc = NULL;
+
+   if (!ed) return NULL;
+
+   cc_parent_ed = _edje_fetch(ed->cc_parent);
+
+   while(cc_parent_ed)
+     {
+        cc = eina_hash_find(cc_parent_ed->color_classes, color_class);
+        if (cc) return cc;
+
+        cc_parent_ed = _edje_fetch(cc_parent_ed->cc_parent);
+     }
+
+   return NULL;
+}
+
+/* Get Edje_Color_Class from the most near ancestor */
+static Edje_Color_Class *
+_edje_color_class_parent_recursive_find(const Edje *ed, const char *color_class)
+{
+   Edje *cc_parent_ed;
+   Edje_Color_Class *cc = NULL;
+
+   if (!ed) return NULL;
+
+   cc_parent_ed = _edje_fetch(ed->cc_parent);
+
+   while(cc_parent_ed)
+     {
+        cc = _edje_hash_find_helper(cc_parent_ed->color_classes, color_class);
+        if (cc) return cc;
+
+        cc_parent_ed = _edje_fetch(cc_parent_ed->cc_parent);
+     }
+
+   return NULL;
+}
+/* END */
+
 Edje_Color_Class *
 _edje_color_class_recursive_find(const Edje *ed, const Edje_File *edf, const char *color_class)
 {
@@ -5722,6 +5917,12 @@ _edje_color_class_recursive_find(const Edje *ed, const Edje_File *edf, const cha
    if (ed) cc = _edje_hash_find_helper(ed->color_classes, color_class);
    if (cc) return cc;
 
+   /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+   if (ed) cc = _edje_color_class_parent_recursive_find(ed, color_class);
+   if (cc) return cc;
+   /* END */
+
+
    /* next look through the global scope */
    cc = _edje_hash_find_helper(_edje_color_class_hash, color_class);
    if (cc) return cc;
@@ -5754,6 +5955,11 @@ _edje_color_class_find(const Edje *ed, const char *color_class)
    /* END */
    if (cc) return cc;
 
+   /* TIZEN_ONLY(20161025): Add color class parent-child relationship with APIs */
+   if (ed) cc = _edje_color_class_parent_find(ed, color_class);
+   if (cc) return cc;
+   /* END */
+
    /* next look through the global scope */
    cc = eina_hash_find(_edje_color_class_hash, color_class);
    if (cc) return cc;