From c2639376046e7bfd9b28da3fffe9faab962e6440 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 14 Oct 2019 09:30:23 -0400 Subject: [PATCH] elm/layout: add some workarounds to try handling legacy min sizes Summary: if a legacy widget calls evas_object_size_hint_min_set, this actually sets efl_gfx_hint_size_restricted_min now, which is supposed to be the hint that is used internally by widgets. as a result, there is a conflict between the size which the user expects and the size which the widget tries to calculate. the user size should always be respected, however, so this adds some tracking to determine whether the layout's min size was set by the layout during its own calc or by something externally @fix Reviewers: eagleeye, CHAN, woohyun, Jaehyun_Cho, cedric Reviewed By: cedric Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10373 --- src/lib/elementary/efl_ui_layout.c | 18 ++++++++++++++++-- src/lib/elementary/efl_ui_layout_legacy_eo.c | 1 + src/lib/elementary/elm_widget_layout.h | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c index 9cadf82..12c7696 100644 --- a/src/lib/elementary/efl_ui_layout.c +++ b/src/lib/elementary/efl_ui_layout.c @@ -190,6 +190,7 @@ _sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd, Elm_Layout_Data *ld) ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd); if (!efl_alive_get(obj)) return; + if (ld) ld->in_calc = EINA_TRUE; if (sd->calc_subobjs && !evas_smart_objects_calculating_get(evas_object_evas_get(obj))) { @@ -201,7 +202,7 @@ _sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd, Elm_Layout_Data *ld) } elm_coords_finger_size_adjust(sd->finger_size_multiplier_x, &rest_w, sd->finger_size_multiplier_y, &rest_h); - if (ld) + if (ld && ld->user_min_sz) sz = efl_gfx_hint_size_combined_min_get(obj); else sz = efl_gfx_hint_size_min_get(obj); @@ -233,7 +234,7 @@ _sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd, Elm_Layout_Data *ld) efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(minw, minh)); if (ld) - ld->restricted_calc_w = ld->restricted_calc_h = EINA_FALSE; + ld->in_calc = ld->restricted_calc_w = ld->restricted_calc_h = EINA_FALSE; } void @@ -2104,6 +2105,19 @@ _elm_layout_efl_canvas_group_change(Eo *obj, Elm_Layout_Data *ld) efl_canvas_group_change(efl_super(obj, ELM_LAYOUT_MIXIN)); } +EOLIAN static void +_elm_layout_efl_gfx_hint_size_restricted_min_set(Eo *obj, Elm_Layout_Data *ld, Eina_Size2D sz) +{ + /* correctly handle legacy case where the user has set a min size hint on the object: + * in legacy code, only restricted_min existed, which resulted in conflicts between + * internal sizing and user-expected sizing. we attempt to simulate this now in a more controlled + * manner by only checking this hint during sizing calcs if the user has set it + */ + if (!ld->in_calc) + ld->user_min_sz = (sz.w > 0) || (sz.h > 0); + efl_gfx_hint_size_restricted_min_set(efl_super(obj, ELM_LAYOUT_MIXIN), sz); +} + /* layout's sizing evaluation is deferred. evaluation requests are * queued up and only flag the object as 'changed'. when it comes to * Evas's rendering phase, it will be addressed, finally (see diff --git a/src/lib/elementary/efl_ui_layout_legacy_eo.c b/src/lib/elementary/efl_ui_layout_legacy_eo.c index 33056b5..e08568e 100644 --- a/src/lib/elementary/efl_ui_layout_legacy_eo.c +++ b/src/lib/elementary/efl_ui_layout_legacy_eo.c @@ -50,6 +50,7 @@ _elm_layout_class_initializer(Efl_Class *klass) EFL_OPS_DEFINE(ops, EFL_OBJECT_OP_FUNC(elm_layout_sizing_eval, _elm_layout_sizing_eval), EFL_OBJECT_OP_FUNC(efl_canvas_group_change, _elm_layout_efl_canvas_group_change), + EFL_OBJECT_OP_FUNC(efl_gfx_hint_size_restricted_min_set, _elm_layout_efl_gfx_hint_size_restricted_min_set), ELM_LAYOUT_EXTRA_OPS ); opsp = &ops; diff --git a/src/lib/elementary/elm_widget_layout.h b/src/lib/elementary/elm_widget_layout.h index 0e7bf3a..4cea96f 100644 --- a/src/lib/elementary/elm_widget_layout.h +++ b/src/lib/elementary/elm_widget_layout.h @@ -83,6 +83,8 @@ typedef struct _Elm_Layout_Data Eina_Bool needs_size_calc : 1; /**< This flag is set true when the layout sizing eval is already requested. This defers sizing evaluation until smart calculation to avoid unnecessary calculation. */ Eina_Bool restricted_calc_w : 1; /**< This is a flag to support edje restricted_calc in w axis. */ Eina_Bool restricted_calc_h : 1; /**< This is a flag to support edje restricted_calc in y axis. */ + Eina_Bool in_calc : 1; /**< object is currently in group_calc */ + Eina_Bool user_min_sz : 1; /**< min size was set by user (legacy only has restricted min) */ } Elm_Layout_Data; /** -- 2.7.4