jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a82ab33bed4a2b8d9f07338cc6e1d41aeab22d84

commit a82ab33bed4a2b8d9f07338cc6e1d41aeab22d84
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Wed Aug 30 13:39:16 2017 +0900

    widget: Use rectangle in show_region
    
    Also make it a property. It's asymmetric because of the force show
    argument, but the get is much cleaner.
    
    Ref T5363
---
 src/lib/elementary/efl_ui_text.c          |  4 ++-
 src/lib/elementary/elc_multibuttonentry.c | 10 +++---
 src/lib/elementary/elm_conform.c          |  2 +-
 src/lib/elementary/elm_entry.c            | 20 ++++++------
 src/lib/elementary/elm_widget.c           | 42 ++++++++-----------------
 src/lib/elementary/elm_widget.eo          | 51 ++++++++++++++++++-------------
 src/lib/elementary/elm_widget.h           |  6 ++--
 7 files changed, 65 insertions(+), 70 deletions(-)

diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c
index f49204027d..c83e035cd8 100644
--- a/src/lib/elementary/efl_ui_text.c
+++ b/src/lib/elementary/efl_ui_text.c
@@ -1042,6 +1042,7 @@ _cursor_geometry_recalc(Evas_Object *obj)
    Evas_Coord x, y, w, h;
    Evas_Coord x2, y2, w2, h2;
    Evas_Coord cx, cy, cw, ch;
+   Eina_Rectangle sr;
 
    cx = cy = cw = ch = 0;
    x2 = y2 = w2 = h2 = 0;
@@ -1063,7 +1064,8 @@ _cursor_geometry_recalc(Evas_Object *obj)
          &x2, &y2, &w2, &h2);
    cx = cx + x - x2;
    cy = cy + y - y2;
-   elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
+   sr = (Eina_Rectangle) { cx, cy, cw, ch };
+   elm_widget_show_region_set(obj, sr, EINA_FALSE);
 }
 
 EOLIAN static void
diff --git a/src/lib/elementary/elc_multibuttonentry.c 
b/src/lib/elementary/elc_multibuttonentry.c
index e86f25c669..9ed9707053 100644
--- a/src/lib/elementary/elc_multibuttonentry.c
+++ b/src/lib/elementary/elc_multibuttonentry.c
@@ -1067,12 +1067,14 @@ _entry_resize_cb(void *data,
                  void *event_info EINA_UNUSED)
 {
    ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(data, sd);
-   Evas_Coord en_x, en_y, en_w, en_h;
-
-   evas_object_geometry_get(sd->entry, &en_x, &en_y, &en_w, &en_h);
 
    if (elm_widget_focus_get(sd->parent))
-     elm_widget_show_region_set(sd->entry, en_x, en_y, en_w, en_h, EINA_TRUE);
+     {
+        Eina_Rectangle sr = {};
+
+        evas_object_geometry_get(sd->entry, &sr.x, &sr.y, &sr.w, &sr.h);
+        elm_widget_show_region_set(sd->entry, sr, EINA_TRUE);
+     }
 }
 
 static void
diff --git a/src/lib/elementary/elm_conform.c b/src/lib/elementary/elm_conform.c
index 1197b961b6..4896061255 100644
--- a/src/lib/elementary/elm_conform.c
+++ b/src/lib/elementary/elm_conform.c
@@ -668,7 +668,7 @@ _show_region_job(void *data)
         if (r.h < _elm_config->finger_size)
           r.h = _elm_config->finger_size;
 
-        elm_widget_show_region_set(focus_obj, r.x, r.y, r.w, r.h, EINA_TRUE);
+        elm_widget_show_region_set(focus_obj, r, EINA_TRUE);
      }
 
    sd->show_region_job = NULL;
diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c
index b56048b915..273143dbb5 100644
--- a/src/lib/elementary/elm_entry.c
+++ b/src/lib/elementary/elm_entry.c
@@ -1009,14 +1009,14 @@ _cursor_geometry_recalc(Evas_Object *obj)
 
    if (!sd->deferred_recalc_job)
      {
-        Evas_Coord cx, cy, cw, ch;
-
-        edje_object_part_text_cursor_geometry_get
-          (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
         if (sd->cur_changed)
           {
+             Eina_Rectangle sr = {};
+
              sd->cur_changed = EINA_FALSE;
-             elm_widget_show_region_set(obj, cx, cy, cw, ch, EINA_FALSE);
+             edje_object_part_text_cursor_geometry_get
+               (sd->entry_edje, "elm.text", &sr.x, &sr.y, &sr.w, &sr.h);
+             elm_widget_show_region_set(obj, sr, EINA_FALSE);
           }
      }
    else
@@ -1083,14 +1083,14 @@ _deferred_recalc_job(void *data)
 
    if (sd->deferred_cur)
      {
-        Evas_Coord cx, cy, cw, ch;
-
-        edje_object_part_text_cursor_geometry_get
-          (sd->entry_edje, "elm.text", &cx, &cy, &cw, &ch);
         if (sd->cur_changed)
           {
+             Eina_Rectangle sr = {};
+
              sd->cur_changed = EINA_FALSE;
-             elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE);
+             edje_object_part_text_cursor_geometry_get
+               (sd->entry_edje, "elm.text", &sr.x, &sr.y, &sr.w, &sr.h);
+             elm_widget_show_region_set(data, sr, EINA_FALSE);
           }
      }
 }
diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c
index bd96b03cd6..4cefaf0aa4 100644
--- a/src/lib/elementary/elm_widget.c
+++ b/src/lib/elementary/elm_widget.c
@@ -3393,32 +3393,25 @@ _elm_widget_disabled_get(Eo *obj EINA_UNUSED, 
Elm_Widget_Smart_Data *sd)
 }
 
 EOLIAN static void
-_elm_widget_show_region_set(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Coord x, 
Evas_Coord y, Evas_Coord w, Evas_Coord h, Eina_Bool forceshow)
+_elm_widget_show_region_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Rectangle 
sr, Eina_Bool forceshow)
 {
-
    Evas_Object *parent_obj, *child_obj;
    Evas_Coord px, py, cx, cy, nx = 0, ny = 0;
 
-
    evas_smart_objects_calculate(evas_object_evas_get(obj));
 
-   if (!forceshow && (x == sd->rx) && (y == sd->ry) &&
-       (w == sd->rw) && (h == sd->rh)) return;
+   if (!forceshow && eina_rectangle_equal(&sr, &sd->show_region)) return;
 
-   sd->rx = x;
-   sd->ry = y;
-   sd->rw = w;
-   sd->rh = h;
+   sd->show_region = sr;
    if (sd->on_show_region)
      {
-        const Eina_Rectangle r = { x, y, w, h };
-        sd->on_show_region(sd->on_show_region_data, obj, r);
+        sd->on_show_region(sd->on_show_region_data, obj, sr);
 
         if (_elm_scrollable_is(obj))
           {
              elm_interface_scrollable_content_pos_get(obj, &nx, &ny);
-             x -= nx;
-             y -= ny;
+             sr.x -= nx;
+             sr.y -= ny;
           }
      }
 
@@ -3433,29 +3426,20 @@ _elm_widget_show_region_set(Eo *obj, 
Elm_Widget_Smart_Data *sd, Evas_Coord x, Ev
         evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL);
         evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL);
 
-        x += (cx - px);
-        y += (cy - py);
-        sd->rx = x;
-        sd->ry = y;
-        sd->rw = w;
-        sd->rh = h;
+        sr.x += (cx - px);
+        sr.y += (cy - py);
+        sd->show_region = sr;
 
         if (sd->on_show_region)
-          {
-             const Eina_Rectangle r = { x, y, w, h };
-             sd->on_show_region(sd->on_show_region_data, parent_obj, r);
-          }
+          sd->on_show_region(sd->on_show_region_data, parent_obj, sr);
      }
    while (parent_obj);
 }
 
