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)
downloadefl-8cc340e8b2016bab13872e19abcde6a0b438b4db.tar.gz
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
_rd_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
- printf("radio value : %d\n", elm_radio_value_get(obj));
+ printf("radio(%p) value : %d\n", obj, elm_radio_value_get(obj));
}
static void
_rdg_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
- printf("radio group value : %d\n", elm_radio_value_get(obj));
+ printf("radio(%p) group value : %d\n", obj, elm_radio_value_get(obj));
}
static 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[] = {
};
static void
-_state_set(Evas_Object *obj, Eina_Bool state, Eina_Bool activate)
+_radio_widget_signal_emit(Evas_Object *obj, const char *middle_term)
{
- ELM_RADIO_DATA_GET(obj, sd);
+ const char *source, *state;
+ char path[PATH_MAX];
+
+ if (elm_widget_is_legacy(obj))
+ source = "elm";
+ else
+ source = "efl";
+
+ if (efl_ui_check_selected_get(obj))
+ state = "on";
+ else
+ state = "off";
+
+ snprintf(path, sizeof(path), "%s,%s,%s", source, middle_term, state);
+ elm_layout_signal_emit(obj, path, source);
+}
- if (state != sd->state)
+static void
+_efl_ui_radio_efl_ui_check_selected_set(Eo *obj, Efl_Ui_Radio_Data *pd EINA_UNUSED, Eina_Bool value)
+{
+ if (value == efl_ui_check_selected_get(obj)) return;
+ efl_ui_check_selected_set(efl_super(obj, MY_CLASS), value);
+
+ _radio_widget_signal_emit(obj, "state,radio");
+
+ if (_elm_config->atspi_mode)
{
- sd->state = state;
- if (sd->state)
- {
- // FIXME: to do animation during state change , we need different signal
- // so that we can distinguish between state change by user or state change
- // by calling state_change() api. Keep both the signal for backward compatibility
- // and only emit "elm,state,radio,on" when activate is false when we can break ABI.
- if (elm_widget_is_legacy(obj))
- {
- if (activate) elm_layout_signal_emit(obj, "elm,activate,radio,on", "elm");
- elm_layout_signal_emit(obj, "elm,state,radio,on", "elm");
- }
- else
- {
- if (activate) elm_layout_signal_emit(obj, "efl,activate,radio,on", "efl");
- elm_layout_signal_emit(obj, "efl,state,radio,on", "efl");
- }
- }
- else
+ if (efl_ui_check_selected_get(obj))
{
- // FIXME: to do animation during state change , we need different signal
- // so that we can distinguish between state change by user or state change
- // by calling state_change() api. Keep both the signal for backward compatibility
- // and only emit "elm,state,radio,off"when activate is false when we can break ABI.
- if (elm_widget_is_legacy(obj))
- {
- if (activate) elm_layout_signal_emit(obj, "elm,activate,radio,off", "elm");
- elm_layout_signal_emit(obj, "elm,state,radio,off", "elm");
- }
- else
- {
- if (activate) elm_layout_signal_emit(obj, "efl,activate,radio,off", "efl");
- elm_layout_signal_emit(obj, "efl,state,radio,off", "efl");
- }
- }
- if (_elm_config->atspi_mode)
- {
- if (sd->state)
- {
- efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_CHECKED, EINA_TRUE);
- }
+ efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_CHECKED, EINA_TRUE);
}
}
}
+
+static void
+_activate_state_emit(Evas_Object *obj)
+{
+ _radio_widget_signal_emit(obj, "activate,radio");
+}
+
static void
_state_set_all(Efl_Ui_Radio_Data *sd, Eina_Bool activate)
{
@@ -105,16 +97,25 @@ _state_set_all(Efl_Ui_Radio_Data *sd, Eina_Bool activate)
{
ELM_RADIO_DATA_GET(child, sdc);
- if (sdc->state) selected = child;
+ if (efl_ui_check_selected_get(child)) selected = child;
if (sdc->value == sd->group->value)
{
- _state_set(child, EINA_TRUE, activate);
- if (!sdc->state) disabled = EINA_TRUE;
+ if (activate) _activate_state_emit(child);
+ efl_ui_check_selected_set(child, EINA_TRUE);
+ if (!efl_ui_check_selected_get(child)) disabled = EINA_TRUE;
+ }
+ else
+ {
+ if (activate) _activate_state_emit(child);
+ efl_ui_check_selected_set(child, EINA_FALSE);
}
- else _state_set(child, EINA_FALSE, activate);
}
- if ((disabled) && (selected)) _state_set(selected, 1, activate);
+ if ((disabled) && (selected))
+ {
+ if (activate) _activate_state_emit(selected);
+ efl_ui_check_selected_set(selected, EINA_TRUE);
+ }
}
static void
@@ -148,7 +149,7 @@ _key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
}
EOLIAN static Eina_Error
-_efl_ui_radio_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Radio_Data *sd)
+_efl_ui_radio_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Radio_Data *sd EINA_UNUSED)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_ERROR_GENERIC);
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)
if (elm_widget_is_legacy(obj))
{
- if (sd->state) elm_layout_signal_emit(obj, "elm,state,radio,on", "elm");
+ if (efl_ui_check_selected_get(obj)) elm_layout_signal_emit(obj, "elm,state,radio,on", "elm");
else elm_layout_signal_emit(obj, "elm,state,radio,off", "elm");
}
else
{
- if (sd->state) elm_layout_signal_emit(obj, "efl,state,radio,on", "efl");
+ if (efl_ui_check_selected_get(obj)) elm_layout_signal_emit(obj, "efl,state,radio,on", "efl");
else elm_layout_signal_emit(obj, "efl,state,radio,off", "efl");
}
@@ -196,10 +197,8 @@ _access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
static char *
_access_state_cb(void *data EINA_UNUSED, Evas_Object *obj)
{
- ELM_RADIO_DATA_GET(obj, sd);
-
if (elm_widget_disabled_get(obj)) return strdup(E_("State: Disabled"));
- if (sd->state) return strdup(E_("State: On"));
+ if (efl_ui_check_selected_get(obj)) return strdup(E_("State: On"));
return strdup(E_("State: Off"));
}
@@ -267,16 +266,16 @@ _efl_ui_radio_group_add(Eo *obj, Efl_Ui_Radio_Data *sd, Evas_Object *group)
sd->group = sdg->group;
sd->group->radios = eina_list_append(sd->group->radios, obj);
}
- if (sd->value == sd->group->value) _state_set(obj, EINA_TRUE, EINA_FALSE);
- else _state_set(obj, EINA_FALSE, EINA_FALSE);
+ if (sd->value == sd->group->value) efl_ui_check_selected_set(obj, EINA_TRUE);
+ else efl_ui_check_selected_set(obj, EINA_FALSE);
}
EOLIAN static void
_efl_ui_radio_state_value_set(Eo *obj, Efl_Ui_Radio_Data *sd, int value)
{
sd->value = value;
- if (sd->value == sd->group->value) _state_set(obj, EINA_TRUE, EINA_FALSE);
- else _state_set(obj, EINA_FALSE, EINA_FALSE);
+ if (sd->value == sd->group->value) efl_ui_check_selected_set(obj, EINA_TRUE);
+ else efl_ui_check_selected_set(obj, EINA_FALSE);
}
EOLIAN 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
Efl.Ui.Widget.widget_input_event_handler;
Efl.Access.Object.state_set { get; }
Efl.Access.Widget.Action.elm_actions { get; }
+ Efl.Ui.Check.selected {set;}
}
}