From d928ba989ad8921c13f5a130ffc2f5246e250e16 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 29 Aug 2017 14:18:50 +0900 Subject: [PATCH] widget: Merge on_focus_region and focus_region_get This simplifies code and API. Ref T5363 --- src/lib/elementary/efl_ui_text.c | 2 +- src/lib/elementary/efl_ui_text.eo | 2 +- src/lib/elementary/elm_entry.c | 2 +- src/lib/elementary/elm_entry.eo | 2 +- src/lib/elementary/elm_gengrid.c | 8 +++++--- src/lib/elementary/elm_gengrid.eo | 2 +- src/lib/elementary/elm_panel.c | 2 +- src/lib/elementary/elm_panel.eo | 2 +- src/lib/elementary/elm_widget.c | 20 +++----------------- src/lib/elementary/elm_widget.eo | 28 ++++++++++++++++------------ 10 files changed, 31 insertions(+), 39 deletions(-) diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c index 25ea11a..dc3fadb 100644 --- a/src/lib/elementary/efl_ui_text.c +++ b/src/lib/elementary/efl_ui_text.c @@ -1203,7 +1203,7 @@ _efl_ui_text_elm_widget_on_focus(Eo *obj, Efl_Ui_Text_Data *sd, Elm_Object_Item } EOLIAN static Eina_Bool -_efl_ui_text_elm_widget_on_focus_region(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +_efl_ui_text_elm_widget_focus_region_get(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) { Evas_Coord edje_x, edje_y, elm_x, elm_y; diff --git a/src/lib/elementary/efl_ui_text.eo b/src/lib/elementary/efl_ui_text.eo index 5898439..94627f4 100644 --- a/src/lib/elementary/efl_ui_text.eo +++ b/src/lib/elementary/efl_ui_text.eo @@ -411,7 +411,7 @@ class Efl.Ui.Text (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable, Elm.Widget.focus_direction_manager_is; Elm.Widget.theme_apply; Elm.Widget.on_focus; - Elm.Widget.on_focus_region; + Elm.Widget.focus_region { get; } Elm.Widget.on_disabled_update; Elm.Widget.widget_sub_object_del; Elm.Widget.focus_next_manager_is; diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c index 686c9ca..b45fae5 100644 --- a/src/lib/elementary/elm_entry.c +++ b/src/lib/elementary/elm_entry.c @@ -1309,7 +1309,7 @@ _elm_entry_elm_widget_on_focus(Eo *obj, Elm_Entry_Data *sd, Elm_Object_Item *ite } EOLIAN static Eina_Bool -_elm_entry_elm_widget_on_focus_region(Eo *obj, Elm_Entry_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +_elm_entry_elm_widget_focus_region_get(Eo *obj, Elm_Entry_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) { Evas_Coord cx, cy, cw, ch; Evas_Coord edx, edy; diff --git a/src/lib/elementary/elm_entry.eo b/src/lib/elementary/elm_entry.eo index 88d26d7..2691d48 100644 --- a/src/lib/elementary/elm_entry.eo +++ b/src/lib/elementary/elm_entry.eo @@ -961,7 +961,7 @@ class Elm.Entry (Efl.Ui.Layout, Elm.Interface_Scrollable, Efl.Ui.Clickable, Elm.Widget.focus_direction_manager_is; Elm.Widget.theme_apply; Elm.Widget.on_focus; - Elm.Widget.on_focus_region; + Elm.Widget.focus_region { get; } Elm.Widget.on_disabled_update; Elm.Widget.widget_sub_object_del; Elm.Widget.focus_next_manager_is; diff --git a/src/lib/elementary/elm_gengrid.c b/src/lib/elementary/elm_gengrid.c index b0cbbb2..c2d35c4 100644 --- a/src/lib/elementary/elm_gengrid.c +++ b/src/lib/elementary/elm_gengrid.c @@ -3540,9 +3540,9 @@ _elm_gengrid_elm_widget_on_focus(Eo *obj, Elm_Gengrid_Data *sd, Elm_Object_Item } EOLIAN static Eina_Bool -_elm_gengrid_elm_widget_on_focus_region(Eo *obj, Elm_Gengrid_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +_elm_gengrid_elm_widget_focus_region_get(Eo *obj, Elm_Gengrid_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) { - if (!sd->focused_item) return EINA_FALSE; + if (!sd->focused_item) goto end; if (elm_object_focus_region_show_mode_get(obj) == ELM_FOCUS_REGION_SHOW_ITEM) { Evas_Coord vx, vy; @@ -3555,7 +3555,9 @@ _elm_gengrid_elm_widget_on_focus_region(Eo *obj, Elm_Gengrid_Data *sd, Evas_Coor return EINA_TRUE; } - return EINA_FALSE; + +end: + return elm_obj_widget_focus_region_get(efl_super(obj, MY_CLASS), x, y, w, h); } static Eina_Bool _elm_gengrid_smart_focus_next_enable = EINA_FALSE; diff --git a/src/lib/elementary/elm_gengrid.eo b/src/lib/elementary/elm_gengrid.eo index 2e0bdff..2fa4211 100644 --- a/src/lib/elementary/elm_gengrid.eo +++ b/src/lib/elementary/elm_gengrid.eo @@ -554,7 +554,7 @@ class Elm.Gengrid (Efl.Ui.Layout, Elm.Interface_Scrollable, Elm.Widget.focus_next; Elm.Widget.focus_direction; Elm.Widget.on_focus; - Elm.Widget.on_focus_region; + Elm.Widget.focus_region { get; } Elm.Widget.widget_event; Elm.Widget.focus_highlight_geometry_get; Elm.Widget.focused_item { get; } diff --git a/src/lib/elementary/elm_panel.c b/src/lib/elementary/elm_panel.c index a890902..c388e58 100644 --- a/src/lib/elementary/elm_panel.c +++ b/src/lib/elementary/elm_panel.c @@ -1107,7 +1107,7 @@ _elm_panel_toggle(Eo *obj, Elm_Panel_Data *_pd EINA_UNUSED) } EOLIAN static Eina_Bool -_elm_panel_elm_widget_on_focus_region(Eo *obj, +_elm_panel_elm_widget_focus_region_get(Eo *obj, Elm_Panel_Data *sd, Evas_Coord *x, Evas_Coord *y, diff --git a/src/lib/elementary/elm_panel.eo b/src/lib/elementary/elm_panel.eo index 2b03f95..fac44c7 100644 --- a/src/lib/elementary/elm_panel.eo +++ b/src/lib/elementary/elm_panel.eo @@ -85,7 +85,7 @@ class Elm.Panel (Efl.Ui.Layout, Elm.Interface_Scrollable, Elm.Widget.on_disabled_update; Elm.Widget.on_access_update; Elm.Widget.widget_event; - Elm.Widget.on_focus_region; + Elm.Widget.focus_region { get; } Elm.Interface.Atspi_Widget_Action.elm_actions { get; } Efl.Part.part; } diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c index 68b88bf..cf85604 100644 --- a/src/lib/elementary/elm_widget.c +++ b/src/lib/elementary/elm_widget.c @@ -465,15 +465,6 @@ _elm_widget_mirrored_reload(Evas_Object *obj) } } -EOLIAN static Eina_Bool -_elm_widget_on_focus_region(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Coord *x EINA_UNUSED, Evas_Coord *y EINA_UNUSED, Evas_Coord *w EINA_UNUSED, Evas_Coord *h EINA_UNUSED) -{ - DBG("The %s widget does not implement the \"on_focus_region\" function.", - efl_class_name_get(efl_class_get(obj))); - - return EINA_FALSE; -} - static void _parents_focus(Evas_Object *obj) { @@ -3487,14 +3478,9 @@ _elm_widget_show_region_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd EOLIAN static Eina_Bool _elm_widget_focus_region_get(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) { - Eina_Bool int_ret = EINA_FALSE; - int_ret = elm_obj_widget_on_focus_region((Eo *)obj, x, y, w, h); - if (!int_ret) - { - evas_object_geometry_get(obj, NULL, NULL, w, h); - if (x) *x = 0; - if (y) *y = 0; - } + efl_gfx_size_get(obj, w, h); + if (x) *x = 0; + if (y) *y = 0; if ((*w <= 0) || (*h <= 0)) return EINA_FALSE; return EINA_TRUE; } diff --git a/src/lib/elementary/elm_widget.eo b/src/lib/elementary/elm_widget.eo index 8ca1bd3..92fed41 100644 --- a/src/lib/elementary/elm_widget.eo +++ b/src/lib/elementary/elm_widget.eo @@ -437,16 +437,6 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible, } return: bool; [[$true if this widget can handle focus, $false otherwise]] } - on_focus_region { - [['Virtual' function returning an inner area of a widget that should be brought into the visible area of a broader viewport, may this context arise.]] - params { - @out x: int; [[X coordinate]] - @out y: int; [[Y coordinate]] - @out w: int; [[Width]] - @out h: int; [[Height]] - } - return: bool; [[$true on success, $false otherwise]] - } /* Scroll API. */ @property on_show_region_hook { @@ -508,9 +498,23 @@ abstract Elm.Widget (Efl.Canvas.Group, Elm.Interface.Atspi_Accessible, /* Old focus API. FIXME: Needs massive clean up! */ @property focus_region { - [[Focus region property]] + [[Region to show when focus changes within this widget. + + When this widget or one of its subwidgets is given focus, this + region should be shown, which means any parent scroller should + attempt to display the given area of this widget. For instance, an + entry given focus should scroll to show the text cursor if that + cursor moves. In this example, this region defines the relative + geometry of the cursor within the widget. + + Note: The region is relative to the top-left corner of the widget, + i.e. X,Y start from 0,0 to indicate the top-left corner of the + widget. + + See also @.focus_region_show. + ]] get { - return: bool; [[$true on success, $false otherwise]] + return: bool; [[If $false, @.focus_region_show will not do anything.]] } values { x: int; [[X coordinate]] -- 2.7.4