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

Update canvas layer size and control after project settings changed. #93717

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3967,6 +3967,7 @@ void CanvasItemEditor::_update_editor_settings() {

void CanvasItemEditor::_project_settings_changed() {
EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels"));
update_viewport();
}

void CanvasItemEditor::_notification(int p_what) {
Expand Down
15 changes: 15 additions & 0 deletions scene/gui/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,11 @@ void Control::_size_changed() {
}
}

void Control::_project_settings_changed() {
update_minimum_size();
_size_changed();
}

void Control::_clear_size_warning() {
data.size_warning = false;
}
Expand Down Expand Up @@ -3259,6 +3264,10 @@ void Control::_notification(int p_notification) {
data.RI = viewport->_gui_add_root_control(this);

get_parent()->connect(SNAME("child_order_changed"), callable_mp(get_viewport(), &Viewport::gui_set_root_order_dirty), CONNECT_REFERENCE_COUNTED);

if (Engine::get_singleton()->is_editor_hint()) {
ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &Control::_project_settings_changed));
}
}

data.parent_canvas_item = get_parent_item();
Expand Down Expand Up @@ -3290,6 +3299,12 @@ void Control::_notification(int p_notification) {
get_parent()->disconnect(SNAME("child_order_changed"), callable_mp(get_viewport(), &Viewport::gui_set_root_order_dirty));
}

if (Engine::get_singleton()->is_editor_hint()) {
if (!Object::cast_to<Control>(get_parent())) {
ProjectSettings::get_singleton()->disconnect("settings_changed", callable_mp(this, &Control::_project_settings_changed));
}
}

data.parent_canvas_item = nullptr;
data.is_rtl_dirty = true;
} break;
Expand Down
1 change: 1 addition & 0 deletions scene/gui/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ class Control : public CanvasItem {
void _update_minimum_size_cache();
void _update_minimum_size();
void _size_changed();
void _project_settings_changed();

void _top_level_changed() override {} // Controls don't need to do anything, only other CanvasItems.
void _top_level_changed_on_parent() override;
Expand Down
Loading