From d30fc5f5d3a150ce847470caf5140719eef638cc Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 10 Jul 2019 16:30:04 +0200 Subject: [PATCH] efl_ui_item: rework parent relation this commit ensures that there is a public way of setting the container to a item. This was also like this before, just with the difference that it was set and unset in all privacy, however, we want to have this class also ready for bindings, so we should stop making things privat like this. Note: the removed fields from grid and list have not been used. ref T7905 Reviewed-by: SangHyeon Jade Lee Differential Revision: https://phab.enlightenment.org/D9262 --- src/lib/elementary/efl_ui_grid.c | 6 ++---- src/lib/elementary/efl_ui_grid_item_private.h | 1 - src/lib/elementary/efl_ui_item.c | 13 +++++++++++++ src/lib/elementary/efl_ui_item.eo | 9 +++++++++ src/lib/elementary/efl_ui_list.c | 6 ++---- src/lib/elementary/efl_ui_list_item_private.h | 1 - 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/lib/elementary/efl_ui_grid.c b/src/lib/elementary/efl_ui_grid.c index d27899d907..36d069b5c7 100644 --- a/src/lib/elementary/efl_ui_grid.c +++ b/src/lib/elementary/efl_ui_grid.c @@ -750,8 +750,7 @@ _grid_item_process(Eo *obj, Efl_Ui_Grid_Data *pd, EINA_UNUSED Efl_Ui_Grid_Item * EFL_UI_GRID_ITEM_DATA_GET_OR_RETURN(it, gd, EINA_FALSE); EFL_UI_ITEM_DATA_GET_OR_RETURN(it, id, EINA_FALSE); id->select_mode = &(pd->select_mode); - id->parent = obj; - gd->parent = obj; + efl_ui_item_container_set(it, obj); efl_canvas_group_member_add(pd->pan, it); efl_ui_mirrored_set(it, efl_ui_mirrored_get(obj)); @@ -772,8 +771,7 @@ _grid_item_unpack_internal(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Ui_Grid_Item *it) EFL_UI_GRID_ITEM_DATA_GET_OR_RETURN(it, gd); EFL_UI_ITEM_DATA_GET_OR_RETURN(it, id); id->select_mode = NULL; - id->parent = NULL; - gd->parent = NULL; + efl_ui_item_container_set(it, NULL); pd->items = eina_list_remove(pd->items, it); if (efl_ui_item_selected_get(it)) diff --git a/src/lib/elementary/efl_ui_grid_item_private.h b/src/lib/elementary/efl_ui_grid_item_private.h index cec53f91ce..d8c4009826 100644 --- a/src/lib/elementary/efl_ui_grid_item_private.h +++ b/src/lib/elementary/efl_ui_grid_item_private.h @@ -7,7 +7,6 @@ typedef struct _Efl_Ui_Grid_Item_Data { // Eo Objects Eo *obj; /* Self-Object */ - Eo *parent; /* Parent Widget */ Eina_Rect geo; int index; struct { diff --git a/src/lib/elementary/efl_ui_item.c b/src/lib/elementary/efl_ui_item.c index 3f87832db5..47d7b632a5 100644 --- a/src/lib/elementary/efl_ui_item.c +++ b/src/lib/elementary/efl_ui_item.c @@ -380,6 +380,19 @@ _efl_ui_item_selected_get(const Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd) return pd->selected; } +EOLIAN static void +_efl_ui_item_container_set(Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd, Efl_Ui_Widget *container) +{ + pd->parent = container; +} + +EOLIAN static Efl_Ui_Widget* +_efl_ui_item_container_get(const Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd) +{ + return pd->parent; +} + + /* Internal EO APIs and hidden overrides */ #define EFL_UI_ITEM_EXTRA_OPS \ diff --git a/src/lib/elementary/efl_ui_item.eo b/src/lib/elementary/efl_ui_item.eo index 50e1e1c739..9ece7e4c0c 100644 --- a/src/lib/elementary/efl_ui_item.eo +++ b/src/lib/elementary/efl_ui_item.eo @@ -18,6 +18,15 @@ abstract @beta Efl.Ui.Item extends Efl.Ui.Layout_Base implements Efl.Ui.Selectab select: bool; } } + @property container { + [[The container this object is part of. + + You should never use this property yourself, the container will set it. Unsetting this while the item is packed into a container does not have an impact on its state in the container. + ]] + values { + container : Efl.Ui.Widget; [[The container this item is in.]] + } + } } implements { //Efl.Object diff --git a/src/lib/elementary/efl_ui_list.c b/src/lib/elementary/efl_ui_list.c index 7e10f06618..971754ca88 100644 --- a/src/lib/elementary/efl_ui_list.c +++ b/src/lib/elementary/efl_ui_list.c @@ -675,8 +675,7 @@ _list_item_process(Eo *obj, Efl_Ui_List_Data *pd, EINA_UNUSED Efl_Ui_List_Item * EFL_UI_LIST_ITEM_DATA_GET_OR_RETURN(it, ld, EINA_FALSE); EFL_UI_ITEM_DATA_GET_OR_RETURN(it, id, EINA_FALSE); id->select_mode = &(pd->select_mode); - id->parent = obj; - ld->parent = obj; + efl_ui_item_container_set(it, obj); efl_ui_mirrored_set(it, efl_ui_mirrored_get(obj)); efl_event_callback_add(it, EFL_UI_EVENT_PRESSED, _list_item_pressed, obj); @@ -695,8 +694,7 @@ _list_item_clear(Eo *obj, Efl_Ui_List_Data *pd EINA_UNUSED, EINA_UNUSED Efl_Ui_L EFL_UI_LIST_ITEM_DATA_GET_OR_RETURN(it, ld); EFL_UI_ITEM_DATA_GET_OR_RETURN(it, id); id->select_mode = NULL; - id->parent = NULL; - ld->parent = NULL; + efl_ui_item_container_set(it, NULL); efl_event_callback_del(it, EFL_UI_EVENT_PRESSED, _list_item_pressed, obj); efl_event_callback_del(it, EFL_UI_EVENT_UNPRESSED, _list_item_unpressed, obj); diff --git a/src/lib/elementary/efl_ui_list_item_private.h b/src/lib/elementary/efl_ui_list_item_private.h index e68b3fa14a..0df36bc459 100644 --- a/src/lib/elementary/efl_ui_list_item_private.h +++ b/src/lib/elementary/efl_ui_list_item_private.h @@ -7,7 +7,6 @@ typedef struct _Efl_Ui_List_Item_Data { // Eo Objects Eo *obj; /* Self-Object */ - Eo *parent; /* Parent Widget */ Eina_Bool needs_size_calc : 1; /* Flag for Size calculation */ } Efl_Ui_List_Item_Data;