forked from enlightenment/efl
efl_ui_pack: allow NULL as existing parameter in after and before
Summary: with this commit all implementations of Efl.Pack_Linear to permit NULL as existing parameter, this is verified with a spec test unit. fixes T8210 Reviewers: zmike, segfaultxavi Reviewed By: zmike Subscribers: woohyun, Jaehyun_Cho, YOhoho, segfaultxavi, zmike, cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8210 Differential Revision: https://phab.enlightenment.org/D10023
This commit is contained in:
parent
0c0db1650a
commit
6714c821f7
|
@ -821,7 +821,8 @@ EOLIAN static Eina_Bool
|
||||||
_efl_ui_collection_efl_pack_linear_pack_before(Eo *obj, Efl_Ui_Collection_Data *pd, Efl_Gfx_Entity *subobj, const Efl_Gfx_Entity *existing)
|
_efl_ui_collection_efl_pack_linear_pack_before(Eo *obj, Efl_Ui_Collection_Data *pd, Efl_Gfx_Entity *subobj, const Efl_Gfx_Entity *existing)
|
||||||
{
|
{
|
||||||
Eina_List *subobj_list = eina_list_data_find_list(pd->items, existing);
|
Eina_List *subobj_list = eina_list_data_find_list(pd->items, existing);
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(subobj_list, EINA_FALSE);
|
if (existing)
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(subobj_list, EINA_FALSE);
|
||||||
|
|
||||||
if (!register_item(obj, pd, subobj))
|
if (!register_item(obj, pd, subobj))
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
@ -835,7 +836,8 @@ EOLIAN static Eina_Bool
|
||||||
_efl_ui_collection_efl_pack_linear_pack_after(Eo *obj, Efl_Ui_Collection_Data *pd, Efl_Gfx_Entity *subobj, const Efl_Gfx_Entity *existing)
|
_efl_ui_collection_efl_pack_linear_pack_after(Eo *obj, Efl_Ui_Collection_Data *pd, Efl_Gfx_Entity *subobj, const Efl_Gfx_Entity *existing)
|
||||||
{
|
{
|
||||||
Eina_List *subobj_list = eina_list_data_find_list(pd->items, existing);
|
Eina_List *subobj_list = eina_list_data_find_list(pd->items, existing);
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(subobj_list, EINA_FALSE);
|
if (existing)
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN_VAL(subobj_list, EINA_FALSE);
|
||||||
|
|
||||||
if (!register_item(obj, pd, subobj))
|
if (!register_item(obj, pd, subobj))
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
|
@ -149,10 +149,19 @@ _efl_ui_group_item_efl_pack_linear_pack_before(Eo *obj, Efl_Ui_Group_Item_Data *
|
||||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(subobj == obj, EINA_FALSE);
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(subobj == obj, EINA_FALSE);
|
||||||
Eo *container = efl_ui_item_container_get(obj);
|
Eo *container = efl_ui_item_container_get(obj);
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE);
|
||||||
|
int group_index = efl_pack_index_get(container, obj);
|
||||||
|
|
||||||
//FIXME, maybe we should check if existing is really part of this group
|
//FIXME, maybe we should check if existing is really part of this group
|
||||||
_register_item(obj, pd, subobj);
|
_register_item(obj, pd, subobj);
|
||||||
HANDLE_REG_CALL(efl_pack_before(container, subobj, existing));
|
if (existing)
|
||||||
|
{
|
||||||
|
HANDLE_REG_CALL(efl_pack_before(container, subobj, existing));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HANDLE_REG_CALL(efl_pack_at(container, subobj, group_index + 1));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
|
@ -161,10 +170,18 @@ _efl_ui_group_item_efl_pack_linear_pack_after(Eo *obj, Efl_Ui_Group_Item_Data *p
|
||||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(subobj == obj, EINA_FALSE);
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(subobj == obj, EINA_FALSE);
|
||||||
Eo *container = efl_ui_item_container_get(obj);
|
Eo *container = efl_ui_item_container_get(obj);
|
||||||
EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE);
|
EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE);
|
||||||
|
int group_index = efl_pack_index_get(container, obj);
|
||||||
|
|
||||||
//FIXME, maybe we should check if existing is really part of this group
|
//FIXME, maybe we should check if existing is really part of this group
|
||||||
_register_item(obj, pd, subobj);
|
_register_item(obj, pd, subobj);
|
||||||
HANDLE_REG_CALL(efl_pack_after(container, subobj, existing));
|
if (existing)
|
||||||
|
{
|
||||||
|
HANDLE_REG_CALL(efl_pack_after(container, subobj, existing));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HANDLE_REG_CALL(efl_pack_at(container, subobj, group_index + eina_list_count(pd->registered_items)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
|
|
|
@ -317,7 +317,8 @@ _efl_ui_spotlight_container_efl_pack_linear_pack_before(Eo *obj EINA_UNUSED,
|
||||||
const Efl_Gfx_Entity *existing)
|
const Efl_Gfx_Entity *existing)
|
||||||
{
|
{
|
||||||
int index = eina_list_data_idx(pd->content_list, (void *)existing);
|
int index = eina_list_data_idx(pd->content_list, (void *)existing);
|
||||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(index >= 0, EINA_FALSE);
|
if (existing)
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(index >= 0, EINA_FALSE);
|
||||||
|
|
||||||
if (!_register_child(obj, pd, subobj)) return EINA_FALSE;
|
if (!_register_child(obj, pd, subobj)) return EINA_FALSE;
|
||||||
pd->content_list = eina_list_prepend_relative(pd->content_list, subobj, existing);
|
pd->content_list = eina_list_prepend_relative(pd->content_list, subobj, existing);
|
||||||
|
@ -332,7 +333,8 @@ _efl_ui_spotlight_container_efl_pack_linear_pack_after(Eo *obj EINA_UNUSED,
|
||||||
const Efl_Gfx_Entity *existing)
|
const Efl_Gfx_Entity *existing)
|
||||||
{
|
{
|
||||||
int index = eina_list_data_idx(pd->content_list, (void *)existing);
|
int index = eina_list_data_idx(pd->content_list, (void *)existing);
|
||||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(index >= 0, EINA_FALSE);
|
if (existing)
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(index >= 0, EINA_FALSE);
|
||||||
|
|
||||||
if (!_register_child(obj, pd, subobj)) return EINA_FALSE;
|
if (!_register_child(obj, pd, subobj)) return EINA_FALSE;
|
||||||
pd->content_list = eina_list_append_relative(pd->content_list, subobj, existing);
|
pd->content_list = eina_list_append_relative(pd->content_list, subobj, existing);
|
||||||
|
|
|
@ -188,7 +188,8 @@ _efl_ui_tab_bar_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Tab_Bar_Data *pd, Efl_G
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_efl_ui_tab_bar_efl_pack_linear_pack_before(Eo *obj, Efl_Ui_Tab_Bar_Data *pd, Efl_Gfx_Entity *subobj, const Efl_Gfx_Entity *existing)
|
_efl_ui_tab_bar_efl_pack_linear_pack_before(Eo *obj, Efl_Ui_Tab_Bar_Data *pd, Efl_Gfx_Entity *subobj, const Efl_Gfx_Entity *existing)
|
||||||
{
|
{
|
||||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_pack_index_get(pd->bx, existing) >= 0, EINA_FALSE);
|
if (existing)
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_pack_index_get(pd->bx, existing) >= 0, EINA_FALSE);
|
||||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(_register_item(obj, pd, subobj), EINA_FALSE);
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(_register_item(obj, pd, subobj), EINA_FALSE);
|
||||||
return efl_pack_before(pd->bx, subobj, existing);
|
return efl_pack_before(pd->bx, subobj, existing);
|
||||||
}
|
}
|
||||||
|
@ -196,7 +197,8 @@ _efl_ui_tab_bar_efl_pack_linear_pack_before(Eo *obj, Efl_Ui_Tab_Bar_Data *pd, Ef
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_efl_ui_tab_bar_efl_pack_linear_pack_after(Eo *obj, Efl_Ui_Tab_Bar_Data *pd, Efl_Gfx_Entity *subobj, const Efl_Gfx_Entity *existing)
|
_efl_ui_tab_bar_efl_pack_linear_pack_after(Eo *obj, Efl_Ui_Tab_Bar_Data *pd, Efl_Gfx_Entity *subobj, const Efl_Gfx_Entity *existing)
|
||||||
{
|
{
|
||||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_pack_index_get(pd->bx, existing) >= 0, EINA_FALSE);
|
if (existing)
|
||||||
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_pack_index_get(pd->bx, existing) >= 0, EINA_FALSE);
|
||||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(_register_item(obj, pd, subobj), EINA_FALSE);
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(_register_item(obj, pd, subobj), EINA_FALSE);
|
||||||
return efl_pack_after(pd->bx, subobj, existing);
|
return efl_pack_after(pd->bx, subobj, existing);
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,6 +182,21 @@ EFL_START_TEST(pack_before3)
|
||||||
}
|
}
|
||||||
EFL_END_TEST
|
EFL_END_TEST
|
||||||
|
|
||||||
|
EFL_START_TEST(pack_before4)
|
||||||
|
{
|
||||||
|
Efl_Ui_Widget *wid[3];
|
||||||
|
Efl_Ui_Widget *inv = create_test_widget();
|
||||||
|
|
||||||
|
_fill_array(wid);
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
efl_pack_end(widget, wid[i]);
|
||||||
|
|
||||||
|
ck_assert_int_eq(efl_pack_before(widget, inv, NULL), EINA_TRUE);
|
||||||
|
ck_assert_ptr_eq(efl_pack_content_get(widget, 0), inv);
|
||||||
|
}
|
||||||
|
EFL_END_TEST
|
||||||
|
|
||||||
EFL_START_TEST(pack_after1)
|
EFL_START_TEST(pack_after1)
|
||||||
{
|
{
|
||||||
Efl_Ui_Widget *wid[3];
|
Efl_Ui_Widget *wid[3];
|
||||||
|
@ -247,6 +262,21 @@ EFL_START_TEST(pack_after3)
|
||||||
}
|
}
|
||||||
EFL_END_TEST
|
EFL_END_TEST
|
||||||
|
|
||||||
|
EFL_START_TEST(pack_after4)
|
||||||
|
{
|
||||||
|
Efl_Ui_Widget *wid[3];
|
||||||
|
Efl_Ui_Widget *inv = create_test_widget();
|
||||||
|
|
||||||
|
_fill_array(wid);
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
efl_pack_end(widget, wid[i]);
|
||||||
|
|
||||||
|
ck_assert_int_eq(efl_pack_after(widget, inv, NULL), EINA_TRUE);
|
||||||
|
ck_assert_ptr_eq(efl_pack_content_get(widget, 3), inv);
|
||||||
|
}
|
||||||
|
EFL_END_TEST
|
||||||
|
|
||||||
EFL_START_TEST(pack_at1)
|
EFL_START_TEST(pack_at1)
|
||||||
{
|
{
|
||||||
for (int x = -3; x < 3; ++x)
|
for (int x = -3; x < 3; ++x)
|
||||||
|
@ -449,9 +479,11 @@ efl_pack_linear_behavior_test(TCase *tc)
|
||||||
tcase_add_test(tc, pack_before1);
|
tcase_add_test(tc, pack_before1);
|
||||||
tcase_add_test(tc, pack_before2);
|
tcase_add_test(tc, pack_before2);
|
||||||
tcase_add_test(tc, pack_before3);
|
tcase_add_test(tc, pack_before3);
|
||||||
|
tcase_add_test(tc, pack_before4);
|
||||||
tcase_add_test(tc, pack_after1);
|
tcase_add_test(tc, pack_after1);
|
||||||
tcase_add_test(tc, pack_after2);
|
tcase_add_test(tc, pack_after2);
|
||||||
tcase_add_test(tc, pack_after3);
|
tcase_add_test(tc, pack_after3);
|
||||||
|
tcase_add_test(tc, pack_after4);
|
||||||
tcase_add_test(tc, pack_at1);
|
tcase_add_test(tc, pack_at1);
|
||||||
tcase_add_test(tc, pack_at2);
|
tcase_add_test(tc, pack_at2);
|
||||||
tcase_add_test(tc, pack_at3);
|
tcase_add_test(tc, pack_at3);
|
||||||
|
|
Loading…
Reference in New Issue