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 Control nodes' size when changing the _window size_ project settings #7125

Closed
sosasees opened this issue Jun 20, 2023 · 10 comments
Closed

Comments

@sosasees
Copy link

sosasees commented Jun 20, 2023

Describe the project you are working on

a GUI application

Describe the problem or limitation you are having in your project

when changing the window size project settings, i can't see if the new window size is better (or worse) for the layout until i close the project settings and reselect the root Control node's anchor preset.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

if the Controls update their size when changing the window size project settings, i can check how the new window size affects the opened scene instantly, instead of having to close the project settings and reselect the scene root Control's anchor preset first.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

when changing the project setting display/window/size/viewport_width or display/window/size/viewport_height , every Control that is a scene root or CanvasLayer child updates its size.

If this enhancement will not be used often, can it be worked around with a few lines of script?

i can add a tool script to the Control that is a scene root or CanvasLayer child, that resets its anchor preset every frame:

@tool
extends Control

func _process(_delta:float) -> void:
	set_anchors_preset(Control.PRESET_FULL_RECT)

※ you could choose any LayoutPreset in place of PRESET_FULL_RECT, but my responsive UI plugin (version 1.1.0) chooses PRESET_FULL_RECT for its FullRectControl node type

Is there a reason why this should be core and not an add-on in the asset library?

this is a very useful (and expected) quality-of-life feature,
and it would be much more useful if

  • it was enabled in Godot out-of-the-box
  • it didn't block a Control's script slot
  • the Controls only updated their size when changing the window size project settings — not on every frame, which is the only way to do this in GDScript ∗

∗ maybe i could change the script to only update the size when changing the window size project settings, if Godot adds the signal
ProjectSettings.setting_changed( name:String )

@RedMser
Copy link

RedMser commented Jun 20, 2023

+1 I've also been bothered by this a bunch. I personally would file this as a bug, but it depends on why it's currently not behaving correctly.
The anchor preset seems to get remembered on the Control, so it probably just isn't notified correctly that the viewport size has changed.

maybe i could change the script to only update the size when changing the window size project settings, if Godot adds the signal ProjectSettings.setting_changed( name:String )

There already exists EditorPlugin.project_settings_changed for this.

@sosasees
Copy link
Author

I personally would file this as a bug, but it depends on why it's currently not behaving correctly.

the disagreement if this is a bug has been there since the comment where i asked about this issue for the very first time:

  1. @YuriSizov asked if i reported this bug (comment)
  2. i replied that i think this should be a feature proposal (comment)

@sosasees
Copy link
Author

sosasees commented Jun 20, 2023

maybe i could change the script to only update the size when changing the window size project settings, if Godot adds the signal
ProjectSettings.setting_changed( name:String )

There already exists EditorPlugin.project_settings_changed for this.

¡thank you! for finding this signal. i expected it to be in ProjectSettings.

update

i failed to connect the signal through this code

EditorPlugin.project_settings_changed.connect(
	_on_project_settings_changed
)

because of the error

Invalid get index 'project_settings_changed' (on base: 'EditorPlugin').

but i found another way to optimise the script: updating the Control's size only in the editor:

@tool
extends Control

func _process(_delta:float) -> void:
	if Engine.is_editor_hint():
		set_anchors_preset(Control.PRESET_FULL_RECT)
	else:
		set_script(null)

※ when adding the feature to Godot, the Control size should update only when changing the window size project settings.
but for the FullRectControl in my add-on, this is very good.

@AThousandShips
Copy link
Member

To be clear, is this only about the editor or both editor and running game?

@sosasees
Copy link
Author

sosasees commented Jun 21, 2023

this issue is about updating the Controls' size when changing the window size project settings in the editor.

updating the Controls' size when resizing the window in the running game works like expected.

@YuriSizov
Copy link
Contributor

YuriSizov commented Jun 22, 2023

Is this essentially the same as godotengine/godot#69208 ? If so, I would prefer to close this in favor of that issue.

@sosasees
Copy link
Author

yes, this is the same issue. the only real differences are:

i didn't find this duplicate myself because i didn't think of looking for bug reports when i looked for duplicates.
from my perspective, this is a missing feature and not a bug.

@B-l-u-e-f-i-r-e
Copy link

@sosasees
This is why I believe this is a Bug:
Almost always, when settings are changed, they're updated immediately. For instance, when the renderer setting is altered, a window appears asking the user to restart the editor to apply the new settings. This seems to be the standard functionality across most settings, which either apply changes instantly or prompt the user to take an action (like restarting) to implement the change.

In this particular case, however, it doesn't update or require an action for the setting to update, instead nothing happens and the setting is not updated. This leads me to believe that we're dealing with a bug, not a situation where we're discussing a new feature request.

@sosasees
Copy link
Author

this makes sense, now i know why this is a bug.

@sosasees
Copy link
Author

closed in favor of godotengine/godot#69208

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants