Focus suport for some widgets

Widgets:
* check
* radio
* slider
* toggle
* spinner
* slideshow

Author:    Thiago Ribeiro Masaki <masaki@profusion.mobi>

SVN revision: 52599
This commit is contained in:
Tiago Rezende Campos Falcao 2010-09-22 17:45:46 +00:00
parent 2bc6b517c3
commit 68c1638c16
7 changed files with 127 additions and 2 deletions

View File

@ -58,6 +58,23 @@ _del_hook(Evas_Object *obj)
free(wd);
}
static void
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (elm_widget_focus_get(obj))
{
edje_object_signal_emit(wd->chk, "elm,action,focus", "elm");
evas_object_focus_set(wd->chk, EINA_TRUE);
}
else
{
edje_object_signal_emit(wd->chk, "elm,action,unfocus", "elm");
evas_object_focus_set(wd->chk, EINA_FALSE);
}
}
static void
_theme_hook(Evas_Object *obj)
{
@ -203,6 +220,7 @@ elm_check_add(Evas_Object *parent)
ELM_SET_WIDTYPE(widtype, "check");
elm_widget_type_set(obj, "check");
elm_widget_sub_object_add(parent, obj);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);

View File

@ -40,6 +40,7 @@ static void _hov_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _hov_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _hov_show(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _hov_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _on_focus_hook(void *data, Evas_Object *obj);
static void
_del_pre_hook(Evas_Object *obj)
@ -71,6 +72,23 @@ _del_hook(Evas_Object *obj)
free(wd);
}
static void
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (elm_widget_focus_get(obj))
{
edje_object_signal_emit(wd->cov, "elm,action,focus", "elm");
evas_object_focus_set(wd->cov, EINA_TRUE);
}
else
{
edje_object_signal_emit(wd->cov, "elm,action,unfocus", "elm");
evas_object_focus_set(wd->cov, EINA_FALSE);
}
}
static void
_theme_hook(Evas_Object *obj)
{
@ -273,10 +291,12 @@ elm_hover_add(Evas_Object *parent)
ELM_SET_WIDTYPE(widtype, "hover");
elm_widget_type_set(obj, "hover");
elm_widget_sub_object_add(parent, obj);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_can_focus_set(obj, 1);
wd->hov = evas_object_rectangle_add(e);
evas_object_pass_events_set(wd->hov, 1);

View File

@ -81,6 +81,23 @@ _del_hook(Evas_Object *obj)
free(wd);
}
static void
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (elm_widget_focus_get(obj))
{
edje_object_signal_emit(wd->radio, "elm,action,focus", "elm");
evas_object_focus_set(wd->radio, EINA_TRUE);
}
else
{
edje_object_signal_emit(wd->radio, "elm,action,unfocus", "elm");
evas_object_focus_set(wd->radio, EINA_FALSE);
}
}
static void
_theme_hook(Evas_Object *obj)
{
@ -237,6 +254,7 @@ elm_radio_add(Evas_Object *parent)
ELM_SET_WIDTYPE(widtype, "radio");
elm_widget_type_set(obj, "radio");
elm_widget_sub_object_add(parent, obj);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);

View File

