1 #include <Elementary.h>
5 _smart_extents_calculate(Evas_Object *box, Evas_Object_Box_Data *priv, int horizontal, int homogeneous, int extended)
7 Evas_Coord minw, minh, maxw, maxh, mnw, mnh, ww;
8 Evas_Coord w, h, cw = 0, ch = 0, cmaxh = 0, sumw = 0;
10 Evas_Object_Box_Option *opt;
13 /* FIXME: need to calc max */
21 EINA_LIST_FOREACH(priv->children, l, opt)
23 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
24 if (minh < mnh) minh = mnh;
25 if (minw < mnw) minw = mnw;
28 minw *= eina_list_count(priv->children);
30 minh *= eina_list_count(priv->children);
34 if (horizontal && extended)
36 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
37 evas_object_size_hint_min_get(box, &minw, NULL);
40 EINA_LIST_FOREACH(priv->children, l, opt)
42 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
48 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
52 if (mnw != -1 && (w - cw) >= mnw)
68 if (cmaxh < mnh) cmaxh = mnh;
72 if (minh < mnh) minh = mnh;
78 if (minw < mnw) minw = mnw;
83 if(horizontal && extended)
89 evas_object_size_hint_min_set(box, minw, minh);
94 _smart_extents_calculate_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
96 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
98 Evas_Object_Box_Option *opt;
102 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
104 EINA_LIST_FOREACH(priv->children, l, opt)
106 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
107 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
111 if (mnw != -1 && (w - cw) >= mnw)
121 if (index > obj_index )
130 if (cmaxh < mnh) cmaxh = mnh;
140 _els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous)
142 _els_box_layout_ex(o, priv, horizontal, homogeneous, 0);
146 _els_box_layout_ex(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous, int extended)
148 Evas_Coord x, y, w, h, xx, yy;
151 Evas_Coord minw, minh, wdif, hdif;
152 int count = 0, expand = 0;
154 Evas_Object_Box_Option *opt;
156 _smart_extents_calculate(o, priv, horizontal, homogeneous, extended);
158 evas_object_geometry_get(o, &x, &y, &w, &h);
160 evas_object_size_hint_min_get(o, &minw, &minh);
161 evas_object_size_hint_align_get(o, &ax, &ay);
162 count = eina_list_count(priv->children);
165 x = x + ((w - minw) * (1.0 - ax));
170 y = y + ((h - minh) * (1.0 - ay));
173 EINA_LIST_FOREACH(priv->children, l, opt)
177 evas_object_size_hint_weight_get(opt->obj, &wx, &wy);
180 if (wx > 0.0) expand++;
184 if (wy > 0.0) expand++;
187 if (expand == 0 && (!extended))
189 evas_object_size_hint_align_get(o, &ax, &ay);
192 x += (double)(w - minw) * ax;
197 y += (double)(h - minh) * ay;
206 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
208 EINA_LIST_FOREACH(priv->children, l, opt)
210 Evas_Coord mnw, mnh, mxw, mxh;
215 evas_object_size_hint_align_get(obj, &ax, &ay);
216 evas_object_size_hint_weight_get(obj, &wx, &wy);
217 evas_object_size_hint_min_get(obj, &mnw, &mnh);
218 evas_object_size_hint_max_get(obj, &mxw, &mxh);
221 if (ax == -1.0) {fw = 1; ax = 0.5;}
222 if (ay == -1.0) {fh = 1; ay = 0.5;}
223 if (wx > 0.0) xw = 1;
224 if (wy > 0.0) xh = 1;
229 Evas_Coord ww, hh, ow, oh;
231 ww = (w / (Evas_Coord)count);
235 if ((mxw >= 0) && (mxw < ow))
239 if ((mxh >= 0) && (mxh < oh))
241 evas_object_move(obj,
242 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
243 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
244 evas_object_resize(obj, ow, oh);
251 Evas_Coord ww, hh, ow, oh;
254 if (mnw != -1 && (w - cw) >= mnw)
261 hh = _smart_extents_calculate_max_height(o, priv, obj_index);
265 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
268 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
278 evas_object_move(obj,
279 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
280 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
281 evas_object_resize(obj, ow, oh);
284 if (cmaxh < hh) cmaxh = hh;
288 Evas_Coord ww, hh, ow, oh;
291 if ((expand > 0) && (xw))
293 if (expand == 1) ow = wdif;
294 else ow = (w - minw) / expand;
301 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
304 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
305 evas_object_move(obj,
306 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
307 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
308 evas_object_resize(obj, ow, oh);
317 Evas_Coord ww, hh, ow, oh;
320 hh = (h / (Evas_Coord)count);
323 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
326 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
327 evas_object_move(obj,
328 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
329 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
330 evas_object_resize(obj, ow, oh);
335 Evas_Coord ww, hh, ow, oh;
339 if ((expand > 0) && (xh))
341 if (expand == 1) oh = hdif;
342 else oh = (h - minh) / expand;
348 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
351 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
352 evas_object_move(obj,
353 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
354 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
355 evas_object_resize(obj, ow, oh);