elementary: add item customization interface 51/89751/4
authorJee-Yong Um <conr2d@gmail.com>
Tue, 27 Sep 2016 01:21:02 +0000 (10:21 +0900)
committerJee-Yong Um <conr2d@gmail.com>
Thu, 29 Sep 2016 06:03:26 +0000 (15:03 +0900)
Signed-Off-By: Jee-Yong Um <jc9.um@samsung.com>
Change-Id: I3f5bb3c7e6d41f55340e9f3095131b94332fd225

src/lib/elm_gengrid.c
src/lib/elm_priv.h
src/lib/elm_widget.c
src/lib/elm_widget.h
src/lib/elm_widget_item.eo
src/mobile_lib/elm_genlist.c

index d8a9434..e1b3686 100644 (file)
@@ -1288,6 +1288,10 @@ _item_unrealize_cb(Elm_Gen_Item *it)
         ELM_SAFE_FREE(VIEW(it), evas_object_del);
         ELM_SAFE_FREE(it->spacer, evas_object_del);
      }
+//TIZEN_ONLY(20160927): add item customization interface
+   if (it->base->color_classes)
+     edje_object_color_class_clear(VIEW(it));
+//
 }
 
 static char *
@@ -1404,6 +1408,11 @@ _item_realize(Elm_Gen_Item *it)
           it->item->nocache_once = EINA_FALSE;
      }
 
+//TIZEN_ONLY(20160927): add item customization interface
+   if (it->base->color_classes)
+     _elm_widget_item_color_class_update(it->base);
+//
+
    if (it->spacer && edje_object_part_exists(VIEW(it), "elm.swallow.pad"))
      {
         it->spacer =
index c729e61..3032819 100644 (file)
@@ -678,6 +678,8 @@ static inline void _elm_color_unpremul(int a, int *r, int *g, int *b)
      }
 }
 #undef _DIV_0xFF
+
+Eina_Bool _elm_widget_item_color_class_update(Elm_Widget_Item_Data *sd);
 //
 
 #endif
index 5325341..c54bd8e 100644 (file)
@@ -4714,6 +4714,9 @@ _elm_widget_item_eo_base_destructor(Eo *eo_item, Elm_Widget_Item_Data *item)
    }
    //
 
+   if (item->color_classes)
+     ELM_SAFE_FREE(item->color_classes, eina_hash_free);
+
    EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
 
    eo_do_super(eo_item, ELM_WIDGET_ITEM_CLASS, eo_destructor());
@@ -6938,7 +6941,6 @@ _elm_widget_edje_class_get(const Eo_Class *klass, const char *style, const char
    Eina_Bool int_ret = EINA_FALSE; \
    if (eo_isa(obj, klass)) \
      { \
-        int r2 = 0, g2 = 0, b2 = 0, a2 = 0, r3 = 0, g3 = 0, b3 = 0, a3 = 0; \
         buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class); \
         _elm_color_unpremul(a, &r, &g, &b)
 
@@ -6956,8 +6958,12 @@ EOLIAN Eina_Bool
 _elm_widget_color_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_UPPER(ELM_LAYOUT_CLASS);
+
+   int r2 = 0, g2 = 0, b2 = 0, a2 = 0, r3 = 0, g3 = 0, b3 = 0, a3 = 0;
+
    edje_object_color_class_get(sd->resize_obj, buf, NULL, NULL, NULL, NULL, &r2, &g2, &b2, &a2, &r3, &g3, &b3, &a3);
    int_ret = edje_object_color_class_set(sd->resize_obj, buf, r, g, b, a, r2, g2, b2, a2, r3, g3, b3, a3);
+
    ELM_COLOR_CLASS_SET_LOWER();
 }
 
@@ -6983,7 +6989,9 @@ EOLIAN Eina_Bool
 _elm_widget_color_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_UPPER(ELM_LAYOUT_CLASS);
+
    int_ret = edje_object_color_class_get(sd->resize_obj, buf, r, g, b, a, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+
    ELM_COLOR_CLASS_GET_LOWER();
 }
 
@@ -6991,8 +6999,12 @@ EOLIAN Eina_Bool
 _elm_widget_color_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_UPPER(ELM_LAYOUT_CLASS);
+
+   int r2 = 0, g2 = 0, b2 = 0, a2 = 0, r3 = 0, g3 = 0, b3 = 0, a3 = 0;
+
    edje_object_color_class_get(sd->resize_obj, buf, &r2, &g2, &b2, &a2, NULL, NULL, NULL, NULL, &r3, &g3, &b3, &a3);
    int_ret = edje_object_color_class_set(sd->resize_obj, buf, r2, g2, b2, a2, r, g, b, a, r3, g3, b3, a3);
+
    ELM_COLOR_CLASS_SET_LOWER();
 }
 
@@ -7000,7 +7012,9 @@ EOLIAN Eina_Bool
 _elm_widget_color_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_UPPER(ELM_LAYOUT_CLASS);
+
    int_ret = edje_object_color_class_get(sd->resize_obj, buf, NULL, NULL, NULL, NULL, r, g, b, a, NULL, NULL, NULL, NULL);
+
    ELM_COLOR_CLASS_GET_LOWER();
 }
 
@@ -7008,8 +7022,12 @@ EOLIAN Eina_Bool
 _elm_widget_color_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_UPPER(ELM_LAYOUT_CLASS);
+
+   int r2 = 0, g2 = 0, b2 = 0, a2 = 0, r3 = 0, g3 = 0, b3 = 0, a3 = 0;
+
    edje_object_color_class_get(sd->resize_obj, buf, &r2, &g2, &b2, &a2, &r3, &g3, &b3, &a3, NULL, NULL, NULL, NULL);
    int_ret = edje_object_color_class_set(sd->resize_obj, buf, r2, g2, b2, a2, r3, g3, b3, a3, r, g, b, a);
+
    ELM_COLOR_CLASS_SET_LOWER();
 }
 
@@ -7017,7 +7035,142 @@ EOLIAN Eina_Bool
 _elm_widget_color_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_UPPER(ELM_LAYOUT_CLASS);
+
    int_ret = edje_object_color_class_get(sd->resize_obj, buf, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, r, g, b, a);