@ -66,6 +66,7 @@ static void _sub_del(void *data, Evas_Object *obj, void *event_info);
static void _units_set(Evas_Object *obj);
static void _val_set(Evas_Object *obj);
static void _indicator_set(Evas_Object *obj);
static void _on_focus_hook(void *data, Evas_Object *obj);
static const char SIG_CHANGED[] = "changed";
static const char SIG_DELAY_CHANGED[] = "delay,changed";
@ -90,6 +91,23 @@ _del_hook(Evas_Object *obj)
free(wd);
}
static void
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (elm_widget_focus_get(obj))
{
edje_object_signal_emit(wd->slider, "elm,action,focus", "elm");
evas_object_focus_set(wd->slider, EINA_TRUE);
}
else
{
edje_object_signal_emit(wd->slider, "elm,action,unfocus", "elm");
evas_object_focus_set(wd->slider, EINA_FALSE);
}
}
static void
_theme_hook(Evas_Object *obj)
{
@ -314,9 +332,11 @@ elm_slider_add(Evas_Object *parent)
ELM_SET_WIDTYPE(widtype, "slider");
elm_widget_type_set(obj, "slider");
elm_widget_sub_object_add(parent, obj);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_can_focus_set(obj, EINA_TRUE);
wd->horizontal = EINA_TRUE;
wd->val = 0.0;

View File

@ -56,6 +56,7 @@ static void _theme_hook(Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
static Eina_Bool _timer_cb(void *data);
static void _on_focus_hook(void *data, Evas_Object *obj);
static void
_del_hook(Evas_Object *obj)
@ -71,6 +72,23 @@ _del_hook(Evas_Object *obj)
free(wd);
}
static void
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (elm_widget_focus_get(obj))
{
edje_object_signal_emit(wd->slideshow, "elm,action,focus", "elm");
evas_object_focus_set(wd->slideshow, EINA_TRUE);
}
else
{
edje_object_signal_emit(wd->slideshow, "elm,action,unfocus", "elm");
evas_object_focus_set(wd->slideshow, EINA_FALSE);
}
}
static void
_theme_hook(Evas_Object *obj)
{
@ -242,9 +260,11 @@ elm_slideshow_add(Evas_Object *parent)
ELM_SET_WIDTYPE(widtype, "slideshow");
elm_widget_type_set(obj, "slideshow");
elm_widget_sub_object_add(parent, obj);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_can_focus_set(obj, EINA_TRUE);
wd->current = NULL;
wd->previous = NULL;

View File

@ -51,6 +51,7 @@ static void _write_label(Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
//static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
static Eina_Bool _value_set(Evas_Object *obj, double delta);
static void _on_focus_hook(void *data, Evas_Object *obj);
static void
_del_hook(Evas_Object *obj)
@ -130,9 +131,15 @@ _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (elm_widget_focus_get(obj))
edje_object_signal_emit(wd->spinner, "elm,action,focus", "elm");
{
edje_object_signal_emit(wd->spinner, "elm,action,focus", "elm");
evas_object_focus_set(wd->spinner, EINA_TRUE);
}
else
edje_object_signal_emit(wd->spinner, "elm,action,unfocus", "elm");
{
edje_object_signal_emit(wd->spinner, "elm,action,unfocus", "elm");
evas_object_focus_set(wd->spinner, EINA_FALSE);
}
}
static Eina_Bool
@ -529,6 +536,7 @@ elm_spinner_add(Evas_Object *parent)
ELM_SET_WIDTYPE(widtype, "spinner");
elm_widget_type_set(obj, "spinner");
elm_widget_sub_object_add(parent, obj);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
@ -537,6 +545,7 @@ elm_spinner_add(Evas_Object *parent)
elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
elm_widget_can_focus_set(obj, EINA_TRUE);
wd->val = 0.0;
wd->val_min = 0.0;

View File

@ -35,6 +35,7 @@ static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *eve
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
static void _signal_toggle_off(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _signal_toggle_on(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _on_focus_hook(void *data, Evas_Object *obj);
static const char SIG_CHANGED[] = "changed";
static const Evas_Smart_Cb_Description _signals[] = {
@ -64,6 +65,23 @@ _disable_hook(Evas_Object *obj)
edje_object_signal_emit(wd->tgl, "elm,state,enabled", "elm");
}
static void
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (elm_widget_focus_get(obj))
{
edje_object_signal_emit(wd->tgl, "elm,action,focus", "elm");
evas_object_focus_set(wd->tgl, EINA_TRUE);
}
else
{
edje_object_signal_emit(wd->tgl, "elm,action,unfocus", "elm");
evas_object_focus_set(wd->tgl, EINA_FALSE);
}
}
static void
_theme_hook(Evas_Object *obj)
{
@ -172,10 +190,12 @@ elm_toggle_add(Evas_Object *parent)
ELM_SET_WIDTYPE(widtype, "toggle");
elm_widget_type_set(obj, "toggle");
elm_widget_sub_object_add(parent, obj);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_disable_hook_set(obj, _disable_hook);
elm_widget_can_focus_set(obj, EINA_TRUE);
wd->tgl = edje_object_add(e);
_elm_theme_object_set(obj, wd->tgl, "toggle", "base", "default");