summaryrefslogtreecommitdiff
path: root/src/examples/elementary
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-05-29 20:06:25 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-20 16:02:02 +0200
commit89102ecbd3bb99c996d7b34fbbb55900686200bc (patch)
tree9dfb0db1da14ca205c2772372ad23a6d922c6023 /src/examples/elementary
parent8cc340e8b2016bab13872e19abcde6a0b438b4db (diff)
efl_ui_radio: cleanup API
This is a bit of a giant commit. However, the problem here is that cleaning up the API went hand in hand with rewriting most of the usages. In the process of renewing and removing old API the following was done: - Legacy API testcases have been ported back to smart callbacks - EO-API testcases have been ported to efl_add syntax - weird event #defines have been removed - Wrong constructor usage has been removed - Ported to the new box object introduced before - removed legacy API from efl_ui_radio -> no more ptr(int) q66 will do jumps of happiness -> no more ununderstandable group_add methods -> Seperated code in blocks only for legacy, and blocks only for non-legacy To verify this commit, you can check all the tests that have been touched here. Additionally, the cxx example has been adjusted ref T7867 Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9060
Diffstat (limited to 'src/examples/elementary')
-rw-r--r--src/examples/elementary/efl_ui_list_example_1.c28
-rw-r--r--src/examples/elementary/radio_cxx_example_01.cc9
2 files changed, 13 insertions, 24 deletions
diff --git a/src/examples/elementary/efl_ui_list_example_1.c b/src/examples/elementary/efl_ui_list_example_1.c
index 135b8a2..7c3b1e5 100644
--- a/src/examples/elementary/efl_ui_list_example_1.c
+++ b/src/examples/elementary/efl_ui_list_example_1.c
@@ -70,13 +70,13 @@ static void
70_select_radio_changed(void *data, const Efl_Event *ev) 70_select_radio_changed(void *data, const Efl_Event *ev)
71{ 71{
72 Eo *list = data; 72 Eo *list = data;
73 efl_ui_select_mode_set(list, efl_ui_radio_state_value_get(ev->object)); 73 efl_ui_select_mode_set(list, efl_ui_radio_group_selected_value_get(ev->object));
74} 74}
75 75
76static void 76static void
77_anim_radio_changed(void *data EINA_UNUSED, const Efl_Event *ev) 77_anim_radio_changed(void *data, const Efl_Event *ev EINA_UNUSED)
78{ 78{
79 priv_d.anim = efl_ui_radio_state_value_get(ev->object); 79 priv_d.anim = efl_ui_radio_group_selected_value_get(data);
80} 80}
81 81
82static void 82static void
@@ -102,7 +102,7 @@ elm_main(int argc EINA_UNUSED, char **argv)
102 Eo *win, *list; 102 Eo *win, *list;
103 Eo *wbox, *ibox, *bbox, *rbox; 103 Eo *wbox, *ibox, *bbox, *rbox;
104 Eo *item, *check, *txt; 104 Eo *item, *check, *txt;
105 Eo *radio, *select_radio, *anim_radio; 105 Eo *radio;
106 Eo *slider, *scrl_btn; 106 Eo *slider, *scrl_btn;
107 int i; 107 int i;
108 char buf[256]; 108 char buf[256];
@@ -229,34 +229,28 @@ elm_main(int argc EINA_UNUSED, char **argv)
229 efl_text_set(txt, "Select Mode"); 229 efl_text_set(txt, "Select Mode");
230 efl_pack_end(wbox, txt); 230 efl_pack_end(wbox, txt);
231 231
232 bbox = efl_add(EFL_UI_BOX_CLASS, wbox); 232 bbox = efl_add(EFL_UI_RADIO_BOX_CLASS, wbox);
233 efl_ui_layout_orientation_set(bbox, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL); 233 efl_ui_layout_orientation_set(bbox, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL);
234 efl_gfx_hint_weight_set(bbox, EFL_GFX_HINT_EXPAND, 0.05); 234 efl_gfx_hint_weight_set(bbox, EFL_GFX_HINT_EXPAND, 0.05);
235 235
236 select_radio = radio = efl_add(EFL_UI_RADIO_CLASS, wbox); 236 radio = efl_add(EFL_UI_RADIO_CLASS, wbox);
237 efl_text_set(radio, "SINGLE"); 237 efl_text_set(radio, "SINGLE");
238 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_MODE_SINGLE); 238 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_MODE_SINGLE);
239 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _select_radio_changed, list);
240 efl_pack_end(bbox, radio); 239 efl_pack_end(bbox, radio);
241 radio = efl_add(EFL_UI_RADIO_CLASS, wbox); 240 radio = efl_add(EFL_UI_RADIO_CLASS, wbox);
242 efl_text_set(radio, "SINGLE_ALWAYS"); 241 efl_text_set(radio, "SINGLE_ALWAYS");
243 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_MODE_SINGLE_ALWAYS); 242 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_MODE_SINGLE_ALWAYS);
244 efl_ui_radio_group_add(radio, select_radio);
245 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _select_radio_changed, list);
246 efl_pack_end(bbox, radio); 243 efl_pack_end(bbox, radio);
247 radio = efl_add(EFL_UI_RADIO_CLASS, wbox); 244 radio = efl_add(EFL_UI_RADIO_CLASS, wbox);
248 efl_text_set(radio, "MULTI"); 245 efl_text_set(radio, "MULTI");
249 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_MODE_MULTI); 246 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_MODE_MULTI);
250 efl_ui_radio_group_add(radio, select_radio);
251 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _select_radio_changed, list);
252 efl_pack_end(bbox, radio); 247 efl_pack_end(bbox, radio);
253 radio = efl_add(EFL_UI_RADIO_CLASS, wbox); 248 radio = efl_add(EFL_UI_RADIO_CLASS, wbox);
254 efl_text_set(radio, "NONE"); 249 efl_text_set(radio, "NONE");
255 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_MODE_NONE); 250 efl_ui_radio_state_value_set(radio, EFL_UI_SELECT_MODE_NONE);
256 efl_ui_radio_group_add(radio, select_radio);
257 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _select_radio_changed, list);
258 efl_pack_end(bbox, radio); 251 efl_pack_end(bbox, radio);
259 efl_pack_end(wbox, bbox); 252 efl_pack_end(wbox, bbox);
253 efl_event_callback_add(bbox, EFL_UI_RADIO_GROUP_EVENT_VALUE_CHANGED, _select_radio_changed, list);
260 254
261 /* scroll mode */ 255 /* scroll mode */
262 txt = efl_add(EFL_UI_TEXT_CLASS, wbox); 256 txt = efl_add(EFL_UI_TEXT_CLASS, wbox);
@@ -278,23 +272,21 @@ elm_main(int argc EINA_UNUSED, char **argv)
278 efl_ui_layout_orientation_set(bbox, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL); 272 efl_ui_layout_orientation_set(bbox, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL);
279 efl_gfx_hint_weight_set(bbox, EFL_GFX_HINT_EXPAND, 0.05); 273 efl_gfx_hint_weight_set(bbox, EFL_GFX_HINT_EXPAND, 0.05);
280 274
281 rbox = efl_add(EFL_UI_BOX_CLASS, bbox); 275 rbox = efl_add(EFL_UI_RADIO_BOX_CLASS, bbox);
282 efl_ui_layout_orientation_set(rbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL); 276 efl_ui_layout_orientation_set(rbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL);
283 277
284 anim_radio = radio = efl_add(EFL_UI_RADIO_CLASS, rbox); 278 radio = efl_add(EFL_UI_RADIO_CLASS, rbox);
285 efl_gfx_hint_align_set(radio, 0.5, 0.5); 279 efl_gfx_hint_align_set(radio, 0.5, 0.5);
286 efl_text_set(radio, "ANIMATION OFF"); 280 efl_text_set(radio, "ANIMATION OFF");
287 efl_ui_radio_state_value_set(radio, 0); 281 efl_ui_radio_state_value_set(radio, 0);
288 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _anim_radio_changed, NULL);
289 efl_pack_end(rbox, radio); 282 efl_pack_end(rbox, radio);
290 radio = efl_add(EFL_UI_RADIO_CLASS, rbox); 283 radio = efl_add(EFL_UI_RADIO_CLASS, rbox);
291 efl_gfx_hint_align_set(radio, 0.5, 0.5); 284 efl_gfx_hint_align_set(radio, 0.5, 0.5);
292 efl_text_set(radio, "ANIMATION ON"); 285 efl_text_set(radio, "ANIMATION ON");
293 efl_ui_radio_state_value_set(radio, 1); 286 efl_ui_radio_state_value_set(radio, 1);
294 efl_ui_radio_group_add(radio, anim_radio);
295 efl_event_callback_add(radio, EFL_UI_RADIO_EVENT_CHANGED, _anim_radio_changed, NULL);
296 efl_pack_end(rbox, radio); 287 efl_pack_end(rbox, radio);
297 efl_pack_end(bbox, rbox); 288 efl_pack_end(bbox, rbox);
289 efl_event_callback_add(rbox, EFL_UI_RADIO_GROUP_EVENT_VALUE_CHANGED, _anim_radio_changed, rbox);
298 290
299 rbox = efl_add(EFL_UI_BOX_CLASS, bbox); 291 rbox = efl_add(EFL_UI_BOX_CLASS, bbox);
300 efl_ui_layout_orientation_set(rbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL); 292 efl_ui_layout_orientation_set(rbox, EFL_UI_LAYOUT_ORIENTATION_VERTICAL);
diff --git a/src/examples/elementary/radio_cxx_example_01.cc b/src/examples/elementary/radio_cxx_example_01.cc
index c6d5146..1b6c659 100644
--- a/src/examples/elementary/radio_cxx_example_01.cc
+++ b/src/examples/elementary/radio_cxx_example_01.cc
@@ -16,7 +16,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
16 win.text_set("Radio Example"); 16 win.text_set("Radio Example");
17 win.autohide_set(true); 17 win.autohide_set(true);
18 18
19 efl::ui::Box bx(instantiate, win); 19 efl::ui::Radio_Box bx(instantiate, win);
20 bx.orientation_set(EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL); 20 bx.orientation_set(EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL);
21 win.content_set(bx); 21 win.content_set(bx);
22 22
@@ -30,15 +30,14 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
30 radio.content_set(ic); 30 radio.content_set(ic);
31 bx.pack_end(radio); 31 bx.pack_end(radio);
32 32
33 auto cb_val = std::bind([] (efl::ui::Radio &obj) 33 auto cb_val = std::bind([bx] (efl::ui::Radio &obj EINA_UNUSED)
34 { std::cout << "val is now: " << obj.group_value_get() << std::endl; }, 34 { std::cout << "val is now: " << bx.selected_value_get() << std::endl; },
35 std::placeholders::_1); 35 std::placeholders::_1);
36 efl::eolian::event_add(efl::ui::Nstate::changed_event, radio, cb_val); 36 efl::eolian::event_add(efl::ui::Nstate::changed_event, radio, cb_val);
37 37
38 efl::ui::Radio radio2(instantiate, win); 38 efl::ui::Radio radio2(instantiate, win);
39 radio2.text_set("Radio 2"); 39 radio2.text_set("Radio 2");
40 radio2.state_value_set(2); 40 radio2.state_value_set(2);
41 radio2.group_add(group);
42 41
43 efl::ui::Image ic2(instantiate, win); 42 efl::ui::Image ic2(instantiate, win);
44 ic2.icon_set("file"); 43 ic2.icon_set("file");
@@ -49,14 +48,12 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
49 efl::ui::Radio radio3(instantiate, win); 48 efl::ui::Radio radio3(instantiate, win);
50 radio3.text_set("Radio 3"); 49 radio3.text_set("Radio 3");
51 radio3.state_value_set(3); 50 radio3.state_value_set(3);
52 radio3.group_add(group);
53 bx.pack_end(radio3); 51 bx.pack_end(radio3);
54 efl::eolian::event_add(efl::ui::Nstate::changed_event, radio3, cb_val); 52 efl::eolian::event_add(efl::ui::Nstate::changed_event, radio3, cb_val);
55 53
56 efl::ui::Radio radio4(instantiate, win); 54 efl::ui::Radio radio4(instantiate, win);
57 radio4.text_set("Radio 4"); 55 radio4.text_set("Radio 4");
58 radio4.state_value_set(4); 56 radio4.state_value_set(4);
59 radio4.group_add(group);
60 bx.pack_end(radio4); 57 bx.pack_end(radio4);
61 efl::eolian::event_add(efl::ui::Nstate::changed_event, radio4, cb_val); 58 efl::eolian::event_add(efl::ui::Nstate::changed_event, radio4, cb_val);
62} 59}