summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2016-03-16 08:45:27 +0530
committerAmitesh Singh <amitesh.sh@samsung.com>2016-03-16 14:09:42 +0530
commitc3c65009e1d6036bf9365d69858cd6809e50614d (patch)
tree87985b87ac82fe4cd81e1fffd777306aa9362c30
parent3848e321f328728f76ee1132ca2df2ca703f82d3 (diff)
introduce nstate widget and inherit check & radio from itdevs/ami/nstate
Test Plan: 1. elementary_test -to "check" 2. tristate check. Reviewers: yashu21985, raster, cedric, tasn, Hermet, seoz, smohanty, felipealmeida, JackDanielZ, jpeg, jypark, herdsman, woohyun 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/themes/Makefile.am1
-rw-r--r--data/themes/default.edc1
-rw-r--r--data/themes/edc/elm/check.edc341
-rw-r--r--data/themes/edc/elm/nstate.edc10
-rw-r--r--data/themes/img/sym_check_intmed_alum.pngbin0 -> 203 bytes
-rw-r--r--src/bin/Makefile.am1
-rw-r--r--src/bin/test.c4
-rw-r--r--src/bin/test_check.c14
-rw-r--r--src/bin/test_nstate.c42
-rw-r--r--src/lib/Elementary.h.in1
-rw-r--r--src/lib/Makefile.am6
-rw-r--r--src/lib/elm_check.c159
-rw-r--r--src/lib/elm_check.eo40
-rw-r--r--src/lib/elm_check_legacy.h43
-rw-r--r--src/lib/elm_nstate.c188
-rw-r--r--src/lib/elm_nstate.eo47
-rw-r--r--src/lib/elm_nstate.h7
-rw-r--r--src/lib/elm_nstate_eo.h1
-rw-r--r--src/lib/elm_nstate_legacy.h11
-rw-r--r--src/lib/elm_widget_check.h1
-rw-r--r--src/lib/elm_widget_nstate.h36
24 files changed, 875 insertions, 148 deletions
diff --git a/config/default/base.src.in b/config/default/base.src.in
index 891a7b75b..e5933f870 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 b950c805c..7ba03bc87 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 02344b083..ba0d70067 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/themes/Makefile.am b/data/themes/Makefile.am
index 319125631..73f56adfc 100644
--- a/data/themes/Makefile.am
+++ b/data/themes/Makefile.am
@@ -613,6 +613,7 @@ img/split_v_glow.png \
613img/split_v_hilight.png \ 613img/split_v_hilight.png \
614img/split_v_inset.png \ 614img/split_v_inset.png \
615img/sym_check_alum.png \ 615img/sym_check_alum.png \
616img/sym_check_intmed_alum.png \
616img/sym_close_dark_normal.png \ 617img/sym_close_dark_normal.png \
617img/sym_close_dark_selected.png \ 618img/sym_close_dark_selected.png \
618img/sym_close_light_normal.png \ 619img/sym_close_light_normal.png \
diff --git a/data/themes/default.edc b/data/themes/default.edc
index 2ba757d02..08853113d 100644
--- a/data/themes/default.edc
+++ b/data/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/themes/edc/elm/check.edc b/data/themes/edc/elm/check.edc
index 10ecd0e10..a9fd4b860 100644
--- a/data/themes/edc/elm/check.edc
+++ b/data/themes/edc/elm/check.edc
@@ -331,7 +331,7 @@ group { name: "elm/check/base/toggle";
331 images.image: "vgrad_med_lighter.png" COMP; 331 images.image: "vgrad_med_lighter.png" COMP;
332 images.image: "shadow_square_tiny.png" COMP; 332 images.image: "shadow_square_tiny.png" COMP;
333 images.image: "glow_small.png" COMP; 333 images.image: "glow_small.png" COMP;
334 334
335#define ICON 1 335#define ICON 1
336#define LABEL 2 336#define LABEL 2
337#define MASK 3 337#define MASK 3
@@ -340,8 +340,8 @@ group { name: "elm/check/base/toggle";
340 public is_rtl; 340 public is_rtl;
341 public is_drag; 341 public is_drag;
342 public was_drag; 342 public was_drag;
343
344 public btmode; 343 public btmode;
344
345 public eval_mode(m) { 345 public eval_mode(m) {
346 new m1 = m & MASK; 346 new m1 = m & MASK;
347 new d = m & DISABLE; 347 new d = m & DISABLE;
@@ -935,3 +935,340 @@ group { name: "elm/check/base/toggle";
935#undef MASK 935#undef MASK
936#undef DISABLE 936#undef DISABLE
937} 937}
938
939group { name: "elm/check/base/tristate";
940 images.image: "inset_shadow_tiny.png" COMP;
941 images.image: "bevel_in.png" COMP;
942 images.image: "sym_check_alum.png" COMP;
943 images.image: "sym_check_intmed_alum.png" COMP;
944#define ICON 1
945#define LABEL 2
946#define MASK 3
947#define DISABLE 4
948 script {
949 public btmode;
950 public eval_mode(m) {
951 new m1 = m & MASK;
952 new d = m & DISABLE;
953 if (m1 == (ICON | LABEL)) {
954 if (!d) {
955 set_state(PART:"elm.swallow.content", "visible", 0.0);
956 set_state(PART:"sizer.content", "visible", 0.0);
957 set_state(PART:"elm.text", "visible", 0.0);
958 set_state(PART:"shadow", "default", 0.0);
959 set_state(PART:"base", "default", 0.0);
960 set_state(PART:"clip", "default", 0.0);
961 set_state(PART:"event", "default", 0.0);
962 } else {
963 set_state(PART:"elm.swallow.content", "visible", 0.0);
964 set_state(PART:"sizer.content", "visible", 0.0);
965 set_state(PART:"elm.text", "disabled_visible", 0.0);
966 set_state(PART:"shadow", "disabled", 0.0);
967 set_state(PART:"base", "disabled", 0.0);
968 set_state(PART:"clip", "disabled", 0.0);
969 set_state(PART:"event", "disabled", 0.0);
970 }
971 } else if (m1 == (ICON)) {
972 if (!d) {
973 set_state(PART:"elm.swallow.content", "visible", 0.0);
974 set_state(PART:"sizer.content", "icononly", 0.0);
975 set_state(PART:"elm.text", "default", 0.0);
976 set_state(PART:"shadow", "default", 0.0);
977 set_state(PART:"base", "default", 0.0);
978 set_state(PART:"clip", "default", 0.0);
979 set_state(PART:"event", "default", 0.0);
980 } else {
981 set_state(PART:"elm.swallow.content", "visible", 0.0);
982 set_state(PART:"sizer.content", "icononly", 0.0);
983 set_state(PART:"elm.text", "disabled", 0.0);
984 set_state(PART:"shadow", "disabled", 0.0);
985 set_state(PART:"base", "disabled", 0.0);
986 set_state(PART:"clip", "disabled", 0.0);
987 set_state(PART:"event", "disabled", 0.0);
988 }
989 } else if (m1 == (LABEL)) {
990 if (!d) {
991 set_state(PART:"elm.swallow.content", "default", 0.0);
992 set_state(PART:"sizer.content", "default", 0.0);
993 set_state(PART:"elm.text", "visible", 0.0);
994 set_state(PART:"shadow", "default", 0.0);
995 set_state(PART:"base", "default", 0.0);
996 set_state(PART:"clip", "default", 0.0);
997 set_state(PART:"event", "default", 0.0);
998 } else {
999 set_state(PART:"elm.swallow.content", "default", 0.0);
1000 set_state(PART:"sizer.content", "default", 0.0);
1001 set_state(PART:"elm.text", "disabled_visible", 0.0);
1002 set_state(PART:"shadow", "disabled", 0.0);
1003 set_state(PART:"base", "disabled", 0.0);
1004 set_state(PART:"clip", "disabled", 0.0);
1005 set_state(PART:"event", "disabled", 0.0);
1006 }
1007 } else {
1008 if (!d) {
1009 set_state(PART:"elm.swallow.content", "default", 0.0);
1010 set_state(PART:"sizer.content", "default", 0.0);
1011 set_state(PART:"elm.text", "default", 0.0);
1012 set_state(PART:"shadow", "default", 0.0);
1013 set_state(PART:"base", "default", 0.0);
1014 set_state(PART:"clip", "default", 0.0);
1015 set_state(PART:"event", "default", 0.0);
1016 } else {
1017 set_state(PART:"elm.swallow.content", "default", 0.0);
1018 set_state(PART:"sizer.content", "default", 0.0);
1019 set_state(PART:"elm.text", "default", 0.0);
1020 set_state(PART:"shadow", "disabled", 0.0);
1021 set_state(PART:"base", "disabled", 0.0);
1022 set_state(PART:"clip", "disabled", 0.0);
1023 set_state(PART:"event", "disabled", 0.0);
1024 }
1025 }
1026 }
1027 }
1028 parts {
1029 part { name: "base"; type: RECT;
1030 description { state: "default" 0.0;
1031 rel1.offset: 1 1;
1032 rel1.to: "inset";
1033 rel2.offset: -2 -2;
1034 rel2.to: "inset";
1035 color: 24 24 24 255;
1036 }
1037 description { state: "disabled" 0.0;
1038 inherit: "default" 0.0;
1039 color: 64 64 64 255;
1040 }
1041 }
1042 part { name: "shadow"; mouse_events: 0;
1043 description { state: "default" 0.0;
1044 image.normal: "inset_shadow_tiny.png";
1045 image.border: 4 4 4 4;
1046 rel1.to: "base";
1047 rel2.to: "base";
1048 }
1049 description { state: "disabled" 0.0;
1050 inherit: "default" 0.0;
1051 visible: 0;
1052 }
1053 }
1054 part { name: "inset"; mouse_events: 0;
1055 scale: 1;
1056 description { state: "default" 0.0;
1057 fixed: 1 0;
1058 rel1.offset: 2 2;
1059 rel2.relative: 0.0 1.0;
1060 rel2.offset: 2 -3;
1061 align: 0.0 0.5;
1062 min: 13 13;
1063 max: 13 13;
1064 image.normal: "bevel_in.png";
1065 image.border: 1 1 1 1;
1066 image.middle: 0;
1067 fill.smooth: 0;
1068 }
1069 }
1070 part { name: "indicator"; mouse_events: 0;
1071 scale: 1;
1072 clip_to: "clip";
1073 description { state: "default" 0.0;
1074 fixed: 1 1;
1075 rel1.to: "base";
1076 rel2.to: "base";
1077 image.normal: "sym_check_alum.png";
1078 min: 11 11;
1079 max: 11 11;
1080 visible: 0;
1081 }
1082 description { state: "mid_selected" 0.0;
1083 inherit: "default" 0.0;
1084 image.normal: "sym_check_intmed_alum.png";
1085 visible: 1;
1086 }
1087 description { state: "selected" 0.0;
1088 inherit: "default" 0.0;
1089 visible: 1;
1090 }
1091 }
1092 part { name: "clip"; type: RECT;
1093 description { state: "default" 0.0;
1094 }
1095 description { state: "disabled" 0.0;
1096 inherit: "default" 0.0;
1097 color: 255 255 255 64;
1098 }
1099 }
1100 part { name: "elm.swallow.content"; type: SWALLOW;
1101 scale: 1;
1102 clip_to: "clip";
1103 description { state: "default" 0.0;
1104 fixed: 1 0;
1105 visible: 0;
1106 align: 0.0 0.5;
1107 max: 0 0;
1108 rel1.to_x: "inset";
1109 rel1.relative: 1.0 0.0;
1110 rel1.offset: 1 1;
1111 rel2.to_x: "inset";
1112 rel2.offset: 1 -2;
1113 rel2.relative: 1.0 1.0;
1114 }
1115 description { state: "visible" 0.0;
1116 inherit: "default" 0.0;
1117 fixed: 0 0;
1118 visible: 1;
1119 aspect: 1.0 1.0;
1120 min: 16 16;
1121 }
1122 }
1123 part { name: "sizer.content"; type: TEXT; mouse_events: 0;
1124 scale: 1;
1125 description { state: "default" 0.0;
1126 fixed: 1 1;
1127 visible: 0;
1128 text { font: FN; size: 10;
1129 min: 0 0;
1130 text_class: "check_text";
1131 }
1132 }
1133 description { state: "visible" 0.0;
1134 inherit: "default" 0.0;
1135 rel1.to: "elm.swallow.content";
1136 rel2.to: "elm.swallow.content";
1137 text {
1138 min: 1 1;
1139 ellipsis: -1;
1140 text: "M";
1141 }
1142 }
1143 description { state: "icononly" 0.0;
1144 inherit: "default" 0.0;
1145 rel1.to: "elm.swallow.content";
1146 rel2.to: "elm.swallow.content";
1147 text {
1148 min: 1 1;
1149 ellipsis: -1;
1150 text: "M";
1151 }
1152 }
1153 }
1154 part { name: "elm.text"; type: TEXT; mouse_events: 0;
1155 effect: SHADOW BOTTOM;
1156 scale: 1;
1157 description { state: "default" 0.0;
1158 rel1.offset: 2 2;
1159 rel1.to_x: "elm.swallow.content";
1160 rel1.relative: 1.0 0.0;
1161 rel2.offset: -3 -3;
1162 color: FN_COL_DEFAULT;
1163 color_class: "check_text";
1164 text { font: FN; size: 10;
1165 min: 0 0;
1166 align: 0.0 0.5;
1167 text_class: "check";
1168 }
1169 }
1170 description { state: "disabled" 0.0;
1171 inherit: "default" 0.0;
1172 color_class: "check_text_disabled";
1173 color3: 255 255 255 255;
1174 }
1175 description { state: "visible" 0.0;
1176 inherit: "default" 0.0;
1177 visible: 1;
1178 text.min: 1 1;
1179 text.ellipsis: -1;
1180 }
1181 description { state: "disabled_visible" 0.0;
1182 inherit: "default" 0.0;
1183 color_class: "check_text_disabled";
1184 color3: 255 255 255 255;
1185 visible: 1;
1186 text.min: 1 1;
1187 text.ellipsis: -1;
1188 }
1189 }
1190 part { name: "event"; type: RECT;
1191 ignore_flags: ON_HOLD;
1192 description { state: "default" 0.0;
1193 color: 0 0 0 0;
1194 }
1195 description { state: "disabled" 0.0;
1196 inherit: "default" 0.0;
1197 visible: 0;
1198 }
1199 }
1200 }
1201 programs {
1202 program {
1203 signal: "mouse,clicked,1"; source: "event";
1204 action: SIGNAL_EMIT "elm,action,state,changed" "elm";
1205 }
1206 program {
1207 signal: "elm,state,changed,0"; source: "elm";
1208 action: STATE_SET "default" 0.0;
1209 target: "indicator";
1210 }
1211 program {
1212 signal: "elm,state,changed,1"; source: "elm";
1213 action: STATE_SET "mid_selected" 0.0;
1214 target: "indicator";
1215 }
1216 program {
1217 signal: "elm,state,changed,2"; source: "elm";
1218 action: STATE_SET "selected" 0.0;
1219 target: "indicator";
1220 }
1221 program {
1222 signal: "elm,state,text,visible"; source: "elm";
1223 script {
1224 new m = get_int(btmode);
1225 m |= LABEL; set_int(btmode, m);
1226 eval_mode(m);
1227 }
1228 }
1229 program {
1230 signal: "elm,state,text,hidden"; source: "elm";
1231 script {
1232 new m = get_int(btmode);
1233 m &= ~LABEL; set_int(btmode, m);
1234 eval_mode(m);
1235 }
1236 }
1237 program {
1238 signal: "elm,state,icon,visible"; source: "elm";
1239 script {
1240 new m = get_int(btmode);
1241 m |= ICON; set_int(btmode, m);
1242 eval_mode(m);
1243 }
1244 }
1245 program {
1246 signal: "elm,state,icon,hidden"; source: "elm";
1247 script {
1248 new m = get_int(btmode);
1249 m &= ~ICON; set_int(btmode, m);
1250 eval_mode(m);
1251 }
1252 }
1253 program {
1254 signal: "elm,state,disabled"; source: "elm";
1255 script {
1256 new m = get_int(btmode);
1257 m |= DISABLE; set_int(btmode, m);
1258 eval_mode(m);
1259 }
1260 }
1261 program {
1262 signal: "elm,state,enabled"; source: "elm";
1263 script {
1264 new m = get_int(btmode);
1265 m &= ~DISABLE; set_int(btmode, m);
1266 eval_mode(m);
1267 }
1268 }
1269 }
1270#undef ICON
1271#undef LABEL
1272#undef MASK
1273#undef DISABLE
1274}
diff --git a/data/themes/edc/elm/nstate.edc b/data/themes/edc/elm/nstate.edc
new file mode 100644
index 000000000..f05880699
--- /dev/null
+++ b/data/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/data/themes/img/sym_check_intmed_alum.png b/data/themes/img/sym_check_intmed_alum.png
new file mode 100644
index 000000000..3b2c0eac9
--- /dev/null
+++ b/data/themes/img/sym_check_intmed_alum.png
Binary files differ
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 46db673e5..4a0382f47 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/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/test.c b/src/bin/test.c
index 3bad1c6d2..3e4676b87 100644
--- a/src/bin/test.c
+++ b/src/bin/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, "Range Values", "Progressbar 2", test_progressbar2); 783 ADD_TEST(NULL, "Range Values", "Progressbar 2", test_progressbar2);
783 784
784 //------------------------------// 785 //------------------------------//
786 ADD_TEST(NULL, "Range Values", "Nstate", test_nstate);
787
788 //------------------------------//
785 ADD_TEST(NULL, "Booleans", "Check", test_check); 789 ADD_TEST(NULL, "Booleans", "Check", test_check);
786 ADD_TEST(NULL, "Booleans", "Check Toggle", test_check_toggle); 790 ADD_TEST(NULL, "Booleans", "Check Toggle", test_check_toggle);
787 791
diff --git a/src/bin/test_check.c b/src/bin/test_check.c
index 1ee3935cc..90a6eaa0d 100644
--- a/src/bin/test_check.c
+++ b/src/bin/test_check.c
@@ -15,6 +15,12 @@ changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
15} 15}
16 16
17static void 17static void
18_tristate_changed_cb(void *d EINA_UNUSED, Evas_Object *o, void *ei EINA_UNUSED)
19{
20 printf("tristate check state: %d\n", efl_ui_nstate_value_get(o));
21}
22
23static void
18state_changed_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 24state_changed_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
19{ 25{
20 printf("State Pointer Value: %d\n", eb); 26 printf("State Pointer Value: %d\n", eb);
@@ -106,6 +112,14 @@ test_check(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_inf
106 evas_object_show(ck); 112 evas_object_show(ck);
107 evas_object_show(ic); 113 evas_object_show(ic);
108 114
115 ck = elm_check_add(win);
116 efl_ui_nstate_count_set(ck, 3);
117 elm_object_style_set(ck, "tristate");
118 elm_object_text_set(ck, "tristate");
119 elm_box_pack_end(bx, ck);
120 evas_object_show(ck);
121 evas_object_smart_callback_add(ck, "state,changed", _tristate_changed_cb, NULL);
122
109 evas_object_show(win); 123 evas_object_show(win);
110} 124}
111 125
diff --git a/src/bin/test_nstate.c b/src/bin/test_nstate.c
new file mode 100644
index 000000000..6f1e27ed5
--- /dev/null
+++ b/src/bin/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 = elm_nstate_add(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.h.in b/src/lib/Elementary.h.in
index b8fe89a2f..54dac8fdd 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/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/Makefile.am b/src/lib/Makefile.am
index 7ea2597f6..03e6d9049 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/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,9 @@ 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 \
294elm_nstate_eo.h \
295elm_nstate_legacy.h \
292elm_object.h \ 296elm_object.h \
293elm_object_item.h \ 297elm_object_item.h \
294elm_panel.h \ 298elm_panel.h \
@@ -462,6 +466,7 @@ elm_mapbuf.c \
462elm_menu.c \ 466elm_menu.c \
463elm_module.c \ 467elm_module.c \
464elm_notify.c \ 468elm_notify.c \
469elm_nstate.c \
465elm_panel.c \ 470elm_panel.c \
466elm_panes.c \ 471elm_panes.c \
467elm_photo.c \ 472elm_photo.c \
@@ -583,6 +588,7 @@ elm_menu.eo \
583elm_multibuttonentry.eo \ 588elm_multibuttonentry.eo \
584elm_naviframe.eo \ 589elm_naviframe.eo \
585elm_notify.eo \ 590elm_notify.eo \
591elm_nstate.eo \
586elm_pan.eo \ 592elm_pan.eo \
587elm_panel.eo \ 593elm_panel.eo \
588elm_panes.eo \ 594elm_panes.eo \
diff --git a/src/lib/elm_check.c b/src/lib/elm_check.c
index 024e3dacb..ea82c6963 100644
--- a/src/lib/elm_check.c
+++ b/src/lib/elm_check.c
@@ -8,19 +8,13 @@
8#include <Elementary.h> 8#include <Elementary.h>
9#include "elm_priv.h" 9#include "elm_priv.h"
10#include "elm_widget_check.h" 10#include "elm_widget_check.h"
11#include "elm_widget_layout.h" 11#include "elm_widget_nstate.h"
12 12
13#define MY_CLASS ELM_CHECK_CLASS 13#define MY_CLASS ELM_CHECK_CLASS
14 14
15#define MY_CLASS_NAME "Elm_Check" 15#define MY_CLASS_NAME "Elm_Check"
16#define MY_CLASS_NAME_LEGACY "elm_check" 16#define MY_CLASS_NAME_LEGACY "elm_check"
17 17
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[] = 18static const Elm_Layout_Part_Alias_Description _text_aliases[] =
25{ 19{
26 {"default", "elm.text"}, 20 {"default", "elm.text"},
@@ -53,9 +47,10 @@ _activate(Evas_Object *obj)
53{ 47{
54 ELM_CHECK_DATA_GET(obj, sd); 48 ELM_CHECK_DATA_GET(obj, sd);
55 49
56 sd->state = !sd->state; 50 efl_ui_nstate_activate(obj);
57 if (sd->statep) *sd->statep = sd->state; 51 if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
58 if (sd->state) 52
53 if (efl_ui_nstate_value_get(obj) == 1)
59 { 54 {
60 // FIXME: to do animation during state change , we need different signal 55 // 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 56 // so that we can distinguish between state change by user or state change
@@ -66,7 +61,7 @@ _activate(Evas_Object *obj)
66 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF) 61 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
67 _elm_access_say(E_("State: On")); 62 _elm_access_say(E_("State: On"));
68 } 63 }
69 else 64 else if (efl_ui_nstate_value_get(obj) == 0)
70 { 65 {
71 // FIXME: to do animation during state change , we need different signal 66 // 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 67 // so that we can distinguish between state change by user or state change
@@ -83,7 +78,7 @@ _activate(Evas_Object *obj)
83 if (_elm_config->atspi_mode) 78 if (_elm_config->atspi_mode)
84 elm_interface_atspi_accessible_state_changed_signal_emit(obj, 79 elm_interface_atspi_accessible_state_changed_signal_emit(obj,
85 ELM_ATSPI_STATE_CHECKED, 80 ELM_ATSPI_STATE_CHECKED,
86 sd->state); 81 efl_ui_nstate_value_get(obj));
87} 82}
88 83
89/* FIXME: replicated from elm_layout just because check's icon spot 84/* FIXME: replicated from elm_layout just because check's icon spot
@@ -144,37 +139,6 @@ _elm_check_elm_widget_activate(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNU
144 return EINA_TRUE; 139 return EINA_TRUE;
145} 140}
146 141
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 142static Eina_Bool
179_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED) 143_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
180{ 144{
@@ -199,17 +163,20 @@ _elm_check_elm_widget_event(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED, Evas_Objec
199} 163}
200 164
201EOLIAN static Eina_Bool 165EOLIAN static Eina_Bool
202_elm_check_elm_widget_theme_apply(Eo *obj, Elm_Check_Data *sd) 166_elm_check_elm_widget_theme_apply(Eo *obj, Elm_Check_Data *sd EINA_UNUSED)
203{ 167{
204 Eina_Bool int_ret = EINA_FALSE; 168 Eina_Bool int_ret = EINA_FALSE;
205 169
206 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); 170 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
207 171
208 int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS)); 172 int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS));
173
209 if (!int_ret) return EINA_FALSE; 174 if (!int_ret) return EINA_FALSE;
210 175
211 if (!sd->state) elm_layout_signal_emit(obj, "elm,state,check,off", "elm"); 176 if (efl_ui_nstate_value_get(obj) == 0)
212 else elm_layout_signal_emit(obj, "elm,state,check,on", "elm"); 177 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
178 else if (efl_ui_nstate_value_get(obj) == 1)
179 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
213 180
214 edje_object_message_signal_process(wd->resize_obj); 181 edje_object_message_signal_process(wd->resize_obj);
215 182
@@ -237,12 +204,11 @@ _access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
237static char * 204static char *
238_access_state_cb(void *data, Evas_Object *obj) 205_access_state_cb(void *data, Evas_Object *obj)
239{ 206{
240 Elm_Check_Data *sd = eo_data_scope_get(data, MY_CLASS);
241 const char *on_text, *off_text; 207 const char *on_text, *off_text;
242 208
243 if (elm_widget_disabled_get(obj)) 209 if (elm_widget_disabled_get(obj))
244 return strdup(E_("State: Disabled")); 210 return strdup(E_("State: Disabled"));
245 if (sd->state) 211 if (efl_ui_nstate_value_get(obj))
246 { 212 {
247 on_text = elm_layout_text_get(data, "on"); 213 on_text = elm_layout_text_get(data, "on");
248 214
@@ -279,8 +245,8 @@ _on_check_off(void *data,
279 245
280 ELM_CHECK_DATA_GET(obj, sd); 246 ELM_CHECK_DATA_GET(obj, sd);
281 247
282 sd->state = EINA_FALSE; 248 efl_ui_nstate_value_set(obj, 0);
283 if (sd->statep) *sd->statep = sd->state; 249 if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
284 250
285 elm_layout_signal_emit(obj, "elm,state,check,off", "elm"); 251 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
286 eo_event_callback_call(obj, ELM_CHECK_EVENT_CHANGED, NULL); 252 eo_event_callback_call(obj, ELM_CHECK_EVENT_CHANGED, NULL);
@@ -288,7 +254,7 @@ _on_check_off(void *data,
288 if (_elm_config->atspi_mode) 254 if (_elm_config->atspi_mode)
289 elm_interface_atspi_accessible_state_changed_signal_emit(data, 255 elm_interface_atspi_accessible_state_changed_signal_emit(data,
290 ELM_ATSPI_STATE_CHECKED, 256 ELM_ATSPI_STATE_CHECKED,
291 sd->state); 257 efl_ui_nstate_value_get(obj));
292} 258}
293 259
294static void 260static void
@@ -301,15 +267,15 @@ _on_check_on(void *data,
301 267
302 ELM_CHECK_DATA_GET(obj, sd); 268 ELM_CHECK_DATA_GET(obj, sd);
303 269
304 sd->state = EINA_TRUE; 270 efl_ui_nstate_value_set(obj, 1);
305 if (sd->statep) *sd->statep = sd->state; 271 if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
306 elm_layout_signal_emit(obj, "elm,state,check,on", "elm"); 272 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
307 eo_event_callback_call(obj, ELM_CHECK_EVENT_CHANGED, NULL); 273 eo_event_callback_call(obj, ELM_CHECK_EVENT_CHANGED, NULL);
308 274
309 if (_elm_config->atspi_mode) 275 if (_elm_config->atspi_mode)
310 elm_interface_atspi_accessible_state_changed_signal_emit(data, 276 elm_interface_atspi_accessible_state_changed_signal_emit(data,
311 ELM_ATSPI_STATE_CHECKED, 277 ELM_ATSPI_STATE_CHECKED,
312 sd->state); 278 efl_ui_nstate_value_get(obj));
313} 279}
314 280
315static void 281static void
@@ -329,6 +295,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)); 295 evas_obj_smart_add(eo_super(obj, MY_CLASS));
330 elm_widget_sub_object_parent_add(obj); 296 elm_widget_sub_object_parent_add(obj);
331 297
298 if (!elm_layout_theme_set(obj, "check", "base", elm_widget_style_get(obj)))
299 CRI("Failed to set layout!");
300
332 edje_object_signal_callback_add 301 edje_object_signal_callback_add
333 (wd->resize_obj, "elm,action,check,on", "*", 302 (wd->resize_obj, "elm,action,check,on", "*",
334 _on_check_on, obj); 303 _on_check_on, obj);
@@ -348,20 +317,10 @@ _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); 317 (_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, obj);
349 318
350 elm_widget_can_focus_set(obj, EINA_TRUE); 319 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); 320 elm_layout_sizing_eval(obj);
356} 321}
357 322
358EOLIAN static const Elm_Layout_Part_Alias_Description* 323EOLIAN 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)
360{
361 return _content_aliases;
362}
363
364EOLIAN static const Elm_Layout_Part_Alias_Description*
365_elm_check_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED) 324_elm_check_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED)
366{ 325{
367 return _text_aliases; 326 return _text_aliases;
@@ -386,59 +345,49 @@ _elm_check_eo_base_constructor(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED)
386 return obj; 345 return obj;
387} 346}
388 347
389EOLIAN static void 348EAPI void
390_elm_check_state_set(Eo *obj, Elm_Check_Data *sd, Eina_Bool state) 349elm_check_state_set(Evas_Object *obj, Eina_Bool state)
391{ 350{
351 ELM_CHECK_DATA_GET_OR_RETURN(obj, sd);
392 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 352 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
393 353
394 if (state != sd->state) 354 if (state == efl_ui_nstate_value_get(obj)) return;
395 { 355
396 sd->state = state; 356 efl_ui_nstate_value_set(obj, state);
397 if (sd->statep) *sd->statep = sd->state; 357 if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
398 if (sd->state) 358 if (efl_ui_nstate_value_get(obj) == 1)
399 elm_layout_signal_emit(obj, "elm,state,check,on", "elm"); 359 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
400 else 360 else if (efl_ui_nstate_value_get(obj) == 0)
401 elm_layout_signal_emit(obj, "elm,state,check,off", "elm"); 361 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
402 }
403 362
404 edje_object_message_signal_process(wd->resize_obj); 363 edje_object_message_signal_process(wd->resize_obj);
405} 364}
406 365
407EOLIAN static Eina_Bool 366EAPI Eina_Bool
408_elm_check_state_get(Eo *obj EINA_UNUSED, Elm_Check_Data *sd) 367elm_check_state_get(const Evas_Object *obj)
409{ 368{
410 return sd->state; 369 return !!efl_ui_nstate_value_get(obj);
411} 370}
412 371
413EOLIAN static void 372EAPI void
414_elm_check_state_pointer_set(Eo *obj, Elm_Check_Data *sd, Eina_Bool *statep) 373elm_check_state_pointer_set(Eo *obj, Eina_Bool *statep)
415{ 374{
416 if (statep) 375 ELM_CHECK_DATA_GET_OR_RETURN(obj, sd);
376 if (!statep)
417 { 377 {
418 sd->statep = statep; 378 sd->statep = NULL;
419 if (*sd->statep != sd->state) 379 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 } 380 }
428 else
429 sd->statep = NULL;
430}
431 381
432EOLIAN static Eina_Bool 382 sd->statep = statep;
433_elm_check_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED) 383 if (*sd->statep != efl_ui_nstate_value_get(obj))
434{ 384 {
435 return EINA_FALSE; 385 efl_ui_nstate_value_set(obj, *sd->statep);
436} 386 if (efl_ui_nstate_value_get(obj) == 1)
437 387 elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
438EOLIAN static Eina_Bool 388 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) 389 elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
440{ 390 }
441 return EINA_FALSE;
442} 391}
443 392
444EOLIAN const Elm_Atspi_Action * 393EOLIAN const Elm_Atspi_Action *
diff --git a/src/lib/elm_check.eo b/src/lib/elm_check.eo
index 452ab93b9..0f8c5f4ba 100644
--- a/src/lib/elm_check.eo
+++ b/src/lib/elm_check.eo
@@ -1,55 +1,17 @@
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: elm_obj_check;
4 methods { 4 methods {
5 @property state {
6 set {
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 }
15 get {
16 [[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 }
34 values {
35 statep: bool * @nullable; [[Pointer to the boolean to modify]]
36 }
37 }
38 } 5 }
39 implements { 6 implements {
40 class.constructor; 7 class.constructor;
41 Eo.Base.constructor; 8 Eo.Base.constructor;
42 Evas.Object_Smart.add; 9 Evas.Object_Smart.add;
43 Elm.Widget.activate; 10 Elm.Widget.activate;
44 Elm.Widget.focus_next_manager_is;
45 Elm.Widget.focus_direction_manager_is;
46 Elm.Widget.theme_apply; 11 Elm.Widget.theme_apply;
47 Elm.Widget.sub_object_del; 12 Elm.Widget.sub_object_del;
48 Elm.Widget.event; 13 Elm.Widget.event;
49 Elm.Container.content_set;
50 Elm.Layout.text_aliases.get; 14 Elm.Layout.text_aliases.get;
51 Elm.Layout.content_aliases.get;
52 Elm.Layout.sizing_eval;
53 Elm.Interface_Atspi_Accessible.state_set.get; 15 Elm.Interface_Atspi_Accessible.state_set.get;
54 Elm.Interface_Atspi_Widget_Action.elm_actions.get; 16 Elm.Interface_Atspi_Widget_Action.elm_actions.get;
55 } 17 }
diff --git a/src/lib/elm_check_legacy.h b/src/lib/elm_check_legacy.h
index 742881d98..d28ea9172 100644
--- a/src/lib/elm_check_legacy.h
+++ b/src/lib/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/elm_nstate.c b/src/lib/elm_nstate.c
new file mode 100644
index 000000000..16d383dce
--- /dev/null
+++ b/src/lib/elm_nstate.c
@@ -0,0 +1,188 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_nstate_eo.h"
7#include "elm_button_eo.h"
8#include "elm_priv.h"
9#include "elm_widget_nstate.h"
10#include "elm_widget_button.h"
11
12#define MY_CLASS ELM_NSTATE_CLASS
13
14#define MY_CLASS_NAME "Elm_Nstate"
15#define MY_CLASS_NAME_LEGACY "elm_nstate"
16
17static const Evas_Smart_Cb_Description _smart_callbacks[] = {
18 {NULL, NULL}
19};
20
21static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
22static void _state_active(Evas_Object *obj, Elm_Nstate_Data *sd);
23
24static const Elm_Action key_actions[] = {
25 {"activate", _key_action_activate},
26 {NULL, NULL}
27};
28
29EOLIAN static Eo_Base *
30_elm_nstate_eo_base_constructor(Eo *obj, Elm_Nstate_Data *pd EINA_UNUSED)
31{
32 obj = eo_constructor(eo_super(obj, MY_CLASS));
33 evas_obj_type_set(obj, MY_CLASS_NAME_LEGACY);
34 evas_obj_smart_callbacks_descriptions_set(obj, _smart_callbacks);
35 //TODO: Add ATSPI call here
36
37 return obj;
38}
39
40static void
41_next_state_set(Elm_Nstate_Data *sd)
42{
43 ++sd->state;
44 if (sd->state == sd->nstate) sd->state = 0;
45}
46
47static void
48_state_active(Evas_Object *obj, Elm_Nstate_Data *sd)
49{
50 char buf[64];
51
52 sprintf(buf, "elm,state,changed,%d", sd->state);
53 elm_layout_signal_emit(obj, buf, "elm");
54 edje_object_message_signal_process(elm_layout_edje_get(obj));
55 elm_obj_layout_sizing_eval(obj);
56 eo_event_callback_call(obj, ELM_NSTATE_EVENT_STATE_CHANGED, NULL);
57}
58
59static void
60_on_state_changed(void *data,
61 Evas_Object *o EINA_UNUSED,
62 const char *emission EINA_UNUSED,
63 const char *source EINA_UNUSED)
64{
65 efl_ui_nstate_activate(data);
66}
67
68EOLIAN static void
69_elm_nstate_evas_object_smart_add(Eo *obj, Elm_Nstate_Data *pd)
70{
71 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
72
73 evas_obj_smart_add(eo_super(obj, MY_CLASS));
74 elm_widget_sub_object_parent_add(obj);
75
76 pd->state = 0;
77 // Default: 2 states
78 pd->nstate = 2;
79
80 if (!elm_layout_theme_set(obj, "nstate", "base", elm_widget_style_get(obj)))
81 CRI("Failed to set layout!");
82
83 edje_object_signal_callback_add(wd->resize_obj, "elm,action,state,changed",
84 "*", _on_state_changed, obj);
85}
86
87EOLIAN static void
88_elm_nstate_evas_object_smart_del(Eo *obj, Elm_Nstate_Data *pd EINA_UNUSED)
89{
90 evas_obj_smart_del(eo_super(obj, MY_CLASS));
91}
92
93EOLIAN static int
94_elm_nstate_count_get(Eo *obj EINA_UNUSED, Elm_Nstate_Data *pd)
95{
96 return pd->nstate;
97}
98
99EOLIAN static void
100_elm_nstate_count_set(Eo *obj EINA_UNUSED, Elm_Nstate_Data *pd, int nstate)
101{
102 if (pd->nstate == nstate) return;
103
104 pd->nstate = nstate;
105 pd->state = 0;
106}
107
108EOLIAN static int
109_elm_nstate_value_get(Eo *obj EINA_UNUSED, Elm_Nstate_Data *pd)
110{
111 return pd->state;
112}
113
114static Eina_Bool
115_is_valid_state(Elm_Nstate_Data *sd, int state)
116{
117 if (sd->state == state || (state < 0 || state >= sd->nstate))
118 return EINA_FALSE;
119
120 return EINA_TRUE;
121}
122
123EOLIAN static void
124_elm_nstate_value_set(Eo *obj, Elm_Nstate_Data *pd, int state)
125{
126 if (!_is_valid_state(pd, state)) return;
127
128 pd->state = state;
129 _state_active(obj, pd);
130}
131
132EOLIAN static Eina_Bool
133_elm_nstate_elm_widget_theme_apply(Eo *obj, Elm_Nstate_Data *pd)
134{
135 Eina_Bool int_ret;
136
137 int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS));
138 if (!int_ret) return EINA_FALSE;
139
140 _state_active(obj, pd);
141
142 return EINA_TRUE;
143}
144
145static Eina_Bool
146_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
147{
148 efl_ui_nstate_activate(obj);
149 return EINA_TRUE;
150}
151
152EOLIAN static Eina_Bool
153_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)
154{
155 Evas_Event_Key_Down *ev = event_info;
156
157 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
158 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
159
160 if (!_elm_config_key_binding_call(obj, MY_CLASS_NAME, ev, key_actions))
161 return EINA_FALSE;
162
163 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
164 return EINA_TRUE;
165}
166
167EOLIAN static void
168_elm_nstate_activate(Eo *obj, Elm_Nstate_Data *_pd)
169{
170 _next_state_set(_pd);
171 _state_active(obj, _pd);
172}
173
174EOLIAN static void
175_elm_nstate_class_constructor(Eo_Class *klass)
176{
177 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
178}
179
180EAPI Evas_Object *
181elm_nstate_add(Evas_Object *parent)
182{
183 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
184 Evas_Object *obj = eo_add(MY_CLASS, parent);
185 return obj;
186}
187
188#include "elm_nstate.eo.c"
diff --git a/src/lib/elm_nstate.eo b/src/lib/elm_nstate.eo
new file mode 100644
index 000000000..6ff0f89a1
--- /dev/null
+++ b/src/lib/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/elm_nstate.h b/src/lib/elm_nstate.h
new file mode 100644
index 000000000..4e35212e3
--- /dev/null
+++ b/src/lib/elm_nstate.h
@@ -0,0 +1,7 @@
1#ifdef EFL_EO_API_SUPPORT
2#include "elm_nstate_eo.h"
3#endif
4#ifndef EFL_NOLEGACY_API_SUPPORT
5#include "elm_nstate_legacy.h"
6#endif
7
diff --git a/src/lib/elm_nstate_eo.h b/src/lib/elm_nstate_eo.h
new file mode 100644
index 000000000..a19bb6555
--- /dev/null
+++ b/src/lib/elm_nstate_eo.h
@@ -0,0 +1 @@
#include "elm_nstate.eo.h"
diff --git a/src/lib/elm_nstate_legacy.h b/src/lib/elm_nstate_legacy.h
new file mode 100644
index 000000000..b0df38655
--- /dev/null
+++ b/src/lib/elm_nstate_legacy.h
@@ -0,0 +1,11 @@
1/**
2 * @brief Add a new nstate to the parent
3 *
4 * @param parent The parent object
5 * @return The new object or NULL if it cannot be created
6 *
7 * @ingroup Nstate
8 */
9EAPI Evas_Object *elm_nstate_add(Evas_Object *parent);
10
11#include "elm_nstate.eo.legacy.h"
diff --git a/src/lib/elm_widget_check.h b/src/lib/elm_widget_check.h
index bcf3eac1f..d5cf27e85 100644
--- a/src/lib/elm_widget_check.h
+++ b/src/lib/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/elm_widget_nstate.h b/src/lib/elm_widget_nstate.h
new file mode 100644
index 000000000..eb9c8f4b8
--- /dev/null
+++ b/src/lib/elm_widget_nstate.h
@@ -0,0 +1,36 @@
1#include "elm_nstate_eo.h"
2
3typedef struct
4{
5 int nstate;
6 int state;
7} Elm_Nstate_Data;
8
9EAPI void efl_ui_nstate_activate(Elm_Nstate *obj);
10
11
12#define ELM_NSTATE_DATA_GET(o, sd) \
13 Elm_Nstate_Data * sd = eo_data_scope_get(o, ELM_NSTATE_CLASS)
14
15#define ELM_NSTATE_DATA_GET_OR_RETURN(o, ptr) \
16 ELM_NSTATE_DATA_GET(o, ptr); \
17 if (EINA_UNLIKELY(!ptr)) \
18 { \
19 CRI("No widget data for object %p (%s)", \
20 o, evas_object_type_get(o)); \
21 return; \
22 }
23
24#define ELM_NSTATE_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
25 ELM_NSTATE_DATA_GET(o, ptr); \
26 if (EINA_UNLIKELY(!ptr)) \
27 { \
28 CRI("No widget data for object %p (%s)", \
29 o, evas_object_type_get(o)); \
30 return val; \
31 }
32
33#define ELM_NSTATE_CHECK(obj) \
34 if (EINA_UNLIKELY(!eo_isa((obj), ELM_NSTATE_CLASS))) \
35 return
36