diff options
author | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2019-08-16 08:46:00 +0200 |
---|---|---|
committer | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2019-08-20 10:09:56 +0200 |
commit | 7c190324f3c8e242944ee2dc295d468a576345ee (patch) | |
tree | 7f15a2e276fdb2f43ca9b12be68a6a735b3cc5cc /src | |
parent | 63c0e431fb33e8028c9ae9568e09274ee2d658a8 (diff) | |
download | efl-7c190324f3c8e242944ee2dc295d468a576345ee.tar.gz |
introduce group item
this brings a group item in the style of genlist / gengrid group items.
The group item theme does currently not provide the signals in the theme
that would be needed for selecting it. This is kind of intended, but we
might need API to express that.
ref T8115
Differential Revision: https://phab.enlightenment.org/D9583
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/elementary/test_ui_items.c | 9 | ||||
-rw-r--r-- | src/lib/elementary/Efl_Ui.h | 4 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_group_item.c | 303 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_group_item.eo | 22 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_item.c | 41 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_item.eo | 9 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_item_private.h | 3 | ||||
-rw-r--r-- | src/lib/elementary/meson.build | 2 | ||||
-rw-r--r-- | src/tests/elementary/spec/efl_test_container.c | 15 | ||||
-rw-r--r-- | src/tests/elementary/spec/efl_test_pack.c | 6 | ||||
-rw-r--r-- | src/tests/elementary/spec/efl_test_pack_linear.c | 47 | ||||
-rw-r--r-- | src/tests/elementary/spec/efl_ui_spec_suite.h | 1 |
12 files changed, 436 insertions, 26 deletions
diff --git a/src/bin/elementary/test_ui_items.c b/src/bin/elementary/test_ui_items.c index 4c2254ad25..901226a3b3 100644 --- a/src/bin/elementary/test_ui_items.c +++ b/src/bin/elementary/test_ui_items.c @@ -84,4 +84,13 @@ void test_efl_ui_item(void *data EINA_UNUSED, efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40)); efl_ui_widget_disabled_set(o, EINA_TRUE); efl_pack_end(box, o); + + o = _item_add(box, EFL_UI_GROUP_ITEM_CLASS, 5); + efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40+40)); + efl_pack_end(box, o); + + o = _item_add(box, EFL_UI_GROUP_ITEM_CLASS, 6); + efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40)); + efl_ui_widget_disabled_set(o, EINA_TRUE); + efl_pack_end(box, o); } diff --git a/src/lib/elementary/Efl_Ui.h b/src/lib/elementary/Efl_Ui.h index 35747e257e..3d0b0ba113 100644 --- a/src/lib/elementary/Efl_Ui.h +++ b/src/lib/elementary/Efl_Ui.h @@ -183,6 +183,7 @@ EAPI void efl_ui_focus_relation_free(Efl_Ui_Focus_Relations *rel); # include <efl_ui_layout_part_table.eo.h> # include <efl_ui_item.eo.h> # include <efl_ui_default_item.eo.h> +# include <efl_ui_group_item.eo.h> # include <efl_ui_win_part.eo.h> # include <efl_ui_bg.eo.h> # include <efl_ui_box.eo.h> @@ -269,7 +270,8 @@ typedef Eo Efl_Ui_Spotlight_Indicator; # include <efl_ui_text_alert_popup.eo.h> # include <efl_ui_anchor_popup.eo.h> # include <efl_ui_popup_part_backwall.eo.h> - +# include <efl_ui_grid.eo.h> +# include <efl_ui_list.eo.h> /** * Initialize Elementary * diff --git a/src/lib/elementary/efl_ui_group_item.c b/src/lib/elementary/efl_ui_group_item.c new file mode 100644 index 0000000000..9c3c03a9a9 --- /dev/null +++ b/src/lib/elementary/efl_ui_group_item.c @@ -0,0 +1,303 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#define EFL_UI_LIST_DEFAULT_ITEM_PROTECTED +#define EFL_PART_PROTECTED + +#include <Elementary.h> + +#include "elm_priv.h" +#include "elm_part_helper.h" + +#define MY_CLASS EFL_UI_GROUP_ITEM_CLASS +#define MY_CLASS_PFX efl_ui_group_item + +#define MY_CLASS_NAME "Efl.Ui.Grid_Default_Item" + + +typedef struct { + Eina_List *registered_items; +} Efl_Ui_Group_Item_Data; + +EOLIAN static Efl_Object* +_efl_ui_group_item_efl_object_constructor(Eo *obj, Efl_Ui_Group_Item_Data *pd EINA_UNUSED) +{ + if (!elm_widget_theme_klass_get(obj)) + elm_widget_theme_klass_set(obj, "group_item"); + + return efl_constructor(efl_super(obj, MY_CLASS)); +} + +EOLIAN static void +_efl_ui_group_item_efl_object_invalidate(Eo *obj, Efl_Ui_Group_Item_Data *pd EINA_UNUSED) +{ + efl_pack_clear(obj); + efl_invalidate(efl_super(obj, MY_CLASS)); +} + +static void _unregister_item(Eo *obj EINA_UNUSED, Efl_Ui_Group_Item_Data *pd, Efl_Gfx_Entity *subobj); + +static void +_invalidate(void *data, const Efl_Event *ev) +{ + Efl_Ui_Group_Item_Data *pd = efl_data_scope_safe_get(data, MY_CLASS); + if (!pd) return; + _unregister_item(data, pd, ev->object); +} + +static void +_register_item(Eo *obj, Efl_Ui_Group_Item_Data *pd, Efl_Gfx_Entity *subobj) +{ + efl_ui_item_parent_set(subobj, obj); + efl_event_callback_add(subobj, EFL_EVENT_INVALIDATE, _invalidate, obj); + pd->registered_items = eina_list_append(pd->registered_items, subobj); +} + +static void +_unregister_item(Eo *obj EINA_UNUSED, Efl_Ui_Group_Item_Data *pd, Efl_Gfx_Entity *subobj) +{ + efl_ui_item_container_set(subobj, NULL); + efl_event_callback_del(subobj, EFL_EVENT_INVALIDATE, _invalidate, obj); + pd->registered_items = eina_list_remove(pd->registered_items, subobj); +} + +EOLIAN static Eina_Bool +_efl_ui_group_item_efl_pack_pack_clear(Eo *obj EINA_UNUSED, Efl_Ui_Group_Item_Data *pd) +{ + Eo *item; + + while(pd->registered_items) + { + item = eina_list_data_get(pd->registered_items); + efl_del(item); + } + + return EINA_TRUE; +} + +EOLIAN static Eina_Bool +_efl_ui_group_item_efl_pack_unpack_all(Eo *obj, Efl_Ui_Group_Item_Data *pd) +{ + Eo *item; + Eo *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE); + + EINA_LIST_FREE(pd->registered_items, item) + { + efl_pack_unpack(container, item); + } + + return EINA_TRUE; +} + +EOLIAN static Eina_Bool +_efl_ui_group_item_efl_pack_unpack(Eo *obj, Efl_Ui_Group_Item_Data *pd, Efl_Gfx_Entity *subobj) +{ + Eo *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE); + + if (!efl_pack_unpack(container, subobj)) + return EINA_FALSE; + + _unregister_item(obj, pd, subobj); + return EINA_TRUE; +} + +#define HANDLE_REG_CALL(cond) \ + if (!(cond)) \ + { \ + _unregister_item(obj, pd, subobj); \ + return EINA_FALSE; \ + } \ + return EINA_TRUE; + +EOLIAN static Eina_Bool +_efl_ui_group_item_efl_pack_pack(Eo *obj, Efl_Ui_Group_Item_Data *pd EINA_UNUSED, Efl_Gfx_Entity *subobj) +{ + EINA_SAFETY_ON_TRUE_RETURN_VAL(subobj == obj, EINA_FALSE); + return efl_pack_end(obj, subobj); +} + +EOLIAN static Eina_Bool +_efl_ui_group_item_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Group_Item_Data *pd, Efl_Gfx_Entity *subobj) +{ + EINA_SAFETY_ON_TRUE_RETURN_VAL(subobj == obj, EINA_FALSE); + Eo *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE); + int group_index = efl_pack_index_get(container, obj); + + _register_item(obj, pd, subobj); + HANDLE_REG_CALL(efl_pack_at(container, subobj, group_index + eina_list_count(pd->registered_items) + 1)); +} + +EOLIAN static Eina_Bool +_efl_ui_group_item_efl_pack_linear_pack_begin(Eo *obj, Efl_Ui_Group_Item_Data *pd, Efl_Gfx_Entity *subobj) +{ + EINA_SAFETY_ON_TRUE_RETURN_VAL(subobj == obj, EINA_FALSE); + Eo *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE); + int group_index = efl_pack_index_get(container, obj); + + _register_item(obj, pd, subobj); + HANDLE_REG_CALL(efl_pack_at(container, subobj, group_index + 1)); +} + +EOLIAN static Eina_Bool +_efl_ui_group_item_efl_pack_linear_pack_before(Eo *obj, Efl_Ui_Group_Item_Data *pd EINA_UNUSED, Efl_Gfx_Entity *subobj, const Efl_Gfx_Entity *existing) +{ + EINA_SAFETY_ON_TRUE_RETURN_VAL(subobj == obj, EINA_FALSE); + Eo *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE); + + //FIXME, maybe we should check if existing is really part of this group + _register_item(obj, pd, subobj); + HANDLE_REG_CALL(efl_pack_before(container, subobj, existing)); +} + +EOLIAN static Eina_Bool +_efl_ui_group_item_efl_pack_linear_pack_after(Eo *obj, Efl_Ui_Group_Item_Data *pd EINA_UNUSED, Efl_Gfx_Entity *subobj, const Efl_Gfx_Entity *existing) +{ + EINA_SAFETY_ON_TRUE_RETURN_VAL(subobj == obj, EINA_FALSE); + Eo *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE); + + //FIXME, maybe we should check if existing is really part of this group + _register_item(obj, pd, subobj); + HANDLE_REG_CALL(efl_pack_after(container, subobj, existing)); +} + +EOLIAN static Eina_Bool +_efl_ui_group_item_efl_pack_linear_pack_at(Eo *obj, Efl_Ui_Group_Item_Data *pd, Efl_Gfx_Entity *subobj, int index) +{ + EINA_SAFETY_ON_TRUE_RETURN_VAL(subobj == obj, EINA_FALSE); + Eo *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, EINA_FALSE); + int group_index = efl_pack_index_get(container, obj); + + int count = eina_list_count(pd->registered_items); + + if (index < -count) + return efl_pack_begin(obj, subobj); + + if (index >= count) + return efl_pack_end(obj, subobj); + + if (index < 0) + index += count; + + _register_item(obj, pd, subobj); + HANDLE_REG_CALL(efl_pack_at(container, subobj, group_index + 1 + index)); +} + +EOLIAN static Efl_Gfx_Entity* +_efl_ui_group_item_efl_pack_linear_pack_unpack_at(Eo *obj, Efl_Ui_Group_Item_Data *pd, int index) +{ + Eo *result, *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, NULL); + int group_index = efl_pack_index_get(container, obj); + int count = eina_list_count(pd->registered_items); + + if (index <= -count) + index = 0; + else if (index >= count) + index = eina_list_count(pd->registered_items); + else if (index < 0) + index += count; + + result = efl_pack_unpack_at(container, group_index + 1 + index); + if (result) + _unregister_item(obj, pd, result); + + return result; +} + +EOLIAN static int +_efl_ui_group_item_efl_pack_linear_pack_index_get(Eo *obj, Efl_Ui_Group_Item_Data *pd, const Efl_Gfx_Entity *subobj) +{ + Eo *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, -1); + int first_index = efl_pack_index_get(container, obj) + 1; + int subobj_index = efl_pack_index_get(container, subobj); + + if (subobj_index == -1) return -1; + + EINA_SAFETY_ON_FALSE_RETURN_VAL(first_index <= subobj_index && subobj_index < (first_index + (int)eina_list_count(pd->registered_items)), -1); + + return subobj_index - (first_index); +} + +EOLIAN static Efl_Gfx_Entity* +_efl_ui_group_item_efl_pack_linear_pack_content_get(Eo *obj, Efl_Ui_Group_Item_Data *pd EINA_UNUSED, int index) +{ + Eo *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, NULL); + int group_index = efl_pack_index_get(container, obj); + + int count = eina_list_count(pd->registered_items); + + if (index <= -count) + return eina_list_data_get(pd->registered_items); + + if (index >= count) + return eina_list_last_data_get(pd->registered_items); + + if (index < 0) + index += count; + + + return efl_pack_content_get(container, group_index + 1 + index); +} + +typedef struct { + Eina_Iterator iterator; + unsigned int current; + unsigned int max; + Eo *container; +} Efl_Ui_Group_Item_Iterator; + +static Eina_Bool +_next_item(Efl_Ui_Group_Item_Iterator *it, void **data) +{ + if (it->current >= it->max) return EINA_FALSE; + + *data = efl_pack_content_get(it->container, it->current); + it->current++; + + return EINA_TRUE; +} + +EOLIAN static Eina_Iterator* +_efl_ui_group_item_efl_container_content_iterate(Eo *obj, Efl_Ui_Group_Item_Data *pd EINA_UNUSED) +{ + Eo *container = efl_ui_item_container_get(obj); + EINA_SAFETY_ON_NULL_RETURN_VAL(container, NULL); + Efl_Ui_Group_Item_Iterator *it; + + it = calloc(1, sizeof (Efl_Ui_Group_Item_Iterator)); + if (!it) return NULL; + + EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR); + + it->current = efl_pack_index_get(container, obj) + 1; + it->max = it->current + eina_list_count(pd->registered_items); + it->container = container; + + it->iterator.version = EINA_ITERATOR_VERSION; + it->iterator.next = FUNC_ITERATOR_NEXT(_next_item); + it->iterator.get_container = NULL; + it->iterator.free = FUNC_ITERATOR_FREE(free); + + return &it->iterator; +} + +EOLIAN static int +_efl_ui_group_item_efl_container_content_count(Eo *obj EINA_UNUSED, Efl_Ui_Group_Item_Data *pd) +{ + return eina_list_count(pd->registered_items); +} + + + + +#include "efl_ui_group_item.eo.c" diff --git a/src/lib/elementary/efl_ui_group_item.eo b/src/lib/elementary/efl_ui_group_item.eo new file mode 100644 index 0000000000..ee4cdd8e63 --- /dev/null +++ b/src/lib/elementary/efl_ui_group_item.eo @@ -0,0 +1,22 @@ +class @beta Efl.Ui.Group_Item extends Efl.Ui.Default_Item implements Efl.Pack_Linear +{ + [[Group item for grids and lists]] + implements { + Efl.Object.constructor; + Efl.Object.invalidate; + Efl.Pack.pack_clear; + Efl.Pack.unpack_all; + Efl.Pack.unpack; + Efl.Pack.pack; + Efl.Pack_Linear.pack_end; + Efl.Pack_Linear.pack_begin; + Efl.Pack_Linear.pack_before; + Efl.Pack_Linear.pack_after; + Efl.Pack_Linear.pack_at; + Efl.Pack_Linear.pack_unpack_at; + Efl.Pack_Linear.pack_index_get; + Efl.Pack_Linear.pack_content_get; + Efl.Container.content_iterate; + Efl.Container.content_count; + } +} diff --git a/src/lib/elementary/efl_ui_item.c b/src/lib/elementary/efl_ui_item.c index 572b945815..5061331551 100644 --- a/src/lib/elementary/efl_ui_item.c +++ b/src/lib/elementary/efl_ui_item.c @@ -17,9 +17,9 @@ _item_select(Eo *obj, Efl_Ui_Item_Data *pd) { Efl_Ui_Select_Mode m; - if (pd->parent) + if (pd->container) { - m = efl_ui_select_mode_get(pd->parent); + m = efl_ui_select_mode_get(pd->container); if (m == EFL_UI_SELECT_MODE_NONE || (pd->selected && m != EFL_UI_SELECT_MODE_SINGLE_ALWAYS)) return; } @@ -119,7 +119,7 @@ _efl_ui_item_efl_object_destructor(Eo *obj, Efl_Ui_Item_Data *pd EINA_UNUSED) EOLIAN static int _efl_ui_item_index_get(const Eo *obj, Efl_Ui_Item_Data *pd) { - return efl_pack_index_get(pd->parent, obj); + return efl_pack_index_get(pd->container, obj); } EOLIAN static void @@ -142,15 +142,48 @@ _efl_ui_item_efl_ui_selectable_selected_get(const Eo *obj EINA_UNUSED, Efl_Ui_It EOLIAN static void _efl_ui_item_container_set(Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd, Efl_Ui_Widget *container) { - pd->parent = container; + pd->container = container; + if (!pd->container) + { + pd->parent = NULL; + } } EOLIAN static Efl_Ui_Widget* _efl_ui_item_container_get(const Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd) { + return pd->container; +} + +EOLIAN static void +_efl_ui_item_item_parent_set(Eo *obj, Efl_Ui_Item_Data *pd, Efl_Ui_Item *parent) +{ + if (pd->parent) + { + ERR("Parent is already set on object %p", obj); + return; + } + if (efl_invalidated_get(obj) || efl_invalidating_get(obj)) + { + ERR("Parent cannot be set during invalidate"); + return; + } + if (pd->container) + { + ERR("Parent must be set before adding the object to the container"); + return; + } + pd->parent = parent; +} + + +EOLIAN static Efl_Ui_Item* +_efl_ui_item_item_parent_get(const Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd) +{ return pd->parent; } + #include "efl_ui_item.eo.c" #include "efl_ui_selectable.eo.c" #include "efl_ui_multi_selectable.eo.c" diff --git a/src/lib/elementary/efl_ui_item.eo b/src/lib/elementary/efl_ui_item.eo index 51c9100fec..7dc9060efd 100644 --- a/src/lib/elementary/efl_ui_item.eo +++ b/src/lib/elementary/efl_ui_item.eo @@ -40,6 +40,15 @@ abstract @beta Efl.Ui.Item extends Efl.Ui.Layout_Base implements Efl.Ui.Selectab container : Efl.Ui.Widget; [[The container this item is in.]] } } + @property item_parent { + [[The parent of the item. + + This property expresses a tree structure of items. If the parent is NULL the item is added in the root level of the content. The item parent can only be set once, when the object is invalidated, the item parent is set to NULL and still cannot be reset. + ]] + values { + parent : Efl.Ui.Item; + } + } } implements { Efl.Object.constructor; diff --git a/src/lib/elementary/efl_ui_item_private.h b/src/lib/elementary/efl_ui_item_private.h index e89076f468..cd8300b6a2 100644 --- a/src/lib/elementary/efl_ui_item_private.h +++ b/src/lib/elementary/efl_ui_item_private.h @@ -6,7 +6,8 @@ typedef struct _Efl_Ui_Item_Data { // Eo Objects - Eo *parent; /* Parent Widget */ + Eo *container; /* Parent Widget */ + Efl_Ui_Item *parent; // Boolean Data Eina_Bool selected : 1; /* State for item selected */ diff --git a/src/lib/elementary/meson.build b/src/lib/elementary/meson.build index e4671baf6d..0f0831687c 100644 --- a/src/lib/elementary/meson.build +++ b/src/lib/elementary/meson.build @@ -118,6 +118,7 @@ pub_eo_files = [ 'efl_ui_list_view_pan.eo', 'efl_ui_item.eo', 'efl_ui_default_item.eo', + 'efl_ui_group_item.eo', 'efl_ui_list_default_item.eo', 'efl_ui_list_placeholder_item.eo', 'efl_ui_list.eo', @@ -893,6 +894,7 @@ elementary_src = [ 'elm_widget_item_static_focus.c', 'efl_ui_item.c', 'efl_ui_default_item.c', + 'efl_ui_group_item.c', 'efl_ui_list_default_item.c', 'efl_ui_list_placeholder_item.c', 'efl_ui_list.c', diff --git a/src/tests/elementary/spec/efl_test_container.c b/src/tests/elementary/spec/efl_test_container.c index ecef9b1740..a78390dc03 100644 --- a/src/tests/elementary/spec/efl_test_container.c +++ b/src/tests/elementary/spec/efl_test_container.c @@ -6,6 +6,21 @@ #include "efl_ui_spec_suite.h" #include "suite_helpers.h" + +Efl_Ui_Widget* +efl_test_parent_get(Eo *obj) +{ + if (efl_isa(widget, EFL_UI_GROUP_ITEM_CLASS)) + { + return efl_ui_item_parent_get(obj); + } + else + { + return efl_ui_widget_parent_get(obj); + } +} + + void efl_test_container_content_equal(Efl_Ui_Widget **wid, unsigned int len) { diff --git a/src/tests/elementary/spec/efl_test_pack.c b/src/tests/elementary/spec/efl_test_pack.c index ab3b19615c..9ecc356610 100644 --- a/src/tests/elementary/spec/efl_test_pack.c +++ b/src/tests/elementary/spec/efl_test_pack.c @@ -137,7 +137,7 @@ EFL_START_TEST(unpack1) _setup_std_pack(wid); ck_assert_int_eq(efl_pack_unpack(widget, wid[2]), EINA_TRUE); - ck_assert_ptr_ne(efl_ui_widget_parent_get(wid[2]), widget); + ck_assert_ptr_ne(efl_test_parent_get(wid[2]), widget); ck_assert_int_eq(efl_ref_count(wid[2]), 1); efl_test_container_content_equal(wid, 2); } @@ -198,7 +198,7 @@ EFL_START_TEST(pack1) for (i = 0; i < sizeof(wid)/sizeof(Efl_Ui_Widget*); ++i) { ck_assert_int_eq(efl_ref_count(wid[i]), 1); - ck_assert_ptr_eq(efl_ui_widget_parent_get(wid[i]), widget); + ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget); } efl_test_container_content_equal(wid, 3); @@ -292,6 +292,7 @@ EFL_END_TEST void efl_pack_behavior_test(TCase *tc) { + tcase_add_test(tc, pack2); tcase_add_test(tc, base2); tcase_add_test(tc, pack_clear1); tcase_add_test(tc, pack_clear2); @@ -301,7 +302,6 @@ efl_pack_behavior_test(TCase *tc) tcase_add_test(tc, unpack2); tcase_add_test(tc, unpack3); tcase_add_test(tc, pack1); - tcase_add_test(tc, pack2); tcase_add_test(tc, pack3); tcase_add_test(tc, evt_content_added); tcase_add_test(tc, evt_content_removed); diff --git a/src/tests/elementary/spec/efl_test_pack_linear.c b/src/tests/elementary/spec/efl_test_pack_linear.c index 71746eaeee..eed26e6b5f 100644 --- a/src/tests/elementary/spec/efl_test_pack_linear.c +++ b/src/tests/elementary/spec/efl_test_pack_linear.c @@ -9,10 +9,11 @@ /* spec-meta-start {"test-interface":"Efl.Pack_Linear", - "test-widgets": ["Efl.Ui.Box", "Efl.Ui.Grid", "Efl.Ui.Spotlight.Container", "Efl.Ui.List"], + "test-widgets": ["Efl.Ui.Box", "Efl.Ui.Grid", "Efl.Ui.Spotlight.Container", "Efl.Ui.List", "Efl.Ui.Group_Item" ], "custom-mapping" : { "Efl.Ui.Grid" : "EFL_UI_GRID_DEFAULT_ITEM_CLASS", - "Efl.Ui.List" : "EFL_UI_LIST_DEFAULT_ITEM_CLASS" + "Efl.Ui.List" : "EFL_UI_LIST_DEFAULT_ITEM_CLASS", + "Efl.Ui.Group_Item" : "EFL_UI_LIST_DEFAULT_ITEM_CLASS" } } spec-meta-end */ @@ -46,7 +47,7 @@ EFL_START_TEST(pack_begin1) for (int i = 2; i >= 0; i--) { efl_pack_begin(widget, wid[i]); - ck_assert_ptr_eq(efl_ui_widget_parent_get(wid[i]), widget); + ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget); } _ordering_equals(wid, 3); efl_pack_begin(widget, inv); @@ -65,7 +66,7 @@ EFL_START_TEST(pack_begin2) for (int i = 2; i >= 0; i--) { efl_pack_begin(widget, wid[i]); - ck_assert_ptr_eq(efl_ui_widget_parent_get(wid[i]), widget); + ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget); } EXPECT_ERROR_START; @@ -85,7 +86,7 @@ EFL_START_TEST(pack_end1) for (int i = 0; i < 3; i++) { efl_pack_end(widget, wid[i]); - ck_assert_ptr_eq(efl_ui_widget_parent_get(wid[i]), widget); + ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget); } _ordering_equals(wid, 3); @@ -105,7 +106,7 @@ EFL_START_TEST(pack_end2) for (int i = 0; i < 3; i++) { efl_pack_end(widget, wid[i]); - ck_assert_ptr_eq(efl_ui_widget_parent_get(wid[i]), widget); + ck_assert_ptr_eq(efl_test_parent_get(wid[i]), widget); } EXPECT_ERROR_START; @@ -126,13 +127,13 @@ EFL_START_TEST(pack_before1) efl_pack_end(widget, wid[i]); ck_assert_int_eq(efl_pack_before(widget, inv, wid[0]), EINA_TRUE); - ck_assert_ptr_eq(efl_ui_widget_parent_get(inv), widget); + ck_assert_ptr_eq(efl_test_parent_get(inv), widget); Efl_Ui_Widget *wid2[] = {inv, wid[0], wid[1], wid[2]}; _ordering_equals(wid2, 4); efl_pack_unpack(widget, inv); ck_assert_int_eq(efl_pack_before(widget, inv, wid[2]), EINA_TRUE); - ck_assert_ptr_eq(efl_ui_widget_parent_get(inv), widget); + ck_assert_ptr_eq(efl_test_parent_get(inv), widget); Efl_Ui_Widget *wid3[] = {wid[0], wid[1], inv, wid[2]}; _ordering_equals(wid3, 4); } @@ -149,7 +150,7 @@ EFL_START_TEST(pack_before2) efl_pack_end(widget, wid[i]); ck_assert_int_eq(efl_pack_before(widget, inv, wid[0]), EINA_TRUE); - ck_assert_ptr_eq(efl_ui_widget_parent_get(inv), widget); + ck_assert_ptr_eq(efl_test_parent_get(inv), widget); Efl_Ui_Widget *wid2[] = {inv, wid[0], wid[1], wid[2]}; _ordering_equals(wid2, 4); @@ -170,13 +171,13 @@ EFL_START_TEST(pack_after1) efl_pack_end(widget, wid[i]); ck_assert_int_eq(efl_pack_after(widget, inv, wid[0]), EINA_TRUE); - ck_assert_ptr_eq(efl_ui_widget_parent_get(inv), widget); + ck_assert_ptr_eq(efl_test_parent_get(inv), widget); Efl_Ui_Widget *wid2[] = {wid[0], inv, wid[1], wid[2]}; _ordering_equals(wid2, 4); efl_pack_unpack(widget, inv); ck_assert_int_eq(efl_pack_after(widget, inv, wid[2]), EINA_TRUE); - ck_assert_ptr_eq(efl_ui_widget_parent_get(inv), widget); + ck_assert_ptr_eq(efl_test_parent_get(inv), widget); Efl_Ui_Widget *wid3[] = {wid[0], wid[1], wid[2], inv}; _ordering_equals(wid3, 4); } @@ -193,7 +194,7 @@ EFL_START_TEST(pack_after2) efl_pack_end(widget, wid[i]); ck_assert_int_eq(efl_pack_after(widget, inv, wid[0]), EINA_TRUE); - ck_assert_ptr_eq(efl_ui_widget_parent_get(inv), widget); + ck_assert_ptr_eq(efl_test_parent_get(inv), widget); Efl_Ui_Widget *wid2[] = {wid[0], inv, wid[1], wid[2]}; _ordering_equals(wid2, 4); @@ -216,7 +217,7 @@ EFL_START_TEST(pack_at1) efl_pack_end(widget, wid[i]); efl_pack_at(widget, inv, x); - ck_assert_ptr_eq(efl_ui_widget_parent_get(inv), widget); + ck_assert_ptr_eq(efl_test_parent_get(inv), widget); for (i = 0; i < 4; ++i) { @@ -247,7 +248,7 @@ EFL_START_TEST(pack_at2) efl_pack_end(widget, wid[i]); ck_assert_int_eq(efl_pack_at(widget, inv, x), EINA_TRUE); - ck_assert_ptr_eq(efl_ui_widget_parent_get(inv), widget); + ck_assert_ptr_eq(efl_test_parent_get(inv), widget); EXPECT_ERROR_START; ck_assert_int_eq(efl_pack_at(widget, inv, x - 1), EINA_FALSE); @@ -281,9 +282,9 @@ EFL_START_TEST(pack_at3) efl_pack_end(widget, wid[i]); ck_assert_int_eq(efl_pack_at(widget, inv,-100000), EINA_TRUE); - ck_assert_ptr_eq(efl_ui_widget_parent_get(inv), widget); + ck_assert_ptr_eq(efl_test_parent_get(inv), widget); ck_assert_int_eq(efl_pack_at(widget, inv2, 100000), EINA_TRUE); - ck_assert_ptr_eq(efl_ui_widget_parent_get(inv2), widget); + ck_assert_ptr_eq(efl_test_parent_get(inv2), widget); Efl_Ui_Widget *wid2[] = {inv, wid[0], wid[1], wid[2], inv2}; _ordering_equals(wid2, 5); } @@ -377,15 +378,27 @@ EFL_START_TEST(pack_unpack_at3) efl_pack_end(widget, wid[i]); ck_assert_ptr_eq(efl_pack_unpack_at(widget, x), wid[(3+x)%3]); ck_assert_int_eq(efl_content_count(widget), 2); - ck_assert_ptr_ne(efl_ui_widget_parent_get(wid[(3+x)%3]), widget); + ck_assert_ptr_ne(efl_test_parent_get(wid[(3+x)%3]), widget); efl_pack_unpack_all(widget); } } EFL_END_TEST void +object_setup(void) +{ + if (efl_isa(widget, EFL_UI_GROUP_ITEM_CLASS)) + { + Efl_Ui_Collection *collection = efl_add(EFL_UI_GRID_CLASS, win); + efl_content_set(win, collection); + efl_pack_end(collection, widget); + } +} + +void efl_pack_linear_behavior_test(TCase *tc) { + tcase_add_checked_fixture(tc, object_setup, NULL); tcase_add_test(tc, pack_begin1); tcase_add_test(tc, pack_begin2); tcase_add_test(tc, pack_end1); diff --git a/src/tests/elementary/spec/efl_ui_spec_suite.h b/src/tests/elementary/spec/efl_ui_spec_suite.h index a4bceeaf54..009e4e0ec5 100644 --- a/src/tests/elementary/spec/efl_ui_spec_suite.h +++ b/src/tests/elementary/spec/efl_ui_spec_suite.h @@ -25,6 +25,7 @@ void efl_ui_selectable_behavior_test(TCase *tc); void efl_test_container_content_equal(Efl_Ui_Widget **wid, unsigned int len); void efl_test_container_expect_evt_content_added(Efl_Ui_Widget *widget, const Efl_Event_Description *ev, Eina_Bool *flag, void *event_data); +Efl_Ui_Widget* efl_test_parent_get(Eo *obj); Eo* create_test_widget(void); |