rimmed pushed a commit to branch master.

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

commit b69ad4175e7a4db5f9578ed1067eaf783bc80f24
Author: Vitalii Vorobiov <vi.vorob...@samsung.com>
Date:   Mon Apr 18 18:55:51 2016 +0300

    popup: add helper for colorselection
---
 src/bin/ui/main_window.h     |  4 +++
 src/bin/ui/popup.c           | 58 ++++++++++++++++++++++++++++++++++++++++++++
 src/bin/ui/property_macros.h | 34 ++++++++------------------
 3 files changed, 72 insertions(+), 24 deletions(-)

diff --git a/src/bin/ui/main_window.h b/src/bin/ui/main_window.h
index 71c323a..610ef9e 100644
--- a/src/bin/ui/main_window.h
+++ b/src/bin/ui/main_window.h
@@ -370,6 +370,10 @@ popup_gengrid_image_helper(const char *title, Evas_Object 
*follow_up,
 void
 popup_gengrid_helper_item_select(const char *item_title);
 
+void
+popup_colorselector_helper(const char *title, Evas_Object *follow_up,
+                           Helper_Done_Cb func, Helper_Done_Cb func_change, 
void *data);
+
 /**
  * Export project as develop edj file.
  *
diff --git a/src/bin/ui/popup.c b/src/bin/ui/popup.c
index 447777d..30b8b5c 100644
--- a/src/bin/ui/popup.c
+++ b/src/bin/ui/popup.c
@@ -723,6 +723,64 @@ popup_gengrid_helper_item_select(const char *item_title)
 }
 
 void
+popup_colorselector_helper(const char *title, Evas_Object *follow_up,
+                           Helper_Done_Cb func, Helper_Done_Cb func_change 
__UNUSED__,
+                           void *data)
+{
+   Helper_Data *helper_data = (Helper_Data *)mem_calloc(1, 
sizeof(Helper_Data));
+
+   dismiss_func = func;
+   func_data = data;
+
+   helper_data->follow_up = follow_up;
+
+   evas_object_del(helper);
+   helper = elm_layout_add(ap.win);
+   elm_layout_theme_set(helper, "layout", "popup", title ? "hint_title" : 
"hint");
+   evas_object_data_set(helper, "STRUCT", helper_data);
+   elm_layout_signal_callback_add(helper, "hint,dismiss", "eflete", 
_helper_dismiss, follow_up);
+
+   fs = elm_colorselector_add(helper);
+   elm_colorselector_mode_set(fs, ELM_COLORSELECTOR_ALL);
+   evas_object_size_hint_weight_set(fs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(fs, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_show(fs);
+
+/*   evas_object_smart_callback_add(fs, "color,changed",
+                                  func_change, data);
+   evas_object_smart_callback_add(fs, "palette,item,selected",
+                                  func_change, data);
+*/
+   BUTTON_ADD(fs, helper_data->button, _("Ok"))
+   elm_object_part_content_set(helper, "elm.swallow.ok", helper_data->button);
+//   evas_object_smart_callback_add(helper_data->button, "clicked", 
_done_image, helper_data);
+   evas_object_show(helper_data->button);
+
+   /* small hack, hide not necessary button */
+   evas_object_hide(elm_layout_content_unset(fs, "elm.swallow.cancel"));
+   evas_object_size_hint_min_set(helper, GENGRID_W / 2, GENGRID_H);
+   evas_object_resize(helper, GENGRID_W / 2, GENGRID_H);
+
+   if (title) elm_object_text_set(helper, title);
+   elm_layout_content_set(helper, "elm.swallow.content", fs);
+   evas_object_size_hint_weight_set(fs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(fs, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   if (follow_up)
+     {
+        _helper_property_follow(NULL, NULL, follow_up, NULL);
+        evas_object_event_callback_add(follow_up, EVAS_CALLBACK_RESIZE, 
_helper_property_follow, NULL);
+        evas_object_event_callback_add(follow_up, EVAS_CALLBACK_MOVE, 
_helper_property_follow, NULL);
+     }
+   else
+     {
+        _helper_win_follow(NULL, NULL, NULL, NULL);
+        evas_object_event_callback_add(ap.win, EVAS_CALLBACK_RESIZE, 
_helper_win_follow, NULL);
+     }
+
+   evas_object_show(helper);
+}
+
+void
 popup_log_message_helper(const char *msg)
 {
    Evas_Object *box, *en, *lab;
diff --git a/src/bin/ui/property_macros.h b/src/bin/ui/property_macros.h
index 6be84db..635da7a 100644
--- a/src/bin/ui/property_macros.h
+++ b/src/bin/ui/property_macros.h
@@ -2164,7 +2164,7 @@ prop_##SUB##_##VALUE##_update(Group_Prop_Data *pd) \
  * @ingroup Property_Macro
  */
 #define STATE_ATTR_COLOR_CALLBACK(SUB, VALUE, MEMBER, DESCRIPTION) \
-static void \
+static Eina_Bool \
 _on_##MEMBER##_##VALUE##_change(void *data, \
                                 Evas_Object *obj, \
                                 void *event_info __UNUSED__) \
@@ -2184,8 +2184,9 @@ _on_##MEMBER##_##VALUE##_change(void *data, \
      } \
    evas_object_color_set(pd->attributes.MEMBER.VALUE##_obj, r*a/255, g*a/255, 
b*a/255, a); \
    evas_object_smart_callback_call(ap.win, SIGNAL_PROPERTY_ATTRIBUTE_CHANGED, 
NULL); \
+   return true; \
 } \
