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, cw = 0, cmaxh = 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);
93 _smart_extents_calculate_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
95 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
97 Evas_Object_Box_Option *opt;
101 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
103 EINA_LIST_FOREACH(priv->children, l, opt)
105 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
106 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
110 if (mnw != -1 && (w - cw) >= mnw)
120 if (index > obj_index )
129 if (cmaxh < mnh) cmaxh = mnh;
138 _els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous)
140 _els_box_layout_ex(o, priv, horizontal, homogeneous, 0);
144 _els_box_layout_ex(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous, int extended)
146 Evas_Coord x, y, w, h, xx, yy;
149 Evas_Coord minw, minh, wdif, hdif;
150 int count = 0, expand = 0;
152 Evas_Object_Box_Option *opt;
154 _smart_extents_calculate(o, priv, horizontal, homogeneous, extended);
156 evas_object_geometry_get(o, &x, &y, &w, &h);
158 evas_object_size_hint_min_get(o, &minw, &minh);
159 evas_object_size_hint_align_get(o, &ax, &ay);
160 count = eina_list_count(priv->children);
163 x = x + ((w - minw) * (1.0 - ax));
168 y = y + ((h - minh) * (1.0 - ay));
171 EINA_LIST_FOREACH(priv->children, l, opt)
175 evas_object_size_hint_weight_get(opt->obj, &wx, &wy);
178 if (wx > 0.0) expand++;
182 if (wy > 0.0) expand++;
185 if ((!expand) && (!extended))
187 evas_object_size_hint_align_get(o, &ax, &ay);
190 x += (double)(w - minw) * ax;
195 y += (double)(h - minh) * ay;
204 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
206 EINA_LIST_FOREACH(priv->children, l, opt)
208 Evas_Coord mnw, mnh, mxw, mxh;
213 evas_object_size_hint_align_get(obj, &ax, &ay);
214 evas_object_size_hint_weight_get(obj, &wx, &wy);
215 evas_object_size_hint_min_get(obj, &mnw, &mnh);
216 evas_object_size_hint_max_get(obj, &mxw, &mxh);
219 if (ax == -1.0) {fw = 1; ax = 0.5;}
220 if (ay == -1.0) {fh = 1; ay = 0.5;}
221 if (wx > 0.0) xw = 1;
222 if (wy > 0.0) xh = 1;
227 Evas_Coord ww, hh, ow, oh;
229 ww = (w / (Evas_Coord)count);
233 if ((mxw >= 0) && (mxw < ow))
237 if ((mxh >= 0) && (mxh < oh))
239 evas_object_move(obj,
240 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
241 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
242 evas_object_resize(obj, ow, oh);
249 Evas_Coord ww, hh, ow, oh;
252 if (mnw != -1 && (w - cw) >= mnw)
259 hh = _smart_extents_calculate_max_height(o, priv, obj_index);
263 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
266 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
276 evas_object_move(obj,
277 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
278 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
279 evas_object_resize(obj, ow, oh);
282 if (cmaxh < hh) cmaxh = hh;
286 Evas_Coord ww, hh, ow, oh;
289 if ((expand > 0) && (xw))
291 if (expand == 1) ow = wdif;
292 else ow = (w - minw) / expand;
299 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
302 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
303 evas_object_move(obj,
304 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
305 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
306 evas_object_resize(obj, ow, oh);
315 Evas_Coord ww, hh, ow, oh;
318 hh = (h / (Evas_Coord)count);
321 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
324 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
325 evas_object_move(obj,
326 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
327 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
328 evas_object_resize(obj, ow, oh);
333 Evas_Coord ww, hh, ow, oh;
337 if ((expand > 0) && (xh))
339 if (expand == 1) oh = hdif;
340 else oh = (h - minh) / expand;
346 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
349 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
350 evas_object_move(obj,
351 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
352 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
353 evas_object_resize(obj, ow, oh);