From ad2c2cd33234dc7561ea5c8e98bdc708bdd0ba43 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Mon, 28 Mar 2022 18:28:02 -0400 Subject: [PATCH 1/4] fancier buttons if you use manifest --- minigui.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/minigui.d b/minigui.d index d3c07b9..bbad167 100644 --- a/minigui.d +++ b/minigui.d @@ -10845,13 +10845,13 @@ class Button : MouseActivatedWidget { super(parent); // BS_BITMAP is set when we want image only, so checking for exactly that combination - enum imgFlags = ImageLabel.DisplayFlags.displayImage; - auto extraStyle = ((label.displayFlags & imgFlags) == imgFlags) ? BS_BITMAP : 0; + enum imgFlags = ImageLabel.DisplayFlags.displayImage | ImageLabel.DisplayFlags.displayText; + auto extraStyle = ((label.displayFlags & imgFlags) == ImageLabel.DisplayFlags.displayImage) ? BS_BITMAP : 0; - createWin32Window(this, "button"w, label.label, BS_PUSHBUTTON | extraStyle); + createWin32Window(this, "button"w, label.label, BS_PUSHBUTTON | extraStyle, WS_EX_TRANSPARENT ); if(label.image) { - sprite = Sprite.fromMemoryImage(parentWindow.win, label.image); + sprite = Sprite.fromMemoryImage(parentWindow.win, label.image, true); SendMessageW(hwnd, BM_SETIMAGE, IMAGE_BITMAP, cast(LPARAM) sprite.nativeHandle); } From ab5ff7d9d187ff068e9a7469f88bd4180ae470fa Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Mon, 28 Mar 2022 18:34:01 -0400 Subject: [PATCH 2/4] more docs --- minigui.d | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/minigui.d b/minigui.d index bbad167..2511296 100644 --- a/minigui.d +++ b/minigui.d @@ -10485,6 +10485,13 @@ class OnOffSwitch : MouseActivatedWidget { +/ struct ImageLabel { /++ + Defines a label+image combo used by some widgets. + + If you provide just a text label, that is all the widget will try to + display. Or just an image will display just that. If you provide both, + it may display both text and image side by side or display the image + and offer text on an input event depending on the widget. + History: The `alignment` parameter was added on September 27, 2021 +/ @@ -10494,6 +10501,7 @@ struct ImageLabel { this.alignment = alignment; } + /// ditto this(string label, MemoryImage image, TextAlignment alignment = TextAlignment.Center) { this.label = label; this.image = image; @@ -10501,12 +10509,14 @@ struct ImageLabel { this.alignment = alignment; } + /// ditto this(MemoryImage image, TextAlignment alignment = TextAlignment.Center) { this.image = image; this.displayFlags = DisplayFlags.displayImage; this.alignment = alignment; } + /// ditto this(string label, MemoryImage image, int displayFlags, TextAlignment alignment = TextAlignment.Center) { this.label = label; this.image = image; @@ -10836,6 +10846,9 @@ class Button : MouseActivatedWidget { History: The [ImageLabel] overload was added on June 21, 2021 (dub v10.1). + + The button with label and image will respect requests to show both on Windows as + of March 28, 2022 iff you provide a manifest file to opt into common controls v6. +/ this(ImageLabel label, Widget parent) { version(win32_widgets) { From 0f5958d42e7740ba8b23de39d8fc7eec688549f2 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Mon, 28 Mar 2022 19:01:48 -0400 Subject: [PATCH 3/4] assume commctl6 even without manifest --- minigui.d | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/minigui.d b/minigui.d index 2511296..53dfe6b 100644 --- a/minigui.d +++ b/minigui.d @@ -326,6 +326,15 @@ version(Windows) { static import gdi = core.sys.windows.wingdi; } +version(Windows) { + version(CRuntime_Microsoft) { // FIXME: mingw? + // assume we want commctrl6 whenever possible since there's really no reason not to + // and this avoids some of the manifest hassle + pragma(linkerDirective, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\""); + } + +} + // this is a hack to call the original window procedure on native win32 widgets if our event listener thing prevents default. private bool lastDefaultPrevented; From ff35d9d120941255b545a8e3466f949d90e4e373 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Mon, 28 Mar 2022 19:12:25 -0400 Subject: [PATCH 4/4] support older compilers in minigui still --- minigui.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minigui.d b/minigui.d index 53dfe6b..635fd03 100644 --- a/minigui.d +++ b/minigui.d @@ -327,12 +327,12 @@ version(Windows) { } version(Windows) { + static if(__VERSION__ >= 2_083) version(CRuntime_Microsoft) { // FIXME: mingw? // assume we want commctrl6 whenever possible since there's really no reason not to // and this avoids some of the manifest hassle pragma(linkerDirective, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\""); } - } // this is a hack to call the original window procedure on native win32 widgets if our event listener thing prevents default.