yakov pushed a commit to branch master.

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

commit db68eb0ec69b668b5db392850f48218ced53a604
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Thu Dec 3 17:10:22 2015 +0200

    Implement centralized canvas update
    
    Implement canvas, objtree, propview, borders update
    in one place: callback called update updater completion.
    
    Also clean up and refactor some code.
---
 src/bin/gui/editor.c | 278 +++++++++++++++++++++++++--------------------------
 1 file changed, 137 insertions(+), 141 deletions(-)

diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c
index 5052cc4..46a350e 100644
--- a/src/bin/gui/editor.c
+++ b/src/bin/gui/editor.c
@@ -294,7 +294,7 @@ enum
              eo_do(line, efl_gfx_size_set(l, w));\
           }\
        eo_do(line, efl_gfx_visible_set(visibility));\
-       eo_do(line, efl_gfx_stack_raise());\
+       if (visibility) eo_do(line, efl_gfx_stack_raise());\
    })
 
 #define MARKER(base_obj, id, x, y, visibility) \
@@ -327,7 +327,7 @@ enum
              eo_do(_m, efl_gfx_position_set(x, y)); \
           }\
         eo_do(_m, efl_gfx_visible_set(visibility));\
-        eo_do(_m, efl_gfx_stack_raise());\
+        if (visibility) eo_do(_m, efl_gfx_stack_raise());\
     })
 
 /* Draws border around obj, Evas is taken from base_obj;
@@ -338,6 +338,7 @@ _wdg_border_draw(const Gui_Widget *wdg, Eina_Bool 
visibility, int border_type_co
    const Gui_Context *ctx = _active_context_get();
    if (!ctx) return;
    const Gui_Session *session = gui_context_editor_session_get(ctx);
+   static Eo *_base_obj_prev = NULL;
    Eo *obj = NULL;
    Eo *base_obj = canvas_get();
    if (wdg)
@@ -360,6 +361,27 @@ _wdg_border_draw(const Gui_Widget *wdg, Eina_Bool 
visibility, int border_type_co
           }
      }
 
+   if (border_type_color == BORDER_SELECTION)
+     {
+        if ((_base_obj_prev) && (base_obj != _base_obj_prev))
+          {
+             LINE(_base_obj_prev, BORDER_TOP, BORDER_SELECTION, 0, 0, 0, 0, 
EINA_FALSE);
+             LINE(_base_obj_prev, BORDER_BOTTOM, BORDER_SELECTION, 0, 0, 0, 0, 
EINA_FALSE);
+             LINE(_base_obj_prev, BORDER_RIGHT, BORDER_SELECTION, 0, 0, 0, 0, 
EINA_FALSE);
+             LINE(_base_obj_prev, BORDER_LEFT, BORDER_SELECTION, 0, 0, 0, 0, 
EINA_FALSE);
+
+             MARKER(_base_obj_prev, BORDER_MARKER_TOP_LEFT, 0, 0, EINA_FALSE);
+             MARKER(_base_obj_prev, BORDER_MARKER_TOP, 0, 0, EINA_FALSE);
+             MARKER(_base_obj_prev, BORDER_MARKER_TOP_RIGHT, 0, 0, EINA_FALSE);
+             MARKER(_base_obj_prev, BORDER_MARKER_RIGHT, 0, 0, EINA_FALSE);
+             MARKER(_base_obj_prev, BORDER_MARKER_BOTTOM_RIGHT, 0, 0, 
EINA_FALSE);
+             MARKER(_base_obj_prev, BORDER_MARKER_BOTTOM, 0, 0, EINA_FALSE);
+             MARKER(_base_obj_prev, BORDER_MARKER_BOTTOM_LEFT, 0, 0, 
EINA_FALSE);
+             MARKER(_base_obj_prev, BORDER_MARKER_LEFT, 0, 0, EINA_FALSE);
+          }
+        _base_obj_prev = base_obj;
+     }
+
    Evas_Coord ox = 0, oy = 0, ow = 0, oh = 0, minw = 0, minh = 0;
    Evas_Coord lw = 0 , lh = 0, hs = 5;
 
@@ -454,7 +476,7 @@ _editor_wdg_selected_set(const Gui_Widget *wdg)
    /* Hide previous border*/
    if (old_wdg)
      {
-        _wdg_border_draw(old_wdg, EINA_FALSE, BORDER_SELECTION);
+       // _wdg_border_draw(old_wdg, EINA_FALSE, BORDER_SELECTION);
      }
    else
      {
@@ -483,6 +505,7 @@ _editor_wdg_selected_set(const Gui_Widget *wdg)
    else
      {
         gui_context_data_set(_active_context_get(), SELECTED_WDG, NULL);
+        _wdg_border_draw(NULL, EINA_TRUE, BORDER_SELECTION);
      }
 }
 
