#include "elm_priv.h"
typedef struct _Smart_Data Smart_Data;
-typedef struct _Box_Item Box_Item;
+typedef struct _Box_Item Box_Item;
struct _Smart_Data
{
- Evas_Coord x, y, w, h;
- Evas_Object *obj;
- Evas_Object *clip;
- Eina_Bool changed : 1;
- Eina_Bool horizontal : 1;
- Eina_Bool homogenous : 1;
- Eina_Bool deleting : 1;
- Eina_List *items;
+ 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_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);
_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;
_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;
_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;
_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;
_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;
int i = 0;
const Eina_List *l;
const Evas_Object *oitr;
+
EINA_LIST_FOREACH(sd->items, l, oitr)
{
- if (oitr == child)
- return i;
+ if (oitr == child) return i;
i++;
}
return -1;
_smart_adopt(sd, child);
sd->items = eina_list_prepend_relative(sd->items, child, before);
_smart_reconfigure(sd);
-
return _els_smart_box_find(sd, child);
}
_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;
while (sd->items)
{
Evas_Object *child = sd->items->data;
+
_els_smart_box_unpack(obj, child);
}
}
while (sd->items)
{
Evas_Object *child = sd->items->data;
+
evas_object_del(child);
}
}
_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)
Evas_Coord x, y, w, h, xx, yy;
const Eina_List *l;
Evas_Object *obj;
- Evas_Coord minw, minh, wdif, hdif, mnw, mnh, mxw, mxh;
- int count, expand, fw, fh, xw, xh;
- double ax, ay, wx, wy;
+ Evas_Coord minw, minh, wdif, hdif;
+ int count = 0, expand = 0;
+ double ax, ay;
_smart_extents_calculate(sd);
-
+
x = sd->x;
y = sd->y;
w = sd->w;
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);
- expand = 0;
if (w < minw)
{
x = x + ((w - minw) * (1.0 - ax));
}
EINA_LIST_FOREACH(sd->items, l, obj)
{
+ double wx, wy;
+
evas_object_size_hint_weight_get(obj, &wx, &wy);
if (sd->horizontal)
{
yy = y;
EINA_LIST_FOREACH(sd->items, l, obj)
{
+ Evas_Coord mnw, mnh, mxw, mxh;
+ double wx, wy;
+ int fw, fh, xw, xh;
+
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);
if (sd->homogenous)
{
Evas_Coord ww, hh, ow, oh;
-
+
ww = (w / (Evas_Coord)count);
hh = h;
ow = mnw;
else
{
Evas_Coord ww, hh, ow, oh;
-
+
ww = mnw;
if ((expand > 0) && (xw))
{
if (sd->homogenous)
{
Evas_Coord ww, hh, ow, oh;
-
+
ww = w;
hh = (h / (Evas_Coord)count);
ow = mnw;
else
{
Evas_Coord ww, hh, ow, oh;
-
+
ww = w;
hh = mnh;
if ((expand > 0) && (xh))
_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;
maxh = -1;
if (sd->homogenous)
{
- const Eina_List *l;
- const Evas_Object *obj;
EINA_LIST_FOREACH(sd->items, l, obj)
{
evas_object_size_hint_min_get(obj, &mnw, &mnh);
}
else
{
- const Eina_List *l;
- const Evas_Object *obj;
EINA_LIST_FOREACH(sd->items, l, obj)
{
evas_object_size_hint_min_get(obj, &mnw, &mnh);
_smart_add(Evas_Object *obj)
{
Smart_Data *sd;
-
+
sd = calloc(1, sizeof(Smart_Data));
if (!sd) return;
sd->obj = obj;
_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);
}
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;
_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;
_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);
_smart_hide(Evas_Object *obj)
{
Smart_Data *sd;
-
+
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_hide(sd->clip);
_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);
_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);
_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);