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
Wrap dialog labels #1001
Wrap dialog labels #1001
Conversation
Oh wow, Andy is your screenshot showing dialog not measuring children for minsize?! As you can see from the golden images there is still a lot of work to do here;
|
From the golden images it looks like the dialog is incorrectly being resized to the full window on the test driver. If that issue is resolved and they go back to minsize you'll probably see the same as in the screenshot I posted. Dialogs are designed to show the content at minsize. They can be expanded programatically, but when you expand the window that does not happen automatically. |
That is with your patch applied. Without it the dialog will expand to fir the content, but (at least I think and from what I can see) with wrapping turned on the minsize shrinks, and so does the dialog? I was just curious about how it looks on your machine... maybe I based it off the wrong branch? |
It appears setting textwrap affects the min size calculation, but when the label is laid out the maxWidth is set to the window's width, not the dialog width. |
After merging #998 some test images changed |
I think the issue is that Label uses textProvider which is itself a BaseWidget. When the updateRowBounds is called the textProvider size is unset, so it does not wrap. Label either needs to resize textProvider when it is resized, or textProvider shouldn't be a BaseWidget. Thoughts? |
Hmm, tricky. In the longrun I think you're right TextProvider should not be a BaseWidget - on reflection that looks like it was a bad choice - it is possibly better presented as a renderer or mixin - probably related to a refresh of how renderers are handled in 2.0. In the meantime I gues that a label should ensure that it's textProvider remains the same size, yes. It's curious that truncating works but wrapping does not - do they walk different paths with regards to their bounds? |
Apologies, I see that this requested reviews a while back - but I think it requires more work as shown in the conversation right? |
Yes, more work is needed here. My bad, I thought marking it as draft would cancel the review requests. I'll take it out of draft when it is ready |
It seems like this has been causing problems recently for some developers. If we wrap and then shrink as we normally do it will likely wrap to as many lines as possible which is likely not what we want. |
I suppose this didn't make 2.0 -- while I hit this issue repeatedly in #1570 it turned out the answer for me was "Stop using Dialog." As in, if you are writing extremely long strings into a Dialog, then you are doing something wrong. Exception: Outside of this however, I would not expect other Dialogs to automagically wrap strings I pass to them. Also, using code such as the following, it is possible to get working label wrapping (but requires workarounds): user := widget.NewEntry()
pass := widget.NewPasswordEntry()
warning := widget.NewLabel(loginWarning) // very long text
warning.Wrapping = fyne.TextWrapWord
vbox := widget.NewVBox(
warning,
layout.NewSpacer(),
widget.NewForm(
widget.NewFormItem("Email", user),
widget.NewFormItem("Password", pass),
),
layout.NewSpacer(),
)
dlg := dialog.NewCustomConfirm(
"Login to sc2replaystats","Login", "Cancel",
vbox, func(ok bool) {
if ok {
// ...
}
},
w)
dlg.Show()
vbox.Resize(fyne.NewSize(999, 280)) // workaround #1565 by setting height to 999 (larger than window)
dlg.Resize(fyne.NewSize(420, 280)) // workaround #1570 by resizing Dialog after container Also, I think checks need to be re-run on a number of PRs/issues (they are stuck at "Waiting for status to be reported." |
These PRs pre-date an infrastructure move (read the Travis OSS story for more) and so they need to be re-based onto latest develop for the checks to run. |
Description:
Wraps dialog labels to avoid them being too wide
Checklist:
Where applicable: