From 2aec4c0844423fd26e9cca49f3b515686017cc67 Mon Sep 17 00:00:00 2001 From: Daniel Hirt Date: Tue, 14 Jun 2016 17:28:32 +0000 Subject: Efl.Ui.Text: fixup decoration geometry --- src/lib/elementary/efl_ui_text.c | 54 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c index 5b7d06097d..01b4f3f4c3 100644 --- a/src/lib/elementary/efl_ui_text.c +++ b/src/lib/elementary/efl_ui_text.c @@ -227,7 +227,7 @@ struct _Mod_Api static void _create_selection_handlers(Evas_Object *obj, Efl_Ui_Text_Data *sd); static void _magnifier_move(void *data); -static void _update_decorations(Eo *obj, Eo *text_obj); +static void _update_decorations(Eo *obj); static void _create_text_cursors(Efl_Ui_Text_Data *sd); static Eina_Bool _efl_ui_text_changed_cb(void *data EINA_UNUSED, const Eo_Event *event); static Eina_Bool _efl_ui_text_selection_changed_cb(void *data EINA_UNUSED, const Eo_Event *event); @@ -1101,10 +1101,8 @@ _deferred_recalc_job(void *data) //FIXME: will not work with complex themes. evas_object_resize(sw, resw, resh); efl_canvas_text_size_formatted_get(sw, &minw, &minh); - printf("formatted calc: (%dx%d)\n", minw, minh); evas_object_size_hint_min_set(sw, minw, minh); edje_object_size_min_restricted_calc(sd->entry_edje, &minw, &minh, resw, 0); - printf("restricted calc: (%dx%d)\n", minw, minh); elm_coords_finger_size_adjust(1, &minw, 1, &minh); /* This is a hack to workaround the way min size hints are treated. @@ -1164,7 +1162,7 @@ _deferred_recalc_job(void *data) elm_widget_show_region_set(data, cx, cy, cw, ch, EINA_FALSE); } } - _update_decorations(data, sw); + _update_decorations(data); } EOLIAN static void @@ -4484,8 +4482,7 @@ _efl_ui_text_scrollable_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool scroll) elm_widget_on_show_region_hook_set(obj, NULL, NULL); } sd->last_w = -1; - evas_object_clip_set(sd->cursor, evas_object_clip_get(sd->entry_edje)); - evas_object_clip_set(sd->cursor_bidi, evas_object_clip_get(sd->entry_edje)); + _update_decorations(obj); elm_obj_widget_theme_apply(obj); } @@ -5410,6 +5407,7 @@ _decoration_create(Efl_Ui_Text_Data *sd, const char *file, /** * Creates the cursors, if not created. */ + static void _create_text_cursors(Efl_Ui_Text_Data *sd) { @@ -5423,6 +5421,18 @@ _create_text_cursors(Efl_Ui_Text_Data *sd) edje_object_signal_emit(sd->cursor_bidi, "elm,action,focus", "elm"); } +static void +_decoration_calc_offset(Efl_Ui_Text_Data *sd, Evas_Coord *_x, Evas_Coord *_y) +{ + Evas_Coord x, y; + Eo *text_obj = edje_object_part_swallow_get(sd->entry_edje, "elm.text"); + + evas_object_geometry_get(text_obj, &x, &y, NULL, NULL); + + if (_x) *_x = x; + if (_y) *_y = y; +} + static void _update_text_cursors(Eo *obj) { @@ -5436,7 +5446,7 @@ _update_text_cursors(Eo *obj) x = y = w = h = -1; xx = yy = ww = hh = -1; - evas_object_geometry_get(text_obj, &x, &y, &w, &h); + _decoration_calc_offset(sd, &x, &y); bidi_cursor = efl_canvas_text_cursor_geometry_get( efl_canvas_text_cursor_get(text_obj), EFL_CANVAS_TEXT_CURSOR_TYPE_BEFORE, &xx, &yy, &ww, &hh, &xx2, &yy2, @@ -5479,23 +5489,12 @@ _update_text_selection(Eo *obj, Eo *text_obj) EFL_UI_TEXT_DATA_GET(obj, sd); - evas_object_geometry_get(text_obj, &x, &y, NULL, NULL); + _decoration_calc_offset(sd, &x, &y); efl_file_get(sd->entry_edje, &file, NULL); efl_ui_text_interactive_selection_cursors_get(text_obj, &sel_start, &sel_end); -#if 0 - { - int pos_start, pos_end; - - pos_start = efl_canvas_text_cursor_position_get(sel_start); - pos_end = efl_canvas_text_cursor_position_get(sel_end); - - printf("start=%d, end=%d\n", pos_start, pos_end); - } -#endif - range = efl_canvas_text_range_geometry_get(text_obj, sel_start, sel_end); @@ -5542,16 +5541,19 @@ _update_text_selection(Eo *obj, Eo *text_obj) } static void -_update_decorations(Eo *en_obj, Eo *text_obj) +_update_decorations(Eo *obj) { - _update_text_cursors(en_obj); - _update_text_selection(en_obj, text_obj); + EFL_UI_TEXT_DATA_GET(obj, sd); + Eo *text_obj = edje_object_part_swallow_get(sd->entry_edje, "elm.text"); + + _update_text_cursors(obj); + _update_text_selection(obj, text_obj); } static Eina_Bool _efl_ui_text_changed_cb(void *data, const Eo_Event *event EINA_UNUSED) { - _update_decorations(data, event->object); + _update_decorations(data); return EINA_TRUE; } @@ -5570,10 +5572,10 @@ _efl_ui_text_selection_changed_cb(void *data, const Eo_Event *event EINA_UNUSED) } static void -_efl_ui_text_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) +_efl_ui_text_move_cb(void *data, Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { - Eo *text_obj = edje_object_part_swallow_get(obj, "elm.text"); - _update_decorations(data, text_obj); + _update_decorations(data); } #if 0 -- cgit v1.2.1