You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Merge pull request #47628 from Calinou/2d-editor-remove-contrained-view
Remove constrained view in the 2D editor
This commit is contained in:
@@ -4010,27 +4010,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);
|
||||
@@ -4038,20 +4025,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);
|
||||
|
||||
Reference in New Issue
Block a user