1 #include <Elementary.h>
5 _smart_extents_calculate(Evas_Object *box, Evas_Object_Box_Data *priv, int horizontal, int homogeneous)
7 Evas_Coord minw, minh, mnw, mnh;
9 Evas_Object_Box_Option *opt;
12 /* FIXME: need to calc max */
17 EINA_LIST_FOREACH(priv->children, l, opt)
19 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
20 if (minh < mnh) minh = mnh;
21 if (minw < mnw) minw = mnw;
24 minw *= eina_list_count(priv->children);
26 minh *= eina_list_count(priv->children);
30 EINA_LIST_FOREACH(priv->children, l, opt)
32 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
35 if (minh < mnh) minh = mnh;
40 if (minw < mnw) minw = mnw;
45 c = eina_list_count(priv->children) - 1;
48 if (horizontal) minw += priv->pad.h * c;
49 else minh += priv->pad.v * c;
51 evas_object_size_hint_min_set(box, minw, minh);
55 _els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous, int rtl)
57 Evas_Coord x, y, w, h, xx, yy;
60 Evas_Coord minw, minh, wdif, hdif;
61 int count = 0, expand = 0;
63 Evas_Object_Box_Option *opt;
65 _smart_extents_calculate(o, priv, horizontal, homogeneous);
67 evas_object_geometry_get(o, &x, &y, &w, &h);
69 evas_object_size_hint_min_get(o, &minw, &minh);
70 evas_object_size_hint_align_get(o, &ax, &ay);
71 count = eina_list_count(priv->children);
75 x = x + ((w - minw) * (1.0 - ax));
80 y = y + ((h - minh) * (1.0 - ay));
83 EINA_LIST_FOREACH(priv->children, l, opt)
87 evas_object_size_hint_weight_get(opt->obj, &wx, &wy);
90 if (wx > 0.0) expand++;
94 if (wy > 0.0) expand++;
99 evas_object_size_hint_align_get(o, &ax, &ay);
102 x += (double)(w - minw) * ax;
107 y += (double)(h - minh) * ay;
115 EINA_LIST_FOREACH(priv->children, l, opt)
117 Evas_Coord mnw, mnh, mxw, mxh;
122 evas_object_size_hint_align_get(obj, &ax, &ay);
123 evas_object_size_hint_weight_get(obj, &wx, &wy);
124 evas_object_size_hint_min_get(obj, &mnw, &mnh);
125 evas_object_size_hint_max_get(obj, &mxw, &mxh);
128 if (ax == -1.0) {fw = 1; ax = 0.5;}
129 if (ay == -1.0) {fh = 1; ay = 0.5;}
130 if (wx > 0.0) xw = 1;
131 if (wy > 0.0) xh = 1;
134 Evas_Coord ww, hh, ow, oh;
138 ww = (w / (Evas_Coord)count);
143 if ((expand > 0) && (xw))
145 if (expand == 1) ow = wdif;
146 else ow = (w - minw) / expand;
154 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
157 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
158 evas_object_move(obj,
159 ((!rtl) ? (xx) : (x + (w - (xx - x) - ww)))
160 + (Evas_Coord)(((double)(ww - ow)) * ax),
161 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
162 evas_object_resize(obj, ow, oh);
168 Evas_Coord ww, hh, ow, oh;
172 hh = (h / (Evas_Coord)count);
177 if ((expand > 0) && (xh))
179 if (expand == 1) oh = hdif;
180 else oh = (h - minh) / expand;
188 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
191 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
192 evas_object_move(obj,
193 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
194 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
195 evas_object_resize(obj, ow, oh);