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)
{
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));
_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);