Skip to content

Commit

Permalink
fix modalPopUpRenderer refresh and refresh dialog when it is shown to f…
Browse files Browse the repository at this point in the history
  • Loading branch information
fpabl0 committed Feb 9, 2021
1 parent 6193bd8 commit 0afcea3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
42 changes: 22 additions & 20 deletions dialog/base.go
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
// }
5 changes: 5 additions & 0 deletions widget/popup.go
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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()
}

0 comments on commit 0afcea3

Please sign in to comment.