rimmed pushed a commit to branch master.

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

commit 06c0bb9005863e4fd40c6897a0627227197ba291
Author: Andrii Kroitor <an.kroi...@samsung.com>
Date:   Mon Oct 5 16:40:21 2015 +0300

    property: use editor api for drag
---
 src/bin/editor/editor.h      | 14 ++++++++++
 src/bin/ui/property.c        |  8 +++---
 src/bin/ui/property_macros.h | 63 +++++++++++++++++++++++++++++++++++++++-----
 3 files changed, 75 insertions(+), 10 deletions(-)

diff --git a/src/bin/editor/editor.h b/src/bin/editor/editor.h
index 605af76..a41bb4b 100644
--- a/src/bin/editor/editor.h
+++ b/src/bin/editor/editor.h
@@ -454,6 +454,20 @@ editor_part_cursor_mode_set(Evas_Object *obj, Change 
*change, Eina_Bool merge, c
       unsigned char new_val);
 
 Eina_Bool
+editor_part_drag_x_set(Evas_Object *obj, Change *change, Eina_Bool merge, 
const char *part_name,
+      int new_val);
+Eina_Bool
+editor_part_drag_step_x_set(Evas_Object *obj, Change *change, Eina_Bool merge, 
const char *part_name,
+      int new_val);
+Eina_Bool
+editor_part_drag_y_set(Evas_Object *obj, Change *change, Eina_Bool merge, 
const char *part_name,
+      int new_val);
+Eina_Bool
+editor_part_drag_step_y_set(Evas_Object *obj, Change *change, Eina_Bool merge, 
const char *part_name,
+      int new_val);
+
+
+Eina_Bool
 editor_part_clip_to_set(Evas_Object *obj, Change *change, Eina_Bool merge, 
const char *part_name,
       const char * new_val);
 Eina_Bool
diff --git a/src/bin/ui/property.c b/src/bin/ui/property.c
index 635e94d..2b1f606 100644
--- a/src/bin/ui/property.c
+++ b/src/bin/ui/property.c
@@ -1416,8 +1416,8 @@ PART_ATTR_SOURCE_UPDATE(part, source)
    PART_ATTR_1COMBOBOX_LIST_CALLBACK(TEXT, SUB, VALUE, TYPE, DESCRIPTION) \
    PART_ATTR_1COMBOBOX_LIST_ADD(TEXT, SUB, VALUE, MEMBER, LIST, TOOLTIP)
 
-#define PART_ATTR_DRAG(TEXT, SUB, VALUE1, VALUE2) \
-   PART_ATTR_DRAG_CALLBACK(SUB, VALUE1, VALUE2) \
+#define PART_ATTR_DRAG(TEXT, SUB, VALUE1, VALUE2, DESCRIPTION1, DESCRIPTION2) \
+   PART_ATTR_DRAG_CALLBACK(SUB, VALUE1, VALUE2, DESCRIPTION1, DESCRIPTION2) \
    PART_ATTR_DRAG_UPDATE(SUB, VALUE1, VALUE2) \
    PART_ATTR_DRAG_ADD(TEXT, SUB, VALUE1, VALUE2)
 
@@ -1441,8 +1441,8 @@ PART_ATTR_1COMBOBOX(_("group source"), part, source, part,
                     _("Used for the group to be loaded and used to display 
GROUP part."),
                     _("group source changed to %s"))
 /* part drag property */
-PART_ATTR_DRAG(_("axis X"), part_drag, x, step_x)
-PART_ATTR_DRAG(_("axis Y"), part_drag, y, step_y)
+PART_ATTR_DRAG(_("axis X"), part_drag, x, step_x, _("drag x changed to %s"), 
_("drag step x changed from %d to %d"))
+PART_ATTR_DRAG(_("axis Y"), part_drag, y, step_y, _("drag y changed to %s"), 
_("drag step y changed from %d to %d"))
 PART_ATTR_1COMBOBOX(_("drag area"), part_drag, confine, part_drag,
                     _("Limits the movement of the dragged part to another 
part's container"),
                     _("drag area changed to %s"))
diff --git a/src/bin/ui/property_macros.h b/src/bin/ui/property_macros.h
index c3eda0f..075d173 100644
--- a/src/bin/ui/property_macros.h
+++ b/src/bin/ui/property_macros.h
@@ -944,6 +944,8 @@ prop_##SUB##_##VALUE1##_##VALUE2##_add(Evas_Object *parent, 
\
    SPINNER_ADD(item, pd->attributes.SUB.VALUE2, 0.0, 9999.0, 1.0, true) \
    elm_spinner_label_format_set(pd->attributes.SUB.VALUE2, N_("%.0f")); \
    if (tooltip2) elm_object_tooltip_text_set(pd->attributes.SUB.VALUE2, 
tooltip2); \
+   evas_object_smart_callback_add(pd->attributes.SUB.VALUE2, 
"spinner,drag,start", _on_part_drag_##VALUE2##_start, pd); \
+   evas_object_smart_callback_add(pd->attributes.SUB.VALUE2, 
"spinner,drag,stop", _on_part_drag_##VALUE2##_stop, pd); \
    evas_object_smart_callback_add(pd->attributes.SUB.VALUE2, "changed", 
_on_part_drag_##VALUE2##_change, pd); \
    evas_object_event_callback_priority_add(pd->attributes.SUB.VALUE2, 
EVAS_CALLBACK_MOUSE_WHEEL, \
                                            EVAS_CALLBACK_PRIORITY_BEFORE, \
@@ -984,7 +986,7 @@ prop_part_drag_##VALUE1##_##VALUE2##_update(Prop_Data *pd) \
  *
  * @ingroup Property_Macro
  */
-#define PART_ATTR_DRAG_CALLBACK(SUB, VALUE1, VALUE2) \
+#define PART_ATTR_DRAG_CALLBACK(SUB, VALUE1, VALUE2, DESCRIPTION1, 
DESCRIPTION2) \
 static void \
 _on_part_drag_##VALUE1##_change(void *data, \
                                 Evas_Object *obj, \
@@ -992,20 +994,69 @@ _on_part_drag_##VALUE1##_change(void *data, \
 { \
    Prop_Data *pd = (Prop_Data *)data; \
    Eina_Bool value = elm_check_state_get(obj); \
-   edje_edit_part_drag_##VALUE1##_set(pd->group->edit_object, pd->part->name, 
value); \
+   Eina_Stringshare *msg = eina_stringshare_printf(DESCRIPTION1, 
value?_("true"):_("false")); \
+   Change *change = change_add(msg); \
+   eina_stringshare_del(msg); \
+   editor_part_drag_##VALUE1##_set(pd->group->edit_object, change, false, 
pd->part->name, value); \
    prop_part_drag_control_disable_set(pd, false); \
-   /*project_changed(false);*/ \
+   history_change_add(pd->group->history, change); \
    evas_object_smart_callback_call(ap.win, SIGNAL_PROPERTY_ATTRIBUTE_CHANGED, 
NULL); \
 } \
 static void \
+_on_part_drag_##VALUE2##_start(void *data, \
+                               Evas_Object *obj __UNUSED__, \
+                               void *ei __UNUSED__) \
+{ \
+   Prop_Data *pd = (Prop_Data *)data; \
+   assert(pd->change == NULL); \
+   pd->change = change_add(NULL); \
+   pd->old_int_val = edje_edit_##SUB##_##VALUE2##_get(pd->group->edit_object, 
pd->part->name); \
+} \
+static void \
+_on_part_drag_##VALUE2##_stop(void *data, \
+                              Evas_Object *obj __UNUSED__, \
+                              void *ei __UNUSED__) \
+{ \
+   Prop_Data *pd = (Prop_Data *)data; \
+   Eina_Stringshare *msg; \
+   assert(pd->change != NULL); \
+   int new_val = edje_edit_##SUB##_##VALUE2##_get(pd->group->edit_object, 
pd->part->name); \
+   if (new_val != pd->old_int_val) \
+     { \
+        msg = eina_stringshare_printf(DESCRIPTION2, pd->old_int_val, new_val); 
\
+        change_description_set(pd->change, msg); \
+        eina_stringshare_del(msg); \
+        history_change_add(pd->group->history, pd->change); \
+     } \
+   else \
+     change_free(pd->change); \
+   pd->change = NULL; \
+} \
+static void \
 _on_part_drag_##VALUE2##_change(void *data, \
                                 Evas_Object *obj, \
-                                void *event_info __UNUSED__) \
+                                void *ei) \
 { \
    Prop_Data *pd = (Prop_Data *)data; \
    int value = elm_spinner_value_get(obj); \
-   edje_edit_part_drag_##VALUE2##_set(pd->group->edit_object, pd->part->name, 
value); \
-   /*project_changed(false);*/ \
+   if (pd->change) \
+     { \
+        if (!editor_##SUB##_##VALUE2##_set(pd->group->edit_object, pd->change, 
true, pd->part->name, value)) \
+        { \
+           ERR("editor_group_"#SUB"_"#VALUE2"_set failed"); \
+           abort(); \
+        } \
+     } \
+   else \
+     { \
+        _on_part_drag_##VALUE2##_start(data, obj, ei); \
+        if (!editor_##SUB##_##VALUE2##_set(pd->group->edit_object, pd->change, 
true, pd->part->name, value)) \
+        { \
+           ERR("editor_"#SUB"_"#VALUE2"_set failed"); \
+           abort(); \
+        } \
+        _on_part_drag_##VALUE2##_stop(data, obj, ei); \
+     } \
    evas_object_smart_callback_call(ap.win, SIGNAL_PROPERTY_ATTRIBUTE_CHANGED, 
NULL); \
 }
 

-- 


Reply via email to