summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-11-27 14:52:08 +0100
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-11-27 14:52:08 +0100
commit3fc29e62e634d81a6959074dd635c95745fe523d (patch)
tree765920262dd8238e1badcf0e05b84b9fb8b97238
parenttabWidgetLayoutItem: Make IdealSize the same as MinSize (diff)
downloadwireguard-windows-3fc29e62e634d81a6959074dd635c95745fe523d.tar.xz
wireguard-windows-3fc29e62e634d81a6959074dd635c95745fe523d.zip
FormBase: Improve automatic resizing to accommodate children
-rw-r--r--form.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/form.go b/form.go
index c04e1634..ac0214e3 100644
--- a/form.go
+++ b/form.go
@@ -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)