widget: Merge on_focus_region and focus_region_get
authorJean-Philippe Andre <jp.andre@samsung.com>
Tue, 29 Aug 2017 05:18:50 +0000 (14:18 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 29 Aug 2017 05:30:35 +0000 (14:30 +0900)
This simplifies code and API.

Ref T5363

src/lib/elementary/efl_ui_text.c
src/lib/elementary/efl_ui_text.eo
src/lib/elementary/elm_entry.c
src/lib/elementary/elm_entry.eo
src/lib/elementary/elm_gengrid.c
src/lib/elementary/elm_gengrid.eo
src/lib/elementary/elm_panel.c
src/lib/elementary/elm_panel.eo
src/lib/elementary/elm_widget.c
src/lib/elementary/elm_widget.eo

index 25ea11a..dc3fadb 100644 (file)
@@ -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;
 
index 5898439..94627f4 100644 (file)
@@ -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;
index 686c9ca..b45fae5 100644 (file)
@@ -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;
index 88d26d7..2691d48 100644 (file)
@@ -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;
index b0cbbb2..c2d35c4 100644 (file)
@@ -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;
index 2e0bdff..2fa4211 100644 (file)
@@ -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; }
index a890902..c388e58 100644 (file)
@@ -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,
index 2b03f95..fac44c7 100644 (file)
@@ -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;
    }
index 68b88bf..cf85604 100644 (file)
@@ -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;
 }
index 8ca1bd3..92fed41 100644 (file)
@@ -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]]