digitalmars.D.learn - arsd-minigui - couple of questions
- sai (9/9) Mar 28 2022 1. I assume arsd-minigui library does not support transparent
- sai (11/20) Mar 28 2022 BTW, the code is very simple:
- Adam Ruppe (8/15) Mar 28 2022 I added that to simpledisplay last year, but never forwarded the
- Adam Ruppe (6/10) Mar 28 2022 Well, I tried forwarding the flag, I can custom draw it this way
- Sai (33/43) Mar 28 2022 Thanks for the reply and the help.
- Adam Ruppe (14/17) Mar 28 2022 Yeah, this tells me they used owner-drawn buttons, which is only
- Adam Ruppe (6/6) Mar 28 2022 oooh it actually is even easier than I thought, just a changed
- Adam Ruppe (5/5) Mar 28 2022 In fact, using a pragma now, I think I got it so you don't even
- sai (30/35) Mar 29 2022 I just cloned the latest arsd lib from github today and compiled
- sai (2/2) Mar 29 2022 Actually as you mentioned, I did find the changes in minigui.d
- sai (8/9) Mar 29 2022 I suspect something is going wrong when passing the linker
- sai (3/3) Mar 29 2022 Found this: https://bugs.llvm.org/show_bug.cgi?id=38797
- Adam D Ruppe (6/8) Mar 29 2022 I just tried copying the lld-link from llvm version 14 upstream
- sai (1/1) Mar 29 2022 Thanks Adam for all the help :)
- sai (6/6) Apr 11 2022 One more request, is it possible for you to do to ImageBox what
- Adam D Ruppe (7/10) Apr 11 2022 oh yeah this one is different because the imagebox custom draws
- sai (2/12) Apr 11 2022 Done, it works. Awesome thanks.
- Adam D Ruppe (10/13) Mar 29 2022 Ah sorry, you caught me in the middle of something. Yes, I
1. I assume arsd-minigui library does not support transparent images by itself, does it? I am trying to show a png image with transparent areas on a button, but those transparent areas shows as black color. 2. I want to show both image and text on a button, but looks like it shows image or text, but not both at the same time. Or am I missing some weird windows manifest stuff? I am using latest arsd library on windows 10. Thanks
Mar 28 2022
On Monday, 28 March 2022 at 17:00:42 UTC, sai wrote:1. I assume arsd-minigui library does not support transparent images by itself, does it? I am trying to show a png image with transparent areas on a button, but those transparent areas shows as black color. 2. I want to show both image and text on a button, but looks like it shows image or text, but not both at the same time. Or am I missing some weird windows manifest stuff? I am using latest arsd library on windows 10. ThanksBTW, the code is very simple: ```d import arsd.minigui; void main() { auto window = new Window(); auto headBut = new Button(ImageLabel("Button name", MemoryImage.fromImage("file.png")), window); window.loop(); } ```
Mar 28 2022
On Monday, 28 March 2022 at 17:00:42 UTC, sai wrote:1. I assume arsd-minigui library does not support transparent images by itself, does it? I am trying to show a png image with transparent areas on a button, but those transparent areas shows as black color.I added that to simpledisplay last year, but never forwarded the flag to minigui since it didn't seem important.... should be easy enough to add, I'll take a look.2. I want to show both image and text on a button, but looks like it shows image or text, but not both at the same time. Or am I missing some weird windows manifest stuff?Yeah, it is one or the other right now. I don't think the standard Windows control supports that without owner draw, which is something I've generally tried to avoid (but it isn't that hard to do at least in some cases...).
Mar 28 2022
On Monday, 28 March 2022 at 17:00:42 UTC, sai wrote:1. I assume arsd-minigui library does not support transparent images by itself, does it? I am trying to show a png image with transparent areas on a button, but those transparent areas shows as black color.Well, I tried forwarding the flag, I can custom draw it this way but the standard Windows button's normal draw doesn't appear to care... There might be a trick I just don't know, but the problem is I don't know it lol.
Mar 28 2022
On Monday, 28 March 2022 at 18:03:32 UTC, Adam Ruppe wrote:On Monday, 28 March 2022 at 17:00:42 UTC, sai wrote:Thanks for the reply and the help. FWIW, DWT which uses native controls on windows can show transparent pngs and also both image & text at the same time. However I had to add the following app.exe.manifest file in the same folder as the app.exe file. Otherwise it only shows text or image but not both. Not sure if this helps, but just want to let you know. Honestly I have no idea how this works under the hood. ``` <?xml version="1.0" encoding="utf-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="-" type="win32" /> <description></description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly> ```1. I assume arsd-minigui library does not support transparent images by itself, does it? I am trying to show a png image with transparent areas on a button, but those transparent areas shows as black color.Well, I tried forwarding the flag, I can custom draw it this way but the standard Windows button's normal draw doesn't appear to care... There might be a trick I just don't know, but the problem is I don't know it lol.
Mar 28 2022
On Monday, 28 March 2022 at 21:10:47 UTC, Sai wrote:FWIW, DWT which uses native controls on windows can show transparent pngs and also both image & text at the same time. However I had to add the following app.exe.manifestYeah, this tells me they used owner-drawn buttons, which is only supported if you use version 6 controls. The version 6 controls are nice btw even if you don't use this specific feature, they also come with automatic theme support and a few other nice things. I actually recommend in the docs that you use this for simpledisplay/minigui applications too, just then you also need to provide a draw method to do the text+image. It isn't hard to do, about a dozen lines for this basic case that you can just opt into and use the default draw for other cases. I was thinking about adding one of those anyway (another nice thing you can do is change the background color), I just haven't gotten around to it yet. Maybe I'll do it tomorrow. Keep an eye on this thread, if I do, I'll let you know.
Mar 28 2022
oooh it actually is even easier than I thought, just a changed flag plus the manifest. Just pushed to minigui master. only ended up being 4 lines for this little thing. Try rebuilding with that AND be sure to use the manifest file too, same as dwt. Then you should be able to find some joy.
Mar 28 2022
In fact, using a pragma now, I think I got it so you don't even need the manifest now (the pragma includes a default one now). Only works when doing dmd -m32mscoff or dmd -m64 builds (which are also what dub uses fyi), will NOT work with a default dmd no-switch build.
Mar 28 2022
On Monday, 28 March 2022 at 23:03:01 UTC, Adam Ruppe wrote:In fact, using a pragma now, I think I got it so you don't even need the manifest now (the pragma includes a default one now). Only works when doing dmd -m32mscoff or dmd -m64 builds (which are also what dub uses fyi), will NOT work with a default dmd no-switch build.I just cloned the latest arsd lib from github today and compiled the example. Got an error. Switched on verbose flag for dub and here is the output: (Lines below until the error is just one giant line, I split them here for clarity) ``` C:\dlang\dmd2\windows\bin64\dmd.exe -of.dub\build\application-debug-windows-x86_64-dmd_v2.099.0-dirty-9C73C615E47957E2F0196C61BFACFF7A\app.exe .dub\build\application-debug-windows-x86_64-dmd_v2.099.0-dirty-9C73C615E47957E2F0196C61BFACFF7A\app.obj C:\dlang\arsd\.dub\build\library-debug-windows-x86_64-dmd_v2.099.0-dirty-5128CD87C77EA53A12BDD90A8B37E0E4\arsd-official_image_files.lib C:\dlang\arsd\.dub\build\library-debug-windows-x86_64-dmd_v2.099.0-dirty-66D647CCA1055F2F9BD2C4AAD0551124\arsd-official_bmp.lib C:\dlang\arsd\.dub\build\library-debug-windows-x86_64-dmd_v2.099.0-dirty-8F6807A564A94A3E26A5FDE91B0A798F\arsd-official_imageresize.lib C:\dlang\arsd\.dub\build\library-debug-windows-x86_64-dmd_v2.099.0-dirty-24F06AB33E1AC529F9B3C0A9DEA4B137\arsd-official_jpeg.lib C:\dlang\arsd\.dub\build\library-debug-windows-x86_64-dmd_v2.099.0-dirty-ABDB0882B5E2D9CDE956E9E845377256\arsd-official_png.lib C:\dlang\arsd\.dub\build\library-debug-windows-x86_64-dmd_v2.099.0-dirty-1DE97EFE0E43837E141C233C0AA5C31F\arsd-official_svg.lib C:\dlang\arsd\.dub\build\library-debug-windows-x86_64-dmd_v2.099.0-dirty-0128B44A475FA39689E2D238F5500D0D\arsd-official_minigui.lib C:\dlang\arsd\.dub\build\normal-debug-windows-x86_64-dmd_v2.099.0-dirty-CD2FC136BEDCF32714DEA23BE867AC78\arsd-official_simpledisplay.lib C:\dlang\arsd\.dub\build\library-debug-windows-x86_64-dmd_v2.099.0-dirty-1A0BC8A3D79617FC811AC1F1422195CC\arsd-off cial_color_base.lib gdi32.lib ole32.lib -m64 -g lld-link: error: /manifestdependency: is not allowed in .drectve Error: linker exited with status 1 FAIL .dub\build\application-debug-windows-x86_64-dmd_v2.099.0-dirty-9C73C615E4795 E2F0196C61BFACFF7A\ app executable C:\dlang\dmd2\windows\bin64\dmd.exe failed with exit code 1. ``` I searched for "manifestdependency" and "drectve" (w/o quotes) in arsd lib and couldn't find them so not sure how to debug this further. I also removed the explicit manifest file from the directory of the exe file (its presence didn't make any difference anyway, as exe file is not created as link failed).
Mar 29 2022
Actually as you mentioned, I did find the changes in minigui.d file. I will try tweaking the pragma there see if anything works.
Mar 29 2022
Interestingly I get the same error if I change the pragma test to "BLAH"I suspect something is going wrong when passing the linker options from pragma to the linker itself. However, if I uncomment the pragma and explicitly place the manifest file it works (as you mentioned before). I will use it this way for now. But fixing the pragma will be awesome if we can get rid of the manifest file.lld-link: error: BLAH is not allowed in .drectve
Mar 29 2022
Found this: https://bugs.llvm.org/show_bug.cgi?id=38797 Seems like a linker bug? So we have to wait for the fix to show up in dmd package.
Mar 29 2022
On Tuesday, 29 March 2022 at 14:24:13 UTC, sai wrote:Seems like a linker bug? So we have to wait for the fix to show up in dmd package.I just tried copying the lld-link from llvm version 14 upstream into the dmd directory and it does fix the problem, so will try to get the dmd release manager to do that for the future. Then I can enable this convenient thing again when that updates based on a dmd version check.
Mar 29 2022
One more request, is it possible for you to do to ImageBox what you did to Button to show the transparent images (png)? Because Imagebox is showing black color for transparent pixels. I tried to see the git history to see if I can make that change to Imagebox and submit a pull request, but I am lost and don't think I understand the code well enough.
Apr 11 2022
On Monday, 11 April 2022 at 12:40:29 UTC, sai wrote:One more request, is it possible for you to do to ImageBox what you did to Button to show the transparent images (png)? Because Imagebox is showing black color for transparent pixels.oh yeah this one is different because the imagebox custom draws it, so it is really as simple as passing `true` to the opacity there too when it converts. Try this diff: https://github.com/adamdruppe/arsd/commit/912047ccdda7e7775f64431a631519e6024d2494 i think it fixes it, let me know.
Apr 11 2022
On Monday, 11 April 2022 at 13:14:16 UTC, Adam D Ruppe wrote:On Monday, 11 April 2022 at 12:40:29 UTC, sai wrote:Done, it works. Awesome thanks.One more request, is it possible for you to do to ImageBox what you did to Button to show the transparent images (png)? Because Imagebox is showing black color for transparent pixels.oh yeah this one is different because the imagebox custom draws it, so it is really as simple as passing `true` to the opacity there too when it converts. Try this diff: https://github.com/adamdruppe/arsd/commit/912047ccdda7e7775f64431a631519e6024d2494 i think it fixes it, let me know.
Apr 11 2022
On Tuesday, 29 March 2022 at 13:39:25 UTC, sai wrote:I searched for "manifestdependency" and "drectve" (w/o quotes) in arsd lib and couldn't find them so not sure how to debug this further.Ah sorry, you caught me in the middle of something. Yes, I remember seeing this before, lld-link is buggy and doesn't support this :( I tried this before and it failed, but this time I tested again after seeing it in the Windows API docs on my laptop computer... which has the Microsoft linker installed, which does support it. So it worked for me and I committed without checking the other linker. This is annoying. You can edit the source to comment that I guess and just use the .manifest file instead. Ugh.
Mar 29 2022