diff options
author | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2019-05-30 16:57:36 +0200 |
---|---|---|
committer | Xavi Artigas <xavierartigas@yahoo.es> | 2019-05-30 16:58:53 +0200 |
commit | 2f28d0c593ee302c79ec3c25eb8626472917bcac (patch) | |
tree | e4b05848288c9e942a46dc3f7912f01bee88cb34 | |
parent | 65deb248e3849851943b2f5c693c7e2a2e909f69 (diff) | |
download | efl-2f28d0c593ee302c79ec3c25eb8626472917bcac.tar.gz |
efl_ui_active_view: update index accordingly
Summary:
The -1 here only worked for cases where we delete widgets at position 0.
When we are deleting something then we need to stay in the virtual
position where the view is right now, but *then* we need to animate
again into the direction where have real content. This commit ensures
that this is the case
fix T7989
Depends on D9056
Reviewers: segfaultxavi
Reviewed By: segfaultxavi
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T7989
Differential Revision: https://phab.enlightenment.org/D9055
-rw-r--r-- | src/lib/elementary/efl_ui_active_view_container.c | 6 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_active_view_view_manager_stack.c | 11 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/lib/elementary/efl_ui_active_view_container.c b/src/lib/elementary/efl_ui_active_view_container.c index 7a264691e8..d1f2fcc9b6 100644 --- a/src/lib/elementary/efl_ui_active_view_container.c +++ b/src/lib/elementary/efl_ui_active_view_container.c @@ -500,6 +500,7 @@ _unpack(Eo *obj, int index) { int early_curr_page = pd->curr.page; + Eina_Bool deletion_of_active = (index == pd->curr.page); pd->content_list = eina_list_remove(pd->content_list, subobj); _elm_widget_sub_object_redirect_to_top(obj, subobj); @@ -516,7 +517,10 @@ _unpack(Eo *obj, if (pd->gravity == EFL_UI_ACTIVE_VIEW_CONTAINER_GRAVITY_CONTENT && early_curr_page == index) { int new_curr_page = MIN(MAX(early_curr_page, 0), (int)eina_list_count(pd->content_list) - 1); - pd->curr.page = -1; + //when we delete the active index and we are not updating the index, + // then force a update, so the same sort of animation is triggered from the right direction + if (deletion_of_active && new_curr_page == pd->curr.page) + pd->curr.page = index -1; if (eina_list_count(pd->content_list) > 0 && efl_alive_get(obj)) efl_ui_active_view_active_index_set(obj, new_curr_page); } diff --git a/src/lib/elementary/efl_ui_active_view_view_manager_stack.c b/src/lib/elementary/efl_ui_active_view_view_manager_stack.c index ad2038a0be..769540d590 100644 --- a/src/lib/elementary/efl_ui_active_view_view_manager_stack.c +++ b/src/lib/elementary/efl_ui_active_view_view_manager_stack.c @@ -179,13 +179,22 @@ _setup_anim(Efl_Animation_Player *player, Efl_Gfx_Entity *entity) efl_player_start(player); } +static Eina_Bool +is_valid(Eo *obj, int index) +{ + if (index < 0) return EINA_FALSE; + if (index >= efl_content_count(obj)) return EINA_FALSE; + + return EINA_TRUE; +} + EOLIAN static void _efl_ui_active_view_view_manager_stack_efl_ui_active_view_view_manager_switch_to(Eo *obj, Efl_Ui_Active_View_View_Manager_Stack_Data *pd, int from, int to) { if (efl_pack_content_get(pd->container, to) == pd->content) return; - if (from != -1) + if (is_valid(pd->container, to) && is_valid(pd->container, from)) { if (pd->animation) { |