-static void \
+static Eina_Bool \
 _on_##MEMBER##_##VALUE##_dismissed(void *data, \
                                    Evas_Object *obj, \
                                    void *event_info __UNUSED__) \
@@ -2193,12 +2194,6 @@ _on_##MEMBER##_##VALUE##_dismissed(void *data, \
    int r, g, b, a; \
    Group_Prop_Data *pd = (Group_Prop_Data *)data; \
    assert(pd->change != NULL); \
-   evas_object_smart_callback_del_full(obj, "color,changed", \
-                                       _on_##MEMBER##_##VALUE##_change, pd); \
-   evas_object_smart_callback_del_full(obj, "palette,item,selected", \
-                                       _on_##MEMBER##_##VALUE##_change, pd); \
-   evas_object_smart_callback_del_full(obj, "dismissed", \
-                                       _on_##MEMBER##_##VALUE##_dismissed, 
pd); \
    edje_edit_##SUB##_##VALUE##_get(pd->group->edit_object, pd->part->name, \
                                    pd->part->current_state->parsed_name, \
                                    pd->part->current_state->parsed_val, \
@@ -2209,29 +2204,20 @@ _on_##MEMBER##_##VALUE##_dismissed(void *data, \
    history_change_add(pd->group->history, pd->change); \
    pd->change = NULL; \
    evas_object_hide(obj); \
+   return true; \
 } \
 static void \
 _on_##MEMBER##_##VALUE##_clicked(void *data, \
-                                 Evas_Object *obj, \
+                                 Evas_Object *obj __UNUSED__, \
                                  const char *emission __UNUSED__, \
                                  const char *source __UNUSED__) \
 { \
-   int x, y; \
-   int r, g, b, a; \
-   Evas_Object *colorsel; \
    Group_Prop_Data *pd = (Group_Prop_Data *)data; \
-   assert(pd->change == NULL); \
-   colorsel = colorselector_get(); \
-   pd->change = change_add(NULL); \
-   evas_object_color_get(pd->attributes.MEMBER.VALUE##_obj, &r, &g, &b, &a); \
-   colorselector_color_set(colorsel, r, g, b, a); \
-   evas_object_smart_callback_add(colorsel, "color,changed", \
-                                  _on_##MEMBER##_##VALUE##_change, pd); \
-   evas_object_smart_callback_add(colorsel, "dismissed", \
-                                  _on_##MEMBER##_##VALUE##_dismissed, pd); \
-   evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y); \
-   evas_object_move(colorsel, x, y); \
-   evas_object_show(colorsel); \
+   popup_colorselector_helper("Select some colors", \
+                              pd->attributes.MEMBER.VALUE##_obj, \
+                              _on_##MEMBER##_##VALUE##_dismissed, \
+                              _on_##MEMBER##_##VALUE##_change, \
+                              pd); \
 }
 
 /*****************************************************************************/

-- 


Reply via email to