-EOLIAN static void
-_elm_widget_show_region_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data 
*sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
+EOLIAN static Eina_Rectangle
+_elm_widget_show_region_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
 {
-   if (x) *x = sd->rx;
-   if (y) *y = sd->ry;
-   if (w) *w = sd->rw;
-   if (h) *h = sd->rh;
+   return sd->show_region;
 }
 
 /**
diff --git a/src/lib/elementary/elm_widget.eo b/src/lib/elementary/elm_widget.eo
index 404cfa388e..7a53bf78ac 100644
--- a/src/lib/elementary/elm_widget.eo
+++ b/src/lib/elementary/elm_widget.eo
@@ -414,12 +414,40 @@ abstract Elm.Widget (Efl.Canvas.Group, 
Elm.Interface.Atspi_Accessible,
 
       /* Scroll API. */
       @property on_show_region_hook {
-         [[Region hook on show property]]
+         [[Hook function called when the @.show_region is changed.
+
+           See also @.show_region.
+         ]]
          set {}
          values {
             func: Efl.Ui.Scrollable_On_Show_Region @nullable; [[Region hook 
function]]
          }
       }
+      @property show_region @protected {
+         [[Region inside the widget to show.
+
+           See also @.on_show_region_hook.
+         ]]
+         set {
+            [[Request parent scrollers to pan around so that this region
+              of the widget becomes visible.
+
+              If $force is $true this will trigger scroller changes and
+              the @.on_show_region_hook to be called even if the region is
+              unchanged.
+            ]]
+            values {
+               region: Eina.Rectangle; [[The region of interest.]]
+               force: bool; [[Set to $true to force show even if unchanged.]]
+            }
+         }
+         get {
+            [[Returns the current region of interest.]]
+            values {
+               region: Eina.Rectangle; [[The region of interest.]]
+            }
+         }
+      }
       @property item_loop_enabled {
          [[Control item loop feature.]]
          values {
@@ -429,27 +457,6 @@ abstract Elm.Widget (Efl.Canvas.Group, 
Elm.Interface.Atspi_Accessible,
       scroll_hold_push {
          [[Push scroll hold]]
       }
-
-      /* FIXME: property with a Eina.Rectangle */
-      show_region_set {
-         [[Set show region]]
-         params {
-            @in x: int; [[X coordinate]]
-            @in y: int; [[Y coordinate]]
-            @in w: int; [[Width]]
-            @in h: int; [[Height]]
-            @in forceshow: bool; [[$true if show should be forced, $false 
otherwise]]
-         }
-      }
-      show_region_get @const {
-         [[Get show region]]
-         params {
-            @out x: int @optional; [[X coordinate]]
-            @out y: int @optional; [[Y coordinate]]
-            @out w: int @optional; [[Width]]
-            @out h: int @optional; [[Height]]
-         }
-      }
       scroll_hold_pop {
          [[Pop scroller hold]]
       }
diff --git a/src/lib/elementary/elm_widget.h b/src/lib/elementary/elm_widget.h
index 482490d896..73914af080 100644
--- a/src/lib/elementary/elm_widget.h
+++ b/src/lib/elementary/elm_widget.h
@@ -396,7 +396,7 @@ typedef struct _Elm_Widget_Smart_Data
    /* "show region" coordinates. all widgets got those because this
     * info may be set and queried recursively through the widget
     * parenting tree */
-   Evas_Coord                    rx, ry, rw, rh;
+   Eina_Rectangle                show_region;
 
    /* scrolling hold/freeze hints. all widgets got those because this
     * info may be set and queried recursively through the widget
@@ -719,8 +719,8 @@ EAPI void             elm_widget_focus_restore(Evas_Object 
*obj);
 
 EAPI void             elm_widget_disabled_set(Evas_Object *obj, Eina_Bool 
disabled);
 EAPI Eina_Bool        elm_widget_disabled_get(const Evas_Object *obj);
-EAPI void             elm_widget_show_region_set(Evas_Object *obj, Evas_Coord 
x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Eina_Bool forceshow);
-EAPI void             elm_widget_show_region_get(const Evas_Object *obj, 
Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
+EAPI void             elm_widget_show_region_set(Evas_Object *obj, 
Eina_Rectangle sr, Eina_Bool forceshow);
+EAPI Eina_Rectangle   elm_widget_show_region_get(const Evas_Object *obj);
 EAPI Eina_Rectangle   elm_widget_focus_region_get(const Evas_Object *obj);
 EAPI void             elm_widget_focus_region_show(Evas_Object *obj);
 EAPI void             elm_widget_scroll_hold_push(Evas_Object *obj);

-- 


Reply via email to