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);
47 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
51 if (mnw != -1 && (w - cw) >= mnw)
67 if (cmaxh < mnh) cmaxh = mnh;
71 if (minh < mnh) minh = mnh;
77 if (minw < mnw) minw = mnw;
82 if(horizontal && extended)
88 evas_object_size_hint_min_set(box, minw, minh);
92 _smart_extents_calculate_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
94 Evas_Coord mnw, mnh, cw = 0, cmaxh = 0, w, ww;
96 Evas_Object_Box_Option *opt;
100 evas_object_geometry_get(box, NULL, NULL, &w, NULL);
102 EINA_LIST_FOREACH(priv->children, l, opt)
104 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
105 evas_object_size_hint_weight_get(opt->obj, &wx, NULL);
109 if (mnw != -1 && (w - cw) >= mnw)
119 if (index > obj_index )
128 if (cmaxh < mnh) cmaxh = mnh;
137 _els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous, int rtl)
139 _els_box_layout_ex(o, priv, horizontal, homogeneous, 0, rtl);
143 _els_box_layout_ex(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous, int extended, int rtl)
145 Evas_Coord x, y, w, h, xx, yy;
148 Evas_Coord minw, minh, wdif, hdif;
149 int count = 0, expand = 0;
151 Evas_Object_Box_Option *opt;
153 _smart_extents_calculate(o, priv, horizontal, homogeneous, extended);
155 evas_object_geometry_get(o, &x, &y, &w, &h);
157 evas_object_size_hint_min_get(o, &minw, &minh);
158 evas_object_size_hint_align_get(o, &ax, &ay);
159 count = eina_list_count(priv->children);
162 x = x + ((w - minw) * (1.0 - ax));
167 y = y + ((h - minh) * (1.0 - ay));
170 EINA_LIST_FOREACH(priv->children, l, opt)
174 evas_object_size_hint_weight_get(opt->obj, &wx, &wy);
177 if (wx > 0.0) expand++;
181 if (wy > 0.0) expand++;
184 if ((!expand) && (!extended))
186 evas_object_size_hint_align_get(o, &ax, &ay);
189 x += (double)(w - minw) * ax;
194 y += (double)(h - minh) * ay;
203 Evas_Coord cw = 0, ch = 0, cmaxh = 0, obj_index = 0;
205 EINA_LIST_FOREACH(priv->children, l, opt)
207 Evas_Coord mnw, mnh, mxw, mxh;
212 evas_object_size_hint_align_get(obj, &ax, &ay);
213 evas_object_size_hint_weight_get(obj, &wx, &wy);
214 evas_object_size_hint_min_get(obj, &mnw, &mnh);
215 evas_object_size_hint_max_get(obj, &mxw, &mxh);
218 if (ax == -1.0) {fw = 1; ax = 0.5;}
219 if (ay == -1.0) {fh = 1; ay = 0.5;}
220 if (wx > 0.0) xw = 1;
221 if (wy > 0.0) xh = 1;
224 Evas_Coord ww, hh, ow, oh;
230 if (mnw != -1 && (w - cw) >= mnw)
237 hh = _smart_extents_calculate_max_height(o, priv, obj_index);
241 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
244 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
254 evas_object_move(obj,
255 xx + cw + (Evas_Coord)(((double)(ww - ow)) * ax),
256 yy + ch + (Evas_Coord)(((double)(hh - oh)) * ay));
257 evas_object_resize(obj, ow, oh);
260 if (cmaxh < hh) cmaxh = hh;
266 ww = (w / (Evas_Coord)count);
271 if ((expand > 0) && (xw))
273 if (expand == 1) ow = wdif;
274 else ow = (w - minw) / expand;
282 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
285 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
286 evas_object_move(obj,
287 ((!rtl) ? (xx) : (x + (w - (xx - x) - ww)))
288 + (Evas_Coord)(((double)(ww - ow)) * ax),
289 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
290 evas_object_resize(obj, ow, oh);
296 Evas_Coord ww, hh, ow, oh;
300 hh = (h / (Evas_Coord)count);
305 if ((expand > 0) && (xh))
307 if (expand == 1) oh = hdif;
308 else oh = (h - minh) / expand;
316 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
319 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
320 evas_object_move(obj,
321 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
322 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
323 evas_object_resize(obj, ow, oh);