efl_ui/layout_base: add "finger_size_multiplier" property

Summary:
this feature is set on objects which inherit from layout_base in order to
allow automatically application of variable finger sizes based on a
widget's needs

an example of this would be a calendar, which is 7:8 fingers

this functionality is disabled by passing 0,0 as the property

@feature

Depends on D9436

Reviewers: bu5hm4n

Reviewed By: bu5hm4n

Subscribers: segfaultxavi, cedric, #reviewers, #committers

Tags: #efl_widgets

Maniphest Tasks: T8059

Differential Revision: https://phab.enlightenment.org/D9437
This commit is contained in:
Mike Blumenkrantz 2019-07-30 13:11:35 -04:00
parent 46cf288d32
commit e583eba56b
4 changed files with 71 additions and 5 deletions

View File

@ -160,7 +160,7 @@ _part_cursor_free(Efl_Ui_Layout_Sub_Object_Cursor *pc)
} }
static void static void
_sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd, Eina_Bool finger) _sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd)
{ {
int minh = 0, minw = 0; int minh = 0, minw = 0;
int rest_w = 0, rest_h = 0; int rest_w = 0, rest_h = 0;
@ -169,8 +169,8 @@ _sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd, Eina_Bool finger)
if (!efl_alive_get(obj)) return; if (!efl_alive_get(obj)) return;
if (finger) elm_coords_finger_size_adjust(sd->finger_size_multiplier_x, &rest_w,
elm_coords_finger_size_adjust(1, &rest_w, 1, &rest_h); sd->finger_size_multiplier_y, &rest_h);
if (elm_widget_is_legacy(obj)) if (elm_widget_is_legacy(obj))
sz = efl_gfx_hint_size_combined_min_get(obj); sz = efl_gfx_hint_size_combined_min_get(obj);
else else
@ -190,6 +190,13 @@ _sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd, Eina_Bool finger)
edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh, edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh,
rest_w, rest_h); rest_w, rest_h);
/* if desired, scale layout by finger size */
if (sd->finger_size_multiplier_x)
elm_coords_finger_size_adjust(sd->finger_size_multiplier_x, &minw,
sd->finger_size_multiplier_y, NULL);
if (sd->finger_size_multiplier_y)
elm_coords_finger_size_adjust(sd->finger_size_multiplier_x, NULL,
sd->finger_size_multiplier_y, &minh);
evas_object_size_hint_min_set(obj, minw, minh); evas_object_size_hint_min_set(obj, minw, minh);
sd->restricted_calc_w = sd->restricted_calc_h = EINA_FALSE; sd->restricted_calc_w = sd->restricted_calc_h = EINA_FALSE;
@ -854,11 +861,31 @@ _efl_ui_layout_base_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Layout_Data
Eina_Bool legacy = elm_widget_is_legacy(obj); Eina_Bool legacy = elm_widget_is_legacy(obj);
efl_canvas_group_need_recalculate_set(obj, EINA_FALSE); efl_canvas_group_need_recalculate_set(obj, EINA_FALSE);
if ((!legacy) || sd->needs_size_calc) if ((!legacy) || sd->needs_size_calc)
/* don't add finger size if this is an actual elm_layout object */ _sizing_eval(obj, sd);
_sizing_eval(obj, sd, !legacy);
sd->needs_size_calc = EINA_FALSE; sd->needs_size_calc = EINA_FALSE;
} }
EOLIAN static void
_efl_ui_layout_base_finger_size_multiplier_get(const Eo *obj EINA_UNUSED, Efl_Ui_Layout_Data *sd, unsigned int *mult_x, unsigned int *mult_y)
{
if (mult_x)
*mult_x = sd->finger_size_multiplier_x;
if (mult_y)
*mult_y = sd->finger_size_multiplier_y;
}
EOLIAN static void
_efl_ui_layout_base_finger_size_multiplier_set(Eo *obj, Efl_Ui_Layout_Data *sd, unsigned int mult_x, unsigned int mult_y)
{
if ((sd->finger_size_multiplier_x == mult_x) &&
(sd->finger_size_multiplier_y == mult_y))
return;
sd->finger_size_multiplier_x = mult_x;
sd->finger_size_multiplier_y = mult_y;
if (efl_alive_get(obj))
efl_canvas_group_change(obj);
}
static Efl_Ui_Layout_Sub_Object_Cursor * static Efl_Ui_Layout_Sub_Object_Cursor *
_parts_cursors_find(Efl_Ui_Layout_Data *sd, _parts_cursors_find(Efl_Ui_Layout_Data *sd,
const char *part) const char *part)
@ -2457,10 +2484,23 @@ _efl_ui_layout_base_efl_ui_factory_bind_factory_bind(Eo *obj EINA_UNUSED, Efl_Ui
_efl_ui_layout_view_model_content_update(pd, tracking, ss_key); _efl_ui_layout_view_model_content_update(pd, tracking, ss_key);
} }
EOLIAN static Eo *
_efl_ui_layout_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, EFL_UI_LAYOUT_CLASS));
Efl_Ui_Layout_Data *sd = efl_data_scope_get(obj, MY_CLASS);
/* basic layouts should not obey finger size */
sd->finger_size_multiplier_x = sd->finger_size_multiplier_y = 0;
return obj;
}
EOLIAN static Eo * EOLIAN static Eo *
_efl_ui_layout_base_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Data *sd) _efl_ui_layout_base_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Data *sd)
{ {
sd->obj = obj; sd->obj = obj;
sd->finger_size_multiplier_x = sd->finger_size_multiplier_y = 1;
obj = efl_constructor(efl_super(obj, MY_CLASS)); obj = efl_constructor(efl_super(obj, MY_CLASS));
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_FILLER); efl_access_object_role_set(obj, EFL_ACCESS_ROLE_FILLER);

View File

@ -8,6 +8,9 @@ class Efl.Ui.Layout extends Efl.Ui.Layout_Base implements Efl.File
the group that the data belongs to, in case it's an EET file the group that the data belongs to, in case it's an EET file
(including Edje files). (including Edje files).
By default, layouts do not apply the finger_size global configuration value
when calculating their geometries.
@since 1.22 @since 1.22
]] ]]
data: null; data: null;
@ -16,6 +19,7 @@ class Efl.Ui.Layout extends Efl.Ui.Layout_Base implements Efl.File
Efl.File.key { get; set; } Efl.File.key { get; set; }
Efl.File.mmap { get; set; } Efl.File.mmap { get; set; }
Efl.File.load; Efl.File.load;
Efl.Object.constructor;
Efl.Canvas.Group.group_calculate; Efl.Canvas.Group.group_calculate;
} }
} }

