From fb5041c9df23eebb9930a5032cecbb6bfb209678 Mon Sep 17 00:00:00 2001 From: raster Date: Tue, 16 Aug 2011 10:52:01 +0000 Subject: [PATCH] =?utf8?q?From:=20=EA=B9=80=EC=9E=AC=ED=99=98=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I added 4 APIs for the page function of the scroller. Those are, EAPI void elm_scroller_current_page_get(Evas_Object *obj, int *h_pagenumber, int *v_pagenumber)); (Get scroll current page number.) EAPI void elm_scroller_last_page_get(Evas_Object *obj, int *h_pagenumber, int *v_pagenumber); (Get scroll last page number.) EAPI void elm_scroller_page_show(Evas_Object *obj, int h_pagenumber, int v_pagenumber); (Show a specific virtual region within the scroller content object by page number without animation.) EAPI void elm_scroller_page_bring_in(Evas_Object *obj, int h_pagenumber, int v_pagenumber); (Show a specific virtual region within the scroller content object by page number with animation.) git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@62496 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/Elementary.h.in | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/elm_scroller.c | 40 +++++++++++++++++++++++++ src/lib/els_scroller.c | 76 +++++++++++++++++++++++++++++++++++++++-------- src/lib/els_scroller.h | 4 +++ 4 files changed, 186 insertions(+), 12 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 2fb3b45..8f430af 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -6902,6 +6902,84 @@ extern "C" { */ EAPI void elm_scroller_page_size_set(Evas_Object *obj, Evas_Coord h_pagesize, Evas_Coord v_pagesize) EINA_ARG_NONNULL(1); /** + * @brief Get scroll current page number. + * + * @param obj The scroller object + * @param h_pagenumber The horizoptal page number + * @param v_pagenumber The vertical page number + * + * The page number starts from 0. 0 is the first page. + * Current page means the page which meet the top-left of the viewport. + * If there are two or more pages in the viewport, it returns the number of page + * which meet the top-left of the viewport. + * + * @see elm_scroller_last_page_get() + * @see elm_scroller_page_show() + * @see elm_scroller_page_brint_in() + */ + EAPI void elm_scroller_current_page_get(Evas_Object *obj, int *h_pagenumber, int *v_pagenumber) EINA_ARG_NONNULL(1); + /** + * @brief Get scroll last page number. + * + * @param obj The scroller object + * @param h_pagenumber The horizoptal page number + * @param v_pagenumber The vertical page number + * + * The page number starts from 0. 0 is the first page. + * This returns the last page number among the pages. + * + * @see elm_scroller_current_page_get() + * @see elm_scroller_page_show() + * @see elm_scroller_page_brint_in() + */ + EAPI void elm_scroller_last_page_get(Evas_Object *obj, int *h_pagenumber, int *v_pagenumber) EINA_ARG_NONNULL(1); + /** + * Show a specific virtual region within the scroller content object by page number. + * + * @param obj The scroller object + * @param h_pagenumber The horizoptal page number + * @param v_pagenumber The vertical page number + * + * 0, 0 of the indicated page is located at the top-left of the viewport. + * This will jump to the page directly without animation. + * + * Example of usage: + * + * @code + * sc = elm_scroller_add(win); + * elm_scroller_content_set(sc, content); + * elm_scroller_page_relative_set(sc, 1, 0); + * elm_scroller_current_page_get(sc, &h_page, &v_page); + * elm_scroller_page_show(sc, h_page + 1, v_page); + * @endcode + * + * @see elm_scroller_page_bring_in() + */ + EAPI void elm_scroller_page_show(Evas_Object *obj, int h_pagenumber, int v_pagenumber) EINA_ARG_NONNULL(1); + /** + * Show a specific virtual region within the scroller content object by page number. + * + * @param obj The scroller object + * @param h_pagenumber The horizoptal page number + * @param v_pagenumber The vertical page number + * + * 0, 0 of the indicated page is located at the top-left of the viewport. + * This will slide to the page with animation. + * + * Example of usage: + * + * @code + * sc = elm_scroller_add(win); + * elm_scroller_content_set(sc, content); + * elm_scroller_page_relative_set(sc, 1, 0); + * elm_scroller_last_page_get(sc, &h_page, &v_page); + * elm_scroller_page_bring_in(sc, h_page, v_page); + * @endcode + * + * @see elm_scroller_page_show() + */ + EAPI void elm_scroller_page_bring_in(Evas_Object *obj, int h_pagenumber, int v_pagenumber) EINA_ARG_NONNULL(1); + /** * @brief Show a specific virtual region within the scroller content object. * * @param obj The scroller object diff --git a/src/lib/elm_scroller.c b/src/lib/elm_scroller.c index a49f0e1..5bc6bed 100644 --- a/src/lib/elm_scroller.c +++ b/src/lib/elm_scroller.c @@ -654,6 +654,46 @@ elm_scroller_page_size_set(Evas_Object *obj, Evas_Coord h_pagesize, Evas_Coord v } EAPI void +elm_scroller_current_page_get(Evas_Object *obj, int *h_pagenumber, int *v_pagenumber) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (wd->scr) + elm_smart_scroller_current_page_get(wd->scr, h_pagenumber, v_pagenumber); +} + +EAPI void +elm_scroller_last_page_get(Evas_Object *obj, int *h_pagenumber, int *v_pagenumber) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (wd->scr) + elm_smart_scroller_last_page_get(wd->scr, h_pagenumber, v_pagenumber); +} + +EAPI void +elm_scroller_page_show(Evas_Object *obj, int h_pagenumber, int v_pagenumber) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (wd->scr) + elm_smart_scroller_page_show(wd->scr, h_pagenumber, v_pagenumber); +} + +EAPI void +elm_scroller_page_bring_in(Evas_Object *obj, int h_pagenumber, int v_pagenumber) +{ + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (wd->scr) + elm_smart_scroller_page_bring_in(wd->scr, h_pagenumber, v_pagenumber); +} + +EAPI void elm_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) { ELM_CHECK_WIDTYPE(obj, widtype); diff --git a/src/lib/els_scroller.c b/src/lib/els_scroller.c index b346ba7..222b977 100644 --- a/src/lib/els_scroller.c +++ b/src/lib/els_scroller.c @@ -599,12 +599,8 @@ _smart_page_x_get(Smart_Data *sd, int offset) x += offset; if (sd->pagerel_h > 0.0) - { - x = x + (w * sd->pagerel_h * 0.5); - x = x / (w * sd->pagerel_h); - x = x * (w * sd->pagerel_h); - } - else if (sd->pagesize_h > 0) + sd->pagesize_h = w * sd->pagerel_h; + if (sd->pagesize_h > 0) { x = x + (sd->pagesize_h * 0.5); x = x / (sd->pagesize_h); @@ -628,12 +624,8 @@ _smart_page_y_get(Smart_Data *sd, int offset) y += offset; if (sd->pagerel_v > 0.0) - { - y = y + (h * sd->pagerel_v * 0.5); - y = y / (h * sd->pagerel_v); - y = y * (h * sd->pagerel_v); - } - else if (sd->pagesize_v > 0) + sd->pagesize_v = h * sd->pagerel_v; + if (sd->pagesize_v > 0) { y = y + (sd->pagesize_v * 0.5); y = y / (sd->pagesize_v); @@ -1311,6 +1303,65 @@ elm_smart_scroller_paging_get(Evas_Object *obj, double *pagerel_h, double *pager } void +elm_smart_scroller_current_page_get(Evas_Object *obj, int *pagenumber_h, int *pagenumber_v) +{ + API_ENTRY return; + Evas_Coord x, y; + elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y); + if (pagenumber_h) *pagenumber_h = (x + sd->pagesize_h - 1) / sd->pagesize_h; + if (pagenumber_v) *pagenumber_v = (y + sd->pagesize_v - 1) / sd->pagesize_v; +} + +void +elm_smart_scroller_last_page_get(Evas_Object *obj, int *pagenumber_h, int *pagenumber_v) +{ + API_ENTRY return; + Evas_Coord cw, ch; + sd->pan_func.child_size_get(sd->pan_obj, &cw, &ch); + if (pagenumber_h) + { + if (sd->pagesize_h > 0) + *pagenumber_h = cw / sd->pagesize_h + 1; + else + *pagenumber_h = 0; + } + if (pagenumber_v) + { + if (sd->pagesize_v > 0) + *pagenumber_v = ch / sd->pagesize_v + 1; + else + *pagenumber_v = 0; + } +} + +void +elm_smart_scroller_page_show(Evas_Object *obj, int pagenumber_h, int pagenumber_v) +{ + API_ENTRY return; + Evas_Coord x, y, w, h; + elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h); + if (pagenumber_h) x = sd->pagesize_h * pagenumber_h; + if (pagenumber_v) y = sd->pagesize_v * pagenumber_v; + if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h)) + elm_smart_scroller_child_pos_set(obj, x, y); +} + +void +elm_smart_scroller_page_bring_in(Evas_Object *obj, int pagenumber_h, int pagenumber_v) +{ + API_ENTRY return; + Evas_Coord x, y, w, h; + elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h); + if (pagenumber_h) x = sd->pagesize_h * pagenumber_h; + if (pagenumber_v) y = sd->pagesize_v * pagenumber_v; + if (_elm_smart_scroller_child_region_show_internal(obj, &x, &y, w, h)) + { + _smart_scrollto_x(sd, _elm_config->bring_in_scroll_friction, x); + _smart_scrollto_y(sd, _elm_config->bring_in_scroll_friction, y); + } +} + +void elm_smart_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) { API_ENTRY return; @@ -2621,6 +2672,7 @@ _smart_reconfigure(Smart_Data *sd) evas_object_move(sd->event_obj, sd->x, sd->y); evas_object_resize(sd->event_obj, sd->w, sd->h); _smart_scrollbar_size_adjust(sd); + _smart_page_adjust(sd); } static void diff --git a/src/lib/els_scroller.h b/src/lib/els_scroller.h index eefe421..8f3638b 100644 --- a/src/lib/els_scroller.h +++ b/src/lib/els_scroller.h @@ -32,6 +32,10 @@ void elm_smart_scroller_bounce_allow_set (Evas_Object *obj, Eina_Bool hor void elm_smart_scroller_bounce_allow_get (const Evas_Object *obj, Eina_Bool *horiz, Eina_Bool *vert); void elm_smart_scroller_paging_set (Evas_Object *obj, double pagerel_h, double pagerel_v, Evas_Coord pagesize_h, Evas_Coord pagesize_v); void elm_smart_scroller_paging_get (Evas_Object *obj, double *pagerel_h, double *pagerel_v, Evas_Coord *pagesize_h, Evas_Coord *pagesize_v); +void elm_smart_scroller_current_page_get (Evas_Object *obj, int *pagenumber_h, int *pagenumber_v); +void elm_smart_scroller_last_page_get (Evas_Object *obj, int *pagenumber_h, int *pagenumber_v); +void elm_smart_scroller_page_show (Evas_Object *obj, int pagenumber_h, int pagenumber_v); +void elm_smart_scroller_page_bring_in (Evas_Object *obj, int pagenumber_h, int pagenumber_v); void elm_smart_scroller_region_bring_in (Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h); void elm_smart_scroller_widget_set (Evas_Object *obj, Evas_Object *wid); Eina_Bool elm_smart_scroller_momentum_animator_disabled_get (Evas_Object *obj); -- 2.7.4