summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-06-13 09:21:38 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-06-13 09:21:38 -0400
commit3a5f506b0e87d42a78a420b5a89936ad0deb04ba (patch)
tree373069c8efc323a5d60a13e88a46ac291e76bc76
parentd7fb6f62b46471767ba13b292dad9f6456de0cdd (diff)
efl_ui_check: make it undependend of nstate
Summary: check can only display 2 states, and is only designed to do so. Additionally, nstate inherits from button, which brings in autorepeat, which is hileriously broken on check and cannot really work. Right now there is not even support in the theme for clickable. So its a good idea to get rid of this for now IMO. ref T7865 Reviewers: stefan_schmidt, zmike, segfaultxavi, akanad, YOhoho Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7865, T7867 Differential Revision: https://phab.enlightenment.org/D9018
-rw-r--r--src/Makefile_Elementary.am1
-rw-r--r--src/bin/elementary/test_bg.c2
-rw-r--r--src/bin/elementary/test_part_bg.c2
-rw-r--r--src/bin/elementary/test_photocam.c2
-rw-r--r--src/bin/elementary/test_ui_pager_scroll.c12
-rw-r--r--src/bin/elementary/test_ui_panel.c4
-rw-r--r--src/bin/elementary/test_ui_tab_pager.c8
-rw-r--r--src/examples/elementary/radio_cxx_example_01.cc2
-rw-r--r--src/lib/elementary/efl_ui_check.c157
-rw-r--r--src/lib/elementary/efl_ui_check.eo10
-rw-r--r--src/lib/elementary/efl_ui_check_private.h1
-rw-r--r--src/lib/elementary/efl_ui_radio.c8
-rw-r--r--src/lib/elementary/efl_ui_radio.eo12
-rw-r--r--src/tests/elementary/efl_ui_suite.c1
-rw-r--r--src/tests/elementary/efl_ui_suite.h3
-rw-r--r--src/tests/elementary/efl_ui_test_check.c80
-rw-r--r--src/tests/elementary/meson.build1
17 files changed, 178 insertions, 128 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 166f2457e7..e2957f185f 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -1962,6 +1962,7 @@ tests_elementary_efl_ui_suite_SOURCES = \
1962 tests/elementary/efl_ui_test_layout.c \ 1962 tests/elementary/efl_ui_test_layout.c \
1963 tests/elementary/efl_ui_test_widget.c \ 1963 tests/elementary/efl_ui_test_widget.c \
1964 tests/elementary/efl_ui_test_active_view.c \ 1964 tests/elementary/efl_ui_test_active_view.c \
1965 tests/elementary/efl_ui_test_check.c \
1965 tests/elementary/efl_ui_suite.h \ 1966 tests/elementary/efl_ui_suite.h \
1966 tests/elementary/efl_ui_model.c 1967 tests/elementary/efl_ui_model.c
1967 1968
diff --git a/src/bin/elementary/test_bg.c b/src/bin/elementary/test_bg.c
index 25e54ff3aa..5c74caf53e 100644
--- a/src/bin/elementary/test_bg.c
+++ b/src/bin/elementary/test_bg.c
@@ -473,7 +473,7 @@ test_bg_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
473 efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED, _cb_radio_changed_scale_type, o_bg), 473 efl_event_callback_add(efl_added, EFL_UI_RADIO_EVENT_CHANGED, _cb_radio_changed_scale_type, o_bg),
474 efl_pack(hbox, efl_added)); 474 efl_pack(hbox, efl_added));
475 475
476 efl_ui_nstate_value_set(rdg, EFL_GFX_IMAGE_SCALE_TYPE_FILL); 476 efl_ui_radio_group_value_set(rdg, EFL_GFX_IMAGE_SCALE_TYPE_FILL);
477 477
478 efl_add(EFL_UI_CHECK_CLASS, hbox, 478 efl_add(EFL_UI_CHECK_CLASS, hbox,
479 efl_text_set(efl_added, "Bg Color"), 479 efl_text_set(efl_added, "Bg Color"),
diff --git a/src/bin/elementary/test_part_bg.c b/src/bin/elementary/test_part_bg.c
index 6285947f01..6ab0d6ecc4 100644
--- a/src/bin/elementary/test_part_bg.c
+++ b/src/bin/elementary/test_part_bg.c
@@ -110,7 +110,7 @@ _create_box_contents(Evas_Object *box)
110 evas_object_data_set(radio, "data", content); 110 evas_object_data_set(radio, "data", content);
111 } 111 }
112 112
113 efl_ui_nstate_value_set(radio_group, 0); 113 efl_ui_radio_group_value_set(radio_group, 0);
114 114
115 return radio_group; 115 return radio_group;
116} 116}
diff --git a/src/bin/elementary/test_photocam.c b/src/bin/elementary/test_photocam.c
index 4e79fecf81..bbbbb1fe88 100644
--- a/src/bin/elementary/test_photocam.c
+++ b/src/bin/elementary/test_photocam.c
@@ -654,7 +654,7 @@ static const struct {
654static void 654static void
655_radio_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 655_radio_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
656{ 656{
657 unsigned char index = efl_ui_nstate_value_get(obj); 657 unsigned char index = elm_radio_value_get(obj);
658 efl_ui_image_icon_set(data, photocam_icons[index].name); 658 efl_ui_image_icon_set(data, photocam_icons[index].name);
659 printf("icon is %s\n", efl_ui_image_icon_get(data)); 659 printf("icon is %s\n", efl_ui_image_icon_get(data));
660} 660}
diff --git a/src/bin/elementary/test_ui_pager_scroll.c b/src/bin/elementary/test_ui_pager_scroll.c
index 740a8fc3d8..e25132d37b 100644
--- a/src/bin/elementary/test_ui_pager_scroll.c
+++ b/src/bin/elementary/test_ui_pager_scroll.c
@@ -339,7 +339,7 @@ static void prev_block_check_cb(void *data, const Efl_Event *ev)
339 Eo *pager = data; 339 Eo *pager = data;
340 Eina_Bool prev, next; 340 Eina_Bool prev, next;
341 341
342 prev = efl_ui_nstate_value_get(ev->object); 342 prev = efl_ui_check_selected_get(ev->object);
343 343
344 efl_ui_pager_scroll_block_get(pager, NULL, &next); 344 efl_ui_pager_scroll_block_get(pager, NULL, &next);
345 efl_ui_pager_scroll_block_set(pager, prev, next); 345 efl_ui_pager_scroll_block_set(pager, prev, next);
@@ -350,7 +350,7 @@ static void next_block_check_cb(void *data, const Efl_Event *ev)
350 Eo *pager = data; 350 Eo *pager = data;
351 Eina_Bool prev, next; 351 Eina_Bool prev, next;
352 352
353 next = efl_ui_nstate_value_get(ev->object); 353 next = efl_ui_check_selected_get(ev->object);
354 354
355 efl_ui_pager_scroll_block_get(pager, &prev, NULL); 355 efl_ui_pager_scroll_block_get(pager, &prev, NULL);
356 efl_ui_pager_scroll_block_set(pager, prev, next); 356 efl_ui_pager_scroll_block_set(pager, prev, next);
@@ -359,7 +359,7 @@ static void next_block_check_cb(void *data, const Efl_Event *ev)
359static void loop_radio_cb(void *data, const Efl_Event *ev) 359static void loop_radio_cb(void *data, const Efl_Event *ev)
360{ 360{
361 Eo *pager = data; 361 Eo *pager = data;
362 int state = efl_ui_nstate_value_get(ev->object); 362 int state = efl_ui_radio_group_value_get(ev->object);
363 363
364 efl_ui_pager_loop_mode_set(pager, state); 364 efl_ui_pager_loop_mode_set(pager, state);
365} 365}
@@ -796,7 +796,7 @@ static void scroll_block_cb(void *data,
796 efl_add(EFL_UI_CHECK_CLASS, box, 796 efl_add(EFL_UI_CHECK_CLASS, box,
797 efl_ui_widget_style_set(efl_added, "toggle"), 797 efl_ui_widget_style_set(efl_added, "toggle"),
798 efl_text_set(efl_added, "Prev Block"), 798 efl_text_set(efl_added, "Prev Block"),
799 efl_ui_nstate_value_set(efl_added, prev), 799 efl_ui_check_selected_set(efl_added, prev),
800 efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_CHANGED, 800 efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_CHANGED,
801 prev_block_check_cb, pager), 801 prev_block_check_cb, pager),
802 efl_pack_end(box, efl_added)); 802 efl_pack_end(box, efl_added));
@@ -804,7 +804,7 @@ static void scroll_block_cb(void *data,
804 efl_add(EFL_UI_CHECK_CLASS, box, 804 efl_add(EFL_UI_CHECK_CLASS, box,
805 efl_ui_widget_style_set(efl_added, "toggle"), 805 efl_ui_widget_style_set(efl_added, "toggle"),
806 efl_text_set(efl_added, "Next Block"), 806 efl_text_set(efl_added, "Next Block"),
807 efl_ui_nstate_value_set(efl_added, next), 807 efl_ui_check_selected_set(efl_added, next),
808 efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_CHANGED, 808 efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_CHANGED,
809 next_block_check_cb, pager), 809 next_block_check_cb, pager),
810 efl_pack_end(box, efl_added)); 810 efl_pack_end(box, efl_added));
@@ -849,7 +849,7 @@ static void loop_cb(void *data EINA_UNUSED,
849 849
850 loop = efl_ui_pager_loop_mode_get(pager); 850 loop = efl_ui_pager_loop_mode_get(pager);
851 851
852 efl_ui_nstate_value_set(rd, loop); 852 efl_ui_radio_group_value_set(rd, loop);
853 853
854 if (loop == EFL_UI_PAGER_LOOP_DISABLED) 854 if (loop == EFL_UI_PAGER_LOOP_DISABLED)
855 { 855 {
diff --git a/src/bin/elementary/test_ui_panel.c b/src/bin/elementary/test_ui_panel.c
index a9c3cafbf8..f8bbd0bd78 100644
--- a/src/bin/elementary/test_ui_panel.c
+++ b/src/bin/elementary/test_ui_panel.c
@@ -67,7 +67,7 @@ test_ui_panel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
67static void 67static void
68_check_changed(void *data EINA_UNUSED, const Efl_Event *ev) 68_check_changed(void *data EINA_UNUSED, const Efl_Event *ev)
69{ 69{
70 elm_config_scroll_thumbscroll_enabled_set(efl_ui_nstate_value_get(ev->object)); 70 elm_config_scroll_thumbscroll_enabled_set(efl_ui_check_selected_get(ev->object));
71} 71}
72 72
73static void 73static void
@@ -76,7 +76,7 @@ _panel_toggled(void *data, const Efl_Event *ev)
76 Evas_Object *list; 76 Evas_Object *list;
77 int i; 77 int i;
78 78
79 if (!efl_ui_nstate_value_get(data)) return; 79 if (!efl_ui_check_selected_get(data)) return;
80 80
81 list = efl_content_get(ev->object); 81 list = efl_content_get(ev->object);
82 evas_object_del(list); 82 evas_object_del(list);
diff --git a/src/bin/elementary/test_ui_tab_pager.c b/src/bin/elementary/test_ui_tab_pager.c
index 0b70c86c12..d2c0e6b7cd 100644
--- a/src/bin/elementary/test_ui_tab_pager.c
+++ b/src/bin/elementary/test_ui_tab_pager.c
@@ -491,7 +491,7 @@ _change_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
491 cur = efl_ui_active_view_active_index_get(tcd->tab_pager); 491 cur = efl_ui_active_view_active_index_get(tcd->tab_pager);
492 tab_page = efl_pack_content_get(tcd->tab_pager, cur); 492 tab_page = efl_pack_content_get(tcd->tab_pager, cur);
493 493
494 if (efl_ui_nstate_value_get(tcd->label_check)) 494 if (efl_ui_check_selected_get(tcd->label_check))
495 { 495 {
496 label = tab_label_get(); 496 label = tab_label_get();
497 efl_text_set(efl_part(tab_page, "tab"), label); 497 efl_text_set(efl_part(tab_page, "tab"), label);
@@ -499,7 +499,7 @@ _change_btn_cb(void *data, const Efl_Event *ev EINA_UNUSED)
499 efl_content_set(tab_page, content); 499 efl_content_set(tab_page, content);
500 } 500 }
501 501
502 if (efl_ui_nstate_value_get(tcd->icon_check)) 502 if (efl_ui_check_selected_get(tcd->icon_check))
503 { 503 {
504 icon = tab_icon_get(); 504 icon = tab_icon_get();
505 efl_ui_tab_page_part_tab_icon_set(efl_part(tab_page, "tab"), icon); 505 efl_ui_tab_page_part_tab_icon_set(efl_part(tab_page, "tab"), icon);
@@ -534,12 +534,12 @@ _tab_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
534 534
535 label_check = efl_add(EFL_UI_CHECK_CLASS, box, 535 label_check = efl_add(EFL_UI_CHECK_CLASS, box,
536 efl_text_set(efl_added, "Tab Label + Page"), 536 efl_text_set(efl_added, "Tab Label + Page"),
537 efl_ui_nstate_value_set(efl_added, EINA_FALSE), 537 efl_ui_check_selected_set(efl_added, EINA_FALSE),
538 efl_pack_end(box, efl_added)); 538 efl_pack_end(box, efl_added));
539 539
540 icon_check = efl_add(EFL_UI_CHECK_CLASS, box, 540 icon_check = efl_add(EFL_UI_CHECK_CLASS, box,
541 efl_text_set(efl_added, "Tab Icon"), 541 efl_text_set(efl_added, "Tab Icon"),
542 efl_ui_nstate_value_set(efl_added, EINA_FALSE), 542 efl_ui_check_selected_set(efl_added, EINA_FALSE),
543 efl_pack_end(box, efl_added)); 543 efl_pack_end(box, efl_added));
544 544
545 tcd->tab_pager = tab_pager; 545 tcd->tab_pager = tab_pager;
diff --git a/src/examples/elementary/radio_cxx_example_01.cc b/src/examples/elementary/radio_cxx_example_01.cc
index 4a6e58330b..c6d5146655 100644
--- a/src/examples/elementary/radio_cxx_example_01.cc
+++ b/src/examples/elementary/radio_cxx_example_01.cc
@@ -31,7 +31,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
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([] (efl::ui::Radio &obj)
34 { std::cout << "val is now: " << obj.value_get() << std::endl; }, 34 { std::cout << "val is now: " << obj.group_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
diff --git a/src/lib/elementary/efl_ui_check.c b/src/lib/elementary/efl_ui_check.c
index e13577a407..a0f643870a 100644
--- a/src/lib/elementary/efl_ui_check.c
+++ b/src/lib/elementary/efl_ui_check.c
@@ -10,9 +10,7 @@
10 10
11#include <Elementary.h> 11#include <Elementary.h>
12#include "elm_priv.h" 12#include "elm_priv.h"
13#include "efl_ui_nstate.eo.h"
14#include "efl_ui_check_private.h" 13#include "efl_ui_check_private.h"
15#include "efl_ui_nstate_private.h"
16#include "elm_part_helper.h" 14#include "elm_part_helper.h"
17 15
18#define MY_CLASS EFL_UI_CHECK_CLASS 16#define MY_CLASS EFL_UI_CHECK_CLASS
@@ -28,6 +26,12 @@ static const Elm_Layout_Part_Alias_Description _text_aliases[] =
28 {NULL, NULL} 26 {NULL, NULL}
29}; 27};
30 28
29static const Elm_Layout_Part_Alias_Description _content_aliases[] =
30{
31 {"icon", "elm.swallow.content"},
32 {NULL, NULL}
33};
34
31static const char SIG_CHANGED[] = "changed"; 35static const char SIG_CHANGED[] = "changed";
32 36
33/* smart callbacks coming from elm check objects: */ 37/* smart callbacks coming from elm check objects: */
@@ -50,26 +54,21 @@ static const Elm_Action key_actions[] = {
50static void 54static void
51_activate(Evas_Object *obj) 55_activate(Evas_Object *obj)
52{ 56{
53 EFL_UI_CHECK_DATA_GET(obj, sd); 57 // state will be changed by the later call to the selected_set call
54 58 if (!efl_ui_check_selected_get(obj))
55 if (sd->statep) *sd->statep = !efl_ui_nstate_value_get(obj);
56
57 // state will be changed to 1 by efl_ui_nstate_activate(obj)
58 if (efl_ui_nstate_value_get(obj) == 0)
59 { 59 {
60 // FIXME: to do animation during state change , we need different signal 60 // FIXME: to do animation during state change , we need different signal
61 // so that we can distinguish between state change by user or state change 61 // so that we can distinguish between state change by user or state change
62 // by calling state_change() api. Keep both the signal for backward compatibility 62 // by calling state_change() api. Keep both the signal for backward compatibility
63 // and remove "elm,state,check,on" signal emission when we can break ABI. 63 // and remove "elm,state,check,on" signal emission when we can break ABI.
64 // efl_ui_check_selected_set below will emit "elm,state,check,*" or "efl,state,check,*"
64 if (elm_widget_is_legacy(obj)) 65 if (elm_widget_is_legacy(obj))
65 { 66 {
66 elm_layout_signal_emit(obj, "elm,activate,check,on", "elm"); 67 elm_layout_signal_emit(obj, "elm,activate,check,on", "elm");
67 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
68 } 68 }
69 else 69 else
70 { 70 {
71 elm_layout_signal_emit(obj, "efl,activate,check,on", "efl"); 71 elm_layout_signal_emit(obj, "efl,activate,check,on", "efl");
72 elm_layout_signal_emit(obj, "efl,state,check,on", "efl");
73 } 72 }
74 73
75 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF) 74 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
@@ -81,27 +80,28 @@ _activate(Evas_Object *obj)
81 // so that we can distinguish between state change by user or state change 80 // so that we can distinguish between state change by user or state change
82 // by calling state_change() api. Keep both the signal for backward compatibility 81 // by calling state_change() api. Keep both the signal for backward compatibility
83 // and remove "elm,state,check,off" signal emission when we can break ABI. 82 // and remove "elm,state,check,off" signal emission when we can break ABI.
83 // efl_ui_check_selected_set below will emit "elm,state,check,*" or "efl,state,check,*"
84 if (elm_widget_is_legacy(obj)) 84 if (elm_widget_is_legacy(obj))
85 { 85 {
86 elm_layout_signal_emit(obj, "elm,activate,check,off", "elm"); 86 elm_layout_signal_emit(obj, "elm,activate,check,off", "elm");
87 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
88 } 87 }
89 else 88 else
90 { 89 {
91 elm_layout_signal_emit(obj, "efl,activate,check,off", "efl"); 90 elm_layout_signal_emit(obj, "efl,activate,check,off", "efl");
92 elm_layout_signal_emit(obj, "efl,state,check,off", "efl");
93 } 91 }
94 92
95 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF) 93 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
96 _elm_access_say(E_("State: Off")); 94 _elm_access_say(E_("State: Off"));
97 } 95 }
98 96 //This commit will update the theme with the correct signals
99 efl_ui_nstate_activate(obj); 97 // "elm,state,check,on" or "elm,state,check,off" for legacy
98 // "efl,state,check,on" or "efl,state,check,off" for eo-api
99 efl_ui_check_selected_set(obj, !efl_ui_check_selected_get(obj));
100 100
101 if (_elm_config->atspi_mode) 101 if (_elm_config->atspi_mode)
102 efl_access_state_changed_signal_emit(obj, 102 efl_access_state_changed_signal_emit(obj,
103 EFL_ACCESS_STATE_TYPE_CHECKED, 103 EFL_ACCESS_STATE_TYPE_CHECKED,
104 efl_ui_nstate_value_get(obj)); 104 efl_ui_check_selected_get(obj));
105} 105}
106 106
107EOLIAN static Efl_Access_State_Set 107EOLIAN static Efl_Access_State_Set
@@ -147,14 +147,14 @@ _efl_ui_check_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Check_Data *sd EINA_UNUS
147 147
148 if (elm_widget_is_legacy(obj)) 148 if (elm_widget_is_legacy(obj))
149 { 149 {
150 if (efl_ui_nstate_value_get(obj) == 0) 150 if (!efl_ui_check_selected_get(obj))
151 elm_layout_signal_emit(obj, "elm,state,check,off", "elm"); 151 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
152 else 152 else
153 elm_layout_signal_emit(obj, "elm,state,check,on", "elm"); 153 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
154 } 154 }
155 else 155 else
156 { 156 {
157 if (efl_ui_nstate_value_get(obj) == 0) 157 if (!efl_ui_check_selected_get(obj))
158 elm_layout_signal_emit(obj, "efl,state,check,off", "efl"); 158 elm_layout_signal_emit(obj, "efl,state,check,off", "efl");
159 else 159 else
160 elm_layout_signal_emit(obj, "efl,state,check,on", "efl"); 160 elm_layout_signal_emit(obj, "efl,state,check,on", "efl");
@@ -185,7 +185,7 @@ _access_state_cb(void *data, Evas_Object *obj)
185 185
186 if (elm_widget_disabled_get(obj)) 186 if (elm_widget_disabled_get(obj))
187 return strdup(E_("State: Disabled")); 187 return strdup(E_("State: Disabled"));
188 if (efl_ui_nstate_value_get(obj)) 188 if (efl_ui_check_selected_get(obj))
189 { 189 {
190 on_text = elm_layout_text_get(data, "on"); 190 on_text = elm_layout_text_get(data, "on");
191 191
@@ -213,6 +213,17 @@ _access_state_cb(void *data, Evas_Object *obj)
213} 213}
214 214
215static void 215static void
216_flush_selected(Eo *obj, Eina_Bool sel)
217{
218 efl_ui_check_selected_set(obj, sel);
219
220 if (_elm_config->atspi_mode)
221 efl_access_state_changed_signal_emit(obj,
222 EFL_ACCESS_STATE_TYPE_CHECKED,
223 efl_ui_check_selected_get(obj));
224}
225
226static void
216_on_check_off(void *data, 227_on_check_off(void *data,
217 Evas_Object *o EINA_UNUSED, 228 Evas_Object *o EINA_UNUSED,
218 const char *emission EINA_UNUSED, 229 const char *emission EINA_UNUSED,
@@ -220,21 +231,7 @@ _on_check_off(void *data,
220{ 231{
221 Evas_Object *obj = data; 232 Evas_Object *obj = data;
222 233
223 EFL_UI_CHECK_DATA_GET(obj, sd); 234 _flush_selected(obj, EINA_FALSE);
224
225 if (sd->statep) *sd->statep = 0;
226
227 if (elm_widget_is_legacy(obj))
228 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
229 else
230 elm_layout_signal_emit(obj, "efl,state,check,off", "efl");
231
232 efl_ui_nstate_value_set(obj, 0);
233
234 if (_elm_config->atspi_mode)
235 efl_access_state_changed_signal_emit(data,
236 EFL_ACCESS_STATE_TYPE_CHECKED,
237 efl_ui_nstate_value_get(obj));
238} 235}
239 236
240static void 237static void
@@ -245,21 +242,7 @@ _on_check_on(void *data,
245{ 242{
246 Evas_Object *obj = data; 243 Evas_Object *obj = data;
247 244
248 EFL_UI_CHECK_DATA_GET(obj, sd); 245 _flush_selected(obj, EINA_TRUE);
249
250 if (sd->statep) *sd->statep = 1;
251
252 if (elm_widget_is_legacy(obj))
253 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
254 else
255 elm_layout_signal_emit(obj, "efl,state,check,on", "efl");
256
257 efl_ui_nstate_value_set(obj, 1);
258
259 if (_elm_config->atspi_mode)
260 efl_access_state_changed_signal_emit(data,
261 EFL_ACCESS_STATE_TYPE_CHECKED,
262 efl_ui_nstate_value_get(obj));
263} 246}
264 247
265static void 248static void
@@ -272,17 +255,23 @@ _on_check_toggle(void *data,
272} 255}
273 256
274EOLIAN static Eina_Bool 257EOLIAN static Eina_Bool
275_efl_ui_check_selected_get(const Eo *obj, Efl_Ui_Check_Data *pd EINA_UNUSED) 258_efl_ui_check_selected_get(const Eo *obj EINA_UNUSED, Efl_Ui_Check_Data *pd EINA_UNUSED)
276{ 259{
277 return !!efl_ui_nstate_value_get(obj); 260 return pd->selected;
278} 261}
279 262
280EOLIAN static void 263EOLIAN static void
281_efl_ui_check_selected_set(Eo *obj, Efl_Ui_Check_Data *sd, Eina_Bool value) 264_efl_ui_check_selected_set(Eo *obj, Efl_Ui_Check_Data *pd, Eina_Bool value)
282{ 265{
283 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 266 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
284 267
285 if (sd->statep) *sd->statep = value; 268 if (pd->selected == value) return;
269
270 if (elm_widget_is_legacy(obj))
271 {
272 if (pd->statep)
273 *pd->statep = value;
274 }
286 275
287 if (elm_widget_is_legacy(obj)) 276 if (elm_widget_is_legacy(obj))
288 { 277 {
@@ -301,16 +290,12 @@ _efl_ui_check_selected_set(Eo *obj, Efl_Ui_Check_Data *sd, Eina_Bool value)
301 290
302 edje_object_message_signal_process(wd->resize_obj); 291 edje_object_message_signal_process(wd->resize_obj);
303 292
304 efl_ui_nstate_value_set(obj, value); 293 pd->selected = value;
305}
306 294
307EOLIAN static void 295 if (elm_widget_is_legacy(obj))
308_efl_ui_check_efl_ui_nstate_value_set(Eo *obj, Efl_Ui_Check_Data *pd EINA_UNUSED, int state) 296 evas_object_smart_callback_call(obj, "changed", NULL);
309{ 297 else
310 Eina_Bool _state = !!state; 298 efl_event_callback_call(obj, EFL_UI_CHECK_EVENT_SELECTED_CHANGED, &pd->selected);
311 if (_state == efl_ui_nstate_value_get(obj)) return;
312
313 efl_ui_nstate_value_set(efl_super(obj, MY_CLASS), _state);
314} 299}
315 300
316EOLIAN static Eo * 301EOLIAN static Eo *
@@ -360,43 +345,21 @@ EAPI void
360elm_check_state_set(Evas_Object *obj, Eina_Bool state) 345elm_check_state_set(Evas_Object *obj, Eina_Bool state)
361{ 346{
362 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 347 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
363 EFL_UI_NSTATE_DATA_GET_OR_RETURN(obj, nd);
364 EFL_UI_CHECK_DATA_GET_OR_RETURN(obj, sd); 348 EFL_UI_CHECK_DATA_GET_OR_RETURN(obj, sd);
365 349
366 if (state != nd->state) 350 efl_ui_check_selected_set(obj, state);
367 {
368 nd->state = state;
369 if (sd->statep) *sd->statep = state;
370
371 if (elm_widget_is_legacy(obj))
372 {
373 if (state == 1)
374 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
375 else
376 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
377 }
378 else
379 {
380 if (state == 1)
381 elm_layout_signal_emit(obj, "efl,state,check,on", "efl");
382 else
383 elm_layout_signal_emit(obj, "efl,state,check,off", "efl");
384 }
385 edje_object_message_signal_process(wd->resize_obj);
386 }
387} 351}
388 352
389EAPI Eina_Bool 353EAPI Eina_Bool
390elm_check_state_get(const Evas_Object *obj) 354elm_check_state_get(const Evas_Object *obj)
391{ 355{
392 return !!efl_ui_nstate_value_get(obj); 356 return !!efl_ui_check_selected_get(obj);
393} 357}
394 358
395EAPI void 359EAPI void
396elm_check_state_pointer_set(Eo *obj, Eina_Bool *statep) 360elm_check_state_pointer_set(Eo *obj, Eina_Bool *statep)
397{ 361{
398 EFL_UI_CHECK_DATA_GET_OR_RETURN(obj, sd); 362 EFL_UI_CHECK_DATA_GET_OR_RETURN(obj, sd);
399 EFL_UI_NSTATE_DATA_GET_OR_RETURN(obj, nd);
400 363
401 if (!statep) 364 if (!statep)
402 { 365 {
@@ -405,24 +368,9 @@ elm_check_state_pointer_set(Eo *obj, Eina_Bool *statep)
405 } 368 }
406 369
407 sd->statep = statep; 370 sd->statep = statep;
408 if (*sd->statep != nd->state) 371 if (*sd->statep != sd->selected)
409 { 372 {
410 nd->state = *sd->statep; 373 efl_ui_check_selected_set(obj, *sd->statep);
411
412 if (elm_widget_is_legacy(obj))
413 {
414 if (nd->state == 1)
415 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
416 else
417 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
418 }
419 else
420 {
421 if (nd->state == 1)
422 elm_layout_signal_emit(obj, "efl,state,check,on", "efl");
423 else
424 elm_layout_signal_emit(obj, "efl,state,check,off", "efl");
425 }
426 } 374 }
427} 375}
428 376
@@ -439,14 +387,19 @@ _efl_ui_check_efl_access_widget_action_elm_actions_get(const Eo *obj EINA_UNUSED
439/* Standard widget overrides */ 387/* Standard widget overrides */
440 388
441ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_check, Efl_Ui_Check_Data) 389ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_check, Efl_Ui_Check_Data)
390ELM_PART_TEXT_DEFAULT_IMPLEMENT(efl_ui_check, Efl_Ui_Check_Data)
391ELM_PART_CONTENT_DEFAULT_IMPLEMENT(efl_ui_check, Efl_Ui_Check_Data)
392ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
442 393
443/* Internal EO APIs and hidden overrides */ 394/* Internal EO APIs and hidden overrides */
444 395
445ELM_LAYOUT_TEXT_ALIASES_IMPLEMENT(MY_CLASS_PFX) 396ELM_LAYOUT_TEXT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
446 397
447#define EFL_UI_CHECK_EXTRA_OPS \ 398#define EFL_UI_CHECK_EXTRA_OPS \
399 ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \
448 ELM_LAYOUT_TEXT_ALIASES_OPS(MY_CLASS_PFX) 400 ELM_LAYOUT_TEXT_ALIASES_OPS(MY_CLASS_PFX)
449 401
402
450#include "efl_ui_check.eo.c" 403#include "efl_ui_check.eo.c"
451#include "efl_ui_check_eo.legacy.c" 404#include "efl_ui_check_eo.legacy.c"
452 405
diff --git a/src/lib/elementary/efl_ui_check.eo b/src/lib/elementary/efl_ui_check.eo
index 5bd3d187e1..95d1635054 100644
--- a/src/lib/elementary/efl_ui_check.eo
+++ b/src/lib/elementary/efl_ui_check.eo
@@ -1,4 +1,4 @@
1class @beta Efl.Ui.Check extends Efl.Ui.Nstate implements Efl.Access.Widget.Action 1class @beta Efl.Ui.Check extends Efl.Ui.Layout_Base implements Efl.Access.Widget.Action, Efl.Text, Efl.Content
2{ 2{
3 [[Check widget 3 [[Check widget
4 4
@@ -24,8 +24,14 @@ class @beta Efl.Ui.Check extends Efl.Ui.Nstate implements Efl.Access.Widget.Acti
24 Efl.Ui.Widget.on_access_activate; 24 Efl.Ui.Widget.on_access_activate;
25 Efl.Ui.Widget.theme_apply; 25 Efl.Ui.Widget.theme_apply;
26 Efl.Ui.Widget.widget_input_event_handler; 26 Efl.Ui.Widget.widget_input_event_handler;
27 Efl.Ui.Nstate.value { set; }
28 Efl.Access.Object.state_set { get; } 27 Efl.Access.Object.state_set { get; }
29 Efl.Access.Widget.Action.elm_actions { get; } 28 Efl.Access.Widget.Action.elm_actions { get; }
29 Efl.Content.content { get; set; }
30 Efl.Content.content_unset;
31 Efl.Text.text { get; set; }
32 Efl.Ui.L10n.l10n_text { get; set; }
33 }
34 events {
35 selected,changed : bool; [[Emitted each time selected has changed]]
30 } 36 }
31} 37}
diff --git a/src/lib/elementary/efl_ui_check_private.h b/src/lib/elementary/efl_ui_check_private.h
index e44c6035e4..82031b28fe 100644
--- a/src/lib/elementary/efl_ui_check_private.h
+++ b/src/lib/elementary/efl_ui_check_private.h
@@ -27,6 +27,7 @@ typedef struct _Efl_Ui_Check_Data Efl_Ui_Check_Data;
27struct _Efl_Ui_Check_Data 27struct _Efl_Ui_Check_Data
28{ 28{
29 Eina_Bool *statep; 29 Eina_Bool *statep;
30 Eina_Bool selected;
30}; 31};
31 32
32/** 33/**
diff --git a/src/lib/elementary/efl_ui_radio.c b/src/lib/elementary/efl_ui_radio.c
index 565a80e13c..a25a9b6007 100644
--- a/src/lib/elementary/efl_ui_radio.c
+++ b/src/lib/elementary/efl_ui_radio.c
@@ -286,7 +286,7 @@ _efl_ui_radio_state_value_get(const Eo *obj EINA_UNUSED, Efl_Ui_Radio_Data *sd)
286} 286}
287 287
288EOLIAN static void 288EOLIAN static void
289_efl_ui_radio_efl_ui_nstate_value_set(Eo *obj EINA_UNUSED, Efl_Ui_Radio_Data *sd, int value) 289_efl_ui_radio_group_value_set(Eo *obj EINA_UNUSED, Efl_Ui_Radio_Data *sd, int value)
290{ 290{
291 if (value == sd->group->value) return; 291 if (value == sd->group->value) return;
292 sd->group->value = value; 292 sd->group->value = value;
@@ -295,7 +295,7 @@ _efl_ui_radio_efl_ui_nstate_value_set(Eo *obj EINA_UNUSED, Efl_Ui_Radio_Data *sd
295} 295}
296 296
297EOLIAN static int 297EOLIAN static int
298_efl_ui_radio_efl_ui_nstate_value_get(const Eo *obj EINA_UNUSED, Efl_Ui_Radio_Data *sd) 298_efl_ui_radio_group_value_get(const Eo *obj EINA_UNUSED, Efl_Ui_Radio_Data *sd)
299{ 299{
300 return sd->group->value; 300 return sd->group->value;
301} 301}
@@ -486,13 +486,13 @@ elm_radio_add(Evas_Object *parent)
486EAPI void 486EAPI void
487elm_radio_value_set(Evas_Object *obj, int value) 487elm_radio_value_set(Evas_Object *obj, int value)
488{ 488{
489 efl_ui_nstate_value_set(obj, value); 489 efl_ui_radio_group_value_set(obj, value);
490} 490}
491 491
492EAPI int 492EAPI int
493elm_radio_value_get(const Evas_Object *obj) 493elm_radio_value_get(const Evas_Object *obj)
494{ 494{
495 return efl_ui_nstate_value_get(obj); 495 return efl_ui_radio_group_value_get(obj);
496} 496}
497 497
498#include "efl_ui_radio_legacy_eo.c" 498#include "efl_ui_radio_legacy_eo.c"
diff --git a/src/lib/elementary/efl_ui_radio.eo b/src/lib/elementary/efl_ui_radio.eo
index 8dabfc7cfc..a833f39e09 100644
--- a/src/lib/elementary/efl_ui_radio.eo
+++ b/src/lib/elementary/efl_ui_radio.eo
@@ -1,4 +1,4 @@
1class @beta Efl.Ui.Radio extends Efl.Ui.Check implements Efl.Access.Widget.Action, Efl.Content 1class @beta Efl.Ui.Radio extends Efl.Ui.Check implements Efl.Access.Widget.Action
2{ 2{
3 [[Elementary radio class]] 3 [[Elementary radio class]]
4 methods { 4 methods {
@@ -56,6 +56,15 @@ class @beta Efl.Ui.Radio extends Efl.Ui.Check implements Efl.Access.Widget.Actio
56 to join.]] 56 to join.]]
57 } 57 }
58 } 58 }
59 @property group_value {
60 [[Change the value of the group.
61
62 This will enable the radio button in the group that is assosiated with this value. A value which is not assosiated with any radio button will result in every radio button beeing disabled.
63 ]]
64 values {
65 value : int; [[The value of the radio button in the group which should be enabled.]]
66 }
67 }
59 } 68 }
60 implements { 69 implements {
61 Efl.Object.constructor; 70 Efl.Object.constructor;
@@ -65,6 +74,5 @@ class @beta Efl.Ui.Radio extends Efl.Ui.Check implements Efl.Access.Widget.Actio
65 Efl.Ui.Widget.widget_input_event_handler; 74 Efl.Ui.Widget.widget_input_event_handler;
66 Efl.Access.Object.state_set { get; } 75 Efl.Access.Object.state_set { get; }
67 Efl.Access.Widget.Action.elm_actions { get; } 76 Efl.Access.Widget.Action.elm_actions { get; }
68 Efl.Ui.Nstate.value { set; get; }
69 } 77 }
70} 78}
diff --git a/src/tests/elementary/efl_ui_suite.c b/src/tests/elementary/efl_ui_suite.c
index 8a8fc123d1..6fab5d7003 100644
--- a/src/tests/elementary/efl_ui_suite.c
+++ b/src/tests/elementary/efl_ui_suite.c
@@ -26,6 +26,7 @@ static const Efl_Test_Case etc[] = {
26 { "Efl_Ui_Model", efl_ui_model }, 26 { "Efl_Ui_Model", efl_ui_model },
27 { "efl_ui_widget", efl_ui_test_widget }, 27 { "efl_ui_widget", efl_ui_test_widget },
28 { "efl_ui_active_view", efl_ui_test_active_view}, 28 { "efl_ui_active_view", efl_ui_test_active_view},
29 { "efl_ui_check", efl_ui_test_check },
29 { NULL, NULL } 30 { NULL, NULL }
30}; 31};
31 32
diff --git a/src/tests/elementary/efl_ui_suite.h b/src/tests/elementary/efl_ui_suite.h
index 004a2a3a52..472493818a 100644
--- a/src/tests/elementary/efl_ui_suite.h
+++ b/src/tests/elementary/efl_ui_suite.h
@@ -30,13 +30,12 @@ void efl_ui_test_image_zoomable(TCase *tc);
30void efl_ui_test_layout(TCase *tc); 30void efl_ui_test_layout(TCase *tc);
31void efl_ui_test_image(TCase *tc); 31void efl_ui_test_image(TCase *tc);
32void efl_ui_test_callback(TCase *tc); 32void efl_ui_test_callback(TCase *tc);
33
34void efl_ui_test_focus(TCase *tc); 33void efl_ui_test_focus(TCase *tc);
35void efl_ui_test_focus_sub(TCase *tc); 34void efl_ui_test_focus_sub(TCase *tc);
36
37void efl_ui_model(TCase *tc); 35void efl_ui_model(TCase *tc);
38void efl_ui_test_widget(TCase *tc); 36void efl_ui_test_widget(TCase *tc);
39void efl_ui_test_active_view(TCase *tc); 37void efl_ui_test_active_view(TCase *tc);
38void efl_ui_test_check(TCase *tc);
40 39
41void loop_timer_interval_set(Eo *obj, double in); 40void loop_timer_interval_set(Eo *obj, double in);
42 41
diff --git a/src/tests/elementary/efl_ui_test_check.c b/src/tests/elementary/efl_ui_test_check.c
new file mode 100644
index 0000000000..bd38aa1e8e
--- /dev/null
+++ b/src/tests/elementary/efl_ui_test_check.c
@@ -0,0 +1,80 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Efl_Ui.h>
6#include "efl_ui_suite.h"
7
8static Eo *win, *check;
9
10static void
11check_setup()
12{
13 win = win_add();
14
15 check = efl_add(EFL_UI_CHECK_CLASS, win);
16}
17
18EFL_START_TEST(check_content)
19{
20 Eo *t = efl_add(EFL_UI_BUTTON_CLASS, win,
21 efl_text_set(efl_added, "asdf")
22 );
23 efl_content_set(check, t);
24 ck_assert_ptr_eq(efl_content_get(check), t);
25 //TODO verify that signals can be emitted
26}
27EFL_END_TEST
28
29EFL_START_TEST(check_text)
30{
31 efl_text_set(check, "Test the Rest");
32 ck_assert_str_eq(efl_text_get(check), "Test the Rest");
33 //TODO verify that signals can be emitted
34}
35EFL_END_TEST
36
37EFL_START_TEST(check_selection_state)
38{
39 efl_ui_check_selected_set(check, EINA_TRUE);
40 ck_assert_int_eq(efl_ui_check_selected_get(check), EINA_TRUE);
41 efl_ui_check_selected_set(check, EINA_TRUE);
42 ck_assert_int_eq(efl_ui_check_selected_get(check), EINA_TRUE);
43 //TODO verify that signals can be emitted
44
45 efl_ui_check_selected_set(check, EINA_FALSE);
46 ck_assert_int_eq(efl_ui_check_selected_get(check), EINA_FALSE);
47 efl_ui_check_selected_set(check, EINA_FALSE);
48 ck_assert_int_eq(efl_ui_check_selected_get(check), EINA_FALSE);
49 //TODO verify that signals can be emitted
50}
51EFL_END_TEST
52
53static void
54_check(void *data, const Efl_Event *ev)
55{
56 Eina_Bool *flag = data;
57
58 *flag = *((Eina_Bool*)ev->info);
59}
60
61EFL_START_TEST(check_selection_events)
62{
63 Eina_Bool bool_event_info = EINA_FALSE;
64
65 efl_event_callback_add(check, EFL_UI_CHECK_EVENT_SELECTED_CHANGED, _check, &bool_event_info);
66 efl_ui_check_selected_set(check, EINA_TRUE);
67 ck_assert_int_eq(bool_event_info, EINA_TRUE);
68 efl_ui_check_selected_set(check, EINA_FALSE);
69 ck_assert_int_eq(bool_event_info, EINA_FALSE);
70}
71EFL_END_TEST
72
73void efl_ui_test_check(TCase *tc)
74{
75 tcase_add_checked_fixture(tc, check_setup, NULL);
76 tcase_add_test(tc, check_selection_state);
77 tcase_add_test(tc, check_text);
78 tcase_add_test(tc, check_content);
79 tcase_add_test(tc, check_selection_events);
80}
diff --git a/src/tests/elementary/meson.build b/src/tests/elementary/meson.build
index 31ce270f4b..735ba0a829 100644
--- a/src/tests/elementary/meson.build
+++ b/src/tests/elementary/meson.build
@@ -139,6 +139,7 @@ efl_ui_suite_src = [
139 'efl_ui_model.c', 139 'efl_ui_model.c',
140 'efl_ui_test_widget.c', 140 'efl_ui_test_widget.c',
141 'efl_ui_test_active_view.c', 141 'efl_ui_test_active_view.c',
142 'efl_ui_test_check.c',
142] 143]
143 144
144efl_ui_suite = executable('efl_ui_suite', 145efl_ui_suite = executable('efl_ui_suite',