bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=b218dcbc3f874672fde32cbfca414c39598a8689

commit b218dcbc3f874672fde32cbfca414c39598a8689
Author: Jaehyun Cho <jae_hyun....@samsung.com>
Date:   Wed Jul 31 09:16:51 2019 +0000

    efl_ui_spotlight: pop() unpacks content although there is one content
    
    Previously, pop() does not unpack content if there is one content.
    
    Now, pop() unpacks content without transition if there is one content.
    Since there is no transition, NULL future is returned.
    
    Reviewed-by: Marcel Hollerbach <m...@marcel-hollerbach.de>
    Differential Revision: https://phab.enlightenment.org/D9450
---
 src/bin/elementary/test_ui_spotlight.c          | 59 +++++++++++++++++++++++--
 src/lib/elementary/efl_ui_spotlight_container.c | 32 ++++++++++++--
 2 files changed, 83 insertions(+), 8 deletions(-)

diff --git a/src/bin/elementary/test_ui_spotlight.c 
b/src/bin/elementary/test_ui_spotlight.c
index 698d23158f..4b81f8acfb 100644
--- a/src/bin/elementary/test_ui_spotlight.c
+++ b/src/bin/elementary/test_ui_spotlight.c
@@ -140,6 +140,57 @@ next_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
      efl_ui_spotlight_active_index_set(spotlight, active_index + 1);
 }
 
+static Eina_Value
+future_then_cb(void *data EINA_UNUSED, const Eina_Value value, const 
Eina_Future *dead_future EINA_UNUSED)
+{
+   /* If efl_ui_spotlight_pop is called with EINA_FALSE, then the content is 
not
+    * deleted and the value contains the content. */
+   Eo *content = eina_value_object_get(&value);
+   if (content)
+     efl_gfx_entity_visible_set(content, EINA_FALSE);
+
+   return EINA_VALUE_EMPTY;
+}
+
+static void
+pop_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
+{
+   Eo *spotlight = data;
+
+   if (efl_content_count(spotlight) == 0) return;
+
+   Eina_Future *future = efl_ui_spotlight_pop(spotlight, EINA_TRUE);
+   eina_future_then(future, future_then_cb, NULL);
+}
+
+static void
+push_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
+{
+   Eo *spotlight = data;
+   Eo *view;
+   int count = efl_content_count(spotlight);
+
+   switch (count % 3)
+     {
+        case 0:
+          view = view_add(BUTTON, spotlight);
+          break;
+
+        case 1:
+          view = view_add(LIST, spotlight);
+          break;
+
+        case 2:
+          view = view_add(LAYOUT, spotlight);
+          break;
+
+        default:
+          view = view_add(LAYOUT, spotlight);
+          break;
+     }
+   efl_ui_spotlight_push(spotlight, view);
+}
+
 static void
 back_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
 {
@@ -842,15 +893,15 @@ test_ui_spotlight_stack(void *data EINA_UNUSED,
    efl_ui_spotlight_manager_set(spotlight, 
efl_new(EFL_UI_SPOTLIGHT_MANAGER_STACK_CLASS));
 
    efl_add(EFL_UI_BUTTON_CLASS, layout,
-           efl_text_set(efl_added, "Prev"),
+           efl_text_set(efl_added, "Pop"),
            efl_event_callback_add(efl_added,
-                                  EFL_INPUT_EVENT_CLICKED, prev_btn_cb, 
spotlight),
+                                  EFL_INPUT_EVENT_CLICKED, pop_btn_cb, 
spotlight),
            efl_content_set(efl_part(layout, "prev_btn"), efl_added));
 
    efl_add(EFL_UI_BUTTON_CLASS, layout,
-           efl_text_set(efl_added, "Next"),
+           efl_text_set(efl_added, "Push"),
            efl_event_callback_add(efl_added,
-                                  EFL_INPUT_EVENT_CLICKED, next_btn_cb, 
spotlight),
+                                  EFL_INPUT_EVENT_CLICKED, push_btn_cb, 
spotlight),
            efl_content_set(efl_part(layout, "next_btn"), efl_added));
 
    params = calloc(1, sizeof(Params));
diff --git a/src/lib/elementary/efl_ui_spotlight_container.c 
b/src/lib/elementary/efl_ui_spotlight_container.c
index 45afd99b1b..10c8125709 100644
--- a/src/lib/elementary/efl_ui_spotlight_container.c
+++ b/src/lib/elementary/efl_ui_spotlight_container.c
@@ -677,16 +677,40 @@ EOLIAN static Eina_Future*
 _efl_ui_spotlight_container_pop(Eo *obj, Efl_Ui_Spotlight_Container_Data *pd, 
Eina_Bool del)
 {
    Eina_Future *transition_done;
+   Eina_Value v;
    int new_index;
+   int count;
+   Eo *content;
 
-   if (eina_list_count(pd->content_list) < 2)
-     new_index = -1;
+   count = (int)eina_list_count(pd->content_list);
+
+   if (count == 0) return NULL;
+
+   content = efl_pack_content_get(obj, efl_ui_spotlight_active_index_get(obj));
+
+   //pop() unpacks content without transition if there is one content.
+   if (count == 1)
+     {
+        efl_pack_unpack(obj, content);
+        pd->curr.page = -1;
+
+        if (del)
+          {
+             efl_del(content);
+             v = EINA_VALUE_EMPTY;
+          }
+        else
+          {
+             v = eina_value_object_init(content);
+          }
+        return efl_loop_future_resolved(obj, v);
+     }
 
    new_index = efl_ui_spotlight_active_index_get(obj) + 1;
-   if (new_index >= (int)eina_list_count(pd->content_list))
+   if (new_index >= count)
      new_index -= 2;
 
-   pd->transition_done.content = efl_pack_content_get(obj, 
efl_ui_spotlight_active_index_get(obj));
+   pd->transition_done.content = content;
    pd->transition_done.transition_done = efl_loop_promise_new(obj);
 
    transition_done = eina_future_new(pd->transition_done.transition_done);

-- 


Reply via email to