@@ -70,29 +70,10 @@ void CodeEdit::_notification(int p_what) {
7070
7171 case NOTIFICATION_DRAW: {
7272 RID ci = get_canvas_item ();
73- const Size2 size = get_size ();
7473 const bool caret_visible = is_caret_visible ();
7574 const bool rtl = is_layout_rtl ();
7675 const int row_height = get_line_height ();
7776
78- if (line_length_guideline_columns.size () > 0 ) {
79- const int xmargin_beg = theme_cache.style_normal ->get_margin (SIDE_LEFT) + get_total_gutter_width ();
80- const int xmargin_end = size.width - theme_cache.style_normal ->get_margin (SIDE_RIGHT) - (is_drawing_minimap () ? get_minimap_width () : 0 );
81-
82- for (int i = 0 ; i < line_length_guideline_columns.size (); i++) {
83- const int column_pos = theme_cache.font ->get_string_size (String (" 0" ).repeat ((int )line_length_guideline_columns[i]), HORIZONTAL_ALIGNMENT_LEFT, -1 , theme_cache.font_size ).x ;
84- const int xoffset = xmargin_beg + column_pos - get_h_scroll ();
85- if (xoffset > xmargin_beg && xoffset < xmargin_end) {
86- Color guideline_color = (i == 0 ) ? theme_cache.line_length_guideline_color : theme_cache.line_length_guideline_color * Color (1 , 1 , 1 , 0.5 );
87- if (rtl) {
88- RenderingServer::get_singleton ()->canvas_item_add_line (ci, Point2 (size.width - xoffset, 0 ), Point2 (size.width - xoffset, size.height ), guideline_color);
89- continue ;
90- }
91- RenderingServer::get_singleton ()->canvas_item_add_line (ci, Point2 (xoffset, 0 ), Point2 (xoffset, size.height ), guideline_color);
92- }
93- }
94- }
95-
9677 if (caret_visible) {
9778 const bool draw_code_completion = code_completion_active && !code_completion_options.is_empty ();
9879 const bool draw_code_hint = !code_hint.is_empty ();
@@ -280,6 +261,32 @@ void CodeEdit::_notification(int p_what) {
280261 }
281262}
282263
264+ void CodeEdit::_draw_guidelines () {
265+ if (line_length_guideline_columns.is_empty ()) {
266+ return ;
267+ }
268+
269+ RID ci = get_canvas_item ();
270+ const Size2 size = get_size ();
271+ const bool rtl = is_layout_rtl ();
272+
273+ const int xmargin_beg = theme_cache.style_normal ->get_margin (SIDE_LEFT) + get_total_gutter_width ();
274+ const int xmargin_end = size.width - theme_cache.style_normal ->get_margin (SIDE_RIGHT) - (is_drawing_minimap () ? get_minimap_width () : 0 );
275+
276+ for (int i = 0 ; i < line_length_guideline_columns.size (); i++) {
277+ const int column_pos = theme_cache.font ->get_string_size (String (" 0" ).repeat ((int )line_length_guideline_columns[i]), HORIZONTAL_ALIGNMENT_LEFT, -1 , theme_cache.font_size ).x ;
278+ const int xoffset = xmargin_beg + column_pos - get_h_scroll ();
279+ if (xoffset > xmargin_beg && xoffset < xmargin_end) {
280+ Color guideline_color = (i == 0 ) ? theme_cache.line_length_guideline_color : theme_cache.line_length_guideline_color * Color (1 , 1 , 1 , 0.5 );
281+ if (rtl) {
282+ RenderingServer::get_singleton ()->canvas_item_add_line (ci, Point2 (size.width - xoffset, 0 ), Point2 (size.width - xoffset, size.height ), guideline_color);
283+ continue ;
284+ }
285+ RenderingServer::get_singleton ()->canvas_item_add_line (ci, Point2 (xoffset, 0 ), Point2 (xoffset, size.height ), guideline_color);
286+ }
287+ }
288+ }
289+
283290void CodeEdit::gui_input (const Ref<InputEvent> &p_gui_input) {
284291 Ref<InputEventPanGesture> pan_gesture = p_gui_input;
285292 if (pan_gesture.is_valid () && code_completion_active && code_completion_rect.has_point (pan_gesture->get_position ())) {
0 commit comments