yakov pushed a commit to branch master.

http://git.enlightenment.org/tools/erigo.git/commit/?id=9615ba56a8f983a6301fd90a36dfb7269c987a21

commit 9615ba56a8f983a6301fd90a36dfb7269c987a21
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Sun Nov 8 14:46:24 2015 +0200

    Refactoring widgets resizing
---
 src/bin/gui/editor.c | 97 ++++++++++++----------------------------------------
 1 file changed, 21 insertions(+), 76 deletions(-)

diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c
index 0c38f23..2698ac1 100644
--- a/src/bin/gui/editor.c
+++ b/src/bin/gui/editor.c
@@ -535,8 +535,6 @@ static Eina_Bool drag_started = EINA_FALSE;
 typedef struct
 {
    void *data;
-   Gui_Widget_Property *prop_size;
-   Gui_Widget_Property *prop_pos;
    Evas_Coord down_x;
    Evas_Coord down_y;
    Evas_Coord object_w;
@@ -547,7 +545,7 @@ typedef struct
    Evas_Coord delta_y;
 } _Marker_Move_Data;
 
-static _Marker_Move_Data _mmd = {NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0};
+static _Marker_Move_Data _mmd = {NULL, 0, 0, 0, 0, 0, 0, 0, 0};
 
 static Eina_Bool
 _drag_widget_start(void *data)
