forked from enlightenment/efl
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
This commit is contained in:
parent
d1709a2b57
commit
56ab435998
|
@ -621,6 +621,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 {
|
||||
|
|
|
@ -625,6 +625,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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 \
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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);
|
||||
|
@ -781,6 +782,9 @@ add_tests:
|
|||
ADD_TEST(NULL, "Booleans", "Check", test_check);
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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>
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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,25 +318,42 @@ _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)
|
||||
{
|
||||
return _content_aliases;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return _text_aliases;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_elm_check_selected_get(Eo *obj, Elm_Check_Data *pd EINA_UNUSED)
|
||||
{
|
||||
return !!efl_ui_nstate_value_get(obj);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_check_selected_set(Eo *obj, Elm_Check_Data *pd EINA_UNUSED, Eina_Bool value)
|
||||
{
|
||||
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 *
|
||||
elm_check_add(Evas_Object *parent)
|
||||
{
|
||||
|
@ -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 *
|
||||
|
|
|
@ -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]]
|
||||
[[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.
|
||||
]]
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -8,4 +8,45 @@
|
|||
*/
|
||||
EAPI Evas_Object * elm_check_add(Evas_Object *parent);
|
||||
|
||||
#include "elm_check.eo.legacy.h"
|
||||
/**
|
||||
* @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"
|
||||
|
|
|
@ -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"
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -26,7 +26,6 @@
|
|||
typedef struct _Elm_Check_Data Elm_Check_Data;
|
||||
struct _Elm_Check_Data
|
||||
{
|
||||
Eina_Bool state;
|
||||
Eina_Bool *statep;
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue