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
2016-04-07 02:25:59 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2016-05-09 23:31:53 -07:00
|
|
|
#define EFL_UI_NSTATE_PROTECTED
|
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
2016-04-07 02:25:59 -07:00
|
|
|
#include "Elementary.h"
|
|
|
|
#include "elm_priv.h"
|
2016-05-09 23:31:53 -07:00
|
|
|
#include "efl_ui_nstate.eo.h"
|
2017-05-21 20:48:12 -07:00
|
|
|
#include "efl_ui_button_private.h"
|
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
2016-04-07 02:25:59 -07:00
|
|
|
|
2016-05-09 23:31:53 -07:00
|
|
|
#define MY_CLASS EFL_UI_NSTATE_CLASS
|
|
|
|
#define MY_CLASS_NAME "Efl.Ui.Nstate"
|
2017-05-18 01:15:39 -07:00
|
|
|
#define MY_CLASS_NAME_LEGACY "efl_ui_nstate"
|
2016-05-09 23:31:53 -07:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int nstate;
|
|
|
|
int state;
|
|
|
|
} Efl_Ui_Nstate_Data;
|
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
2016-04-07 02:25:59 -07:00
|
|
|
|
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
|
2016-05-09 23:31:53 -07:00
|
|
|
static void _state_active(Evas_Object *obj, Efl_Ui_Nstate_Data *sd);
|
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
2016-04-07 02:25:59 -07:00
|
|
|
|
|
|
|
static const Elm_Action key_actions[] = {
|
|
|
|
{"activate", _key_action_activate},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2016-08-10 07:23:04 -07:00
|
|
|
EOLIAN static Efl_Object *
|
|
|
|
_efl_ui_nstate_efl_object_constructor(Eo *obj, Efl_Ui_Nstate_Data *pd EINA_UNUSED)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
2016-06-20 21:26:15 -07:00
|
|
|
efl_canvas_object_type_set(obj, MY_CLASS_NAME);
|
2016-06-16 22:12:02 -07:00
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
|
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
2016-04-07 02:25:59 -07:00
|
|
|
//TODO: Add ATSPI call here
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-05-09 23:31:53 -07:00
|
|
|
_next_state_set(Efl_Ui_Nstate_Data *sd)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
|
|
|
++sd->state;
|
|
|
|
if (sd->state == sd->nstate) sd->state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-05-09 23:31:53 -07:00
|
|
|
_state_active(Evas_Object *obj, Efl_Ui_Nstate_Data *sd)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
|
|
|
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));
|
2017-08-02 23:20:58 -07:00
|
|
|
elm_layout_sizing_eval(obj);
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(obj, EFL_UI_NSTATE_EVENT_STATE_CHANGED, NULL);
|
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
2016-04-07 02:25:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2016-06-17 01:26:08 -07:00
|
|
|
_efl_ui_nstate_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Nstate_Data *pd)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
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
2016-04-07 02:25:59 -07:00
|
|
|
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
|
2016-06-17 01:26:08 -07:00
|
|
|
_efl_ui_nstate_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Nstate_Data *pd EINA_UNUSED)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
2016-09-28 21:59:58 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
|
|
|
|
|
|
|
edje_object_signal_callback_del_full(wd->resize_obj, "elm,action,state,changed",
|
|
|
|
"*", _on_state_changed, obj);
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_del(efl_super(obj, MY_CLASS));
|
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
2016-04-07 02:25:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
2016-05-09 23:31:53 -07:00
|
|
|
_efl_ui_nstate_count_get(Eo *obj EINA_UNUSED, Efl_Ui_Nstate_Data *pd)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
|
|
|
return pd->nstate;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2016-05-09 23:31:53 -07:00
|
|
|
_efl_ui_nstate_count_set(Eo *obj EINA_UNUSED, Efl_Ui_Nstate_Data *pd, int nstate)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
|
|
|
if (pd->nstate == nstate) return;
|
|
|
|
|
|
|
|
pd->nstate = nstate;
|
|
|
|
pd->state = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
2016-05-09 23:31:53 -07:00
|
|
|
_efl_ui_nstate_value_get(Eo *obj EINA_UNUSED, Efl_Ui_Nstate_Data *pd)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
|
|
|
return pd->state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2016-05-09 23:31:53 -07:00
|
|
|
_is_valid_state(Efl_Ui_Nstate_Data *sd, int state)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
|
|
|
if (sd->state == state || (state < 0 || state >= sd->nstate))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2016-05-09 23:31:53 -07:00
|
|
|
_efl_ui_nstate_value_set(Eo *obj, Efl_Ui_Nstate_Data *pd, int state)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
|
|
|
if (!_is_valid_state(pd, state)) return;
|
|
|
|
|
|
|
|
pd->state = state;
|
|
|
|
_state_active(obj, pd);
|
|
|
|
}
|
|
|
|
|
2017-08-09 00:13:06 -07:00
|
|
|
EOLIAN static Efl_Ui_Theme_Apply
|
2016-05-09 23:31:53 -07:00
|
|
|
_efl_ui_nstate_elm_widget_theme_apply(Eo *obj, Efl_Ui_Nstate_Data *pd)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
2017-08-09 00:13:06 -07:00
|
|
|
Efl_Ui_Theme_Apply int_ret = EFL_UI_THEME_APPLY_FAILED;
|
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
2016-04-07 02:25:59 -07:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
int_ret = elm_obj_widget_theme_apply(efl_super(obj, MY_CLASS));
|
2017-08-09 00:13:06 -07:00
|
|
|
if (!int_ret) return EFL_UI_THEME_APPLY_FAILED;
|
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
2016-04-07 02:25:59 -07:00
|
|
|
|
|
|
|
_state_active(obj, pd);
|
|
|
|
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
return int_ret;
|
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
2016-04-07 02:25:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2017-01-01 23:48:17 -08:00
|
|
|
_efl_ui_nstate_elm_widget_widget_event(Eo *obj, Efl_Ui_Nstate_Data *_pd EINA_UNUSED, Evas_Object *src EINA_UNUSED, Evas_Callback_Type type, void *event_info)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2016-07-12 02:03:54 -07:00
|
|
|
if (!_elm_config_key_binding_call(obj, MY_CLASS_NAME_LEGACY, ev, key_actions))
|
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
2016-04-07 02:25:59 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2016-05-09 23:31:53 -07:00
|
|
|
_efl_ui_nstate_activate(Eo *obj, Efl_Ui_Nstate_Data *_pd)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
|
|
|
_next_state_set(_pd);
|
|
|
|
_state_active(obj, _pd);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2016-08-10 07:23:04 -07:00
|
|
|
_efl_ui_nstate_class_constructor(Efl_Class *klass)
|
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
2016-04-07 02:25:59 -07:00
|
|
|
{
|
2016-05-09 23:31:53 -07:00
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME, klass);
|
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
2016-04-07 02:25:59 -07:00
|
|
|
}
|
|
|
|
|
2017-05-18 01:52:17 -07:00
|
|
|
/* Internal EO APIs and hidden overrides */
|
|
|
|
|
|
|
|
#define EFL_UI_NSTATE_EXTRA_OPS \
|
|
|
|
EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_nstate)
|
|
|
|
|
2016-05-09 23:31:53 -07:00
|
|
|
#include "efl_ui_nstate.eo.c"
|