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)
downloadefl-06ec847a7c13a8f7f43a5216264ea7a4e25c4bee.tar.gz
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
}
static void
-_show_region_hook(void *data EINA_UNUSED,
- Evas_Object *obj)
+_show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rectangle r)
{
- Evas_Coord x, y, w, h;
- elm_widget_show_region_get(obj, &x, &y, &w, &h);
- elm_interface_scrollable_content_region_show(obj, x, y, w, h);
+ elm_interface_scrollable_content_region_show(obj, r.x, r.y, r.w, r.h);
}
EOLIAN static Eina_Bool
@@ -3731,7 +3728,7 @@ _efl_ui_text_scrollable_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool scroll)
elm_interface_scrollable_policy_set(obj, sd->policy_h, sd->policy_v);
elm_interface_scrollable_content_set(obj, sd->entry_edje);
elm_interface_scrollable_content_viewport_resize_cb_set(obj, _efl_ui_text_content_viewport_resize_cb);
- elm_widget_on_show_region_hook_set(obj, _show_region_hook, NULL);
+ elm_widget_on_show_region_hook_set(obj, NULL, _show_region_hook, NULL);
}
else
{
@@ -3747,7 +3744,7 @@ _efl_ui_text_scrollable_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool scroll)
elm_interface_scrollable_objects_set(obj, sd->entry_edje, sd->hit_rect);
- elm_widget_on_show_region_hook_set(obj, NULL, NULL);
+ elm_widget_on_show_region_hook_set(obj, NULL, NULL, NULL);
}
_update_decorations(obj);
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
}
static void
-_show_region_hook(void *data EINA_UNUSED,
- Evas_Object *obj)
+_show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rectangle r)
{
- Evas_Coord x, y, w, h;
-
- elm_widget_show_region_get(obj, &x, &y, &w, &h);
-
- elm_interface_scrollable_content_region_show(obj, x, y, w, h);
+ elm_interface_scrollable_content_region_show(obj, r.x, r.y, r.w, r.h);
}
EOLIAN static Eina_Bool
@@ -5047,7 +5042,7 @@ _elm_entry_scrollable_set(Eo *obj, Elm_Entry_Data *sd, Eina_Bool scroll)
elm_interface_scrollable_policy_set(obj, sd->policy_h, sd->policy_v);
elm_interface_scrollable_content_set(obj, sd->entry_edje);
elm_interface_scrollable_content_viewport_resize_cb_set(obj, _elm_entry_content_viewport_resize_cb);
- elm_widget_on_show_region_hook_set(obj, _show_region_hook, NULL);
+ elm_widget_on_show_region_hook_set(obj, NULL, _show_region_hook, NULL);
}
else
{
@@ -5063,7 +5058,7 @@ _elm_entry_scrollable_set(Eo *obj, Elm_Entry_Data *sd, Eina_Bool scroll)
elm_interface_scrollable_objects_set(obj, sd->entry_edje, sd->hit_rect);
- elm_widget_on_show_region_hook_set(obj, NULL, NULL);
+ elm_widget_on_show_region_hook_set(obj, NULL, NULL, NULL);
}
sd->last_w = -1;
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)
/* FIXME: take off later. maybe this show region coords belong in the
* interface (new api functions, set/get)? */
static void
-_show_region_hook(void *data EINA_UNUSED,
- Evas_Object *obj)
+_show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rectangle r)
{
- Evas_Coord x, y, w, h;
-
ELM_GENLIST_DATA_GET_OR_RETURN(obj, sd);
- elm_widget_show_region_get(obj, &x, &y, &w, &h);
//x & y are screen coordinates, Add with pan coordinates
- x += sd->pan_x;
- y += sd->pan_y;
- elm_interface_scrollable_content_region_show(obj, x, y, w, h);
+ r.x += sd->pan_x;
+ r.y += sd->pan_y;
+ elm_interface_scrollable_content_region_show(obj, r.x, r.y, r.w, r.h);
}
static void
@@ -5602,7 +5598,7 @@ _elm_genlist_efl_canvas_group_group_add(Eo *obj, Elm_Genlist_Data *priv)
evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
elm_widget_can_focus_set(obj, EINA_TRUE);
- elm_widget_on_show_region_hook_set(obj, _show_region_hook, NULL);
+ elm_widget_on_show_region_hook_set(obj, NULL, _show_region_hook, NULL);
if (!elm_layout_theme_set
(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,
/* FIXME: take off later. maybe this show region coords belong in the
* interface (new api functions, set/get)? */
static void
-_show_region_hook(void *data EINA_UNUSED,
- Evas_Object *obj)
+_show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rectangle r)
{
- Evas_Coord x, y, w, h;
-
- elm_widget_show_region_get(obj, &x, &y, &w, &h);
- elm_interface_scrollable_content_region_set(obj, x, y, w, h);
+ elm_interface_scrollable_content_region_set(obj, r.x, r.y, r.w, r.h);
}
EOLIAN static Eina_Bool
@@ -2432,7 +2428,7 @@ _elm_list_efl_canvas_group_group_add(Eo *obj, Elm_List_Data *priv)
elm_interface_atspi_accessible_type_set(priv->box, ELM_ATSPI_TYPE_DISABLED);
/* FIXME: change this ugly code path later */
- elm_widget_on_show_region_hook_set(priv->box, _show_region_hook, obj);
+ elm_widget_on_show_region_hook_set(priv->box, obj, _show_region_hook, NULL);
elm_widget_sub_object_add(obj, priv->box);
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
}
static void
-_show_region_hook(void *data,
- Evas_Object *content_obj)
+_show_region_hook(void *data, Evas_Object *content_obj EINA_UNUSED, Eina_Rectangle r)
{
- Evas_Coord x, y, w, h;
-
- elm_widget_show_region_get(content_obj, &x, &y, &w, &h);
- elm_interface_scrollable_content_region_show(data, x, y, w, h);
+ elm_interface_scrollable_content_region_show(data, r.x, r.y, r.w, r.h);
}
static void
@@ -564,7 +560,7 @@ _elm_scroller_elm_widget_sub_object_del(Eo *obj, Elm_Scroller_Data *sd, Evas_Obj
if (sobj == sd->content)
{
if (elm_widget_is(sobj))
- elm_widget_on_show_region_hook_set(sd->content, NULL, NULL);
+ elm_widget_on_show_region_hook_set(sd->content, NULL, NULL, NULL);
sd->content = NULL;
}
@@ -741,7 +737,7 @@ _loop_content_set(Evas_Object *obj, Elm_Scroller_Data *sd, Evas_Object *content)
evas_object_size_hint_align_set(sd->contents, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_widget_sub_object_add(obj, sd->contents);
- elm_widget_on_show_region_hook_set(sd->contents, _show_region_hook, obj);
+ elm_widget_on_show_region_hook_set(sd->contents, obj, _show_region_hook, NULL);
efl_ui_mirrored_automatic_set(sd->contents, EINA_FALSE);
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
if (content)
{
if (elm_widget_is(content))
- elm_widget_on_show_region_hook_set(content, _show_region_hook, obj);
+ elm_widget_on_show_region_hook_set(content, obj, _show_region_hook, NULL);
elm_widget_sub_object_add(obj, content);
if (sd->loop_h || sd->loop_v)
@@ -1373,7 +1369,7 @@ elm_scroller_loop_set(Evas_Object *obj,
{
elm_interface_scrollable_content_set(obj, sd->contents);
elm_widget_sub_object_add(obj, sd->contents);
- elm_widget_on_show_region_hook_set(sd->contents, _show_region_hook, obj);
+ elm_widget_on_show_region_hook_set(sd->contents, obj, _show_region_hook, NULL);
}
}
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
}
EOLIAN static void
-_elm_widget_on_show_region_hook_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd, region_hook_func_type func, void *data)
+_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)
{
+ if ((sd->on_show_region_data == data) && (sd->on_show_region == func))
+ return;
+
+ if (sd->on_show_region_data && sd->on_show_region_data_free)
+ sd->on_show_region_data_free(sd->on_show_region_data);
+
sd->on_show_region = func;
sd->on_show_region_data = data;
+ sd->on_show_region_data_free = func_free_cb;
}
/*
@@ -3396,8 +3403,8 @@ _elm_widget_show_region_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Coord x, Ev
sd->rh = h;
if (sd->on_show_region)
{
- sd->on_show_region
- (sd->on_show_region_data, obj);
+ const Eina_Rectangle r = { x, y, w, h };
+ sd->on_show_region(sd->on_show_region_data, obj, r);
if (_elm_scrollable_is(obj))
{
@@ -3427,8 +3434,8 @@ _elm_widget_show_region_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Coord x, Ev
if (sd->on_show_region)
{
- sd->on_show_region
- (sd->on_show_region_data, parent_obj);
+ const Eina_Rectangle r = { x, y, w, h };
+ sd->on_show_region(sd->on_show_region_data, parent_obj, r);
}
}
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;
/* FIXME: This shouldn't be here. */
type list_data_get_func_type: __undefined_type; [[Elementary list data get function type]]
-type region_hook_func_type: __undefined_type; [[Elementary region hook function type]]
+
+function Efl.Ui.Scrollable_On_Show_Region
+{
+ params {
+ @in obj: Efl.Canvas.Object;
+ @in region: Eina.Rectangle;
+ }
+};
enum Elm.Activate
{
@@ -172,6 +179,15 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible,
}
}
+ /* Not sure if the following are internal only? */
+ @property on_show_region_hook {
+ [[Region hook on show property]]
+ set {}
+ values {
+ func: Efl.Ui.Scrollable_On_Show_Region @nullable; [[Region hook function]]
+ }
+ }
+
@property drag_lock_y {
[[Lock the Y axis from being dragged]]
values {
@@ -299,17 +315,6 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible,
sobj: Efl.Canvas.Object @nullable; [[Hover sub object]]
}
}
- /* internal only - most objects use data = null as they work on
- themselves except scroller itself */
- @property on_show_region_hook {
- [[Region hook on show property]]
- set {
- }
- values {
- func: region_hook_func_type @nullable; [[Region hook function]]
- data: void_ptr @optional; [[Data pointer]]
- }
- }
/* this is a part api */
@property domain_part_text_translatable {
[[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);
typedef void (*Elm_Access_On_Highlight_Cb)(void *data);
-typedef void (*region_hook_func_type)(void *data, Evas_Object *obj);
+typedef void (*region_hook_func_type)(void *data, Evas_Object *obj, Eina_Rectangle region);
typedef void * (*list_data_get_func_type)(const Eina_List * l);
#include "elm_widget.eo.h"
@@ -424,8 +424,8 @@ typedef struct _Elm_Widget_Smart_Data
* handling the request of showing a specific region from an inner
* widget (mainly issued by entries, on cursor moving) */
void *on_show_region_data;
- void (*on_show_region)(void *data,
- Evas_Object *obj);
+ Efl_Ui_Scrollable_On_Show_Region on_show_region;
+ Eina_Free_Cb on_show_region_data_free;
int orient_mode; /* -1 is disabled */
Elm_Focus_Move_Policy focus_move_policy;
@@ -640,7 +640,7 @@ EAPI Eina_Bool elm_widget_access(Evas_Object *obj, Eina_Bool is_access);
EAPI Efl_Ui_Theme_Apply elm_widget_theme(Evas_Object *obj);
EAPI void elm_widget_theme_specific(Evas_Object *obj, Elm_Theme *th, Eina_Bool force);
EAPI void elm_widget_translate(Evas_Object *obj);
-EAPI void elm_widget_on_show_region_hook_set(Evas_Object *obj, void (*func)(void *data, Evas_Object *obj), void *data);
+EAPI 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);
EAPI Eina_Bool elm_widget_sub_object_parent_add(Evas_Object *sobj);
EAPI Eina_Bool elm_widget_sub_object_add(Evas_Object *obj, Evas_Object *sobj);
EAPI Eina_Bool elm_widget_sub_object_del(Evas_Object *obj, Evas_Object *sobj);