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

Popup containing an auto-wrap label opens too tall #47005

Open
Zylann opened this issue Mar 14, 2021 · 4 comments
Open

Popup containing an auto-wrap label opens too tall #47005

Zylann opened this issue Mar 14, 2021 · 4 comments

Comments

@Zylann
Copy link
Contributor

Zylann commented Mar 14, 2021

Some issues slightly related to similar problems exist, but they were worked around by turning off autowrap instead of actually fixing the problem with it.

Godot version:
Godot 3.2.3, Godot 3.2.4

OS/device including version:
Windows 10 64 bits

Issue description:
I have an AcceptDialog with a VBoxContainer inside. I added a label with some description text inside, and enabled autowrap so it fits inside the dialog.
Controls have the correct width when the popup opens, but no matter which sequence of setup I use, it always opens with a crazy high vertical size:
image

Steps to reproduce:
I do this in a module, so this is the code I used to reproduce it in GDScript:

extends Node

class CustomDialog extends AcceptDialog:
	func _init():
		rect_min_size = Vector2(300, 280)
		var vb = VBoxContainer.new()
		# Does not fix it
		#vb.rect_size = rect_min_size
		var label = Label.new()
		label.text = "This is custom text to debug my problem with the dialog size"
		label.autowrap = true
		# Does not fix it
		#label.rect_size = rect_min_size
		vb.add_child(label)
		add_child(vb)

var _dialog

func _init():
	_dialog = CustomDialog.new()
	add_child(_dialog)

func _on_Button_pressed():
	_dialog.popup_centered_minsize()

Minimal reproduction project:
PopupWithAutowrapLabel.zip

I suspect the reason is because at some point, controls get sorted in a state where the label is given a width of zero, making it become very tall to fit each letter in one column. I tried to workaround this by giving controls an initial size, and gave the popup a minimum size, to no avail.

@ray90514
Copy link
Contributor

ray90514 commented Mar 16, 2021

I can reproduce the problem in 3.2.3 stable but can't in 4.0
Edit: label can't get non-zero width by Control::get_size() before it is visible resulting in large line count and height
When AcceptDialog is opend, it will not update size by change of customized child
The AcceptDialog has already defined a HBoxContainer and a 'Label' , and the method set_autowrap() seems well-working
I think you could extend WindowDialog rather than AcceptDialog

@novalis
Copy link
Contributor

novalis commented Aug 2, 2022

For the next person to hit this: Set the dialog's text to "\n" (or maybe the empty string?) before you pop it up. Then, once you've popped it up, set the text to the text you want. That seems to work.

@timothyqiu
Copy link
Member

This is still the case for ConfirmationDialog in 4.0.2 (but okay for AcceptDialog).

MRP: wrap.zip

@YuriSizov
Copy link
Contributor

This is still the case for ConfirmationDialog in 4.0.2 (but okay for AcceptDialog).

The only difference between the two is how many buttons they have. So the issue is likely valid for both, but maybe confirm accidentally causes an extra update, or something like that.

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

6 participants