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
Resize ignored in popup containing wrapped text. #1570
Comments
Hidden widgets should not be included in any calculations and disposal is not needed. You may have noticed that |
Same issue, and The work-around for now is to "resize all the things" The following works, but exemplifies the bug: Reproduction
Codefunc (w *windowMain) WizardModal(skipText, nextText string, skipFn, nextFn func(*widget.PopUp), contents ...fyne.CanvasObject) {
var modal *widget.PopUp
if skipFn == nil {
skipFn = func(*widget.PopUp) { modal.Hide() }
}
if nextFn == nil {
nextFn = func(*widget.PopUp) { modal.Hide() }
}
buttons := make([]fyne.CanvasObject, 0)
if skipText != "" {
btn := widget.NewButtonWithIcon(skipText, theme.CancelIcon(), func() { skipFn(modal) })
btn.Importance = widget.LowImportance
buttons = append(buttons, btn)
}
if nextText != "" {
btn := widget.NewButtonWithIcon(nextText, theme.NavigateNextIcon(), func() { nextFn(modal) })
btn.Importance = widget.HighImportance
buttons = append(buttons, btn)
}
box := widget.NewVBox(
widget.NewCard(title, summary, widget.NewVBox(contents...)),
layout.NewSpacer(),
widget.NewSeparator(),
fyne.NewContainerWithLayout(
layout.NewGridLayout(len(buttons)),
buttons...,
),
)
modal = widget.NewModalPopUp(box, w.Canvas())
modal.Show()
// modal.Resize(fyne.NewSize(320, 220)) // required to resize subsequent modals
box.Resize(fyne.NewSize(320, 220)) // required to resize the first shown modal
}
func (w *windowMain) Step1() {
w.WizardModal("Skip", "Next", nil, func(modal *widget.PopUp) {
modal.Hide()
w.Step2()
},
labelWithWrapping("You are only two steps away from having your replays automatically uploaded!"),
labelWithWrapping("We will guide you through both of the steps (don't worry, they're easy!"),
)
}
func (w *windowMain) Step2() {
w.WizardModal("Back", "Next", func(modal *widget.PopUp() {
modal.Hide()
w.Step1()
}, func(modal *widget.PopUp) {
modal.Hide()
},
labelWithWrapping("First thing's first. We need to find your StarCraft II Replays Directory!"),
labelWithWrapping("More Lorem Ipsum text because I haven't written this yet. Shows off the bug."),
)
} |
Given that I have a work-around for this, I will be finishing up However, once I've done that, I'll create a reproduction repository for this (and the linked) bug, to make it easier for you guys. Sorry about creating all these issues, haha. |
Thanks for all the information. |
I know it might be a daft thing to ask - but why not use a single modal dialog and pack a container inside it that can switch out contents instead? You could show/hide panels like the container.AppTabs does. Might be less code for you. |
widget.PopUp
?
In the above example, one need only call The following code is very pared-down, but is what was used to reproduce this bug. Probably more scaffolding/structure than is required, hence I'm making a repository soon. // Window represents a managed fyne.Window
type Window interface {
GetWindow() fyne.Window
SetWindow(fyne.Window)
Init()
Hide()
Show()
}
type windowBase struct {
fyne.Window
app fyne.App
ui *graphicalInterface
}
// GetWindow returns the managed fyne.Window
func (b *windowBase) GetWindow() fyne.Window {
return b.Window
}
// SetWindow is not used in this bug replication
func (b *windowBase) SetWindow(w fyne.Window) {
b.Window = w
}
type windowMain struct {
*windowBase
// other stuff unrelated to bug
}
func (w *windowMain) Init() {
w.windowBase.Window = w.windowBase.app.NewWindow("Main Window")
w.SetContent(widget.NewVBox(
widget.NewButton("Hi!", func() {
w.Step1()
}),
))
w.Resize(fyne.NewSize(420, 360))
w.CenterOnScreen()
}
const (
// WindowMain is an index string used in graphicalInterface.windows
WindowMain = "Main"
)
func newUI() *graphicalInterface {
ui := new(graphicalInterface)
ui.app = app.New()
ui.app.Settings().SetTheme(theme.DarkTheme())
ui.windows = make(map[string]Window)
ui.windows[WindowMain] = &windowMain{
windowBase: &windowBase{app: ui.app, ui: ui}}
// preparation of other windows
ui.windows[WindowMain].Init()
return ui
}
type graphicalInterface struct {
app fyne.App
windows map[string]Window
}
// OpenWindow shows a given window, initializing it first if needed
func (ui *graphicalInterface) OpenWindow(windowName string) {
if w, ok := ui.windows[windowName]; ok {
if w.GetWindow() == nil {
w.Init()
} else {
w.Show()
}
}
}
// Run starts the fyne.App and shows the main window
func (ui *graphicalInterface) Run() {
ui.windows[WindowMain].Show()
ui.app.Run()
}
func main() {
GUI = newUI()
GUI.Run()
} I may be following through with that suggestion soon, keeping the modal around and managing its' lifecycle instead of trying to dispose it or otherwise. Part of the issue, is that some actions from the Modal can trigger Dialogs, which currently do not play nice together (it is more reliable to close the modal before showing a dialog, then returning the modal after the dialog has been dismissed) which requires a lot of state management. |
There is no definition here for |
Apologies, that method is: func labelWithWrapping(text string) *widget.Label {
label := widget.NewLabel(text)
label.Wrapping = fyne.TextWrapWord
return label
} Alright, I tried to refactor changing the contents, however:
I am trying with a container now as you mentioned. |
I will try with that code, but for note:
|
When running the complete code I cannot see any issue. Can you please confirm the exact steps and show the bug outcome so we can verify? I have tried with and without your calls to |
All four of the below gifs were recording using the new re-used Modal/Container code (attached at the bottom of this message) With the 3
|
This issue can be seen in the application AlbinoGeek/sc2-rsu@475bac24 Most of the GUI code pertaining to this can be found in the |
Yes - nothing will draw smaller than it's minSize. If we take shadows out of the equasion (as they are being tracked in #1370), is the issue that the sizes you were using are too small, or is there another issue in here that we still need to fix? |
P.S. if you do want smaller dialogs than the size being presented, then in combination with your requested size in |
If we ignore the shadows, then this particular issue boils down to:
The |
Ok, updated the title accordingly. |
Was a new PR for this issue made since the cleanup of issues/PR that "pre-date an infrastructure move" |
Nobody has figured out how to solve this, so there is no PR open (the previous one was a work in progress that was not complete). |
So, I have code that creates a
widget.PopUp
using thewidget.NewModalPopUp
function. However, one of the buttons in the model closes it out (modal.Hide()
) and creates a new model (because simply replacing theContent
does not have the size re-calculated, due to the current shadow bug + the wordwrap bug...) --However, the second modal cannot be resized (???) -- I would assume it has something to do with the first one not being disposed, as there is no
modal.Close()
or equiv. function to trigger it to happen.Am I missing something?
The text was updated successfully, but these errors were encountered: