summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2020-09-01 11:53:45 +0200
committerAlexander Neumann <alexander.neumann@picos-software.com>2020-09-01 11:53:45 +0200
commit6eca744e8e85c67bb570d383f46ddbc9a441e29e (patch)
tree627fb82ee43f92a86343c0d84a41f0e9bb9dd3a9
parentTableView: Reduce flicker (diff)
downloadwireguard-windows-6eca744e8e85c67bb570d383f46ddbc9a441e29e.tar.xz
wireguard-windows-6eca744e8e85c67bb570d383f46ddbc9a441e29e.zip
Button: Fix weird BCM_GETIDEALSIZE issue with empty text
-rw-r--r--button.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/button.go b/button.go
index dde10a79..366d127f 100644
--- a/button.go
+++ b/button.go
@@ -220,11 +220,16 @@ func (b *Button) WndProc(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uint
// idealSize returns ideal button size in native pixels.
func (b *Button) idealSize() Size {
- var s win.SIZE
+ min := b.dialogBaseUnitsToPixels(Size{50, 14})
+
+ if b.Text() == "" {
+ return min
+ }
+ var s win.SIZE
b.SendMessage(win.BCM_GETIDEALSIZE, 0, uintptr(unsafe.Pointer(&s)))
- return maxSize(sizeFromSIZE(s), b.dialogBaseUnitsToPixels(Size{50, 14}))
+ return maxSize(sizeFromSIZE(s), min)
}
func (b *Button) CreateLayoutItem(ctx *LayoutContext) LayoutItem {