2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2017-11-15 18:31:26 -08:00
|
|
|
#define EFL_ACCESS_WIDGET_ACTION_PROTECTED
|
2018-04-03 04:27:30 -07:00
|
|
|
#define EFL_ACCESS_OBJECT_PROTECTED
|
2016-04-20 05:07:38 -07:00
|
|
|
#define ELM_LAYOUT_PROTECTED
|
2018-05-03 16:34:17 -07:00
|
|
|
#define EFL_PART_PROTECTED
|
2019-07-29 02:42:34 -07:00
|
|
|
#define EFL_INPUT_CLICKABLE_PROTECTED
|
2014-10-17 08:56:11 -07:00
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2017-05-21 20:48:12 -07:00
|
|
|
#include "efl_ui_button_private.h"
|
2012-11-25 22:32:53 -08:00
|
|
|
#include "elm_widget_layout.h"
|
2016-05-24 04:40:18 -07:00
|
|
|
#include "elm_part_helper.h"
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2017-05-21 20:48:12 -07:00
|
|
|
#define MY_CLASS EFL_UI_BUTTON_CLASS
|
2017-07-27 23:35:10 -07:00
|
|
|
#define MY_CLASS_PFX efl_ui_button
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2017-05-21 20:48:12 -07:00
|
|
|
#define MY_CLASS_NAME "Efl.Ui.Button"
|
2008-09-29 23:58:56 -07:00
|
|
|
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
static const char SIG_CLICKED[] = "clicked";
|
|
|
|
static const char SIG_REPEATED[] = "repeated";
|
2011-06-30 16:43:24 -07:00
|
|
|
static const char SIG_PRESSED[] = "pressed";
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
static const char SIG_UNPRESSED[] = "unpressed";
|
2013-06-09 02:54:43 -07:00
|
|
|
|
|
|
|
/* smart callbacks coming from elm button objects (besides the ones
|
|
|
|
* coming from elm layout): */
|
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|
|
|
{SIG_CLICKED, ""},
|
|
|
|
{SIG_REPEATED, ""},
|
|
|
|
{SIG_PRESSED, ""},
|
|
|
|
{SIG_UNPRESSED, ""},
|
2014-02-05 23:18:57 -08:00
|
|
|
{SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
|
|
|
|
{SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */
|
2013-06-09 02:54:43 -07:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2012-05-03 15:41:42 -07:00
|
|
|
|
|
|
|
static const Elm_Layout_Part_Alias_Description _content_aliases[] =
|
|
|
|
{
|
|
|
|
{"icon", "elm.swallow.content"},
|
|
|
|
{NULL, NULL}
|
Proxy Elementary widget signals to Edje.
Add support to automatic proxy events from Elementary to Edje using
callbacks described with Evas_Smart_Cb_Description and set to
Evas_Smart_Class or per-instance with
evas_object_smart_callbacks_descriptions_set().
Right now elm_widget is not subclassable, so there is no way to define
class signals, just instance signals.
Just doing it for button, lots of widgets to do... If you can help,
please follow the process:
* see example at src/lib/elm_button.c, copy it.
* read your widget documentation at Elementary.h
* grep for evas_object_smart_callback_call(), see if they are all
documented in Elementary.h, or if there are some missing. Fix Elementary.h
* paste and change based on fixed Elementary.h My recommendation is
to create "static const char []" variables and replace all
evas_object_smart_callback_call() with that, to force sync.
With callback descriptions pre-defined and using the same pointer with
a custom variation evas_object_smart_callback_call_ptr() we may later
optimize signal calling heavily, removing the requirement to call
eina_stringshare_add()/eina_stringshare_del() and also not mixing all
the callbacks in teh same list, instead having an array for defined
signals, and a list from there. These optimizations are not in, but
they are easily added later without breaking the API/ABI.
SVN revision: 47461
2010-03-25 17:58:14 -07:00
|
|
|
};
|
|
|
|
|
2014-03-31 05:28:05 -07:00
|
|
|
static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
|
2014-03-21 22:31:49 -07:00
|
|
|
|
|
|
|
static const Elm_Action key_actions[] = {
|
|
|
|
{"activate", _key_action_activate},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2018-06-26 09:21:54 -07:00
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_button"
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_button_class_constructor(Efl_Class *klass)
|
|
|
|
{
|
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
|
|
|
}
|
|
|
|
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_activate(Evas_Object *obj)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN(obj, sd);
|
|
|
|
|
2013-05-29 04:41:01 -07:00
|
|
|
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->repeating = EINA_FALSE;
|
|
|
|
|
|
|
|
if ((_elm_config->access_mode == ELM_ACCESS_MODE_OFF) ||
|
|
|
|
(_elm_access_2nd_click_timeout(obj)))
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
|
|
|
|
_elm_access_say(E_("Clicked"));
|
|
|
|
if (!elm_widget_disabled_get(obj) &&
|
|
|
|
!evas_object_freeze_events_get(obj))
|
2019-05-13 12:14:13 -07:00
|
|
|
{
|
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
evas_object_smart_callback_call(obj, "clicked", NULL);
|
|
|
|
else
|
2019-05-14 12:50:25 -07:00
|
|
|
{
|
2019-07-29 02:42:34 -07:00
|
|
|
efl_input_clickable_press(obj, 1);
|
|
|
|
efl_input_clickable_unpress(obj, 1);
|
2019-05-14 12:50:25 -07:00
|
|
|
}
|
2019-05-13 12:14:13 -07:00
|
|
|
}
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
|
|
|
}
|
2009-08-16 04:35:55 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static void
|
2017-05-21 20:48:12 -07:00
|
|
|
_efl_ui_button_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Button_Data *_pd EINA_UNUSED)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2013-10-05 01:13:39 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2012-05-03 15:41:42 -07:00
|
|
|
Evas_Coord minw = -1, minh = -1;
|
2010-10-07 07:49:35 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
|
|
|
edje_object_size_min_restricted_calc
|
2012-11-25 22:32:53 -08:00
|
|
|
(wd->resize_obj, &minw, &minh, minw, minh);
|
2012-05-03 15:41:42 -07:00
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-01-07 20:55:35 -08:00
|
|
|
_efl_ui_button_efl_ui_widget_on_access_activate(Eo *obj, Efl_Ui_Button_Data *_pd EINA_UNUSED, Efl_Ui_Activate act)
|
2012-09-03 01:49:45 -07:00
|
|
|
{
|
2014-03-19 23:40:43 -07:00
|
|
|
if (elm_widget_disabled_get(obj)) return EINA_FALSE;
|
2017-10-15 21:33:52 -07:00
|
|
|
if (act != EFL_UI_ACTIVATE_DEFAULT) return EINA_FALSE;
|
2014-03-19 23:40:43 -07:00
|
|
|
if (evas_object_freeze_events_get(obj)) return EINA_FALSE;
|
2012-09-16 20:01:46 -07:00
|
|
|
|
2019-05-13 12:14:13 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
evas_object_smart_callback_call(obj, "clicked", NULL);
|
|
|
|
else
|
2019-05-14 12:50:25 -07:00
|
|
|
{
|
2019-07-29 02:42:34 -07:00
|
|
|
efl_input_clickable_press(obj, 1);
|
|
|
|
efl_input_clickable_unpress(obj, 1);
|
2019-05-14 12:50:25 -07:00
|
|
|
}
|
2018-04-26 04:24:09 -07:00
|
|
|
|
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
elm_layout_signal_emit(obj, "elm,anim,activate", "elm");
|
|
|
|
else
|
|
|
|
elm_layout_signal_emit(obj, "efl,anim,activate", "efl");
|
2012-09-16 20:01:46 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
return EINA_TRUE;
|
2012-09-03 01:49:45 -07:00
|
|
|
}
|
|
|
|
|
2014-03-31 05:28:05 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
|
2014-03-21 22:31:49 -07:00
|
|
|
{
|
2018-04-26 04:24:09 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
elm_layout_signal_emit(obj, "elm,anim,activate", "elm");
|
|
|
|
else
|
|
|
|
elm_layout_signal_emit(obj, "efl,anim,activate", "efl");
|
2014-03-21 22:31:49 -07:00
|
|
|
_activate(obj);
|
2014-03-31 05:28:05 -07:00
|
|
|
return EINA_TRUE;
|
2014-03-21 22:31:49 -07:00
|
|
|
}
|
|
|
|
|
2010-09-22 10:45:43 -07:00
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_on_clicked_signal(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2010-09-22 10:45:43 -07:00
|
|
|
{
|
|
|
|
_activate(data);
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
|
|
|
|
2010-06-25 02:58:14 -07:00
|
|
|
static Eina_Bool
|
2010-01-23 17:53:37 -08:00
|
|
|
_autorepeat_send(void *data)
|
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN_VAL(data, sd, ECORE_CALLBACK_CANCEL);
|
2010-01-23 17:53:37 -08:00
|
|
|
|
2019-05-13 12:14:03 -07:00
|
|
|
if (elm_widget_is_legacy(data))
|
|
|
|
evas_object_smart_callback_call(data, "repeated", NULL);
|
|
|
|
else
|
|
|
|
efl_event_callback_call(data, EFL_UI_AUTOREPEAT_EVENT_REPEATED, NULL);
|
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
if (!sd->repeating)
|
2010-04-08 08:15:22 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->timer = NULL;
|
2011-02-27 14:59:12 -08:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2010-04-08 08:15:22 -07:00
|
|
|
}
|
2010-01-23 17:53:37 -08:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2010-06-25 02:58:14 -07:00
|
|
|
static Eina_Bool
|
2010-01-23 17:53:37 -08:00
|
|
|
_autorepeat_initial_send(void *data)
|
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN_VAL(data, sd, ECORE_CALLBACK_CANCEL);
|
2010-01-23 17:53:37 -08:00
|
|
|
|
2013-05-29 04:41:01 -07:00
|
|
|
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->repeating = EINA_TRUE;
|
2010-01-23 17:53:37 -08:00
|
|
|
_autorepeat_send(data);
|
2014-04-12 20:43:41 -07:00
|
|
|
sd->timer = ecore_timer_add(sd->ar_gap_timeout, _autorepeat_send, data);
|
2010-01-23 17:53:37 -08:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_on_pressed_signal(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN(data, sd);
|
2010-01-23 17:53:37 -08:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
if ((sd->autorepeat) && (!sd->repeating))
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2014-04-12 20:43:41 -07:00
|
|
|
if (sd->ar_initial_timeout <= 0.0)
|
2012-05-03 15:41:42 -07:00
|
|
|
_autorepeat_initial_send(data); /* call immediately */
|
2011-02-27 14:59:12 -08:00
|
|
|
else
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->timer = ecore_timer_add
|
2014-04-12 20:43:41 -07:00
|
|
|
(sd->ar_initial_timeout, _autorepeat_initial_send, data);
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
2011-06-30 16:43:24 -07:00
|
|
|
|
2019-05-13 12:14:13 -07:00
|
|
|
if (elm_widget_is_legacy(data))
|
|
|
|
evas_object_smart_callback_call
|
|
|
|
(data, "pressed", NULL);
|
|
|
|
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_on_unpressed_signal(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *emission EINA_UNUSED,
|
|
|
|
const char *source EINA_UNUSED)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN(data, sd);
|
2010-01-23 17:53:37 -08:00
|
|
|
|
2013-05-29 04:41:01 -07:00
|
|
|
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->repeating = EINA_FALSE;
|
2019-05-13 12:14:13 -07:00
|
|
|
|
|
|
|
if (elm_widget_is_legacy(data))
|
|
|
|
evas_object_smart_callback_call
|
|
|
|
(data, "unpressed", NULL);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2011-08-19 04:07:42 -07:00
|
|
|
static char *
|
2014-01-06 06:30:02 -08:00
|
|
|
_access_info_cb(void *data EINA_UNUSED, Evas_Object *obj)
|
2011-08-19 04:07:42 -07:00
|
|
|
{
|
2011-08-25 19:02:15 -07:00
|
|
|
const char *txt = elm_widget_access_info_get(obj);
|
2012-05-03 15:41:42 -07:00
|
|
|
|
|
|
|
if (!txt) txt = elm_layout_text_get(obj, NULL);
|
2011-08-19 04:07:42 -07:00
|
|
|
if (txt) return strdup(txt);
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2011-08-25 19:02:15 -07:00
|
|
|
return NULL;
|
2011-08-19 04:07:42 -07:00
|
|
|
}
|
|
|
|
|
2011-08-19 04:20:45 -07:00
|
|
|
static char *
|
2014-01-06 06:30:02 -08:00
|
|
|
_access_state_cb(void *data EINA_UNUSED, Evas_Object *obj)
|
2011-08-19 04:20:45 -07:00
|
|
|
{
|
|
|
|
if (elm_widget_disabled_get(obj))
|
2011-08-25 19:02:15 -07:00
|
|
|
return strdup(E_("State: Disabled"));
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2011-08-19 04:20:45 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static void
|
2017-05-21 20:48:12 -07:00
|
|
|
_efl_ui_button_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Button_Data *_pd EINA_UNUSED)
|
2012-05-03 15:41:42 -07:00
|
|
|
{
|
2013-10-05 01:13:39 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2017-11-14 05:03:25 -08:00
|
|
|
if (!elm_widget_theme_klass_get(obj))
|
|
|
|
elm_widget_theme_klass_set(obj, "button");
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
2013-02-20 21:57:05 -08:00
|
|
|
|
2018-04-26 04:24:09 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
{
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(wd->resize_obj, "elm,action,click", "*",
|
|
|
|
_on_clicked_signal, obj);
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(wd->resize_obj, "elm,action,press", "*",
|
|
|
|
_on_pressed_signal, obj);
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(wd->resize_obj, "elm,action,unpress", "*",
|
|
|
|
_on_unpressed_signal, obj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(wd->resize_obj, "efl,action,press", "*",
|
|
|
|
_on_pressed_signal, obj);
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(wd->resize_obj, "efl,action,unpress", "*",
|
|
|
|
_on_unpressed_signal, obj);
|
2019-05-14 12:50:25 -07:00
|
|
|
efl_ui_clickable_util_bind_to_theme(wd->resize_obj, obj);
|
2018-04-26 04:24:09 -07:00
|
|
|
}
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2012-11-25 22:32:53 -08:00
|
|
|
_elm_access_object_register(obj, wd->resize_obj);
|
2012-05-03 15:41:42 -07:00
|
|
|
_elm_access_text_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_TYPE, E_("Button"));
|
2012-05-03 15:41:42 -07:00
|
|
|
_elm_access_callback_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL);
|
2012-05-03 15:41:42 -07:00
|
|
|
_elm_access_callback_set
|
2013-07-30 20:53:04 -07:00
|
|
|
(_elm_access_info_get(obj), ELM_ACCESS_STATE, _access_state_cb, obj);
|
2012-05-03 15:41:42 -07:00
|
|
|
|
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
2017-11-14 05:03:25 -08:00
|
|
|
|
2019-03-04 10:36:41 -08:00
|
|
|
if (elm_widget_theme_object_set(obj, wd->resize_obj,
|
2017-11-14 05:03:25 -08:00
|
|
|
elm_widget_theme_klass_get(obj),
|
|
|
|
elm_widget_theme_element_get(obj),
|
2019-03-04 10:36:41 -08:00
|
|
|
elm_widget_theme_style_get(obj)) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
|
2013-12-25 20:03:55 -08:00
|
|
|
CRI("Failed to set layout!");
|
2012-05-03 15:41:42 -07:00
|
|
|
}
|
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2017-05-21 20:48:12 -07:00
|
|
|
_efl_ui_button_efl_object_constructor(Eo *obj, Efl_Ui_Button_Data *_pd EINA_UNUSED)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
2016-06-16 22:12:02 -07:00
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
|
2018-04-03 04:27:30 -07:00
|
|
|
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_PUSH_BUTTON);
|
2015-05-19 05:34:07 -07:00
|
|
|
|
|
|
|
return obj;
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static void
|
2017-05-21 20:48:12 -07:00
|
|
|
_efl_ui_button_efl_ui_autorepeat_autorepeat_enabled_set(Eo *obj EINA_UNUSED, Efl_Ui_Button_Data *sd, Eina_Bool on)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2013-05-29 04:41:01 -07:00
|
|
|
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->autorepeat = on;
|
|
|
|
sd->repeating = EINA_FALSE;
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2019-05-02 10:48:29 -07:00
|
|
|
_efl_ui_button_efl_ui_autorepeat_autorepeat_enabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Button_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2019-05-02 10:48:29 -07:00
|
|
|
return (sd->autorepeat);
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static void
|
2019-05-02 10:48:29 -07:00
|
|
|
_efl_ui_button_efl_ui_autorepeat_autorepeat_initial_timeout_set(Eo *obj EINA_UNUSED, Efl_Ui_Button_Data *sd, double t)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2017-01-06 09:57:46 -08:00
|
|
|
if (EINA_DBL_EQ(sd->ar_initial_timeout, t)) return;
|
2013-05-29 04:41:01 -07:00
|
|
|
ELM_SAFE_FREE(sd->timer, ecore_timer_del);
|
2014-04-12 20:43:41 -07:00
|
|
|
sd->ar_initial_timeout = t;
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static double
|
2019-05-02 10:48:29 -07:00
|
|
|
_efl_ui_button_efl_ui_autorepeat_autorepeat_initial_timeout_get(const Eo *obj EINA_UNUSED, Efl_Ui_Button_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2019-05-02 10:48:29 -07:00
|
|
|
return sd->ar_initial_timeout;
|
2010-10-27 07:38:45 -07:00
|
|
|
}
|
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static void
|
2019-05-02 10:48:29 -07:00
|
|
|
_efl_ui_button_efl_ui_autorepeat_autorepeat_gap_timeout_set(Eo *obj EINA_UNUSED, Efl_Ui_Button_Data *sd, double t)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2017-01-06 09:57:46 -08:00
|
|
|
if (EINA_DBL_EQ(sd->ar_gap_timeout, t)) return;
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2014-04-12 20:43:41 -07:00
|
|
|
sd->ar_gap_timeout = t;
|
2012-05-03 15:41:42 -07:00
|
|
|
if ((sd->repeating) && (sd->timer)) ecore_timer_interval_set(sd->timer, t);
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
2010-10-27 07:38:45 -07:00
|
|
|
|
2014-03-19 23:40:43 -07:00
|
|
|
EOLIAN static double
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_button_efl_ui_autorepeat_autorepeat_gap_timeout_get(const Eo *obj EINA_UNUSED, Efl_Ui_Button_Data *sd)
|
2010-10-27 07:38:45 -07:00
|
|
|
{
|
2014-04-12 20:43:41 -07:00
|
|
|
return sd->ar_gap_timeout;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-03 15:41:42 -07:00
|
|
|
|
2017-11-15 18:55:06 -08:00
|
|
|
EOLIAN const Efl_Access_Action_Data *
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_button_efl_access_widget_action_elm_actions_get(const Eo *obj EINA_UNUSED, Efl_Ui_Button_Data *pd EINA_UNUSED)
|
2014-04-20 23:04:25 -07:00
|
|
|
{
|
2017-11-15 18:55:06 -08:00
|
|
|
static Efl_Access_Action_Data atspi_actions[] = {
|
2014-07-25 01:33:19 -07:00
|
|
|
{ "activate", "activate", NULL, _key_action_activate },
|
|
|
|
{ NULL, NULL, NULL, NULL}
|
|
|
|
};
|
|
|
|
return &atspi_actions[0];
|
2014-04-20 23:04:25 -07:00
|
|
|
}
|
|
|
|
|
2017-08-16 23:08:00 -07:00
|
|
|
/* Standard widget overrides */
|
|
|
|
|
|
|
|
ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_button, Efl_Ui_Button_Data)
|
2017-09-19 05:46:59 -07:00
|
|
|
ELM_PART_TEXT_DEFAULT_IMPLEMENT(efl_ui_button, Efl_Ui_Button_Data)
|
2017-11-20 03:22:48 -08:00
|
|
|
ELM_PART_CONTENT_DEFAULT_IMPLEMENT(efl_ui_button, Efl_Ui_Button_Data)
|
2017-01-04 03:17:21 -08:00
|
|
|
|
2017-05-15 23:57:16 -07:00
|
|
|
EAPI void
|
|
|
|
elm_button_autorepeat_initial_timeout_set(Evas_Object *obj, double t)
|
|
|
|
{
|
|
|
|
efl_ui_autorepeat_initial_timeout_set(obj, t);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI double
|
|
|
|
elm_button_autorepeat_initial_timeout_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
return efl_ui_autorepeat_initial_timeout_get(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_button_autorepeat_gap_timeout_set(Evas_Object *obj, double t)
|
|
|
|
{
|
|
|
|
efl_ui_autorepeat_gap_timeout_set(obj, t);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI double
|
|
|
|
elm_button_autorepeat_gap_timeout_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
return efl_ui_autorepeat_gap_timeout_get(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_button_autorepeat_set(Evas_Object *obj, Eina_Bool on)
|
|
|
|
{
|
|
|
|
efl_ui_autorepeat_enabled_set(obj, on);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_button_autorepeat_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
return efl_ui_autorepeat_enabled_get(obj);
|
|
|
|
}
|
|
|
|
|
2017-05-18 01:52:17 -07:00
|
|
|
/* Internal EO APIs and hidden overrides */
|
|
|
|
|
2017-08-07 19:48:31 -07:00
|
|
|
ELM_LAYOUT_CONTENT_ALIASES_IMPLEMENT(MY_CLASS_PFX)
|
2017-07-27 23:35:10 -07:00
|
|
|
|
2017-05-21 20:48:12 -07:00
|
|
|
#define EFL_UI_BUTTON_EXTRA_OPS \
|
2017-08-07 19:48:31 -07:00
|
|
|
ELM_LAYOUT_CONTENT_ALIASES_OPS(MY_CLASS_PFX), \
|
2017-08-07 00:13:38 -07:00
|
|
|
ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_button), \
|
2018-05-28 01:32:46 -07:00
|
|
|
EFL_CANVAS_GROUP_ADD_OPS(efl_ui_button)
|
2017-05-18 01:52:17 -07:00
|
|
|
|
2017-05-21 20:48:12 -07:00
|
|
|
#include "efl_ui_button.eo.c"
|
2018-01-23 22:50:58 -08:00
|
|
|
|
2019-03-05 14:00:37 -08:00
|
|
|
#include "efl_ui_button_legacy_eo.h"
|
efl.ui.layout: change signal name for icon/text
Summary:
when set/unset icon and text,
signal "elm,state,[part],visible/hidden" is emitted.
This is wrong because visible/hidden should be handled by
Efl.Gfx.visible, not Efl.Text nor Efl.Content.
This should be changed into elm,state,[part],set/unset"
All relating edc should be fixed.
Test Plan: run elementary_test->button, Efl.Ui.Button
Reviewers: jpeg, cedric, woohyun, Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D5798
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2018-02-14 11:29:19 -08:00
|
|
|
#include "efl_ui_button_legacy_part.eo.h"
|
2018-01-23 22:50:58 -08:00
|
|
|
|
|
|
|
EOLIAN static Eo *
|
|
|
|
_efl_ui_button_legacy_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
obj = efl_constructor(efl_super(obj, EFL_UI_BUTTON_LEGACY_CLASS));
|
2018-10-22 04:39:06 -07:00
|
|
|
legacy_object_focus_handle(obj);
|
2018-01-23 22:50:58 -08:00
|
|
|
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
efl.ui.layout: change signal name for icon/text
Summary:
when set/unset icon and text,
signal "elm,state,[part],visible/hidden" is emitted.
This is wrong because visible/hidden should be handled by
Efl.Gfx.visible, not Efl.Text nor Efl.Content.
This should be changed into elm,state,[part],set/unset"
All relating edc should be fixed.
Test Plan: run elementary_test->button, Efl.Ui.Button
Reviewers: jpeg, cedric, woohyun, Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D5798
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2018-02-14 11:29:19 -08:00
|
|
|
/* FIXME: replicated from elm_layout just because button's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
|
|
|
static void
|
2018-06-18 20:42:09 -07:00
|
|
|
_icon_signal_emit(Evas_Object *obj)
|
efl.ui.layout: change signal name for icon/text
Summary:
when set/unset icon and text,
signal "elm,state,[part],visible/hidden" is emitted.
This is wrong because visible/hidden should be handled by
Efl.Gfx.visible, not Efl.Text nor Efl.Content.
This should be changed into elm,state,[part],set/unset"
All relating edc should be fixed.
Test Plan: run elementary_test->button, Efl.Ui.Button
Reviewers: jpeg, cedric, woohyun, Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D5798
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2018-02-14 11:29:19 -08:00
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
|
|
|
|
if (!elm_widget_resize_object_get(obj)) return;
|
2019-05-29 06:23:12 -07:00
|
|
|
if (!edje_object_part_exists(obj, "elm.swallow.content")) return;
|
2018-06-18 20:42:09 -07:00
|
|
|
snprintf(buf, sizeof(buf), "elm,state,icon,%s",
|
|
|
|
elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
|
efl.ui.layout: change signal name for icon/text
Summary:
when set/unset icon and text,
signal "elm,state,[part],visible/hidden" is emitted.
This is wrong because visible/hidden should be handled by
Efl.Gfx.visible, not Efl.Text nor Efl.Content.
This should be changed into elm,state,[part],set/unset"
All relating edc should be fixed.
Test Plan: run elementary_test->button, Efl.Ui.Button
Reviewers: jpeg, cedric, woohyun, Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D5798
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2018-02-14 11:29:19 -08:00
|
|
|
|
|
|
|
elm_layout_signal_emit(obj, buf, "elm");
|
|
|
|
edje_object_message_signal_process(elm_layout_edje_get(obj));
|
|
|
|
elm_layout_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: replicated from elm_layout just because button's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
2019-03-04 10:37:07 -08:00
|
|
|
EOLIAN static Eina_Error
|
efl.ui.layout: change signal name for icon/text
Summary:
when set/unset icon and text,
signal "elm,state,[part],visible/hidden" is emitted.
This is wrong because visible/hidden should be handled by
Efl.Gfx.visible, not Efl.Text nor Efl.Content.
This should be changed into elm,state,[part],set/unset"
All relating edc should be fixed.
Test Plan: run elementary_test->button, Efl.Ui.Button
Reviewers: jpeg, cedric, woohyun, Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D5798
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2018-02-14 11:29:19 -08:00
|
|
|
_efl_ui_button_legacy_efl_ui_widget_theme_apply(Eo *obj, void *_pd EINA_UNUSED)
|
|
|
|
{
|
2019-03-04 10:37:07 -08:00
|
|
|
Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
|
efl.ui.layout: change signal name for icon/text
Summary:
when set/unset icon and text,
signal "elm,state,[part],visible/hidden" is emitted.
This is wrong because visible/hidden should be handled by
Efl.Gfx.visible, not Efl.Text nor Efl.Content.
This should be changed into elm,state,[part],set/unset"
All relating edc should be fixed.
Test Plan: run elementary_test->button, Efl.Ui.Button
Reviewers: jpeg, cedric, woohyun, Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D5798
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2018-02-14 11:29:19 -08:00
|
|
|
|
|
|
|
int_ret = efl_ui_widget_theme_apply(efl_super(obj, EFL_UI_BUTTON_LEGACY_CLASS));
|
2019-03-04 10:36:41 -08:00
|
|
|
if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
|
2018-06-18 20:42:09 -07:00
|
|
|
_icon_signal_emit(obj);
|
efl.ui.layout: change signal name for icon/text
Summary:
when set/unset icon and text,
signal "elm,state,[part],visible/hidden" is emitted.
This is wrong because visible/hidden should be handled by
Efl.Gfx.visible, not Efl.Text nor Efl.Content.
This should be changed into elm,state,[part],set/unset"
All relating edc should be fixed.
Test Plan: run elementary_test->button, Efl.Ui.Button
Reviewers: jpeg, cedric, woohyun, Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D5798
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2018-02-14 11:29:19 -08:00
|
|
|
|
|
|
|
return int_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: replicated from elm_layout just because button's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_button_legacy_efl_ui_widget_widget_sub_object_del(Eo *obj, void *_pd EINA_UNUSED, Evas_Object *sobj)
|
|
|
|
{
|
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
|
|
|
|
|
|
|
int_ret = elm_widget_sub_object_del(efl_super(obj, EFL_UI_BUTTON_LEGACY_CLASS), sobj);
|
|
|
|
if (!int_ret) return EINA_FALSE;
|
|
|
|
|
2018-06-18 20:42:09 -07:00
|
|
|
_icon_signal_emit(obj);
|
efl.ui.layout: change signal name for icon/text
Summary:
when set/unset icon and text,
signal "elm,state,[part],visible/hidden" is emitted.
This is wrong because visible/hidden should be handled by
Efl.Gfx.visible, not Efl.Text nor Efl.Content.
This should be changed into elm,state,[part],set/unset"
All relating edc should be fixed.
Test Plan: run elementary_test->button, Efl.Ui.Button
Reviewers: jpeg, cedric, woohyun, Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D5798
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2018-02-14 11:29:19 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: replicated from elm_layout just because button's icon spot
|
|
|
|
* is elm.swallow.content, not elm.swallow.icon. Fix that whenever we
|
|
|
|
* can changed the theme API */
|
|
|
|
static Eina_Bool
|
|
|
|
_efl_ui_button_legacy_content_set(Eo *obj, void *_pd EINA_UNUSED, const char *part, Evas_Object *content)
|
|
|
|
{
|
|
|
|
Eina_Bool int_ret = EINA_FALSE;
|
|
|
|
|
|
|
|
int_ret = efl_content_set(efl_part(efl_super(obj, EFL_UI_BUTTON_LEGACY_CLASS), part), content);
|
|
|
|
if (!int_ret) return EINA_FALSE;
|
|
|
|
|
2018-06-18 20:42:09 -07:00
|
|
|
_icon_signal_emit(obj);
|
efl.ui.layout: change signal name for icon/text
Summary:
when set/unset icon and text,
signal "elm,state,[part],visible/hidden" is emitted.
This is wrong because visible/hidden should be handled by
Efl.Gfx.visible, not Efl.Text nor Efl.Content.
This should be changed into elm,state,[part],set/unset"
All relating edc should be fixed.
Test Plan: run elementary_test->button, Efl.Ui.Button
Reviewers: jpeg, cedric, woohyun, Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D5798
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2018-02-14 11:29:19 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Efl.Part begin */
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_part_is_efl_ui_button_legacy_part(const Eo *obj EINA_UNUSED, const char *part)
|
|
|
|
{
|
|
|
|
return eina_streq(part, "elm.swallow.content");
|
|
|
|
}
|
|
|
|
|
|
|
|
ELM_PART_OVERRIDE_PARTIAL(efl_ui_button_legacy, EFL_UI_BUTTON_LEGACY, void, _part_is_efl_ui_button_legacy_part)
|
2018-06-20 09:24:06 -07:00
|
|
|
ELM_PART_OVERRIDE_CONTENT_SET_NO_SD(efl_ui_button_legacy)
|
efl.ui.layout: change signal name for icon/text
Summary:
when set/unset icon and text,
signal "elm,state,[part],visible/hidden" is emitted.
This is wrong because visible/hidden should be handled by
Efl.Gfx.visible, not Efl.Text nor Efl.Content.
This should be changed into elm,state,[part],set/unset"
All relating edc should be fixed.
Test Plan: run elementary_test->button, Efl.Ui.Button
Reviewers: jpeg, cedric, woohyun, Jaehyun_Cho
Differential Revision: https://phab.enlightenment.org/D5798
Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2018-02-14 11:29:19 -08:00
|
|
|
#include "efl_ui_button_legacy_part.eo.c"
|
|
|
|
|
|
|
|
/* Efl.Part end */
|
|
|
|
|
2018-01-23 22:50:58 -08:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_button_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
|
|
|
return elm_legacy_add(EFL_UI_BUTTON_LEGACY_CLASS, parent);
|
|
|
|
}
|
|
|
|
|
2019-03-05 14:00:37 -08:00
|
|
|
#include "efl_ui_button_legacy_eo.c"
|