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"
|
2018-02-13 05:50:14 -08:00
|
|
|
#include "efl_ui_nstate_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"
|
|
|
|
|
|
|
|
|
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);
|
2018-02-13 02:20:19 -08: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}
|
|
|
|
};
|
|
|
|
|
2017-10-23 19:13:51 -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);
|
|
|
|
}
|
|
|
|
|
2016-08-10 07:23:04 -07:00
|
|
|
EOLIAN static Efl_Object *
|
2017-10-23 19:13:51 -07:00
|
|
|
_efl_ui_nstate_efl_object_constructor(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-11-14 05:03:25 -08:00
|
|
|
if (!elm_widget_theme_klass_get(obj))
|
|
|
|
elm_widget_theme_klass_set(obj, "nstate");
|
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);
|
2017-10-23 19:13:51 -07:00
|
|
|
elm_widget_sub_object_parent_add(obj);
|
|
|
|
|
|
|
|
pd->state = 0;
|
|
|
|
// Default: 2 states
|
|
|
|
pd->nstate = 2;
|
|
|
|
|
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
|
2017-12-04 21:39:20 -08:00
|
|
|
efl_layout_signal_callback_add
|
2019-02-06 10:48:43 -08:00
|
|
|
(wd->resize_obj, "efl,action,state,changed", "*", obj, _on_state_changed, NULL);
|
2017-10-23 19:13:51 -07:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-02-13 01:39:20 -08:00
|
|
|
static void
|
2018-02-13 05:50:14 -08:00
|
|
|
_state_signal_emit(Evas_Object *obj, Efl_Ui_Nstate_Data *sd)
|
2018-02-13 01:39:20 -08:00
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
|
2018-04-26 04:24:09 -07:00
|
|
|
sprintf(buf, "efl,state,changed,%d", sd->state);
|
|
|
|
elm_layout_signal_emit(obj, buf, "efl");
|
2018-02-13 01:39:20 -08:00
|
|
|
edje_object_message_signal_process(elm_layout_edje_get(obj));
|
|
|
|
elm_layout_sizing_eval(obj);
|
2018-02-13 05:50:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_state_active(Evas_Object *obj, Efl_Ui_Nstate_Data *sd)
|
|
|
|
{
|
|
|
|
_state_signal_emit(obj, sd);
|
2018-02-13 01:39:20 -08:00
|
|
|
efl_event_callback_legacy_call(obj, EFL_UI_NSTATE_EVENT_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
|
|
|
EOLIAN static int
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_nstate_count_get(const 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
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_nstate_value_get(const 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
|
2018-02-13 01:39:20 -08: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;
|
2018-02-13 01:39:20 -08:00
|
|
|
_state_active(obj, 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
|
|
|
}
|
|
|
|
|
2019-03-04 10:37:07 -08:00
|
|
|
EOLIAN static Eina_Error
|
2018-02-13 02:20:19 -08:00
|
|
|
_efl_ui_nstate_efl_ui_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
|
|
|
{
|
2019-03-04 10:37:07 -08:00
|
|
|
Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
|
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-10-23 22:03:46 -07:00
|
|
|
int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
|
2019-03-04 10:36:41 -08:00
|
|
|
if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) 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
|
|
|
|
2018-02-13 05:50:14 -08:00
|
|
|
_state_signal_emit(obj, pd);
|
2018-02-13 02:20:19 -08:00
|
|
|
|
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 void
|
2018-02-13 01:39:20 -08: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);
|
2018-02-13 01:39:20 -08:00
|
|
|
_state_active(obj, _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
|
|
|
}
|
|
|
|
|
|
|
|
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-08-16 23:08:00 -07:00
|
|
|
/* Standard widget overrides */
|
|
|
|
|
|
|
|
ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_nstate, Efl_Ui_Nstate_Data)
|
|
|
|
|
2016-05-09 23:31:53 -07:00
|
|
|
#include "efl_ui_nstate.eo.c"
|