+
+   ELM_COLOR_CLASS_GET_LOWER();
+}
+
+Eina_Bool
+_elm_widget_item_color_class_update(Elm_Widget_Item_Data *sd)
+{
+   Evas_Object *edje;
+   Eina_Iterator *itr;
+   Edje_Color_Class *cc;
+   Eina_Bool int_ret = EINA_TRUE;
+
+   if (!sd->color_classes || !sd->view) return EINA_FALSE;
+
+   if (eo_isa(sd->view, ELM_LAYOUT_CLASS))
+     edje = elm_layout_edje_get(sd->view);
+   else
+     edje = sd->view;
+
+   itr = eina_hash_iterator_data_new(sd->color_classes);
+   EINA_ITERATOR_FOREACH(itr, cc)
+     {
+        int_ret &= edje_object_color_class_set(edje, cc->name,
+                                               cc->r, cc->g, cc->b, cc->a,
+                                               cc->r2, cc->g2, cc->b2, cc->a2,
+                                               cc->r3, cc->g3, cc->b3, cc->a3);
+     }
+   eina_iterator_free(itr);
+   return int_ret;
+}
+
+#define CHECK_BOUND(x) \
+   if (x > 0xFF) x = 0xff; \
+   else if (x < 0) x = 0
+
+#define ELM_ITEM_COLOR_CLASS_SET(cr, cg, cb, ca) \
+   Edje_Color_Class *cc = NULL; \
+   CHECK_BOUND(r); \
+   CHECK_BOUND(g); \
+   CHECK_BOUND(b); \
+   CHECK_BOUND(a); \
+   if (!sd->color_classes) \
+     sd->color_classes = eina_hash_string_small_new(free); \
+   else \
+     cc = eina_hash_find(sd->color_classes, buf); \
+   if (!cc) \
+     { \
+        cc = calloc(1, sizeof(Edje_Color_Class)); \
+        cc->name = eina_stringshare_add(buf); \
+        if (!cc->name) \
+          { \
+             free(cc); \
+             eina_stringshare_del(buf); \
+             return EINA_FALSE; \
+          } \
+        eina_hash_direct_add(sd->color_classes, cc->name, cc); \
+     } \
+   else if ((cc->cr == r) && (cc->cg == g) && (cc->cb == b) && (cc->ca == a)) \
+     { \
+        eina_stringshare_del(buf); \
+        return EINA_TRUE; \
+     } \
+   cc->cr = r; \
+   cc->cg = g; \
+   cc->cb = b; \
+   cc->ca = a; \
+   int_ret = EINA_TRUE; \
+   if (sd->view) \
+     int_ret &= _elm_widget_item_color_class_update(sd)
+
+EOLIAN Eina_Bool
+_elm_widget_item_color_class_color_set(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int r, int g, int b, int a)
+{
+   ELM_COLOR_CLASS_SET_UPPER(ELM_WIDGET_ITEM_CLASS);
+   ELM_ITEM_COLOR_CLASS_SET(r, g, b, a);
+   ELM_COLOR_CLASS_SET_LOWER();
+}
+
+#define ELM_ITEM_COLOR_CLASS_GET(cr, cg, cb, ca) \
+   Edje_Color_Class *cc; \
+   if ((!sd->color_classes) || !(cc = eina_hash_find(sd->color_classes, buf))) \
+     { \
+        if (r) *r = 0; \
+        if (g) *g = 0; \
+        if (b) *b = 0; \
+        if (a) *a = 0; \
+        int_ret = EINA_FALSE; \
+     } \
+   else \
+     { \
+        if (r) *r = cc->cr; \
+        if (g) *g = cc->cg; \
+        if (b) *b = cc->cb; \
+        if (a) *a = cc->ca; \
+        int_ret = EINA_TRUE; \
+     }
+
+EOLIAN Eina_Bool
+_elm_widget_item_color_class_color_get(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
+{
+   ELM_COLOR_CLASS_GET_UPPER(ELM_WIDGET_ITEM_CLASS);
+   ELM_ITEM_COLOR_CLASS_GET(r, g, b, a);
+   ELM_COLOR_CLASS_GET_LOWER();
+}
+
+EOLIAN Eina_Bool
+_elm_widget_item_color_class_color2_set(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int r, int g, int b, int a)
+{
+   ELM_COLOR_CLASS_SET_UPPER(ELM_WIDGET_ITEM_CLASS);
+   ELM_ITEM_COLOR_CLASS_SET(r2, g2, b2, a2);
+   ELM_COLOR_CLASS_SET_LOWER();
+}
+
+EOLIAN Eina_Bool
+_elm_widget_item_color_class_color2_get(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
+{
+   ELM_COLOR_CLASS_GET_UPPER(ELM_WIDGET_ITEM_CLASS);
+   ELM_ITEM_COLOR_CLASS_GET(r2, g2, b2, a2);
+   ELM_COLOR_CLASS_GET_LOWER();
+}
+
+EOLIAN Eina_Bool
+_elm_widget_item_color_class_color3_set(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int r, int g, int b, int a)
+{
+   ELM_COLOR_CLASS_SET_UPPER(ELM_WIDGET_ITEM_CLASS);
+   ELM_ITEM_COLOR_CLASS_SET(r3, g3, b3, a3);
+   ELM_COLOR_CLASS_SET_LOWER();
+}
+
+EOLIAN Eina_Bool
+_elm_widget_item_color_class_color3_get(Eo *obj, Elm_Widget_Item_Data *sd, const char *color_class, int *r, int *g, int *b, int *a)
+{
+   ELM_COLOR_CLASS_GET_UPPER(ELM_WIDGET_ITEM_CLASS);
+   ELM_ITEM_COLOR_CLASS_GET(r3, g3, b3, a3);
    ELM_COLOR_CLASS_GET_LOWER();
 }
 //
index fbd1fa3..915799b 100644 (file)
@@ -669,6 +669,9 @@ struct _Elm_Widget_Item_Data
    //TIZEN_ONLY(20150731) : add i18n support for name and description
    const char                    *atspi_translation_domain;
    ///
+   //TIZEN_ONLY(20160927): add customization interface
+   Eina_Hash                     *color_classes;
+   //
 
    Eina_Bool                      disabled : 1;
    Eina_Bool                      on_deletion : 1;
index b23f708..cc53b7d 100644 (file)
@@ -532,6 +532,85 @@ class Elm.Widget_Item (Eo.Base, Elm_Interface_Atspi_Accessible,
                      dir: Elm.Focus_Direction; [[Focus direction]]
                 }
            }
+           //TIZEN_ONLY(20160926): add customization interface
+           @property color_class_color @internal {
+              set {
+                [[Set the color of color class for the Elementary widget item.
+
+                  Note: These color values are expected to be premultiplied by \@p a.]]
+                 return: bool;
+              }
+              get {
+                [[Get the color of color class for the Elementary widget item.
+
+                  Note: These color values are expected to be premultiplied by \@p a.]]
+                 return: bool;
+              }
+              keys {
+                 color_class: const(char)*; [[The name of color class.]]
+              }
+              values {
+                 r: int; [[The red intensity of the red color.]]
+                 g: int; [[The green intensity of the red color.]]
+                 b: int; [[The blue intensity of the red color.]]
+                 a: int; [[The alpha value.]]
+              }
+           }
+           @property color_class_color2 @internal {
+              set {
+                [[Set the second color of color class for the Elementary widget item.
+
+                  The second color is commonly used for outline of text.
+
+                  Note: These color values are expected to be premultiplied by \@p a.]]
+                 return: bool;
+              }
+              get {
+                [[Get the second color of color class for the Elementary widget item.
+
+                  The second color is commonly used for outline of text.
+
+                  Note: These color values are expected to be premultiplied by \@p a.]]
+                 return: bool;
+              }
+              keys {
+                 color_class: const(char)*; [[The name of color class.]]
+              }
+              values {
+                 r: int; [[The red intensity of the red color.]]
+                 g: int; [[The green intensity of the red color.]]
+                 b: int; [[The blue intensity of the red color.]]
+                 a: int; [[The alpha value.]]
+              }
+           }
+           @property color_class_color3 @internal {
+              set {
+                [[Set the third color of color class for the Elementary widget item.
+
+                  The third color is commonly used for shadow of text.
+
+                  Note: These color values are expected to be premultiplied by \@p a.]]
+                 return: bool;
+              }
+              get {
+                [[Get the third color of color class for the Elementary widget item.
+
+                  The third color is commonly used for shadow of text.
+
+                  Note: These color values are expected to be premultiplied by \@p a.]]
+                 return: bool;
+              }
+              keys {
+                 color_class: const(char)*; [[The name of color class.]]
+              }
+              values {
+                 r: int; [[The red intensity of the red color.]]
+                 g: int; [[The green intensity of the red color.]]
+                 b: int; [[The blue intensity of the red color.]]
+                 a: int; [[The alpha value.]]
+              }
+           }
+           //
       }
       implements {
            Eo.Base.constructor;
index feabb37..52950c0 100644 (file)
@@ -1147,6 +1147,8 @@ _item_unrealize(Elm_Gen_Item *it,
      }
    /* trackt */
    eo_do(EO_OBJ(it), elm_wdg_item_track_cancel());
+   if (it->base->color_classes)
+     edje_object_color_class_clear(VIEW(it));
    _item_cache_push(it);
    it->realized = EINA_FALSE;
 }
@@ -1529,6 +1531,9 @@ _item_realize(Elm_Gen_Item *it,
    if (!_item_cache_pop(it))
      VIEW(it) = _view_create(it, it->itc->item_style);
 
+   if (it->base->color_classes)
+     _elm_widget_item_color_class_update(it->base);
+
    treesize = edje_object_data_get(VIEW(it), "treesize");
    if (treesize)
      {