bubble widget and test. looking good.
SVN revision: 37291
This commit is contained in:
parent
3c2f9078e6
commit
2586c28fec
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 251 B |
|
@ -3080,46 +3080,26 @@ collections {
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
group { name: "elm/bubble/base/default";
|
||||
images {
|
||||
image: "frame_1.png" COMP;
|
||||
image: "frame_2.png" COMP;
|
||||
image: "dia_grad.png" COMP;
|
||||
image: "bubble_1.png" COMP;
|
||||
image: "bubble_shine.png" COMP;
|
||||
}
|
||||
parts {
|
||||
part { name: "base0";
|
||||
mouse_events: 0;
|
||||
description { state: "default" 0.0;
|
||||
image.normal: "dia_grad.png";
|
||||
rel1.to: "over";
|
||||
rel2.to: "over";
|
||||
fill {
|
||||
smooth: 0;
|
||||
size {
|
||||
relative: 0.0 1.0;
|
||||
offset: 64 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
part { name: "base";
|
||||
mouse_events: 0;
|
||||
description { state: "default" 0.0;
|
||||
image {
|
||||
normal: "frame_2.png";
|
||||
border: 5 5 32 26;
|
||||
middle: 0;
|
||||
}
|
||||
fill.smooth : 0;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.content";
|
||||
part { name: "elm.swallow.icon";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
fixed: 1 1;
|
||||
align: 0.0 1.0;
|
||||
aspect: 1.0 1.0;
|
||||
aspect_preference: VERTICAL;
|
||||
rel1 {
|
||||
to_y: "elm.text";
|
||||
relative: 0.0 1.0;
|
||||
offset: 8 2;
|
||||
relative: 0.0 0.0;
|
||||
offset: 4 0;
|
||||
}
|
||||
rel2 {
|
||||
relative: 0.0 1.0;
|
||||
offset: 4 -5;
|
||||
}
|
||||
rel2.offset: -9 -9;
|
||||
}
|
||||
}
|
||||
part { name: "elm.text";
|
||||
|
@ -3127,15 +3107,42 @@ collections {
|
|||
mouse_events: 0;
|
||||
scale: 1;
|
||||
description { state: "default" 0.0;
|
||||
align: 0.0 0.0;
|
||||
align: 0.0 1.0;
|
||||
fixed: 0 1;
|
||||
rel1 {
|
||||
relative: 0.0 0.0;
|
||||
offset: 6 6;
|
||||
to_x: "elm.swallow.icon";
|
||||
relative: 1.0 1.0;
|
||||
offset: 4 -5;
|
||||
}
|
||||
rel2 {
|
||||
relative: 1.0 0.0;
|
||||
offset: -7 6;
|
||||
to_x: "elm.info";
|
||||
relative: 0.0 1.0;
|
||||
offset: -5 -5;
|
||||
}
|
||||
color: 0 0 0 255;
|
||||
text {
|
||||
font: "Sans:style=Bold,Edje-Vera-Bold";
|
||||
size: 10;
|
||||
min: 0 1;
|
||||
max: 0 1;
|
||||
align: 0.0 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
part { name: "elm.info";
|
||||
type: TEXT;
|
||||
mouse_events: 0;
|
||||
scale: 1;
|
||||
description { state: "default" 0.0;
|
||||
align: 1.0 1.0;
|
||||
fixed: 1 1;
|
||||
rel1 {
|
||||
relative: 1.0 1.0;
|
||||
offset: -5 -5;
|
||||
}
|
||||
rel2 {
|
||||
relative: 1.0 1.0;
|
||||
offset: -5 -5;
|
||||
}
|
||||
color: 0 0 0 64;
|
||||
text {
|
||||
|
@ -3143,21 +3150,55 @@ collections {
|
|||
size: 10;
|
||||
min: 1 1;
|
||||
max: 1 1;
|
||||
align: 0.0 0.0;
|
||||
align: 1.0 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
part { name: "over";
|
||||
part { name: "base0";
|
||||
mouse_events: 0;
|
||||
description { state: "default" 0.0;
|
||||
rel1.offset: 4 4;
|
||||
rel2.offset: -5 -5;
|
||||
image {
|
||||
normal: "frame_1.png";
|
||||
border: 2 2 28 22;
|
||||
middle: 0;
|
||||
rel2 {
|
||||
to_y: "elm.swallow.icon";
|
||||
relative: 1.0 0.0;
|
||||
offset: -1 -1;
|
||||
}
|
||||
fill.smooth : 0;
|
||||
image {
|
||||
normal: "bubble_1.png";
|
||||
border: 36 11 10 19;
|
||||
}
|
||||
fill.smooth: 0;
|
||||
}
|
||||
}
|
||||
part { name: "elm.swallow.content";
|
||||
type: SWALLOW;
|
||||
description { state: "default" 0.0;
|
||||
rel1 {
|
||||
to: "base0";
|
||||
offset: 9 8;
|
||||
}
|
||||
rel2 {
|
||||
to: "base0";
|
||||
offset: -10 -17;
|
||||
}
|
||||
}
|
||||
}
|
||||
part { name: "shine";
|
||||
mouse_events: 0;
|
||||
description { state: "default" 0.0;
|
||||
rel1 {
|
||||
to: "base0";
|
||||
offset: 5 4;
|
||||
}
|
||||
rel2 {
|
||||
to: "base0";
|
||||
relative: 1.0 0.5;
|
||||
offset: -6 -16;
|
||||
}
|
||||
image {
|
||||
normal: "bubble_shine.png";
|
||||
border: 5 5 5 0;
|
||||
}
|
||||
fill.smooth: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1130,7 +1130,7 @@ my_anchorblock_anchor(void *data, Evas_Object *obj, void *event_info)
|
|||
static void
|
||||
my_bt_17(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Object *win, *bg, *av, *sc, *bx, *fr;
|
||||
Evas_Object *win, *bg, *av, *sc, *bx, *bb, *ic;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
win = elm_win_add(NULL, "anchorblock", ELM_WIN_BASIC);
|
||||
|
@ -1152,10 +1152,19 @@ my_bt_17(void *data, Evas_Object *obj, void *event_info)
|
|||
elm_scroller_content_set(sc, bx);
|
||||
evas_object_show(bx);
|
||||
|
||||
fr = elm_frame_add(win);
|
||||
elm_frame_label_set(fr, "Message 3");
|
||||
evas_object_size_hint_weight_set(fr, 1.0, 0.0);
|
||||
evas_object_size_hint_align_set(fr, -1.0,-1.0);
|
||||
ic = elm_icon_add(win);
|
||||
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
|
||||
elm_icon_file_set(ic, buf, NULL);
|
||||
elm_icon_scale_set(ic, 0, 0);
|
||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
|
||||
bb = elm_bubble_add(win);
|
||||
elm_bubble_label_set(bb, "Message 3");
|
||||
elm_bubble_info_set(bb, "10:32 4/11/2008");
|
||||
elm_bubble_icon_set(bb, ic);
|
||||
evas_object_show(ic);
|
||||
evas_object_size_hint_weight_set(bb, 1.0, 0.0);
|
||||
evas_object_size_hint_align_set(bb, -1.0,-1.0);
|
||||
av = elm_anchorblock_add(win);
|
||||
elm_anchorblock_hover_style_set(av, "popout");
|
||||
elm_anchorblock_hover_parent_set(av, win);
|
||||
|
@ -1164,15 +1173,23 @@ my_bt_17(void *data, Evas_Object *obj, void *event_info)
|
|||
"list of messages. It has one <a href=tel:+614321234>+61 432 1234</a> "
|
||||
"(phone number) to click on.");
|
||||
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorblock_anchor, av);
|
||||
elm_frame_content_set(fr, av);
|
||||
elm_bubble_content_set(bb, av);
|
||||
evas_object_show(av);
|
||||
elm_box_pack_end(bx, fr);
|
||||
evas_object_show(fr);
|
||||
elm_box_pack_end(bx, bb);
|
||||
evas_object_show(bb);
|
||||
|
||||
fr = elm_frame_add(win);
|
||||
elm_frame_label_set(fr, "Message 2");
|
||||
evas_object_size_hint_weight_set(fr, 1.0, 0.0);
|
||||
evas_object_size_hint_align_set(fr, -1.0,-1.0);
|
||||
ic = elm_icon_add(win);
|
||||
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
|
||||
elm_icon_file_set(ic, buf, NULL);
|
||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
|
||||
bb = elm_bubble_add(win);
|
||||
elm_bubble_label_set(bb, "Message 2");
|
||||
elm_bubble_info_set(bb, "7:16 27/10/2008");
|
||||
elm_bubble_icon_set(bb, ic);
|
||||
evas_object_show(ic);
|
||||
evas_object_size_hint_weight_set(bb, 1.0, 0.0);
|
||||
evas_object_size_hint_align_set(bb, -1.0,-1.0);
|
||||
av = elm_anchorblock_add(win);
|
||||
elm_anchorblock_hover_style_set(av, "popout");
|
||||
elm_anchorblock_hover_parent_set(av, win);
|
||||
|
@ -1191,25 +1208,34 @@ my_bt_17(void *data, Evas_Object *obj, void *event_info)
|
|||
"web URL's too that launch the web browser and point it "
|
||||
"to that URL.");
|
||||
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorblock_anchor, av);
|
||||
elm_frame_content_set(fr, av);
|
||||
elm_bubble_content_set(bb, av);
|
||||
evas_object_show(av);
|
||||
elm_box_pack_end(bx, fr);
|
||||
evas_object_show(fr);
|
||||
elm_box_pack_end(bx, bb);
|
||||
evas_object_show(bb);
|
||||
|
||||
fr = elm_frame_add(win);
|
||||
elm_frame_label_set(fr, "Message 1");
|
||||
evas_object_size_hint_weight_set(fr, 1.0, 0.0);
|
||||
evas_object_size_hint_align_set(fr, -1.0,-1.0);
|
||||
ic = elm_icon_add(win);
|
||||
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
|
||||
elm_icon_file_set(ic, buf, NULL);
|
||||
elm_icon_scale_set(ic, 0, 0);
|
||||
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
||||
|
||||
bb = elm_bubble_add(win);
|
||||
elm_bubble_label_set(bb, "Message 1");
|
||||
elm_bubble_info_set(bb, "20:47 18/6/2008");
|
||||
elm_bubble_icon_set(bb, ic);
|
||||
evas_object_show(ic);
|
||||
evas_object_size_hint_weight_set(bb, 1.0, 0.0);
|
||||
evas_object_size_hint_align_set(bb, -1.0,-1.0);
|
||||
av = elm_anchorblock_add(win);
|
||||
elm_anchorblock_hover_style_set(av, "popout");
|
||||
elm_anchorblock_hover_parent_set(av, win);
|
||||
elm_anchorblock_text_set(av,
|
||||
"This is a short message");
|
||||
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorblock_anchor, av);
|
||||
elm_frame_content_set(fr, av);
|
||||
elm_bubble_content_set(bb, av);
|
||||
evas_object_show(av);
|
||||
elm_box_pack_end(bx, fr);
|
||||
evas_object_show(fr);
|
||||
elm_box_pack_end(bx, bb);
|
||||
evas_object_show(bb);
|
||||
|
||||
evas_object_show(sc);
|
||||
|
||||
|
|
|
@ -270,6 +270,13 @@ extern "C" {
|
|||
* "anchor,clicked" - achor called was clicked | event_info = Elm_Entry_Anchorblock_Info
|
||||
*/
|
||||
|
||||
EAPI Evas_Object *elm_bubble_add(Evas_Object *parent);
|
||||
EAPI void elm_bubble_label_set(Evas_Object *obj, const char *label);
|
||||
EAPI void elm_bubble_info_set(Evas_Object *obj, const char *label);
|
||||
EAPI void elm_bubble_content_set(Evas_Object *obj, Evas_Object *content);
|
||||
EAPI void elm_bubble_icon_set(Evas_Object *obj, Evas_Object *icon);
|
||||
/* smart callbacks called:
|
||||
*/
|
||||
|
||||
// FIXME: fixes to do
|
||||
// * current sizing tree inefficient
|
||||
|
|
|
@ -33,6 +33,7 @@ elm_clock.c \
|
|||
elm_layout.c \
|
||||
elm_hover.c \
|
||||
elm_entry.c \
|
||||
elm_bubble.c \
|
||||
elm_contact.c \
|
||||
elm_contactlist.c \
|
||||
\
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
typedef struct _Widget_Data Widget_Data;
|
||||
|
||||
struct _Widget_Data
|
||||
{
|
||||
Evas_Object *bbl;
|
||||
Evas_Object *content, *icon;
|
||||
};
|
||||
|
||||
static void _del_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 void _sub_del(void *data, Evas_Object *obj, void *event_info);
|
||||
|
||||
static void
|
||||
_del_hook(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_sizing_eval(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
||||
|
||||
edje_object_size_min_calc(wd->bbl, &minw, &minh);
|
||||
evas_object_size_hint_min_set(obj, minw, minh);
|
||||
evas_object_size_hint_max_set(obj, maxw, maxh);
|
||||
}
|
||||
|
||||
static void
|
||||
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(data);
|
||||
if (wd->content)
|
||||
edje_object_part_swallow(wd->bbl, "elm.swallow.content", wd->content);
|
||||
if (wd->icon)
|
||||
edje_object_part_swallow(wd->bbl, "elm.swallow.icon", wd->icon);
|
||||
_sizing_eval(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_sub_del(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
Evas_Object *sub = event_info;
|
||||
if (sub == wd->content)
|
||||
{
|
||||
evas_object_event_callback_del
|
||||
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
|
||||
wd->content = NULL;
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
if (sub == wd->icon)
|
||||
{
|
||||
evas_object_event_callback_del
|
||||
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
|
||||
wd->icon = NULL;
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_bubble_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *obj;
|
||||
Evas *e;
|
||||
Widget_Data *wd;
|
||||
|
||||
wd = ELM_NEW(Widget_Data);
|
||||
e = evas_object_evas_get(parent);
|
||||
obj = elm_widget_add(e);
|
||||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
|
||||
wd->bbl = edje_object_add(e);
|
||||
_elm_theme_set(wd->bbl, "bubble", "base", "default");
|
||||
elm_widget_resize_object_set(obj, wd->bbl);
|
||||
|
||||
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
||||
|
||||
_sizing_eval(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_bubble_label_set(Evas_Object *obj, const char *label)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
edje_object_part_text_set(wd->bbl, "elm.text", label);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_bubble_info_set(Evas_Object *obj, const char *label)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
edje_object_part_text_set(wd->bbl, "elm.info", label);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_bubble_content_set(Evas_Object *obj, Evas_Object *content)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if ((wd->content != content) && (wd->content))
|
||||
elm_widget_sub_object_del(obj, wd->content);
|
||||
wd->content = content;
|
||||
if (content)
|
||||
{
|
||||
elm_widget_sub_object_add(obj, content);
|
||||
edje_object_part_swallow(wd->bbl, "elm.swallow.content", content);
|
||||
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_bubble_icon_set(Evas_Object *obj, Evas_Object *icon)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if ((wd->icon != icon) && (wd->icon))
|
||||
elm_widget_sub_object_del(obj, wd->icon);
|
||||
wd->icon = icon;
|
||||
if (icon)
|
||||
{
|
||||
elm_widget_sub_object_add(obj, icon);
|
||||
edje_object_part_swallow(wd->bbl, "elm.swallow.icon", icon);
|
||||
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue