summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-10-25 12:06:03 +0200
committerGitHub <noreply@github.com>2019-10-25 12:06:03 +0200
commitf259beb4f1d8c9f2417c5a80deed2ae68baa69fa (patch)
tree8fb9c87f564c0441a693ea34f7186d1a097795a1 /editor/plugins
parent2869c13ba2f1ce2b17f30b611eb1eb7f0fa4a472 (diff)
parent50528b966dd45dba5d6214b8a3d7aa6b56e20dc3 (diff)
Merge pull request #33048 from KoBeWi/smarts_vs_grids
Make Ruler Tool depend on grid snap only
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 84372a6f93..7659363cdf 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -2287,9 +2287,7 @@ bool CanvasItemEditor::_gui_input_ruler_tool(const Ref<InputEvent> &p_event) {
return true;
}
- bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
-
- if (m.is_valid() && (ruler_tool_active || (is_snap_active && previous_origin != ruler_tool_origin))) {
+ if (m.is_valid() && (ruler_tool_active || (grid_snap_active && previous_origin != ruler_tool_origin))) {
viewport->update();
return true;
@@ -2687,8 +2685,6 @@ void CanvasItemEditor::_draw_ruler_tool() {
if (tool != TOOL_RULER)
return;
- bool is_snap_active = smart_snap_active ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL);
-
if (ruler_tool_active) {
Color ruler_primary_color = get_color("accent_color", "Editor");
Color ruler_secondary_color = ruler_primary_color;
@@ -2744,13 +2740,13 @@ void CanvasItemEditor::_draw_ruler_tool() {
if (begin.y < end.y) {
h_angle_text_pos.y = end.y + text_height * 1.5;
if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) {
- int height_multiplier = 1.5 + (int)is_snap_active;
+ int height_multiplier = 1.5 + (int)grid_snap_active;
h_angle_text_pos.y = MAX(text_pos.y + height_multiplier * text_height, MAX(end.y + text_height * 1.5, text_pos2.y + height_multiplier * text_height));
}
} else {
h_angle_text_pos.y = end.y - text_height * 0.5;
if (ABS(text_pos2.x - h_angle_text_pos.x) < text_width) {
- int height_multiplier = 1 + (int)is_snap_active;
+ int height_multiplier = 1 + (int)grid_snap_active;
h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height));
}
}
@@ -2785,7 +2781,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
viewport->draw_arc(end, arc_2_radius, arc_2_start_angle, arc_2_end_angle, arc_point_count, ruler_primary_color, Math::round(EDSCALE * arc_line_width));
}
- if (is_snap_active) {
+ if (grid_snap_active) {
text_pos = (begin + end) / 2 + Vector2(-text_width / 2, text_height / 2);
text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5);
@@ -2807,7 +2803,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
}
} else {
- if (is_snap_active) {
+ if (grid_snap_active) {
Ref<Texture> position_icon = get_icon("EditorPosition", "EditorIcons");
viewport->draw_texture(get_icon("EditorPosition", "EditorIcons"), (ruler_tool_origin - view_offset) * zoom - position_icon->get_size() / 2);
}