Skip to content

Commit

Permalink
Merge pull request #92392 from KoBeWi/this_makes_editor_200%_faster
Browse files Browse the repository at this point in the history
Optimize usage of position icon in 2D editor
  • Loading branch information
akien-mga committed May 30, 2024
2 parents c9f2497 + d927d41 commit 32def9f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3058,6 +3058,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
return;
}

const Ref<Texture2D> 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;
Expand Down Expand Up @@ -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<Texture2D> 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;
}

Expand Down Expand Up @@ -3198,7 +3198,6 @@ void CanvasItemEditor::_draw_ruler_tool() {
}
} else {
if (grid_snap_active) {
Ref<Texture2D> position_icon = get_editor_theme_icon(SNAME("EditorPosition"));
viewport->draw_texture(position_icon, (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
}
}
Expand Down

0 comments on commit 32def9f

Please sign in to comment.