summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-04-06 19:33:30 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-04-06 19:34:25 +0100
commitcd4508150d3ce07ae7e431af7a86216d5c19a494 (patch)
tree0c201eb218156f9828892cb1351d762261c56949
parentd6bfab70d2f0f0809e262227ffded94572800f17 (diff)
elm icon/image efl ui image - respect aspect hints at all if set
these did not even look at aspect hints when calculating sizing. that means any attempt to set them would lead to... nothing useful. this handles horiz/vert/both cases (as best as is possible). @fix This reverts previous commit and fixes it in the box layout to respect aspect in elm boxes. note - this probably needs doing in other containers too like table... Revert "elm icon/image efl ui image - respect aspect hints at all if set"
-rw-r--r--src/lib/elementary/efl_ui_image.c29
-rw-r--r--src/lib/elementary/els_box.c30
2 files changed, 20 insertions, 39 deletions
diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c
index 47bd561138..1ba7fe5037 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -764,11 +764,8 @@ _key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
764static void 764static void
765_efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd) 765_efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd)
766{ 766{
767 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1, asp_w = 0, asp_h = 0; 767 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
768 Evas_Coord w, h;
769 Eina_Size2D sz; 768 Eina_Size2D sz;
770 Eina_Rect geom;
771 Evas_Aspect_Control asp = EVAS_ASPECT_CONTROL_NONE;
772 double ts; 769 double ts;
773 770
774 sd->in_calc = EINA_TRUE; 771 sd->in_calc = EINA_TRUE;
@@ -781,13 +778,10 @@ _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd)
781 ts = sd->scale; 778 ts = sd->scale;
782 sd->scale = 1.0; 779 sd->scale = 1.0;
783 sz = efl_gfx_view_size_get(obj); 780 sz = efl_gfx_view_size_get(obj);
784 geom = efl_gfx_entity_geometry_get(obj);
785 781
786 sd->scale = ts; 782 sd->scale = ts;
787 evas_object_size_hint_combined_min_get(obj, &minw, &minh); 783 evas_object_size_hint_combined_min_get(obj, &minw, &minh);
788 784
789 evas_object_size_hint_aspect_get(obj, &asp, &asp_w, &asp_h);
790
791 if (sd->no_scale) 785 if (sd->no_scale)
792 { 786 {
793 maxw = minw = sz.w; 787 maxw = minw = sz.w;
@@ -816,27 +810,6 @@ _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd)
816 maxh = sz.h * sd->scale; 810 maxh = sz.h * sd->scale;
817 } 811 }
818 } 812 }
819 switch (asp)
820 {
821 case EVAS_ASPECT_CONTROL_HORIZONTAL:
822 if (asp_w > 0) h = (geom.w * asp_h) / asp_w;
823 if (h > minh) minh = h;
824 break;
825 case EVAS_ASPECT_CONTROL_VERTICAL:
826 if (asp_h > 0) w = (geom.h * asp_w) / asp_h;
827 if (w > minw) minw = w;
828 break;
829 case EVAS_ASPECT_CONTROL_BOTH:
830 if (asp_w > 0) h = (geom.w * asp_h) / asp_w;
831 if (h > minh) minh = h;
832 if (asp_h > 0) w = (geom.h * asp_w) / asp_h;
833 if (w > minw) minw = w;
834 break;
835 case EVAS_ASPECT_CONTROL_NEITHER:
836 case EVAS_ASPECT_CONTROL_NONE:
837 default:
838 break;
839 }
840 813
841 efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(minw, minh)); 814 efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(minw, minh));
842 efl_gfx_hint_size_restricted_max_set(obj, EINA_SIZE2D(maxw, maxh)); 815 efl_gfx_hint_size_restricted_max_set(obj, EINA_SIZE2D(maxw, maxh));
diff --git a/src/lib/elementary/els_box.c b/src/lib/elementary/els_box.c
index b870c9deeb..9d7b4644bf 100644
--- a/src/lib/elementary/els_box.c
+++ b/src/lib/elementary/els_box.c
@@ -329,17 +329,22 @@ _smart_extents_calculate(Evas_Object *box, Evas_Object_Box_Data *priv, int w, in
329 else 329 else
330 { 330 {
331 /* returns true if at least one item has aspect hint */ 331 /* returns true if at least one item has aspect hint */
332 if (_smart_extents_non_homogeneous_calc(priv, w, h, &minw, &minh, &maxw, &maxh, expand, horizontal, 0)) 332 if (_smart_extents_non_homogeneous_calc(priv, w, h, &minw, &minh,
333 &maxw, &maxh, expand,
334 horizontal, EINA_FALSE))
333 { 335 {
334 /* aspect can only be accurately calculated after the full (non-aspected) min size of the box has 336 /* aspect can only be accurately calculated after the full (non-aspected) min size of the box has
335 * been calculated due to the use of this min size during aspect calculations 337 * been calculated due to the use of this min size during aspect calculations
336 */ 338 */
337 int aminw = minw; 339 int aminw = minw;
338 int aminh = minh; 340 int aminh = minh;
339 _smart_extents_padding_calc(priv, &minw, &minh, &maxw, &maxh, horizontal); 341 _smart_extents_padding_calc(priv, &minw, &minh, &maxw, &maxh,
340 _smart_extents_non_homogeneous_calc(priv, w, h, &aminw, &aminh, &maxw, &maxh, expand, horizontal, 1); 342 horizontal);
341 if (horizontal) minh = aminh; 343 _smart_extents_non_homogeneous_calc(priv, w, h, &aminw, &aminh,
342 else minw = aminw; 344 &maxw, &maxh, expand,
345 horizontal, EINA_TRUE);
346 if (horizontal) minw = aminw;
347 else minh = aminh;
343 } 348 }
344 } 349 }
345 _smart_extents_padding_calc(priv, &minw, &minh, &maxw, &maxh, horizontal); 350 _smart_extents_padding_calc(priv, &minw, &minh, &maxw, &maxh, horizontal);
@@ -454,11 +459,13 @@ _els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, Eina_Bool horizontal
454 } 459 }
455 hh = h; 460 hh = h;
456 461
457 _box_object_aspect_calc(&ow, &oh, mnw, mnh, mxw, mxh, fw, fh, ww, hh, aspect, asx / (double)asy); 462 _box_object_aspect_calc(&ow, &oh, mnw, mnh, mxw, mxh, fw, fh,
458 /* non-homogeneous, aspected, expending items are calculated based on object size 463 ww, hh, aspect, asx / (double)asy);
459 * during extents calc, so use this for positioning during layout as well 464 /* non-homogeneous, aspected, expending items are calculated
465 * based on object size during extents calc, so use this for
466 * positioning during layout as well
460 */ 467 */
461 if (xw && aspect && (!homogeneous)) 468 if (aspect && (!homogeneous))
462 ww = ow; 469 ww = ow;
463 evas_object_move(obj, 470 evas_object_move(obj,
464 ((!rtl) ? (xx + pad_l) : (x + (w - (xx - x) - ww) + pad_r)) 471 ((!rtl) ? (xx + pad_l) : (x + (w - (xx - x) - ww) + pad_r))
@@ -489,8 +496,9 @@ _els_box_layout(Evas_Object *o, Evas_Object_Box_Data *priv, Eina_Bool horizontal
489 } 496 }
490 ww = w; 497 ww = w;
491 498
492 _box_object_aspect_calc(&ow, &oh, mnw, mnh, mxw, mxh, fw, fh, ww, hh, aspect, asx / (double)asy); 499 _box_object_aspect_calc(&ow, &oh, mnw, mnh, mxw, mxh, fw, fh,
493 if (xh && aspect && (!homogeneous)) 500 ww, hh, aspect, asx / (double)asy);
501 if (aspect && (!homogeneous))
494 hh = oh; 502 hh = oh;
495 evas_object_move(obj, 503 evas_object_move(obj,
496 xx + (Evas_Coord)(((double)(ww - ow)) * ax) + pad_l, 504 xx + (Evas_Coord)(((double)(ww - ow)) * ax) + pad_l,