summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-08-22 15:16:54 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-08-23 11:16:45 +0900
commit06ec847a7c13a8f7f43a5216264ea7a4e25c4bee (patch)
treee378368a8f404dff10a06e543fe3f44a94880f90
parent509ed86cdf583decedd00f701d45bd412420a0fd (diff)
widget: Use EO function pointer for on_show_region
This is as much a test of the EO function pointer as it is a clean up of this widget API.
-rw-r--r--src/lib/elementary/efl_ui_text.c11
-rw-r--r--src/lib/elementary/elm_entry.c13
-rw-r--r--src/lib/elementary/elm_genlist.c14
-rw-r--r--src/lib/elementary/elm_list.c10
-rw-r--r--src/lib/elementary/elm_scroller.c16
-rw-r--r--src/lib/elementary/elm_widget.c17
-rw-r--r--src/lib/elementary/elm_widget.eo29
-rw-r--r--src/lib/elementary/elm_widget.h8
8 files changed, 55 insertions, 63 deletions
diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c
index 147509dc98..42131b01b0 100644
--- a/src/lib/elementary/efl_ui_text.c
+++ b/src/lib/elementary/efl_ui_text.c
@@ -1234,12 +1234,9 @@ _efl_ui_text_elm_widget_on_focus_region(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *s
1234} 1234}
1235 1235
1236static void 1236static void
1237_show_region_hook(void *data EINA_UNUSED, 1237_show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rectangle r)
1238 Evas_Object *obj)
1239{ 1238{
1240 Evas_Coord x, y, w, h; 1239 elm_interface_scrollable_content_region_show(obj, r.x, r.y, r.w, r.h);
1241 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1242 elm_interface_scrollable_content_region_show(obj, x, y, w, h);
1243} 1240}
1244 1241
1245EOLIAN static Eina_Bool 1242EOLIAN static Eina_Bool
@@ -3731,7 +3728,7 @@ _efl_ui_text_scrollable_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool scroll)
3731 elm_interface_scrollable_policy_set(obj, sd->policy_h, sd->policy_v); 3728 elm_interface_scrollable_policy_set(obj, sd->policy_h, sd->policy_v);
3732 elm_interface_scrollable_content_set(obj, sd->entry_edje); 3729 elm_interface_scrollable_content_set(obj, sd->entry_edje);
3733 elm_interface_scrollable_content_viewport_resize_cb_set(obj, _efl_ui_text_content_viewport_resize_cb); 3730 elm_interface_scrollable_content_viewport_resize_cb_set(obj, _efl_ui_text_content_viewport_resize_cb);
3734 elm_widget_on_show_region_hook_set(obj, _show_region_hook, NULL); 3731 elm_widget_on_show_region_hook_set(obj, NULL, _show_region_hook, NULL);
3735 } 3732 }
3736 else 3733 else
3737 { 3734 {
@@ -3747,7 +3744,7 @@ _efl_ui_text_scrollable_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool scroll)
3747 3744
3748 elm_interface_scrollable_objects_set(obj, sd->entry_edje, sd->hit_rect); 3745 elm_interface_scrollable_objects_set(obj, sd->entry_edje, sd->hit_rect);
3749 3746
3750 elm_widget_on_show_region_hook_set(obj, NULL, NULL); 3747 elm_widget_on_show_region_hook_set(obj, NULL, NULL, NULL);
3751 } 3748 }
3752 _update_decorations(obj); 3749 _update_decorations(obj);
3753 elm_obj_widget_theme_apply(obj); 3750 elm_obj_widget_theme_apply(obj);
diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c
index cba0fe5691..a203d0d170 100644
--- a/src/lib/elementary/elm_entry.c
+++ b/src/lib/elementary/elm_entry.c
@@ -1351,14 +1351,9 @@ _elm_entry_elm_widget_on_focus_region(Eo *obj, Elm_Entry_Data *sd, Evas_Coord *x
1351} 1351}
1352 1352
1353static void 1353static void
1354_show_region_hook(void *data EINA_UNUSED, 1354_show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rectangle r)
1355 Evas_Object *obj)
1356{ 1355{
1357 Evas_Coord x, y, w, h; 1356 elm_interface_scrollable_content_region_show(obj, r.x, r.y, r.w, r.h);
1358
1359 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1360
1361 elm_interface_scrollable_content_region_show(obj, x, y, w, h);
1362} 1357}
1363 1358
1364EOLIAN static Eina_Bool 1359EOLIAN static Eina_Bool
@@ -5047,7 +5042,7 @@ _elm_entry_scrollable_set(Eo *obj, Elm_Entry_Data *sd, Eina_Bool scroll)
5047 elm_interface_scrollable_policy_set(obj, sd->policy_h, sd->policy_v); 5042 elm_interface_scrollable_policy_set(obj, sd->policy_h, sd->policy_v);
5048 elm_interface_scrollable_content_set(obj, sd->entry_edje); 5043 elm_interface_scrollable_content_set(obj, sd->entry_edje);
5049 elm_interface_scrollable_content_viewport_resize_cb_set(obj, _elm_entry_content_viewport_resize_cb); 5044 elm_interface_scrollable_content_viewport_resize_cb_set(obj, _elm_entry_content_viewport_resize_cb);
5050 elm_widget_on_show_region_hook_set(obj, _show_region_hook, NULL); 5045 elm_widget_on_show_region_hook_set(obj, NULL, _show_region_hook, NULL);
5051 } 5046 }
5052 else 5047 else
5053 { 5048 {
@@ -5063,7 +5058,7 @@ _elm_entry_scrollable_set(Eo *obj, Elm_Entry_Data *sd, Eina_Bool scroll)
5063 5058
5064 elm_interface_scrollable_objects_set(obj, sd->entry_edje, sd->hit_rect); 5059 elm_interface_scrollable_objects_set(obj, sd->entry_edje, sd->hit_rect);
5065 5060
5066 elm_widget_on_show_region_hook_set(obj, NULL, NULL); 5061 elm_widget_on_show_region_hook_set(obj, NULL, NULL, NULL);
5067 } 5062 }
5068 sd->last_w = -1; 5063 sd->last_w = -1;
5069 elm_obj_widget_theme_apply(obj); 5064 elm_obj_widget_theme_apply(obj);
diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c
index 2fe4068117..99d2b9a8ec 100644
--- a/src/lib/elementary/elm_genlist.c
+++ b/src/lib/elementary/elm_genlist.c
@@ -3462,18 +3462,14 @@ _elm_genlist_elm_widget_theme_apply(Eo *obj, Elm_Genlist_Data *sd)
3462/* FIXME: take off later. maybe this show region coords belong in the 3462/* FIXME: take off later. maybe this show region coords belong in the
3463 * interface (new api functions, set/get)? */ 3463 * interface (new api functions, set/get)? */
3464static void 3464static void
3465_show_region_hook(void *data EINA_UNUSED, 3465_show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rectangle r)
3466 Evas_Object *obj)
3467{ 3466{
3468 Evas_Coord x, y, w, h;
3469
3470 ELM_GENLIST_DATA_GET_OR_RETURN(obj, sd); 3467 ELM_GENLIST_DATA_GET_OR_RETURN(obj, sd);
3471 3468
3472 elm_widget_show_region_get(obj, &x, &y, &w, &h);
3473 //x & y are screen coordinates, Add with pan coordinates 3469 //x & y are screen coordinates, Add with pan coordinates
3474 x += sd->pan_x; 3470 r.x += sd->pan_x;
3475 y += sd->pan_y; 3471 r.y += sd->pan_y;
3476 elm_interface_scrollable_content_region_show(obj, x, y, w, h); 3472 elm_interface_scrollable_content_region_show(obj, r.x, r.y, r.w, r.h);
3477} 3473}
3478 3474
3479static void 3475static void
@@ -5602,7 +5598,7 @@ _elm_genlist_efl_canvas_group_group_add(Eo *obj, Elm_Genlist_Data *priv)
5602 evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE); 5598 evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
5603 5599
5604 elm_widget_can_focus_set(obj, EINA_TRUE); 5600 elm_widget_can_focus_set(obj, EINA_TRUE);
5605 elm_widget_on_show_region_hook_set(obj, _show_region_hook, NULL); 5601 elm_widget_on_show_region_hook_set(obj, NULL, _show_region_hook, NULL);
5606 5602
5607 if (!elm_layout_theme_set 5603 if (!elm_layout_theme_set
5608 (obj, "genlist", "base", elm_widget_style_get(obj))) 5604 (obj, "genlist", "base", elm_widget_style_get(obj)))
diff --git a/src/lib/elementary/elm_list.c b/src/lib/elementary/elm_list.c
index 91252779c8..789a025918 100644
--- a/src/lib/elementary/elm_list.c
+++ b/src/lib/elementary/elm_list.c
@@ -1027,13 +1027,9 @@ _size_hints_changed_cb(void *data,
1027/* FIXME: take off later. maybe this show region coords belong in the 1027/* FIXME: take off later. maybe this show region coords belong in the
1028 * interface (new api functions, set/get)? */ 1028 * interface (new api functions, set/get)? */
1029static void 1029static void
1030_show_region_hook(void *data EINA_UNUSED, 1030_show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rectangle r)
1031 Evas_Object *obj)
1032{ 1031{
1033 Evas_Coord x, y, w, h; 1032 elm_interface_scrollable_content_region_set(obj, r.x, r.y, r.w, r.h);
1034
1035 elm_widget_show_region_get(obj, &x, &y, &w, &h);
1036 elm_interface_scrollable_content_region_set(obj, x, y, w, h);
1037} 1033}
1038 1034
1039EOLIAN static Eina_Bool 1035EOLIAN static Eina_Bool
@@ -2432,7 +2428,7 @@ _elm_list_efl_canvas_group_group_add(Eo *obj, Elm_List_Data *priv)
2432 elm_interface_atspi_accessible_type_set(priv->box, ELM_ATSPI_TYPE_DISABLED); 2428 elm_interface_atspi_accessible_type_set(priv->box, ELM_ATSPI_TYPE_DISABLED);
2433 2429
2434 /* FIXME: change this ugly code path later */ 2430 /* FIXME: change this ugly code path later */
2435 elm_widget_on_show_region_hook_set(priv->box, _show_region_hook, obj); 2431 elm_widget_on_show_region_hook_set(priv->box, obj, _show_region_hook, NULL);
2436 elm_widget_sub_object_add(obj, priv->box); 2432 elm_widget_sub_object_add(obj, priv->box);
2437 2433
2438 elm_interface_scrollable_content_set(obj, priv->box); 2434 elm_interface_scrollable_content_set(obj, priv->box);
diff --git a/src/lib/elementary/elm_scroller.c b/src/lib/elementary/elm_scroller.c
index 28bf6b69bc..7c17b40c60 100644
--- a/src/lib/elementary/elm_scroller.c
+++ b/src/lib/elementary/elm_scroller.c
@@ -536,13 +536,9 @@ _elm_scroller_elm_widget_focus_direction(Eo *obj, Elm_Scroller_Data *sd, const E
536} 536}
537 537
538static void 538static void
539_show_region_hook(void *data, 539_show_region_hook(void *data, Evas_Object *content_obj EINA_UNUSED, Eina_Rectangle r)
540 Evas_Object *content_obj)
541{ 540{
542 Evas_Coord x, y, w, h; 541 elm_interface_scrollable_content_region_show(data, r.x, r.y, r.w, r.h);
543
544 elm_widget_show_region_get(content_obj, &x, &y, &w, &h);
545 elm_interface_scrollable_content_region_show(data, x, y, w, h);
546} 542}
547 543
548static void 544static void
@@ -564,7 +560,7 @@ _elm_scroller_elm_widget_sub_object_del(Eo *obj, Elm_Scroller_Data *sd, Evas_Obj
564 if (sobj == sd->content) 560 if (sobj == sd->content)
565 { 561 {
566 if (elm_widget_is(sobj)) 562 if (elm_widget_is(sobj))
567 elm_widget_on_show_region_hook_set(sd->content, NULL, NULL); 563 elm_widget_on_show_region_hook_set(sd->content, NULL, NULL, NULL);
568 564
569 sd->content = NULL; 565 sd->content = NULL;
570 } 566 }
@@ -741,7 +737,7 @@ _loop_content_set(Evas_Object *obj, Elm_Scroller_Data *sd, Evas_Object *content)
741 evas_object_size_hint_align_set(sd->contents, EVAS_HINT_FILL, EVAS_HINT_FILL); 737 evas_object_size_hint_align_set(sd->contents, EVAS_HINT_FILL, EVAS_HINT_FILL);
742 738
743 elm_widget_sub_object_add(obj, sd->contents); 739 elm_widget_sub_object_add(obj, sd->contents);
744 elm_widget_on_show_region_hook_set(sd->contents, _show_region_hook, obj); 740 elm_widget_on_show_region_hook_set(sd->contents, obj, _show_region_hook, NULL);
745 741
746 efl_ui_mirrored_automatic_set(sd->contents, EINA_FALSE); 742 efl_ui_mirrored_automatic_set(sd->contents, EINA_FALSE);
747 efl_ui_mirrored_set(sd->contents, EINA_FALSE); 743 efl_ui_mirrored_set(sd->contents, EINA_FALSE);
@@ -796,7 +792,7 @@ _elm_scroller_content_set(Eo *obj, Elm_Scroller_Data *sd, const char *part, Evas
796 if (content) 792 if (content)
797 { 793 {
798 if (elm_widget_is(content)) 794 if (elm_widget_is(content))
799 elm_widget_on_show_region_hook_set(content, _show_region_hook, obj); 795 elm_widget_on_show_region_hook_set(content, obj, _show_region_hook, NULL);
800 elm_widget_sub_object_add(obj, content); 796 elm_widget_sub_object_add(obj, content);
801 797
802 if (sd->loop_h || sd->loop_v) 798 if (sd->loop_h || sd->loop_v)
@@ -1373,7 +1369,7 @@ elm_scroller_loop_set(Evas_Object *obj,
1373 { 1369 {
1374 elm_interface_scrollable_content_set(obj, sd->contents); 1370 elm_interface_scrollable_content_set(obj, sd->contents);
1375 elm_widget_sub_object_add(obj, sd->contents); 1371 elm_widget_sub_object_add(obj, sd->contents);
1376 elm_widget_on_show_region_hook_set(sd->contents, _show_region_hook, obj); 1372 elm_widget_on_show_region_hook_set(sd->contents, obj, _show_region_hook, NULL);
1377 } 1373 }
1378 } 1374 }
1379 else 1375 else
diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c
index ef56e90841..bfd0094cca 100644
--- a/src/lib/elementary/elm_widget.c
+++ b/src/lib/elementary/elm_widget.c
@@ -1341,10 +1341,17 @@ _elm_widget_efl_ui_base_mirrored_automatic_set(Eo *obj, Elm_Widget_Smart_Data *s
1341} 1341}
1342 1342
1343EOLIAN static void 1343EOLIAN static void
1344_elm_widget_on_show_region_hook_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, region_hook_func_type func, void *data) 1344_elm_widget_on_show_region_hook_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, void *data, Efl_Ui_Scrollable_On_Show_Region func, Eina_Free_Cb func_free_cb)
1345{ 1345{
1346 if ((sd->on_show_region_data == data) && (sd->on_show_region == func))
1347 return;
1348
1349 if (sd->on_show_region_data && sd->on_show_region_data_free)
1350 sd->on_show_region_data_free(sd->on_show_region_data);
1351
1346 sd->on_show_region = func; 1352 sd->on_show_region = func;
1347 sd->on_show_region_data = data; 1353 sd->on_show_region_data = data;
1354 sd->on_show_region_data_free = func_free_cb;
1348} 1355}
1349 1356
1350/* 1357/*
@@ -3396,8 +3403,8 @@ _elm_widget_show_region_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Coord x, Ev
3396 sd->rh = h; 3403 sd->rh = h;
3397 if (sd->on_show_region) 3404 if (sd->on_show_region)
3398 { 3405 {
3399 sd->on_show_region 3406 const Eina_Rectangle r = { x, y, w, h };
3400 (sd->on_show_region_data, obj); 3407 sd->on_show_region(sd->on_show_region_data, obj, r);
3401 3408
3402 if (_elm_scrollable_is(obj)) 3409 if (_elm_scrollable_is(obj))
3403 { 3410 {
@@ -3427,8 +3434,8 @@ _elm_widget_show_region_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Coord x, Ev
3427 3434
3428 if (sd->on_show_region) 3435 if (sd->on_show_region)
3429 { 3436 {
3430 sd->on_show_region 3437 const Eina_Rectangle r = { x, y, w, h };
3431 (sd->on_show_region_data, parent_obj); 3438 sd->on_show_region(sd->on_show_region_data, parent_obj, r);
3432 } 3439 }
3433 } 3440 }
3434 while (parent_obj); 3441 while (parent_obj);
diff --git a/src/lib/elementary/elm_widget.eo b/src/lib/elementary/elm_widget.eo
index 5b49fb951f..b01005a554 100644
--- a/src/lib/elementary/elm_widget.eo
+++ b/src/lib/elementary/elm_widget.eo
@@ -3,7 +3,14 @@ import efl_input_types;
3 3
4/* FIXME: This shouldn't be here. */ 4/* FIXME: This shouldn't be here. */
5type list_data_get_func_type: __undefined_type; [[Elementary list data get function type]] 5type list_data_get_func_type: __undefined_type; [[Elementary list data get function type]]
6type region_hook_func_type: __undefined_type; [[Elementary region hook function type]] 6
7function Efl.Ui.Scrollable_On_Show_Region
8{
9 params {
10 @in obj: Efl.Canvas.Object;
11 @in region: Eina.Rectangle;
12 }
13};
7 14
8enum Elm.Activate 15enum Elm.Activate
9{ 16{
@@ -172,6 +179,15 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible,
172 } 179 }
173 } 180 }
174 181
182 /* Not sure if the following are internal only? */
183 @property on_show_region_hook {
184 [[Region hook on show property]]
185 set {}
186 values {
187 func: Efl.Ui.Scrollable_On_Show_Region @nullable; [[Region hook function]]
188 }
189 }
190
175 @property drag_lock_y { 191 @property drag_lock_y {
176 [[Lock the Y axis from being dragged]] 192 [[Lock the Y axis from being dragged]]
177 values { 193 values {
@@ -299,17 +315,6 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible,
299 sobj: Efl.Canvas.Object @nullable; [[Hover sub object]] 315 sobj: Efl.Canvas.Object @nullable; [[Hover sub object]]
300 } 316 }
301 } 317 }
302 /* internal only - most objects use data = null as they work on
303 themselves except scroller itself */
304 @property on_show_region_hook {
305 [[Region hook on show property]]
306 set {
307 }
308 values {
309 func: region_hook_func_type @nullable; [[Region hook function]]
310 data: void_ptr @optional; [[Data pointer]]
311 }
312 }
313 /* this is a part api */ 318 /* this is a part api */
314 @property domain_part_text_translatable { 319 @property domain_part_text_translatable {
315 [[Translate domain text part property]] 320 [[Translate domain text part property]]
diff --git a/src/lib/elementary/elm_widget.h b/src/lib/elementary/elm_widget.h
index f590b4739c..05f2102618 100644
--- a/src/lib/elementary/elm_widget.h
+++ b/src/lib/elementary/elm_widget.h
@@ -313,7 +313,7 @@ typedef Eina_Bool (*Elm_Widget_Focus_Get_Cb)(const void *data);
313 313
314typedef void (*Elm_Access_On_Highlight_Cb)(void *data); 314typedef void (*Elm_Access_On_Highlight_Cb)(void *data);
315 315
316typedef void (*region_hook_func_type)(void *data, Evas_Object *obj); 316typedef void (*region_hook_func_type)(void *data, Evas_Object *obj, Eina_Rectangle region);
317typedef void * (*list_data_get_func_type)(const Eina_List * l); 317typedef void * (*list_data_get_func_type)(const Eina_List * l);
318 318
319#include "elm_widget.eo.h" 319#include "elm_widget.eo.h"
@@ -424,8 +424,8 @@ typedef struct _Elm_Widget_Smart_Data
424 * handling the request of showing a specific region from an inner 424 * handling the request of showing a specific region from an inner
425 * widget (mainly issued by entries, on cursor moving) */ 425 * widget (mainly issued by entries, on cursor moving) */
426 void *on_show_region_data; 426 void *on_show_region_data;
427 void (*on_show_region)(void *data, 427 Efl_Ui_Scrollable_On_Show_Region on_show_region;
428 Evas_Object *obj); 428 Eina_Free_Cb on_show_region_data_free;
429 429
430 int orient_mode; /* -1 is disabled */ 430 int orient_mode; /* -1 is disabled */
431 Elm_Focus_Move_Policy focus_move_policy; 431 Elm_Focus_Move_Policy focus_move_policy;
@@ -640,7 +640,7 @@ EAPI Eina_Bool elm_widget_access(Evas_Object *obj, Eina_Bool is_access);
640EAPI Efl_Ui_Theme_Apply elm_widget_theme(Evas_Object *obj); 640EAPI Efl_Ui_Theme_Apply elm_widget_theme(Evas_Object *obj);
641EAPI void elm_widget_theme_specific(Evas_Object *obj, Elm_Theme *th, Eina_Bool force); 641EAPI void elm_widget_theme_specific(Evas_Object *obj, Elm_Theme *th, Eina_Bool force);
642EAPI void elm_widget_translate(Evas_Object *obj); 642EAPI void elm_widget_translate(Evas_Object *obj);
643EAPI void elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func)(void *data, Evas_Object *obj), void *data); 643EAPI void elm_widget_on_show_region_hook_set(Evas_Object *obj, void *data, Efl_Ui_Scrollable_On_Show_Region func, Eina_Free_Cb data_free);
644EAPI Eina_Bool elm_widget_sub_object_parent_add(Evas_Object *sobj); 644EAPI Eina_Bool elm_widget_sub_object_parent_add(Evas_Object *sobj);
645EAPI Eina_Bool elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj); 645EAPI Eina_Bool elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj);
646EAPI Eina_Bool elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj); 646EAPI Eina_Bool elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj);