forked from enlightenment/efl
efl_ui_item: add API that restricts a item from beeing unselected
Summary: There are usecases where items should not be unselectable by the user. For example in the tab_bar. With this commit, a tab bar user cannot unselect a item by hand anymore. Depends on D10305 Reviewers: zmike, woohyun, segfaultxavi, cedric Reviewed By: zmike, segfaultxavi, cedric Subscribers: SanghyeonLee, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10306
This commit is contained in:
parent
87e5907f18
commit
92c01d9e63
|
@ -146,6 +146,7 @@ typedef struct {
|
|||
Fast_Accessor size_accessor;
|
||||
Efl_Gfx_Entity *sizer;
|
||||
unsigned int start_id, end_id;
|
||||
Eina_Bool allow_manual_deselection : 1;
|
||||
} Efl_Ui_Collection_Data;
|
||||
|
||||
static Eina_Bool register_item(Eo *obj, Efl_Ui_Collection_Data *pd, Efl_Ui_Item *item);
|
||||
|
@ -360,6 +361,8 @@ _efl_ui_collection_efl_object_constructor(Eo *obj, Efl_Ui_Collection_Data *pd EI
|
|||
{
|
||||
Eo *o;
|
||||
|
||||
efl_ui_selectable_allow_manual_deselection_set(obj, EINA_TRUE);
|
||||
|
||||
pd->dir = EFL_UI_LAYOUT_ORIENTATION_VERTICAL;
|
||||
|
||||
_fast_accessor_init(&pd->obj_accessor, &pd->items);
|
||||
|
@ -1176,6 +1179,19 @@ _efl_ui_collection_efl_ui_single_selectable_fallback_selection_get(const Eo *obj
|
|||
return pd->fallback;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_collection_efl_ui_single_selectable_allow_manual_deselection_set(Eo *obj EINA_UNUSED, Efl_Ui_Collection_Data *pd, Eina_Bool allow_manual_deselection)
|
||||
{
|
||||
pd->allow_manual_deselection = !!allow_manual_deselection;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_ui_collection_efl_ui_single_selectable_allow_manual_deselection_get(const Eo *obj EINA_UNUSED, Efl_Ui_Collection_Data *pd)
|
||||
{
|
||||
return pd->allow_manual_deselection;
|
||||
}
|
||||
|
||||
|
||||
#include "efl_ui_collection.eo.c"
|
||||
|
||||
#define ITEM_IS_OUTSIDE_VISIBLE(id) id < collection_pd->start_id || id > collection_pd->end_id
|
||||
|
|
|
@ -97,6 +97,7 @@ class Efl.Ui.Collection extends Efl.Ui.Layout_Base implements
|
|||
Efl.Ui.Multi_Selectable_Object_Range.range_select;
|
||||
Efl.Ui.Multi_Selectable_Object_Range.range_unselect;
|
||||
Efl.Ui.Single_Selectable.fallback_selection {get; set;}
|
||||
Efl.Ui.Single_Selectable.allow_manual_deselection {get; set;}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,10 @@ _item_unpressed(void *data, const Efl_Event *ev EINA_UNUSED)
|
|||
m = _fetch_state(pd->container);
|
||||
|
||||
if (pd->selected)
|
||||
efl_ui_selectable_selected_set(obj, EINA_FALSE);
|
||||
{
|
||||
if (efl_ui_selectable_allow_manual_deselection_get(pd->container))
|
||||
efl_ui_selectable_selected_set(obj, EINA_FALSE);
|
||||
}
|
||||
else if (m != EFL_UI_SELECT_MODE_NONE)
|
||||
efl_ui_selectable_selected_set(obj, EINA_TRUE);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,18 @@ typedef struct {
|
|||
Eina_Bool in_value_change;
|
||||
} Efl_Ui_Radio_Group_Impl_Data;
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_radio_group_impl_efl_ui_single_selectable_allow_manual_deselection_set(Eo *obj EINA_UNUSED, Efl_Ui_Radio_Group_Impl_Data *pd EINA_UNUSED, Eina_Bool allow_manual_deselection EINA_UNUSED)
|
||||
{
|
||||
if (allow_manual_deselection == EINA_FALSE)
|
||||
ERR("This is right now not supported.");
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_ui_radio_group_impl_efl_ui_single_selectable_allow_manual_deselection_get(const Eo *obj EINA_UNUSED, Efl_Ui_Radio_Group_Impl_Data *pd EINA_UNUSED)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_radio_group_impl_efl_ui_single_selectable_fallback_selection_set(Eo *obj EINA_UNUSED, Efl_Ui_Radio_Group_Impl_Data *pd, Efl_Ui_Selectable *fallback)
|
||||
|
|
|
@ -12,5 +12,6 @@ class Efl.Ui.Radio_Group_Impl extends Efl.Object implements Efl.Ui.Radio_Group
|
|||
Efl.Ui.Radio_Group.unregister;
|
||||
Efl.Ui.Single_Selectable.last_selected {get;}
|
||||
Efl.Ui.Single_Selectable.fallback_selection {set; get;}
|
||||
Efl.Ui.Single_Selectable.allow_manual_deselection {set; get;}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,12 @@ interface Efl.Ui.Single_Selectable {
|
|||
fallback : Efl.Ui.Selectable;
|
||||
}
|
||||
}
|
||||
@property allow_manual_deselection {
|
||||
[[This controlls if a selected item can be deselected due to clicking]]
|
||||
values {
|
||||
allow_manual_deselection : bool; [[$true if clicking while selected results in a state change to unselected]]
|
||||
}
|
||||
}
|
||||
}
|
||||
events {
|
||||
selection_changed : void; [[Emitted when there is a change in the selection state. This event will collect all
|
||||
|
|
|
@ -26,6 +26,19 @@ _efl_ui_tab_bar_efl_ui_single_selectable_fallback_selection_set(Eo *obj EINA_UNU
|
|||
efl_ui_selectable_selected_set(pd->fallback_selection, EINA_TRUE);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_ui_tab_bar_efl_ui_single_selectable_allow_manual_deselection_set(Eo *obj EINA_UNUSED, Efl_Ui_Tab_Bar_Data *pd, Eina_Bool allow_manual_deselection)
|
||||
{
|
||||
pd->allow_manual_deselection = !!allow_manual_deselection;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_ui_tab_bar_efl_ui_single_selectable_allow_manual_deselection_get(const Eo *obj EINA_UNUSED, Efl_Ui_Tab_Bar_Data *pd)
|
||||
{
|
||||
return pd->allow_manual_deselection;
|
||||
}
|
||||
|
||||
|
||||
EOLIAN static Efl_Ui_Selectable*
|
||||
_efl_ui_tab_bar_efl_ui_single_selectable_fallback_selection_get(const Eo *obj EINA_UNUSED, Efl_Ui_Tab_Bar_Data *pd)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ class @beta Efl.Ui.Tab_Bar extends Efl.Ui.Layout_Base
|
|||
Efl.Object.destructor;
|
||||
Efl.Ui.Single_Selectable.last_selected {get;}
|
||||
Efl.Ui.Single_Selectable.fallback_selection {get; set;}
|
||||
Efl.Ui.Single_Selectable.allow_manual_deselection {get; set;}
|
||||
Efl.Pack.pack;
|
||||
Efl.Pack.pack_clear;
|
||||
Efl.Pack.unpack_all;
|
||||
|
|
|
@ -8,6 +8,7 @@ struct _Efl_Ui_Tab_Bar_Data
|
|||
Efl_Ui_Box *bx;
|
||||
Efl_Ui_Item *selected, *fallback_selection;
|
||||
Eina_Bool in_value_change;
|
||||
Eina_Bool allow_manual_deselection : 1;
|
||||
};
|
||||
|
||||
#define EFL_UI_TAB_BAR_DATA_GET(o, sd) \
|
||||
|
|
Loading…
Reference in New Issue