summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2021-04-04 19:25:11 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2023-05-20 03:01:12 +0200
commit86314e1e537dad0e9c007a10ace04cb4261c3b7d (patch)
tree627515110a815eadbc179e8d46ec9717d340d718
parent809a98216267f3066b9fec2f02b2042bdc9d3e0d (diff)
downloadredot-engine-86314e1e537dad0e9c007a10ace04cb4261c3b7d.tar.gz
Remove constrained view in the 2D editor
We initially added an option to disable constraining the 2D editor view. This setting was still enabled by default to avoid confusing users who end up scrolling too far away from their current scene (which is a problem if you don't know about the F key to focus on the selection). However, it's probably a better choice to unconstrain the 2D editor view by default because: - Lots of people don't know about this setting and wonder how they can scroll far away from the scene. This feels really limiting for them, and it can even lead to some people thinking Godot intentionally limits scene sizes. - The 3D editor doesn't have such a contrain mechanism. This makes the 2D editor more consistent with the 3D editor.
-rw-r--r--doc/classes/EditorSettings.xml3
-rw-r--r--editor/editor_settings.cpp1
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp33
3 files changed, 4 insertions, 33 deletions
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 6a27bff763..703c78ceb9 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -228,9 +228,6 @@
<member name="editors/2d/bone_width" type="int" setter="" getter="">
The bone width in the 2D skeleton editor (in pixels). See also [member editors/2d/bone_outline_size].
</member>
- <member name="editors/2d/constrain_editor_view" type="bool" setter="" getter="">
- If [code]true[/code], prevents the 2D editor viewport from leaving the scene. Limits are calculated dynamically based on nodes present in the current scene. If [code]false[/code], the 2D editor viewport will be able to move freely, but you risk getting lost when zooming out too far. You can refocus on the scene by selecting a node then pressing [kbd]F[/kbd].
- </member>
<member name="editors/2d/grid_color" type="Color" setter="" getter="">
The grid color to use in the 2D editor.
</member>
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 0eb76c6011..9798f890a0 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -687,7 +687,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("editors/2d/bone_outline_color", Color(0.35, 0.35, 0.35, 0.5));
_initial_set("editors/2d/bone_outline_size", 2);
_initial_set("editors/2d/viewport_border_color", Color(0.4, 0.4, 1.0, 0.4));
- _initial_set("editors/2d/constrain_editor_view", true);
// Panning
// Enum should be in sync with ControlScheme in ViewPanner.
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 2a04f7b174..169d10c0b6 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -4009,27 +4009,14 @@ void CanvasItemEditor::_update_scrollbars() {
canvas_item_rect.size += screen_rect * 2;
canvas_item_rect.position -= screen_rect;
- // Constraints the view offset and updates the scrollbars.
- Size2 size = viewport->get_size();
- Point2 begin = canvas_item_rect.position;
- Point2 end = canvas_item_rect.position + canvas_item_rect.size - local_rect.size / zoom;
- bool constrain_editor_view = bool(EDITOR_GET("editors/2d/constrain_editor_view"));
+ // Updates the scrollbars.
+ const Size2 size = viewport->get_size();
+ const Point2 begin = canvas_item_rect.position;
+ const Point2 end = canvas_item_rect.position + canvas_item_rect.size - local_rect.size / zoom;
if (canvas_item_rect.size.height <= (local_rect.size.y / zoom)) {
- real_t centered = -(size.y / 2) / zoom + screen_rect.y / 2;
- if (constrain_editor_view && ABS(centered - previous_update_view_offset.y) < ABS(centered - view_offset.y)) {
- view_offset.y = previous_update_view_offset.y;
- }
-
v_scroll->hide();
} else {
- if (constrain_editor_view && view_offset.y > end.y && view_offset.y > previous_update_view_offset.y) {
- view_offset.y = MAX(end.y, previous_update_view_offset.y);
- }
- if (constrain_editor_view && view_offset.y < begin.y && view_offset.y < previous_update_view_offset.y) {
- view_offset.y = MIN(begin.y, previous_update_view_offset.y);
- }
-
v_scroll->show();
v_scroll->set_min(MIN(view_offset.y, begin.y));
v_scroll->set_max(MAX(view_offset.y, end.y) + screen_rect.y);
@@ -4037,20 +4024,8 @@ void CanvasItemEditor::_update_scrollbars() {
}
if (canvas_item_rect.size.width <= (local_rect.size.x / zoom)) {
- real_t centered = -(size.x / 2) / zoom + screen_rect.x / 2;
- if (constrain_editor_view && ABS(centered - previous_update_view_offset.x) < ABS(centered - view_offset.x)) {
- view_offset.x = previous_update_view_offset.x;
- }
-
h_scroll->hide();
} else {
- if (constrain_editor_view && view_offset.x > end.x && view_offset.x > previous_update_view_offset.x) {
- view_offset.x = MAX(end.x, previous_update_view_offset.x);
- }
- if (constrain_editor_view && view_offset.x < begin.x && view_offset.x < previous_update_view_offset.x) {
- view_offset.x = MIN(begin.x, previous_update_view_offset.x);
- }
-
h_scroll->show();
h_scroll->set_min(MIN(view_offset.x, begin.x));
h_scroll->set_max(MAX(view_offset.x, end.x) + screen_rect.x);