@@ -3182,94 +3205,6 @@ _wdg_parent_win_reload(const Gui_Widget *wdg)
    _editor_wdg_selected_set(NULL);
 }
 
-static void
-_editor_undo_redo_post(const Memento *memento)
-{
-   Memento_Command *cmd;
-   const Eina_List *cmds_list = memento_commands_get(memento), *itr;
-   EINA_LIST_FOREACH(cmds_list, itr, cmd)
-     {
-        Memento_Type type = memento_command_type_get(cmd);
-        Eid *eid = memento_command_wdg_get(cmd);
-        Gui_Widget *memento_wdg = wdg_get(eid);
-        switch (type)
-          {
-           case MEMENTO_PROPERTY:
-                {
-                   objtree_item_selected_set(memento_wdg);
-                   proplayout_view_switch(PROPERTY_TYPE);
-                   // FIXME
-                   // depending on direction need
-                   // to update old or new value in propview
-                   // propview_item_update(to);
-
-                   //set prop selected
-                   //if (op_desc)
-                   //  propview_item_selected_set(op_desc);
-                   break;
-                }
-           case MEMENTO_OBJ_CONTAINER:
-           case MEMENTO_ITEM_CONTAINER_ITEM:
-                {
-                   proplayout_view_switch(CONTENT_TYPE);
-                   _editor_wdg_selected_set(memento_wdg);
-                   objtree_item_selected_set(memento_wdg);
-                   break;
-                }
-           case MEMENTO_CALLBACK:
-                {
-                   proplayout_view_switch(CALLBACK_TYPE);
-                   _editor_wdg_selected_set(memento_wdg);
-
-                   // FIXME
-                   // depending on direction need
-                   // to select old or new value in propview
-                   //Eid *cb_eid = cb_eid_get(to);
-                   //cbview_item_selected_set(cb_eid);
-                   break;
-                }
-           case MEMENTO_CALLBACK_ADD_DEL:
-                {
-                   proplayout_view_switch(CALLBACK_TYPE);
-                   _editor_wdg_selected_set(memento_wdg);
-                   break;
-                }
-           case MEMENTO_WIDGET:
-           case MEMENTO_WIDGET_PARENT:
-                {
-                   if (memento_wdg)
-                     {
-                        _editor_wdg_selected_set(memento_wdg);
-                        objtree_item_selected_set(memento_wdg);
-                     }
-                   break;
-                }
-           case MEMENTO_NONE:
-           case MEMENTO_WIDGET_NAME:
-                {
-                   /*FIXME:
-                    * update item in objtree*/
-                   const Gui_Widget *sel = 
gui_context_data_get(_active_context_get(), SELECTED_WDG);
-                   objtree_item_refresh(memento_wdg);
-                   objtree_item_selected_set(sel);
-                   break;
-                }
-           case MEMENTO_ACTION:
-                {
-                   proplayout_view_switch(CALLBACK_TYPE);
-                   break;
-                }
-           case MEMENTO_WIDGET_PUBLIC:
-                {
-                   proplayout_view_switch(DESCRIPTION_TYPE);
-                   break;
-                }
-           default:
-              ERR("case - default");
-          }
-     }
-}
-
 /* Undo last action */
 static Eina_Bool
 _editor_undo(const Gui_Context *ctx)
@@ -3283,8 +3218,6 @@ _editor_undo(const Gui_Context *ctx)
    /* Update propview. */
    context_memento_not_updated_add((Gui_Context *) ctx, head_memento, 
EINA_FALSE);
 
-   _editor_undo_redo_post(head_memento);
-
    return EINA_TRUE;
 }
 
@@ -3300,8 +3233,6 @@ _editor_redo(const Gui_Context *ctx)
    head_memento = context_current_memento_get(ctx);
    context_memento_not_updated_add((Gui_Context *) ctx, head_memento, 
EINA_TRUE);
 
-   _editor_undo_redo_post(head_memento);
-
    return EINA_TRUE;
 }
 
