hermet pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=451959973ddb5e1723f8c26b22420b6566cea026
commit 451959973ddb5e1723f8c26b22420b6566cea026 Author: Shinwoo Kim <[email protected]> Date: Thu May 23 20:11:44 2019 +0900 Efl.Ui.Textpath: fix a size problem Summary: Textpath set its hint_size using its position and calulated path information. The path information is calculated using center postion, radius & start angle. For example, if textpath position is 0,0 and center positon of path is 100,100 and radius 50, then text will be located on the rigth side of textpath object. Moreover there is another problem. [Step to reproduce] 1. Launch elementary_test 2. open Efl.Ui.Textpath 3. see circle is not center aligned. 4. click Clockwise 1 ~ 2 times center position is changed repeatedly. This occurs because textpath size is calculated by position_set. It does not make sense that changing postion defines its size. So this patch is setting textpath hint_size using only given center position. The text will position on the middle of textpath object always. Reviewers: Hermet, jsuya Reviewed By: Hermet Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8930 --- src/lib/elementary/efl_ui_textpath.c | 42 ++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/lib/elementary/efl_ui_textpath.c b/src/lib/elementary/efl_ui_textpath.c index f9c906ab1a..df712c1615 100644 --- a/src/lib/elementary/efl_ui_textpath.c +++ b/src/lib/elementary/efl_ui_textpath.c @@ -403,7 +403,7 @@ _text_draw(void *data) } static void -_path_data_get(Eo *obj, Efl_Ui_Textpath_Data *pd, Eina_Bool set_min) +_path_data_get(Eo *obj, Efl_Ui_Textpath_Data *pd) { const Efl_Gfx_Path_Command_Type *cmd; const double *points; @@ -508,10 +508,6 @@ _path_data_get(Eo *obj, Efl_Ui_Textpath_Data *pd, Eina_Bool set_min) } cmd++; } - if (set_min) - { - efl_gfx_hint_size_min_set(obj, rect.size); - } } } @@ -563,7 +559,7 @@ _ellipsis_set(Efl_Ui_Textpath_Data *pd, Eo *obj) static void _efl_ui_textpath_efl_gfx_path_commit(Eo *obj, Efl_Ui_Textpath_Data *pd) { - _path_data_get(obj, pd, EINA_TRUE); + _path_data_get(obj, pd); _sizing_eval(pd); } @@ -651,7 +647,7 @@ _path_start_angle_adjust(Eo *obj, Efl_Ui_Textpath_Data *pd) pd->circle.start_angle - offset_angle, 360); } - _path_data_get(obj, pd, EINA_TRUE); + _path_data_get(obj, pd); } EOLIAN static void @@ -753,8 +749,34 @@ _efl_ui_textpath_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Textpath_Data *pd) EOLIAN static void _efl_ui_textpath_efl_gfx_entity_position_set(Eo *obj, Efl_Ui_Textpath_Data *pd, Eina_Position2D pos) { + Eina_Position2D opos, diff; + Efl_Ui_Textpath_Segment *seg; + double sx, sy, csx, csy, cex, cey, ex, ey; + + opos = efl_gfx_entity_position_get(obj); + + diff.x = pos.x - opos.x; + diff.y = pos.y - opos.y; + efl_gfx_entity_position_set(efl_super(obj, MY_CLASS), pos); - _path_data_get(obj, pd, EINA_FALSE); + + EINA_INLIST_FOREACH(pd->segments, seg) + { + eina_bezier_values_get(&seg->bezier, &sx, &sy, &csx, &csy, + &cex, &cey, &ex, &ey); + sx += diff.x; + sy += diff.y; + csx += diff.x; + csy += diff.y; + cex += diff.x; + cey += diff.y; + ex += diff.x; + ey += diff.y; + + eina_bezier_values_set(&seg->bezier, sx, sy, csx, csy, + cex, cey, ex, ey); + } + _text_draw(pd); } @@ -792,9 +814,11 @@ _efl_ui_textpath_circle_set(Eo *obj, Efl_Ui_Textpath_Data *pd, double x, double radius * 2, start_angle, 360); } - _path_data_get(obj, pd, EINA_TRUE); + _path_data_get(obj, pd); _path_start_angle_adjust(obj, pd); _sizing_eval(pd); + + efl_gfx_hint_size_min_set(obj, EINA_SIZE2D(x * 2, y * 2)); } EOLIAN static int --
