From c2c50fd57646e88b424eed228e220a91b84c29b6 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Sun, 28 Nov 2021 09:05:28 -0500 Subject: [PATCH] button ideal size setting (helps inline block layouts a lot) --- minigui.d | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/minigui.d b/minigui.d index 2f61633..58681d3 100644 --- a/minigui.d +++ b/minigui.d @@ -10167,6 +10167,29 @@ class Button : MouseActivatedWidget { }); } + override int flexBasisWidth() { + version(win32_widgets) { + SIZE size; + SendMessage(hwnd, BCM_GETIDEALSIZE, 0, cast(LPARAM) &size); + if(size.cx == 0) + goto fallback; + return size.cx + scaleWithDpi(16); + } + fallback: + return scaleWithDpi(cast(int) label.length * 8 + 16); + } + + override int flexBasisHeight() { + version(win32_widgets) { + SIZE size; + SendMessage(hwnd, BCM_GETIDEALSIZE, 0, cast(LPARAM) &size); + if(size.cy == 0) + goto fallback; + return size.cy + scaleWithDpi(6); + } + fallback: + return defaultLineHeight + 4; + } } /++