diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2020-04-06 12:38:33 +0100 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2020-04-06 12:42:22 +0100 |
commit | d6bfab70d2f0f0809e262227ffded94572800f17 (patch) | |
tree | 5ed907b7c261a06549a5b9af96b362ad905cae8b | |
parent | 5245bc03be0421e98e72deb5e1d2ddaeafae3c0f (diff) | |
download | efl-d6bfab70d2f0f0809e262227ffded94572800f17.tar.gz |
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.c | 29 |
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) static void _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd) { - Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1; + Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1, asp_w = 0, asp_h = 0; + Evas_Coord w, h; Eina_Size2D sz; + Eina_Rect geom; + Evas_Aspect_Control asp = EVAS_ASPECT_CONTROL_NONE; double ts; sd->in_calc = EINA_TRUE; @@ -778,10 +781,13 @@ _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd) ts = sd->scale; sd->scale = 1.0; sz = efl_gfx_view_size_get(obj); + geom = efl_gfx_entity_geometry_get(obj); sd->scale = ts; evas_object_size_hint_combined_min_get(obj, &minw, &minh); + evas_object_size_hint_aspect_get(obj, &asp, &asp_w, &asp_h); + if (sd->no_scale) { maxw = minw = sz.w; @@ -810,6 +816,27 @@ _efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd) maxh = sz.h * sd->scale; } } + switch (asp) + { + case EVAS_ASPECT_CONTROL_HORIZONTAL: + if (asp_w > 0) h = (geom.w * asp_h) / asp_w; + if (h > minh) minh = h; + break; + case EVAS_ASPECT_CONTROL_VERTICAL: + if (asp_h > 0) w = (geom.h * asp_w) / asp_h; + if (w > minw) minw = w; + break; + case EVAS_ASPECT_CONTROL_BOTH: + if (asp_w > 0) h = (geom.w * asp_h) / asp_w; + if (h > minh) minh = h; + if (asp_h > 0) w = (geom.h * asp_w) / asp_h; + if (w > minw) minw = w; + break; + case EVAS_ASPECT_CONTROL_NEITHER: + case EVAS_ASPECT_CONTROL_NONE: + default: + break; + } efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(minw, minh)); efl_gfx_hint_size_restricted_max_set(obj, EINA_SIZE2D(maxw, maxh)); |