1 #include <Elementary.h>
6 _smart_extents_calculate(Evas_Object *box, Evas_Object_Box_Data *priv, int horizontal, int homogeneous)
8 Evas_Coord minw, minh, mnw, mnh, maxw, maxh;
10 Evas_Object_Box_Option *opt;
19 EINA_LIST_FOREACH(priv->children, l, opt)
21 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
22 if (minh < mnh) minh = mnh;
23 if (minw < mnw) minw = mnw;
25 evas_object_size_hint_max_get(opt->obj, &mnw, &mnh);
28 if (maxw == -1) maxh = mnh;
29 else if (maxh > mnh) maxh = mnh;
33 if (maxw == -1) maxw = mnw;
34 else if (maxw > mnw) maxw = mnw;
39 minw *= eina_list_count(priv->children);
41 maxw *= eina_list_count(priv->children);
46 minh *= eina_list_count(priv->children);
48 maxh *= eina_list_count(priv->children);
54 EINA_LIST_FOREACH(priv->children, l, opt)
56 evas_object_size_hint_min_get(opt->obj, &mnw, &mnh);
59 if (minh < mnh) minh = mnh;
64 if (minw < mnw) minw = mnw;
67 evas_object_size_hint_max_get(opt->obj, &mnw, &mnh);
70 if (mnw < 0) maxw = -1;
73 if (maxw > mnw) maxw = mnw;
79 if (mnh < 0) maxh = -1;
82 if (maxh > mnh) maxh = mnh;
88 c = eina_list_count(priv->children) - 1;
93 minw += priv->pad.h * c;
94 if (maxw != -1) maxw += priv->pad.h * c;
98 minh += priv->pad.v * c;
99 if (maxh != -1) maxh += priv->pad.v * c;
102 evas_object_size_hint_min_set(box, minw, minh);
103 evas_object_size_hint_max_set(box, maxw, maxh);
107 _els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, int horizontal, int homogeneous, int rtl)
109 Evas_Coord x, y, w, h, xx, yy;
112 Evas_Coord minw, minh, wdif, hdif;
116 Evas_Object_Box_Option *opt;
118 _smart_extents_calculate(o, priv, horizontal, homogeneous);
120 evas_object_geometry_get(o, &x, &y, &w, &h);
122 evas_object_size_hint_min_get(o, &minw, &minh);
123 evas_object_size_hint_align_get(o, &ax, &ay);
124 if ((w < minw) || (h < minh)) return;
125 count = eina_list_count(priv->children);
126 if (rtl) ax = 1.0 - ax;
130 x = x + ((w - minw) * (1.0 - ax));
135 y = y + ((h - minh) * (1.0 - ay));
138 EINA_LIST_FOREACH(priv->children, l, opt)
142 evas_object_size_hint_weight_get(opt->obj, &wx, &wy);
145 if (wx > 0.0) expand += wx;
149 if (wy > 0.0) expand += wy;
154 evas_object_size_hint_align_get(o, &ax, &ay);
155 if (rtl) ax = 1.0 - ax;
158 x += (double)(w - minw) * ax;
163 y += (double)(h - minh) * ay;
171 EINA_LIST_FOREACH(priv->children, l, opt)
173 Evas_Coord mnw, mnh, mxw, mxh;
178 evas_object_size_hint_align_get(obj, &ax, &ay);
179 evas_object_size_hint_weight_get(obj, &wx, &wy);
180 evas_object_size_hint_min_get(obj, &mnw, &mnh);
181 evas_object_size_hint_max_get(obj, &mxw, &mxh);
184 if (ax == -1.0) {fw = 1; ax = 0.5;}
185 if (ay == -1.0) {fh = 1; ay = 0.5;}
186 if (rtl) ax = 1.0 - ax;
187 if (wx > 0.0) xw = 1;
188 if (wy > 0.0) xh = 1;
191 Evas_Coord ww, hh, ow, oh;
195 ww = (w / (Evas_Coord)count);
200 if ((expand > 0) && (xw))
202 ow = ((w - minw) * wx) / expand;
210 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
213 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
214 evas_object_move(obj,
215 ((!rtl) ? (xx) : (x + (w - (xx - x) - ww)))
216 + (Evas_Coord)(((double)(ww - ow)) * ax),
217 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
218 evas_object_resize(obj, ow, oh);
224 Evas_Coord ww, hh, ow, oh;
228 hh = (h / (Evas_Coord)count);
233 if ((expand > 0) && (xh))
235 oh = ((h - minh) * wy) / expand;
243 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
246 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
247 evas_object_move(obj,
248 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
249 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
250 evas_object_resize(obj, ow, oh);