summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-05-30 22:15:19 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-20 16:02:01 +0200
commit8cc340e8b2016bab13872e19abcde6a0b438b4db (patch)
tree357eb9cc6e3ed16d46815df5696a31dfeee5cd52
parentc9177a9f8d75fc7bd2634a0adb63106492f3e94c (diff)
efl_ui_radio: refactor for usage of efl_ui_check_selected
in previous versions of this widget, the calls that are available due to inheritance did not work. efl_ui_check_selected_set did not work on a radio button. However, the internal function _state_set did just exactly that. So this commit refactors the activity emitting out of the function, so the _state_set function can just be used as the efl_ui_check_selected set function. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9059
-rw-r--r--src/bin/elementary/test_radio.c4
-rw-r--r--src/lib/elementary/efl_ui_radio.c115
-rw-r--r--src/lib/elementary/efl_ui_radio.eo1
3 files changed, 60 insertions, 60 deletions
diff --git a/src/bin/elementary/test_radio.c b/src/bin/elementary/test_radio.c
index 99eadfafca..608893e9a0 100644
--- a/src/bin/elementary/test_radio.c
+++ b/src/bin/elementary/test_radio.c
@@ -7,14 +7,14 @@ static void
7_rd_changed_cb(void *data EINA_UNUSED, Evas_Object *obj, 7_rd_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
8 void *event_info EINA_UNUSED) 8 void *event_info EINA_UNUSED)
9{ 9{
10 printf("radio value : %d\n", elm_radio_value_get(obj)); 10 printf("radio(%p) value : %d\n", obj, elm_radio_value_get(obj));
11} 11}
12 12
13static void 13static void
14_rdg_changed_cb(void *data EINA_UNUSED, Evas_Object *obj, 14_rdg_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
15 void *event_info EINA_UNUSED) 15 void *event_info EINA_UNUSED)
16{ 16{
17 printf("radio group value : %d\n", elm_radio_value_get(obj)); 17 printf("radio(%p) group value : %d\n", obj, elm_radio_value_get(obj));
18} 18}
19 19
20static void 20static void
diff --git a/src/lib/elementary/efl_ui_radio.c b/src/lib/elementary/efl_ui_radio.c
index 35e273a06f..7653fe0cba 100644
--- a/src/lib/elementary/efl_ui_radio.c
+++ b/src/lib/elementary/efl_ui_radio.c
@@ -43,57 +43,49 @@ static const Elm_Action key_actions[] = {
43}; 43};
44 44
45static void 45static void
46_state_set(Evas_Object *obj, Eina_Bool state, Eina_Bool activate) 46_radio_widget_signal_emit(Evas_Object *obj, const char *middle_term)
47{ 47{
48 ELM_RADIO_DATA_GET(obj, sd); 48 const char *source, *state;
49 char path[PATH_MAX];
50
51 if (elm_widget_is_legacy(obj))
52 source = "elm";
53 else
54 source = "efl";
55
56 if (efl_ui_check_selected_get(obj))
57 state = "on";
58 else
59 state = "off";
60
61 snprintf(path, sizeof(path), "%s,%s,%s", source, middle_term, state);
62 elm_layout_signal_emit(obj, path, source);
63}
49 64
50 if (state != sd->state) 65static void
66_efl_ui_radio_efl_ui_check_selected_set(Eo *obj, Efl_Ui_Radio_Data *pd EINA_UNUSED, Eina_Bool value)
67{
68 if (value == efl_ui_check_selected_get(obj)) return;
69 efl_ui_check_selected_set(efl_super(obj, MY_CLASS), value);
70
71 _radio_widget_signal_emit(obj, "state,radio");
72
73 if (_elm_config->atspi_mode)
51 { 74 {
52 sd->state = state; 75 if (efl_ui_check_selected_get(obj))
53 if (sd->state)
54 {
55 // FIXME: to do animation during state change , we need different signal
56 // so that we can distinguish between state change by user or state change
57 // by calling state_change() api. Keep both the signal for backward compatibility
58 // and only emit "elm,state,radio,on" when activate is false when we can break ABI.
59 if (elm_widget_is_legacy(obj))
60 {
61 if (activate) elm_layout_signal_emit(obj, "elm,activate,radio,on", "elm");
62 elm_layout_signal_emit(obj, "elm,state,radio,on", "elm");
63 }
64 else
65 {
66 if (activate) elm_layout_signal_emit(obj, "efl,activate,radio,on", "efl");
67 elm_layout_signal_emit(obj, "efl,state,radio,on", "efl");
68 }
69 }
70 else
71 { 76 {
72 // FIXME: to do animation during state change , we need different signal 77 efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_CHECKED, EINA_TRUE);
73 // so that we can distinguish between state change by user or state change
74 // by calling state_change() api. Keep both the signal for backward compatibility
75 // and only emit "elm,state,radio,off"when activate is false when we can break ABI.
76 if (elm_widget_is_legacy(obj))
77 {
78 if (activate) elm_layout_signal_emit(obj, "elm,activate,radio,off", "elm");
79 elm_layout_signal_emit(obj, "elm,state,radio,off", "elm");
80 }
81 else
82 {
83 if (activate) elm_layout_signal_emit(obj, "efl,activate,radio,off", "efl");
84 elm_layout_signal_emit(obj, "efl,state,radio,off", "efl");
85 }
86 }
87 if (_elm_config->atspi_mode)
88 {
89 if (sd->state)
90 {
91 efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_CHECKED, EINA_TRUE);
92 }
93 } 78 }
94 } 79 }
95} 80}
96 81
82
83static void
84_activate_state_emit(Evas_Object *obj)
85{
86 _radio_widget_signal_emit(obj, "activate,radio");
87}
88
97static void 89static void
98_state_set_all(Efl_Ui_Radio_Data *sd, Eina_Bool activate) 90_state_set_all(Efl_Ui_Radio_Data *sd, Eina_Bool activate)
99{ 91{
@@ -105,16 +97,25 @@ _state_set_all(Efl_Ui_Radio_Data *sd, Eina_Bool activate)
105 { 97 {
106 ELM_RADIO_DATA_GET(child, sdc); 98 ELM_RADIO_DATA_GET(child, sdc);
107 99
108 if (sdc->state) selected = child; 100 if (efl_ui_check_selected_get(child)) selected = child;
109 if (sdc->value == sd->group->value) 101 if (sdc->value == sd->group->value)
110 { 102 {
111 _state_set(child, EINA_TRUE, activate); 103 if (activate) _activate_state_emit(child);
112 if (!sdc->state) disabled = EINA_TRUE; 104 efl_ui_check_selected_set(child, EINA_TRUE);
105 if (!efl_ui_check_selected_get(child)) disabled = EINA_TRUE;
106 }
107 else
108 {
109 if (activate) _activate_state_emit(child);
110 efl_ui_check_selected_set(child, EINA_FALSE);
113 } 111 }
114 else _state_set(child, EINA_FALSE, activate);
115 } 112 }
116 113
117 if ((disabled) && (selected)) _state_set(selected, 1, activate); 114 if ((disabled) && (selected))
115 {
116 if (activate) _activate_state_emit(selected);
117 efl_ui_check_selected_set(selected, EINA_TRUE);
118 }
118} 119}
119 120
120static void 121static void
@@ -148,7 +149,7 @@ _key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
148} 149}
149 150
150EOLIAN static Eina_Error 151EOLIAN static Eina_Error
151_efl_ui_radio_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Radio_Data *sd) 152_efl_ui_radio_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Radio_Data *sd EINA_UNUSED)
152{ 153{
153 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC); 154 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC);
154 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC; 155 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
@@ -157,12 +158,12 @@ _efl_ui_radio_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Radio_Data *sd)
157 158
158 if (elm_widget_is_legacy(obj)) 159 if (elm_widget_is_legacy(obj))
159 { 160 {
160 if (sd->state) elm_layout_signal_emit(obj, "elm,state,radio,on", "elm"); 161 if (efl_ui_check_selected_get(obj)) elm_layout_signal_emit(obj, "elm,state,radio,on", "elm");
161 else elm_layout_signal_emit(obj, "elm,state,radio,off", "elm"); 162 else elm_layout_signal_emit(obj, "elm,state,radio,off", "elm");
162 } 163 }
163 else 164 else
164 { 165 {
165 if (sd->state) elm_layout_signal_emit(obj, "efl,state,radio,on", "efl"); 166 if (efl_ui_check_selected_get(obj)) elm_layout_signal_emit(obj, "efl,state,radio,on", "efl");
166 else elm_layout_signal_emit(obj, "efl,state,radio,off", "efl"); 167 else elm_layout_signal_emit(obj, "efl,state,radio,off", "efl");
167 } 168 }
168 169
@@ -196,10 +197,8 @@ _access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
196static char * 197static char *
197_access_state_cb(void *data EINA_UNUSED, Evas_Object *obj) 198_access_state_cb(void *data EINA_UNUSED, Evas_Object *obj)
198{ 199{
199 ELM_RADIO_DATA_GET(obj, sd);
200
201 if (elm_widget_disabled_get(obj)) return strdup(E_("State: Disabled")); 200 if (elm_widget_disabled_get(obj)) return strdup(E_("State: Disabled"));
202 if (sd->state) return strdup(E_("State: On")); 201 if (efl_ui_check_selected_get(obj)) return strdup(E_("State: On"));
203 202
204 return strdup(E_("State: Off")); 203 return strdup(E_("State: Off"));
205} 204}
@@ -267,16 +266,16 @@ _efl_ui_radio_group_add(Eo *obj, Efl_Ui_Radio_Data *sd, Evas_Object *group)
267 sd->group = sdg->group; 266 sd->group = sdg->group;
268 sd->group->radios = eina_list_append(sd->group->radios, obj); 267 sd->group->radios = eina_list_append(sd->group->radios, obj);
269 } 268 }
270 if (sd->value == sd->group->value) _state_set(obj, EINA_TRUE, EINA_FALSE); 269 if (sd->value == sd->group->value) efl_ui_check_selected_set(obj, EINA_TRUE);
271 else _state_set(obj, EINA_FALSE, EINA_FALSE); 270 else efl_ui_check_selected_set(obj, EINA_FALSE);
272} 271}
273 272
274EOLIAN static void 273EOLIAN static void
275_efl_ui_radio_state_value_set(Eo *obj, Efl_Ui_Radio_Data *sd, int value) 274_efl_ui_radio_state_value_set(Eo *obj, Efl_Ui_Radio_Data *sd, int value)
276{ 275{
277 sd->value = value; 276 sd->value = value;
278 if (sd->value == sd->group->value) _state_set(obj, EINA_TRUE, EINA_FALSE); 277 if (sd->value == sd->group->value) efl_ui_check_selected_set(obj, EINA_TRUE);
279 else _state_set(obj, EINA_FALSE, EINA_FALSE); 278 else efl_ui_check_selected_set(obj, EINA_FALSE);
280} 279}
281 280
282EOLIAN static int 281EOLIAN static int
diff --git a/src/lib/elementary/efl_ui_radio.eo b/src/lib/elementary/efl_ui_radio.eo
index e59e548300..bd7475775c 100644
--- a/src/lib/elementary/efl_ui_radio.eo
+++ b/src/lib/elementary/efl_ui_radio.eo
@@ -28,5 +28,6 @@ class @beta Efl.Ui.Radio extends Efl.Ui.Check implements Efl.Access.Widget.Actio
28 Efl.Ui.Widget.widget_input_event_handler; 28 Efl.Ui.Widget.widget_input_event_handler;
29 Efl.Access.Object.state_set { get; } 29 Efl.Access.Object.state_set { get; }
30 Efl.Access.Widget.Action.elm_actions { get; } 30 Efl.Access.Widget.Action.elm_actions { get; }
31 Efl.Ui.Check.selected {set;}
31 } 32 }
32} 33}