summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-04-06 12:38:33 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-04-06 12:42:22 +0100
commitd6bfab70d2f0f0809e262227ffded94572800f17 (patch)
tree5ed907b7c261a06549a5b9af96b362ad905cae8b
parent5245bc03be0421e98e72deb5e1d2ddaeafae3c0f (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
-rw-r--r--src/lib/elementary/efl_ui_image.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c
index 1ba7fe5037..47bd561138 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -764,8 +764,11 @@ _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; 767 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1, asp_w = 0, asp_h = 0;
768 Evas_Coord w, h;
768 Eina_Size2D sz; 769 Eina_Size2D sz;
770 Eina_Rect geom;
771 Evas_Aspect_Control asp = EVAS_ASPECT_CONTROL_NONE;
769 double ts; 772 double ts;
770 773
771 sd->in_calc = EINA_TRUE; 774 sd->in_calc = EINA_TRUE;
@@ -778,10 +781,13 @@ _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd)
778 ts = sd->scale; 781 ts = sd->scale;
779 sd->scale = 1.0; 782 sd->scale = 1.0;
780 sz = efl_gfx_view_size_get(obj); 783 sz = efl_gfx_view_size_get(obj);
784 geom = efl_gfx_entity_geometry_get(obj);
781 785
782 sd->scale = ts; 786 sd->scale = ts;
783 evas_object_size_hint_combined_min_get(obj, &minw, &minh); 787 evas_object_size_hint_combined_min_get(obj, &minw, &minh);
784 788
789 evas_object_size_hint_aspect_get(obj, &asp, &asp_w, &asp_h);
790
785 if (sd->no_scale) 791 if (sd->no_scale)
786 { 792 {
787 maxw = minw = sz.w; 793 maxw = minw = sz.w;
@@ -810,6 +816,27 @@ _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd)
810 maxh = sz.h * sd->scale; 816 maxh = sz.h * sd->scale;
811 } 817 }
812 } 818 }
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 }
813 840
814 efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(minw, minh)); 841 efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(minw, minh));
815 efl_gfx_hint_size_restricted_max_set(obj, EINA_SIZE2D(maxw, maxh)); 842 efl_gfx_hint_size_restricted_max_set(obj, EINA_SIZE2D(maxw, maxh));