Little titlebar pre-made layout goes in.

This comes from a contributed widget from Samsung that was basically reproducing the code of elm_layout, so instead it was turned into a simple pre-made layout (could get more love, but once again I'm no artist).
In order to make its use simpler, previous commits introduced the signal hooks for elm_layout, text_set and some macros to make it easier to set icon/end and text for layouts like this one.

Also uglified a bit the test for Layout in order to show it working, but I intend to get it fixed again soon. Unless discomfitor wants to practice his Edje skills with it... just saying.


SVN revision: 53971
This commit is contained in:
Iván Briano 2010-10-28 17:23:53 +00:00
parent 7801aade62
commit babe15679b
2 changed files with 158 additions and 2 deletions

View File

@ -31010,3 +31010,136 @@ collections {
}
}
}
/* a simple title layout, with a label and two icons */
group { name: "elm/layout/application/titlebar";
images {
image: "bt_dis_shine.png" COMP;
}
parts {
part { name: "base";
type: RECT;
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
min: 0 30;
max: 99999 30;
color: 0 0 0 255;
}
}
part { name: "bg";
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
align: 0.0 0.0;
rel1.to: "base";
rel2.to: "base";
rel1.offset: -1 -1;
rel2.offset: 0 0;
image { normal: "bt_dis_shine.png";
border: 4 4 4 4;
}
}
}
part { name: "elm.swallow.icon";
type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
visible: 0;
fixed: 1 1;
align: 0.0 0.5;
rel1 {
to: "base";
relative: 0.0 0.0;
offset: 12 0;
}
rel2 {
to: "base";
relative: 0.0 1.0;
}
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
part { name: "elm.swallow.end";
type: SWALLOW;
scale: 1;
description { state: "default" 0.0;
visible: 0;
fixed: 1 1;
align: 1.0 0.5;
rel1 {
to: "base";
relative: 1.0 0.0;
offset: 0 0;
}
rel2 {
to: "base";
relative: 1.0 1.0;
offset: -13 -1;
}
}
description { state: "visible" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
part { name: "elm.text";
type: TEXT;
effect: SOFT_SHADOW;
mouse_events: 0;
scale: 1;
description { state: "default" 0.0;
align: 0.0 0.5;
fixed: 1 1;
rel1 {
to_x: "elm.swallow.icon";
to_y: "base";
relative: 1.0 0.0;
offset: 2 0;
}
rel2 {
to_x: "elm.swallow.end";
to_y: "base";
relative: 0.0 1.0;
offset: -3 -1;
}
text {
font: "Sans";
size: 12;
min: 0 0;
align: 0.0 0.5;
}
}
}
}
programs {
program { name: "show_icon";
signal: "elm,state,icon,visible";
source: "elm";
action: STATE_SET "visible" 0.0;
target: "elm.swallow.icon";
}
program { name: "hide_icon";
signal: "elm,state,icon,hidden";
source: "elm";
action: STATE_SET "default" 0.0;
target: "elm.swallow.icon";
}
program { name: "show_end";
signal: "elm,state,end,visible";
source: "elm";
action: STATE_SET "visible" 0.0;
target: "elm.swallow.end";
}
program { name: "hide_end";
signal: "elm,state,end,hidden";
source: "elm";
action: STATE_SET "default" 0.0;
target: "elm.swallow.end";
}
}
}
}

View File

@ -14,7 +14,7 @@ _clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
void
test_layout(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *ly, *bt;
Evas_Object *win, *bg, *box, *ly, *bt;
char buf[PATH_MAX];
win = elm_win_add(NULL, "layout", ELM_WIN_BASIC);
@ -26,11 +26,34 @@ test_layout(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
box = elm_box_add(win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_win_resize_object_add(win, box);
evas_object_show(box);
ly = elm_layout_add(win);
elm_layout_theme_set(ly, "layout", "application", "titlebar");
elm_layout_label_set(ly, "Some title");
elm_box_pack_end(box, ly);
evas_object_show(ly);
bt = elm_icon_add(win);
elm_icon_standard_set(bt, "chat");
evas_object_size_hint_min_set(bt, 20, 20);
elm_layout_icon_set(ly, bt);
bt = elm_icon_add(win);
elm_icon_standard_set(bt, "close");
evas_object_size_hint_min_set(bt, 20, 20);
elm_layout_end_set(ly, bt);
ly = elm_layout_add(win);
snprintf(buf, sizeof(buf), "%s/objects/test.edj", PACKAGE_DATA_DIR);
elm_layout_file_set(ly, buf, "layout");
evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, ly);
elm_box_pack_end(box, ly);
//elm_win_resize_object_add(win, ly);
evas_object_show(ly);
bt = elm_button_add(win);