diff --git a/dialog/base.go b/dialog/base.go index adf6738c18..a40609ab24 100644 --- a/dialog/base.go +++ b/dialog/base.go @@ -108,10 +108,9 @@ func (d *dialog) Show() { } func (d *dialog) Layout(obj []fyne.CanvasObject, size fyne.Size) { - d.bg.Move(fyne.NewPos(-theme.Padding(), -theme.Padding())) - d.bg.Resize(size.Add(fyne.NewSize(theme.Padding()*2, theme.Padding()*2))) + d.bg.Move(fyne.NewPos(0, 0)) + d.bg.Resize(size) - textMin := obj[2].MinSize() btnMin := obj[3].MinSize().Union(obj[3].Size()) // icon @@ -119,21 +118,23 @@ func (d *dialog) Layout(obj []fyne.CanvasObject, size fyne.Size) { obj[0].Resize(fyne.NewSize(iconHeight, iconHeight)) obj[0].Move(fyne.NewPos(size.Width-iconHeight+theme.Padding(), -theme.Padding())) - // content (text) - obj[2].Move(fyne.NewPos(size.Width/2-(textMin.Width/2), size.Height-padHeight-btnMin.Height-textMin.Height-theme.Padding())) - obj[2].Resize(fyne.NewSize(textMin.Width, textMin.Height)) - // buttons obj[3].Resize(btnMin) obj[3].Move(fyne.NewPos(size.Width/2-(btnMin.Width/2), size.Height-padHeight-btnMin.Height)) + + // content + contentStart := d.label.Position().Y + d.label.MinSize().Height + padHeight + contentEnd := obj[3].Position().Y - theme.Padding() + obj[2].Move(fyne.NewPos((padWidth / 2), d.label.MinSize().Height+padHeight)) + obj[2].Resize(fyne.NewSize(size.Width-padWidth, contentEnd-contentStart)) } func (d *dialog) MinSize(obj []fyne.CanvasObject) fyne.Size { - textMin := obj[2].MinSize() + contentMin := obj[2].MinSize() btnMin := obj[3].MinSize().Union(obj[3].Size()) - width := fyne.Max(fyne.Max(textMin.Width, btnMin.Width), obj[4].MinSize().Width) + padWidth*2 - height := textMin.Height + btnMin.Height + d.label.MinSize().Height + theme.Padding() + padHeight*2 + width := fyne.Max(fyne.Max(contentMin.Width, btnMin.Width), obj[4].MinSize().Width) + padWidth + height := contentMin.Height + btnMin.Height + d.label.MinSize().Height + theme.Padding() + padHeight*2 return fyne.NewSize(width, height) } diff --git a/dialog/base_test.go b/dialog/base_test.go index 0a62038e1b..94d0d2f068 100644 --- a/dialog/base_test.go +++ b/dialog/base_test.go @@ -15,7 +15,11 @@ func TestShowCustom_ApplyTheme(t *testing.T) { test.ApplyTheme(t, theme.DarkTheme()) w := test.NewWindow(canvas.NewRectangle(color.Transparent)) w.Resize(fyne.NewSize(300, 200)) - d := NewCustom("Title", "OK", widget.NewLabel("Content"), w) + + label := widget.NewLabel("Content") + label.Alignment = fyne.TextAlignCenter + + d := NewCustom("Title", "OK", label, w) d.Show() test.AssertImageMatches(t, "dialog-custom-dark.png", w.Canvas().Capture()) diff --git a/dialog/testdata/color/dialog_expanded_theme_dark.png b/dialog/testdata/color/dialog_expanded_theme_dark.png index 28f09ca804..b47e9b9f41 100644 Binary files a/dialog/testdata/color/dialog_expanded_theme_dark.png and b/dialog/testdata/color/dialog_expanded_theme_dark.png differ diff --git a/dialog/testdata/color/dialog_expanded_theme_light.png b/dialog/testdata/color/dialog_expanded_theme_light.png index fb4bc0a609..f87a2d6446 100644 Binary files a/dialog/testdata/color/dialog_expanded_theme_light.png and b/dialog/testdata/color/dialog_expanded_theme_light.png differ diff --git a/dialog/testdata/color/dialog_recents_theme_dark.png b/dialog/testdata/color/dialog_recents_theme_dark.png index 9bc6cb47fb..12d725af52 100644 Binary files a/dialog/testdata/color/dialog_recents_theme_dark.png and b/dialog/testdata/color/dialog_recents_theme_dark.png differ diff --git a/dialog/testdata/color/dialog_recents_theme_light.png b/dialog/testdata/color/dialog_recents_theme_light.png index 8254e3b340..b2b16bab6b 100644 Binary files a/dialog/testdata/color/dialog_recents_theme_light.png and b/dialog/testdata/color/dialog_recents_theme_light.png differ diff --git a/dialog/testdata/color/dialog_simple_recents_theme_dark.png b/dialog/testdata/color/dialog_simple_recents_theme_dark.png index 795da4a6eb..962e280bf6 100644 Binary files a/dialog/testdata/color/dialog_simple_recents_theme_dark.png and b/dialog/testdata/color/dialog_simple_recents_theme_dark.png differ diff --git a/dialog/testdata/color/dialog_simple_recents_theme_light.png b/dialog/testdata/color/dialog_simple_recents_theme_light.png index d2046d05cd..0c08927cc5 100644 Binary files a/dialog/testdata/color/dialog_simple_recents_theme_light.png and b/dialog/testdata/color/dialog_simple_recents_theme_light.png differ diff --git a/dialog/testdata/color/dialog_simple_theme_dark.png b/dialog/testdata/color/dialog_simple_theme_dark.png index 5006948bb7..f426b462cc 100644 Binary files a/dialog/testdata/color/dialog_simple_theme_dark.png and b/dialog/testdata/color/dialog_simple_theme_dark.png differ diff --git a/dialog/testdata/color/dialog_simple_theme_light.png b/dialog/testdata/color/dialog_simple_theme_light.png index e2629a4137..a3b557c613 100644 Binary files a/dialog/testdata/color/dialog_simple_theme_light.png and b/dialog/testdata/color/dialog_simple_theme_light.png differ diff --git a/dialog/testdata/color/dialog_theme_dark.png b/dialog/testdata/color/dialog_theme_dark.png index a34ad8525e..df11411d36 100644 Binary files a/dialog/testdata/color/dialog_theme_dark.png and b/dialog/testdata/color/dialog_theme_dark.png differ diff --git a/dialog/testdata/color/dialog_theme_light.png b/dialog/testdata/color/dialog_theme_light.png index f97ae61ed0..94574ff06b 100644 Binary files a/dialog/testdata/color/dialog_theme_light.png and b/dialog/testdata/color/dialog_theme_light.png differ diff --git a/dialog/testdata/dialog-custom-dark.png b/dialog/testdata/dialog-custom-dark.png index 5ae704ed47..8e311e315d 100644 Binary files a/dialog/testdata/dialog-custom-dark.png and b/dialog/testdata/dialog-custom-dark.png differ diff --git a/dialog/testdata/dialog-custom-light.png b/dialog/testdata/dialog-custom-light.png index 9c8172eaf5..66643bc638 100644 Binary files a/dialog/testdata/dialog-custom-light.png and b/dialog/testdata/dialog-custom-light.png differ