rimmed pushed a commit to branch master.

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

commit 36e82a9598699cff3aa82e5ba4fbe7d13f3ae8f5
Author: Vitalii Vorobiov <[email protected]>
Date:   Fri Jun 24 12:00:51 2016 +0300

    property_group: use elementary combobox for clip_to part selecting
---
 src/bin/ui/property/property_common.c  | 52 +++++++++++++++++++++++++
 src/bin/ui/property/property_group.c   | 71 +++++++++++++++++++++++++++++++---
 src/bin/ui/property/property_private.h |  8 ++++
 3 files changed, 126 insertions(+), 5 deletions(-)

diff --git a/src/bin/ui/property/property_common.c 
b/src/bin/ui/property/property_common.c
index c4f77aa..ca929aa 100644
--- a/src/bin/ui/property/property_common.c
+++ b/src/bin/ui/property/property_common.c
@@ -220,10 +220,51 @@ _start_change_cb(void *data,
      }
 }
 
+static char *
+_combobox_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part 
__UNUSED__)
+{
+   Combobox_Item *item = (Combobox_Item *)data;
+   return strdup(item->data);
+}
+
+static void
+_combobox_item_del(void *data,
+                   Evas_Object *obj __UNUSED__)
+{
+   Combobox_Item *item = (Combobox_Item *)data;
+   eina_stringshare_del(item->data);
+   free(item);
+}
+
+static void
+_combobox_item_pressed_cb(void *data __UNUSED__, Evas_Object *obj,
+                          void *event_info)
+{
+   Combobox_Item *item_obj, *item = elm_object_item_data_get(event_info);
+   item_obj = evas_object_data_del(obj, "CURRENT_DATA");
+   if (item_obj)
+     {
+        eina_stringshare_del(item_obj->data);
+        free(item_obj);
+     }
+
+   item_obj = mem_malloc(sizeof(Combobox_Item));
+   item_obj->index = item->index;
+   item_obj->data = eina_stringshare_add(item->data);
+
+   evas_object_data_set(obj, "CURRENT_DATA", item_obj);
+
+   _start_change_stop_cb(data, obj, event_info);
+
+   elm_combobox_hover_end(obj);
+   elm_entry_cursor_end_set(obj);
+}
+
 static Evas_Object *
 _control_create(Property_Attribute *pa, Property_Action *action, Evas_Object 
*parent)
 {
    Evas_Object *content = NULL;
+   Elm_Genlist_Item_Class *itc;
 
    assert(pa != NULL);
    assert(action != NULL);
@@ -244,6 +285,16 @@ _control_create(Property_Attribute *pa, Property_Action 
*action, Evas_Object *pa
          EWE_COMBOBOX_ADD(parent, content);
          evas_object_smart_callback_add(content, "selected", 
_start_change_stop_cb, pa);
          break;
+      case PROPERTY_CONTROL_NEWCOMBOBOX:
+         COMBOBOX_ADD(parent, content);
+         itc = elm_genlist_item_class_new();
+         itc->item_style = "default";
+         itc->func.text_get = _combobox_text_get;
+         itc->func.del = _combobox_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);
@@ -590,6 +641,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_NEWCOMBOBOX]    [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 dbcc386..e308abe 100644
--- a/src/bin/ui/property/property_group.c
+++ b/src/bin/ui/property/property_group.c
@@ -1111,6 +1111,62 @@ _parts_combobox_fill(Evas_Object *combo, const char 
*selected, int allowed_types
           }
      }
 }
