elementary: clean up elm color class feature 34/92134/8
authorJee-Yong Um <conr2d@gmail.com>
Thu, 13 Oct 2016 10:04:34 +0000 (19:04 +0900)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Fri, 14 Oct 2016 07:03:31 +0000 (00:03 -0700)
Signed-Off-By: Jee-Yong Um <jc9.um@samsung.com>
Change-Id: I9b7fa64fc684091b05ceeb6df2d4408eec3c1977

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

index b2a2e8fd671616272c51a7461d73aa0c679fc105..5d9e144e0a857a210b0093e57688f70cbd608fea 100644 (file)
@@ -1289,7 +1289,7 @@ _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
+//TIZEN_ONLY(20161013): clean up elm color class feature
    if (it->base->color_classes)
      edje_object_color_class_clear(VIEW(it));
 //
@@ -1409,7 +1409,7 @@ _item_realize(Elm_Gen_Item *it)
           it->item->nocache_once = EINA_FALSE;
      }
 
-//TIZEN_ONLY(20160927): add item customization interface
+//TIZEN_ONLY(20161013): clean up elm color class feature
    if (it->base->color_classes)
      _elm_widget_item_color_class_update(it->base);
 //
index 7a1ebc84c7d84238f75f653938a4ded50fdc941e..b2ebda1fbc7e38e24c3db1ea90c46482f85ec3f6 100644 (file)
@@ -1906,7 +1906,7 @@ elm_object_accessibility_highlight_set(Evas_Object *obj, Eina_Bool visible)
 }
 //
 
