yakov pushed a commit to branch master.

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

commit df410cd20ae858bbfb4e4b02faa8cb8790c863b2
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Mon Mar 28 15:54:28 2016 +0300

    Redesing view update
    
    The problem is: when object is re-created, rendering occurs during following
    iterations. Thus properties values can pe properly fetched after.
---
 src/bin/gui/editor.c |   1 +
 src/lib/updater.c    | 279 +++++++++++++++++++++++++++++----------------------
 2 files changed, 159 insertions(+), 121 deletions(-)

diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c
index 0fd29f8..7379ca7 100644
--- a/src/bin/gui/editor.c
+++ b/src/bin/gui/editor.c
@@ -3688,6 +3688,7 @@ _drop_property_cb(void *data, Evas_Object *obj, void 
*event_info EINA_UNUSED)
           }
      }
    elm_obj_ctxpopup_dismiss(obj);
+   update_from_undo_redo = EINA_TRUE;
    context_memento_finalize(ctx);
 }
 
diff --git a/src/lib/updater.c b/src/lib/updater.c
index f60f2be..714dea7 100644
--- a/src/lib/updater.c
+++ b/src/lib/updater.c
@@ -91,6 +91,17 @@ updater_completion_callback_add(Updater_Completion_Cb cb, 
void *data)
    _completion_cbs = eina_list_append(_completion_cbs, info);
 }
 
+static Eina_Bool _resize_cb_added = EINA_FALSE;
+static Eina_Bool _resize_cb_called = EINA_FALSE;
+
+static Eina_Bool
+_resized_cb(void *data EINA_UNUSED, const Eo_Event *event)
+{
+   eo_event_callback_del(event->obj, EVAS_OBJECT_EVENT_RESIZE, _resized_cb, 
NULL);
+   _resize_cb_called = EINA_TRUE;
+   return EINA_TRUE;
+}
+
 static void
 _eo_add_apply(const Eina_List *sessions, Eid *eid)
 {
@@ -101,6 +112,9 @@ _eo_add_apply(const Eina_List *sessions, Eid *eid)
      {
         if (session_eo_get(s, wdg)) continue;
         manager_widget_create(s, wdg, NULL);
+        _resize_cb_added = EINA_TRUE;
+        _resize_cb_called = EINA_FALSE;
+        eo_event_callback_add(session_eo_get(s, wdg), 
EVAS_OBJECT_EVENT_RESIZE, _resized_cb, NULL);
      }
 }
 