View File

@ -12,6 +12,26 @@ abstract Efl.Ui.Layout_Base extends Efl.Ui.Widget implements Efl.Container,
c_prefix: efl_ui_layout; c_prefix: efl_ui_layout;
data: Efl_Ui_Layout_Data; data: Efl_Ui_Layout_Data;
methods { methods {
@property finger_size_multiplier {
[[Set a multiplier for applying finger size to the layout.
By default, any widget which inherits from this class will apply
the finger_size global config value with a 1:1 width:height ratio during sizing
calculations. This will cause the widget to scale its size based on the finger_size
config value.
To disable finger_size in a layout's sizing calculations, set the multipliers for both
axes to 0.
@since 1.23
]]
set {}
get {}
values {
multiplier_x: uint; [[Multiplier for X axis.]]
multiplier_y: uint; [[Multiplier for Y axis.]]
}
}
@property theme { @property theme {
[[The theme of this widget, defines which edje group will be used. [[The theme of this widget, defines which edje group will be used.

View File

@ -64,6 +64,8 @@ typedef struct _Elm_Layout_Smart_Data
int frozen; /**< Layout freeze counter */ int frozen; /**< Layout freeze counter */
unsigned int finger_size_multiplier_x, finger_size_multiplier_y; /**< multipliers for finger_size during group_calc */
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 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_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 restricted_calc_h : 1; /**< This is a flag to support edje restricted_calc in y axis. */