diff options
author | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-11-27 14:52:08 +0100 |
---|---|---|
committer | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-11-27 14:52:08 +0100 |
commit | 3fc29e62e634d81a6959074dd635c95745fe523d (patch) | |
tree | 765920262dd8238e1badcf0e05b84b9fb8b97238 | |
parent | tabWidgetLayoutItem: Make IdealSize the same as MinSize (diff) | |
download | wireguard-windows-3fc29e62e634d81a6959074dd635c95745fe523d.tar.xz wireguard-windows-3fc29e62e634d81a6959074dd635c95745fe523d.zip |
FormBase: Improve automatic resizing to accommodate children
-rw-r--r-- | form.go | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -681,10 +681,17 @@ func (fb *FormBase) startLayout() bool { return false } - cb := fb.window.ClientBoundsPixels() cs := fb.clientSizeFromSizePixels(fb.proposedSize) + min := CreateLayoutItemsForContainer(fb.clientComposite).MinSizeForSize(fb.proposedSize) - fb.clientComposite.SetBoundsPixels(Rectangle{cb.X, cb.Y, cs.Width, cs.Height}) + if cs.Width < min.Width || cs.Height < min.Height { + cs = maxSize(cs, min) + size := fb.sizeFromClientSizePixels(cs) + fb.SetSizePixels(size) + fb.Invalidate() + } + + fb.clientComposite.SetBoundsPixels(Rectangle{Width: cs.Width, Height: cs.Height}) cli := CreateLayoutItemsForContainer(fb) cli.Geometry().ClientSize = cs @@ -838,7 +845,9 @@ func (fb *FormBase) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) u fb.SetSuspended(wasSuspended) rc := (*win.RECT)(unsafe.Pointer(lParam)) - fb.window.SetBoundsPixels(rectangleFromRECT(*rc)) + bounds := rectangleFromRECT(*rc) + fb.proposedSize = bounds.Size() + fb.window.SetBoundsPixels(bounds) fb.SetIcon(fb.icon) |