+static void
+_parts_newcombobox_fill(Evas_Object *combo, const char *selected, int 
allowed_types_mask)
+{
+   Eina_List *l;
+   Part *part;
+   unsigned int i = 1;
+   Combobox_Item *combobox_item;
+   Elm_Genlist_Item_Class *itc;
+
+   assert(combo != NULL);
+
+   itc = evas_object_data_get(combo, "COMMON_ITC");
+
+   if (selected)
+     elm_object_text_set(combo, selected);
+   else
+     elm_object_text_set(combo, STR_NONE);
+
+   combobox_item = mem_malloc(sizeof(Combobox_Item));
+   combobox_item->index = 0;
+   combobox_item->data = eina_stringshare_add(STR_NONE);
+   elm_genlist_item_append(combo, itc,
+                           combobox_item, NULL,
+                           ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+   if (allowed_types_mask)
+     {
+        EINA_LIST_FOREACH(group_pd.group->parts, l, part)
+          {
+             if ((PART_MASK(part->type) & allowed_types_mask) && (part != 
(Part *)group_pd.group->current_selected))
+               {
+                  combobox_item = mem_malloc(sizeof(Combobox_Item));
+                  combobox_item->index = i++;
+                  combobox_item->data = eina_stringshare_add(part->name);
+                  elm_genlist_item_append(combo, itc,
+                                          combobox_item, NULL,
+                                          ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               }
+          }
+     }
+   else
+     {
+        EINA_LIST_FOREACH(group_pd.group->parts, l, part)
+          {
+             if (part != (Part *)group_pd.group->current_selected)
+               {
+                  combobox_item = mem_malloc(sizeof(Combobox_Item));
+                  combobox_item->index = i++;
+                  combobox_item->data = eina_stringshare_add(part->name);
+                  elm_genlist_item_append(combo, itc,
+                                          combobox_item, NULL,
+                                          ELM_GENLIST_ITEM_NONE, NULL, NULL);
+               }
+          }
+     }
+}
 
 static void
 _part_states_combobox_fill(Evas_Object *combo, const char *part_name, const 
char *selected, Eina_Bool ignore_value)
@@ -1544,9 +1600,9 @@ _update_cb(Property_Attribute *pa, Property_Action 
*action)
          elm_check_state_set(action->control, bool_val1);
          return editor_part_repeat_events_default_is(EDIT_OBJ, PART_ARGS);
       case ATTRIBUTE_PART_CLIP_TO:
-         ewe_combobox_items_list_free(action->control, true);
+         elm_genlist_clear(action->control);
          str_val1 = edje_edit_part_clip_to_get(EDIT_OBJ, PART_ARGS);
-         _parts_combobox_fill(action->control, str_val1, PART_RECTANGLE | 
PART_IMAGE);
+         _parts_newcombobox_fill(action->control, str_val1, PART_RECTANGLE | 
PART_IMAGE);
          edje_edit_string_free(str_val1);
          return editor_part_clip_to_default_is(EDIT_OBJ, PART_ARGS);
       case ATTRIBUTE_STATE_PROXY_SOURCE:
@@ -3078,6 +3134,7 @@ _change_cb(Property_Attribute *pa, Property_Action 
*action)
    Eina_Stringshare *str_val1 = NULL;
    Eina_Bool bool_val1 = false;;
    Ewe_Combobox_Item *cb_item = NULL;
+   Combobox_Item *cb_item_combo = NULL;
 
    Eina_List *deleted_tweens = NULL, *l;
    Eina_List *added_tweens = NULL;
@@ -3103,6 +3160,10 @@ _change_cb(Property_Attribute *pa, Property_Action 
*action)
          TODO("change this after migrating to elm_combobox");
          cb_item = ewe_combobox_select_item_get(action->control);
          break;
+      case PROPERTY_CONTROL_NEWCOMBOBOX:
+         cb_item_combo = evas_object_data_get(action->control, "CURRENT_DATA");
+         if (!cb_item_combo) return;
+         break;
       case PROPERTY_CONTROL_COLOR:
          property_color_control_color_get(action->control, &r, &g, &b, &a);
          break;
@@ -3203,8 +3264,8 @@ _change_cb(Property_Attribute *pa, Property_Action 
*action)
          group_pd.history.new.bool_val1 = bool_val1;
          break;
       case ATTRIBUTE_PART_CLIP_TO:
-         assert(cb_item != NULL);
-         str_val1 = (cb_item->index != 0) ? 
eina_stringshare_add(cb_item->title) : NULL;
+         assert(cb_item_combo != NULL);
+         str_val1 = (cb_item_combo->index != 0) ? 
eina_stringshare_add(cb_item_combo->data) : NULL;
          CRIT_ON_FAIL(editor_part_clip_to_set(EDIT_OBJ, CHANGE_NO_MERGE, 
PART_ARGS, str_val1));
          eina_stringshare_del(group_pd.history.new.str_val1);
          group_pd.history.new.str_val1 = str_val1;
@@ -4423,7 +4484,7 @@ _init_items()
              break;
            case PROPERTY_GROUP_ITEM_PART_CLIP_TO:
               IT.name = "Clip to";
-              _action1(&IT, NULL, NULL, PROPERTY_CONTROL_COMBOBOX, 
ATTRIBUTE_PART_CLIP_TO,
+              _action1(&IT, NULL, NULL, PROPERTY_CONTROL_NEWCOMBOBOX, 
ATTRIBUTE_PART_CLIP_TO,
                        _("Only renders the area of the part that coincides 
with "
                          "another part's container. The overflowing content is 
"
                          "not displayed. Note that the part being clipped to 
can"
diff --git a/src/bin/ui/property/property_private.h 
b/src/bin/ui/property/property_private.h
index d5bc553..b3e4435 100644
--- a/src/bin/ui/property/property_private.h
+++ b/src/bin/ui/property/property_private.h
@@ -27,12 +27,20 @@
    Property_Data *pd = evas_object_data_get(OBJ, PROPERTY_DATA); \
    assert(pd != NULL);
 
+typedef struct
+{
+   int index;
+   Eina_Stringshare *data;
+} Combobox_Item;
+
 enum _Property_Control {
    PROPERTY_CONTROL_NONE,
 
    PROPERTY_CONTROL_CHECK,
    PROPERTY_CONTROL_BUTTON,
    PROPERTY_CONTROL_COMBOBOX,
+/* temporary decision to not break everything at once will be removed later */
+   PROPERTY_CONTROL_NEWCOMBOBOX,
    PROPERTY_CONTROL_SPINNER,
    PROPERTY_CONTROL_ENTRY,
    PROPERTY_CONTROL_COLOR,

-- 


Reply via email to