From d927d41f89c5662f9e439026aa00556b8db119b2 Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 26 May 2024 20:08:59 +0200 Subject: [PATCH] Optimize usage of position icon in 2D editor --- editor/plugins/canvas_item_editor_plugin.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index ee96de8f233..c97801487d2 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3058,6 +3058,7 @@ void CanvasItemEditor::_draw_ruler_tool() { return; } + const Ref position_icon = get_editor_theme_icon(SNAME("EditorPosition")); if (ruler_tool_active) { Color ruler_primary_color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor)); Color ruler_secondary_color = ruler_primary_color; @@ -3126,8 +3127,7 @@ void CanvasItemEditor::_draw_ruler_tool() { if (begin.is_equal_approx(end)) { viewport->draw_string_outline(font, text_pos, (String)ruler_tool_origin, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, outline_size, outline_color); viewport->draw_string(font, text_pos, (String)ruler_tool_origin, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, font_color); - Ref position_icon = get_editor_theme_icon(SNAME("EditorPosition")); - viewport->draw_texture(get_editor_theme_icon(SNAME("EditorPosition")), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); + viewport->draw_texture(position_icon, (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); return; } @@ -3198,7 +3198,6 @@ void CanvasItemEditor::_draw_ruler_tool() { } } else { if (grid_snap_active) { - Ref position_icon = get_editor_theme_icon(SNAME("EditorPosition")); viewport->draw_texture(position_icon, (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2); } }