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;
8 Evas_Coord w, h, cal_w = 0, cal_h = 0, cur_line_max_h = 0;
10 Evas_Object_Box_Option *opt;
12 /* FIXME: need to calc max */
20 EINA_LIST_FOREACH(priv->children, l, opt)
22 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
23 if (minh < mnh) minh = mnh;
24 if (minw < mnw) minw = mnw;
27 minw *= eina_list_count(priv->children);
29 minh *= eina_list_count(priv->children);
33 if (horizontal && extended)
35 evas_object_geometry_get(box, NULL, NULL, &w, &h);
39 EINA_LIST_FOREACH(priv->children, l, opt)
41 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
46 if ((cal_w + mnw) > w)
48 minh += cur_line_max_h;
53 if (cur_line_max_h < mnh) cur_line_max_h = mnh;
57 if (minh < mnh) minh = mnh;
63 if (minw < mnw) minw = mnw;
68 if(horizontal && extended)
70 minh += cur_line_max_h;
74 evas_object_size_hint_min_set(box, minw, minh);
79 _smart_extents_calculate_max_height(Evas_Object *box, Evas_Object_Box_Data *priv, int obj_index)
81 Evas_Coord mnw, mnh, box_w, cal_w = 0, cur_line_max_h = 0;
83 Evas_Object_Box_Option *opt;
86 evas_object_geometry_get(box, NULL, NULL, &box_w, NULL);
88 EINA_LIST_FOREACH(priv->children, l, opt)
90 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
92 if ((cal_w + mnw) > box_w)
94 if (index > obj_index )
96 return cur_line_max_h;
103 if (cur_line_max_h < mnh) cur_line_max_h = mnh;
108 return cur_line_max_h;
113 _els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous)
115 _els_box_layout_ex(o, priv, horizontal, homogeneous, 0);
119 _els_box_layout_ex(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous, int extended)
121 Evas_Coord x, y, w, h, xx, yy;
124 Evas_Coord minw, minh, wdif, hdif;
125 int count = 0, expand = 0;
127 Evas_Object_Box_Option *opt;
129 _smart_extents_calculate(o, priv, horizontal, homogeneous, extended);
131 evas_object_geometry_get(o, &x, &y, &w, &h);
133 evas_object_size_hint_min_get(o, &minw, &minh);
134 evas_object_size_hint_align_get(o, &ax, &ay);
135 count = eina_list_count(priv->children);
138 x = x + ((w - minw) * (1.0 - ax));
143 y = y + ((h - minh) * (1.0 - ay));
146 EINA_LIST_FOREACH(priv->children, l, opt)
150 evas_object_size_hint_weight_get(opt->obj, &wx, &wy);
153 if (wx > 0.0) expand++;
157 if (wy > 0.0) expand++;
162 evas_object_size_hint_align_get(o, &ax, &ay);
165 x += (double)(w - minw) * ax;
170 y += (double)(h - minh) * ay;
179 Evas_Coord cal_w = 0, cal_h = 0, cur_line_max_h = 0, obj_index = 0;
181 EINA_LIST_FOREACH(priv->children, l, opt)
183 Evas_Coord mnw, mnh, mxw, mxh;
188 evas_object_size_hint_align_get(obj, &ax, &ay);
189 evas_object_size_hint_weight_get(obj, &wx, &wy);
190 evas_object_size_hint_min_get(obj, &mnw, &mnh);
191 evas_object_size_hint_max_get(obj, &mxw, &mxh);
194 if (ax == -1.0) {fw = 1; ax = 0.5;}
195 if (ay == -1.0) {fh = 1; ay = 0.5;}
196 if (wx > 0.0) xw = 1;
197 if (wy > 0.0) xh = 1;
202 Evas_Coord ww, hh, ow, oh;
204 ww = (w / (Evas_Coord)count);
208 if ((mxw >= 0) && (mxw < ow))
212 if ((mxh >= 0) && (mxh < oh))
214 evas_object_move(obj,
215 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
216 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
217 evas_object_resize(obj, ow, oh);
224 Evas_Coord ww, hh, ow, oh;
226 hh = _smart_extents_calculate_max_height(o, priv, obj_index);
230 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
233 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
235 if ((cal_w + ww) > w)
237 cal_h += cur_line_max_h;
243 evas_object_move(obj,
244 xx + cal_w + (Evas_Coord)(((double)(ww - ow)) * ax),
245 yy + cal_h + (Evas_Coord)(((double)(hh - oh)) * ay));
246 evas_object_resize(obj, ow, oh);
249 if (cur_line_max_h < hh) cur_line_max_h = hh;
253 Evas_Coord ww, hh, ow, oh;
256 if ((expand > 0) && (xw))
258 if (expand == 1) ow = wdif;
259 else ow = (w - minw) / expand;
266 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
269 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
270 evas_object_move(obj,
271 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
272 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
273 evas_object_resize(obj, ow, oh);
282 Evas_Coord ww, hh, ow, oh;
285 hh = (h / (Evas_Coord)count);
288 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
291 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
292 evas_object_move(obj,
293 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
294 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
295 evas_object_resize(obj, ow, oh);
300 Evas_Coord ww, hh, ow, oh;
304 if ((expand > 0) && (xh))
306 if (expand == 1) oh = hdif;
307 else oh = (h - minh) / expand;
313 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
316 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
317 evas_object_move(obj,
318 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
319 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
320 evas_object_resize(obj, ow, oh);