diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-06-27 15:14:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-27 15:14:23 +0200 |
commit | 11b8bf5572405a6b19d0ec80f0141c3b1e472a44 (patch) | |
tree | 585442603664aaaa1e03b4bc351048a4f4091cc0 /editor | |
parent | 071c033355953f225df5994558a084489f9e7b75 (diff) | |
parent | 1b53ea79e2094f3ef91ba9e377bb4b3242611cd6 (diff) |
Merge pull request #30103 from groud/center_2D_editor
Centers the 2D viewport in the editor
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 6ae3e2132a..e0e9d4af52 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3611,7 +3611,8 @@ void CanvasItemEditor::_update_scrollbars() { bool constrain_editor_view = bool(EditorSettings::get_singleton()->get("editors/2d/constrain_editor_view")); if (canvas_item_rect.size.height <= (local_rect.size.y / zoom)) { - if (constrain_editor_view && ABS(begin.y - previous_update_view_offset.y) < ABS(begin.y - view_offset.y)) { + float 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; } @@ -3631,7 +3632,8 @@ void CanvasItemEditor::_update_scrollbars() { } if (canvas_item_rect.size.width <= (local_rect.size.x / zoom)) { - if (constrain_editor_view && ABS(begin.x - previous_update_view_offset.x) < ABS(begin.x - view_offset.x)) { + float 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; } |