2008-09-29 23:58:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
2012-05-03 15:41:42 -07:00
|
|
|
#include "elm_widget_button.h"
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2012-08-01 14:04:14 -07:00
|
|
|
EAPI const char ELM_BUTTON_SMART_NAME[] = "elm_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";
|
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
|
|
|
};
|
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
static const Elm_Layout_Part_Alias_Description _text_aliases[] =
|
2010-09-22 10:45:49 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
{"default", "elm.text"},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2011-09-14 02:53:11 -07:00
|
|
|
|
2012-05-03 15:41:42 -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, ""},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2008-09-29 23:58:56 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
EVAS_SMART_SUBCLASS_NEW
|
2012-08-01 14:04:14 -07:00
|
|
|
(ELM_BUTTON_SMART_NAME, _elm_button, Elm_Button_Smart_Class,
|
2012-05-03 15:41:42 -07:00
|
|
|
Elm_Layout_Smart_Class, elm_layout_smart_class_get, _smart_callbacks);
|
2012-05-02 09:58:26 -07:00
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (sd->timer)
|
2010-04-20 13:03:05 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ecore_timer_del(sd->timer);
|
|
|
|
sd->timer = NULL;
|
2010-04-20 13:03:05 -07:00
|
|
|
}
|
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))
|
|
|
|
evas_object_smart_callback_call(obj, SIG_CLICKED, NULL);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
|
|
|
}
|
2009-08-16 04:35:55 -07:00
|
|
|
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_elm_button_smart_sizing_eval(Evas_Object *obj)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
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_BUTTON_DATA_GET(obj, sd);
|
2012-05-02 18:19:05 -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
|
|
|
|
(ELM_WIDGET_DATA(sd)->resize_obj, &minw, &minh, minw, minh);
|
|
|
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:42 -07: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 */
|
2012-05-02 18:19:05 -07:00
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_icon_signal_emit(Evas_Object *obj)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
char buf[64];
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
snprintf(buf, sizeof(buf), "elm,state,icon,%s",
|
|
|
|
elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
elm_layout_signal_emit(obj, buf, "elm");
|
2012-07-12 04:11:21 -07:00
|
|
|
edje_object_message_signal_process(elm_layout_edje_get(obj));
|
|
|
|
_elm_button_smart_sizing_eval(obj);
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:42 -07: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 Eina_Bool
|
|
|
|
_elm_button_smart_theme(Evas_Object *obj)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
if (!ELM_WIDGET_CLASS(_elm_button_parent_sc)->theme(obj)) return EINA_FALSE;
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
_icon_signal_emit(obj);
|
2012-05-02 18:19:05 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
return EINA_TRUE;
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:42 -07: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 Eina_Bool
|
|
|
|
_elm_button_smart_sub_object_del(Evas_Object *obj,
|
|
|
|
Evas_Object *sobj)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
if (!ELM_WIDGET_CLASS(_elm_button_parent_sc)->sub_object_del(obj, sobj))
|
|
|
|
return EINA_FALSE;
|
2011-10-24 18:23:25 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
_icon_signal_emit(obj);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
return EINA_TRUE;
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:42 -07: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 Eina_Bool
|
|
|
|
_elm_button_smart_content_set(Evas_Object *obj,
|
|
|
|
const char *part,
|
|
|
|
Evas_Object *content)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
if (!ELM_CONTAINER_CLASS(_elm_button_parent_sc)->content_set
|
|
|
|
(obj, part, content))
|
|
|
|
return EINA_FALSE;
|
2008-10-06 23:55:11 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
_icon_signal_emit(obj);
|
2012-05-02 09:58:26 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
return EINA_TRUE;
|
2012-05-02 18:19:05 -07:00
|
|
|
}
|
2010-09-22 10:45:43 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_elm_button_smart_event(Evas_Object *obj,
|
|
|
|
Evas_Object *src __UNUSED__,
|
|
|
|
Evas_Callback_Type type,
|
|
|
|
void *event_info)
|
2012-05-02 18:19:05 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
Evas_Event_Key_Down *ev = event_info;
|
|
|
|
|
|
|
|
if (elm_widget_disabled_get(obj)) return EINA_FALSE;
|
|
|
|
|
|
|
|
if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
|
|
|
|
|
|
|
|
if ((strcmp(ev->keyname, "Return")) &&
|
|
|
|
(strcmp(ev->keyname, "KP_Enter")) &&
|
|
|
|
(strcmp(ev->keyname, "space")))
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
2010-09-22 10:45:43 -07:00
|
|
|
_activate(obj);
|
2012-05-03 15:41:42 -07:00
|
|
|
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
|
|
|
elm_layout_signal_emit(obj, "elm,anim,activate", "elm");
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
2010-09-22 10:45:43 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-05-03 15:41:42 -07:00
|
|
|
_on_clicked_signal(void *data,
|
|
|
|
Evas_Object *obj __UNUSED__,
|
|
|
|
const char *emission __UNUSED__,
|
|
|
|
const char *source __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
|
|
|
|
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
|
|
|
evas_object_smart_callback_call(data, SIG_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
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
if (sd->timer) ecore_timer_del(sd->timer);
|
|
|
|
sd->repeating = EINA_TRUE;
|
2010-01-23 17:53:37 -08:00
|
|
|
_autorepeat_send(data);
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->timer = ecore_timer_add(sd->ar_interval, _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,
|
|
|
|
Evas_Object *obj __UNUSED__,
|
|
|
|
const char *emission __UNUSED__,
|
|
|
|
const char *source __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
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
if (sd->ar_threshold <= 0.0)
|
|
|
|
_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
|
|
|
|
(sd->ar_threshold, _autorepeat_initial_send, data);
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
2011-06-30 16:43:24 -07:00
|
|
|
|
|
|
|
evas_object_smart_callback_call(data, SIG_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,
|
|
|
|
Evas_Object *obj __UNUSED__,
|
|
|
|
const char *emission __UNUSED__,
|
|
|
|
const char *source __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->timer)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ecore_timer_del(sd->timer);
|
|
|
|
sd->timer = NULL;
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->repeating = EINA_FALSE;
|
2010-04-08 08:15:22 -07:00
|
|
|
evas_object_smart_callback_call(data, SIG_UNPRESSED, NULL);
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2011-08-19 04:07:42 -07:00
|
|
|
static char *
|
2012-05-03 15:41:42 -07:00
|
|
|
_access_info_cb(void *data __UNUSED__,
|
|
|
|
Evas_Object *obj,
|
|
|
|
Elm_Widget_Item *item __UNUSED__)
|
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 *
|
2012-05-03 15:41:42 -07:00
|
|
|
_access_state_cb(void *data __UNUSED__,
|
|
|
|
Evas_Object *obj,
|
|
|
|
Elm_Widget_Item *item __UNUSED__)
|
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;
|
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
static void
|
|
|
|
_elm_button_smart_add(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
EVAS_SMART_DATA_ALLOC(obj, Elm_Button_Smart_Data);
|
|
|
|
|
|
|
|
ELM_WIDGET_CLASS(_elm_button_parent_sc)->base.add(obj);
|
|
|
|
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,click", "",
|
|
|
|
_on_clicked_signal, obj);
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,press", "",
|
|
|
|
_on_pressed_signal, obj);
|
|
|
|
edje_object_signal_callback_add
|
|
|
|
(ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,unpress", "",
|
|
|
|
_on_unpressed_signal, obj);
|
|
|
|
|
|
|
|
_elm_access_object_register(obj, ELM_WIDGET_DATA(priv)->resize_obj);
|
|
|
|
_elm_access_text_set
|
|
|
|
(_elm_access_object_get(obj), ELM_ACCESS_TYPE, E_("Button"));
|
|
|
|
_elm_access_callback_set
|
|
|
|
(_elm_access_object_get(obj), ELM_ACCESS_INFO, _access_info_cb, NULL);
|
|
|
|
_elm_access_callback_set
|
|
|
|
(_elm_access_object_get(obj), ELM_ACCESS_STATE, _access_state_cb, priv);
|
|
|
|
|
|
|
|
elm_widget_can_focus_set(obj, EINA_TRUE);
|
|
|
|
|
|
|
|
elm_layout_theme_set(obj, "button", "base", elm_widget_style_get(obj));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_button_smart_set_user(Elm_Button_Smart_Class *sc)
|
|
|
|
{
|
|
|
|
ELM_WIDGET_CLASS(sc)->base.add = _elm_button_smart_add;
|
|
|
|
|
|
|
|
ELM_WIDGET_CLASS(sc)->event = _elm_button_smart_event;
|
|
|
|
ELM_WIDGET_CLASS(sc)->theme = _elm_button_smart_theme;
|
|
|
|
ELM_WIDGET_CLASS(sc)->sub_object_del = _elm_button_smart_sub_object_del;
|
|
|
|
|
|
|
|
/* not a 'focus chain manager' */
|
|
|
|
ELM_WIDGET_CLASS(sc)->focus_next = NULL;
|
|
|
|
ELM_WIDGET_CLASS(sc)->focus_direction = NULL;
|
|
|
|
|
|
|
|
ELM_CONTAINER_CLASS(sc)->content_set = _elm_button_smart_content_set;
|
|
|
|
|
|
|
|
ELM_LAYOUT_CLASS(sc)->sizing_eval = _elm_button_smart_sizing_eval;
|
|
|
|
|
|
|
|
ELM_LAYOUT_CLASS(sc)->content_aliases = _content_aliases;
|
|
|
|
ELM_LAYOUT_CLASS(sc)->text_aliases = _text_aliases;
|
2012-08-01 14:04:14 -07:00
|
|
|
|
|
|
|
sc->admits_autorepeat = EINA_TRUE;
|
2012-05-03 15:41:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const Elm_Button_Smart_Class *
|
|
|
|
elm_button_smart_class_get(void)
|
|
|
|
{
|
|
|
|
static Elm_Button_Smart_Class _sc =
|
2012-08-01 14:04:14 -07:00
|
|
|
ELM_BUTTON_SMART_CLASS_INIT_NAME_VERSION(ELM_BUTTON_SMART_NAME);
|
2012-05-03 15:41:42 -07:00
|
|
|
static const Elm_Button_Smart_Class *class = NULL;
|
2012-06-08 14:05:45 -07:00
|
|
|
Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
|
2012-05-03 15:41:42 -07:00
|
|
|
|
|
|
|
if (class) return class;
|
|
|
|
|
|
|
|
_elm_button_smart_set(&_sc);
|
2012-06-08 14:05:45 -07:00
|
|
|
esc->callbacks = _smart_callbacks;
|
2012-05-03 15:41:42 -07:00
|
|
|
class = &_sc;
|
|
|
|
|
|
|
|
return class;
|
|
|
|
}
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_button_add(Evas_Object *parent)
|
2008-09-29 23:58:56 -07:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
|
|
|
|
2012-08-01 14:04:14 -07:00
|
|
|
obj = elm_widget_add(_elm_button_smart_class_new(), parent);
|
2012-07-18 14:03:39 -07:00
|
|
|
if (!obj) return NULL;
|
2012-05-03 15:41:42 -07:00
|
|
|
|
|
|
|
if (!elm_widget_sub_object_add(parent, obj))
|
|
|
|
ERR("could not add %p as sub object of %p", obj, parent);
|
|
|
|
|
2008-10-06 18:23:49 -07:00
|
|
|
return obj;
|
2008-09-29 23:58:56 -07:00
|
|
|
}
|
|
|
|
|
2010-01-23 17:53:37 -08:00
|
|
|
EAPI void
|
2012-05-03 15:41:42 -07:00
|
|
|
elm_button_autorepeat_set(Evas_Object *obj,
|
|
|
|
Eina_Bool on)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_CHECK(obj);
|
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN(obj, sd);
|
|
|
|
|
|
|
|
if (sd->timer)
|
2010-03-08 23:30:48 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ecore_timer_del(sd->timer);
|
|
|
|
sd->timer = NULL;
|
2010-03-08 23:30:48 -08:00
|
|
|
}
|
2012-05-03 15:41:42 -07:00
|
|
|
sd->autorepeat = on;
|
|
|
|
sd->repeating = EINA_FALSE;
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
#define _AR_CAPABLE(_sd) \
|
|
|
|
(ELM_BUTTON_CLASS(ELM_WIDGET_DATA(_sd)->api)->admits_autorepeat)
|
|
|
|
|
2010-10-27 07:38:45 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_button_autorepeat_get(const Evas_Object *obj)
|
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_CHECK(obj) EINA_FALSE;
|
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
|
|
|
|
|
|
|
|
return _AR_CAPABLE(sd) & sd->autorepeat;
|
2010-10-27 07:38:45 -07:00
|
|
|
}
|
|
|
|
|
2010-01-23 17:53:37 -08:00
|
|
|
EAPI void
|
2012-05-03 15:41:42 -07:00
|
|
|
elm_button_autorepeat_initial_timeout_set(Evas_Object *obj,
|
|
|
|
double t)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_CHECK(obj);
|
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN(obj, sd);
|
|
|
|
|
|
|
|
if (!_AR_CAPABLE(sd))
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ERR("this widget does not support auto repetition of clicks.");
|
|
|
|
return;
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
2012-05-03 15:41:42 -07:00
|
|
|
|
|
|
|
if (sd->ar_threshold == t) return;
|
|
|
|
if (sd->timer)
|
|
|
|
{
|
|
|
|
ecore_timer_del(sd->timer);
|
|
|
|
sd->timer = NULL;
|
|
|
|
}
|
|
|
|
sd->ar_threshold = t;
|
2010-01-23 17:53:37 -08:00
|
|
|
}
|
|
|
|
|
2010-10-27 07:38:45 -07:00
|
|
|
EAPI double
|
|
|
|
elm_button_autorepeat_initial_timeout_get(const Evas_Object *obj)
|
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_CHECK(obj) 0.0;
|
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN_VAL(obj, sd, 0.0);
|
|
|
|
|
|
|
|
if (!_AR_CAPABLE(sd)) return 0.0;
|
|
|
|
|
|
|
|
return sd->ar_threshold;
|
2010-10-27 07:38:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2012-05-03 15:41:42 -07:00
|
|
|
elm_button_autorepeat_gap_timeout_set(Evas_Object *obj,
|
|
|
|
double t)
|
2010-01-23 17:53:37 -08:00
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_CHECK(obj);
|
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN(obj, sd);
|
2010-04-08 08:15:22 -07:00
|
|
|
|
2012-05-03 15:41:42 -07:00
|
|
|
if (!_AR_CAPABLE(sd))
|
|
|
|
{
|
|
|
|
ERR("this widget does not support auto repetition of clicks.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sd->ar_interval == t) return;
|
|
|
|
|
|
|
|
sd->ar_interval = t;
|
|
|
|
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
|
|
|
|
|
|
|
EAPI double
|
|
|
|
elm_button_autorepeat_gap_timeout_get(const Evas_Object *obj)
|
|
|
|
{
|
2012-05-03 15:41:42 -07:00
|
|
|
ELM_BUTTON_CHECK(obj) 0.0;
|
|
|
|
ELM_BUTTON_DATA_GET_OR_RETURN_VAL(obj, sd, 0.0);
|
|
|
|
|
|
|
|
return sd->ar_interval;
|
2010-10-27 07:38:45 -07:00
|
|
|
}
|