yakov pushed a commit to branch master.

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

commit ec2fc1c8558de903eeb551573e1ef8465cf3f5e3
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Sun Dec 6 13:35:36 2015 +0200

    Add support for memento focused widgets
    
    When an action takes place on some widget: e.i. drag widget from one
    container to another, several auxiliary memento commands are created:
    chagne initial container, change parent, change final container, etc.
    Nevertheless data, about what widget is main(focused) in this action, has 
never
    been explicitly saved. This patch removes this deficiency.
    
    Focused widgets are saved in a list, for the case when action can take
    place on several multi-selected widgets.
---
 src/lib/undoredo.c | 23 +++++++++++++++++++++++
 src/lib/undoredo.h |  8 ++++++++
 2 files changed, 31 insertions(+)

diff --git a/src/lib/undoredo.c b/src/lib/undoredo.c
index 7fe9686..aeecc52 100644
--- a/src/lib/undoredo.c
+++ b/src/lib/undoredo.c
@@ -77,6 +77,7 @@ struct _Memento
 {
    Eina_List *cmds; /* List of Memento commands */
    Eina_Bool finalized : 1;
+   Eina_List *focused_wdgs; /* List of Widgets the action takes place on. */
 };
 
 const char *
@@ -209,6 +210,27 @@ memento_command_add(Eid *eid, Memento_Type type, void 
*old_pointer, void *new_po
    return EINA_TRUE;
 }
 
+void
+memento_focused_widget_add(Eid *eid)
+{
+   const Gui_Context *ctx = gui_context_get_by_eid(eid);
+   Memento *memento = (Memento *)context_current_memento_get(ctx);
+   if (!memento || memento->finalized)
+     {
+        memento = calloc(1, sizeof(*memento));
+        _context_memento_add((Gui_Context *)ctx, memento);
+     }
+   if (eina_list_data_find(memento->focused_wdgs, eid)) return;
+   memento->focused_wdgs = eina_list_append(memento->focused_wdgs, eid);
+}
+
+const Eina_List*
+memento_focused_widget_list_get(const Memento *mem)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(mem, NULL);
+   return mem->focused_wdgs;
+}
+
 static void
 _cmd_del(Memento_Command *cmd)
 {
@@ -290,6 +312,7 @@ memento_del(Memento *memento)
    EINA_SAFETY_ON_NULL_RETURN(memento);
    Memento_Command *cmd;
    EINA_LIST_FREE(memento->cmds, cmd) _cmd_del(cmd);
+   eina_list_free(memento->focused_wdgs);
    free(memento);
 }
 
diff --git a/src/lib/undoredo.h b/src/lib/undoredo.h
index 7316a55..b8363f4 100644
--- a/src/lib/undoredo.h
+++ b/src/lib/undoredo.h
@@ -31,6 +31,14 @@ typedef struct _Memento Memento;
 Eina_Bool
 memento_command_add(Eid *wdg_id, Memento_Type type, void *old_pointer, void 
*new_pointer);
 
+/* Add widget to a dedicated list. To keep Widgets the action takes place on. 
*/
+void
+memento_focused_widget_add(Eid *eid);
+
+/* API to get list of widgets the action takes place on. */
+const Eina_List*
+memento_focused_widget_list_get(const Memento *mem);
+
 /* Delete Memento Object */
 void
 memento_del(Memento *memento);

-- 


Reply via email to