summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-07-30 13:11:35 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-07-30 13:12:52 -0400
commite583eba56b2a27a1a7cbad5983a3f1958caed184 (patch)
tree7af18313d1840b434eaf2e793c4cb5e41d193281 /src/lib
parent46cf288d32f06a0c82ef227c65e55062bf494672 (diff)
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
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/elementary/efl_ui_layout.c50
-rw-r--r--src/lib/elementary/efl_ui_layout.eo4
-rw-r--r--src/lib/elementary/efl_ui_layout_base.eo20
-rw-r--r--src/lib/elementary/elm_widget_layout.h2
4 files changed, 71 insertions, 5 deletions
diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c
index f36455773c..c040d2dcd3 100644
--- a/src/lib/elementary/efl_ui_layout.c
+++ b/src/lib/elementary/efl_ui_layout.c
@@ -160,7 +160,7 @@ _part_cursor_free(Efl_Ui_Layout_Sub_Object_Cursor *pc)
160} 160}
161 161
162static void 162static void
163_sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd, Eina_Bool finger) 163_sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd)
164{ 164{
165 int minh = 0, minw = 0; 165 int minh = 0, minw = 0;
166 int rest_w = 0, rest_h = 0; 166 int rest_w = 0, rest_h = 0;
@@ -169,8 +169,8 @@ _sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd, Eina_Bool finger)
169 169
170 if (!efl_alive_get(obj)) return; 170 if (!efl_alive_get(obj)) return;
171 171
172 if (finger) 172 elm_coords_finger_size_adjust(sd->finger_size_multiplier_x, &rest_w,
173 elm_coords_finger_size_adjust(1, &rest_w, 1, &rest_h); 173 sd->finger_size_multiplier_y, &rest_h);
174 if (elm_widget_is_legacy(obj)) 174 if (elm_widget_is_legacy(obj))
175 sz = efl_gfx_hint_size_combined_min_get(obj); 175 sz = efl_gfx_hint_size_combined_min_get(obj);
176 else 176 else
@@ -190,6 +190,13 @@ _sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd, Eina_Bool finger)
190 190
191 edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh, 191 edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh,
192 rest_w, rest_h); 192 rest_w, rest_h);
193 /* if desired, scale layout by finger size */
194 if (sd->finger_size_multiplier_x)
195 elm_coords_finger_size_adjust(sd->finger_size_multiplier_x, &minw,
196 sd->finger_size_multiplier_y, NULL);
197 if (sd->finger_size_multiplier_y)
198 elm_coords_finger_size_adjust(sd->finger_size_multiplier_x, NULL,
199 sd->finger_size_multiplier_y, &minh);
193 evas_object_size_hint_min_set(obj, minw, minh); 200 evas_object_size_hint_min_set(obj, minw, minh);
194 201
195 sd->restricted_calc_w = sd->restricted_calc_h = EINA_FALSE; 202 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
854 Eina_Bool legacy = elm_widget_is_legacy(obj); 861 Eina_Bool legacy = elm_widget_is_legacy(obj);
855 efl_canvas_group_need_recalculate_set(obj, EINA_FALSE); 862 efl_canvas_group_need_recalculate_set(obj, EINA_FALSE);
856 if ((!legacy) || sd->needs_size_calc) 863 if ((!legacy) || sd->needs_size_calc)
857 /* don't add finger size if this is an actual elm_layout object */ 864 _sizing_eval(obj, sd);
858 _sizing_eval(obj, sd, !legacy);
859 sd->needs_size_calc = EINA_FALSE; 865 sd->needs_size_calc = EINA_FALSE;
860} 866}
861 867
868EOLIAN static void
869_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)
870{
871 if (mult_x)
872 *mult_x = sd->finger_size_multiplier_x;
873 if (mult_y)
874 *mult_y = sd->finger_size_multiplier_y;
875}
876
877EOLIAN static void
878_efl_ui_layout_base_finger_size_multiplier_set(Eo *obj, Efl_Ui_Layout_Data *sd, unsigned int mult_x, unsigned int mult_y)
879{
880 if ((sd->finger_size_multiplier_x == mult_x) &&
881 (sd->finger_size_multiplier_y == mult_y))
882 return;
883 sd->finger_size_multiplier_x = mult_x;
884 sd->finger_size_multiplier_y = mult_y;
885 if (efl_alive_get(obj))
886 efl_canvas_group_change(obj);
887}
888
862static Efl_Ui_Layout_Sub_Object_Cursor * 889static Efl_Ui_Layout_Sub_Object_Cursor *
863_parts_cursors_find(Efl_Ui_Layout_Data *sd, 890_parts_cursors_find(Efl_Ui_Layout_Data *sd,
864 const char *part) 891 const char *part)
@@ -2458,9 +2485,22 @@ _efl_ui_layout_base_efl_ui_factory_bind_factory_bind(Eo *obj EINA_UNUSED, Efl_Ui
2458} 2485}
2459 2486
2460EOLIAN static Eo * 2487EOLIAN static Eo *
2488_efl_ui_layout_efl_object_constructor(Eo *obj, void *_pd EINA_UNUSED)
2489{
2490 obj = efl_constructor(efl_super(obj, EFL_UI_LAYOUT_CLASS));
2491 Efl_Ui_Layout_Data *sd = efl_data_scope_get(obj, MY_CLASS);
2492
2493 /* basic layouts should not obey finger size */
2494 sd->finger_size_multiplier_x = sd->finger_size_multiplier_y = 0;
2495
2496 return obj;
2497}
2498
2499EOLIAN static Eo *
2461_efl_ui_layout_base_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Data *sd) 2500_efl_ui_layout_base_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Data *sd)
2462{ 2501{
2463 sd->obj = obj; 2502 sd->obj = obj;
2503 sd->finger_size_multiplier_x = sd->finger_size_multiplier_y = 1;
2464 obj = efl_constructor(efl_super(obj, MY_CLASS)); 2504 obj = efl_constructor(efl_super(obj, MY_CLASS));
2465 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks); 2505 evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
2466 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_FILLER); 2506 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_FILLER);
diff --git a/src/lib/elementary/efl_ui_layout.eo b/src/lib/elementary/efl_ui_layout.eo
index 1f04fc023c..7e3de17a05 100644
--- a/src/lib/elementary/efl_ui_layout.eo
+++ b/src/lib/elementary/efl_ui_layout.eo
@@ -8,6 +8,9 @@ class Efl.Ui.Layout extends Efl.Ui.Layout_Base implements Efl.File
8 the group that the data belongs to, in case it's an EET file 8 the group that the data belongs to, in case it's an EET file
9 (including Edje files). 9 (including Edje files).
10 10
11 By default, layouts do not apply the finger_size global configuration value
12 when calculating their geometries.
13
11 @since 1.22 14 @since 1.22
12 ]] 15 ]]
13 data: null; 16 data: null;
@@ -16,6 +19,7 @@ class Efl.Ui.Layout extends Efl.Ui.Layout_Base implements Efl.File
16 Efl.File.key { get; set; } 19 Efl.File.key { get; set; }
17 Efl.File.mmap { get; set; } 20 Efl.File.mmap { get; set; }
18 Efl.File.load; 21 Efl.File.load;
22 Efl.Object.constructor;
19 Efl.Canvas.Group.group_calculate; 23 Efl.Canvas.Group.group_calculate;
20 } 24 }
21} 25}
diff --git a/src/lib/elementary/efl_ui_layout_base.eo b/src/lib/elementary/efl_ui_layout_base.eo
index 1266dcef85..b66095f87b 100644
--- a/src/lib/elementary/efl_ui_layout_base.eo
+++ b/src/lib/elementary/efl_ui_layout_base.eo
@@ -12,6 +12,26 @@ abstract Efl.Ui.Layout_Base extends Efl.Ui.Widget implements Efl.Container,
12 c_prefix: efl_ui_layout; 12 c_prefix: efl_ui_layout;
13 data: Efl_Ui_Layout_Data; 13 data: Efl_Ui_Layout_Data;
14 methods { 14 methods {
15 @property finger_size_multiplier {
16 [[Set a multiplier for applying finger size to the layout.
17
18 By default, any widget which inherits from this class will apply
19 the finger_size global config value with a 1:1 width:height ratio during sizing
20 calculations. This will cause the widget to scale its size based on the finger_size
21 config value.
22
23 To disable finger_size in a layout's sizing calculations, set the multipliers for both
24 axes to 0.
25
26 @since 1.23
27 ]]
28 set {}
29 get {}
30 values {
31 multiplier_x: uint; [[Multiplier for X axis.]]
32 multiplier_y: uint; [[Multiplier for Y axis.]]
33 }
34 }
15 @property theme { 35 @property theme {
16 [[The theme of this widget, defines which edje group will be used. 36 [[The theme of this widget, defines which edje group will be used.
17 37
diff --git a/src/lib/elementary/elm_widget_layout.h b/src/lib/elementary/elm_widget_layout.h
index d8de1d4bde..1eb49bb2b3 100644
--- a/src/lib/elementary/elm_widget_layout.h
+++ b/src/lib/elementary/elm_widget_layout.h
@@ -64,6 +64,8 @@ typedef struct _Elm_Layout_Smart_Data
64 64
65 int frozen; /**< Layout freeze counter */ 65 int frozen; /**< Layout freeze counter */
66 66
67 unsigned int finger_size_multiplier_x, finger_size_multiplier_y; /**< multipliers for finger_size during group_calc */
68
67 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. */ 69 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. */
68 Eina_Bool restricted_calc_w : 1; /**< This is a flag to support edje restricted_calc in w axis. */ 70 Eina_Bool restricted_calc_w : 1; /**< This is a flag to support edje restricted_calc in w axis. */
69 Eina_Bool restricted_calc_h : 1; /**< This is a flag to support edje restricted_calc in y axis. */ 71 Eina_Bool restricted_calc_h : 1; /**< This is a flag to support edje restricted_calc in y axis. */