summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Poole <netstar@gmail.com>2018-07-24 10:07:42 +0100
committerAndy Williams <andy@andywilliams.me>2018-07-24 10:10:26 +0100
commitab7d2ebb552ca8ece5e998bbae5ceaf5400e2bb7 (patch)
treee119f63c42513f634f5c50ceb83bae3c07b812f0
parent08d23ea58201756e59367c184c1a3ff9e274670c (diff)
elm_code_widget: resize cursor at time of font change.
Summary: This ensures the cursor changes to meet the font size change when a font change is made in an Elm_Code_Widget. @fix T6470 Test Plan: Run ecrire or Edi. Open a text file and change the font settings. Cursor should resize with the font when it is changed. Reviewers: #committers, ajwillia.ms Reviewed By: #committers, ajwillia.ms Subscribers: cedric, zmike Tags: #efl Maniphest Tasks: T6470 Differential Revision: https://phab.enlightenment.org/D6596
-rw-r--r--src/lib/elementary/elm_code_widget.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c
index a8fb499160..36e7ccfdf0 100644
--- a/src/lib/elementary/elm_code_widget.c
+++ b/src/lib/elementary/elm_code_widget.c
@@ -312,10 +312,30 @@ _elm_code_widget_fill_whitespace(Elm_Code_Widget *widget, Eina_Unicode character
312} 312}
313 313
314static void 314static void
315_elm_code_widget_cursor_update(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd)
316{
317 Evas_Coord cx, cy, cw, ch;
318
319 elm_code_widget_geometry_for_position_get(widget, pd->cursor_line, pd->cursor_col, &cx, &cy, &cw, &ch);
320
321 if (!pd->cursor_rect)
322 {
323 pd->cursor_rect = elm_layout_add(widget);
324
325 if (!elm_layout_theme_set(pd->cursor_rect, "entry", "cursor", elm_widget_style_get(widget)))
326 CRI("Failed to set layout!");
327 elm_layout_signal_emit(pd->cursor_rect, "elm,action,focus", "elm");
328 }
329
330 evas_object_resize(pd->cursor_rect, cw/8, ch);
331 evas_object_move(pd->cursor_rect, cx, cy);
332 evas_object_show(pd->cursor_rect);
333}
334
335static void
315_elm_code_widget_fill_cursor(Elm_Code_Widget *widget, unsigned int number, int gutter, int w) 336_elm_code_widget_fill_cursor(Elm_Code_Widget *widget, unsigned int number, int gutter, int w)
316{ 337{
317 Elm_Code_Widget_Data *pd; 338 Elm_Code_Widget_Data *pd;
318 Evas_Coord cx, cy, cw, ch;
319 339
320 pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); 340 pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
321 341
@@ -324,21 +344,7 @@ _elm_code_widget_fill_cursor(Elm_Code_Widget *widget, unsigned int number, int g
324 if (pd->cursor_col + gutter - 1 >= (unsigned int) w) 344 if (pd->cursor_col + gutter - 1 >= (unsigned int) w)
325 return; 345 return;
326 346
327 elm_code_widget_geometry_for_position_get(widget, pd->cursor_line, pd->cursor_col, &cx, &cy, &cw, &ch); 347 _elm_code_widget_cursor_update(widget, pd);
328
329 if (!pd->cursor_rect)
330 {
331 pd->cursor_rect = elm_layout_add(widget);
332
333 if (!elm_layout_theme_set(pd->cursor_rect, "entry", "cursor", elm_widget_style_get(widget)))
334 CRI("Failed to set layout!");
335 elm_layout_signal_emit(pd->cursor_rect, "elm,action,focus", "elm");
336
337 evas_object_resize(pd->cursor_rect, cw/8, ch);
338 }
339
340 evas_object_move(pd->cursor_rect, cx, cy);
341 evas_object_show(pd->cursor_rect);
342 } 348 }
343} 349}
344 350
@@ -2066,7 +2072,7 @@ _elm_code_widget_lines_visible_get(Eo *obj, Elm_Code_Widget_Data *pd)
2066} 2072}
2067 2073
2068EOLIAN static void 2074EOLIAN static void
2069_elm_code_widget_font_set(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd, 2075_elm_code_widget_font_set(Eo *obj, Elm_Code_Widget_Data *pd,
2070 const char *name, Evas_Font_Size size) 2076 const char *name, Evas_Font_Size size)
2071{ 2077{
2072 Eina_List *item; 2078 Eina_List *item;
@@ -2083,6 +2089,10 @@ _elm_code_widget_font_set(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd,
2083 { 2089 {
2084 evas_object_textgrid_font_set(grid, face, size * elm_config_scale_get()); 2090 evas_object_textgrid_font_set(grid, face, size * elm_config_scale_get());
2085 } 2091 }
2092
2093 if (pd->cursor_rect && (eina_list_count(pd->grids) >= pd->cursor_line))
2094 _elm_code_widget_cursor_update(obj, pd);
2095
2086 if (pd->font_name) 2096 if (pd->font_name)
2087 eina_stringshare_del((char *)pd->font_name); 2097 eina_stringshare_del((char *)pd->font_name);
2088 pd->font_name = eina_stringshare_add(face); 2098 pd->font_name = eina_stringshare_add(face);