Skip to content

Commit

Permalink
Dialog: Fix centering in owner when calling Show.
Browse files Browse the repository at this point in the history
  • Loading branch information
lxn committed Apr 17, 2013
1 parent 3231cda commit 4e01aba
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,24 @@ func (dlg *Dialog) focusFirstCandidateDescendant() {

func (dlg *Dialog) Show() {
if dlg.owner != nil {
var size Size
if layout := dlg.Layout(); layout != nil {
size = layout.MinSize()
min := dlg.MinSize()
size.Width = maxi(size.Width, min.Width)
size.Height = maxi(size.Height, min.Height)
} else {
size = dlg.Size()
}

ob := dlg.owner.Bounds()
b := dlg.Bounds()

if dlg.centerInOwnerWhenRun {
dlg.SetBounds(Rectangle{
ob.X + (ob.Width-b.Width)/2,
ob.Y + (ob.Height-b.Height)/2,
b.Width,
b.Height,
ob.X + (ob.Width-size.Width)/2,
ob.Y + (ob.Height-size.Height)/2,
size.Width,
size.Height,
})
}
} else {
Expand Down

0 comments on commit 4e01aba

Please sign in to comment.