From 0afcea36d26ac75233ec745a00cd23b931ddef5d Mon Sep 17 00:00:00 2001 From: FPabl0 Date: Tue, 9 Feb 2021 13:36:01 -0500 Subject: [PATCH] fix modalPopUpRenderer refresh and refresh dialog when it is shown to fix #1866 --- dialog/base.go | 42 ++++++++++++++++++++++-------------------- widget/popup.go | 5 +++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/dialog/base.go b/dialog/base.go index 69979a19ba..7a135cd94c 100644 --- a/dialog/base.go +++ b/dialog/base.go @@ -104,6 +104,7 @@ func (d *dialog) Show() { d.win.Resize(d.desiredSize) } d.win.Show() + d.Refresh() } func (d *dialog) Layout(obj []fyne.CanvasObject, size fyne.Size) { @@ -198,7 +199,7 @@ func (d *dialog) hideWithResponse(resp bool) { func (d *dialog) setButtons(buttons fyne.CanvasObject) { d.bg = canvas.NewRectangle(theme.BackgroundColor()) - d.label = newDialogTitle(d.title, d) + d.label = widget.NewLabelWithStyle(d.title, fyne.TextAlignLeading, fyne.TextStyle{Bold: true}) var content fyne.CanvasObject if d.icon == nil { @@ -245,27 +246,28 @@ func newButtonList(buttons ...*widget.Button) fyne.CanvasObject { return list } -// dialogTitle is really just a normal title but we use the Refresh() hook to update the background rectangle. -type dialogTitle struct { - widget.Label +// TODO I don't think it is needed +// // dialogTitle is really just a normal title but we use the Refresh() hook to update the background rectangle. +// type dialogTitle struct { +// widget.Label - d *dialog -} +// d *dialog +// } -// Refresh applies the current theme to the whole dialog before refreshing the underlying label. -func (t *dialogTitle) Refresh() { - t.d.Refresh() +// // Refresh applies the current theme to the whole dialog before refreshing the underlying label. +// func (t *dialogTitle) Refresh() { +// t.d.Refresh() - t.BaseWidget.Refresh() -} +// t.BaseWidget.Refresh() +// } -func newDialogTitle(title string, d *dialog) *dialogTitle { - l := &dialogTitle{} - l.Text = title - l.Alignment = fyne.TextAlignLeading - l.TextStyle.Bold = true +// func newDialogTitle(title string, d *dialog) *dialogTitle { +// l := &dialogTitle{} +// l.Text = title +// l.Alignment = fyne.TextAlignLeading +// l.TextStyle.Bold = true - l.d = d - l.ExtendBaseWidget(l) - return l -} +// l.d = d +// l.ExtendBaseWidget(l) +// return l +// } diff --git a/widget/popup.go b/widget/popup.go index 848f33e321..e7f371c577 100644 --- a/widget/popup.go +++ b/widget/popup.go @@ -203,6 +203,7 @@ func (r *popUpRenderer) Refresh() { if r.background.Size() != r.popUp.innerSize || r.background.Position() != r.popUp.innerPos { r.Layout(r.popUp.Size()) } + // TODO should fix this refresh too? r.background.Refresh() } @@ -241,5 +242,9 @@ func (r *modalPopUpRenderer) Refresh() { if r.background.Size() != r.popUp.innerSize { r.Layout(r.popUp.Size()) } + if !r.popUp.Canvas.Size().Subtract(r.popUp.BaseWidget.Size()).IsZero() { + r.popUp.BaseWidget.Resize(r.popUp.Canvas.Size()) + } + r.popUp.Content.Refresh() r.background.Refresh() }