@@ -801,6 +799,7 @@ _marker_mouse_move(void *data, Eo *marker EINA_UNUSED, 
const Eo_Event_Descriptio
              Op_Desc *op = db_mro_op_desc_get(wdg_class_name_get(wdg), 
DB_DEF_EFL_GFX_BASE_CLASS, SIZE_SET);
              prop = prop_create_for_op(op);
              wdg_prop_add((Gui_Widget *) wdg, prop);
+             memento_command_add(wdg_eid_get(wdg), MEMENTO_PROPERTY, NULL, 
prop);
 
              val = prop_value_nth_get(prop, 0);
              gui_value_int_set(val, new_w);
@@ -825,6 +824,7 @@ _marker_mouse_move(void *data, Eo *marker EINA_UNUSED, 
const Eo_Event_Descriptio
              Op_Desc *op = db_mro_op_desc_get(wdg_class_name_get(wdg), 
DB_DEF_EFL_GFX_BASE_CLASS, POSITION_SET);
              prop = prop_create_for_op(op);
              wdg_prop_add((Gui_Widget *) wdg, prop);
+             memento_command_add(wdg_eid_get(wdg), MEMENTO_PROPERTY, NULL, 
prop);
 
              val = prop_value_nth_get(prop, 0);
              gui_value_int_set(val, new_x);
@@ -857,27 +857,30 @@ _marker_mouse_down(void *data, Eo *obj, const 
Eo_Event_Description *desc EINA_UN
    _mmd.delta_x = 0;
    _mmd.delta_y = 0;
 
-   Gui_Widget_Property *prop;
-   prop = wdg_prop_get(wdg, DB_DEF_EFL_GFX_BASE_CLASS, SIZE_SET);
-   if (prop)
+   Gui_Widget_Property *old_prop, *new_prop;
+   old_prop = wdg_prop_get(wdg, DB_DEF_EFL_GFX_BASE_CLASS, SIZE_SET);
+   if (old_prop)
      {
-        _mmd.prop_size = prop;
-        prop_ref(prop);
-        wdg_prop_remove((Gui_Widget *) wdg, prop);
+        new_prop = prop_copy(old_prop);
+        memento_command_add(wdg_eid_get(wdg), MEMENTO_PROPERTY, old_prop, 
new_prop);
+        wdg_prop_remove((Gui_Widget *) wdg, old_prop);
+        wdg_prop_add((Gui_Widget *) wdg, new_prop);
 
-        _mmd.object_w = INT_GET(prop_value_nth_get(prop, 0));
-        _mmd.object_h = INT_GET(prop_value_nth_get(prop, 1));
+        _mmd.object_w = INT_GET(prop_value_nth_get(old_prop, 0));
+        _mmd.object_h = INT_GET(prop_value_nth_get(old_prop, 1));
      }
    if (!IS_MAIN(wdg))
      {
-        prop = wdg_prop_get(wdg, DB_DEF_EFL_GFX_BASE_CLASS, POSITION_SET);
-        if (prop)
+        old_prop = wdg_prop_get(wdg, DB_DEF_EFL_GFX_BASE_CLASS, POSITION_SET);
+        if (old_prop)
           {
-             _mmd.prop_pos = prop;
-             prop_ref(prop);
-             wdg_prop_remove((Gui_Widget *) wdg, prop);
-             _mmd.object_x = INT_GET(prop_value_nth_get(prop, 0));
-             _mmd.object_y = INT_GET(prop_value_nth_get(prop, 1));
+             new_prop = prop_copy(old_prop);
+             memento_command_add(wdg_eid_get(wdg), MEMENTO_PROPERTY, old_prop, 
new_prop);
+             wdg_prop_remove((Gui_Widget *) wdg, old_prop);
+             wdg_prop_add((Gui_Widget *) wdg, new_prop);
+
+             _mmd.object_x = INT_GET(prop_value_nth_get(old_prop, 0));
+             _mmd.object_y = INT_GET(prop_value_nth_get(old_prop, 1));
           }
      }
    else
@@ -902,70 +905,12 @@ _marker_mouse_up(void *data EINA_UNUSED, Eo *obj, const 
Eo_Event_Description *de
    eo_do(obj, eo_event_callback_del(EVAS_OBJECT_EVENT_MOUSE_UP, 
_marker_mouse_up, data));
 
    const Gui_Widget *wdg = _editor_wdg_selected_get();
-
-   Gui_Widget_Property *prop = wdg_prop_get(wdg, DB_DEF_EFL_GFX_BASE_CLASS, 
SIZE_SET);
-   /* mouse was not moved... */
-   if (!prop)
-     {
-        /*...put old property back. */
-        if (_mmd.prop_size)
-          {
-             wdg_prop_add((Gui_Widget *) wdg, _mmd.prop_size);
-          }
-        goto end;
-     }
-   else
-     {
-        if (_mmd.prop_size &&
-            (INT_GET(prop_value_nth_get(prop, 0)) == 
INT_GET(prop_value_nth_get(_mmd.prop_size, 0))) &&
-            (INT_GET(prop_value_nth_get(prop, 1)) == 
INT_GET(prop_value_nth_get(_mmd.prop_size, 1))))
-          {
-             goto end;
-          }
-        memento_command_add(wdg_eid_get(wdg), MEMENTO_PROPERTY, 
_mmd.prop_size, prop);
-     }
-
-   /* For non Main widget save position in memento. */
-   if (!IS_MAIN(wdg))
-     {
-        prop = wdg_prop_get(wdg, DB_DEF_EFL_GFX_BASE_CLASS, POSITION_SET);
-        if (!prop)
-          {
-             if (_mmd.prop_pos)
-               {
-                  wdg_prop_add((Gui_Widget *) wdg, _mmd.prop_pos);
-               }
-             goto end;
-          }
-        else
-          {
-             if (_mmd.prop_pos &&
-                (INT_GET(prop_value_nth_get(prop, 0)) == 
INT_GET(prop_value_nth_get(_mmd.prop_pos, 0))) &&
-                 (INT_GET(prop_value_nth_get(prop, 1)) == 
INT_GET(prop_value_nth_get(_mmd.prop_pos, 1))))
-               {
-                  goto end;
-               }
-             memento_command_add(wdg_eid_get(wdg), MEMENTO_PROPERTY, 
_mmd.prop_pos, prop);
-          }
-     }
-
    /* For main widget update canvas size*/
    if (IS_MAIN(wdg))
      {
         _canvas_resize_cb(NULL, g->main_win->canvas_scroller, NULL, NULL);
      }
 
-end:
-   if (_mmd.prop_size)
-     {
-        prop_unref(_mmd.prop_size);
-        _mmd.prop_size = NULL;
-     }
-   if (_mmd.prop_pos)
-     {
-        prop_unref(_mmd.prop_pos);
-        _mmd.prop_pos = NULL;
-     }
    _mmd.down_x = 0;
    _mmd.down_y = 0;
    _mmd.object_w = 0;

-- 


Reply via email to