efl_ui_item: only fetch multiselection state if this is relevant

there are cases where the container does only implement single
selection, when then just asume implicitly single mode here.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Differential Revision: https://phab.enlightenment.org/D9722
This commit is contained in:
Marcel Hollerbach 2019-08-23 10:41:44 +02:00
parent 02b63b8260
commit c947485bd0
1 changed files with 13 additions and 2 deletions

View File

@ -12,6 +12,17 @@
#define MY_CLASS_NAME "Efl.Ui.Item"
static Efl_Ui_Select_Mode
_fetch_state(Eo *obj)
{
if (efl_isa(obj, EFL_UI_MULTI_SELECTABLE_INTERFACE))
return efl_ui_select_mode_get(obj);
if (efl_isa(obj, EFL_UI_SINGLE_SELECTABLE_INTERFACE))
return EFL_UI_SELECT_MODE_SINGLE;
ERR("Uncaught state");
return EFL_UI_SELECT_MODE_NONE;
}
static void
_item_select(Eo *obj, Efl_Ui_Item_Data *pd)
{
@ -19,7 +30,7 @@ _item_select(Eo *obj, Efl_Ui_Item_Data *pd)
if (pd->container)
{
m = efl_ui_select_mode_get(pd->container);
m = _fetch_state(pd->container);
if (m == EFL_UI_SELECT_MODE_NONE || (pd->selected && m != EFL_UI_SELECT_MODE_SINGLE_ALWAYS))
return;
}
@ -68,7 +79,7 @@ _item_unpressed(void *data, const Efl_Event *ev EINA_UNUSED)
if (!efl_ui_item_container_get(obj)) return;
efl_layout_signal_emit(obj, "efl,state,unpressed", "efl");
m = efl_ui_select_mode_get(efl_ui_item_container_get(obj));
m = _fetch_state(pd->container);
if ((m != EFL_UI_SELECT_MODE_SINGLE_ALWAYS) && (pd->selected))
efl_ui_selectable_selected_set(obj, EINA_FALSE);