summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-09-18 16:44:42 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-09-18 16:50:58 +0900
commitd8eea084fb86514843e64390479c9a6b17bd2e57 (patch)
tree0e81a693af1edf7c64522752b3f85fd36cb31873 /src/lib
parent6b5d155918452df206a9b8142842cbc6af94ae1a (diff)
efl: Use Eina.Size2D for size hint aspect
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/efl/interfaces/efl_gfx_size_hint.eo3
-rw-r--r--src/lib/elementary/efl_ui_box_layout.c35
-rw-r--r--src/lib/elementary/efl_ui_win.c16
-rw-r--r--src/lib/evas/canvas/evas_object_main.c31
-rw-r--r--src/lib/evas/include/evas_private.h2
5 files changed, 47 insertions, 40 deletions
diff --git a/src/lib/efl/interfaces/efl_gfx_size_hint.eo b/src/lib/efl/interfaces/efl_gfx_size_hint.eo
index eef7412..329ec2e 100644
--- a/src/lib/efl/interfaces/efl_gfx_size_hint.eo
+++ b/src/lib/efl/interfaces/efl_gfx_size_hint.eo
@@ -59,8 +59,7 @@ interface Efl.Gfx.Size.Hint
59 */ 59 */
60 values { 60 values {
61 mode: Efl.Gfx.Size.Hint.Aspect; [[Mode of interpretation.]] 61 mode: Efl.Gfx.Size.Hint.Aspect; [[Mode of interpretation.]]
62 w: int; [[Width]] 62 sz: Eina.Size2D; [[Base size to use for aspecting.]]
63 h: int; [[Height]]
64 63
65 /* FIXME: do we want min/max like Edje instead?? 64 /* FIXME: do we want min/max like Edje instead??
66 min: double; [[Default: 0.0 (no preference).]] 65 min: double; [[Default: 0.0 (no preference).]]
diff --git a/src/lib/elementary/efl_ui_box_layout.c b/src/lib/elementary/efl_ui_box_layout.c
index 70cf4ca..ba8b35e 100644
--- a/src/lib/elementary/efl_ui_box_layout.c
+++ b/src/lib/elementary/efl_ui_box_layout.c
@@ -12,10 +12,9 @@ struct _Item_Calc
12 Evas_Object *obj; 12 Evas_Object *obj;
13 double weight[2]; 13 double weight[2];
14 double align[2]; 14 double align[2];
15 Eina_Size2D max, want; 15 Eina_Size2D max, want, aspect;
16 int pad[4]; 16 int pad[4];
17 Efl_Gfx_Size_Hint_Aspect aspect_type; 17 Efl_Gfx_Size_Hint_Aspect aspect_type;
18 int aspect[2];
19 int id; 18 int id;
20}; 19};
21 20
@@ -79,13 +78,13 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
79 efl_gfx_size_hint_margin_get(o, &item->pad[0], &item->pad[1], &item->pad[2], &item->pad[3]); 78 efl_gfx_size_hint_margin_get(o, &item->pad[0], &item->pad[1], &item->pad[2], &item->pad[3]);
80 item->max = efl_gfx_size_hint_max_get(o); 79 item->max = efl_gfx_size_hint_max_get(o);
81 item->want = efl_gfx_size_hint_combined_min_get(o); 80 item->want = efl_gfx_size_hint_combined_min_get(o);
82 efl_gfx_size_hint_aspect_get(o, &item->aspect_type, &item->aspect[0], &item->aspect[1]); 81 efl_gfx_size_hint_aspect_get(o, &item->aspect_type, &item->aspect);
83 82
84 if (item->aspect[0] <= 0 || item->aspect[1] <= 0) 83 if (item->aspect.w <= 0 || item->aspect.h <= 0)
85 { 84 {
86 if (item->aspect_type >= EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL) 85 if (item->aspect_type >= EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL)
87 ERR("Invalid aspect parameter for obj: %p", item->obj); 86 ERR("Invalid aspect parameter for obj: %p", item->obj);
88 item->aspect[0] = item->aspect[1] = 0; 87 item->aspect.w = item->aspect.h = 0;
89 item->aspect_type = EFL_GFX_SIZE_HINT_ASPECT_NONE; 88 item->aspect_type = EFL_GFX_SIZE_HINT_ASPECT_NONE;
90 } 89 }
91 90
@@ -94,11 +93,11 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
94 double w, h; 93 double w, h;
95 94
96 w = item->want.w; 95 w = item->want.w;
97 h = w * item->aspect[1] / item->aspect[0]; 96 h = w * item->aspect.h / item->aspect.w;
98 if (h < item->want.h) 97 if (h < item->want.h)
99 { 98 {
100 h = item->want.h; 99 h = item->want.h;
101 w = h * item->aspect[0] / item->aspect[1]; 100 w = h * item->aspect.w / item->aspect.h;
102 } 101 }
103 102
104 if (horiz) 103 if (horiz)
@@ -108,7 +107,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
108 double w1, h1; 107 double w1, h1;
109 h1 = item->max.h > 0 ? MIN(boxh, item->max.h) : boxh; 108 h1 = item->max.h > 0 ? MIN(boxh, item->max.h) : boxh;
110 h1 = MAX(h, h1); 109 h1 = MAX(h, h1);
111 w1 = h1 * item->aspect[0] / item->aspect[1]; 110 w1 = h1 * item->aspect.w / item->aspect.h;
112 w = item->max.w > 0 ? MIN(w1, item->max.w) : w1; 111 w = item->max.w > 0 ? MIN(w1, item->max.w) : w1;
113 } 112 }
114 } 113 }
@@ -119,7 +118,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
119 double w1, h1; 118 double w1, h1;
120 w1 = item->max.w > 0 ? MIN(boxw, item->max.w) : boxw; 119 w1 = item->max.w > 0 ? MIN(boxw, item->max.w) : boxw;
121 w1 = MAX(w, w1); 120 w1 = MAX(w, w1);
122 h1 = w1 * item->aspect[1] / item->aspect[0]; 121 h1 = w1 * item->aspect.h / item->aspect.w;
123 h = item->max.h > 0 ? MIN(h1, item->max.h) : h1; 122 h = item->max.h > 0 ? MIN(h1, item->max.h) : h1;
124 } 123 }
125 } 124 }
@@ -254,7 +253,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
254 h = item->want.h; 253 h = item->want.h;
255 if (weight[0] > 0) 254 if (weight[0] > 0)
256 w = item->want.w + extra * item->weight[0] / weight[0]; 255 w = item->want.w + extra * item->weight[0] / weight[0];
257 h = w * item->aspect[1] / item->aspect[0]; 256 h = w * item->aspect.h / item->aspect.w;
258 257
259 if (item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_BOTH || 258 if (item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_BOTH ||
260 item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_VERTICAL) 259 item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_VERTICAL)
@@ -262,7 +261,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
262 if (h > boxh) 261 if (h > boxh)
263 { 262 {
264 h = boxh; 263 h = boxh;
265 w = h * item->aspect[0] / item->aspect[1]; 264 w = h * item->aspect.w / item->aspect.h;
266 } 265 }
267 } 266 }
268 } 267 }
@@ -272,7 +271,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
272 h = item->want.h; 271 h = item->want.h;
273 if (weight[1] > 0) 272 if (weight[1] > 0)
274 h = item->want.h + extra * item->weight[1] / weight[1]; 273 h = item->want.h + extra * item->weight[1] / weight[1];
275 w = h * item->aspect[0] / item->aspect[1]; 274 w = h * item->aspect.w / item->aspect.h;
276 275
277 if (item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_BOTH || 276 if (item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_BOTH ||
278 item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL) 277 item->aspect_type == EFL_GFX_SIZE_HINT_ASPECT_HORIZONTAL)
@@ -280,7 +279,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
280 if (w > boxw) 279 if (w > boxw)
281 { 280 {
282 w = boxw; 281 w = boxw;
283 h = w * item->aspect[1] / item->aspect[0]; 282 h = w * item->aspect.h / item->aspect.w;
284 } 283 }
285 } 284 }
286 } 285 }
@@ -289,13 +288,13 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
289 { 288 {
290 double mar, ar; 289 double mar, ar;
291 mar = item->max.w / (double)item->max.h; 290 mar = item->max.w / (double)item->max.h;
292 ar = item->aspect[0] / (double)item->aspect[1]; 291 ar = item->aspect.w / (double)item->aspect.h;
293 if (ar < mar) 292 if (ar < mar)
294 { 293 {
295 if (h > item->max.h) 294 if (h > item->max.h)
296 { 295 {
297 h = item->max.h; 296 h = item->max.h;
298 w = h * item->aspect[0] / item->aspect[1]; 297 w = h * item->aspect.w / item->aspect.h;
299 } 298 }
300 } 299 }
301 else 300 else
@@ -303,19 +302,19 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
303 if (w > item->max.w) 302 if (w > item->max.w)
304 { 303 {
305 w = item->max.w; 304 w = item->max.w;
306 h = w * item->aspect[1] / item->aspect[0]; 305 h = w * item->aspect.h / item->aspect.w;
307 } 306 }
308 } 307 }
309 } 308 }
310 else if (item->max.w != INT_MAX) 309 else if (item->max.w != INT_MAX)
311 { 310 {
312 w = MIN(w, MAX(item->want.w, item->max.w)); 311 w = MIN(w, MAX(item->want.w, item->max.w));
313 h = w * item->aspect[1] / item->aspect[0]; 312 h = w * item->aspect.h / item->aspect.w;
314 } 313 }
315 else 314 else
316 { 315 {
317 h = MIN(h, MAX(item->want.h, item->max.h)); 316 h = MIN(h, MAX(item->want.h, item->max.h));
318 w = h * item->aspect[0] / item->aspect[1]; 317 w = h * item->aspect.w / item->aspect.h;
319 } 318 }
320 w = w - item->pad[0] - item->pad[1]; 319 w = w - item->pad[0] - item->pad[1];
321 h = h - item->pad[2] - item->pad[3]; 320 h = h - item->pad[2] - item->pad[3];
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 258755f..46c97b5 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -5951,14 +5951,14 @@ _win_aspect_get(Efl_Ui_Win_Data *sd)
5951 5951
5952EOLIAN static void 5952EOLIAN static void
5953_efl_ui_win_efl_gfx_size_hint_hint_aspect_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd, 5953_efl_ui_win_efl_gfx_size_hint_hint_aspect_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd,
5954 Efl_Gfx_Size_Hint_Aspect mode, int w, int h) 5954 Efl_Gfx_Size_Hint_Aspect mode, Eina_Size2D sz)
5955{ 5955{
5956 if (h) _win_aspect_set(pd, (double) w / (double) h); 5956 if (sz.h) _win_aspect_set(pd, (double) sz.w / (double) sz.h);
5957 else _win_aspect_set(pd, 0.0); 5957 else _win_aspect_set(pd, 0.0);
5958 efl_gfx_size_hint_aspect_set(efl_super(obj, MY_CLASS), mode, w, h); 5958 efl_gfx_size_hint_aspect_set(efl_super(obj, MY_CLASS), mode, sz);
5959#ifdef HAVE_ELEMENTARY_WL2 5959#ifdef HAVE_ELEMENTARY_WL2
5960 if (pd->wl.win) 5960 if (pd->wl.win)
5961 ecore_wl2_window_aspect_set(pd->wl.win, w, h, mode); 5961 ecore_wl2_window_aspect_set(pd->wl.win, sz.w, sz.h, mode);
5962#endif 5962#endif
5963} 5963}
5964 5964
@@ -7957,10 +7957,12 @@ end:
7957EAPI void 7957EAPI void
7958elm_win_aspect_set(Eo *obj, double aspect) 7958elm_win_aspect_set(Eo *obj, double aspect)
7959{ 7959{
7960 Eina_Size2D sz = { 0, 0 };
7961
7960 if (aspect > DBL_EPSILON) 7962 if (aspect > DBL_EPSILON)
7961 efl_gfx_size_hint_aspect_set(obj, EFL_GFX_SIZE_HINT_ASPECT_NONE, 1000 * aspect, 1000); 7963 sz = EINA_SIZE2D(1000 * aspect, 1000);
7962 else 7964
7963 efl_gfx_size_hint_aspect_set(obj, EFL_GFX_SIZE_HINT_ASPECT_NONE, 0, 0); 7965 efl_gfx_size_hint_aspect_set(obj, EFL_GFX_SIZE_HINT_ASPECT_NONE, sz);
7964} 7966}
7965 7967
7966EAPI double 7968EAPI double
diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c
index 9b8810b..88261ed 100644
--- a/src/lib/evas/canvas/evas_object_main.c
+++ b/src/lib/evas/canvas/evas_object_main.c
@@ -1527,35 +1527,39 @@ _efl_canvas_object_efl_gfx_size_hint_hint_min_set(Eo *eo_obj, Evas_Object_Protec
1527} 1527}
1528 1528
1529EOLIAN static void 1529EOLIAN static void
1530_efl_canvas_object_efl_gfx_size_hint_hint_aspect_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Efl_Gfx_Size_Hint_Aspect *aspect, Evas_Coord *w, Evas_Coord *h) 1530_efl_canvas_object_efl_gfx_size_hint_hint_aspect_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Efl_Gfx_Size_Hint_Aspect *aspect, Eina_Size2D *sz)
1531{ 1531{
1532 if ((!obj->size_hints) || obj->delete_me) 1532 if ((!obj->size_hints) || obj->delete_me)
1533 { 1533 {
1534 if (aspect) *aspect = EVAS_ASPECT_CONTROL_NONE; 1534 if (aspect) *aspect = EVAS_ASPECT_CONTROL_NONE;
1535 if (w) *w = 0; 1535 if (sz) *sz = EINA_SIZE2D(0, 0);
1536 if (h) *h = 0;
1537 return; 1536 return;
1538 } 1537 }
1539 if (aspect) *aspect = obj->size_hints->aspect.mode; 1538 if (aspect) *aspect = obj->size_hints->aspect.mode;
1540 if (w) *w = obj->size_hints->aspect.size.w; 1539 if (sz)
1541 if (h) *h = obj->size_hints->aspect.size.h; 1540 {
1541 sz->w = obj->size_hints->aspect.size.w;
1542 sz->h = obj->size_hints->aspect.size.h;
1543 }
1542} 1544}
1543 1545
1544EOLIAN static void 1546EOLIAN static void
1545_efl_canvas_object_efl_gfx_size_hint_hint_aspect_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Efl_Gfx_Size_Hint_Aspect aspect, Evas_Coord w, Evas_Coord h) 1547_efl_canvas_object_efl_gfx_size_hint_hint_aspect_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Efl_Gfx_Size_Hint_Aspect aspect, Eina_Size2D sz)
1546{ 1548{
1547 if (obj->delete_me) 1549 if (obj->delete_me)
1548 return; 1550 return;
1551
1549 evas_object_async_block(obj); 1552 evas_object_async_block(obj);
1550 if (EINA_UNLIKELY(!obj->size_hints)) 1553 if (EINA_UNLIKELY(!obj->size_hints))
1551 { 1554 {
1552 if (!w && !h) return; 1555 if (!sz.w && !sz.h) return;
1553 _evas_object_size_hint_alloc(eo_obj, obj); 1556 _evas_object_size_hint_alloc(eo_obj, obj);
1554 } 1557 }
1555 if ((obj->size_hints->aspect.mode == aspect) && (obj->size_hints->aspect.size.w == w) && (obj->size_hints->aspect.size.h == h)) return; 1558 if ((obj->size_hints->aspect.mode == aspect) &&
1559 (obj->size_hints->aspect.size.w == sz.w) &&
1560 (obj->size_hints->aspect.size.h == sz.h)) return;
1556 obj->size_hints->aspect.mode = aspect; 1561 obj->size_hints->aspect.mode = aspect;
1557 obj->size_hints->aspect.size.w = w; 1562 obj->size_hints->aspect.size = sz;
1558 obj->size_hints->aspect.size.h = h;
1559 1563
1560 evas_object_inform_call_changed_size_hints(eo_obj); 1564 evas_object_inform_call_changed_size_hints(eo_obj);
1561} 1565}
@@ -2544,13 +2548,16 @@ evas_object_static_clip_get(const Evas_Object *eo_obj)
2544EAPI void 2548EAPI void
2545evas_object_size_hint_aspect_set(Evas_Object *obj, Evas_Aspect_Control aspect, Evas_Coord w, Evas_Coord h) 2549evas_object_size_hint_aspect_set(Evas_Object *obj, Evas_Aspect_Control aspect, Evas_Coord w, Evas_Coord h)
2546{ 2550{
2547 efl_gfx_size_hint_aspect_set(obj, aspect, w, h); 2551 efl_gfx_size_hint_aspect_set(obj, aspect, EINA_SIZE2D(w, h));
2548} 2552}
2549 2553
2550EAPI void 2554EAPI void
2551evas_object_size_hint_aspect_get(const Evas_Object *obj, Evas_Aspect_Control *aspect, Evas_Coord *w, Evas_Coord *h) 2555evas_object_size_hint_aspect_get(const Evas_Object *obj, Evas_Aspect_Control *aspect, Evas_Coord *w, Evas_Coord *h)
2552{ 2556{
2553 efl_gfx_size_hint_aspect_get(obj, aspect, w, h); 2557 Eina_Size2D sz = { 0, 0 };
2558 efl_gfx_size_hint_aspect_get(obj, aspect, &sz);
2559 if (w) *w = sz.w;
2560 if (h) *h = sz.h;
2554} 2561}
2555 2562
2556EAPI void 2563EAPI void
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index f071e24..fe265d8 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1004,7 +1004,7 @@ struct _Evas_Size
1004struct _Evas_Aspect 1004struct _Evas_Aspect
1005{ 1005{
1006 Evas_Aspect_Control mode; 1006 Evas_Aspect_Control mode;
1007 Evas_Size size; 1007 Eina_Size2D size;
1008}; 1008};
1009 1009
1010struct _Evas_Border 1010struct _Evas_Border