forked from enlightenment/efl
fix sub object tracking. add layout object (untested)
SVN revision: 36491
This commit is contained in:
parent
55b01e9534
commit
2eee18b46f
|
@ -506,8 +506,8 @@ my_win_main(void)
|
||||||
/* set weight to 1.0 x 1.0 == expand in x and y) */
|
/* set weight to 1.0 x 1.0 == expand in x and y) */
|
||||||
evas_object_size_hint_weight_set(bx, 1.0, 0.0);
|
evas_object_size_hint_weight_set(bx, 1.0, 0.0);
|
||||||
|
|
||||||
/* set the box ad the child int he scrolled view*/
|
/* set the box ad the content in the scrolled view*/
|
||||||
elm_scroller_child_set(sc, bx);
|
elm_scroller_content_set(sc, bx);
|
||||||
/* show the box, scroller and main box */
|
/* show the box, scroller and main box */
|
||||||
evas_object_show(bx);
|
evas_object_show(bx);
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EAPI Evas_Object *elm_scroller_add(Evas_Object *parent);
|
EAPI Evas_Object *elm_scroller_add(Evas_Object *parent);
|
||||||
EAPI void elm_scroller_child_set(Evas_Object *obj, Evas_Object *child);
|
EAPI void elm_scroller_content_set(Evas_Object *obj, Evas_Object *child);
|
||||||
/* smart callbacks elm_win objects will call:
|
/* smart callbacks elm_win objects will call:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -164,4 +164,18 @@ extern "C" {
|
||||||
* "changed" - the user changed the time
|
* "changed" - the user changed the time
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// FIXME: fixes to do
|
||||||
|
// * current sizing inefficient
|
||||||
|
// * scroller could do with page up/down/left/right buttons and and idea of
|
||||||
|
// a page size
|
||||||
|
//
|
||||||
|
// FIXME: immediate hitlist for widgets:
|
||||||
|
// HOVER: select a widget (any) and attach a hover to it - the over will hover
|
||||||
|
// on top of the hover target and accept child widgets. haver may
|
||||||
|
// optionally place something to cover the window (under the hover
|
||||||
|
// widget, above everything else)
|
||||||
|
// POPSEL: a buttont that when pressed uses a hover to display a h/v box or
|
||||||
|
// a table of options surrounding the button with scroll butons at
|
||||||
|
// the end and the ability to drag and scroll
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,7 @@ elm_toggle.c \
|
||||||
elm_frame.c \
|
elm_frame.c \
|
||||||
elm_table.c \
|
elm_table.c \
|
||||||
elm_clock.c \
|
elm_clock.c \
|
||||||
|
elm_layout.c \
|
||||||
\
|
\
|
||||||
els_pan.c \
|
els_pan.c \
|
||||||
els_pan.h \
|
els_pan.h \
|
||||||
|
|
|
@ -10,6 +10,8 @@ struct _Widget_Data
|
||||||
|
|
||||||
static void _del_hook(Evas_Object *obj);
|
static void _del_hook(Evas_Object *obj);
|
||||||
static void _sizing_eval(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
|
static void
|
||||||
_del_hook(Evas_Object *obj)
|
_del_hook(Evas_Object *obj)
|
||||||
|
@ -42,7 +44,17 @@ _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
_sizing_eval(data);
|
_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;
|
||||||
|
evas_object_event_callback_del
|
||||||
|
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
|
||||||
|
_sizing_eval(obj);
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Evas_Object *
|
EAPI Evas_Object *
|
||||||
elm_box_add(Evas_Object *parent)
|
elm_box_add(Evas_Object *parent)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +72,10 @@ elm_box_add(Evas_Object *parent)
|
||||||
elm_widget_sub_object_add(obj, wd->box);
|
elm_widget_sub_object_add(obj, wd->box);
|
||||||
evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||||
_changed_size_hints, obj);
|
_changed_size_hints, obj);
|
||||||
elm_widget_resize_object_set(obj, wd->box);
|
elm_widget_resize_object_set(obj, wd->box);
|
||||||
|
|
||||||
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +99,6 @@ elm_box_pack_start(Evas_Object *obj, Evas_Object *subobj)
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
_els_smart_box_pack_start(wd->box, subobj);
|
_els_smart_box_pack_start(wd->box, subobj);
|
||||||
elm_widget_sub_object_add(obj, subobj);
|
elm_widget_sub_object_add(obj, subobj);
|
||||||
// FIXME: track new sub obj...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -93,7 +107,6 @@ elm_box_pack_end(Evas_Object *obj, Evas_Object *subobj)
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
_els_smart_box_pack_end(wd->box, subobj);
|
_els_smart_box_pack_end(wd->box, subobj);
|
||||||
elm_widget_sub_object_add(obj, subobj);
|
elm_widget_sub_object_add(obj, subobj);
|
||||||
// FIXME: track new sub obj...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -102,7 +115,6 @@ elm_box_pack_before(Evas_Object *obj, Evas_Object *subobj, Evas_Object *before)
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
_els_smart_box_pack_before(wd->box, subobj, before);
|
_els_smart_box_pack_before(wd->box, subobj, before);
|
||||||
elm_widget_sub_object_add(obj, subobj);
|
elm_widget_sub_object_add(obj, subobj);
|
||||||
// FIXME: track new sub obj...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -111,5 +123,4 @@ elm_box_pack_after(Evas_Object *obj, Evas_Object *subobj, Evas_Object *after)
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
_els_smart_box_pack_after(wd->box, subobj, after);
|
_els_smart_box_pack_after(wd->box, subobj, after);
|
||||||
elm_widget_sub_object_add(obj, subobj);
|
elm_widget_sub_object_add(obj, subobj);
|
||||||
// FIXME: track new sub obj...
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,13 @@ typedef struct _Widget_Data Widget_Data;
|
||||||
struct _Widget_Data
|
struct _Widget_Data
|
||||||
{
|
{
|
||||||
Evas_Object *btn;
|
Evas_Object *btn;
|
||||||
|
Evas_Object *icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void _del_hook(Evas_Object *obj);
|
static void _del_hook(Evas_Object *obj);
|
||||||
static void _sizing_eval(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 _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 _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
|
static void _signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -35,10 +37,26 @@ static void
|
||||||
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
Widget_Data *wd = elm_widget_data_get(data);
|
Widget_Data *wd = elm_widget_data_get(data);
|
||||||
|
if (obj != wd->icon) return;
|
||||||
edje_object_part_swallow(wd->btn, "elm.swallow.content", obj);
|
edje_object_part_swallow(wd->btn, "elm.swallow.content", obj);
|
||||||
_sizing_eval(data);
|
_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->icon)
|
||||||
|
{
|
||||||
|
edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
|
||||||
|
evas_object_event_callback_del
|
||||||
|
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
|
||||||
|
wd->icon = NULL;
|
||||||
|
_sizing_eval(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
|
_signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +81,8 @@ elm_button_add(Evas_Object *parent)
|
||||||
_elm_theme_set(wd->btn, "button", "button");
|
_elm_theme_set(wd->btn, "button", "button");
|
||||||
edje_object_signal_callback_add(wd->btn, "elm,action,click", "", _signal_clicked, obj);
|
edje_object_signal_callback_add(wd->btn, "elm,action,click", "", _signal_clicked, obj);
|
||||||
elm_widget_resize_object_set(obj, wd->btn);
|
elm_widget_resize_object_set(obj, wd->btn);
|
||||||
|
|
||||||
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
||||||
|
|
||||||
_sizing_eval(obj);
|
_sizing_eval(obj);
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -92,11 +112,16 @@ EAPI void
|
||||||
elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
|
elm_button_icon_set(Evas_Object *obj, Evas_Object *icon)
|
||||||
{
|
{
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
edje_object_part_swallow(wd->btn, "elm.swallow.content", icon);
|
if ((wd->icon != icon) && (wd->icon))
|
||||||
edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
|
elm_widget_sub_object_del(obj, wd->icon);
|
||||||
elm_widget_sub_object_add(obj, icon);
|
wd->icon = icon;
|
||||||
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
if (icon)
|
||||||
_changed_size_hints, obj);
|
{
|
||||||
// FIXME: track new sub obj...
|
edje_object_part_swallow(wd->btn, "elm.swallow.content", icon);
|
||||||
_sizing_eval(obj);
|
edje_object_signal_emit(wd->btn, "elm,state,icon,visible", "elm");
|
||||||
|
elm_widget_sub_object_add(obj, icon);
|
||||||
|
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||||
|
_changed_size_hints, obj);
|
||||||
|
_sizing_eval(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,13 @@ typedef struct _Widget_Data Widget_Data;
|
||||||
struct _Widget_Data
|
struct _Widget_Data
|
||||||
{
|
{
|
||||||
Evas_Object *frm;
|
Evas_Object *frm;
|
||||||
|
Evas_Object *content;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void _del_hook(Evas_Object *obj);
|
static void _del_hook(Evas_Object *obj);
|
||||||
static void _sizing_eval(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 _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
|
static void
|
||||||
_del_hook(Evas_Object *obj)
|
_del_hook(Evas_Object *obj)
|
||||||
|
@ -38,6 +40,20 @@ _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
_sizing_eval(data);
|
_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Evas_Object *
|
EAPI Evas_Object *
|
||||||
elm_frame_add(Evas_Object *parent)
|
elm_frame_add(Evas_Object *parent)
|
||||||
{
|
{
|
||||||
|
@ -54,6 +70,8 @@ elm_frame_add(Evas_Object *parent)
|
||||||
wd->frm = edje_object_add(e);
|
wd->frm = edje_object_add(e);
|
||||||
_elm_theme_set(wd->frm, "frame", "frame");
|
_elm_theme_set(wd->frm, "frame", "frame");
|
||||||
elm_widget_resize_object_set(obj, wd->frm);
|
elm_widget_resize_object_set(obj, wd->frm);
|
||||||
|
|
||||||
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
||||||
|
|
||||||
_sizing_eval(obj);
|
_sizing_eval(obj);
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -71,148 +89,15 @@ EAPI void
|
||||||
elm_frame_content_set(Evas_Object *obj, Evas_Object *content)
|
elm_frame_content_set(Evas_Object *obj, Evas_Object *content)
|
||||||
{
|
{
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
|
if ((wd->content != content) && (wd->content))
|
||||||
elm_widget_sub_object_add(obj, content);
|
elm_widget_sub_object_del(obj, wd->content);
|
||||||
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
wd->content = content;
|
||||||
_changed_size_hints, obj);
|
if (content)
|
||||||
// FIXME: track new sub obj...
|
|
||||||
_sizing_eval(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
static void _elm_frame_text_set(Elm_Frame *fr, const char *text);
|
|
||||||
|
|
||||||
Elm_Frame_Class _elm_frame_class =
|
|
||||||
{
|
|
||||||
&_elm_widget_class,
|
|
||||||
ELM_OBJ_FRAME,
|
|
||||||
_elm_frame_text_set
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
_elm_frame_text_set(Elm_Frame *fr, const char *text)
|
|
||||||
{
|
|
||||||
Evas_Coord mw, mh;
|
|
||||||
|
|
||||||
edje_object_part_text_set(fr->base, "elm.text", text);
|
|
||||||
edje_object_size_min_calc(fr->base, &mw, &mh);
|
|
||||||
if ((fr->minw != mw) || (fr->minh != mh))
|
|
||||||
{
|
{
|
||||||
fr->minw = mw;
|
edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
|
||||||
fr->minh = mh;
|
elm_widget_sub_object_add(obj, content);
|
||||||
((Elm_Widget *)(fr->parent))->size_req(fr->parent, fr, fr->minw, fr->minh);
|
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||||
fr->geom_set(fr, fr->x, fr->y, fr->minw, fr->minh);
|
_changed_size_hints, obj);
|
||||||
|
_sizing_eval(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_elm_frame_size_alloc(Elm_Frame *fr, int w, int h)
|
|
||||||
{
|
|
||||||
if (w < fr->minw) w = fr->minw;
|
|
||||||
if (h < fr->minh) h = fr->minh;
|
|
||||||
fr->req.w = w;
|
|
||||||
fr->req.h = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_elm_frame_size_req(Elm_Frame *fr, Elm_Widget *child, int w, int h)
|
|
||||||
{
|
|
||||||
Evas_Coord mw, mh;
|
|
||||||
|
|
||||||
if (child)
|
|
||||||
{
|
|
||||||
Evas_Coord maxx, maxy;
|
|
||||||
|
|
||||||
child->size_alloc(child, 0, 0);
|
|
||||||
maxx = child->req.w;
|
|
||||||
maxy = child->req.h;
|
|
||||||
if (child->expand_x) maxx = 32767;
|
|
||||||
if (child->expand_y) maxy = 32767;
|
|
||||||
edje_extern_object_min_size_set(child->base,
|
|
||||||
child->req.w,
|
|
||||||
child->req.h);
|
|
||||||
edje_object_part_swallow(fr->base , "elm.swallow.content",
|
|
||||||
child->base);
|
|
||||||
edje_object_size_min_calc(fr->base, &mw, &mh);
|
|
||||||
if ((fr->minw != mw) || (fr->minh != mh))
|
|
||||||
{
|
|
||||||
fr->minw = mw;
|
|
||||||
fr->minh = mh;
|
|
||||||
((Elm_Widget *)(fr->parent))->size_req(fr->parent, fr, mw, mh);
|
|
||||||
fr->geom_set(fr, fr->x, fr->y, mw, mh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// FIXME: handle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_elm_on_child_add(void *data, Elm_Frame *fr, Elm_Cb_Type type, Elm_Obj *obj)
|
|
||||||
{
|
|
||||||
Evas_Coord mw, mh;
|
|
||||||
|
|
||||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
|
||||||
((Elm_Widget *)(obj))->size_alloc(obj, 0, 0);
|
|
||||||
((Elm_Widget *)(obj))->geom_set(obj,
|
|
||||||
((Elm_Widget *)(obj))->x,
|
|
||||||
((Elm_Widget *)(obj))->y,
|
|
||||||
((Elm_Widget *)(obj))->req.w,
|
|
||||||
((Elm_Widget *)(obj))->req.h);
|
|
||||||
edje_extern_object_min_size_set(((Elm_Widget *)(obj))->base,
|
|
||||||
((Elm_Widget *)(obj))->req.w,
|
|
||||||
((Elm_Widget *)(obj))->req.h);
|
|
||||||
edje_object_part_swallow(fr->base , "elm.swallow.content",
|
|
||||||
((Elm_Widget *)(obj))->base);
|
|
||||||
edje_object_size_min_calc(fr->base, &mw, &mh);
|
|
||||||
if ((fr->minw != mw) || (fr->minh != mh))
|
|
||||||
{
|
|
||||||
fr->minw = mw;
|
|
||||||
fr->minh = mh;
|
|
||||||
((Elm_Widget *)(fr->parent))->size_req(fr->parent, fr, mw, mh);
|
|
||||||
fr->geom_set(fr, fr->x, fr->y, mw, mh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_elm_on_child_del(void *data, Elm_Frame *fr, Elm_Cb_Type type, Elm_Obj *obj)
|
|
||||||
{
|
|
||||||
if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
|
|
||||||
// FIXME: allow for removal of child - size down
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_elm_frame_del(Elm_Frame *fr)
|
|
||||||
{
|
|
||||||
if (fr->text) evas_stringshare_del(fr->text);
|
|
||||||
((Elm_Obj_Class *)(((Elm_Frame_Class *)(fr->clas))->parent))->del(ELM_OBJ(fr));
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI Elm_Frame *
|
|
||||||
elm_frame_new(Elm_Win *win)
|
|
||||||
{
|
|
||||||
Elm_Frame *fr;
|
|
||||||
|
|
||||||
fr = ELM_NEW(Elm_Frame);
|
|
||||||
|
|
||||||
_elm_widget_init(fr);
|
|
||||||
fr->clas = &_elm_frame_class;
|
|
||||||
fr->type = ELM_OBJ_FRAME;
|
|
||||||
|
|
||||||
fr->del = _elm_frame_del;
|
|
||||||
|
|
||||||
fr->size_alloc = _elm_frame_size_alloc;
|
|
||||||
fr->size_req = _elm_frame_size_req;
|
|
||||||
|
|
||||||
fr->text_set = _elm_frame_text_set;
|
|
||||||
|
|
||||||
fr->base = edje_object_add(win->evas);
|
|
||||||
_elm_theme_set(fr->base, "frame", "frame");
|
|
||||||
fr->cb_add(fr, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
|
|
||||||
fr->cb_add(fr, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
|
|
||||||
_elm_widget_post_init(fr);
|
|
||||||
win->child_add(win, fr);
|
|
||||||
return fr;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
@ -0,0 +1,147 @@
|
||||||
|
#include <Elementary.h>
|
||||||
|
#include "elm_priv.h"
|
||||||
|
|
||||||
|
typedef struct _Widget_Data Widget_Data;
|
||||||
|
typedef struct _Subinfo Subinfo;
|
||||||
|
|
||||||
|
struct _Widget_Data
|
||||||
|
{
|
||||||
|
Evas_Object *lay;
|
||||||
|
Evas_List *subs;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Subinfo
|
||||||
|
{
|
||||||
|
const char *swallow;
|
||||||
|
Evas_Object *obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
while (wd->subs)
|
||||||
|
{
|
||||||
|
Subinfo *si = wd->subs->data;
|
||||||
|
wd->subs = evas_list_remove_list(wd->subs, wd->subs);
|
||||||
|
evas_stringshare_del(si->swallow);
|
||||||
|
free(si);
|
||||||
|
}
|
||||||
|
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->lay, &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);
|
||||||
|
Evas_List *l;
|
||||||
|
for (l = wd->subs; l; l = l->next)
|
||||||
|
{
|
||||||
|
Subinfo *si = l->data;
|
||||||
|
if (si->obj == obj)
|
||||||
|
{
|
||||||
|
edje_object_part_swallow(wd->lay, si->swallow, obj);
|
||||||
|
_sizing_eval(obj);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
Evas_List *l;
|
||||||
|
|
||||||
|
for (l = wd->subs; l; l = l->next)
|
||||||
|
{
|
||||||
|
Subinfo *si = l->data;
|
||||||
|
if (si->obj == sub)
|
||||||
|
{
|
||||||
|
evas_object_event_callback_del
|
||||||
|
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
|
||||||
|
wd->subs = evas_list_remove_list(wd->subs, l);
|
||||||
|
evas_stringshare_del(si->swallow);
|
||||||
|
free(si);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Evas_Object *
|
||||||
|
elm_layout_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->lay = edje_object_add(e);
|
||||||
|
elm_widget_resize_object_set(obj, wd->lay);
|
||||||
|
|
||||||
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
||||||
|
|
||||||
|
_sizing_eval(obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
elm_layout_file_set(Evas_Object *obj, const char *file, const char *group)
|
||||||
|
{
|
||||||
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
|
_elm_theme_set(wd->lay, file, group);
|
||||||
|
_sizing_eval(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
|
||||||
|
{
|
||||||
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
|
Subinfo *si;
|
||||||
|
Evas_List *l;
|
||||||
|
|
||||||
|
for (l = wd->subs; l; l = l->next)
|
||||||
|
{
|
||||||
|
si = l->data;
|
||||||
|
if (!strcmp(swallow, si->swallow))
|
||||||
|
{
|
||||||
|
if (content == si->obj) return;
|
||||||
|
elm_widget_sub_object_del(obj, si->obj);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (content)
|
||||||
|
{
|
||||||
|
edje_object_part_swallow(wd->lay, swallow, content);
|
||||||
|
elm_widget_sub_object_add(obj, content);
|
||||||
|
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||||
|
_changed_size_hints, obj);
|
||||||
|
si = ELM_NEW(Subinfo);
|
||||||
|
si->swallow = evas_stringshare_add(swallow);
|
||||||
|
si->obj = content;
|
||||||
|
wd->subs = evas_list_append(wd->subs, si);
|
||||||
|
_sizing_eval(obj);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,11 +6,12 @@ typedef struct _Widget_Data Widget_Data;
|
||||||
struct _Widget_Data
|
struct _Widget_Data
|
||||||
{
|
{
|
||||||
Evas_Object *scr;
|
Evas_Object *scr;
|
||||||
Evas_Object *child;
|
Evas_Object *content;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void _del_hook(Evas_Object *obj);
|
static void _del_hook(Evas_Object *obj);
|
||||||
static void _sizing_eval(Evas_Object *obj);
|
static void _sizing_eval(Evas_Object *obj);
|
||||||
|
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_del_hook(Evas_Object *obj)
|
_del_hook(Evas_Object *obj)
|
||||||
|
@ -26,9 +27,9 @@ _sizing_eval(Evas_Object *obj)
|
||||||
Evas_Coord vw, vh, minw, minh, maxw, maxh;
|
Evas_Coord vw, vh, minw, minh, maxw, maxh;
|
||||||
double xw, xy;
|
double xw, xy;
|
||||||
|
|
||||||
evas_object_size_hint_min_get(wd->child, &minw, &minh);
|
evas_object_size_hint_min_get(wd->content, &minw, &minh);
|
||||||
evas_object_size_hint_max_get(wd->child, &maxw, &maxh);
|
evas_object_size_hint_max_get(wd->content, &maxw, &maxh);
|
||||||
evas_object_size_hint_weight_get(wd->child, &xw, &xy);
|
evas_object_size_hint_weight_get(wd->content, &xw, &xy);
|
||||||
elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
|
elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
|
||||||
if (xw > 0.0)
|
if (xw > 0.0)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +43,7 @@ _sizing_eval(Evas_Object *obj)
|
||||||
else if ((maxh > 0) && (vh > maxh)) vh = maxh;
|
else if ((maxh > 0) && (vh > maxh)) vh = maxh;
|
||||||
}
|
}
|
||||||
else if (minh > 0) vh = minh;
|
else if (minh > 0) vh = minh;
|
||||||
evas_object_resize(wd->child, vw, vh);
|
evas_object_resize(wd->content, vw, vh);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -51,6 +52,20 @@ _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
_sizing_eval(data);
|
_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
|
@ -77,20 +92,26 @@ elm_scroller_add(Evas_Object *parent)
|
||||||
edje_object_size_min_calc(wd->scr, &minw, &minh);
|
edje_object_size_min_calc(wd->scr, &minw, &minh);
|
||||||
evas_object_size_hint_min_set(obj, minw, minh);
|
evas_object_size_hint_min_set(obj, minw, minh);
|
||||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
|
||||||
|
|
||||||
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
||||||
|
|
||||||
_sizing_eval(obj);
|
_sizing_eval(obj);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_scroller_child_set(Evas_Object *obj, Evas_Object *child)
|
elm_scroller_content_set(Evas_Object *obj, Evas_Object *content)
|
||||||
{
|
{
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
wd->child = child;
|
if ((wd->content != content) && (wd->content))
|
||||||
elm_smart_scroller_child_set(wd->scr, child);
|
elm_widget_sub_object_del(obj, wd->content);
|
||||||
evas_object_event_callback_add(child, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
wd->content = content;
|
||||||
_changed_size_hints, obj);
|
if (content)
|
||||||
elm_widget_sub_object_add(obj, child);
|
{
|
||||||
// FIXME: track new sub obj...
|
elm_smart_scroller_child_set(wd->scr, content);
|
||||||
_sizing_eval(obj);
|
evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||||
|
_changed_size_hints, obj);
|
||||||
|
elm_widget_sub_object_add(obj, content);
|
||||||
|
_sizing_eval(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ struct _Widget_Data
|
||||||
|
|
||||||
static void _del_hook(Evas_Object *obj);
|
static void _del_hook(Evas_Object *obj);
|
||||||
static void _sizing_eval(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
|
static void
|
||||||
_del_hook(Evas_Object *obj)
|
_del_hook(Evas_Object *obj)
|
||||||
|
@ -43,6 +45,16 @@ _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
_sizing_eval(data);
|
_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;
|
||||||
|
evas_object_event_callback_del
|
||||||
|
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
|
||||||
|
_sizing_eval(obj);
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Evas_Object *
|
EAPI Evas_Object *
|
||||||
elm_table_add(Evas_Object *parent)
|
elm_table_add(Evas_Object *parent)
|
||||||
{
|
{
|
||||||
|
@ -61,6 +73,9 @@ elm_table_add(Evas_Object *parent)
|
||||||
evas_object_event_callback_add(wd->tbl, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
evas_object_event_callback_add(wd->tbl, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||||
_changed_size_hints, obj);
|
_changed_size_hints, obj);
|
||||||
elm_widget_resize_object_set(obj, wd->tbl);
|
elm_widget_resize_object_set(obj, wd->tbl);
|
||||||
|
|
||||||
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,5 +92,4 @@ elm_table_pack(Evas_Object *obj, Evas_Object *subobj, int x, int y, int w, int h
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
_els_smart_table_pack(wd->tbl, subobj, x, y, w, h);
|
_els_smart_table_pack(wd->tbl, subobj, x, y, w, h);
|
||||||
elm_widget_sub_object_add(obj, subobj);
|
elm_widget_sub_object_add(obj, subobj);
|
||||||
// FIXME: track new sub obj...
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ typedef struct _Widget_Data Widget_Data;
|
||||||
struct _Widget_Data
|
struct _Widget_Data
|
||||||
{
|
{
|
||||||
Evas_Object *tgl;
|
Evas_Object *tgl;
|
||||||
|
Evas_Object *icon;
|
||||||
Evas_Bool state;
|
Evas_Bool state;
|
||||||
Evas_Bool *statep;
|
Evas_Bool *statep;
|
||||||
};
|
};
|
||||||
|
@ -13,6 +14,7 @@ struct _Widget_Data
|
||||||
static void _del_hook(Evas_Object *obj);
|
static void _del_hook(Evas_Object *obj);
|
||||||
static void _sizing_eval(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 _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 _signal_toggle_off(void *data, Evas_Object *obj, const char *emission, const char *source);
|
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 _signal_toggle_on(void *data, Evas_Object *obj, const char *emission, const char *source);
|
||||||
|
|
||||||
|
@ -38,10 +40,26 @@ static void
|
||||||
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
{
|
{
|
||||||
Widget_Data *wd = elm_widget_data_get(data);
|
Widget_Data *wd = elm_widget_data_get(data);
|
||||||
|
if (obj != wd->icon) return;
|
||||||
edje_object_part_swallow(wd->tgl, "elm.swallow.content", obj);
|
edje_object_part_swallow(wd->tgl, "elm.swallow.content", obj);
|
||||||
_sizing_eval(data);
|
_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->icon)
|
||||||
|
{
|
||||||
|
edje_object_signal_emit(wd->tgl, "elm,state,icon,hidden", "elm");
|
||||||
|
evas_object_event_callback_del
|
||||||
|
(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints);
|
||||||
|
wd->icon = NULL;
|
||||||
|
_sizing_eval(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_signal_toggle_off(void *data, Evas_Object *obj, const char *emission, const char *source)
|
_signal_toggle_off(void *data, Evas_Object *obj, const char *emission, const char *source)
|
||||||
{
|
{
|
||||||
|
@ -78,6 +96,8 @@ elm_toggle_add(Evas_Object *parent)
|
||||||
edje_object_signal_callback_add(wd->tgl, "elm,action,toggle,on", "", _signal_toggle_on, obj);
|
edje_object_signal_callback_add(wd->tgl, "elm,action,toggle,on", "", _signal_toggle_on, obj);
|
||||||
edje_object_signal_callback_add(wd->tgl, "elm,action,toggle,off", "", _signal_toggle_off, obj);
|
edje_object_signal_callback_add(wd->tgl, "elm,action,toggle,off", "", _signal_toggle_off, obj);
|
||||||
elm_widget_resize_object_set(obj, wd->tgl);
|
elm_widget_resize_object_set(obj, wd->tgl);
|
||||||
|
|
||||||
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
||||||
|
|
||||||
_sizing_eval(obj);
|
_sizing_eval(obj);
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -107,13 +127,18 @@ EAPI void
|
||||||
elm_toggle_icon_set(Evas_Object *obj, Evas_Object *icon)
|
elm_toggle_icon_set(Evas_Object *obj, Evas_Object *icon)
|
||||||
{
|
{
|
||||||
Widget_Data *wd = elm_widget_data_get(obj);
|
Widget_Data *wd = elm_widget_data_get(obj);
|
||||||
edje_object_part_swallow(wd->tgl, "elm.swallow.content", icon);
|
if ((wd->icon != icon) && (wd->icon))
|
||||||
edje_object_signal_emit(wd->tgl, "elm,state,icon,visible", "elm");
|
elm_widget_sub_object_del(obj, wd->icon);
|
||||||
elm_widget_sub_object_add(obj, icon);
|
wd->icon = icon;
|
||||||
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
if (icon)
|
||||||
_changed_size_hints, obj);
|
{
|
||||||
// FIXME: track new sub obj...
|
edje_object_part_swallow(wd->tgl, "elm.swallow.content", icon);
|
||||||
_sizing_eval(obj);
|
edje_object_signal_emit(wd->tgl, "elm,state,icon,visible", "elm");
|
||||||
|
elm_widget_sub_object_add(obj, icon);
|
||||||
|
evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||||
|
_changed_size_hints, obj);
|
||||||
|
_sizing_eval(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
|
|
@ -146,6 +146,7 @@ elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj)
|
||||||
sd->parent_obj = obj;
|
sd->parent_obj = obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
evas_object_smart_callback_call(obj, "sub-object-add", sobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -157,6 +158,7 @@ elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj)
|
||||||
{
|
{
|
||||||
if (elm_widget_can_focus_get(sobj)) sd->child_can_focus = 0;
|
if (elm_widget_can_focus_get(sobj)) sd->child_can_focus = 0;
|
||||||
}
|
}
|
||||||
|
evas_object_smart_callback_call(obj, "sub-object-del", sobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -167,6 +169,7 @@ elm_widget_resize_object_set(Evas_Object *obj, Evas_Object *sobj)
|
||||||
sd->resize_obj = sobj;
|
sd->resize_obj = sobj;
|
||||||
evas_object_smart_member_add(sobj, obj);
|
evas_object_smart_member_add(sobj, obj);
|
||||||
_smart_reconfigure(sd);
|
_smart_reconfigure(sd);
|
||||||
|
evas_object_smart_callback_call(obj, "sub-object-add", sobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
|
Loading…
Reference in New Issue