summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2016-04-07 18:25:59 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-04-07 19:05:57 +0900
commit56ab4359981baffbbc93102b098eede1ad79e47a (patch)
tree839b5137fd77529695f6456d8cdb72b81a69afe2
parentd1709a2b57e655cab947b69487b48208dc0e50b9 (diff)
elm_nstate: introduce nstate widget and inherit check from it
Test Plan: elementary_test -to "nstate" @feature Reviewers: yashu21985, tasn, Hermet, seoz, smohanty, felipealmeida, JackDanielZ, jypark, woohyun, herdsman, raster, cedric, jpeg Subscribers: saurabhbunty, seoz Differential Revision: https://phab.enlightenment.org/D3786
-rw-r--r--config/default/base.src.in23
-rw-r--r--config/mobile/base.src.in23
-rw-r--r--config/standard/base.src.in23
-rw-r--r--data/elementary/themes/default.edc1
-rw-r--r--data/elementary/themes/edc/elm/nstate.edc10
-rw-r--r--doc/widgets/Makefile.am1
-rw-r--r--src/Makefile_Elementary.am5
-rw-r--r--src/bin/elementary/Makefile.am1
-rw-r--r--src/bin/elementary/test.c4
-rw-r--r--src/bin/elementary/test_nstate.c42
-rw-r--r--src/lib/elementary/Elementary.h.in1
-rw-r--r--src/lib/elementary/Makefile.am4
-rw-r--r--src/lib/elementary/elm_check.c185
-rw-r--r--src/lib/elementary/elm_check.eo41
-rw-r--r--src/lib/elementary/elm_check_legacy.h43
-rw-r--r--src/lib/elementary/elm_nstate.c179
-rw-r--r--src/lib/elementary/elm_nstate.eo47
-rw-r--r--src/lib/elementary/elm_nstate.h26
-rw-r--r--src/lib/elementary/elm_widget_check.h1
-rw-r--r--src/lib/elementary/elm_widget_nstate.h38
20 files changed, 559 insertions, 139 deletions
diff --git a/config/default/base.src.in b/config/default/base.src.in
index 891a7b75b7..e5933f8706 100644
--- a/config/default/base.src.in
+++ b/config/default/base.src.in
@@ -622,6 +622,29 @@ group "Elm_Config" struct {
622 } 622 }
623 } 623 }
624 group "Elm_Config_Bindings_Widget" struct { 624 group "Elm_Config_Bindings_Widget" struct {
625 value "name" string: "Elm_Nstate";
626 group "key_bindings" list {
627 group "Elm_Config_Binding_Key" struct {
628 value "context" int: 0;
629 value "key" string: "Return";
630 value "action" string: "activate";
631 value "params" string: "";
632 }
633 group "Elm_Config_Binding_Key" struct {
634 value "context" int: 0;
635 value "key" string: "KP_Enter";
636 value "action" string: "activate";
637 value "params" string: "";
638 }
639 group "Elm_Config_Binding_Key" struct {
640 value "context" int: 0;
641 value "key" string: "space";
642 value "action" string: "activate";
643 value "params" string: "";
644 }
645 }
646 }
647 group "Elm_Config_Bindings_Widget" struct {
625 value "name" string: "Elm_Calendar"; 648 value "name" string: "Elm_Calendar";
626 group "key_bindings" list { 649 group "key_bindings" list {
627 group "Elm_Config_Binding_Key" struct { 650 group "Elm_Config_Binding_Key" struct {
diff --git a/config/mobile/base.src.in b/config/mobile/base.src.in
index b950c805c2..7ba03bc875 100644
--- a/config/mobile/base.src.in
+++ b/config/mobile/base.src.in
@@ -626,6 +626,29 @@ group "Elm_Config" struct {
626 } 626 }
627 } 627 }
628 group "Elm_Config_Bindings_Widget" struct { 628 group "Elm_Config_Bindings_Widget" struct {
629 value "name" string: "Elm_Nstate";
630 group "key_bindings" list {
631 group "Elm_Config_Binding_Key" struct {
632 value "context" int: 0;
633 value "key" string: "Return";
634 value "action" string: "activate";
635 value "params" string: "";
636 }
637 group "Elm_Config_Binding_Key" struct {
638 value "context" int: 0;
639 value "key" string: "KP_Enter";
640 value "action" string: "activate";
641 value "params" string: "";
642 }
643 group "Elm_Config_Binding_Key" struct {
644 value "context" int: 0;
645 value "key" string: "space";
646 value "action" string: "activate";
647 value "params" string: "";
648 }
649 }
650 }
651 group "Elm_Config_Bindings_Widget" struct {
629 value "name" string: "Elm_Calendar"; 652 value "name" string: "Elm_Calendar";
630 group "key_bindings" list { 653 group "key_bindings" list {
631 group "Elm_Config_Binding_Key" struct { 654 group "Elm_Config_Binding_Key" struct {
diff --git a/config/standard/base.src.in b/config/standard/base.src.in
index 02344b0837..ba0d70067f 100644
--- a/config/standard/base.src.in
+++ b/config/standard/base.src.in
@@ -623,6 +623,29 @@ group "Elm_Config" struct {
623 } 623 }
624 } 624 }
625 group "Elm_Config_Bindings_Widget" struct { 625 group "Elm_Config_Bindings_Widget" struct {
626 value "name" string: "Elm_Nstate";
627 group "key_bindings" list {
628 group "Elm_Config_Binding_Key" struct {
629 value "context" int: 0;
630 value "key" string: "Return";
631 value "action" string: "activate";
632 value "params" string: "";
633 }
634 group "Elm_Config_Binding_Key" struct {
635 value "context" int: 0;
636 value "key" string: "KP_Enter";
637 value "action" string: "activate";
638 value "params" string: "";
639 }
640 group "Elm_Config_Binding_Key" struct {
641 value "context" int: 0;
642 value "key" string: "space";
643 value "action" string: "activate";
644 value "params" string: "";
645 }
646 }
647 }
648 group "Elm_Config_Bindings_Widget" struct {
626 value "name" string: "Elm_Calendar"; 649 value "name" string: "Elm_Calendar";
627 group "key_bindings" list { 650 group "key_bindings" list {
628 group "Elm_Config_Binding_Key" struct { 651 group "Elm_Config_Binding_Key" struct {
diff --git a/data/elementary/themes/default.edc b/data/elementary/themes/default.edc
index 2ba757d028..08853113d6 100644
--- a/data/elementary/themes/default.edc
+++ b/data/elementary/themes/default.edc
@@ -13,6 +13,7 @@ collections {
13// elm 13// elm
14#include "edc/elm/bg.edc" 14#include "edc/elm/bg.edc"
15#include "edc/elm/button.edc" 15#include "edc/elm/button.edc"
16#include "edc/elm/nstate.edc"
16// XXX: mobile mode needs invisible scrollers... make signals that do this 17// XXX: mobile mode needs invisible scrollers... make signals that do this
17#include "edc/elm/scroller.edc" 18#include "edc/elm/scroller.edc"
18// XXX: mobile mode needs different entry setup 19// XXX: mobile mode needs different entry setup
diff --git a/data/elementary/themes/edc/elm/nstate.edc b/data/elementary/themes/edc/elm/nstate.edc
new file mode 100644
index 0000000000..f05880699d
--- /dev/null
+++ b/data/elementary/themes/edc/elm/nstate.edc
@@ -0,0 +1,10 @@
1group { name: "elm/nstate/base/default";
2 inherit: "elm/button/base/default";
3 programs {
4 program {
5 signal: "mouse,clicked,1"; source: "event";
6 action: SIGNAL_EMIT "elm,action,state,changed" "elm";
7 }
8 }
9}
10
diff --git a/doc/widgets/Makefile.am b/doc/widgets/Makefile.am
index 5002c8a144..c056084a4f 100644
--- a/doc/widgets/Makefile.am
+++ b/doc/widgets/Makefile.am
@@ -176,6 +176,7 @@ EXTRA_DIST = \
176 widget_preview_progressbar.c \ 176 widget_preview_progressbar.c \
177 widget_preview_box.c \ 177 widget_preview_box.c \
178 widget_preview_notify.c \ 178 widget_preview_notify.c \
179 widget_preview_nstate.c \
179 widget_preview_slideshow.c \ 180 widget_preview_slideshow.c \
180 widget_preview_photocam.c \ 181 widget_preview_photocam.c \
181 widget_preview_inwin1.c \ 182 widget_preview_inwin1.c \
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 4d2f1420aa..3ec83f9b7f 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -67,6 +67,7 @@ elm_eolian_files = \
67 lib/elementary/elm_multibuttonentry.eo \ 67 lib/elementary/elm_multibuttonentry.eo \
68 lib/elementary/elm_naviframe.eo \ 68 lib/elementary/elm_naviframe.eo \
69 lib/elementary/elm_notify.eo \ 69 lib/elementary/elm_notify.eo \
70 lib/elementary/elm_nstate.eo \
70 lib/elementary/elm_pan.eo \ 71 lib/elementary/elm_pan.eo \
71 lib/elementary/elm_panel.eo \ 72 lib/elementary/elm_panel.eo \
72 lib/elementary/elm_panes.eo \ 73 lib/elementary/elm_panes.eo \
@@ -196,6 +197,7 @@ includesunstable_HEADERS = \
196 lib/elementary/elm_widget_multibuttonentry.h \ 197 lib/elementary/elm_widget_multibuttonentry.h \
197 lib/elementary/elm_widget_naviframe.h \ 198 lib/elementary/elm_widget_naviframe.h \
198 lib/elementary/elm_widget_notify.h \ 199 lib/elementary/elm_widget_notify.h \
200 lib/elementary/elm_widget_nstate.h \
199 lib/elementary/elm_widget_panel.h \ 201 lib/elementary/elm_widget_panel.h \
200 lib/elementary/elm_widget_panes.h \ 202 lib/elementary/elm_widget_panes.h \
201 lib/elementary/elm_widget_photo.h \ 203 lib/elementary/elm_widget_photo.h \
@@ -400,6 +402,7 @@ includesub_HEADERS = \
400 lib/elementary/elm_notify_common.h \ 402 lib/elementary/elm_notify_common.h \
401 lib/elementary/elm_notify_eo.h \ 403 lib/elementary/elm_notify_eo.h \
402 lib/elementary/elm_notify_legacy.h \ 404 lib/elementary/elm_notify_legacy.h \
405 lib/elementary/elm_nstate.h \
403 lib/elementary/elm_object.h \ 406 lib/elementary/elm_object.h \
404 lib/elementary/elm_object_item.h \ 407 lib/elementary/elm_object_item.h \
405 lib/elementary/elm_panel.h \ 408 lib/elementary/elm_panel.h \
@@ -572,6 +575,7 @@ lib_elementary_libelementary_la_SOURCES = \
572 lib/elementary/elm_menu.c \ 575 lib/elementary/elm_menu.c \
573 lib/elementary/elm_module.c \ 576 lib/elementary/elm_module.c \
574 lib/elementary/elm_notify.c \ 577 lib/elementary/elm_notify.c \
578 lib/elementary/elm_nstate.c \
575 lib/elementary/elm_panel.c \ 579 lib/elementary/elm_panel.c \
576 lib/elementary/elm_panes.c \ 580 lib/elementary/elm_panes.c \
577 lib/elementary/elm_photo.c \ 581 lib/elementary/elm_photo.c \
@@ -737,6 +741,7 @@ bin/elementary/test_multibuttonentry.c \
737bin/elementary/test_naviframe.c \ 741bin/elementary/test_naviframe.c \
738bin/elementary/test_naviframe_complex.c \ 742bin/elementary/test_naviframe_complex.c \
739bin/elementary/test_notify.c \ 743bin/elementary/test_notify.c \
744bin/elementary/test_nstate.c \
740bin/elementary/test_panel.c \ 745bin/elementary/test_panel.c \
741bin/elementary/test_panes.c \ 746bin/elementary/test_panes.c \
742bin/elementary/test_photo.c \ 747bin/elementary/test_photo.c \
diff --git a/src/bin/elementary/Makefile.am b/src/bin/elementary/Makefile.am
index 0b2b4e3c6d..5acd88fa98 100644
--- a/src/bin/elementary/Makefile.am
+++ b/src/bin/elementary/Makefile.am
@@ -99,6 +99,7 @@ test_multibuttonentry.c \
99test_naviframe.c \ 99test_naviframe.c \
100test_naviframe_complex.c \ 100test_naviframe_complex.c \
101test_notify.c \ 101test_notify.c \
102test_nstate.c \
102test_panel.c \ 103test_panel.c \
103test_panes.c \ 104test_panes.c \
104test_photo.c \ 105test_photo.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index f1ccbe30c1..334ce0a240 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -49,6 +49,7 @@ void test_combobox(void *data, Evas_Object *obj, void *event_info);
49void test_combobox2(void *data, Evas_Object *obj, void *event_info); 49void test_combobox2(void *data, Evas_Object *obj, void *event_info);
50void test_check(void *data, Evas_Object *obj, void *event_info); 50void test_check(void *data, Evas_Object *obj, void *event_info);
51void test_check_toggle(void *data, Evas_Object *obj, void *event_info); 51void test_check_toggle(void *data, Evas_Object *obj, void *event_info);
52void test_nstate(void *data, Evas_Object *obj, void *event_info);
52void test_radio(void *data, Evas_Object *obj, void *event_info); 53void test_radio(void *data, Evas_Object *obj, void *event_info);
53void test_layout(void *data, Evas_Object *obj, void *event_info); 54void test_layout(void *data, Evas_Object *obj, void *event_info);
54void test_layout2(void *data, Evas_Object *obj, void *event_info); 55void test_layout2(void *data, Evas_Object *obj, void *event_info);
@@ -782,6 +783,9 @@ add_tests:
782 ADD_TEST(NULL, "Booleans", "Check Toggle", test_check_toggle); 783 ADD_TEST(NULL, "Booleans", "Check Toggle", test_check_toggle);
783 784
784 //------------------------------// 785 //------------------------------//
786 ADD_TEST(NULL, "Range Values", "Nstate", test_nstate);
787
788 //------------------------------//
785 ADD_TEST(NULL, "Popups", "Ctxpopup", test_ctxpopup); 789 ADD_TEST(NULL, "Popups", "Ctxpopup", test_ctxpopup);
786 ADD_TEST(NULL, "Popups", "Hover", test_hover); 790 ADD_TEST(NULL, "Popups", "Hover", test_hover);
787 ADD_TEST(NULL, "Popups", "Hover 2", test_hover2); 791 ADD_TEST(NULL, "Popups", "Hover 2", test_hover2);
diff --git a/src/bin/elementary/test_nstate.c b/src/bin/elementary/test_nstate.c
new file mode 100644
index 0000000000..8c66ae5c22
--- /dev/null
+++ b/src/bin/elementary/test_nstate.c
@@ -0,0 +1,42 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5
6static void
7_state_changed_cb(void *d EINA_UNUSED, Evas_Object *o, void *ei EINA_UNUSED)
8{
9 char buf[100];
10 int val;
11
12 val = efl_ui_nstate_value_get(o);
13
14 printf("nstate widget state: %d\n", val);
15 sprintf(buf, "nstate = %d", val);
16 elm_object_text_set(o, buf);
17}
18
19void
20test_nstate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
21{
22 Evas_Object *win, *bx, *nstate;
23
24 win = elm_win_util_standard_add("nstate", "nstate");
25 elm_win_autodel_set(win, EINA_TRUE);
26
27 bx = elm_box_add(win);
28 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
29 elm_win_resize_object_add(win, bx);
30 evas_object_show(bx);
31
32 nstate = eo_add(ELM_NSTATE_CLASS, win);
33 efl_ui_nstate_count_set(nstate, 5);
34 elm_object_text_set(nstate, "nstate = 0");
35 elm_box_pack_end(bx, nstate);
36 evas_object_show(nstate);
37 evas_object_smart_callback_add(nstate, "state,changed",
38 _state_changed_cb, NULL);
39
40 evas_object_resize(win, 100, 100);
41 evas_object_show(win);
42}
diff --git a/src/lib/elementary/Elementary.h.in b/src/lib/elementary/Elementary.h.in
index 3e948c5a7f..1723c5844e 100644
--- a/src/lib/elementary/Elementary.h.in
+++ b/src/lib/elementary/Elementary.h.in
@@ -236,6 +236,7 @@ EAPI extern Elm_Version *elm_version;
236#include <elm_mirroring.h> 236#include <elm_mirroring.h>
237#include <elm_need.h> 237#include <elm_need.h>
238#include <elm_notify.h> 238#include <elm_notify.h>
239#include <elm_nstate.h>
239#include <elm_object.h> 240#include <elm_object.h>
240 241
241#include <elm_panel.h> 242#include <elm_panel.h>
diff --git a/src/lib/elementary/Makefile.am b/src/lib/elementary/Makefile.am
index 7ea2597f6c..ca081b1375 100644
--- a/src/lib/elementary/Makefile.am
+++ b/src/lib/elementary/Makefile.am
@@ -87,6 +87,7 @@ elm_widget_menu.h \
87elm_widget_multibuttonentry.h \ 87elm_widget_multibuttonentry.h \
88elm_widget_naviframe.h \ 88elm_widget_naviframe.h \
89elm_widget_notify.h \ 89elm_widget_notify.h \
90elm_widget_nstate.h \
90elm_widget_panel.h \ 91elm_widget_panel.h \
91elm_widget_panes.h \ 92elm_widget_panes.h \
92elm_widget_photo.h \ 93elm_widget_photo.h \
@@ -289,6 +290,7 @@ elm_notify.h \
289elm_notify_common.h \ 290elm_notify_common.h \
290elm_notify_eo.h \ 291elm_notify_eo.h \
291elm_notify_legacy.h \ 292elm_notify_legacy.h \
293elm_nstate.h \
292elm_object.h \ 294elm_object.h \
293elm_object_item.h \ 295elm_object_item.h \
294elm_panel.h \ 296elm_panel.h \
@@ -462,6 +464,7 @@ elm_mapbuf.c \
462elm_menu.c \ 464elm_menu.c \
463elm_module.c \ 465elm_module.c \
464elm_notify.c \ 466elm_notify.c \
467elm_nstate.c \
465elm_panel.c \ 468elm_panel.c \
466elm_panes.c \ 469elm_panes.c \
467elm_photo.c \ 470elm_photo.c \
@@ -583,6 +586,7 @@ elm_menu.eo \
583elm_multibuttonentry.eo \ 586elm_multibuttonentry.eo \
584elm_naviframe.eo \ 587elm_naviframe.eo \
585elm_notify.eo \ 588elm_notify.eo \
589elm_nstate.eo \
586elm_pan.eo \ 590elm_pan.eo \
587elm_panel.eo \ 591elm_panel.eo \
588elm_panes.eo \ 592elm_panes.eo \
diff --git a/src/lib/elementary/elm_check.c b/src/lib/elementary/elm_check.c
index 024e3dacb7..6a12c70448 100644
--- a/src/lib/elementary/elm_check.c
+++ b/src/lib/elementary/elm_check.c
@@ -5,22 +5,17 @@
5#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED 5#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
6#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED 6#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
7 7
8#define ELM_NSTATE_PROTECTED
8#include <Elementary.h> 9#include <Elementary.h>
9#include "elm_priv.h" 10#include "elm_priv.h"
10#include "elm_widget_check.h" 11#include "elm_widget_check.h"
11#include "elm_widget_layout.h" 12#include "elm_widget_nstate.h"
12 13
13#define MY_CLASS ELM_CHECK_CLASS 14#define MY_CLASS ELM_CHECK_CLASS
14 15
15#define MY_CLASS_NAME "Elm_Check" 16#define MY_CLASS_NAME "Elm_Check"
16#define MY_CLASS_NAME_LEGACY "elm_check" 17#define MY_CLASS_NAME_LEGACY "elm_check"
17 18
18static const Elm_Layout_Part_Alias_Description _content_aliases[] =
19{
20 {"icon", "elm.swallow.content"},
21 {NULL, NULL}
22};
23
24static const Elm_Layout_Part_Alias_Description _text_aliases[] = 19static const Elm_Layout_Part_Alias_Description _text_aliases[] =
25{ 20{
26 {"default", "elm.text"}, 21 {"default", "elm.text"},
@@ -53,9 +48,10 @@ _activate(Evas_Object *obj)
53{ 48{
54 ELM_CHECK_DATA_GET(obj, sd); 49 ELM_CHECK_DATA_GET(obj, sd);
55 50
56 sd->state = !sd->state; 51 efl_ui_nstate_activate(obj);
57 if (sd->statep) *sd->statep = sd->state; 52 if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
58 if (sd->state) 53
54 if (efl_ui_nstate_value_get(obj) == 1)
59 { 55 {
60 // FIXME: to do animation during state change , we need different signal 56 // 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 57 // so that we can distinguish between state change by user or state change
@@ -66,7 +62,7 @@ _activate(Evas_Object *obj)
66 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF) 62 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
67 _elm_access_say(E_("State: On")); 63 _elm_access_say(E_("State: On"));
68 } 64 }
69 else 65 else if (efl_ui_nstate_value_get(obj) == 0)
70 { 66 {
71 // FIXME: to do animation during state change , we need different signal 67 // FIXME: to do animation during state change , we need different signal
72 // so that we can distinguish between state change by user or state change 68 // so that we can distinguish between state change by user or state change
@@ -83,7 +79,7 @@ _activate(Evas_Object *obj)
83 if (_elm_config->atspi_mode) 79 if (_elm_config->atspi_mode)
84 elm_interface_atspi_accessible_state_changed_signal_emit(obj, 80 elm_interface_atspi_accessible_state_changed_signal_emit(obj,
85 ELM_ATSPI_STATE_CHECKED, 81 ELM_ATSPI_STATE_CHECKED,
86 sd->state); 82 efl_ui_nstate_value_get(obj));
87} 83}
88 84
89/* FIXME: replicated from elm_layout just because check's icon spot 85/* FIXME: replicated from elm_layout just because check's icon spot
@@ -144,37 +140,6 @@ _elm_check_elm_widget_activate(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNU
144 return EINA_TRUE; 140 return EINA_TRUE;
145} 141}
146 142
147/* FIXME: replicated from elm_layout just because check's icon spot
148 * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
149 * can changed the theme API */
150EOLIAN static Eina_Bool
151_elm_check_elm_container_content_set(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED, const char *part, Evas_Object *content)
152{
153 Eina_Bool int_ret = EINA_FALSE;
154
155 int_ret = elm_obj_container_content_set(eo_super(obj, MY_CLASS), part, content);
156 if (!int_ret) return EINA_FALSE;
157
158 _icon_signal_emit(obj);
159
160 elm_obj_layout_sizing_eval(obj);
161
162 return EINA_TRUE;
163}
164
165EOLIAN static void
166_elm_check_elm_layout_sizing_eval(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED)
167{
168 Evas_Coord minw = -1, minh = -1;
169 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
170
171 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
172 edje_object_size_min_restricted_calc
173 (wd->resize_obj, &minw, &minh, minw, minh);
174 evas_object_size_hint_min_set(obj, minw, minh);
175 evas_object_size_hint_max_set(obj, -1, -1);
176}
177
178static Eina_Bool 143static Eina_Bool
179_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED) 144_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
180{ 145{
@@ -199,17 +164,20 @@ _elm_check_elm_widget_event(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED, Evas_Objec
199} 164}
200 165
201EOLIAN static Eina_Bool 166EOLIAN static Eina_Bool
202_elm_check_elm_widget_theme_apply(Eo *obj, Elm_Check_Data *sd) 167_elm_check_elm_widget_theme_apply(Eo *obj, Elm_Check_Data *sd EINA_UNUSED)
203{ 168{
204 Eina_Bool int_ret = EINA_FALSE; 169 Eina_Bool int_ret = EINA_FALSE;
205 170
206 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); 171 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
207 172
208 int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS)); 173 int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS));
174
209 if (!int_ret) return EINA_FALSE; 175 if (!int_ret) return EINA_FALSE;
210 176
211 if (!sd->state) elm_layout_signal_emit(obj, "elm,state,check,off", "elm"); 177 if (efl_ui_nstate_value_get(obj) == 0)
212 else elm_layout_signal_emit(obj, "elm,state,check,on", "elm"); 178 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
179 else if (efl_ui_nstate_value_get(obj) == 1)
180 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
213 181
214 edje_object_message_signal_process(wd->resize_obj); 182 edje_object_message_signal_process(wd->resize_obj);
215 183
@@ -237,12 +205,11 @@ _access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
237static char * 205static char *
238_access_state_cb(void *data, Evas_Object *obj) 206_access_state_cb(void *data, Evas_Object *obj)
239{ 207{
240 Elm_Check_Data *sd = eo_data_scope_get(data, MY_CLASS);
241 const char *on_text, *off_text; 208 const char *on_text, *off_text;
242 209
243 if (elm_widget_disabled_get(obj)) 210 if (elm_widget_disabled_get(obj))
244 return strdup(E_("State: Disabled")); 211 return strdup(E_("State: Disabled"));
245 if (sd->state) 212 if (efl_ui_nstate_value_get(obj))
246 { 213 {
247 on_text = elm_layout_text_get(data, "on"); 214 on_text = elm_layout_text_get(data, "on");
248 215
@@ -279,8 +246,8 @@ _on_check_off(void *data,
279 246
280 ELM_CHECK_DATA_GET(obj, sd); 247 ELM_CHECK_DATA_GET(obj, sd);
281 248
282 sd->state = EINA_FALSE; 249 efl_ui_nstate_value_set(obj, 0);
283 if (sd->statep) *sd->statep = sd->state; 250 if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
284 251
285 elm_layout_signal_emit(obj, "elm,state,check,off", "elm"); 252 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
286 eo_event_callback_call(obj, ELM_CHECK_EVENT_CHANGED, NULL); 253 eo_event_callback_call(obj, ELM_CHECK_EVENT_CHANGED, NULL);
@@ -288,7 +255,7 @@ _on_check_off(void *data,
288 if (_elm_config->atspi_mode) 255 if (_elm_config->atspi_mode)
289 elm_interface_atspi_accessible_state_changed_signal_emit(data, 256 elm_interface_atspi_accessible_state_changed_signal_emit(data,
290 ELM_ATSPI_STATE_CHECKED, 257 ELM_ATSPI_STATE_CHECKED,
291 sd->state); 258 efl_ui_nstate_value_get(obj));
292} 259}
293 260
294static void 261static void
@@ -301,15 +268,15 @@ _on_check_on(void *data,
301 268
302 ELM_CHECK_DATA_GET(obj, sd); 269 ELM_CHECK_DATA_GET(obj, sd);
303 270
304 sd->state = EINA_TRUE; 271 efl_ui_nstate_value_set(obj, 1);
305 if (sd->statep) *sd->statep = sd->state; 272 if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
306 elm_layout_signal_emit(obj, "elm,state,check,on", "elm"); 273 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
307 eo_event_callback_call(obj, ELM_CHECK_EVENT_CHANGED, NULL); 274 eo_event_callback_call(obj, ELM_CHECK_EVENT_CHANGED, NULL);
308 275
309 if (_elm_config->atspi_mode) 276 if (_elm_config->atspi_mode)
310 elm_interface_atspi_accessible_state_changed_signal_emit(data, 277 elm_interface_atspi_accessible_state_changed_signal_emit(data,
311 ELM_ATSPI_STATE_CHECKED, 278 ELM_ATSPI_STATE_CHECKED,
312 sd->state); 279 efl_ui_nstate_value_get(obj));
313} 280}
314 281
315static void 282static void
@@ -329,6 +296,9 @@ _elm_check_evas_object_smart_add(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED)
329 evas_obj_smart_add(eo_super(obj, MY_CLASS)); 296 evas_obj_smart_add(eo_super(obj, MY_CLASS));
330 elm_widget_sub_object_parent_add(obj); 297 elm_widget_sub_object_parent_add(obj);
331 298
299 if (!elm_layout_theme_set(obj, "check", "base", elm_widget_style_get(obj)))
300 CRI("Failed to set layout!");
301
332 edje_object_signal_callback_add 302 edje_object_signal_callback_add
333 (wd->resize_obj, "elm,action,check,on", "*", 303 (wd->resize_obj, "elm,action,check,on", "*",
334 _on_check_on, obj); 304 _on_check_on, obj);
@@ -348,23 +318,40 @@ _elm_check_evas_object_smart_add(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED)
348 (_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, obj); 318 (_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, obj);
349 319
350 elm_widget_can_focus_set(obj, EINA_TRUE); 320 elm_widget_can_focus_set(obj, EINA_TRUE);
351
352 if (!elm_layout_theme_set(obj, "check", "base", elm_widget_style_get(obj)))
353 CRI("Failed to set layout!");
354
355 elm_layout_sizing_eval(obj); 321 elm_layout_sizing_eval(obj);
356} 322}
357 323
358EOLIAN static const Elm_Layout_Part_Alias_Description* 324EOLIAN static const Elm_Layout_Part_Alias_Description*
359_elm_check_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED) 325_elm_check_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED)
326{
327 return _text_aliases;
328}
329
330EOLIAN static Eina_Bool
331_elm_check_selected_get(Eo *obj, Elm_Check_Data *pd EINA_UNUSED)
360{ 332{
361 return _content_aliases; 333 return !!efl_ui_nstate_value_get(obj);
362} 334}
363 335
364EOLIAN static const Elm_Layout_Part_Alias_Description* 336EOLIAN static void
365_elm_check_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED) 337_elm_check_selected_set(Eo *obj, Elm_Check_Data *pd EINA_UNUSED, Eina_Bool value)
366{ 338{
367 return _text_aliases; 339 efl_ui_nstate_value_set(obj, value);
340}
341
342EOLIAN static void
343_elm_check_elm_nstate_count_set(Eo *obj EINA_UNUSED, Elm_Check_Data *pd EINA_UNUSED, int nstate EINA_UNUSED)
344{
345 //NOP;
346}
347
348EOLIAN static void
349_elm_check_elm_nstate_value_set(Eo *obj, Elm_Check_Data *pd EINA_UNUSED, int state)
350{
351 Eina_Bool _state = !!state;
352 if (_state == efl_ui_nstate_value_get(obj)) return;
353
354 efl_ui_nstate_value_set(eo_super(obj, MY_CLASS), _state);
368} 355}
369 356
370EAPI Evas_Object * 357EAPI Evas_Object *
@@ -386,59 +373,49 @@ _elm_check_eo_base_constructor(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED)
386 return obj; 373 return obj;
387} 374}
388 375
389EOLIAN static void 376EAPI void
390_elm_check_state_set(Eo *obj, Elm_Check_Data *sd, Eina_Bool state) 377elm_check_state_set(Evas_Object *obj, Eina_Bool state)
391{ 378{
379 ELM_CHECK_DATA_GET_OR_RETURN(obj, sd);
392 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 380 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
393 381
394 if (state != sd->state) 382 if (state == efl_ui_nstate_value_get(obj)) return;
395 { 383
396 sd->state = state; 384 efl_ui_nstate_value_set(obj, state);
397 if (sd->statep) *sd->statep = sd->state; 385 if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
398 if (sd->state) 386 if (efl_ui_nstate_value_get(obj) == 1)
399 elm_layout_signal_emit(obj, "elm,state,check,on", "elm"); 387 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
400 else 388 else if (efl_ui_nstate_value_get(obj) == 0)
401 elm_layout_signal_emit(obj, "elm,state,check,off", "elm"); 389 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
402 }
403 390
404 edje_object_message_signal_process(wd->resize_obj); 391 edje_object_message_signal_process(wd->resize_obj);
405} 392}
406 393
407EOLIAN static Eina_Bool 394EAPI Eina_Bool
408_elm_check_state_get(Eo *obj EINA_UNUSED, Elm_Check_Data *sd) 395elm_check_state_get(const Evas_Object *obj)
409{ 396{
410 return sd->state; 397 return !!efl_ui_nstate_value_get(obj);
411} 398}
412 399
413EOLIAN static void 400EAPI void
414_elm_check_state_pointer_set(Eo *obj, Elm_Check_Data *sd, Eina_Bool *statep) 401elm_check_state_pointer_set(Eo *obj, Eina_Bool *statep)
415{ 402{
416 if (statep) 403 ELM_CHECK_DATA_GET_OR_RETURN(obj, sd);
404 if (!statep)
417 { 405 {
418 sd->statep = statep; 406 sd->statep = NULL;
419 if (*sd->statep != sd->state) 407 return;
420 {
421 sd->state = *sd->statep;
422 if (sd->state)
423 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
424 else
425 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
426 }
427 } 408 }
428 else
429 sd->statep = NULL;
430}
431 409
432EOLIAN static Eina_Bool 410 sd->statep = statep;
433_elm_check_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED) 411 if (*sd->statep != efl_ui_nstate_value_get(obj))
434{ 412 {
435 return EINA_FALSE; 413 efl_ui_nstate_value_set(obj, *sd->statep);
436} 414 if (efl_ui_nstate_value_get(obj) == 1)
437 415 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
438EOLIAN static Eina_Bool 416 else if (efl_ui_nstate_value_get(obj) == 0)
439_elm_check_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED) 417 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
440{ 418 }
441 return EINA_FALSE;
442} 419}
443 420
444EOLIAN const Elm_Atspi_Action * 421EOLIAN const Elm_Atspi_Action *
diff --git a/src/lib/elementary/elm_check.eo b/src/lib/elementary/elm_check.eo
index 47a32ec9dd..3833d6b67e 100644
--- a/src/lib/elementary/elm_check.eo
+++ b/src/lib/elementary/elm_check.eo
@@ -1,38 +1,16 @@
1class Elm.Check (Elm.Layout, Elm.Interface_Atspi_Widget_Action) 1class Elm.Check (Elm.Nstate, Elm.Interface_Atspi_Widget_Action)
2{ 2{
3 eo_prefix: elm_obj_check; 3 eo_prefix: efl_ui_check;
4 methods { 4 methods {
5 @property state { 5 @property selected {
6 set { 6 set {
7 [[Set the on/off state of the check object 7 [[Set the on/off state of the check object.]]
8
9 This sets the state of the check. If set with
10 @.state_pointer.set, the state of that variable is also
11 changed. Calling this doesn't cause the "changed" signal to
12 be emitted.
13 ]]
14 } 8 }
15 get { 9 get {
16 [[Get the state of the check object]] 10 [[Get the state of the check object.]]
17 }
18 values {
19 state: bool; [[The state to use (1 == on, 0 == off)]]
20 }
21 }
22 @property state_pointer {
23 set {
24 [[Set a convenience pointer to a boolean to change
25
26 This sets a pointer to a boolean, that, in addition to the check
27 objects state will also be modified directly. To stop setting the
28 object pointed to simply use null as the "statep" parameter.
29 If "statep" is not null, then when this is called, the check
30 objects state will also be modified to reflect the value of the
31 boolean "statep" points to, just like calling @.state.set.
32 ]]
33 } 11 }
34 values { 12 values {
35 statep: bool * @nullable; [[Pointer to the boolean to modify]] 13 value: Eina_Bool;
36 } 14 }
37 } 15 }
38 } 16 }
@@ -41,15 +19,12 @@ class Elm.Check (Elm.Layout, Elm.Interface_Atspi_Widget_Action)
41 Eo.Base.constructor; 19 Eo.Base.constructor;
42 Evas.Object_Smart.add; 20 Evas.Object_Smart.add;
43 Elm.Widget.activate; 21 Elm.Widget.activate;
44 Elm.Widget.focus_next_manager_is;
45 Elm.Widget.focus_direction_manager_is;
46 Elm.Widget.theme_apply; 22 Elm.Widget.theme_apply;
47 Elm.Widget.sub_object_del; 23 Elm.Widget.sub_object_del;
48 Elm.Widget.event; 24 Elm.Widget.event;
49 Elm.Container.content.set;
50 Elm.Layout.text_aliases.get; 25 Elm.Layout.text_aliases.get;
51 Elm.Layout.content_aliases.get; 26 Elm.Nstate.count.set;
52 Elm.Layout.sizing_eval; 27 Elm.Nstate.value.set;
53 Elm.Interface_Atspi_Accessible.state_set.get; 28 Elm.Interface_Atspi_Accessible.state_set.get;
54 Elm.Interface_Atspi_Widget_Action.elm_actions.get; 29 Elm.Interface_Atspi_Widget_Action.elm_actions.get;
55 } 30 }
diff --git a/src/lib/elementary/elm_check_legacy.h b/src/lib/elementary/elm_check_legacy.h
index a6653c3e91..b1fc8dabce 100644
--- a/src/lib/elementary/elm_check_legacy.h
+++ b/src/lib/elementary/elm_check_legacy.h
@@ -8,4 +8,45 @@
8 */ 8 */
9EAPI Evas_Object * elm_check_add(Evas_Object *parent); 9EAPI Evas_Object * elm_check_add(Evas_Object *parent);
10 10
11#include "elm_check.eo.legacy.h" \ No newline at end of file 11/**
12 * @brief Get the state of the check object
13 *
14 * @param obj The check object
15 *
16 * @ingroup Check
17 */
18EAPI Eina_Bool elm_check_state_get(const Evas_Object *obj);
19
20/**
21 * @brief Set the on/off state of the check object
22 *
23 * This sets the state of the check. If set with
24 * @.state_pointer.set, the state of that variable is also
25 * changed. Calling this doesn't cause the "changed" signal to
26 * be emitted.
27 *
28 * @param obj The check object
29 * @param state The state to use (1 == on, 0 == off)
30 *
31 * @ingroup Check
32 */
33EAPI void elm_check_state_set(Evas_Object *obj, Eina_Bool state);
34
35/**
36 * @brief Set a convenience pointer to a boolean to change
37 *
38 * This sets a pointer to a boolean, that, in addition to the check
39 * objects state will also be modified directly. To stop setting the
40 * object pointed to simply use null as the "statep" parameter.
41 * If "statep" is not null, then when this is called, the check
42 * objects state will also be modified to reflect the value of the
43 * boolean "statep" points to, just like calling @.state.set.
44 *
45 * @param obj The check object
46 * @param statep pointer to the boolean to modify
47 *
48 * @ingroup Check
49 */
50EAPI void elm_check_state_pointer_set(Evas_Object *obj, Eina_Bool *statep);
51
52#include "elm_check.eo.legacy.h"
diff --git a/src/lib/elementary/elm_nstate.c b/src/lib/elementary/elm_nstate.c
new file mode 100644
index 0000000000..dac44d328e
--- /dev/null
+++ b/src/lib/elementary/elm_nstate.c
@@ -0,0 +1,179 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define ELM_NSTATE_PROTECTED
6#include "Elementary.h"
7#include "elm_priv.h"
8#include "elm_widget_nstate.h"
9#include "elm_widget_button.h"
10
11#define MY_CLASS ELM_NSTATE_CLASS
12
13#define MY_CLASS_NAME "Elm_Nstate"
14#define MY_CLASS_NAME_LEGACY "elm_nstate"
15
16static const Evas_Smart_Cb_Description _smart_callbacks[] = {
17 {NULL, NULL}
18};
19
20static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
21static void _state_active(Evas_Object *obj, Elm_Nstate_Data *sd);
22
23static const Elm_Action key_actions[] = {
24 {"activate", _key_action_activate},
25 {NULL, NULL}
26};
27
28EOLIAN static Eo_Base *
29_elm_nstate_eo_base_constructor(Eo *obj, Elm_Nstate_Data *pd EINA_UNUSED)
30{
31 obj = eo_constructor(eo_super(obj, MY_CLASS));
32 evas_obj_type_set(obj, MY_CLASS_NAME_LEGACY);
33 evas_obj_smart_callbacks_descriptions_set(obj, _smart_callbacks);
34 //TODO: Add ATSPI call here
35
36 return obj;
37}
38
39static void
40_next_state_set(Elm_Nstate_Data *sd)
41{
42 ++sd->state;
43 if (sd->state == sd->nstate) sd->state = 0;
44}
45
46static void
47_state_active(Evas_Object *obj, Elm_Nstate_Data *sd)
48{
49 char buf[64];
50
51 sprintf(buf, "elm,state,changed,%d", sd->state);
52 elm_layout_signal_emit(obj, buf, "elm");
53 edje_object_message_signal_process(elm_layout_edje_get(obj));
54 elm_obj_layout_sizing_eval(obj);
55 eo_event_callback_call(obj, ELM_NSTATE_EVENT_STATE_CHANGED, NULL);
56}
57
58static void
59_on_state_changed(void *data,
60 Evas_Object *o EINA_UNUSED,
61 const char *emission EINA_UNUSED,
62 const char *source EINA_UNUSED)
63{
64 efl_ui_nstate_activate(data);
65}
66
67EOLIAN static void
68_elm_nstate_evas_object_smart_add(Eo *obj, Elm_Nstate_Data *pd)
69{
70 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
71
72 evas_obj_smart_add(eo_super(obj, MY_CLASS));
73 elm_widget_sub_object_parent_add(obj);
74
75 pd->state = 0;
76 // Default: 2 states
77 pd->nstate = 2;
78
79 if (!elm_layout_theme_set(obj, "nstate", "base", elm_widget_style_get(obj)))
80 CRI("Failed to set layout!");
81
82 edje_object_signal_callback_add(wd->resize_obj, "elm,action,state,changed",
83 "*", _on_state_changed, obj);
84}
85
86EOLIAN static void
87_elm_nstate_evas_object_smart_del(Eo *obj, Elm_Nstate_Data *pd EINA_UNUSED)
88{
89 evas_obj_smart_del(eo_super(obj, MY_CLASS));
90}
91
92EOLIAN static int
93_elm_nstate_count_get(Eo *obj EINA_UNUSED, Elm_Nstate_Data *pd)
94{
95 return pd->nstate;
96}
97
98EOLIAN static void
99_elm_nstate_count_set(Eo *obj EINA_UNUSED, Elm_Nstate_Data *pd, int nstate)
100{
101 if (pd->nstate == nstate) return;
102
103 pd->nstate = nstate;
104 pd->state = 0;
105}
106
107EOLIAN static int
108_elm_nstate_value_get(Eo *obj EINA_UNUSED, Elm_Nstate_Data *pd)
109{
110 return pd->state;
111}
112
113static Eina_Bool
114_is_valid_state(Elm_Nstate_Data *sd, int state)
115{
116 if (sd->state == state || (state < 0 || state >= sd->nstate))
117 return EINA_FALSE;
118
119 return EINA_TRUE;
120}
121
122EOLIAN static void
123_elm_nstate_value_set(Eo *obj, Elm_Nstate_Data *pd, int state)
124{
125 if (!_is_valid_state(pd, state)) return;
126
127 pd->state = state;
128 _state_active(obj, pd);
129}
130
131EOLIAN static Eina_Bool
132_elm_nstate_elm_widget_theme_apply(Eo *obj, Elm_Nstate_Data *pd)
133{
134 Eina_Bool int_ret;
135
136 int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS));
137 if (!int_ret) return EINA_FALSE;
138
139 _state_active(obj, pd);
140
141 return EINA_TRUE;
142}
143
144static Eina_Bool
145_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
146{
147 efl_ui_nstate_activate(obj);
148 return EINA_TRUE;
149}
150
151EOLIAN static Eina_Bool
152_elm_nstate_elm_widget_event(Eo *obj, Elm_Nstate_Data *_pd EINA_UNUSED, Evas_Object *src EINA_UNUSED, Evas_Callback_Type type, void *event_info)
153{
154 Evas_Event_Key_Down *ev = event_info;
155
156 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
157 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
158
159 if (!_elm_config_key_binding_call(obj, MY_CLASS_NAME, ev, key_actions))
160 return EINA_FALSE;
161
162 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
163 return EINA_TRUE;
164}
165
166EOLIAN static void
167_elm_nstate_activate(Eo *obj, Elm_Nstate_Data *_pd)
168{
169 _next_state_set(_pd);
170 _state_active(obj, _pd);
171}
172
173EOLIAN static void
174_elm_nstate_class_constructor(Eo_Class *klass)
175{
176 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
177}
178
179#include "elm_nstate.eo.c"
diff --git a/src/lib/elementary/elm_nstate.eo b/src/lib/elementary/elm_nstate.eo
new file mode 100644
index 0000000000..6ff0f89a1f
--- /dev/null
+++ b/src/lib/elementary/elm_nstate.eo
@@ -0,0 +1,47 @@
1class Elm.Nstate(Elm.Button)
2{
3 eo_prefix: efl_ui_nstate;
4 legacy_prefix: null;
5 data: Elm_Nstate_Data;
6 methods {
7 activate @protected {
8 }
9 @property count {
10 set {
11 [[Set the maximum number of states.
12 ]]
13 }
14 get {
15 [[Get the max number of states.
16 ]]
17 }
18 values {
19 nstate: int; [[The number of states.]]
20 }
21 }
22 @property value {
23 set {
24 [[Set the particular state given in (0...nstate}.
25 ]]
26 }
27 get {
28 [[Get the state value.
29 ]]
30 }
31 values {
32 state: int; [[The state.]]
33 }
34 }
35 }
36 implements {
37 class.constructor;
38 Eo.Base.constructor;
39 Evas.Object_Smart.add;
40 Evas.Object_Smart.del;
41 Elm.Widget.theme_apply;
42 Elm.Widget.event;
43 }
44 events {
45 state,changed;
46 }
47}
diff --git a/src/lib/elementary/elm_nstate.h b/src/lib/elementary/elm_nstate.h
new file mode 100644
index 0000000000..66d7aed1dc
--- /dev/null
+++ b/src/lib/elementary/elm_nstate.h
@@ -0,0 +1,26 @@
1/**
2 * @defgroup Elm_Nstate Nstate
3 * @ingroup Elementary
4 *
5 * @image html nstate_inheritance_tree.png
6 * @image latex nstate_inheritance_tree.eps
7 *
8 * @image html img/widget/nstate/preview-00.png
9 * @image latex img/widget/nstate/preview-00.eps
10 *
11 * A Nstate is a widget which displays one of the state among states defined by user.
12 *
13 * This widget inherits from the @ref Button, so that all the functions acting on @ref Button also work for nstate objects.
14 *
15 * This widget emits the following signals, besides the ones sent from
16 * @ref Button:
17 * - @c "state,changed" - whenever state of nstate is changed
18 *
19 * Default content parts of the nstate widget that you can use are the
20 * the same that you use with the @ref Button
21 * @{
22 */
23
24#ifdef EFL_EO_API_SUPPORT
25#include "elm_nstate.eo.h"
26#endif
diff --git a/src/lib/elementary/elm_widget_check.h b/src/lib/elementary/elm_widget_check.h
index bcf3eac1fc..d5cf27e85e 100644
--- a/src/lib/elementary/elm_widget_check.h
+++ b/src/lib/elementary/elm_widget_check.h
@@ -26,7 +26,6 @@
26typedef struct _Elm_Check_Data Elm_Check_Data; 26typedef struct _Elm_Check_Data Elm_Check_Data;
27struct _Elm_Check_Data 27struct _Elm_Check_Data
28{ 28{
29 Eina_Bool state;
30 Eina_Bool *statep; 29 Eina_Bool *statep;
31}; 30};
32 31
diff --git a/src/lib/elementary/elm_widget_nstate.h b/src/lib/elementary/elm_widget_nstate.h
new file mode 100644
index 0000000000..6733d97f4c
--- /dev/null
+++ b/src/lib/elementary/elm_widget_nstate.h
@@ -0,0 +1,38 @@
1#ifndef ELM_WIDGET_NSTATE_H
2#define ELM_WIDGET_NSTATE_H
3
4#include "elm_nstate.eo.h"
5
6typedef struct
7{
8 int nstate;
9 int state;
10} Elm_Nstate_Data;
11
12
13#define ELM_NSTATE_DATA_GET(o, sd) \
14 Elm_Nstate_Data * sd = eo_data_scope_get(o, ELM_NSTATE_CLASS)
15
16#define ELM_NSTATE_DATA_GET_OR_RETURN(o, ptr) \
17 ELM_NSTATE_DATA_GET(o, ptr); \
18 if (EINA_UNLIKELY(!ptr)) \
19 { \
20 CRI("No widget data for object %p (%s)", \
21 o, evas_object_type_get(o)); \
22 return; \
23 }
24
25#define ELM_NSTATE_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
26 ELM_NSTATE_DATA_GET(o, ptr); \
27 if (EINA_UNLIKELY(!ptr)) \
28 { \
29 CRI("No widget data for object %p (%s)", \
30 o, evas_object_type_get(o)); \
31 return val; \
32 }
33
34#define ELM_NSTATE_CHECK(obj) \
35 if (EINA_UNLIKELY(!eo_isa((obj), ELM_NSTATE_CLASS))) \
36 return
37
38#endif