@@ -159,154 +173,177 @@ static Eina_Bool
 _update_check(void *data EINA_UNUSED)
 {
    Gui_Context *ctx;
-   if (!_ctxs_to_update) return EINA_TRUE;
-   EINA_LIST_FREE(_ctxs_to_update, ctx)
+   static Memento *mem_last;
+   static Eina_Bool mem_dir_last;
+   static Eina_Bool odd_call = EINA_TRUE;
+
+   if (odd_call)
      {
-        Eina_List *sessions = gui_context_data_get(ctx, SESSIONS_DATA_KEY);
-        Eina_Bool mem_dir = EINA_TRUE;
-        Eina_List *mementos = context_memento_not_updated_list_steal(ctx, 
&mem_dir);
-        if (mementos)
+        if (!_ctxs_to_update) return EINA_TRUE;
+        odd_call = EINA_FALSE;
+
+        if (eina_list_count(_ctxs_to_update) != 1)
           {
-             Eina_List *itr2;
-             Memento *mem;
-             Completion_Info *info;
-             EINA_LIST_FREE(mementos, mem)
+             ERR("More then 1 contexts to update. Re-think design!");
+          }
+
+        EINA_LIST_FREE(_ctxs_to_update, ctx)
+          {
+             Eina_List *sessions = gui_context_data_get(ctx, 
SESSIONS_DATA_KEY);
+             Eina_Bool mem_dir = EINA_TRUE;
+             Eina_List *mementos = context_memento_not_updated_list_steal(ctx, 
&mem_dir);
+             if (mementos)
                {
-                  const Eina_List *itr, *commands;
-                  Memento_Command *cmd;
+                  Memento *mem;
+                  EINA_LIST_FREE(mementos, mem)
+                    {
+                       const Eina_List *itr, *commands;
+                       Memento_Command *cmd;
 
-                  commands = memento_commands_get(mem);
-                  itr = mem_dir ? commands : eina_list_last(commands);
+                       commands = memento_commands_get(mem);
+                       itr = mem_dir ? commands : eina_list_last(commands);
 
-                  /* According to direction we must iterate forward/backward 
through commands.
-                   * Following for loop is opened EINA_LIST_FOREACH and 
EINA_LIST_REVERSE_FOREACH */
-                  for (cmd = eina_list_data_get(itr);
-                        itr;
-                        itr = (mem_dir ? eina_list_next(itr) : 
eina_list_prev(itr)),
-                        cmd = eina_list_data_get(itr))
-                    {
-                       Eid *eid = memento_command_wdg_get(cmd);
-                       Gui_Widget *wdg = wdg_get(eid);
-                       Memento_Type type = memento_command_type_get(cmd);
-                       void *from, *to;
-                       if (mem_dir)
-                         {
-                            from = memento_command_old_pointer_get(cmd);
-                            to = memento_command_new_pointer_get(cmd);
-                         }
-                       else
-                         {
-                            from = memento_command_new_pointer_get(cmd);
-                            to = memento_command_old_pointer_get(cmd);
-                         }
-                       updater_debug("Updating %s on %s: %p -> %p",
-                                     memento_type_get_as_string(type),
-                                     eid_name_get_internal(eid), from, to);
-                       switch(type)
+                       /* According to direction we must iterate 
forward/backward through commands.
+                        * Following for loop is opened EINA_LIST_FOREACH and 
EINA_LIST_REVERSE_FOREACH */
+                       for (cmd = eina_list_data_get(itr);
+                            itr;
+                            itr = (mem_dir ? eina_list_next(itr) : 
eina_list_prev(itr)),
+                            cmd = eina_list_data_get(itr))
                          {
-                          case MEMENTO_WIDGET:
-                               {
-                                  if (from)
+                            Eid *eid = memento_command_wdg_get(cmd);
+                            Gui_Widget *wdg = wdg_get(eid);
+                            Memento_Type type = memento_command_type_get(cmd);
+                            void *from, *to;
+                            if (mem_dir)
+                              {
+                                 from = memento_command_old_pointer_get(cmd);
+                                 to = memento_command_new_pointer_get(cmd);
+                              }
+                            else
+                              {
+                                 from = memento_command_new_pointer_get(cmd);
+                                 to = memento_command_old_pointer_get(cmd);
+                              }
+                            updater_debug("Updating %s on %s: %p -> %p",
+                                          memento_type_get_as_string(type),
+                                          eid_name_get_internal(eid), from, 
to);
+                            switch(type)
+                              {
+                               case MEMENTO_WIDGET:
                                     {
-                                       eid_active_set(eid, EINA_TRUE);
-                                       _eo_del_apply(sessions, eid);
-                                       eid_active_set(eid, EINA_FALSE);
+                                       if (from)
+                                         {
+                                            eid_active_set(eid, EINA_TRUE);
+                                            _eo_del_apply(sessions, eid);
+                                            eid_active_set(eid, EINA_FALSE);
+                                         }
+                                       else
+                                         {
+                                            _eo_add_apply(sessions, eid);
+                                            Eid *parent_container_id = 
wdg_parent_container_eid_get(wdg);
+                                            if (parent_container_id) 
_container_update(sessions, parent_container_id);
+                                         }
+                                       break;
                                     }
-                                  else
+                               case MEMENTO_PROPERTY:
                                     {
-                                       _eo_add_apply(sessions, eid);
-                                       Eid *parent_container_id = 
wdg_parent_container_eid_get(wdg);
-                                       if (parent_container_id) 
_container_update(sessions, parent_container_id);
+                                       /* When setting File property for 
layout, need to re-create object and reconfigure.
+                                        * Because dummy objects probably were 
not created. */
+                                       if (IS_LAYOUT(wdg) && 
!strcmp(prop_name_get(to ? to : from), FILE_SET))
+                                         {
+                                            _eo_del_apply(sessions, eid);
+                                            _eo_add_apply(sessions, eid);
+                                            /* Here separate algorithm for 
each kind of container can be implemented. */
+                                            Eid *parent_container_id = 
wdg_parent_container_eid_get(wdg);
+                                            if (parent_container_id) 
_container_update(sessions, parent_container_id);
+                                         }
+                                       else if (to)
+                                         {
+                                            _eo_prop_apply(sessions, eid, to);
+                                         }
+                                       else
+                                         {
+                                            _eo_del_apply(sessions, eid);
+                                            _eo_add_apply(sessions, eid);
+                                            /* Here separate algorithm for 
each kind of container can be implemented. */
+                                            Eid *parent_container_id = 
wdg_parent_container_eid_get(wdg);
+                                            if (parent_container_id) 
_container_update(sessions, parent_container_id);
+                                         }
+                                       break;
                                     }
-                                  break;
-                               }
-                          case MEMENTO_PROPERTY:
-                               {
-                                  /* When setting File property for layout, 
need to re-create object and reconfigure.
-                                   * Because dummy objects probably were not 
created. */
-                                  if (IS_LAYOUT(wdg) && 
!strcmp(prop_name_get(to ? to : from), FILE_SET))
-                                    {
-                                       _eo_del_apply(sessions, eid);
-                                       _eo_add_apply(sessions, eid);
-                                       /* Here separate algorithm for each 
kind of container can be implemented. */
-                                       Eid *parent_container_id = 
wdg_parent_container_eid_get(wdg);
-                                       if (parent_container_id) 
_container_update(sessions, parent_container_id);
-                                    }
-                                  else if (to)
+                               case MEMENTO_OBJ_CONTAINER:
                                     {
-                                       _eo_prop_apply(sessions, eid, to);
+                                       _container_update(sessions, eid);
+                                       break;
                                     }
-                                  else
+                               case MEMENTO_WIDGET_PARENT:
                                     {
                                        _eo_del_apply(sessions, eid);
                                        _eo_add_apply(sessions, eid);
-                                       /* Here separate algorithm for each 
kind of container can be implemented. */
-                                       Eid *parent_container_id = 
wdg_parent_container_eid_get(wdg);
-                                       if (parent_container_id) 
_container_update(sessions, parent_container_id);
-                                    }
-                                  break;
-                               }
-                          case MEMENTO_OBJ_CONTAINER:
-                               {
-                                  _container_update(sessions, eid);
-                                  break;
-                               }
-                          case MEMENTO_WIDGET_PARENT:
-                               {
-                                  _eo_del_apply(sessions, eid);
-                                  _eo_add_apply(sessions, eid);
-                                  break;
-                               }
-                          case MEMENTO_ITEM_CONTAINER_ITEM:
-                               {
-                                  if (strstr(wdg_name_get(wdg), "main_menu"))
-                                    {
-                                       Eid *parent_eid = 
wdg_parent_id_get(wdg);
-                                       _eo_del_apply(sessions, parent_eid);
-                                       _eo_add_apply(sessions, parent_eid);
+                                       break;
                                     }
-                                  else
+                               case MEMENTO_ITEM_CONTAINER_ITEM:
                                     {
-                                       _eo_del_apply(sessions, eid);
-                                       _eo_add_apply(sessions, eid);
-                                       /* Here separate algorithm for each 
kind of container can be implemented. */
-                                       Eid *parent_container_id = 
wdg_parent_container_eid_get(wdg);
-                                       if (parent_container_id) 
_container_update(sessions, parent_container_id);
+                                       if (strstr(wdg_name_get(wdg), 
"main_menu"))
+                                         {
+                                            Eid *parent_eid = 
wdg_parent_id_get(wdg);
+                                            _eo_del_apply(sessions, 
parent_eid);
+                                            _eo_add_apply(sessions, 
parent_eid);
+                                         }
+                                       else
+                                         {
+                                            _eo_del_apply(sessions, eid);
+                                            _eo_add_apply(sessions, eid);
+                                            /* Here separate algorithm for 
each kind of container can be implemented. */
+                                            Eid *parent_container_id = 
wdg_parent_container_eid_get(wdg);
+                                            if (parent_container_id) 
_container_update(sessions, parent_container_id);
+                                         }
+                                       break;
                                     }
+                               case MEMENTO_ACTION:
+                               case MEMENTO_CALLBACK:
+                               case MEMENTO_CALLBACK_ADD_DEL:
+                               case MEMENTO_WIDGET_NAME:
+                               case MEMENTO_WIDGET_PUBLIC:
+                               default:
+                                  printf("%s - Apply %d\n", __FUNCTION__, 
type);
                                   break;
-                               }
-                          case MEMENTO_ACTION:
-                          case MEMENTO_CALLBACK:
-                          case MEMENTO_CALLBACK_ADD_DEL:
-                          case MEMENTO_WIDGET_NAME:
-                          case MEMENTO_WIDGET_PUBLIC:
-                          default:
-                             printf("%s - Apply %d\n", __FUNCTION__, type);
-                             break;
+                              }
                          }
+                       mem_last = mem;
+                       mem_dir_last = mem_dir;
                     }
-                  EINA_LIST_FOREACH(_completion_cbs, itr2, info)
+               }
+             Eina_List *forced_wdgs_infos = gui_context_data_get(ctx, 
CONTEXT_FORCE_WDGS_KEY);
+             Force_Info *info;
+             EINA_LIST_FREE(forced_wdgs_infos, info)
+               {
+                  switch(info->type)
                     {
-                       info->cb(info->data, mem, mem_dir);
+                     case UPDATER_PROPERTIES_FORCE:
+                          {
+                             _container_update(sessions, info->eid);
+                             break;
+                          }
+                     default: break;
                     }
+                  free(info);
                }
+             gui_context_data_set(ctx, CONTEXT_FORCE_WDGS_KEY, NULL);
           }
-        Eina_List *forced_wdgs_infos = gui_context_data_get(ctx, 
CONTEXT_FORCE_WDGS_KEY);
-        Force_Info *info;
-        EINA_LIST_FREE(forced_wdgs_infos, info)
+     }
+   else
+     {
+        if (!_resize_cb_added || (_resize_cb_added && _resize_cb_called) )
           {
-             switch(info->type)
+             Eina_List *itr2;
+             Completion_Info *info;
+             EINA_LIST_FOREACH(_completion_cbs, itr2, info)
                {
-                case UPDATER_PROPERTIES_FORCE:
-                     {
-                        _container_update(sessions, info->eid);
-                        break;
-                     }
-                default: break;
+                  info->cb(info->data, mem_last, mem_dir_last);
                }
-             free(info);
+             odd_call = EINA_TRUE;
           }
-        gui_context_data_set(ctx, CONTEXT_FORCE_WDGS_KEY, NULL);
      }
    return EINA_TRUE;
 }
@@ -315,7 +352,7 @@ Eina_Bool
 updater_init()
 {
    if (_init_counter++) return EINA_TRUE;
-   _idler = ecore_idle_exiter_add(_update_check, NULL);
+   _idler = ecore_idle_enterer_add(_update_check, NULL);
    return EINA_TRUE;
 }
 
@@ -324,7 +361,7 @@ updater_shutdown()
 {
    if (--_init_counter)
      {
-        ecore_idle_exiter_del(_idler);
+        ecore_idle_enterer_del(_idler);
         _idler = NULL;
      }
 }

-- 


Reply via email to