-//TIZEN_ONLY(20160926): add customization interface
+//TIZEN_ONLY(20161013): clean up elm color class feature
 EAPI Eina_Bool
 elm_color_class_color_set(const char *color_class, int r, int g, int b, int a)
 {
@@ -1925,10 +1925,12 @@ EAPI Eina_Bool
 elm_color_class_color_get(const char *color_class, int *r, int *g, int *b, int *a)
 {
    Eina_Bool int_ret = EINA_FALSE;
+   int alpha = 0;
 
-   int_ret = edje_color_class_get(color_class, r, g, b, a, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+   int_ret = edje_color_class_get(color_class, r, g, b, &alpha, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+   if (a) *a = alpha;
 
-   _elm_color_premul(*a, r, g, b);
+   _elm_color_premul(alpha, r, g, b);
 
    return int_ret;
 }
@@ -1951,10 +1953,12 @@ EAPI Eina_Bool
 elm_color_class_color2_get(const char *color_class, int *r, int *g, int *b, int *a)
 {
    Eina_Bool int_ret = EINA_FALSE;
+   int alpha = 0;
 
-   int_ret = edje_color_class_get(color_class, NULL, NULL, NULL, NULL, r, g, b, a, NULL, NULL, NULL, NULL);
+   int_ret = edje_color_class_get(color_class, NULL, NULL, NULL, NULL, r, g, b, &alpha, NULL, NULL, NULL, NULL);
+   if (a) *a = alpha;
 
-   _elm_color_premul(*a, r, g, b);
+   _elm_color_premul(alpha, r, g, b);
 
    return int_ret;
 }
@@ -1977,10 +1981,12 @@ EAPI Eina_Bool
 elm_color_class_color3_get(const char *color_class, int *r, int *g, int *b, int *a)
 {
    Eina_Bool int_ret = EINA_FALSE;
+   int alpha = 0;
 
-   int_ret = edje_color_class_get(color_class, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, r, g, b, a);
+   int_ret = edje_color_class_get(color_class, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, r, g, b, &alpha);
+   if (a) *a = alpha;
 
-   _elm_color_premul(*a, r, g, b);
+   _elm_color_premul(alpha, r, g, b);
 
    return int_ret;
 }
@@ -1990,7 +1996,7 @@ elm_object_color_class_color_set(Evas_Object *obj, const char *color_class, int
 {
    Eina_Bool int_ret = EINA_FALSE;
 
-   return eo_do_ret(obj, int_ret, elm_obj_widget_color_class_color_set(color_class, r, g, b, a));
+   return eo_do_ret(obj, int_ret, elm_obj_widget_class_color_set(color_class, r, g, b, a));
 }
 
 EAPI Eina_Bool
@@ -1998,7 +2004,7 @@ elm_object_color_class_color_get(Evas_Object *obj, const char *color_class, int
 {
    Eina_Bool int_ret = EINA_FALSE;
 
-   return eo_do_ret(obj, int_ret, elm_obj_widget_color_class_color_get(color_class, r, g, b, a));
+   return eo_do_ret(obj, int_ret, elm_obj_widget_class_color_get(color_class, r, g, b, a));
 }
 
 EAPI Eina_Bool
@@ -2006,7 +2012,7 @@ elm_object_color_class_color2_set(Evas_Object *obj, const char *color_class, int
 {
    Eina_Bool int_ret = EINA_FALSE;
 
-   return eo_do_ret(obj, int_ret, elm_obj_widget_color_class_color2_set(color_class, r, g, b, a));
+   return eo_do_ret(obj, int_ret, elm_obj_widget_class_color2_set(color_class, r, g, b, a));
 }
 
 EAPI Eina_Bool
@@ -2014,7 +2020,7 @@ elm_object_color_class_color2_get(Evas_Object *obj, const char *color_class, int
 {
    Eina_Bool int_ret = EINA_FALSE;
 
-   return eo_do_ret(obj, int_ret, elm_obj_widget_color_class_color2_get(color_class, r, g, b, a));
+   return eo_do_ret(obj, int_ret, elm_obj_widget_class_color2_get(color_class, r, g, b, a));
 }
 
 EAPI Eina_Bool
@@ -2022,7 +2028,7 @@ elm_object_color_class_color3_set(Evas_Object *obj, const char *color_class, int
 {
    Eina_Bool int_ret = EINA_FALSE;
 
-   return eo_do_ret(obj, int_ret, elm_obj_widget_color_class_color3_set(color_class, r, g, b, a));
+   return eo_do_ret(obj, int_ret, elm_obj_widget_class_color3_set(color_class, r, g, b, a));
 }
 
 EAPI Eina_Bool
@@ -2030,6 +2036,6 @@ elm_object_color_class_color3_get(Evas_Object *obj, const char *color_class, int
 {
    Eina_Bool int_ret = EINA_FALSE;
 
-   return eo_do_ret(obj, int_ret, elm_obj_widget_color_class_color3_get(color_class, r, g, b, a));
+   return eo_do_ret(obj, int_ret, elm_obj_widget_class_color3_get(color_class, r, g, b, a));
 }
 //
index f2f6f8f0dd842664b3c12b2891ddc4bfe491c79b..77acba106195eb2e44ce65d3e205d2167aba1ce4 100644 (file)
@@ -733,7 +733,7 @@ EAPI void elm_object_scroll_item_valign_set(Evas_Object *obj, char *scroll_item_
 EAPI const char* elm_object_scroll_item_valign_get(const Evas_Object *obj);
 //
 
-//TIZEN_ONLY(20160926): add customization interface
+//TIZEN_ONLY(20161013): clean up elm color class feature
 /**
  * @internal
  *
@@ -742,9 +742,9 @@ EAPI const char* elm_object_scroll_item_valign_get(const Evas_Object *obj);
  * @note These color values are expected to be premultiplied by @p a.
  *
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -761,9 +761,9 @@ EAPI Eina_Bool        elm_color_class_color_set(const char *color_class, int r,
  * @note These color values are expected to be premultiplied by @p a.
  *
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -782,9 +782,9 @@ EAPI Eina_Bool        elm_color_class_color_get(const char *color_class, int *r,
  * @note These color values are expected to be premultiplied by @p a.
  *
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -803,9 +803,9 @@ EAPI Eina_Bool        elm_color_class_color2_set(const char *color_class, int r,
  * @note These color values are expected to be premultiplied by @p a.
  *
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -824,9 +824,9 @@ EAPI Eina_Bool        elm_color_class_color2_get(const char *color_class, int *r
  * @note These color values are expected to be premultiplied by @p a.
  *
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -845,9 +845,9 @@ EAPI Eina_Bool        elm_color_class_color3_set(const char *color_class, int r,
  * @note These color values are expected to be premultiplied by @p a.
  *
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -865,9 +865,9 @@ EAPI Eina_Bool        elm_color_class_color3_get(const char *color_class, int *r
  *
  * @param[in] obj The Elementary widget.
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -885,9 +885,9 @@ EAPI Eina_Bool        elm_object_color_class_color_set(Evas_Object *obj, const c
  *
  * @param[in] obj The Elementary widget.
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -907,9 +907,9 @@ EAPI Eina_Bool        elm_object_color_class_color_get(Evas_Object *obj, const c
  *
  * @param[in] obj The Elementary widget.
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -929,9 +929,9 @@ EAPI Eina_Bool        elm_object_color_class_color2_set(Evas_Object *obj, const
  *
  * @param[in] obj The Elementary widget.
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -951,9 +951,9 @@ EAPI Eina_Bool        elm_object_color_class_color2_get(Evas_Object *obj, const
  *
  * @param[in] obj The Elementary widget.
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
@@ -973,9 +973,9 @@ EAPI Eina_Bool        elm_object_color_class_color3_set(Evas_Object *obj, const
  *
  * @param[in] obj The Elementary widget.
  * @param[in] color_class The name of color class.
- * @param[in] r The red intensity of the red color.
- * @param[in] g The green intensity of the green color.
- * @param[in] b The blue intensity of the blue color.
+ * @param[in] r The intensity of the red color.
+ * @param[in] g The intensity of the green color.
+ * @param[in] b The intensity of the blue color.
  * @param[in] a The alpha value.
  *
  * @since 1.19
index 7f71cb79229e5b09a1a716d787e3efcd8ce76fa7..e60e064ed698d6323b912d8cb5522f69e5213669 100644 (file)
@@ -654,7 +654,7 @@ typedef enum _Conformant_Property
 #endif
 //
 
-//TIZEN_ONLY(20160926): add customization interface
+//TIZEN_ONLY(20161013): clean up elm color class feature
 #define _DIV_0xFF(x) ((x+1+((x+1)>>8))>>8)
 static inline void _elm_color_premul(int a, int *r, int *g, int *b)
 {
index b938d27e8f2953af948c5b816734f4775dab25e3..62eaf5516166da7e65e58744946267509bde53ac 100644 (file)
@@ -4717,8 +4717,10 @@ _elm_widget_item_eo_base_destructor(Eo *eo_item, Elm_Widget_Item_Data *item)
    }
    //
 
+//TIZEN_ONLY(20161013): clean up elm color class feature
    if (item->color_classes)
      ELM_SAFE_FREE(item->color_classes, eina_hash_free);
+//
 
    EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
 
@@ -6040,6 +6042,11 @@ _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;
 
@@ -6864,7 +6871,17 @@ _elm_widget_evas_object_paragraph_direction_set(Eo *obj, Elm_Widget_Smart_Data *
 }
 //
 
-//TIZEN_ONLY(20160926): add customization interface
+
+//TIZEN_ONLY(20161013): clean up elm color class feature
+void
+_edje_color_class_free(void *data)
+{
+   Edje_Color_Class *cc = data;
+
+   if (cc->name) eina_stringshare_del(cc->name);
+   free(cc);
+}
+
 Eina_Stringshare *
 _elm_widget_edje_class_get(const Eo_Class *klass, const char *style, const char *part)
 {
@@ -6893,247 +6910,219 @@ _elm_widget_edje_class_get(const Eo_Class *klass, const char *style, const char
    return str;
 }
 
-#define ELM_COLOR_CLASS_SET_UPPER(klass) \
-   Eina_Stringshare *buf; \
-   Eina_Bool int_ret = EINA_FALSE; \
-   if (eo_isa(obj, klass)) \
-     { \
-        buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class); \
-        _elm_color_unpremul(a, &r, &g, &b)
-
-#define ELM_COLOR_CLASS_SET_LOWER() \
-        eina_stringshare_del(buf); \
-        return int_ret; \
-     } \
-   else \
-     { \
-        ERR("%s does not support %s() API.", elm_widget_type_get(obj), __func__); \
-        return EINA_FALSE; \
-     }
-
-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)
+Eina_Hash *
+_elm_widget_color_classes_get(Eo *obj)
 {
-   ELM_COLOR_CLASS_SET_UPPER(ELM_LAYOUT_CLASS);
+   Elm_Widget_Smart_Data *sd = eo_data_scope_get(obj, ELM_WIDGET_CLASS);
+
+   if ((!sd) || (!sd->color_classes)) return NULL;
 
-   int r2 = 0, g2 = 0, b2 = 0, a2 = 0, r3 = 0, g3 = 0, b3 = 0, a3 = 0;
+   return sd->color_classes;
+}
 
-   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);
+#define ELM_COLOR_CLASS_UPDATE(obj, hash, cond)                                  \
+   Evas_Object *edje = NULL;                                                     \
+   Eina_Iterator *itr;                                                           \
+   Edje_Color_Class *cc;                                                         \
+   Eina_Bool int_ret = EINA_TRUE;                                                \
+   if (cond) return EINA_FALSE;                                                  \
+   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 EINA_FALSE;                                                 \
+   itr = eina_hash_iterator_data_new(hash);                                      \
+   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
 
-   ELM_COLOR_CLASS_SET_LOWER();
+Eina_Bool
+_elm_widget_color_class_update(Eo *obj, Eina_Hash *color_classes)
+{
+   ELM_COLOR_CLASS_UPDATE(obj, color_classes, (!obj) || (!color_classes));
 }
 
-#define ELM_COLOR_CLASS_GET_UPPER(klass) \
-   Eina_Stringshare *buf; \
-   Eina_Bool int_ret = EINA_FALSE; \
-   if (eo_isa(obj, klass)) \
-     { \
-        int alpha = 0; \
-        buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class)
+#define CHECK_BOUND(x)                                                           \
+   if (x > 0xff) x = 0xff;                                                       \
+   else if (x < 0) x = 0
 
-#define ELM_COLOR_CLASS_GET_LOWER() \
-        _elm_color_premul(alpha, r, g, b); \
-        eina_stringshare_del(buf); \
-        return int_ret; \
-     } \
-   else \
-     { \
-        ERR("%s does not support %s() API.", eo_class_name_get(eo_class_get(obj)), __func__); \
-        return EINA_FALSE; \
-     }
+#define ELM_COLOR_CLASS_SET_START(obj, cr, cg, cb, ca)                           \
+   Eina_Bool int_ret = EINA_FALSE;                                               \
+   Edje_Color_Class *cc = NULL;                                                  \
+   Eina_Stringshare *buf;                                                        \
+   buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class);       \
+   CHECK_BOUND(r);                                                               \
+   CHECK_BOUND(g);                                                               \
+   CHECK_BOUND(b);                                                               \
+   CHECK_BOUND(a);                                                               \
+   _elm_color_unpremul(a, &r, &g, &b);                                           \
+   if (!sd->color_classes)                                                       \
+     sd->color_classes = eina_hash_string_small_new(_edje_color_class_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
+
+#define ELM_COLOR_CLASS_SET_END()                                                \
+   eina_stringshare_del(buf);                                                    \
+   return int_ret
 
 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);
+_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;                                                         \
+   Eina_Stringshare *buf;                                                        \
+   int alpha = 0;                                                                \
+   buf = _elm_widget_edje_class_get(eo_class_get(obj), NULL, color_class);       \
+   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;                                                      \
+        alpha = cc->ca;                                                          \
+        int_ret = EINA_TRUE;                                                     \
+     }                                                                           \
+   _elm_color_premul(alpha, r, g, b);                                            \
+   eina_stringshare_del(buf);                                                    \
+   return int_ret
 
-   int_ret = edje_object_color_class_get(sd->resize_obj, buf, r, g, b, &alpha, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-   if (a) *a = alpha;
 
-   ELM_COLOR_CLASS_GET_LOWER();
+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_color_class_color2_set(Eo *obj, Elm_Widget_Smart_Data *sd, const char *color_class, int r, int g, int b, int a)
+_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_UPPER(ELM_LAYOUT_CLASS);
+   ELM_COLOR_CLASS_SET_START(obj, r2, g2, b2, a2);
 
-   int r2 = 0, g2 = 0, b2 = 0, a2 = 0, r3 = 0, g3 = 0, b3 = 0, a3 = 0;
+   int_ret &= _elm_widget_color_class_update(obj, sd->color_classes);
 
-   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();
+   ELM_COLOR_CLASS_SET_END();
 }
 
 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_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_UPPER(ELM_LAYOUT_CLASS);
-
-   int_ret = edje_object_color_class_get(sd->resize_obj, buf, NULL, NULL, NULL, NULL, r, g, b, &alpha, NULL, NULL, NULL, NULL);
-   if (a) *a = alpha;
-
-   ELM_COLOR_CLASS_GET_LOWER();
+   ELM_COLOR_CLASS_GET(obj, r2, g2, b2, a2);
 }
 
 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_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_UPPER(ELM_LAYOUT_CLASS);
 
-   int r2 = 0, g2 = 0, b2 = 0, a2 = 0, r3 = 0, g3 = 0, b3 = 0, a3 = 0;
+   ELM_COLOR_CLASS_SET_START(obj, r3, g3, b3, a3);
 
-   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);
+   int_ret &= _elm_widget_color_class_update(obj, sd->color_classes);
 
-   ELM_COLOR_CLASS_SET_LOWER();
+   ELM_COLOR_CLASS_SET_END();
 }
 
 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_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_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, &alpha);
-   if (a) *a = alpha;
-
-   ELM_COLOR_CLASS_GET_LOWER();
+   ELM_COLOR_CLASS_GET(obj, r3, g3, b3, a3);
 }
 
 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;
+   ELM_COLOR_CLASS_UPDATE(sd->view, sd->color_classes, (!sd) || (!sd->color_classes) || (!sd->view));
 }
 
-#define CHECK_BOUND(x) \
-   if (x > 0xFF) x = 0xff; \
-   else if (x < 0) x = 0
+EOLIAN Eina_Bool
+_elm_widget_item_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_START(obj, r, g, b, a);
 
-#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)
+   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; \
-        alpha = cc->ca; \
-        int_ret = EINA_TRUE; \
-     }
+   ELM_COLOR_CLASS_SET_END();
+}
 
 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_widget_item_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();
+   ELM_COLOR_CLASS_GET(obj, r, g, b, a);
 }
 
 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_widget_item_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();
+   ELM_COLOR_CLASS_SET_START(obj, r2, g2, b2, a2);
+
+   int_ret &= _elm_widget_item_color_class_update(sd);
+
+   ELM_COLOR_CLASS_SET_END();
 }
 
 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_widget_item_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();
+   ELM_COLOR_CLASS_GET(obj, r2, g2, b2, a2);
 }
 
 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_widget_item_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();
+   ELM_COLOR_CLASS_SET_START(obj, r3, g3, b3, a3);
+
+   int_ret &= _elm_widget_item_color_class_update(sd);
+
+   ELM_COLOR_CLASS_SET_END();
 }
 
 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_widget_item_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();
+   ELM_COLOR_CLASS_GET(obj, r3, g3, b3, a3);
 }
 //
 
index 4d251efb80aacbffa1a662f278d3fb4f91c9acaa..4f8635472b0b0bb4de068321474d41df241abb1d 100644 (file)
@@ -791,8 +791,8 @@ abstract Elm.Widget (Evas.Object_Smart, Elm_Interface_Atspi_Accessible,
          }
       }
       //
-      //TIZEN_ONLY(20160926): add customization interface
-      @property color_class_color {
+      //TIZEN_ONLY(20161013): clean up elm color class feature
+      @property class_color {
          set {
             return: bool;
          }
@@ -809,7 +809,7 @@ abstract Elm.Widget (Evas.Object_Smart, Elm_Interface_Atspi_Accessible,
             a: int;
          }
       }
-      @property color_class_color2 {
+      @property class_color2 {
          set {
             return: bool;
          }
@@ -826,7 +826,7 @@ abstract Elm.Widget (Evas.Object_Smart, Elm_Interface_Atspi_Accessible,
             a: int;
          }
       }
-      @property color_class_color3 {
+      @property class_color3 {
          set {
             return: bool;
          }
index 915799b9f861b37bfb547023a993ec1008255deb..41bef6d92c47426730d53c3b5175cc7b5b59c707 100644 (file)
@@ -439,6 +439,9 @@ 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;
@@ -669,7 +672,7 @@ 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
+   //TIZEN_ONLY(20161013): clean up elm color class feature
    Eina_Hash                     *color_classes;
    //
 
@@ -933,6 +936,11 @@ _elm_widget_sub_object_redirect_to_top(Evas_Object *obj, Evas_Object *sobj)
    return ret;
 }
 
+//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);
+//
+
 /* to be used by INTERNAL classes on Elementary, so that the widgets
  * parsing script skips it */
 #define ELM_INTERNAL_SMART_SUBCLASS_NEW EVAS_SMART_SUBCLASS_NEW
index a3ce14f449725f32f31d8ecac8ebc20982575b75..bdd948189578cddc1893554c002fa8d43ab6feda 100644 (file)
@@ -532,31 +532,33 @@ 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 {
+           //TIZEN_ONLY(20161013): clean up elm color class feature
+           @property 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;
+                 legacy: elm_object_item_color_class_color_set;
               }
               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;
+                 legacy: elm_object_item_color_class_color_get;
               }
               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.]]
+                 r: int; [[The intensity of the red color.]]
+                 g: int; [[The intensity of the green color.]]
+                 b: int; [[The intensity of the blue color.]]
                  a: int; [[The alpha value.]]
               }
            }
-           @property color_class_color2 @internal {
+           @property class_color2 @internal {
               set {
                 [[Set the second color of color class for the Elementary widget item.
 
@@ -564,6 +566,7 @@ class Elm.Widget_Item (Eo.Base, Elm_Interface_Atspi_Accessible,
 
                   Note: These color values are expected to be premultiplied by \@p a.]]
                  return: bool;
+                 legacy: elm_object_item_color_class_color2_set;
               }
               get {
                 [[Get the second color of color class for the Elementary widget item.
@@ -572,18 +575,19 @@ class Elm.Widget_Item (Eo.Base, Elm_Interface_Atspi_Accessible,
 
                   Note: These color values are expected to be premultiplied by \@p a.]]
                  return: bool;
+                 legacy: elm_object_item_color_class_color2_get;
               }
               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.]]
+                 r: int; [[The intensity of the red color.]]
+                 g: int; [[The intensity of the green color.]]
+                 b: int; [[The intensity of the blue color.]]
                  a: int; [[The alpha value.]]
               }
            }
-           @property color_class_color3 @internal {
+           @property class_color3 @internal {
               set {
                 [[Set the third color of color class for the Elementary widget item.
 
@@ -591,6 +595,7 @@ class Elm.Widget_Item (Eo.Base, Elm_Interface_Atspi_Accessible,
 
                   Note: These color values are expected to be premultiplied by \@p a.]]
                  return: bool;
+                 legacy: elm_object_item_color_class_color3_set;
               }
               get {
                 [[Get the third color of color class for the Elementary widget item.
@@ -599,14 +604,15 @@ class Elm.Widget_Item (Eo.Base, Elm_Interface_Atspi_Accessible,
 
                   Note: These color values are expected to be premultiplied by \@p a.]]
                  return: bool;
+                 legacy: elm_object_item_color_class_color3_get;
               }
               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.]]
+                 r: int; [[The intensity of the red color.]]
+                 g: int; [[The intensity of the green color.]]
+                 b: int; [[The intensity of the blue color.]]
                  a: int; [[The alpha value.]]
               }
            }
index 34376f07a3d05c7699035a445e509c6daf655f73..973ee9adc49601963348b38dd2bfed21adfa6541 100644 (file)
@@ -1151,8 +1151,10 @@ _item_unrealize(Elm_Gen_Item *it,
      }
    /* trackt */
    eo_do(EO_OBJ(it), elm_wdg_item_track_cancel());
+//TIZEN_ONLY(20161013): clean up elm color class feature
    if (it->base->color_classes)
      edje_object_color_class_clear(VIEW(it));
+//
    _item_cache_push(it);
    it->realized = EINA_FALSE;
 }
@@ -1535,8 +1537,10 @@ _item_realize(Elm_Gen_Item *it,
    if (!_item_cache_pop(it))
      VIEW(it) = _view_create(it, it->itc->item_style);
 
+//TIZEN_ONLY(20161013): clean up elm color class feature
    if (it->base->color_classes)
      _elm_widget_item_color_class_update(it->base);
+//
 
    treesize = edje_object_data_get(VIEW(it), "treesize");
    if (treesize)