From 1b441adddf010ebe6b618810ff4a7c34dcf1e9e9 Mon Sep 17 00:00:00 2001 From: WooHyun Jung Date: Tue, 25 Jan 2011 12:08:23 +0900 Subject: [PATCH] [scroller, entry, scrolled_entry] modified for the bug ( long text input -> text is not shown) --- src/lib/Elementary.h.in | 1 + src/lib/elc_scrolled_entry.c | 4 +-- src/lib/elm_entry.c | 26 +++++++++++++++++++ src/lib/elm_scroller.c | 22 ++++++++++------ src/lib/els_scroller.c | 60 +++++++++++++++++++++++++++++++++++++------- src/lib/els_scroller.h | 1 + 6 files changed, 96 insertions(+), 18 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 1b6a222..332abd7 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -1245,6 +1245,7 @@ extern "C" { EAPI Eina_Bool elm_entry_cursor_is_format_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_entry_cursor_is_visible_format_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI const char *elm_entry_cursor_content_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) EINA_ARG_NONNULL(1); EAPI void elm_entry_selection_cut(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_entry_selection_copy(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void elm_entry_selection_paste(Evas_Object *obj) EINA_ARG_NONNULL(1); diff --git a/src/lib/elc_scrolled_entry.c b/src/lib/elc_scrolled_entry.c index 8826e13..3deff40 100644 --- a/src/lib/elc_scrolled_entry.c +++ b/src/lib/elc_scrolled_entry.c @@ -1009,9 +1009,9 @@ elm_scrolled_entry_cursor_end_set(Evas_Object *obj) ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; - int x, y, w, h; - elm_scroller_region_get(wd->scroller, &x, &y, &w, &h); + Evas_Coord x, y, w, h; elm_entry_cursor_end_set(wd->entry); + elm_widget_show_region_get(wd->entry, &x, &y, &w, &h); elm_scroller_region_show(wd->scroller, x, y, w, h); } diff --git a/src/lib/elm_entry.c b/src/lib/elm_entry.c index bed614d..4963518 100644 --- a/src/lib/elm_entry.c +++ b/src/lib/elm_entry.c @@ -2807,6 +2807,32 @@ elm_entry_select_all(Evas_Object *obj) } /** + * This function returns the geometry of the cursor. + * + * It's useful if you want to draw something on the cursor (or where it is), + * or for example in the case of scrolled entry where you want to show the + * cursor. + * + * @param obj The entry object + * @param x returned geometry + * @param y returned geometry + * @param w returned geometry + * @param h returned geometry + * @return EINA_TRUE upon success, EINA_FALSE upon failure + * + * @ingroup Entry + */ +EAPI Eina_Bool +elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +{ + ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return EINA_FALSE; + edje_object_part_text_cursor_geometry_get(wd->ent, "elm.text", x, y, w, h); + return EINA_TRUE; +} + +/** * This moves the cursor one place to the right within the entry. * * @param obj The entry object diff --git a/src/lib/elm_scroller.c b/src/lib/elm_scroller.c index 9111a69..6faef1f 100644 --- a/src/lib/elm_scroller.c +++ b/src/lib/elm_scroller.c @@ -35,6 +35,7 @@ typedef struct _Widget_Data Widget_Data; struct _Widget_Data { + Evas_Coord wx, wy, ww, wh; /* Last "wanted" geometry */ Evas_Object *scr; Evas_Object *content; const char *widget_name, *widget_base; @@ -248,20 +249,15 @@ _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *so static void _show_region_hook(void *data, Evas_Object *obj) { - Widget_Data *wd = elm_widget_data_get(data); Evas_Coord x, y, w, h; - if (!wd) return; elm_widget_show_region_get(obj, &x, &y, &w, &h); - if (wd->scr) - elm_smart_scroller_child_region_show(wd->scr, x, y, w, h); + elm_scroller_region_show(data, x, y, w, h); } static void _focus_region_hook(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) { - Widget_Data *wd = elm_widget_data_get(obj); - if (wd->scr) - elm_smart_scroller_child_region_show(wd->scr, x, y, w, h); + elm_scroller_region_show(obj, x, y, w, h); } static void @@ -300,6 +296,7 @@ _sizing_eval(Evas_Object *obj) if ((maxw > 0) && (w > maxw)) w = maxw; if ((maxh > 0) && (h > maxh)) h = maxh; evas_object_size_hint_min_set(obj, w, h); + elm_smart_scroller_child_region_show(wd->scr, wd->wx, wd->wy, wd->ww, wd->wh); } } @@ -532,6 +529,8 @@ elm_scroller_content_set(Evas_Object *obj, Evas_Object *content) if (!wd) return; if (wd->content == content) return; if (wd->content) evas_object_del(wd->content); + wd->wx = wd->wh = wd->ww = wd->wy = 0; + wd->content = content; if (content) { @@ -656,6 +655,11 @@ elm_scroller_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coor ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if ((!wd) || (!wd->scr)) return; + wd->wx = x; + wd->wh = h; + wd->ww = w; + wd->wy = y; + elm_smart_scroller_child_region_show(wd->scr, x, y, w, h); } @@ -873,6 +877,10 @@ elm_scroller_region_bring_in(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_ ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if ((!wd) || (!wd->scr)) return; + wd->wx = x; + wd->wh = h; + wd->ww = w; + wd->wy = y; elm_smart_scroller_region_bring_in(wd->scr, x, y, w, h); } diff --git a/src/lib/els_scroller.c b/src/lib/els_scroller.c index ec02afa..b3ec7f6 100644 --- a/src/lib/els_scroller.c +++ b/src/lib/els_scroller.c @@ -12,6 +12,7 @@ typedef struct _Smart_Data Smart_Data; struct _Smart_Data { Evas_Coord x, y, w, h; + Evas_Coord wx, wy, ww, wh; /* Last "wanted" geometry */ Evas_Object *smart_obj; Evas_Object *child_obj; @@ -170,6 +171,7 @@ elm_smart_scroller_child_set(Evas_Object *obj, Evas_Object *child) } sd->child_obj = child; + sd->wx = sd->wy = sd->ww = sd->wh = 0; if (!child) return; if (!sd->pan_obj) @@ -405,7 +407,7 @@ _smart_scrollto_x(Smart_Data *sd, double t_in, Evas_Coord pos_x) elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y); elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h); x = pos_x; - elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h); + elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h); return; } t = ecore_loop_time_get(); @@ -416,7 +418,7 @@ _smart_scrollto_x(Smart_Data *sd, double t_in, Evas_Coord pos_x) sd->scrollto.x.t_end = t + t_in; elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y); elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h); - elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h); + elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h); if (!sd->scrollto.x.animator) { if (!sd->scrollto.y.animator) @@ -472,7 +474,7 @@ _smart_scrollto_y(Smart_Data *sd, double t_in, Evas_Coord pos_y) elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y); elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h); y = pos_y; - elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h); + elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h); return; } t = ecore_loop_time_get(); @@ -483,7 +485,7 @@ _smart_scrollto_y(Smart_Data *sd, double t_in, Evas_Coord pos_y) sd->scrollto.y.t_end = t + t_in; elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y); elm_smart_scroller_child_viewport_size_get(sd->smart_obj, &w, &h); - elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h); + elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h); if (!sd->scrollto.y.animator) { if (!sd->scrollto.x.animator) @@ -578,7 +580,7 @@ _smart_page_adjust(Smart_Data *sd) x = _smart_page_x_get(sd, 0); y = _smart_page_y_get(sd, 0); - elm_smart_scroller_child_region_show(sd->smart_obj, x, y, w, h); + elm_smart_scroller_child_region_set(sd->smart_obj, x, y, w, h); } static Eina_Bool @@ -956,8 +958,10 @@ elm_smart_scroller_child_pos_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) sd->pan_func.get(sd->pan_obj, x, y); } -void -elm_smart_scroller_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +/* "internal_call" actually toggles whether we should save the coords and do + * extra "speedup" checks, or not. */ +static void +_elm_smart_scroller_child_region_show_internal(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h, Eina_Bool internal_call) { Evas_Coord mx = 0, my = 0, cw = 0, ch = 0, px = 0, py = 0, nx, ny, minx = 0, miny = 0; @@ -973,7 +977,15 @@ elm_smart_scroller_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord ny = py; if ((y < py) && ((y + h) < (py + (ch - my)))) ny = y; else if ((y > py) && ((y + h) > (py + (ch - my)))) ny = y + h - (ch - my); - if ((nx == px) && (ny == py)) return; +// if ((nx == px) && (ny == py)) return; + if (!internal_call) + { + sd->wx = x; + sd->wy = y; + sd->ww = w; + sd->wh = h; + if ((nx == px) && (ny == py)) return; + } if ((sd->down.bounce_x_animator) || (sd->down.bounce_y_animator) || (sd->scrollto.x.animator) || (sd->scrollto.y.animator)) { @@ -1025,6 +1037,23 @@ elm_smart_scroller_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord sd->new.pos_job = ecore_idler_add(_smart_pos_set, sd); } +/* Set should be used for calculated positions, for example, when we move + * because of an animation or because this is the correct position after + * constraints. */ +void +elm_smart_scroller_child_region_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +{ + _elm_smart_scroller_child_region_show_internal(obj, x, y, w, h, EINA_TRUE); +} + +/* Set should be used for setting the wanted position, for example a user scroll + * or moving the cursor in an entry. */ +void +elm_smart_scroller_child_region_show(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +{ + _elm_smart_scroller_child_region_show_internal(obj, x, y, w, h, EINA_FALSE); +} + void elm_smart_scroller_child_viewport_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h) { @@ -1485,7 +1514,11 @@ _smart_event_wheel(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, x += ev->z * sd->step.x; if ((!sd->hold) && (!sd->freeze)) - elm_smart_scroller_child_pos_set(sd->smart_obj, x, y); + { + sd->wx = x; + sd->wy = y; + elm_smart_scroller_child_pos_set(sd->smart_obj, x, y); + } } static void @@ -1603,6 +1636,8 @@ _smart_hold_animator(void *data) } } elm_smart_scroller_child_pos_set(sd->smart_obj, ox, oy); + sd->wx = ox; + sd->wy = oy; return ECORE_CALLBACK_RENEW; } @@ -1821,6 +1856,8 @@ _smart_event_mouse_up(void *data, Evas *e, Evas_Object *obj __UNUSED__, void *ev sd->down.now = 0; elm_smart_scroller_child_pos_get(sd->smart_obj, &x, &y); elm_smart_scroller_child_pos_set(sd->smart_obj, x, y); + sd->wx = x; + sd->wy = y; if (!_smart_do_page(sd)) bounce_eval(sd); } @@ -1869,6 +1906,8 @@ _smart_onhold_animator(void *data) } elm_smart_scroller_child_pos_set(sd->smart_obj, x, y); + sd->wx = x; + sd->wy = y; // printf("scroll %i %i\n", sd->down.hold_x, sd->down.hold_y); } sd->down.onhold_tlast = t; @@ -1958,6 +1997,8 @@ _smart_event_mouse_move(void *data, Evas *e, Evas_Object *obj __UNUSED__, void * #ifdef SCROLLDBG printf("::: %i %i\n", ev->cur.canvas.x, ev->cur.canvas.y); #endif + sd->wx = ev->cur.canvas.x; + sd->wy = ev->cur.canvas.y; memmove(&(sd->down.history[1]), &(sd->down.history[0]), sizeof(sd->down.history[0]) * 19); #ifdef EVTIME @@ -2547,6 +2588,7 @@ _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) sd->w = w; sd->h = h; _smart_reconfigure(sd); + elm_smart_scroller_child_region_set(obj, sd->wx, sd->wy, sd->ww, sd->h); } static void diff --git a/src/lib/els_scroller.h b/src/lib/els_scroller.h index a265cee..4fe85fc 100644 --- a/src/lib/els_scroller.h +++ b/src/lib/els_scroller.h @@ -13,6 +13,7 @@ void elm_smart_scroller_custom_edje_file_set (Evas_Object *obj, char *file, c void elm_smart_scroller_child_pos_set (Evas_Object *obj, Evas_Coord x, Evas_Coord y); void elm_smart_scroller_child_pos_get (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y); void elm_smart_scroller_child_region_show (Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h); +void elm_smart_scroller_child_region_set (Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h); void elm_smart_scroller_child_viewport_size_get (Evas_Object *obj, Evas_Coord *w, Evas_Coord *h); void elm_smart_scroller_step_size_set (Evas_Object *obj, Evas_Coord x, Evas_Coord y); void elm_smart_scroller_step_size_get (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y); -- 2.7.4