summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-02 09:07:13 -0500
committerMike Blumenkrantz <zmike@samsung.com>2020-01-02 09:12:39 -0500
commit92c01d9e630103281875e757ac36a4115f0622c6 (patch)
treec8bd3d16aafe2491cf4c590ce28a16c13ee78cdf
parent87e5907f18dee96c9e93a41f7a611aa362039813 (diff)
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
-rw-r--r--src/lib/elementary/efl_ui_collection.c16
-rw-r--r--src/lib/elementary/efl_ui_collection.eo1
-rw-r--r--src/lib/elementary/efl_ui_item.c5
-rw-r--r--src/lib/elementary/efl_ui_radio_group_impl.c12
-rw-r--r--src/lib/elementary/efl_ui_radio_group_impl.eo1
-rw-r--r--src/lib/elementary/efl_ui_single_selectable.eo6
-rw-r--r--src/lib/elementary/efl_ui_tab_bar.c13
-rw-r--r--src/lib/elementary/efl_ui_tab_bar.eo1
-rw-r--r--src/lib/elementary/efl_ui_tab_bar_private.h1
9 files changed, 55 insertions, 1 deletions
diff --git a/src/lib/elementary/efl_ui_collection.c b/src/lib/elementary/efl_ui_collection.c
index 02e76552e6..b6f96ba2da 100644
--- a/src/lib/elementary/efl_ui_collection.c
+++ b/src/lib/elementary/efl_ui_collection.c
@@ -146,6 +146,7 @@ typedef struct {
146 Fast_Accessor size_accessor; 146 Fast_Accessor size_accessor;
147 Efl_Gfx_Entity *sizer; 147 Efl_Gfx_Entity *sizer;
148 unsigned int start_id, end_id; 148 unsigned int start_id, end_id;
149 Eina_Bool allow_manual_deselection : 1;
149} Efl_Ui_Collection_Data; 150} Efl_Ui_Collection_Data;
150 151
151static Eina_Bool register_item(Eo *obj, Efl_Ui_Collection_Data *pd, Efl_Ui_Item *item); 152static 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
360{ 361{
361 Eo *o; 362 Eo *o;
362 363
364 efl_ui_selectable_allow_manual_deselection_set(obj, EINA_TRUE);
365
363 pd->dir = EFL_UI_LAYOUT_ORIENTATION_VERTICAL; 366 pd->dir = EFL_UI_LAYOUT_ORIENTATION_VERTICAL;
364 367
365 _fast_accessor_init(&pd->obj_accessor, &pd->items); 368 _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
1176 return pd->fallback; 1179 return pd->fallback;
1177} 1180}
1178 1181
1182EOLIAN static void
1183_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)
1184{
1185 pd->allow_manual_deselection = !!allow_manual_deselection;
1186}
1187
1188EOLIAN static Eina_Bool
1189_efl_ui_collection_efl_ui_single_selectable_allow_manual_deselection_get(const Eo *obj EINA_UNUSED, Efl_Ui_Collection_Data *pd)
1190{
1191 return pd->allow_manual_deselection;
1192}
1193
1194
1179#include "efl_ui_collection.eo.c" 1195#include "efl_ui_collection.eo.c"
1180 1196
1181#define ITEM_IS_OUTSIDE_VISIBLE(id) id < collection_pd->start_id || id > collection_pd->end_id 1197#define ITEM_IS_OUTSIDE_VISIBLE(id) id < collection_pd->start_id || id > collection_pd->end_id
diff --git a/src/lib/elementary/efl_ui_collection.eo b/src/lib/elementary/efl_ui_collection.eo
index 4a5a440002..d890b1656e 100644
--- a/src/lib/elementary/efl_ui_collection.eo
+++ b/src/lib/elementary/efl_ui_collection.eo
@@ -97,6 +97,7 @@ class Efl.Ui.Collection extends Efl.Ui.Layout_Base implements
97 Efl.Ui.Multi_Selectable_Object_Range.range_select; 97 Efl.Ui.Multi_Selectable_Object_Range.range_select;
98 Efl.Ui.Multi_Selectable_Object_Range.range_unselect; 98 Efl.Ui.Multi_Selectable_Object_Range.range_unselect;
99 Efl.Ui.Single_Selectable.fallback_selection {get; set;} 99 Efl.Ui.Single_Selectable.fallback_selection {get; set;}
100 Efl.Ui.Single_Selectable.allow_manual_deselection {get; set;}
100 } 101 }
101} 102}
102 103
diff --git a/src/lib/elementary/efl_ui_item.c b/src/lib/elementary/efl_ui_item.c
index 85b50ee758..2504f410e0 100644
--- a/src/lib/elementary/efl_ui_item.c
+++ b/src/lib/elementary/efl_ui_item.c
@@ -96,7 +96,10 @@ _item_unpressed(void *data, const Efl_Event *ev EINA_UNUSED)
96 m = _fetch_state(pd->container); 96 m = _fetch_state(pd->container);
97 97
98 if (pd->selected) 98 if (pd->selected)
99 efl_ui_selectable_selected_set(obj, EINA_FALSE); 99 {
100 if (efl_ui_selectable_allow_manual_deselection_get(pd->container))
101 efl_ui_selectable_selected_set(obj, EINA_FALSE);
102 }
100 else if (m != EFL_UI_SELECT_MODE_NONE) 103 else if (m != EFL_UI_SELECT_MODE_NONE)
101 efl_ui_selectable_selected_set(obj, EINA_TRUE); 104 efl_ui_selectable_selected_set(obj, EINA_TRUE);
102} 105}
diff --git a/src/lib/elementary/efl_ui_radio_group_impl.c b/src/lib/elementary/efl_ui_radio_group_impl.c
index 6a14f37115..ff1e085b8d 100644
--- a/src/lib/elementary/efl_ui_radio_group_impl.c
+++ b/src/lib/elementary/efl_ui_radio_group_impl.c
@@ -16,6 +16,18 @@ typedef struct {
16 Eina_Bool in_value_change; 16 Eina_Bool in_value_change;
17} Efl_Ui_Radio_Group_Impl_Data; 17} Efl_Ui_Radio_Group_Impl_Data;
18 18
19EOLIAN static void
20_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)
21{
22 if (allow_manual_deselection == EINA_FALSE)
23 ERR("This is right now not supported.");
24}
25
26EOLIAN static Eina_Bool
27_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)
28{
29 return EINA_FALSE;
30}
19 31
20EOLIAN static void 32EOLIAN static void
21_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) 33_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)
diff --git a/src/lib/elementary/efl_ui_radio_group_impl.eo b/src/lib/elementary/efl_ui_radio_group_impl.eo
index 7e4fefe01b..6bc4379d39 100644
--- a/src/lib/elementary/efl_ui_radio_group_impl.eo
+++ b/src/lib/elementary/efl_ui_radio_group_impl.eo
@@ -12,5 +12,6 @@ class Efl.Ui.Radio_Group_Impl extends Efl.Object implements Efl.Ui.Radio_Group
12 Efl.Ui.Radio_Group.unregister; 12 Efl.Ui.Radio_Group.unregister;
13 Efl.Ui.Single_Selectable.last_selected {get;} 13 Efl.Ui.Single_Selectable.last_selected {get;}
14 Efl.Ui.Single_Selectable.fallback_selection {set; get;} 14 Efl.Ui.Single_Selectable.fallback_selection {set; get;}
15 Efl.Ui.Single_Selectable.allow_manual_deselection {set; get;}
15 } 16 }
16} 17}
diff --git a/src/lib/elementary/efl_ui_single_selectable.eo b/src/lib/elementary/efl_ui_single_selectable.eo
index 1044082cc6..6e65c0a0ac 100644
--- a/src/lib/elementary/efl_ui_single_selectable.eo
+++ b/src/lib/elementary/efl_ui_single_selectable.eo
@@ -30,6 +30,12 @@ interface Efl.Ui.Single_Selectable {
30 fallback : Efl.Ui.Selectable; 30 fallback : Efl.Ui.Selectable;
31 } 31 }
32 } 32 }
33 @property allow_manual_deselection {
34 [[This controlls if a selected item can be deselected due to clicking]]
35 values {
36 allow_manual_deselection : bool; [[$true if clicking while selected results in a state change to unselected]]
37 }
38 }
33 } 39 }
34 events { 40 events {
35 selection_changed : void; [[Emitted when there is a change in the selection state. This event will collect all 41 selection_changed : void; [[Emitted when there is a change in the selection state. This event will collect all
diff --git a/src/lib/elementary/efl_ui_tab_bar.c b/src/lib/elementary/efl_ui_tab_bar.c
index 34e37299e2..da5ca2c43d 100644
--- a/src/lib/elementary/efl_ui_tab_bar.c
+++ b/src/lib/elementary/efl_ui_tab_bar.c
@@ -26,6 +26,19 @@ _efl_ui_tab_bar_efl_ui_single_selectable_fallback_selection_set(Eo *obj EINA_UNU
26 efl_ui_selectable_selected_set(pd->fallback_selection, EINA_TRUE); 26 efl_ui_selectable_selected_set(pd->fallback_selection, EINA_TRUE);
27} 27}
28 28
29EOLIAN static void
30_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)
31{
32 pd->allow_manual_deselection = !!allow_manual_deselection;
33}
34
35EOLIAN static Eina_Bool
36_efl_ui_tab_bar_efl_ui_single_selectable_allow_manual_deselection_get(const Eo *obj EINA_UNUSED, Efl_Ui_Tab_Bar_Data *pd)
37{
38 return pd->allow_manual_deselection;
39}
40
41
29EOLIAN static Efl_Ui_Selectable* 42EOLIAN static Efl_Ui_Selectable*
30_efl_ui_tab_bar_efl_ui_single_selectable_fallback_selection_get(const Eo *obj EINA_UNUSED, Efl_Ui_Tab_Bar_Data *pd) 43_efl_ui_tab_bar_efl_ui_single_selectable_fallback_selection_get(const Eo *obj EINA_UNUSED, Efl_Ui_Tab_Bar_Data *pd)
31{ 44{
diff --git a/src/lib/elementary/efl_ui_tab_bar.eo b/src/lib/elementary/efl_ui_tab_bar.eo
index cf06e0de47..c077cf0a57 100644
--- a/src/lib/elementary/efl_ui_tab_bar.eo
+++ b/src/lib/elementary/efl_ui_tab_bar.eo
@@ -15,6 +15,7 @@ class @beta Efl.Ui.Tab_Bar extends Efl.Ui.Layout_Base
15 Efl.Object.destructor; 15 Efl.Object.destructor;
16 Efl.Ui.Single_Selectable.last_selected {get;} 16 Efl.Ui.Single_Selectable.last_selected {get;}
17 Efl.Ui.Single_Selectable.fallback_selection {get; set;} 17 Efl.Ui.Single_Selectable.fallback_selection {get; set;}
18 Efl.Ui.Single_Selectable.allow_manual_deselection {get; set;}
18 Efl.Pack.pack; 19 Efl.Pack.pack;
19 Efl.Pack.pack_clear; 20 Efl.Pack.pack_clear;
20 Efl.Pack.unpack_all; 21 Efl.Pack.unpack_all;
diff --git a/src/lib/elementary/efl_ui_tab_bar_private.h b/src/lib/elementary/efl_ui_tab_bar_private.h
index 87763a9e87..02775c36a7 100644
--- a/src/lib/elementary/efl_ui_tab_bar_private.h
+++ b/src/lib/elementary/efl_ui_tab_bar_private.h
@@ -8,6 +8,7 @@ struct _Efl_Ui_Tab_Bar_Data
8 Efl_Ui_Box *bx; 8 Efl_Ui_Box *bx;
9 Efl_Ui_Item *selected, *fallback_selection; 9 Efl_Ui_Item *selected, *fallback_selection;
10 Eina_Bool in_value_change; 10 Eina_Bool in_value_change;
11 Eina_Bool allow_manual_deselection : 1;
11}; 12};
12 13
13#define EFL_UI_TAB_BAR_DATA_GET(o, sd) \ 14#define EFL_UI_TAB_BAR_DATA_GET(o, sd) \