forked from enlightenment/efl
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:
parent
1264fb4af2
commit
3136500fbe
|
@ -4,16 +4,10 @@
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
|
|
||||||
static void
|
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 = efl_ui_nstate_value_get(ev->object);
|
||||||
int val;
|
efl_text_set(ev->object, eina_slstr_printf("nstate = %d", 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -21,21 +15,19 @@ test_nstate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
||||||
{
|
{
|
||||||
Evas_Object *win, *bx, *nstate;
|
Evas_Object *win, *bx, *nstate;
|
||||||
|
|
||||||
win = elm_win_util_standard_add("nstate", "nstate");
|
win = efl_add(EFL_UI_WIN_CLASS, NULL,
|
||||||
elm_win_autodel_set(win, EINA_TRUE);
|
efl_text_set(efl_added, "N-state widget"),
|
||||||
|
elm_win_autodel_set(efl_added, EINA_TRUE));
|
||||||
|
|
||||||
bx = elm_box_add(win);
|
bx = efl_add(EFL_UI_BOX_CLASS, win);
|
||||||
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
efl_content_set(win, bx);
|
||||||
elm_win_resize_object_add(win, bx);
|
|
||||||
evas_object_show(bx);
|
|
||||||
|
|
||||||
nstate = efl_add(EFL_UI_NSTATE_CLASS, win);
|
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);
|
efl_ui_nstate_count_set(nstate, 5);
|
||||||
elm_object_text_set(nstate, "nstate = 0");
|
efl_text_set(nstate, "nstate = 0");
|
||||||
elm_box_pack_end(bx, nstate);
|
efl_pack(bx, nstate);
|
||||||
evas_object_smart_callback_add(nstate, "state,changed",
|
|
||||||
_state_changed_cb, NULL);
|
|
||||||
|
|
||||||
evas_object_resize(win, 100, 100);
|
efl_gfx_size_set(win, EINA_SIZE2D(120, 80));
|
||||||
evas_object_show(win);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,4 @@ class Efl.Ui.Check (Efl.Ui.Nstate, Efl.Access.Widget.Action)
|
||||||
Efl.Access.state_set { get; }
|
Efl.Access.state_set { get; }
|
||||||
Efl.Access.Widget.Action.elm_actions { 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).]]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ _state_active(Evas_Object *obj, Efl_Ui_Nstate_Data *sd)
|
||||||
elm_layout_signal_emit(obj, buf, "elm");
|
elm_layout_signal_emit(obj, buf, "elm");
|
||||||
edje_object_message_signal_process(elm_layout_edje_get(obj));
|
edje_object_message_signal_process(elm_layout_edje_get(obj));
|
||||||
elm_layout_sizing_eval(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
|
EOLIAN static int
|
||||||
|
|
|
@ -34,6 +34,6 @@ class Efl.Ui.Nstate(Efl.Ui.Button)
|
||||||
Elm.Widget.widget_event;
|
Elm.Widget.widget_event;
|
||||||
}
|
}
|
||||||
events {
|
events {
|
||||||
state,changed; [[Called when nstate widget changed]]
|
changed; [[Called when the value changed.]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,4 @@ class Efl.Ui.Radio (Efl.Ui.Check, Efl.Access.Widget.Action, Efl.Content)
|
||||||
Efl.Content.content_unset;
|
Efl.Content.content_unset;
|
||||||
Efl.Ui.Nstate.value { set; get; }
|
Efl.Ui.Nstate.value { set; get; }
|
||||||
}
|
}
|
||||||
events {
|
|
||||||
changed; [[Called when radio changed]]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
|
|
||||||
#ifdef EFL_EO_API_SUPPORT
|
#ifdef EFL_EO_API_SUPPORT
|
||||||
#include "efl_ui_check_eo.h"
|
#include "efl_ui_check_eo.h"
|
||||||
|
#define EFL_UI_CHECK_EVENT_CHANGED EFL_UI_NSTATE_EVENT_CHANGED
|
||||||
#endif
|
#endif
|
||||||
#ifndef EFL_NOLEGACY_API_SUPPORT
|
#ifndef EFL_NOLEGACY_API_SUPPORT
|
||||||
#include "elm_check_legacy.h"
|
#include "elm_check_legacy.h"
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
|
|
||||||
#ifdef EFL_EO_API_SUPPORT
|
#ifdef EFL_EO_API_SUPPORT
|
||||||
#include "efl_ui_radio_eo.h"
|
#include "efl_ui_radio_eo.h"
|
||||||
|
#define EFL_UI_RADIO_EVENT_CHANGED EFL_UI_NSTATE_EVENT_CHANGED
|
||||||
#endif
|
#endif
|
||||||
#ifndef EFL_NOLEGACY_API_SUPPORT
|
#ifndef EFL_NOLEGACY_API_SUPPORT
|
||||||
#include "elm_radio_legacy.h"
|
#include "elm_radio_legacy.h"
|
||||||
|
|
Loading…
Reference in New Issue