rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=bf021e7face2a8f0bcfe40cfb9ce2dfbb45dc754

commit bf021e7face2a8f0bcfe40cfb9ce2dfbb45dc754
Author: Vitalii Vorobiov <[email protected]>
Date:   Wed Jun 29 14:41:17 2016 +0300

    property_group: style for combobox items to show color_classes
---
 data/themes/default/widgets/combobox.edc | 207 +++++++++++++++++++++++++++++++
 src/bin/ui/property/property_common.c    |  40 ++++++
 src/bin/ui/property/property_group.c     |  53 +++++++-
 src/bin/ui/property/property_private.h   |  10 ++
 4 files changed, 306 insertions(+), 4 deletions(-)

diff --git a/data/themes/default/widgets/combobox.edc 
b/data/themes/default/widgets/combobox.edc
index 0a0fc94..932175b 100644
--- a/data/themes/default/widgets/combobox.edc
+++ b/data/themes/default/widgets/combobox.edc
@@ -1327,6 +1327,213 @@ group { name: 
"elm/genlist/base/combobox_vertical/default";
    }
 }
 
+group { name: 
"elm/genlist/item_compress/color_class/combobox_vertical/default";
+   data {
+      item: "texts" "elm.text";
+      item: "treesize" "20";
+      item: "contents" "swallow.color1 swallow.color2 swallow.color3";
+      item: "stacking" "above";
+      item: "selectraise" "on";
+   }
+   parts {
+      part { name: "bg";
+         type: RECT;
+         description { state: "default" 0.0;
+            color: 0 0 0 0;
+            min: 0 24;
+            max: -1 0;
+         }
+         description { state: "selected" 0.0;
+            color_class: "select";
+            min: 0 19;
+            max: -1 0;
+         }
+      }
+      part { name: "elm.text";
+         type: TEXT;
+         repeat_events: 1;
+         description { state: "default" 0.0;
+            color: 213 213 213 255;
+            rel1 {
+               offset: 10 0;
+            }
+            rel2 {
+               offset: -11 -1;
+            }
+            text {
+               font: FN;
+               size: 12;
+               align: 0.0 0.5;
+               min: 1 1;
+               elipsis: -1;
+            }
+         }
+         description { state: "hide" 0.0;
+            inherit: "default";
+            visible: 0;
+         }
+      }
+      part { name: "bg.color3";
+         type: IMAGE;
+         description { state: "default" 0.0;
+            align: 1.0 0.5;
+            min: 16 13;
+            max: 16 13;
+            rel2 {
+               offset: -7 -1;
+            }
+            image {
+               normal: "color-background-2.png";
+               middle: DEFAULT;
+            }
+         }
+      }
+      part { name: "bg.color2";
+         type: IMAGE;
+         description { state: "default" 0.0;
+            align: 1.0 0.5;
+            min: 16 13;
+            max: 16 13;
+            rel2 {
+               relative: 0.0 1.0;
+               offset: -6 -1;
+               to_x: "bg.color3";
+            }
+            image {
+               normal: "color-background-2.png";
+               middle: DEFAULT;
+            }
+         }
+      }
+      part { name: "bg.color1";
+         type: IMAGE;
+         description { state: "default" 0.0;
+            align: 1.0 0.5;
+            min: 16 13;
+            max: 16 13;
+            rel2 {
+               relative: 0.0 1.0;
+               offset: -6 -1;
+               to_x: "bg.color2";
+            }
+            image {
+               normal: "color-background-2.png";
+               middle: DEFAULT;
+            }
+         }
+      }
+      part { name: "swallow.color1";
+         type: SWALLOW;
+         description { state: "default" 0.0;
+            rel1 {
+               to: "bg.color1";
+            }
+            rel2 {
+               to: "bg.color1";
+            }
+         }
+      }
+      part { name: "swallow.color2";
+         type: SWALLOW;
+         description { state: "default" 0.0;
+            rel1 {
+               to: "bg.color2";
+            }
+            rel2 {
+               to: "bg.color2";
+            }
+         }
+      }
+      part { name: "swallow.color3";
+         type: SWALLOW;
+         description { state: "default" 0.0;
+            rel1 {
+               to: "bg.color3";
+            }
+            rel2 {
+               to: "bg.color3";
+            }
+         }
+      }
+      part { name: "shadow.color1";
+         type: IMAGE;
+         description { state: "default" 0.0;
+            rel1 {
+               to: "bg.color1";
+            }
+            rel2 {
+               to: "bg.color1";
+            }
+            image {
+               normal: "color-shadow-2.png";
+               border: 3 3 3 3;
+               middle: DEFAULT;
+            }
+         }
+      }
+      part { name: "shadow.color2";
+         type: IMAGE;
+         description { state: "default" 0.0;
+            rel1 {
+               to: "bg.color2";
+            }
+            rel2 {
+               to: "bg.color2";
+            }
+            image {
+               normal: "color-shadow-2.png";
+               border: 3 3 3 3;
+               middle: DEFAULT;
+            }
+         }
+      }
+      part { name: "shadow.color3";
+         type: IMAGE;
+         description { state: "default" 0.0;
+            rel1 {
+               to: "bg.color3";
+            }
+            rel2 {
+               to: "bg.color3";
+            }
+            image {
+               normal: "color-shadow-2.png";
+               border: 3 3 3 3;
+               middle: DEFAULT;
+            }
+         }
+      }
+      part { name: "disclip";
+         type: RECT;
+         repeat_events: 1;
+         description { state: "default" 0.0;
+            color: 255 255 255 0;
+         }
+      }
+   }
+   programs {
+      program { name: "selected";
+         signal: "mouse,in";
+         source: "disclip";
+         action: STATE_SET "selected" 0.00;
+         target: "bg";
+      }
+      program { name: "unselected";
+         signal: "mouse,out";
+         source: "disclip";
+         action: STATE_SET "default" 0.00;
+         target: "bg";
+      }
+      program { name: "item_hide";
+         signal: "elm,state,contract_flip";
+         source: "elm";
+         action: STATE_SET "hide" 0.00;
+         target: "elm.text";
+         target: "disclip";
+      }
+   }
+}
+
 group { name: "elm/genlist/item_compress/default/combobox_vertical/default";
    data {
       item: "texts" "elm.text";
diff --git a/src/bin/ui/property/property_common.c 
b/src/bin/ui/property/property_common.c
index 2130751..45622ca 100644
--- a/src/bin/ui/property/property_common.c
+++ b/src/bin/ui/property/property_common.c
@@ -227,6 +227,25 @@ _combobox_text_get(void *data, Evas_Object *obj 
__UNUSED__, const char *part __U
    return strdup(item->data);
 }
 
+static Evas_Object *
+_combobox_cc_content_get(void *data, Evas_Object *obj, const char *part)
+{
+   Combobox_Cc_Item *item = (Combobox_Cc_Item *)data;
+
+   Evas_Object *object = evas_object_rectangle_add(evas_object_evas_get(obj));
+
+   if (!strcmp(part, "swallow.color1"))
+     evas_object_color_set(object, item->r1, item->g1, item->b1, item->a1);
+   else if (!strcmp(part, "swallow.color2"))
+     evas_object_color_set(object, item->r2, item->g2, item->b2, item->a2);
+   else if (!strcmp(part, "swallow.color3"))
+     evas_object_color_set(object, item->r3, item->g3, item->b3, item->a3);
+
+   evas_object_show(object);
+
+   return object;
+}
+
 static void
 _combobox_item_del(void *data,
                    Evas_Object *obj __UNUSED__)
@@ -237,6 +256,15 @@ _combobox_item_del(void *data,
 }
 
 static void
+_combobox_cc_item_del(void *data,
+                   Evas_Object *obj __UNUSED__)
+{
+   Combobox_Cc_Item *item = (Combobox_Cc_Item *)data;
+   eina_stringshare_del(item->data);
+   free(item);
+}
+
+static void
 _combobox_item_pressed_cb(void *data __UNUSED__, Evas_Object *obj,
                           void *event_info)
 {
@@ -291,6 +319,17 @@ _control_create(Property_Attribute *pa, Property_Action 
*action, Evas_Object *pa
          evas_object_smart_callback_add(content, "item,pressed",
                                         _combobox_item_pressed_cb, pa);
          break;
+      case PROPERTY_CONTROL_COMBOBOX_CC:
+         COMBOBOX_ADD(parent, content);
+         itc = elm_genlist_item_class_new();
+         itc->item_style = "color_class";
+         itc->func.text_get = _combobox_text_get;
+         itc->func.content_get = _combobox_cc_content_get;
+         itc->func.del = _combobox_cc_item_del;
+         evas_object_data_set(content, "COMMON_ITC", itc);
+         evas_object_smart_callback_add(content, "item,pressed",
+                                        _combobox_item_pressed_cb, pa);
+         break;
       case PROPERTY_CONTROL_SPINNER:
          SPINNER_ADD(parent, content, 0.0, 9999.0, 1.0, true);
          evas_object_smart_callback_add(content, "spinner,drag,start", 
_start_cb, pa);
@@ -637,6 +676,7 @@ property_common_itc_init(Property_Data *pd)
 
    pd->item_classes[PROPERTY_CONTROL_ENTRY]          [PROPERTY_CONTROL_NONE]   
  = pd->itc_1swallow;
    pd->item_classes[PROPERTY_CONTROL_COMBOBOX]       [PROPERTY_CONTROL_NONE]   
  = pd->itc_1swallow;
+   pd->item_classes[PROPERTY_CONTROL_COMBOBOX_CC]    [PROPERTY_CONTROL_NONE]   
  = pd->itc_1swallow;
    pd->item_classes[PROPERTY_CONTROL_COLORSEL]       [PROPERTY_CONTROL_NONE]   
  = pd->itc_1swallow_wide;
    pd->item_classes[PROPERTY_CONTROL_LABEL]          [PROPERTY_CONTROL_NONE]   
  = pd->itc_1swallow;
    pd->item_classes[PROPERTY_CONTROL_IMAGE_NORMAL]   [PROPERTY_CONTROL_NONE]   
  = pd->itc_1swallow;
diff --git a/src/bin/ui/property/property_group.c 
b/src/bin/ui/property/property_group.c
index 49573dd..486526d 100644
--- a/src/bin/ui/property/property_group.c
+++ b/src/bin/ui/property/property_group.c
@@ -714,6 +714,46 @@ _ccl_control_free(void *data __UNUSED__,
    color = evas_object_data_del(obj, "color3");
    evas_object_del(color);
 }
+/*
+static void
+_color_class_colors_fill(void *data __UNUSED__,
+                         Evas_Object *combo,
+                         void *event_info __UNUSED__)
+{
+   int cc_val[12];
+   Evas_Object *color;
+   const Eina_List *items, *l;
+   Ewe_Combobox_Item *item;
+   Evas *canvas;
+
+   items = ewe_combobox_items_list_get(combo);
+   if (!items) return;
+
+   item = eina_list_data_get(items);
+   canvas = evas_object_evas_get(item->content);
+   items = eina_list_next(items);
+   EINA_LIST_FOREACH(items, l, item)
+     {
+        evas_color_argb_premul(cc_val[3], &cc_val[0], &cc_val[1], &cc_val[2]);
+        evas_color_argb_premul(cc_val[7], &cc_val[4], &cc_val[5], &cc_val[6]);
+        evas_color_argb_premul(cc_val[11], &cc_val[8], &cc_val[9], 
&cc_val[10]);
+        FIXME: this is bad solition, user shoud not use edje object for add 
contnent to a
+         * combobox item. Need to move combobox from edje ocject to layout.
+        color = edje_object_add(canvas);
+        edje_object_file_set(color, EFLETE_THEME, "elm/image/color/color_set");
+        evas_object_color_set(color, cc_val[0], cc_val[1], cc_val[2], 
cc_val[3]);
+        edje_object_part_swallow(item->content, "swallow.color1", color);
+        color = edje_object_add(canvas);
+        edje_object_file_set(color, EFLETE_THEME, "elm/image/color/color_set");
+        evas_object_color_set(color, cc_val[4], cc_val[5], cc_val[6], 
cc_val[7]);
+        edje_object_part_swallow(item->content, "swallow.color2", color);
+        color = edje_object_add(canvas);
+        edje_object_file_set(color, EFLETE_THEME, "elm/image/color/color_set");
+        evas_object_color_set(color, cc_val[8], cc_val[9], cc_val[10], 
cc_val[11]);
+        edje_object_part_swallow(item->content, "swallow.color3", color);
+     }
+}
+*/
 
 static void
 _init_cb(Property_Attribute *pa, Property_Action *action)
@@ -1250,7 +1290,7 @@ _color_classes_combobox_fill(Evas_Object *combo, const 
char *selected)
    Eina_Stringshare *color_class;
    Elm_Genlist_Item_Class *itc;
    unsigned int i = 0;
-   Combobox_Item *combobox_item;
+   Combobox_Cc_Item *combobox_item;
 
    assert(combo != NULL);
 
@@ -1259,7 +1299,7 @@ _color_classes_combobox_fill(Evas_Object *combo, const 
char *selected)
 
    cclist = edje_edit_color_classes_list_get(EDIT_OBJ);
 
-   combobox_item = mem_malloc(sizeof(Combobox_Item));
+   combobox_item = mem_calloc(1, sizeof(Combobox_Cc_Item));
    combobox_item->index = i++;
    combobox_item->data = eina_stringshare_add(STR_NONE);
    elm_genlist_item_append(combo, itc,
@@ -1268,8 +1308,12 @@ _color_classes_combobox_fill(Evas_Object *combo, const 
char *selected)
 
    EINA_LIST_FOREACH(cclist, l, color_class)
      {
-        combobox_item = mem_malloc(sizeof(Combobox_Item));
+        combobox_item = mem_calloc(1, sizeof(Combobox_Cc_Item));
         combobox_item->index = i++;
+        edje_edit_color_class_colors_get(EDIT_OBJ, color_class,
+                                         &combobox_item->r1, 
&combobox_item->g1, &combobox_item->b1, &combobox_item->a1,
+                                         &combobox_item->r2, 
&combobox_item->g2, &combobox_item->b2, &combobox_item->a2,
+                                         &combobox_item->r3, 
&combobox_item->g3, &combobox_item->b3, &combobox_item->a3);
         combobox_item->data = eina_stringshare_add(color_class);
         elm_genlist_item_append(combo, itc,
                                 combobox_item, NULL,
@@ -3156,6 +3200,7 @@ _change_cb(Property_Attribute *pa, Property_Action 
*action)
          bool_val1 = elm_check_state_get(action->control);
          break;
       case PROPERTY_CONTROL_COMBOBOX:
+      case PROPERTY_CONTROL_COMBOBOX_CC:
          cb_item_combo = evas_object_data_get(action->control, "CURRENT_DATA");
          if (!cb_item_combo) return;
          break;
@@ -5110,7 +5155,7 @@ _init_items()
               break;
            case PROPERTY_GROUP_ITEM_STATE_COLORS_COLOR_CLASS:
               IT.name = "Color class";
-              _action1(&IT, NULL, NULL, PROPERTY_CONTROL_COMBOBOX, 
ATTRIBUTE_STATE_COLOR_CLASS,
+              _action1(&IT, NULL, NULL, PROPERTY_CONTROL_COMBOBOX_CC, 
ATTRIBUTE_STATE_COLOR_CLASS,
                        _("The part uses the color values of the chosen color 
class. "
                          "These values can be overridden by the \"color\", 
\"color2\" "
                          "and \"color3\" properties set below."));
diff --git a/src/bin/ui/property/property_private.h 
b/src/bin/ui/property/property_private.h
index 137af1a..ef0ddd4 100644
--- a/src/bin/ui/property/property_private.h
+++ b/src/bin/ui/property/property_private.h
@@ -33,12 +33,22 @@ typedef struct
    Eina_Stringshare *data;
 } Combobox_Item;
 
+typedef struct
+{
+   int index;
+   Eina_Stringshare *data;
+   int r1, g1, b1, a1;
+   int r2, g2, b2, a2;
+   int r3, g3, b3, a3;
+} Combobox_Cc_Item;
+
 enum _Property_Control {
    PROPERTY_CONTROL_NONE,
 
    PROPERTY_CONTROL_CHECK,
    PROPERTY_CONTROL_BUTTON,
    PROPERTY_CONTROL_COMBOBOX,
+   PROPERTY_CONTROL_COMBOBOX_CC, /* special combobox for color_classes */
    PROPERTY_CONTROL_SPINNER,
    PROPERTY_CONTROL_ENTRY,
    PROPERTY_CONTROL_COLOR,

-- 


Reply via email to