@@ -3373,21 +3304,6 @@ _editor_selected_wdg_del_cb()
    eid_active_set(wdg_eid_get(wdg), EINA_FALSE);
    memento_command_add(wdg_eid_get(wdg), MEMENTO_WIDGET,  (void *) (intptr_t) 
EINA_TRUE, (void *) (intptr_t) EINA_FALSE);
    memento_focused_widget_add(wdg_eid_get(wdg));
-
-   /* if parent_wdg is not NULL, it's not window, so it has parent.
-    * if parent wdg is NULL, wdg is window, so just delete it. */
-#if 0
-   if (parent_wdg)
-     {
-        _wdg_parent_win_reload(parent_wdg);
-     }
-#endif
-//   proplayout_build(NULL);
-
-   /* Set selected widget: t.e. if I delete button, box will be selected after.
-    * If I delete window, main item will be selected. */
-//   objtree_item_selected_set(parent_wdg);
-//   _editor_wdg_selected_set(parent_wdg);
    context_memento_finalize(ctx);
 }
 
@@ -3673,11 +3589,7 @@ _drop_property_cb(void *data, Evas_Object *obj, void 
*event_info EINA_UNUSED)
           {
              memento_command_add(wdg_eid_get(wdg), MEMENTO_PROPERTY, prop, 
NULL);
              memento_focused_widget_add(wdg_eid_get(wdg));
-
              wdg_prop_remove((Gui_Widget *) wdg, (Gui_Widget_Property *) prop);
-             proplayout_build(NULL);
-             _editor_wdg_selected_set(wdg);
-             objtree_item_selected_set(wdg);
           }
      }
    eo_do(obj, elm_obj_ctxpopup_dismiss());
@@ -3784,12 +3696,6 @@ _field_update_from_itemview(void *data EINA_UNUSED, Eo 
*obj, const Eo_Event_Desc
           {
              gui_value_string_free(val);
              gui_value_string_set(val, entry_data);
-
-             /* Reloading all window. */
-             proplayout_build(NULL);
-             _editor_wdg_selected_set(wdg);
-             objtree_item_selected_set(wdg);
-             itemview_item_selected_set(new_wit);
           }
      }
    /* Currently hoversel is used only for callback name
@@ -3887,7 +3793,6 @@ _itemview_item_selected(void *data EINA_UNUSED, 
Evas_Object *obj EINA_UNUSED, vo
 static Eina_Bool
 _itemview_item_do_(unsigned int type)
 {
-   Eina_Bool reload = EINA_TRUE;
    static int i = -1;
    i++;
    Item_Container_Item *wit = NULL, *parent_it = NULL;
@@ -3998,7 +3903,7 @@ _itemview_item_do_(unsigned int type)
         item_container_item_set_on_id(item_container_item_eid_get(parent_it), 
new_parent_item);
 
         intptr_t dir = (type == ITEM_MOVE_UP) ? UP : DOWN;
-        if ((reload = item_container_item_reorder(wit, dir)))
+        if (item_container_item_reorder(wit, dir))
           {
              memento_command_add(wdg_eid_get(wdg), 
MEMENTO_ITEM_CONTAINER_ITEM, parent_it, new_parent_item);
           }
@@ -4036,14 +3941,6 @@ _itemview_item_do_(unsigned int type)
          ERR("case - default");
      }
 
-   if (reload)
-     {
-        proplayout_build(NULL);
-        _editor_wdg_selected_set(wdg);
-        objtree_item_selected_set(wdg);
-        itemview_item_selected_set(it);
-     }
-
    context_memento_finalize(_active_context_get());
    return EO_CALLBACK_CONTINUE;
 }
@@ -4114,10 +4011,6 @@ _content_reorder_from_propview(void *data, Eo *obj 
EINA_UNUSED, const Eo_Event_D
              memento_command_add(wdg_eid_get(wdg), MEMENTO_OBJ_CONTAINER, 
_old_container, _new_container);
              memento_focused_widget_add(wdg_eid_get(wdg));
              context_memento_finalize(_active_context_get());
-
-             /* Update propview. */
-             _editor_wdg_selected_set(wdg);
-             objtree_item_selected_set(wdg);
           }
         obj_container_unref(_old_container);
      }
@@ -4339,10 +4232,6 @@ _content_change_from_propview(void *data EINA_UNUSED, Eo 
*obj, const Eo_Event_De
                }
              ci = obj_container_item_new(new_prop, eid);
              wdg_obj_container_item_add((Gui_Widget *) wdg, ci, 
pfd->it_data->idx);
-
-             /* Update propview. */
-             _editor_wdg_selected_set(wdg);
-             objtree_item_selected_set(wdg);
           }
      }
 
