diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c index 8d2310fd20..614b4219b6 100644 --- a/src/lib/elementary/efl_ui_widget.c +++ b/src/lib/elementary/efl_ui_widget.c @@ -1342,20 +1342,6 @@ _efl_ui_widget_efl_ui_i18n_mirrored_automatic_set(Eo *obj, Elm_Widget_Smart_Data } } -EOLIAN static void -_efl_ui_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; -} - /* * @internal * @@ -2422,66 +2408,6 @@ _efl_ui_widget_disabled_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd return pd->disabled > 0; } -EOLIAN static void -_efl_ui_widget_show_region_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Rect 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 && eina_rectangle_equal(&sr.rect, &sd->show_region.rect)) return; - - sd->show_region = sr; - if (sd->on_show_region) - { - sd->on_show_region(sd->on_show_region_data, obj, sr); - - if (_elm_scrollable_is(obj)) - { - if (elm_widget_is_legacy(obj)) - { - elm_interface_scrollable_content_pos_get(obj, &nx, &ny); - sr.x -= nx; - sr.y -= ny; - } - else - { - Eina_Position2D pos; - pos = efl_ui_scrollable_content_pos_get(obj); - sr.x -= pos.x; - sr.y -= pos.y; - } - } - } - - do - { - parent_obj = sd->parent_obj; - child_obj = sd->obj; - if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break; - sd = efl_data_scope_get(parent_obj, MY_CLASS); - if (!sd) break; - - evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL); - evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL); - - sr.x += (cx - px); - sr.y += (cy - py); - sd->show_region = sr; - - if (sd->on_show_region) - sd->on_show_region(sd->on_show_region_data, parent_obj, sr); - } - while (parent_obj); -} - -EOLIAN static Eina_Rect -_efl_ui_widget_show_region_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd) -{ - return (Eina_Rect) sd->show_region; -} - /** * @internal * @@ -5481,6 +5407,84 @@ _efl_ui_widget_efl_ui_focus_object_focus_set(Eo *obj, Elm_Widget_Smart_Data *pd, /* Legacy APIs */ +EAPI void +elm_widget_on_show_region_hook_set(Eo *obj, void *data, Efl_Ui_Scrollable_On_Show_Region func, Eina_Free_Cb func_free_cb) +{ + ELM_WIDGET_DATA_GET(obj, sd); + + 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; +} + +EAPI void +elm_widget_show_region_set(Eo *obj, Eina_Rect sr, Eina_Bool forceshow) +{ + Evas_Object *parent_obj, *child_obj; + Evas_Coord px, py, cx, cy, nx = 0, ny = 0; + + ELM_WIDGET_DATA_GET_OR_RETURN(obj, sd); + + evas_smart_objects_calculate(evas_object_evas_get(obj)); + + if (!forceshow && eina_rectangle_equal(&sr.rect, &sd->show_region.rect)) return; + + sd->show_region = sr; + if (sd->on_show_region) + { + sd->on_show_region(sd->on_show_region_data, obj, sr); + + if (_elm_scrollable_is(obj)) + { + if (elm_widget_is_legacy(obj)) + { + elm_interface_scrollable_content_pos_get(obj, &nx, &ny); + sr.x -= nx; + sr.y -= ny; + } + else + { + Eina_Position2D pos; + pos = efl_ui_scrollable_content_pos_get(obj); + sr.x -= pos.x; + sr.y -= pos.y; + } + } + } + + do + { + parent_obj = sd->parent_obj; + child_obj = sd->obj; + if ((!parent_obj) || (!_elm_widget_is(parent_obj))) break; + sd = efl_data_scope_get(parent_obj, MY_CLASS); + if (!sd) break; + + evas_object_geometry_get(parent_obj, &px, &py, NULL, NULL); + evas_object_geometry_get(child_obj, &cx, &cy, NULL, NULL); + + sr.x += (cx - px); + sr.y += (cy - py); + sd->show_region = sr; + + if (sd->on_show_region) + sd->on_show_region(sd->on_show_region_data, parent_obj, sr); + } + while (parent_obj); +} + +EAPI Eina_Rect +elm_widget_show_region_get(const Eo *obj) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, sd, EINA_RECT_EMPTY()); + return (Eina_Rect) sd->show_region; +} /* elm_object_content_xxx APIs are supposed to work on all objects for which * elm_object_widget_check() returns true. The below checks avoid printing out * undesired ERR messages. */ diff --git a/src/lib/elementary/efl_ui_widget.eo b/src/lib/elementary/efl_ui_widget.eo index 815cb7761e..2e1e82ff26 100644 --- a/src/lib/elementary/efl_ui_widget.eo +++ b/src/lib/elementary/efl_ui_widget.eo @@ -329,43 +329,6 @@ abstract @beta Efl.Ui.Widget extends Efl.Canvas.Group implements Efl.Access.Obje theme or default theme was used.]] } - /* Scroll API. */ - @property on_show_region_hook @protected { - [[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.Rect; [[The region to show.]] - force: bool; [[Set to $true to force show even if unchanged.]] - } - } - get { - [[Returns the current region to show.]] - values { - region: Eina.Rect; [[The region to show.]] - } - } - } - /* FIXME: Scroll API. Not sure how those APIs should be exposed with * the new scrollable API. */ scroll_hold_push { @@ -410,9 +373,9 @@ abstract @beta Efl.Ui.Widget extends Efl.Canvas.Group implements Efl.Access.Obje } } @property interest_region_mode { - [[Defines how @.show_region should be calculated. + [[Defines how @.interest_region should be calculated. - It is up to the implementation of @.show_region.get to take this + It is up to the implementation of @.interest_region.get to take this value into account (or ignore it). ]] get {