forked from enlightenment/efl
Hacky move to evas_box
Evas_Box layouts don't get along with what elm expects, so for now, it's using the old els_box calculate functions as a custom layout. SVN revision: 42863
This commit is contained in:
parent
6b56241c3a
commit
a95ba2636d
|
@ -21,6 +21,8 @@ typedef struct _Widget_Data Widget_Data;
|
|||
struct _Widget_Data
|
||||
{
|
||||
Evas_Object *box;
|
||||
Eina_Bool horizontal:1;
|
||||
Eina_Bool homogeneous:1;
|
||||
};
|
||||
|
||||
static void _del_hook(Evas_Object *obj);
|
||||
|
@ -70,6 +72,14 @@ _sub_del(void *data, Evas_Object *obj, void *event_info)
|
|||
_sizing_eval(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
|
||||
{
|
||||
Widget_Data *wd = data;
|
||||
|
||||
_els_box_layout(o, priv, wd->horizontal, wd->homogeneous);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new box to the parent
|
||||
|
@ -94,7 +104,10 @@ elm_box_add(Evas_Object *parent)
|
|||
elm_widget_data_set(obj, wd);
|
||||
elm_widget_del_hook_set(obj, _del_hook);
|
||||
|
||||
wd->box = _els_smart_box_add(e);
|
||||
wd->box = evas_object_box_add(e);
|
||||
/*evas_object_box_layout_set(wd->box, evas_object_box_layout_vertical,
|
||||
NULL, NULL);*/
|
||||
evas_object_box_layout_set(wd->box, _layout, wd, NULL);
|
||||
evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_changed_size_hints, obj);
|
||||
elm_widget_resize_object_set(obj, wd->box);
|
||||
|
@ -120,7 +133,26 @@ EAPI void
|
|||
elm_box_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_orientation_set(wd->box, horizontal);
|
||||
wd->horizontal = !!horizontal;
|
||||
evas_object_smart_calculate(wd->box);
|
||||
/*if (wd->horizontal)
|
||||
{
|
||||
if (wd->homogeneous)
|
||||
evas_object_box_layout_set(wd->box,
|
||||
evas_object_box_layout_homogeneous_horizontal, NULL, NULL);
|
||||
else
|
||||
evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
|
||||
NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wd->homogeneous)
|
||||
evas_object_box_layout_set(wd->box,
|
||||
evas_object_box_layout_homogeneous_vertical, NULL, NULL);
|
||||
else
|
||||
evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
|
||||
NULL, NULL);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,7 +170,26 @@ EAPI void
|
|||
elm_box_homogenous_set(Evas_Object *obj, Eina_Bool homogenous)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_homogenous_set(wd->box, homogenous);
|
||||
wd->homogeneous = !!homogenous;
|
||||
evas_object_smart_calculate(wd->box);
|
||||
/*if (wd->horizontal)
|
||||
{
|
||||
if (wd->homogeneous)
|
||||
evas_object_box_layout_set(wd->box,
|
||||
evas_object_box_layout_homogeneous_horizontal, NULL, NULL);
|
||||
else
|
||||
evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
|
||||
NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wd->homogeneous)
|
||||
evas_object_box_layout_set(wd->box,
|
||||
evas_object_box_layout_homogeneous_vertical, NULL, NULL);
|
||||
else
|
||||
evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
|
||||
NULL, NULL);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,7 +208,7 @@ elm_box_pack_start(Evas_Object *obj, Evas_Object *subobj)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
elm_widget_sub_object_add(obj, subobj);
|
||||
_els_smart_box_pack_start(wd->box, subobj);
|
||||
evas_object_box_prepend(wd->box, subobj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,7 +227,7 @@ elm_box_pack_end(Evas_Object *obj, Evas_Object *subobj)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
elm_widget_sub_object_add(obj, subobj);
|
||||
_els_smart_box_pack_end(wd->box, subobj);
|
||||
evas_object_box_append(wd->box, subobj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,7 +249,7 @@ elm_box_pack_before(Evas_Object *obj, Evas_Object *subobj, Evas_Object *before)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
elm_widget_sub_object_add(obj, subobj);
|
||||
_els_smart_box_pack_before(wd->box, subobj, before);
|
||||
evas_object_box_insert_before(wd->box, subobj, before);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -220,7 +271,7 @@ elm_box_pack_after(Evas_Object *obj, Evas_Object *subobj, Evas_Object *after)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
elm_widget_sub_object_add(obj, subobj);
|
||||
_els_smart_box_pack_after(wd->box, subobj, after);
|
||||
evas_object_box_insert_after(wd->box, subobj, after);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,7 +287,7 @@ EAPI void
|
|||
elm_box_clear(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_clear(wd->box);
|
||||
evas_object_box_remove_all(wd->box, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,7 +304,7 @@ EAPI void
|
|||
elm_box_unpack(Evas_Object *obj, Evas_Object *subobj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_unpack(wd->box, subobj);
|
||||
evas_object_box_remove(wd->box, subobj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -270,5 +321,5 @@ EAPI void
|
|||
elm_box_unpack_all(Evas_Object *obj)
|
||||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
_els_smart_box_unpack_all(wd->box);
|
||||
evas_object_box_remove_all(wd->box, 0);
|
||||
}
|
||||
|
|
|
@ -175,9 +175,9 @@ elm_carousel_add(Evas_Object *parent)
|
|||
|
||||
wd->icon_size = 32;
|
||||
|
||||
wd->bx = _els_smart_box_add(e);
|
||||
_els_smart_box_orientation_set(wd->bx, 1);
|
||||
_els_smart_box_homogenous_set(wd->bx, 1);
|
||||
wd->bx = evas_object_box_add(e);
|
||||
evas_object_box_layout_set(wd->bx,
|
||||
evas_object_box_layout_homogeneous_horizontal, NULL, NULL);
|
||||
elm_widget_sub_object_add(obj, wd->bx);
|
||||
elm_smart_scroller_child_set(wd->scr, wd->bx);
|
||||
evas_object_show(wd->bx);
|
||||
|
@ -223,7 +223,7 @@ elm_carousel_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, vo
|
|||
evas_object_size_hint_align_set(it->base, -1.0, -1.0);
|
||||
evas_object_size_hint_min_set(it->base, mw, mh);
|
||||
evas_object_size_hint_max_set(it->base, 9999, mh);
|
||||
_els_smart_box_pack_end(wd->bx, it->base);
|
||||
evas_object_box_append(wd->bx, it->base);
|
||||
evas_object_show(it->base);
|
||||
_sizing_eval(obj);
|
||||
return it;
|
||||
|
|
|
@ -66,6 +66,14 @@ _del_hook(Evas_Object *obj)
|
|||
free(wd);
|
||||
}
|
||||
|
||||
static void
|
||||
_layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
|
||||
{
|
||||
Widget_Data *wd = data;
|
||||
|
||||
_els_box_layout(o, priv, wd->horizontal, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_theme_hook(Evas_Object *obj)
|
||||
{
|
||||
|
@ -83,9 +91,8 @@ _theme_hook(Evas_Object *obj)
|
|||
{
|
||||
if (!wd->bx[1])
|
||||
{
|
||||
wd->bx[1] = _els_smart_box_add(evas_object_evas_get(wd->base));
|
||||
_els_smart_box_orientation_set(wd->bx[1], wd->horizontal);
|
||||
_els_smart_box_homogenous_set(wd->bx[1], 1);
|
||||
wd->bx[1] = evas_object_box_add(wd->base);
|
||||
evas_object_box_layout_set(wd->bx[1], _layout, wd, NULL);
|
||||
elm_widget_sub_object_add(obj, wd->bx[1]);
|
||||
}
|
||||
edje_object_part_swallow(wd->base, "elm.swallow.index.1", wd->bx[1]);
|
||||
|
@ -209,7 +216,7 @@ _index_box_auto_fill(Evas_Object *obj, Evas_Object *box, int level)
|
|||
evas_object_size_hint_weight_set(o, 1.0, 1.0);
|
||||
evas_object_size_hint_align_set(o, -1.0, -1.0);
|
||||
elm_widget_sub_object_add(obj, o);
|
||||
_els_smart_box_pack_end(box, o);
|
||||
evas_object_box_append(box, o);
|
||||
stacking = edje_object_data_get(o, "stacking");
|
||||
if (stacking)
|
||||
{
|
||||
|
@ -528,18 +535,16 @@ elm_index_add(Evas_Object *parent)
|
|||
elm_widget_sub_object_add(obj, o);
|
||||
}
|
||||
|
||||
wd->bx[0] = _els_smart_box_add(e);
|
||||
_els_smart_box_orientation_set(wd->bx[0], 0);
|
||||
_els_smart_box_homogenous_set(wd->bx[0], 1);
|
||||
wd->bx[0] = evas_object_box_add(e);
|
||||
evas_object_box_layout_set(wd->bx[0], _layout, wd, NULL);
|
||||
elm_widget_sub_object_add(obj, wd->bx[0]);
|
||||
edje_object_part_swallow(wd->base, "elm.swallow.index.0", wd->bx[0]);
|
||||
evas_object_show(wd->bx[0]);
|
||||
|
||||
if (edje_object_part_exists(wd->base, "elm.swallow.index.1"))
|
||||
{
|
||||
wd->bx[1] = _els_smart_box_add(e);
|
||||
_els_smart_box_orientation_set(wd->bx[1], 0);
|
||||
_els_smart_box_homogenous_set(wd->bx[1], 1);
|
||||
wd->bx[1] = evas_object_box_add(e);
|
||||
evas_object_box_layout_set(wd->bx[1], _layout, wd, NULL);
|
||||
elm_widget_sub_object_add(obj, wd->bx[1]);
|
||||
edje_object_part_swallow(wd->base, "elm.swallow.index.1", wd->bx[1]);
|
||||
evas_object_show(wd->bx[1]);
|
||||
|
|
|
@ -9,6 +9,7 @@ struct _Widget_Data
|
|||
Eina_List *items;
|
||||
int icon_size;
|
||||
Eina_Bool scrollable : 1;
|
||||
Eina_Bool homogeneous : 1;
|
||||
};
|
||||
|
||||
struct _Elm_Toolbar_Item
|
||||
|
@ -159,6 +160,7 @@ _sizing_eval(Evas_Object *obj)
|
|||
Evas_Coord w, h;
|
||||
|
||||
if (!wd) return;
|
||||
evas_object_smart_calculate(wd->bx);
|
||||
edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
|
||||
&minw, &minh);
|
||||
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
||||
|
@ -217,6 +219,14 @@ _select(void *data, Evas_Object *obj, const char *emission, const char *source)
|
|||
_item_select(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
|
||||
{
|
||||
Widget_Data *wd = data;
|
||||
|
||||
_els_box_layout(o, priv, 1, wd->homogeneous);
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_toolbar_add(Evas_Object *parent)
|
||||
{
|
||||
|
@ -244,10 +254,10 @@ elm_toolbar_add(Evas_Object *parent)
|
|||
|
||||
wd->icon_size = 32;
|
||||
wd->scrollable = EINA_TRUE;
|
||||
wd->homogeneous = EINA_TRUE;
|
||||
|
||||
wd->bx = _els_smart_box_add(e);
|
||||
_els_smart_box_orientation_set(wd->bx, 1);
|
||||
_els_smart_box_homogenous_set(wd->bx, 1);
|
||||
wd->bx = evas_object_box_add(e);
|
||||
evas_object_box_layout_set(wd->bx, _layout, wd, NULL);
|
||||
elm_widget_sub_object_add(obj, wd->bx);
|
||||
elm_smart_scroller_child_set(wd->scr, wd->bx);
|
||||
evas_object_show(wd->bx);
|
||||
|
@ -320,7 +330,7 @@ elm_toolbar_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, voi
|
|||
evas_object_size_hint_align_set(it->base, -1.0, -1.0);
|
||||
evas_object_size_hint_min_set(it->base, mw, mh);
|
||||
evas_object_size_hint_max_set(it->base, 9999, mh);
|
||||
_els_smart_box_pack_end(wd->bx, it->base);
|
||||
evas_object_box_append(wd->bx, it->base);
|
||||
evas_object_show(it->base);
|
||||
_sizing_eval(obj);
|
||||
return it;
|
||||
|
@ -417,6 +427,7 @@ elm_toolbar_homogenous_set(Evas_Object *obj, Eina_Bool homogenous)
|
|||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
|
||||
if (!wd) return;
|
||||
_els_smart_box_homogenous_set(wd->bx, homogenous);
|
||||
wd->homogeneous = !!homogenous;
|
||||
evas_object_smart_calculate(wd->bx);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,255 +1,53 @@
|
|||
#include <Elementary.h>
|
||||
#include "elm_priv.h"
|
||||
|
||||
typedef struct _Smart_Data Smart_Data;
|
||||
typedef struct _Box_Item Box_Item;
|
||||
|
||||
struct _Smart_Data
|
||||
static void
|
||||
_smart_extents_calculate(Evas_Object *box, Evas_Object_Box_Data *priv, int horizontal, int homogeneous)
|
||||
{
|
||||
Evas_Coord x, y, w, h;
|
||||
Evas_Object *obj, *clip;
|
||||
Eina_Bool changed : 1;
|
||||
Eina_Bool horizontal : 1;
|
||||
Eina_Bool homogenous : 1;
|
||||
Eina_Bool deleting : 1;
|
||||
Eina_List *items;
|
||||
};
|
||||
|
||||
/* local subsystem functions */
|
||||
static void _smart_adopt(Smart_Data *sd, Evas_Object *obj);
|
||||
static void _smart_disown(Evas_Object *obj);
|
||||
static void _smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _smart_item_changed_size_hints_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _smart_reconfigure(Smart_Data *sd);
|
||||
static void _smart_extents_calculate(Smart_Data *sd);
|
||||
static void _smart_init(void);
|
||||
static void _smart_add(Evas_Object *obj);
|
||||
static void _smart_del(Evas_Object *obj);
|
||||
static void _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
|
||||
static void _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
|
||||
static void _smart_show(Evas_Object *obj);
|
||||
static void _smart_hide(Evas_Object *obj);
|
||||
static void _smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
|
||||
static void _smart_clip_set(Evas_Object *obj, Evas_Object *clip);
|
||||
static void _smart_clip_unset(Evas_Object *obj);
|
||||
|
||||
/* local subsystem globals */
|
||||
static Evas_Smart *_e_smart = NULL;
|
||||
|
||||
/* externally accessible functions */
|
||||
Evas_Object *
|
||||
_els_smart_box_add(Evas *evas)
|
||||
{
|
||||
_smart_init();
|
||||
return evas_object_smart_add(evas, _e_smart);
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_box_orientation_set(Evas_Object *obj, int horizontal)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if (sd->horizontal == horizontal) return;
|
||||
sd->horizontal = horizontal;
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
int
|
||||
_els_smart_box_orientation_get(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return 0;
|
||||
return sd->horizontal;
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_box_homogenous_set(Evas_Object *obj, int homogenous)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if (sd->homogenous == homogenous) return;
|
||||
sd->homogenous = homogenous;
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
int
|
||||
_els_smart_box_pack_start(Evas_Object *obj, Evas_Object *child)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
if (!child) return 0;
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return 0;
|
||||
_smart_adopt(sd, child);
|
||||
sd->items = eina_list_prepend(sd->items, child);
|
||||
_smart_reconfigure(sd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_els_smart_box_pack_end(Evas_Object *obj, Evas_Object *child)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
if (!child) return 0;
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return 0;
|
||||
_smart_adopt(sd, child);
|
||||
sd->items = eina_list_append(sd->items, child);
|
||||
_smart_reconfigure(sd);
|
||||
return eina_list_count(sd->items) - 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_els_smart_box_find(const Smart_Data *sd, const Evas_Object *child)
|
||||
{
|
||||
int i = 0;
|
||||
Evas_Coord minw, minh, maxw, maxh, mnw, mnh;
|
||||
const Eina_List *l;
|
||||
const Evas_Object *oitr;
|
||||
Evas_Object_Box_Option *opt;
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, oitr)
|
||||
/* FIXME: need to calc max */
|
||||
minw = 0;
|
||||
minh = 0;
|
||||
maxw = -1;
|
||||
maxh = -1;
|
||||
if (homogeneous)
|
||||
{
|
||||
if (oitr == child) return i;
|
||||
i++;
|
||||
EINA_LIST_FOREACH(priv->children, l, opt)
|
||||
{
|
||||
evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
|
||||
if (minh < mnh) minh = mnh;
|
||||
if (minw < mnw) minw = mnw;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
_els_smart_box_pack_before(Evas_Object *obj, Evas_Object *child, Evas_Object *before)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
if (!child) return 0;
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return 0;
|
||||
_smart_adopt(sd, child);
|
||||
sd->items = eina_list_prepend_relative(sd->items, child, before);
|
||||
_smart_reconfigure(sd);
|
||||
return _els_smart_box_find(sd, child);
|
||||
}
|
||||
|
||||
int
|
||||
_els_smart_box_pack_after(Evas_Object *obj, Evas_Object *child, Evas_Object *after)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
if (!child) return 0;
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return 0;
|
||||
_smart_adopt(sd, child);
|
||||
sd->items = eina_list_append_relative(sd->items, child, after);
|
||||
_smart_reconfigure(sd);
|
||||
return _els_smart_box_find(sd, child);
|
||||
if (horizontal)
|
||||
minw *= eina_list_count(priv->children);
|
||||
else
|
||||
minh *= eina_list_count(priv->children);
|
||||
}
|
||||
else
|
||||
{
|
||||
EINA_LIST_FOREACH(priv->children, l, opt)
|
||||
{
|
||||
evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
|
||||
if (horizontal)
|
||||
{
|
||||
if (minh < mnh) minh = mnh;
|
||||
minw += mnw;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (minw < mnw) minw = mnw;
|
||||
minh += mnh;
|
||||
}
|
||||
}
|
||||
}
|
||||
evas_object_size_hint_min_set(box, minw, minh);
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_box_unpack(Evas_Object *obj, Evas_Object *child)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
if (!obj) return;
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
sd->items = eina_list_remove(sd->items, child);
|
||||
elm_widget_sub_object_del(obj, child);
|
||||
_smart_disown(child);
|
||||
if (!sd->deleting)
|
||||
{
|
||||
if (!evas_object_clipees_get(sd->clip))
|
||||
evas_object_hide(sd->clip);
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_box_unpack_all(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
while (sd->items)
|
||||
{
|
||||
Evas_Object *child = sd->items->data;
|
||||
|
||||
_els_smart_box_unpack(obj, child);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_els_smart_box_clear(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
while (sd->items)
|
||||
{
|
||||
Evas_Object *child = sd->items->data;
|
||||
|
||||
evas_object_del(child);
|
||||
}
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_smart_adopt(Smart_Data *sd, Evas_Object *obj)
|
||||
{
|
||||
evas_object_clip_set(obj, sd->clip);
|
||||
evas_object_smart_member_add(obj, sd->obj);
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
|
||||
_smart_item_del_hook, NULL);
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_smart_item_changed_size_hints_hook, NULL);
|
||||
if ((!evas_object_visible_get(sd->clip)) &&
|
||||
(evas_object_visible_get(sd->obj)))
|
||||
evas_object_show(sd->clip);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_disown(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(evas_object_smart_parent_get(obj));
|
||||
if (!sd) return;
|
||||
if (sd->items)
|
||||
{
|
||||
if (evas_object_visible_get(sd->clip))
|
||||
evas_object_hide(sd->clip);
|
||||
}
|
||||
evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
|
||||
_smart_item_del_hook);
|
||||
evas_object_event_callback_del(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_smart_item_changed_size_hints_hook);
|
||||
evas_object_smart_member_del(obj);
|
||||
evas_object_clip_unset(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
_els_smart_box_unpack(evas_object_smart_parent_get(obj), obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_item_changed_size_hints_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(evas_object_smart_parent_get(obj));
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_reconfigure(Smart_Data *sd)
|
||||
_els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous)
|
||||
{
|
||||
Evas_Coord x, y, w, h, xx, yy;
|
||||
const Eina_List *l;
|
||||
|
@ -257,17 +55,15 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
Evas_Coord minw, minh, wdif, hdif;
|
||||
int count = 0, expand = 0;
|
||||
double ax, ay;
|
||||
Evas_Object_Box_Option *opt;
|
||||
|
||||
_smart_extents_calculate(sd);
|
||||
_smart_extents_calculate(o, priv, horizontal, homogeneous);
|
||||
|
||||
x = sd->x;
|
||||
y = sd->y;
|
||||
w = sd->w;
|
||||
h = sd->h;
|
||||
evas_object_geometry_get(o, &x, &y, &w, &h);
|
||||
|
||||
evas_object_size_hint_min_get(sd->obj, &minw, &minh);
|
||||
evas_object_size_hint_align_get(sd->obj, &ax, &ay);
|
||||
count = eina_list_count(sd->items);
|
||||
evas_object_size_hint_min_get(o, &minw, &minh);
|
||||
evas_object_size_hint_align_get(o, &ax, &ay);
|
||||
count = eina_list_count(priv->children);
|
||||
if (w < minw)
|
||||
{
|
||||
x = x + ((w - minw) * (1.0 - ax));
|
||||
|
@ -278,12 +74,12 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
y = y + ((h - minh) * (1.0 - ay));
|
||||
h = minh;
|
||||
}
|
||||
EINA_LIST_FOREACH(sd->items, l, obj)
|
||||
EINA_LIST_FOREACH(priv->children, l, opt)
|
||||
{
|
||||
double wx, wy;
|
||||
|
||||
evas_object_size_hint_weight_get(obj, &wx, &wy);
|
||||
if (sd->horizontal)
|
||||
evas_object_size_hint_weight_get(opt->obj, &wx, &wy);
|
||||
if (horizontal)
|
||||
{
|
||||
if (wx > 0.0) expand++;
|
||||
}
|
||||
|
@ -294,8 +90,8 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
}
|
||||
if (expand == 0)
|
||||
{
|
||||
evas_object_size_hint_align_get(sd->obj, &ax, &ay);
|
||||
if (sd->horizontal)
|
||||
evas_object_size_hint_align_get(o, &ax, &ay);
|
||||
if (horizontal)
|
||||
{
|
||||
x += (double)(w - minw) * ax;
|
||||
w = minw;
|
||||
|
@ -310,12 +106,13 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
hdif = h - minh;
|
||||
xx = x;
|
||||
yy = y;
|
||||
EINA_LIST_FOREACH(sd->items, l, obj)
|
||||
EINA_LIST_FOREACH(priv->children, l, opt)
|
||||
{
|
||||
Evas_Coord mnw, mnh, mxw, mxh;
|
||||
double wx, wy;
|
||||
int fw, fh, xw, xh;
|
||||
|
||||
obj = opt->obj;
|
||||
evas_object_size_hint_align_get(obj, &ax, &ay);
|
||||
evas_object_size_hint_weight_get(obj, &wx, &wy);
|
||||
evas_object_size_hint_min_get(obj, &mnw, &mnh);
|
||||
|
@ -326,9 +123,9 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
if (ay == -1.0) {fh = 1; ay = 0.5;}
|
||||
if (wx > 0.0) xw = 1;
|
||||
if (wy > 0.0) xh = 1;
|
||||
if (sd->horizontal)
|
||||
if (horizontal)
|
||||
{
|
||||
if (sd->homogenous)
|
||||
if (homogeneous)
|
||||
{
|
||||
Evas_Coord ww, hh, ow, oh;
|
||||
|
||||
|
@ -376,7 +173,7 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (sd->homogenous)
|
||||
if (homogeneous)
|
||||
{
|
||||
Evas_Coord ww, hh, ow, oh;
|
||||
|
||||
|
@ -423,195 +220,3 @@ _smart_reconfigure(Smart_Data *sd)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_extents_calculate(Smart_Data *sd)
|
||||
{
|
||||
Evas_Coord minw, minh, maxw, maxh, mnw, mnh;
|
||||
const Eina_List *l;
|
||||
const Evas_Object *obj;
|
||||
|
||||
/* FIXME: need to calc max */
|
||||
minw = 0;
|
||||
minh = 0;
|
||||
maxw = -1;
|
||||
maxh = -1;
|
||||
if (sd->homogenous)
|
||||
{
|
||||
EINA_LIST_FOREACH(sd->items, l, obj)
|
||||
{
|
||||
evas_object_size_hint_min_get(obj, &mnw, &mnh);
|
||||
if (minh < mnh) minh = mnh;
|
||||
if (minw < mnw) minw = mnw;
|
||||
}
|
||||
if (sd->horizontal)
|
||||
minw *= eina_list_count(sd->items);
|
||||
else
|
||||
minh *= eina_list_count(sd->items);
|
||||
}
|
||||
else
|
||||
{
|
||||
EINA_LIST_FOREACH(sd->items, l, obj)
|
||||
{
|
||||
evas_object_size_hint_min_get(obj, &mnw, &mnh);
|
||||
if (sd->horizontal)
|
||||
{
|
||||
if (minh < mnh) minh = mnh;
|
||||
minw += mnw;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (minw < mnw) minw = mnw;
|
||||
minh += mnh;
|
||||
}
|
||||
}
|
||||
}
|
||||
evas_object_size_hint_min_set(sd->obj, minw, minh);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_init(void)
|
||||
{
|
||||
if (_e_smart) return;
|
||||
{
|
||||
static const Evas_Smart_Class sc =
|
||||
{
|
||||
"els_box",
|
||||
EVAS_SMART_CLASS_VERSION,
|
||||
_smart_add,
|
||||
_smart_del,
|
||||
_smart_move,
|
||||
_smart_resize,
|
||||
_smart_show,
|
||||
_smart_hide,
|
||||
_smart_color_set,
|
||||
_smart_clip_set,
|
||||
_smart_clip_unset,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
_e_smart = evas_smart_class_new(&sc);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_add(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = calloc(1, sizeof(Smart_Data));
|
||||
if (!sd) return;
|
||||
sd->obj = obj;
|
||||
sd->clip = evas_object_rectangle_add(evas_object_evas_get(obj));
|
||||
evas_object_smart_member_add(sd->clip, obj);
|
||||
evas_object_move(sd->clip, -100004, -100004);
|
||||
evas_object_resize(sd->clip, 200008, 200008);
|
||||
evas_object_color_set(sd->clip, 255, 255, 255, 255);
|
||||
evas_object_smart_data_set(obj, sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_del(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
sd->deleting = EINA_TRUE;
|
||||
while (sd->items)
|
||||
{
|
||||
Evas_Object *child;
|
||||
|
||||
child = sd->items->data;
|
||||
_els_smart_box_unpack(obj, child);
|
||||
}
|
||||
evas_object_del(sd->clip);
|
||||
free(sd);
|
||||
evas_object_smart_data_set(obj, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
const Eina_List *l;
|
||||
Evas_Object *child;
|
||||
Evas_Coord dx, dy;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
dx = x - sd->x;
|
||||
dy = y - sd->y;
|
||||
sd->x = x;
|
||||
sd->y = y;
|
||||
EINA_LIST_FOREACH(sd->items, l, child)
|
||||
{
|
||||
Evas_Coord ox, oy;
|
||||
|
||||
evas_object_geometry_get(child, &ox, &oy, NULL, NULL);
|
||||
evas_object_move(child, ox + dx, oy + dy);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
sd->w = w;
|
||||
sd->h = h;
|
||||
_smart_reconfigure(sd);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_show(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
if (sd->items) evas_object_show(sd->clip);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_hide(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
evas_object_hide(sd->clip);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
evas_object_color_set(sd->clip, r, g, b, a);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
evas_object_clip_set(sd->clip, clip);
|
||||
}
|
||||
|
||||
static void
|
||||
_smart_clip_unset(Evas_Object *obj)
|
||||
{
|
||||
Smart_Data *sd;
|
||||
|
||||
sd = evas_object_smart_data_get(obj);
|
||||
if (!sd) return;
|
||||
evas_object_clip_unset(sd->clip);
|
||||
}
|
||||
|
|
|
@ -1,11 +1 @@
|
|||
Evas_Object *_els_smart_box_add (Evas *evas);
|
||||
void _els_smart_box_orientation_set (Evas_Object *obj, int horizontal);
|
||||
int _els_smart_box_orientation_get (Evas_Object *obj);
|
||||
void _els_smart_box_homogenous_set (Evas_Object *obj, int homogenous);
|
||||
int _els_smart_box_pack_start (Evas_Object *obj, Evas_Object *child);
|
||||
int _els_smart_box_pack_end (Evas_Object *obj, Evas_Object *child);
|
||||
int _els_smart_box_pack_before (Evas_Object *obj, Evas_Object *child, Evas_Object *before);
|
||||
int _els_smart_box_pack_after (Evas_Object *obj, Evas_Object *child, Evas_Object *after);
|
||||
void _els_smart_box_unpack (Evas_Object *obj, Evas_Object *child);
|
||||
void _els_smart_box_unpack_all (Evas_Object *obj);
|
||||
void _els_smart_box_clear (Evas_Object *obj);
|
||||
void _els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous);
|
||||
|
|
Loading…
Reference in New Issue