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
This commit is contained in:
Marcel Hollerbach 2019-05-30 16:57:36 +02:00 committed by Xavi Artigas
parent 65deb248e3
commit 2f28d0c593
2 changed files with 15 additions and 2 deletions

View File

@ -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);
}

View File

@ -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)
{