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
This commit is contained in:
Mike Blumenkrantz 2019-10-14 09:30:23 -04:00
parent dc5c17a104
commit 95b5731461
3 changed files with 19 additions and 2 deletions

View File

@ -175,6 +175,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)))
{
@ -186,7 +187,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);
@ -218,7 +219,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
@ -1918,6 +1919,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

View File

@ -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;

View File

@ -82,6 +82,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;
/**