Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize usage of position icon in 2D editor #92392

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading