Panel fixed and is now focusable.

The old theme start show animation on obj show, if you want
disabled by default it doesn't work well. I changed the theme
default to be visible, don't need animation on "show".

And hidden_set was with inverted logic.

The focus highlight is in theme. And the widget react to
Return/Space.

SVN revision: 52814
This commit is contained in:
Tiago Rezende Campos Falcao 2010-09-27 21:13:32 +00:00
parent a276bb071a
commit 3660486ed2
4 changed files with 212 additions and 74 deletions

View File

@ -25610,6 +25610,7 @@ collections {
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
group { group {
name: "elm/panel/base/left"; name: "elm/panel/base/left";
alias: "elm/panel/base/top";
images images
{ {
image: "bt_base1.png" COMP; image: "bt_base1.png" COMP;
@ -25620,8 +25621,35 @@ collections {
image: "icon_arrow_left.png" COMP; image: "icon_arrow_left.png" COMP;
image: "icon_arrow_right.png" COMP; image: "icon_arrow_right.png" COMP;
} }
data {
item: "focus_highlight" "on";
}
parts parts
{ {
part { name: "focus_highlight";
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1 {
to: "btn";
offset: -8 -8;
}
rel2 {
to: "btn";
offset: 7 7;
}
image {
normal: "frame_2.png";
border: 5 5 32 26;
middle: 0;
}
}
description { state: "enabled" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part part
{ {
name: "bg"; name: "bg";
@ -25631,14 +25659,19 @@ collections {
{ {
state: "default" 0.0; state: "default" 0.0;
color: 255 255 255 0; color: 255 255 255 0;
rel1.offset: 30 0; rel1.relative: 0.0 0.0;
rel2.relative: 0.0 1.0; rel1.offset: 0 0;
rel2.relative: 1.0 1.0;
rel2.offset: -1 -1;
} }
description description
{ {
state: "visible" 0.0; state: "hidden" 0.0;
inherit: "default" 0.0; inherit: "default" 0.0;
rel2.relative: 1.0 1.0; rel1.relative: -1.0 0.0;
rel1.offset: 21 0;
rel2.relative: 0.0 1.0;
rel2.offset: 20 -1;
} }
} }
part part
@ -25649,11 +25682,9 @@ collections {
description description
{ {
state: "default" 0.0; state: "default" 0.0;
rel2 rel1.to: "bg";
{ rel2.to: "bg";
offset: -20 -1; rel2.offset: -20 -1;
to_x: "bg";
}
image image
{ {
normal: "bt_dis_base.png"; normal: "bt_dis_base.png";
@ -25804,13 +25835,13 @@ collections {
align: 0.5 0.5; align: 0.5 0.5;
min: 16 16; min: 16 16;
max: 16 16; max: 16 16;
image.normal: "icon_arrow_right.png"; image.normal: "icon_arrow_left.png";
} }
description description
{ {
state: "visible" 0.0; state: "hidden" 0.0;
inherit: "default" 0.0; inherit: "default" 0.0;
image.normal: "icon_arrow_left.png"; image.normal: "icon_arrow_right.png";
} }
} }
} }
@ -25821,26 +25852,9 @@ collections {
name: "show"; name: "show";
signal: "elm,action,show"; signal: "elm,action,show";
source: "elm"; source: "elm";
action: STATE_SET "visible" 0.0;
target: "bg";
target: "btn_icon";
transition: LINEAR 0.5;
}
program
{
name: "show2";
signal: "show";
action: STATE_SET "default" 0.0; action: STATE_SET "default" 0.0;
target: "bg"; target: "bg";
target: "btn_icon"; target: "btn_icon";
after: "show3";
}
program
{
name: "show3";
action: STATE_SET "visible" 0.0;
target: "bg";
target: "btn_icon";
transition: LINEAR 0.5; transition: LINEAR 0.5;
} }
program program
@ -25848,7 +25862,7 @@ collections {
name: "hide"; name: "hide";
signal: "elm,action,hide"; signal: "elm,action,hide";
source: "elm"; source: "elm";
action: STATE_SET "default" 0.0; action: STATE_SET "hidden" 0.0;
target: "bg"; target: "bg";
target: "btn_icon"; target: "btn_icon";
transition: LINEAR 0.5; transition: LINEAR 0.5;
@ -25889,15 +25903,30 @@ collections {
program program
{ {
name: "btn_unclick3"; name: "btn_unclick3";
signal: "mouse,up,1"; signal: "mouse,clicked,1";
source: "btn_over2"; source: "btn_over2";
action: SIGNAL_EMIT "elm,action,panel,toggle" ""; action: SIGNAL_EMIT "elm,action,panel,toggle" "";
} }
program { name: "highlight_show";
signal: "elm,action,focus_highlight,show";
source: "elm";
action: STATE_SET "enabled" 0.0;
transition: ACCELERATE 0.3;
target: "focus_highlight";
}
program { name: "highlight_hide";
signal: "elm,action,focus_highlight,hide";
source: "elm";
action: STATE_SET "default" 0.0;
transition: DECELERATE 0.3;
target: "focus_highlight";
}
} }
} }
group { group {
name: "elm/panel/base/right"; name: "elm/panel/base/right";
alias: "elm/panel/base/bottom";
images images
{ {
image: "bt_base1.png" COMP; image: "bt_base1.png" COMP;
@ -25910,6 +25939,30 @@ collections {
} }
parts parts
{ {
part { name: "focus_highlight";
description { state: "default" 0.0;
visible: 0;
color: 255 255 255 0;
rel1 {
to: "btn";
offset: -8 -8;
}
rel2 {
to: "btn";
offset: 7 7;
}
image {
normal: "frame_2.png";
border: 5 5 32 26;
middle: 0;
}
}
description { state: "enabled" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part part
{ {
name: "bg"; name: "bg";
@ -25919,14 +25972,19 @@ collections {
{ {
state: "default" 0.0; state: "default" 0.0;
color: 255 255 255 0; color: 255 255 255 0;
rel1.relative: 1 0; rel1.relative: 0.0 0.0;
rel2.offset: -31 0; rel1.offset: 0 0;
rel2.relative: 1.0 1.0;
rel2.offset: -1 -1;
} }
description description
{ {
state: "visible" 0.0; state: "hidden" 0.0;
inherit: "default" 0.0; inherit: "default" 0.0;
rel1.relative: 0 0; rel1.relative: 1.0 0.0;
rel1.offset: -22 0;
rel2.relative: 2.0 1.0;
rel2.offset: -23 -1;
} }
} }
part part
@ -25937,12 +25995,9 @@ collections {
description description
{ {
state: "default" 0.0; state: "default" 0.0;
rel1 rel1.to: "bg";
{ rel1.offset: 20 0;
offset: 20 0; rel2.to: "bg";
to_x: "bg";
}
rel2.offset: -1 -1;
image image
{ {
normal: "bt_dis_base.png"; normal: "bt_dis_base.png";
@ -26096,13 +26151,13 @@ collections {
align: 0.5 0.5; align: 0.5 0.5;
min: 16 16; min: 16 16;
max: 16 16; max: 16 16;
image.normal: "icon_arrow_left.png"; image.normal: "icon_arrow_right.png";
} }
description description
{ {
state: "visible" 0.0; state: "hidden" 0.0;
inherit: "default" 0.0; inherit: "default" 0.0;
image.normal: "icon_arrow_right.png"; image.normal: "icon_arrow_left.png";
} }
} }
} }
@ -26113,26 +26168,9 @@ collections {
name: "show"; name: "show";
signal: "elm,action,show"; signal: "elm,action,show";
source: "elm"; source: "elm";
action: STATE_SET "visible" 0.0;
target: "bg";
target: "btn_icon";
transition: LINEAR 0.5;
}
program
{
name: "show2";
signal: "show";
action: STATE_SET "default" 0.0; action: STATE_SET "default" 0.0;
target: "bg"; target: "bg";
target: "btn_icon"; target: "btn_icon";
after: "show3";
}
program
{
name: "show3";
action: STATE_SET "visible" 0.0;
target: "bg";
target: "btn_icon";
transition: LINEAR 0.5; transition: LINEAR 0.5;
} }
program program
@ -26140,7 +26178,7 @@ collections {
name: "hide"; name: "hide";
signal: "elm,action,hide"; signal: "elm,action,hide";
source: "elm"; source: "elm";
action: STATE_SET "default" 0.0; action: STATE_SET "hidden" 0.0;
target: "bg"; target: "bg";
target: "btn_icon"; target: "btn_icon";
transition: LINEAR 0.5; transition: LINEAR 0.5;
@ -26185,6 +26223,20 @@ collections {
source: "btn_over2"; source: "btn_over2";
action: SIGNAL_EMIT "elm,action,panel,toggle" ""; action: SIGNAL_EMIT "elm,action,panel,toggle" "";
} }
program { name: "highlight_show";
signal: "elm,action,focus";
source: "elm";
action: STATE_SET "enabled" 0.0;
transition: ACCELERATE 0.3;
target: "focus_highlight";
}
program { name: "highlight_hide";
signal: "elm,action,unfocus";
source: "elm";
action: STATE_SET "default" 0.0;
transition: DECELERATE 0.3;
target: "focus_highlight";
}
} }
} }

View File

@ -1,6 +1,5 @@
/* Test for Focus Chain Linear*/ /* Test for Focus Chain Linear*/
#include <Elementary.h> #include <Elementary.h>
#include <elm_widget.h> /* needed for testing hacks */
static void static void
_on_key_down(void *data, Evas *e, Evas_Object *obj, void *einfo) _on_key_down(void *data, Evas *e, Evas_Object *obj, void *einfo)
@ -49,7 +48,6 @@ test_focus(void *data, Evas_Object *obj, void *event_info)
{ //First Col { //First Col
Evas_Object *bx = elm_box_add(win); Evas_Object *bx = elm_box_add(win);
//evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND); EVAS_HINT_EXPAND);
elm_box_pack_end(mainbx, bx); elm_box_pack_end(mainbx, bx);
@ -274,7 +272,7 @@ test_focus(void *data, Evas_Object *obj, void *event_info)
{ //Panel { //Panel
Evas_Object *panel = elm_panel_add(win); Evas_Object *panel = elm_panel_add(win);
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_BOTTOM); elm_panel_orient_set(panel, ELM_PANEL_ORIENT_LEFT);
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND); EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);

View File

@ -215,6 +215,7 @@ test_panel(void *data, Evas_Object *obj, void *event_info)
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_RIGHT); elm_panel_orient_set(panel, ELM_PANEL_ORIENT_RIGHT);
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(panel, 1, EVAS_HINT_FILL); evas_object_size_hint_align_set(panel, 1, EVAS_HINT_FILL);
elm_panel_hidden_set(panel, EINA_TRUE);
list = elm_genlist_add(win); list = elm_genlist_add(win);
evas_object_size_hint_min_set(list, 100, -1); evas_object_size_hint_min_set(list, 100, -1);
@ -235,6 +236,7 @@ test_panel(void *data, Evas_Object *obj, void *event_info)
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_BOTTOM); elm_panel_orient_set(panel, ELM_PANEL_ORIENT_BOTTOM);
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, 0); evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_panel_hidden_set(panel, EINA_TRUE);
toolbar = elm_toolbar_add(win); toolbar = elm_toolbar_add(win);
elm_toolbar_homogenous_set(toolbar, 0); elm_toolbar_homogenous_set(toolbar, 0);

View File

@ -28,6 +28,7 @@ struct _Widget_Data
static const char *widtype = NULL; static const char *widtype = NULL;
static void _del_hook(Evas_Object *obj); static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj); static void _theme_hook(Evas_Object *obj);
static void _on_focus_hook(void *data, Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj); static void _sizing_eval(Evas_Object *obj);
static void _resize(void *data, Evas *evas, Evas_Object *obj, void *event); static void _resize(void *data, Evas *evas, Evas_Object *obj, void *event);
static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data); static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
@ -46,12 +47,36 @@ _theme_hook(Evas_Object *obj)
{ {
Widget_Data *wd = elm_widget_data_get(obj); Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return; if (!wd) return;
elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", elm_widget_style_get(obj)); if (wd->scr)
// scale = (elm_widget_scale_get(obj) * _elm_config->scale); {
// edje_object_scale_set(wd->scr, scale); Evas_Object *edj;
const char *str;
elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base",
elm_widget_style_get(obj));
// scale = (elm_widget_scale_get(obj) * _elm_config->scale);
// edje_object_scale_set(wd->scr, scale);
edj = elm_smart_scroller_edje_object_get(wd->scr);
str = edje_object_data_get(edj, "focus_highlight");
if (str && !strcmp(str, "on"))
elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
else
elm_widget_highlight_in_theme_set(obj, EINA_FALSE);
}
_sizing_eval(obj); _sizing_eval(obj);
} }
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))
evas_object_focus_set(obj, EINA_TRUE);
else
evas_object_focus_set(obj, EINA_FALSE);
}
static Eina_Bool static Eina_Bool
_elm_panel_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular) _elm_panel_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool circular)
{ {
@ -82,6 +107,34 @@ _elm_panel_focus_cycle_hook(Evas_Object *obj, Elm_Focus_Direction dir, Eina_Bool
return EINA_FALSE; return EINA_FALSE;
} }
static void
_signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
emission, source);
}
static void
_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
edje_object_signal_callback_add(elm_smart_scroller_edje_object_get(wd->scr),
emission, source, func_cb, data);
}
static void *
_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, void (*func_cb) (void *data, Evas_Object *o, const char *emission, const char *source))
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return edje_object_signal_callback_del(
elm_smart_scroller_edje_object_get(wd->scr), emission, source,
func_cb);
}
static void static void
_sizing_eval(Evas_Object *obj) _sizing_eval(Evas_Object *obj)
{ {
@ -134,7 +187,7 @@ _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
} }
static void static void
_toggle_panel(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) _toggle_panel(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
{ {
Widget_Data *wd = elm_widget_data_get(data); Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return; if (!wd) return;
@ -143,15 +196,42 @@ _toggle_panel(void *data, Evas_Object *obj __UNUSED__, const char *emission __UN
edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
"elm,action,show", "elm"); "elm,action,show", "elm");
wd->hidden = EINA_FALSE; wd->hidden = EINA_FALSE;
evas_object_repeat_events_set(obj, EINA_FALSE);
} }
else else
{ {
edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
"elm,action,hide", "elm"); "elm,action,hide", "elm");
wd->hidden = EINA_TRUE; wd->hidden = EINA_TRUE;
evas_object_repeat_events_set(obj, EINA_TRUE);
if (elm_widget_focus_get(wd->content))
{
elm_widget_focused_object_clear(obj);
elm_widget_focus_steal(obj);
}
} }
} }
static Eina_Bool
_event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
{
if ((src != obj) || (type != EVAS_CALLBACK_KEY_DOWN)) return EINA_FALSE;
Evas_Event_Key_Down *ev = event_info;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
if (strcmp(ev->keyname, "Return") && strcmp(ev->keyname, "space"))
return EINA_FALSE;
_toggle_panel(obj, NULL, "elm,action,panel,toggle", "*");
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
return EINA_TRUE;
}
/** /**
* Adds a panel object * Adds a panel object
* *
@ -177,12 +257,18 @@ elm_panel_add(Evas_Object *parent)
elm_widget_data_set(obj, wd); elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook); elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook); elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
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_focus_cycle_hook_set(obj, _elm_panel_focus_cycle_hook); elm_widget_focus_cycle_hook_set(obj, _elm_panel_focus_cycle_hook);
elm_widget_can_focus_set(obj, EINA_FALSE); elm_widget_can_focus_set(obj, EINA_TRUE);
elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
elm_widget_event_hook_set(obj, _event_hook);
wd->scr = elm_smart_scroller_add(evas); wd->scr = elm_smart_scroller_add(evas);
elm_smart_scroller_widget_set(wd->scr, obj); elm_smart_scroller_widget_set(wd->scr, obj);
elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "left"); _theme_hook(obj);
elm_smart_scroller_bounce_allow_set(wd->scr, 0, 0); elm_smart_scroller_bounce_allow_set(wd->scr, 0, 0);
elm_widget_resize_object_set(obj, wd->scr); elm_widget_resize_object_set(obj, wd->scr);
elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF, elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
@ -232,7 +318,10 @@ elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient)
switch (orient) switch (orient)
{ {
case ELM_PANEL_ORIENT_TOP: case ELM_PANEL_ORIENT_TOP:
elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "top");
break;
case ELM_PANEL_ORIENT_BOTTOM: case ELM_PANEL_ORIENT_BOTTOM:
elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "bottom");
break; break;
case ELM_PANEL_ORIENT_LEFT: case ELM_PANEL_ORIENT_LEFT:
elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "left"); elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "left");
@ -240,8 +329,6 @@ elm_panel_orient_set(Evas_Object *obj, Elm_Panel_Orient orient)
case ELM_PANEL_ORIENT_RIGHT: case ELM_PANEL_ORIENT_RIGHT:
elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "right"); elm_smart_scroller_object_theme_set(obj, wd->scr, "panel", "base", "right");
break; break;
default:
break;
} }
_sizing_eval(obj); _sizing_eval(obj);
} }
@ -332,7 +419,6 @@ elm_panel_hidden_set(Evas_Object *obj, Eina_Bool hidden)
Widget_Data *wd = elm_widget_data_get(obj); Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return; if (!wd) return;
if (wd->hidden == hidden) return; if (wd->hidden == hidden) return;
wd->hidden = hidden;
_toggle_panel(obj, NULL, "elm,action,panel,toggle", "*"); _toggle_panel(obj, NULL, "elm,action,panel,toggle", "*");
} }