@@ -4827,13 +4716,120 @@ _context_changed_cb(void *data EINA_UNUSED, Memento 
*mem, Eina_Bool dir EINA_UNU
    _canvas_name_update(ctx, EINA_FALSE);
    if (mem)
      {
-        const Eina_List *cmds = memento_commands_get(mem), *itr;
         Memento_Command *cmd;
+        const Eina_List *cmds = memento_commands_get(mem), *itr;
+        const Eina_List *focused_wdgs = memento_focused_widget_list_get(mem);
+
+        Eid *focused_eid = NULL;
+        if (eina_list_count(focused_wdgs) == 1)
+          {
+             focused_eid = eina_list_data_get(focused_wdgs);
+          }
+        else
+          {
+             ERR("Add support for multiple focused widgets");
+          }
+        Gui_Widget *focused_wdg = wdg_get(focused_eid);
+
+        Gui_Widget_Property *prop = NULL;
+        Eina_Bool refresh_objtree_item = EINA_FALSE;
+        It_Data_Type propview_type = DEFAULT_TYPE;
         EINA_LIST_FOREACH(cmds, itr, cmd)
           {
+             Memento_Type type = memento_command_type_get(cmd);
              Eid *eid = memento_command_wdg_get(cmd);
-             Gui_Widget *wdg = wdg_get(eid);
-             if (wdg) objtree_item_selected_set(wdg);
+             Gui_Widget *memento_wdg = wdg_get(eid);
+
+             switch (type)
+               {
+                case MEMENTO_PROPERTY:
+                     {
+                        Gui_Widget_Property *from = 
memento_command_old_pointer_get(cmd);
+                        Gui_Widget_Property *to = 
memento_command_new_pointer_get(cmd);
+                        prop = from ? from : to;
+                        propview_type = PROPERTY_TYPE;
+                        break;
+                     }
+                case MEMENTO_OBJ_CONTAINER:
+                     {
+                        if (focused_wdg == memento_wdg)
+                          propview_type = CONTENT_TYPE;
+                        /* When wdg is deleted from container, it will be NULL.
+                         * So assign container to be selected. */
+                        if (!focused_wdg) focused_wdg = memento_wdg;
+                        break;
+                     }
+                case MEMENTO_ITEM_CONTAINER_ITEM:
+                     {
+                        propview_type = ITEM_TYPE;
+                        break;
+                     }
+                case MEMENTO_WIDGET:
+                     {
+                        if (!focused_wdg)
+                          {
+                             eid_active_set(focused_eid, EINA_TRUE);
+                             focused_wdg = (Gui_Widget *) 
wdg_parent_get(wdg_get(focused_eid));
+                             eid_active_set(focused_eid, EINA_FALSE);
+                          }
+                        break;
+                     }
+                case MEMENTO_NONE:
+                case MEMENTO_WIDGET_PARENT:
+                     {
+                        break;
+                     }
+                case MEMENTO_CALLBACK:
+                case MEMENTO_CALLBACK_ADD_DEL:
+                case MEMENTO_ACTION:
+                     {
+                        propview_type = CALLBACK_TYPE;
+                        break;
+                     }
+                case MEMENTO_WIDGET_NAME:
+                     {
+                        refresh_objtree_item = EINA_TRUE;
+                     }
+                case MEMENTO_WIDGET_PUBLIC:
+                     {
+                        propview_type = DESCRIPTION_TYPE;
+                        break;
+                     }
+                default:
+                   ERR("case - default");
+               }
+          }
+
+        _editor_wdg_selected_set(focused_wdg);
+        objtree_item_selected_set(focused_wdg);
+        proplayout_view_switch(propview_type);
+
+        switch (propview_type)
+          {
+
+           case DEFAULT_TYPE:
+                {
+                   break;
+                }
+           case CALLBACK_TYPE:
+           case DESCRIPTION_TYPE:
+                {
+                   if (refresh_objtree_item) objtree_item_refresh(focused_wdg);
+                   break;
+                }
+           case PROPERTY_TYPE:
+                {
+                   if (prop) 
propview_item_selected_set(prop_op_desc_get(prop));
+                   break;
+                }
+           case CONTENT_TYPE:
+                {
+                   break;
+                }
+           case ITEM_TYPE:
+                {
+                   break;
+                }
           }
      }
 }

-- 


Reply via email to