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;
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;
169 EINA_LIST_FOREACH(priv->children, l, opt)
171 Evas_Coord mnw, mnh, mxw, mxh;
176 evas_object_size_hint_align_get(obj, &ax, &ay);
177 evas_object_size_hint_weight_get(obj, &wx, &wy);
178 evas_object_size_hint_min_get(obj, &mnw, &mnh);
179 evas_object_size_hint_max_get(obj, &mxw, &mxh);
182 if (ax == -1.0) {fw = 1; ax = 0.5;}
183 if (ay == -1.0) {fh = 1; ay = 0.5;}
184 if (rtl) ax = 1.0 - ax;
185 if (wx > 0.0) xw = 1;
186 if (wy > 0.0) xh = 1;
189 Evas_Coord ww, hh, ow, oh;
193 ww = (w / (Evas_Coord)count);
198 if ((expand > 0) && (xw))
200 ow = ((w - minw) * wx) / expand;
207 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
210 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
211 evas_object_move(obj,
212 ((!rtl) ? (xx) : (x + (w - (xx - x) - ww)))
213 + (Evas_Coord)(((double)(ww - ow)) * ax),
214 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
215 evas_object_resize(obj, ow, oh);
221 Evas_Coord ww, hh, ow, oh;
225 hh = (h / (Evas_Coord)count);
230 if ((expand > 0) && (xh))
232 oh = ((h - minh) * wy) / expand;
239 if ((mxw >= 0) && (mxw < ow)) ow = mxw;
242 if ((mxh >= 0) && (mxh < oh)) oh = mxh;
243 evas_object_move(obj,
244 xx + (Evas_Coord)(((double)(ww - ow)) * ax),
245 yy + (Evas_Coord)(((double)(hh - oh)) * ay));
246 evas_object_resize(obj, ow, oh);