elm: Uniform change event for nstate,radio,check

I added convenience macros for check and radio, easing discoverability
in C.

This will avoid C# issues such as:

lib/elementary/elm_pan.eo.cs(14,23): warning CS0108: `elm.Pan.CHANGED'
hides inherited member `efl.Gfx.CHANGED'. Use the new keyword if hiding
was intended
lib/efl/interfaces/efl_gfx.eo.cs(24,23): (Location of the symbol related
to previous warning)

Since nstate is not a legacy widget, I can safely change the event name
and the test case.
This commit is contained in:
Jean-Philippe Andre 2017-12-12 15:55:43 +09:00
parent 1264fb4af2
commit 3136500fbe
7 changed files with 17 additions and 30 deletions

View File

@ -4,16 +4,10 @@
#include <Elementary.h>
static void
_state_changed_cb(void *d EINA_UNUSED, Evas_Object *o, void *ei EINA_UNUSED)
_state_changed_cb(void *data EINA_UNUSED, const Efl_Event *ev)
{
char buf[100];
int val;
val = efl_ui_nstate_value_get(o);
printf("nstate widget state: %d\n", val);
sprintf(buf, "nstate = %d", val);
elm_object_text_set(o, buf);
int val = efl_ui_nstate_value_get(ev->object);
efl_text_set(ev->object, eina_slstr_printf("nstate = %d", val));
}
void
@ -21,21 +15,19 @@ test_nstate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
{
Evas_Object *win, *bx, *nstate;
win = elm_win_util_standard_add("nstate", "nstate");
elm_win_autodel_set(win, EINA_TRUE);
win = efl_add(EFL_UI_WIN_CLASS, NULL,
efl_text_set(efl_added, "N-state widget"),
elm_win_autodel_set(efl_added, EINA_TRUE));
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
bx = efl_add(EFL_UI_BOX_CLASS, win);
efl_content_set(win, bx);
nstate = efl_add(EFL_UI_NSTATE_CLASS, win);
efl_event_callback_add(nstate, EFL_UI_NSTATE_EVENT_CHANGED,
_state_changed_cb, NULL);
efl_ui_nstate_count_set(nstate, 5);
elm_object_text_set(nstate, "nstate = 0");
elm_box_pack_end(bx, nstate);
evas_object_smart_callback_add(nstate, "state,changed",
_state_changed_cb, NULL);
efl_text_set(nstate, "nstate = 0");
efl_pack(bx, nstate);
evas_object_resize(win, 100, 100);
evas_object_show(win);
efl_gfx_size_set(win, EINA_SIZE2D(120, 80));
}

View File

@ -32,8 +32,4 @@ class Efl.Ui.Check (Efl.Ui.Nstate, Efl.Access.Widget.Action)
Efl.Access.state_set { get; }
Efl.Access.Widget.Action.elm_actions { get; }
}
events {
changed; [[This is called whenever the user changes the state of the check
objects (event_info is always NULL).]]
}
}

View File

@ -73,7 +73,7 @@ _state_active(Evas_Object *obj, Efl_Ui_Nstate_Data *sd)
elm_layout_signal_emit(obj, buf, "elm");
edje_object_message_signal_process(elm_layout_edje_get(obj));
elm_layout_sizing_eval(obj);
efl_event_callback_legacy_call(obj, EFL_UI_NSTATE_EVENT_STATE_CHANGED, NULL);
efl_event_callback_legacy_call(obj, EFL_UI_NSTATE_EVENT_CHANGED, NULL);
}
EOLIAN static int

View File

@ -34,6 +34,6 @@ class Efl.Ui.Nstate(Efl.Ui.Button)
Elm.Widget.widget_event;
}
events {
state,changed; [[Called when nstate widget changed]]
changed; [[Called when the value changed.]]
}
}

View File

@ -71,7 +71,4 @@ class Efl.Ui.Radio (Efl.Ui.Check, Efl.Access.Widget.Action, Efl.Content)
Efl.Content.content_unset;
Efl.Ui.Nstate.value { set; get; }
}
events {
changed; [[Called when radio changed]]
}
}

View File

@ -61,6 +61,7 @@
#ifdef EFL_EO_API_SUPPORT
#include "efl_ui_check_eo.h"
#define EFL_UI_CHECK_EVENT_CHANGED EFL_UI_NSTATE_EVENT_CHANGED
#endif
#ifndef EFL_NOLEGACY_API_SUPPORT
#include "elm_check_legacy.h"

View File

@ -66,6 +66,7 @@
#ifdef EFL_EO_API_SUPPORT
#include "efl_ui_radio_eo.h"
#define EFL_UI_RADIO_EVENT_CHANGED EFL_UI_NSTATE_EVENT_CHANGED
#endif
#ifndef EFL_NOLEGACY_API_SUPPORT
#include "elm_radio_legacy.h"