summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 {
}
}
group "Elm_Config_Bindings_Widget" struct {
+ value "name" string: "Elm_Nstate";
+ group "key_bindings" list {
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "Return";
+ value "action" string: "activate";
+ value "params" string: "";
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "KP_Enter";
+ value "action" string: "activate";
+ value "params" string: "";
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "space";
+ value "action" string: "activate";
+ value "params" string: "";
+ }
+ }
+ }
+ group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elm_Calendar";
group "key_bindings" list {
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 {
}
}
group "Elm_Config_Bindings_Widget" struct {
+ value "name" string: "Elm_Nstate";
+ group "key_bindings" list {
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "Return";
+ value "action" string: "activate";
+ value "params" string: "";
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "KP_Enter";
+ value "action" string: "activate";
+ value "params" string: "";
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "space";
+ value "action" string: "activate";
+ value "params" string: "";
+ }
+ }
+ }
+ group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elm_Calendar";
group "key_bindings" list {
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 {
}
}
group "Elm_Config_Bindings_Widget" struct {
+ value "name" string: "Elm_Nstate";
+ group "key_bindings" list {
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "Return";
+ value "action" string: "activate";
+ value "params" string: "";
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "KP_Enter";
+ value "action" string: "activate";
+ value "params" string: "";
+ }
+ group "Elm_Config_Binding_Key" struct {
+ value "context" int: 0;
+ value "key" string: "space";
+ value "action" string: "activate";
+ value "params" string: "";
+ }
+ }
+ }
+ group "Elm_Config_Bindings_Widget" struct {
value "name" string: "Elm_Calendar";
group "key_bindings" list {
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 {
// elm
#include "edc/elm/bg.edc"
#include "edc/elm/button.edc"
+#include "edc/elm/nstate.edc"
// XXX: mobile mode needs invisible scrollers... make signals that do this
#include "edc/elm/scroller.edc"
// 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 @@
+group { name: "elm/nstate/base/default";
+ inherit: "elm/button/base/default";
+ programs {
+ program {
+ signal: "mouse,clicked,1"; source: "event";
+ action: SIGNAL_EMIT "elm,action,state,changed" "elm";
+ }
+ }
+}
+
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 = \
widget_preview_progressbar.c \
widget_preview_box.c \
widget_preview_notify.c \
+ widget_preview_nstate.c \
widget_preview_slideshow.c \
widget_preview_photocam.c \
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 = \
lib/elementary/elm_multibuttonentry.eo \
lib/elementary/elm_naviframe.eo \
lib/elementary/elm_notify.eo \
+ lib/elementary/elm_nstate.eo \
lib/elementary/elm_pan.eo \
lib/elementary/elm_panel.eo \
lib/elementary/elm_panes.eo \
@@ -196,6 +197,7 @@ includesunstable_HEADERS = \
lib/elementary/elm_widget_multibuttonentry.h \
lib/elementary/elm_widget_naviframe.h \
lib/elementary/elm_widget_notify.h \
+ lib/elementary/elm_widget_nstate.h \
lib/elementary/elm_widget_panel.h \
lib/elementary/elm_widget_panes.h \
lib/elementary/elm_widget_photo.h \
@@ -400,6 +402,7 @@ includesub_HEADERS = \
lib/elementary/elm_notify_common.h \
lib/elementary/elm_notify_eo.h \
lib/elementary/elm_notify_legacy.h \
+ lib/elementary/elm_nstate.h \
lib/elementary/elm_object.h \
lib/elementary/elm_object_item.h \
lib/elementary/elm_panel.h \
@@ -572,6 +575,7 @@ lib_elementary_libelementary_la_SOURCES = \
lib/elementary/elm_menu.c \
lib/elementary/elm_module.c \
lib/elementary/elm_notify.c \
+ lib/elementary/elm_nstate.c \
lib/elementary/elm_panel.c \
lib/elementary/elm_panes.c \
lib/elementary/elm_photo.c \
@@ -737,6 +741,7 @@ bin/elementary/test_multibuttonentry.c \
bin/elementary/test_naviframe.c \
bin/elementary/test_naviframe_complex.c \
bin/elementary/test_notify.c \
+bin/elementary/test_nstate.c \
bin/elementary/test_panel.c \
bin/elementary/test_panes.c \
bin/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 \
test_naviframe.c \
test_naviframe_complex.c \
test_notify.c \
+test_nstate.c \
test_panel.c \
test_panes.c \
test_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);
void test_combobox2(void *data, Evas_Object *obj, void *event_info);
void test_check(void *data, Evas_Object *obj, void *event_info);
void test_check_toggle(void *data, Evas_Object *obj, void *event_info);
+void test_nstate(void *data, Evas_Object *obj, void *event_info);
void test_radio(void *data, Evas_Object *obj, void *event_info);
void test_layout(void *data, Evas_Object *obj, void *event_info);
void test_layout2(void *data, Evas_Object *obj, void *event_info);
@@ -782,6 +783,9 @@ add_tests:
ADD_TEST(NULL, "Booleans", "Check Toggle", test_check_toggle);
//------------------------------//
+ ADD_TEST(NULL, "Range Values", "Nstate", test_nstate);
+
+ //------------------------------//
ADD_TEST(NULL, "Popups", "Ctxpopup", test_ctxpopup);
ADD_TEST(NULL, "Popups", "Hover", test_hover);
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 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+#include <Elementary.h>
+
+static void
+_state_changed_cb(void *d EINA_UNUSED, Evas_Object *o, void *ei EINA_UNUSED)
+{
+ char buf[100];
+ int val;
+
+ val = efl_ui_nstate_value_get(o);
+
+ printf("nstate widget state: %d\n", val);
+ sprintf(buf, "nstate = %d", val);
+ elm_object_text_set(o, buf);
+}
+
+void
+test_nstate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+ Evas_Object *win, *bx, *nstate;
+
+ win = elm_win_util_standard_add("nstate", "nstate");
+ elm_win_autodel_set(win, EINA_TRUE);
+
+ bx = elm_box_add(win);
+ evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bx);
+ evas_object_show(bx);
+
+ nstate = eo_add(ELM_NSTATE_CLASS, win);
+ efl_ui_nstate_count_set(nstate, 5);
+ elm_object_text_set(nstate, "nstate = 0");
+ elm_box_pack_end(bx, nstate);
+ evas_object_show(nstate);
+ evas_object_smart_callback_add(nstate, "state,changed",
+ _state_changed_cb, NULL);
+
+ evas_object_resize(win, 100, 100);
+ evas_object_show(win);
+}
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;
#include <elm_mirroring.h>
#include <elm_need.h>
#include <elm_notify.h>
+#include <elm_nstate.h>
#include <elm_object.h>
#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 \
elm_widget_multibuttonentry.h \
elm_widget_naviframe.h \
elm_widget_notify.h \
+elm_widget_nstate.h \
elm_widget_panel.h \
elm_widget_panes.h \
elm_widget_photo.h \
@@ -289,6 +290,7 @@ elm_notify.h \
elm_notify_common.h \
elm_notify_eo.h \
elm_notify_legacy.h \
+elm_nstate.h \
elm_object.h \
elm_object_item.h \
elm_panel.h \
@@ -462,6 +464,7 @@ elm_mapbuf.c \
elm_menu.c \
elm_module.c \
elm_notify.c \
+elm_nstate.c \
elm_panel.c \
elm_panes.c \
elm_photo.c \
@@ -583,6 +586,7 @@ elm_menu.eo \
elm_multibuttonentry.eo \
elm_naviframe.eo \
elm_notify.eo \
+elm_nstate.eo \
elm_pan.eo \
elm_panel.eo \
elm_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 @@
#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
+#define ELM_NSTATE_PROTECTED
#include <Elementary.h>
#include "elm_priv.h"
#include "elm_widget_check.h"
-#include "elm_widget_layout.h"
+#include "elm_widget_nstate.h"
#define MY_CLASS ELM_CHECK_CLASS
#define MY_CLASS_NAME "Elm_Check"
#define MY_CLASS_NAME_LEGACY "elm_check"
-static const Elm_Layout_Part_Alias_Description _content_aliases[] =
-{
- {"icon", "elm.swallow.content"},
- {NULL, NULL}
-};
-
static const Elm_Layout_Part_Alias_Description _text_aliases[] =
{
{"default", "elm.text"},
@@ -53,9 +48,10 @@ _activate(Evas_Object *obj)
{
ELM_CHECK_DATA_GET(obj, sd);
- sd->state = !sd->state;
- if (sd->statep) *sd->statep = sd->state;
- if (sd->state)
+ efl_ui_nstate_activate(obj);
+ if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
+
+ if (efl_ui_nstate_value_get(obj) == 1)
{
// FIXME: to do animation during state change , we need different signal
// so that we can distinguish between state change by user or state change
@@ -66,7 +62,7 @@ _activate(Evas_Object *obj)
if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
_elm_access_say(E_("State: On"));
}
- else
+ else if (efl_ui_nstate_value_get(obj) == 0)
{
// FIXME: to do animation during state change , we need different signal
// so that we can distinguish between state change by user or state change
@@ -83,7 +79,7 @@ _activate(Evas_Object *obj)
if (_elm_config->atspi_mode)
elm_interface_atspi_accessible_state_changed_signal_emit(obj,
ELM_ATSPI_STATE_CHECKED,
- sd->state);
+ efl_ui_nstate_value_get(obj));
}
/* 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
return EINA_TRUE;
}
-/* FIXME: replicated from elm_layout just because check's icon spot
- * is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
- * can changed the theme API */
-EOLIAN static Eina_Bool
-_elm_check_elm_container_content_set(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED, const char *part, Evas_Object *content)
-{
- Eina_Bool int_ret = EINA_FALSE;
-
- int_ret = elm_obj_container_content_set(eo_super(obj, MY_CLASS), part, content);
- if (!int_ret) return EINA_FALSE;
-
- _icon_signal_emit(obj);
-
- elm_obj_layout_sizing_eval(obj);
-
- return EINA_TRUE;
-}
-
-EOLIAN static void
-_elm_check_elm_layout_sizing_eval(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED)
-{
- Evas_Coord minw = -1, minh = -1;
- ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
-
- elm_coords_finger_size_adjust(1, &minw, 1, &minh);
- edje_object_size_min_restricted_calc
- (wd->resize_obj, &minw, &minh, minw, minh);
- evas_object_size_hint_min_set(obj, minw, minh);
- evas_object_size_hint_max_set(obj, -1, -1);
-}
-
static Eina_Bool
_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
{
@@ -199,17 +164,20 @@ _elm_check_elm_widget_event(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED, Evas_Objec
}
EOLIAN static Eina_Bool
-_elm_check_elm_widget_theme_apply(Eo *obj, Elm_Check_Data *sd)
+_elm_check_elm_widget_theme_apply(Eo *obj, Elm_Check_Data *sd EINA_UNUSED)
{
Eina_Bool int_ret = EINA_FALSE;
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS));
+
if (!int_ret) return EINA_FALSE;
- if (!sd->state) elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
- else elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
+ if (efl_ui_nstate_value_get(obj) == 0)
+ elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
+ else if (efl_ui_nstate_value_get(obj) == 1)
+ elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
edje_object_message_signal_process(wd->resize_obj);
@@ -237,12 +205,11 @@ _access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
static char *
_access_state_cb(void *data, Evas_Object *obj)
{
- Elm_Check_Data *sd = eo_data_scope_get(data, MY_CLASS);
const char *on_text, *off_text;
if (elm_widget_disabled_get(obj))
return strdup(E_("State: Disabled"));
- if (sd->state)
+ if (efl_ui_nstate_value_get(obj))
{
on_text = elm_layout_text_get(data, "on");
@@ -279,8 +246,8 @@ _on_check_off(void *data,
ELM_CHECK_DATA_GET(obj, sd);
- sd->state = EINA_FALSE;
- if (sd->statep) *sd->statep = sd->state;
+ efl_ui_nstate_value_set(obj, 0);
+ if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
eo_event_callback_call(obj, ELM_CHECK_EVENT_CHANGED, NULL);
@@ -288,7 +255,7 @@ _on_check_off(void *data,
if (_elm_config->atspi_mode)
elm_interface_atspi_accessible_state_changed_signal_emit(data,
ELM_ATSPI_STATE_CHECKED,
- sd->state);
+ efl_ui_nstate_value_get(obj));
}
static void
@@ -301,15 +268,15 @@ _on_check_on(void *data,
ELM_CHECK_DATA_GET(obj, sd);
- sd->state = EINA_TRUE;
- if (sd->statep) *sd->statep = sd->state;
+ efl_ui_nstate_value_set(obj, 1);
+ if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
eo_event_callback_call(obj, ELM_CHECK_EVENT_CHANGED, NULL);
if (_elm_config->atspi_mode)
- elm_interface_atspi_accessible_state_changed_signal_emit(data,
- ELM_ATSPI_STATE_CHECKED,
- sd->state);
+ elm_interface_atspi_accessible_state_changed_signal_emit(data,
+ ELM_ATSPI_STATE_CHECKED,
+ efl_ui_nstate_value_get(obj));
}
static void
@@ -329,6 +296,9 @@ _elm_check_evas_object_smart_add(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED)
evas_obj_smart_add(eo_super(obj, MY_CLASS));
elm_widget_sub_object_parent_add(obj);
+ if (!elm_layout_theme_set(obj, "check", "base", elm_widget_style_get(obj)))
+ CRI("Failed to set layout!");
+
edje_object_signal_callback_add
(wd->resize_obj, "elm,action,check,on", "*",
_on_check_on, obj);
@@ -348,23 +318,40 @@ _elm_check_evas_object_smart_add(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED)
(_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, obj);
elm_widget_can_focus_set(obj, EINA_TRUE);
-
- if (!elm_layout_theme_set(obj, "check", "base", elm_widget_style_get(obj)))
- CRI("Failed to set layout!");
-
elm_layout_sizing_eval(obj);
}
EOLIAN static const Elm_Layout_Part_Alias_Description*
-_elm_check_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED)
+_elm_check_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED)
+{
+ return _text_aliases;
+}
+
+EOLIAN static Eina_Bool
+_elm_check_selected_get(Eo *obj, Elm_Check_Data *pd EINA_UNUSED)
{
- return _content_aliases;
+ return !!efl_ui_nstate_value_get(obj);
}
-EOLIAN static const Elm_Layout_Part_Alias_Description*
-_elm_check_elm_layout_text_aliases_get(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED)
+EOLIAN static void
+_elm_check_selected_set(Eo *obj, Elm_Check_Data *pd EINA_UNUSED, Eina_Bool value)
{
- return _text_aliases;
+ efl_ui_nstate_value_set(obj, value);
+}
+
+EOLIAN static void
+_elm_check_elm_nstate_count_set(Eo *obj EINA_UNUSED, Elm_Check_Data *pd EINA_UNUSED, int nstate EINA_UNUSED)
+{
+ //NOP;
+}
+
+EOLIAN static void
+_elm_check_elm_nstate_value_set(Eo *obj, Elm_Check_Data *pd EINA_UNUSED, int state)
+{
+ Eina_Bool _state = !!state;
+ if (_state == efl_ui_nstate_value_get(obj)) return;
+
+ efl_ui_nstate_value_set(eo_super(obj, MY_CLASS), _state);
}
EAPI Evas_Object *
@@ -386,59 +373,49 @@ _elm_check_eo_base_constructor(Eo *obj, Elm_Check_Data *_pd EINA_UNUSED)
return obj;
}
-EOLIAN static void
-_elm_check_state_set(Eo *obj, Elm_Check_Data *sd, Eina_Bool state)
+EAPI void
+elm_check_state_set(Evas_Object *obj, Eina_Bool state)
{
+ ELM_CHECK_DATA_GET_OR_RETURN(obj, sd);
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
- if (state != sd->state)
- {
- sd->state = state;
- if (sd->statep) *sd->statep = sd->state;
- if (sd->state)
- elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
- else
- elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
- }
+ if (state == efl_ui_nstate_value_get(obj)) return;
+
+ efl_ui_nstate_value_set(obj, state);
+ if (sd->statep) *sd->statep = efl_ui_nstate_value_get(obj);
+ if (efl_ui_nstate_value_get(obj) == 1)
+ elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
+ else if (efl_ui_nstate_value_get(obj) == 0)
+ elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
edje_object_message_signal_process(wd->resize_obj);
}
-EOLIAN static Eina_Bool
-_elm_check_state_get(Eo *obj EINA_UNUSED, Elm_Check_Data *sd)
+EAPI Eina_Bool
+elm_check_state_get(const Evas_Object *obj)
{
- return sd->state;
+ return !!efl_ui_nstate_value_get(obj);
}
-EOLIAN static void
-_elm_check_state_pointer_set(Eo *obj, Elm_Check_Data *sd, Eina_Bool *statep)
+EAPI void
+elm_check_state_pointer_set(Eo *obj, Eina_Bool *statep)
{
- if (statep)
+ ELM_CHECK_DATA_GET_OR_RETURN(obj, sd);
+ if (!statep)
{
- sd->statep = statep;
- if (*sd->statep != sd->state)
- {
- sd->state = *sd->statep;
- if (sd->state)
- elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
- else
- elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
- }
+ sd->statep = NULL;
+ return;
}
- else
- sd->statep = NULL;
-}
-EOLIAN static Eina_Bool
-_elm_check_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED)
-{
- return EINA_FALSE;
-}
-
-EOLIAN static Eina_Bool
-_elm_check_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Check_Data *_pd EINA_UNUSED)
-{
- return EINA_FALSE;
+ sd->statep = statep;
+ if (*sd->statep != efl_ui_nstate_value_get(obj))
+ {
+ efl_ui_nstate_value_set(obj, *sd->statep);
+ if (efl_ui_nstate_value_get(obj) == 1)
+ elm_layout_signal_emit(obj, "elm,state,check,on", "elm");
+ else if (efl_ui_nstate_value_get(obj) == 0)
+ elm_layout_signal_emit(obj, "elm,state,check,off", "elm");
+ }
}
EOLIAN 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 @@
-class Elm.Check (Elm.Layout, Elm.Interface_Atspi_Widget_Action)
+class Elm.Check (Elm.Nstate, Elm.Interface_Atspi_Widget_Action)
{
- eo_prefix: elm_obj_check;
+ eo_prefix: efl_ui_check;
methods {
- @property state {
+ @property selected {
set {
- [[Set the on/off state of the check object
-
- This sets the state of the check. If set with
- @.state_pointer.set, the state of that variable is also
- changed. Calling this doesn't cause the "changed" signal to
- be emitted.
- ]]
+ [[Set the on/off state of the check object.]]
}
get {
- [[Get the state of the check object]]
- }
- values {
- state: bool; [[The state to use (1 == on, 0 == off)]]
- }
- }
- @property state_pointer {
- set {
- [[Set a convenience pointer to a boolean to change
-
- This sets a pointer to a boolean, that, in addition to the check
- objects state will also be modified directly. To stop setting the
- object pointed to simply use null as the "statep" parameter.
- If "statep" is not null, then when this is called, the check
- objects state will also be modified to reflect the value of the
- boolean "statep" points to, just like calling @.state.set.
- ]]
+ [[Get the state of the check object.]]
}
values {
- statep: bool * @nullable; [[Pointer to the boolean to modify]]
+ value: Eina_Bool;
}
}
}
@@ -41,15 +19,12 @@ class Elm.Check (Elm.Layout, Elm.Interface_Atspi_Widget_Action)
Eo.Base.constructor;
Evas.Object_Smart.add;
Elm.Widget.activate;
- Elm.Widget.focus_next_manager_is;
- Elm.Widget.focus_direction_manager_is;
Elm.Widget.theme_apply;
Elm.Widget.sub_object_del;
Elm.Widget.event;
- Elm.Container.content.set;
Elm.Layout.text_aliases.get;
- Elm.Layout.content_aliases.get;
- Elm.Layout.sizing_eval;
+ Elm.Nstate.count.set;
+ Elm.Nstate.value.set;
Elm.Interface_Atspi_Accessible.state_set.get;
Elm.Interface_Atspi_Widget_Action.elm_actions.get;
}
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 @@
*/
EAPI Evas_Object * elm_check_add(Evas_Object *parent);
-#include "elm_check.eo.legacy.h" \ No newline at end of file
+/**
+ * @brief Get the state of the check object
+ *
+ * @param obj The check object
+ *
+ * @ingroup Check
+ */
+EAPI Eina_Bool elm_check_state_get(const Evas_Object *obj);
+
+/**
+ * @brief Set the on/off state of the check object
+ *
+ * This sets the state of the check. If set with
+ * @.state_pointer.set, the state of that variable is also
+ * changed. Calling this doesn't cause the "changed" signal to
+ * be emitted.
+ *
+ * @param obj The check object
+ * @param state The state to use (1 == on, 0 == off)
+ *
+ * @ingroup Check
+ */
+EAPI void elm_check_state_set(Evas_Object *obj, Eina_Bool state);
+
+/**
+ * @brief Set a convenience pointer to a boolean to change
+ *
+ * This sets a pointer to a boolean, that, in addition to the check
+ * objects state will also be modified directly. To stop setting the
+ * object pointed to simply use null as the "statep" parameter.
+ * If "statep" is not null, then when this is called, the check
+ * objects state will also be modified to reflect the value of the
+ * boolean "statep" points to, just like calling @.state.set.
+ *
+ * @param obj The check object
+ * @param statep pointer to the boolean to modify
+ *
+ * @ingroup Check
+ */
+EAPI void elm_check_state_pointer_set(Evas_Object *obj, Eina_Bool *statep);
+
+#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 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#define ELM_NSTATE_PROTECTED
+#include "Elementary.h"
+#include "elm_priv.h"
+#include "elm_widget_nstate.h"
+#include "elm_widget_button.h"
+
+#define MY_CLASS ELM_NSTATE_CLASS
+
+#define MY_CLASS_NAME "Elm_Nstate"
+#define MY_CLASS_NAME_LEGACY "elm_nstate"
+
+static const Evas_Smart_Cb_Description _smart_callbacks[] = {
+ {NULL, NULL}
+};
+
+static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
+static void _state_active(Evas_Object *obj, Elm_Nstate_Data *sd);
+
+static const Elm_Action key_actions[] = {
+ {"activate", _key_action_activate},
+ {NULL, NULL}
+};
+
+EOLIAN static Eo_Base *
+_elm_nstate_eo_base_constructor(Eo *obj, Elm_Nstate_Data *pd EINA_UNUSED)
+{
+ obj = eo_constructor(eo_super(obj, MY_CLASS));
+ evas_obj_type_set(obj, MY_CLASS_NAME_LEGACY);
+ evas_obj_smart_callbacks_descriptions_set(obj, _smart_callbacks);
+ //TODO: Add ATSPI call here
+
+ return obj;
+}
+
+static void
+_next_state_set(Elm_Nstate_Data *sd)
+{
+ ++sd->state;
+ if (sd->state == sd->nstate) sd->state = 0;
+}
+
+static void
+_state_active(Evas_Object *obj, Elm_Nstate_Data *sd)
+{
+ char buf[64];
+
+ sprintf(buf, "elm,state,changed,%d", sd->state);
+ elm_layout_signal_emit(obj, buf, "elm");
+ edje_object_message_signal_process(elm_layout_edje_get(obj));
+ elm_obj_layout_sizing_eval(obj);
+ eo_event_callback_call(obj, ELM_NSTATE_EVENT_STATE_CHANGED, NULL);
+}
+
+static void
+_on_state_changed(void *data,
+ Evas_Object *o EINA_UNUSED,
+ const char *emission EINA_UNUSED,
+ const char *source EINA_UNUSED)
+{
+ efl_ui_nstate_activate(data);
+}
+
+EOLIAN static void
+_elm_nstate_evas_object_smart_add(Eo *obj, Elm_Nstate_Data *pd)
+{
+ ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
+
+ evas_obj_smart_add(eo_super(obj, MY_CLASS));
+ elm_widget_sub_object_parent_add(obj);
+
+ pd->state = 0;
+ // Default: 2 states
+ pd->nstate = 2;
+
+ if (!elm_layout_theme_set(obj, "nstate", "base", elm_widget_style_get(obj)))
+ CRI("Failed to set layout!");
+
+ edje_object_signal_callback_add(wd->resize_obj, "elm,action,state,changed",
+ "*", _on_state_changed, obj);
+}
+
+EOLIAN static void
+_elm_nstate_evas_object_smart_del(Eo *obj, Elm_Nstate_Data *pd EINA_UNUSED)
+{
+ evas_obj_smart_del(eo_super(obj, MY_CLASS));
+}
+
+EOLIAN static int
+_elm_nstate_count_get(Eo *obj EINA_UNUSED, Elm_Nstate_Data *pd)
+{
+ return pd->nstate;
+}
+
+EOLIAN static void
+_elm_nstate_count_set(Eo *obj EINA_UNUSED, Elm_Nstate_Data *pd, int nstate)
+{
+ if (pd->nstate == nstate) return;
+
+ pd->nstate = nstate;
+ pd->state = 0;
+}
+
+EOLIAN static int
+_elm_nstate_value_get(Eo *obj EINA_UNUSED, Elm_Nstate_Data *pd)
+{
+ return pd->state;
+}
+
+static Eina_Bool
+_is_valid_state(Elm_Nstate_Data *sd, int state)
+{
+ if (sd->state == state || (state < 0 || state >= sd->nstate))
+ return EINA_FALSE;
+
+ return EINA_TRUE;
+}
+
+EOLIAN static void
+_elm_nstate_value_set(Eo *obj, Elm_Nstate_Data *pd, int state)
+{
+ if (!_is_valid_state(pd, state)) return;
+
+ pd->state = state;
+ _state_active(obj, pd);
+}
+
+EOLIAN static Eina_Bool
+_elm_nstate_elm_widget_theme_apply(Eo *obj, Elm_Nstate_Data *pd)
+{
+ Eina_Bool int_ret;
+
+ int_ret = elm_obj_widget_theme_apply(eo_super(obj, MY_CLASS));
+ if (!int_ret) return EINA_FALSE;
+
+ _state_active(obj, pd);
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
+{
+ efl_ui_nstate_activate(obj);
+ return EINA_TRUE;
+}
+
+EOLIAN static Eina_Bool
+_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)
+{
+ Evas_Event_Key_Down *ev = event_info;
+
+ if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
+
+ if (!_elm_config_key_binding_call(obj, MY_CLASS_NAME, ev, key_actions))
+ return EINA_FALSE;
+
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ return EINA_TRUE;
+}
+
+EOLIAN static void
+_elm_nstate_activate(Eo *obj, Elm_Nstate_Data *_pd)
+{
+ _next_state_set(_pd);
+ _state_active(obj, _pd);
+}
+
+EOLIAN static void
+_elm_nstate_class_constructor(Eo_Class *klass)
+{
+ evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
+}
+
+#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 @@
+class Elm.Nstate(Elm.Button)
+{
+ eo_prefix: efl_ui_nstate;
+ legacy_prefix: null;
+ data: Elm_Nstate_Data;
+ methods {
+ activate @protected {
+ }
+ @property count {
+ set {
+ [[Set the maximum number of states.
+ ]]
+ }
+ get {
+ [[Get the max number of states.
+ ]]
+ }
+ values {
+ nstate: int; [[The number of states.]]
+ }
+ }
+ @property value {
+ set {
+ [[Set the particular state given in (0...nstate}.
+ ]]
+ }
+ get {
+ [[Get the state value.
+ ]]
+ }
+ values {
+ state: int; [[The state.]]
+ }
+ }
+ }
+ implements {
+ class.constructor;
+ Eo.Base.constructor;
+ Evas.Object_Smart.add;
+ Evas.Object_Smart.del;
+ Elm.Widget.theme_apply;
+ Elm.Widget.event;
+ }
+ events {
+ state,changed;
+ }
+}
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 @@
+/**
+ * @defgroup Elm_Nstate Nstate
+ * @ingroup Elementary
+ *
+ * @image html nstate_inheritance_tree.png
+ * @image latex nstate_inheritance_tree.eps
+ *
+ * @image html img/widget/nstate/preview-00.png
+ * @image latex img/widget/nstate/preview-00.eps
+ *
+ * A Nstate is a widget which displays one of the state among states defined by user.
+ *
+ * This widget inherits from the @ref Button, so that all the functions acting on @ref Button also work for nstate objects.
+ *
+ * This widget emits the following signals, besides the ones sent from
+ * @ref Button:
+ * - @c "state,changed" - whenever state of nstate is changed
+ *
+ * Default content parts of the nstate widget that you can use are the
+ * the same that you use with the @ref Button
+ * @{
+ */
+
+#ifdef EFL_EO_API_SUPPORT
+#include "elm_nstate.eo.h"
+#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 @@
typedef struct _Elm_Check_Data Elm_Check_Data;
struct _Elm_Check_Data
{
- Eina_Bool state;
Eina_Bool *statep;
};
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 @@
+#ifndef ELM_WIDGET_NSTATE_H
+#define ELM_WIDGET_NSTATE_H
+
+#include "elm_nstate.eo.h"
+
+typedef struct
+{
+ int nstate;
+ int state;
+} Elm_Nstate_Data;
+
+
+#define ELM_NSTATE_DATA_GET(o, sd) \
+ Elm_Nstate_Data * sd = eo_data_scope_get(o, ELM_NSTATE_CLASS)
+
+#define ELM_NSTATE_DATA_GET_OR_RETURN(o, ptr) \
+ ELM_NSTATE_DATA_GET(o, ptr); \
+ if (EINA_UNLIKELY(!ptr)) \
+ { \
+ CRI("No widget data for object %p (%s)", \
+ o, evas_object_type_get(o)); \
+ return; \
+ }
+
+#define ELM_NSTATE_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
+ ELM_NSTATE_DATA_GET(o, ptr); \
+ if (EINA_UNLIKELY(!ptr)) \
+ { \
+ CRI("No widget data for object %p (%s)", \
+ o, evas_object_type_get(o)); \
+ return val; \
+ }
+
+#define ELM_NSTATE_CHECK(obj) \
+ if (EINA_UNLIKELY(!eo_isa((obj), ELM_NSTATE_CLASS))) \
+ return
+
+#endif