Some plugins' icons disappear when going from light to dark mode
-
I could be missing something, but it looks like youāre loading bitmaps from the PNG files in your resource directory (?)
No, I have
bmp
andico
files in the Resources directory, and those are referenced in theResources.resx
file. They arenāt 32x32 and 16x16, but if their size is the problem, then why do I only have problems when Iām switching from light mode to dark mode and not any other time?EDIT: The PNG files are in the same directory because I take screenshots of a PowerPoint presentation and then use ImageMagick in this batch file to regenerate the
bmp
andico
files whenever I want to change the icons. -
IMO most of the available evidence points to a very subtle bug in Notepad++, and so far nothing (including my own staring at how my icon initialization code compares to the corresponding code in other plugins like this code here) has particularly dissuaded me from this perspective.
FWIW, most of the Notepad++ code manipulating icons on the toolbar seems to be in the
ToolBar::reset(bool create)
method. Iāve tried to step through it in the debugger, but I just donāt have the patience to figure out what the hell is going on. Maybe Iāll take another crack at it tomorrow and figure something out. -
@Mark-Olson Iām not sure if this is related, at all ā¦ but when switching between light and dark mode while the style configurator is open. It appears as if Notepad++ gets a little confused about what theme is actually active.
After closing and opening NPP again, opening the Style configurator in light mode shows the darkmode theme selected.
It also seems like the change to move the ādefaultā theme to the top gets somewhat reversed and the Global Override is back on top.
Iām trying to nail down steps to reproduce, but itās all a bit strange.
-
@Snabel42 said in Some plugins' icons disappear when going from light to dark mode:
It also seems like the change to move the ādefaultā theme to the top gets somewhat reversed and the Global Override is back on top.
There is no confusion on Notepad++'s end. The order of the styles in the Global Styles list is 100% dependent on the XML file for your
stylers.xml
or selectedthemes\*.xml
ā look in the<GlobalStyles>
section in the XML, and youāll see that in whichever mode itās ārightā, the<WidgetStyle name="Default Style" ...
will be the first entry in the section, and in the mode that itās" wrong", the<WidgetStyle name="Global override"
will be first. If you donāt like the order, change it and restart Notepad++.(I just looked at the
DarkModeDefault,xml
and otherthemes\
in the portable of 8.7.5-RC1, and itās got the wrong order compared tostylers.model.xml
ā apparently, when the order was āfixedā, it was only for the default stylers, not for any of the themes. MyConfigUpdater.py
script, shared in Config Files Need Updating, Too, does fix the order in all the themes to match the order instylers.model.xml
, so itās yet another reason to run that script using the PythonScript plugin.) -
@Snabel42 if I switch to dark mode,then open the style configurator, NPP will select the Default (stylers.xml) theme. After closing and reopening NPP, then opening style configurator while still in Dark mode, NPP will select the DareModeDefault. If not a bug, at least a deficiency?
I believe the theme DarkModeDefault deserves to be aligned with the Default theme when it comes to Default Style vs Global Override. DarkModeDefault is not just a user-chosen theme but an actual āmodeā. But I suppose thatās a feature request then?
-
@Snabel42 said in Some plugins' icons disappear when going from light to dark mode:
If not a bug, at least a deficiency?
My reply wasnāt about that section. It was only about the section you quoted. But, since you askā¦
if I switch to dark mode,then open the style configurator, NPP will select the Default (stylers.xml) theme.
I cannot reproduce.if i start in light mode withstylers.xml
, then change to Dark theme, I close the Preferences dialog and open the Style Configurator, and itās immediately on DarkModeDefault. Thus, working exactlty as Iād expect, and not as you describe.I believe the theme DarkModeDefault deserves to be aligned with the Default theme when it comes to Default Style vs Global Override. DarkModeDefault is not just a user-chosen theme but an actual āmodeā. But I suppose thatās a feature request then?
It should be a feature request, yes. But note that because Notepad++ doesnāt overwrite your existing AppData themes when you upgrade, even if the ones in the installer were updated to match the order in the
stylers.model.xml
, you wouldnāt notice when you upgrade, because it will still see your old copy. (This is intentional, because the installer doesnāt know if youāve customized or not, and doesnāt want to risk deleting your customizations.) -
@PeterJones said in Some plugins' icons disappear when going from light to dark mode:
I cannot reproduce.if i start in light mode with stylers.xml, then change to Dark theme, I close the Preferences dialog and open the Style Configurator, and itās immediately on DarkModeDefault. Thus, working exactlty as Iād expect, and not as you describe.Update (and hence the strikeout): The first time I open Style Configurator after changing to Dark Mode, it correctly claims the
DarkModeDefault
is active, as I said above. But then after making my post, I went back and was going to switch back to my normal Light Mode, but accidentally clicked Style Configurator instead of Preferencesā¦ and when I did, I saw that it was now sayingDefault (stylers.xml)
, even though it was still obviously DarkModeDefault in reality. So I have now confirmed the bug. I would recommend that you put in a bug report for that one, but make it clear in the Steps to Reproduce that it might be different on the first time and second time opening the Style Configurator. -
@PeterJones Iām glad you tried some more and managed to see that something wasnāt quite right.
Iāve known thereās an issue for quite some time, but I couldnāt quite get the steps to reproduce it down.I thought Iād mention it here to try to crow source it a bit or at least shame myself into spending some time on it. Iāll try to reduce it to at least one consistent set of steps and then report it
@Mark-Olson sorry for the thread hijacking, assuming my issue is unrelated to yours
-
@Mark-Olson said in Some plugins' icons disappear when going from light to dark mode:
IMO most of the available evidence points to a very subtle bug in Notepad++, and so far nothing (including my own staring at how my icon initialization code compares to the corresponding code in other plugins like this code here) has particularly dissuaded me from this perspective.
Only thing I can think of trying is to recreate your
*.ico
files like this:@echo off @rem ~ 31K (all dims) @rem ~ 5K (32,16 only) magick %1.png -define icon:auto-resize=256,128,96,64,48,32,16 %1.ico
As you probably know already, the
*.ico
resources are what gets loaded if any of the āFluent UIā styles has been selected inPreferences > General
, in light or dark mode. The BMP files are just legacy baggage for users who prefer to Win2K look-and-feel of the āstandardā icon style.The crucial difference is that BMP icons are statically sized; the ICOs are āfluentā, i.e., can be scaled up, since an ICO is basically an archive of multiple, varying-sized images.
Is it possible your existing
*.ico
resources donāt provide one of the dimensions which the fluent UI code is expecting, making them disappear at certain scales ā¦ ? -
Thank you so much for suggesting that I resize my icons and bitmaps.š Your depth and breadth of knowledge continues to impress. I donāt know why I didnāt try doing this sooner! This doesnāt seem to have completely addressed the issue, because now it seems that the icons sometimes disappear when going from light to dark or dark to light, and I have no idea why itās inconsistent now.
Anyone who wants to look at my first crack at addressing this issue can download my most recent commit, JsonTools v8.3.1.1. After reading up on how ImageMagick handles geometry, I was able to update my batch file to get my icons and bitmaps to 32x32 and 16x16 respectively.
-
I said in Some plugins' icons disappear when going from light to dark mode:
BMP icons are statically sized; the ICOs are āfluentā, i.e., can be scaled up [ā¦]
This is mostly correct, but I should have mentioned that toolbar BMPs actually can simulate a kind of āDPI awarenessā, provided your plugin interface can access the GDI device capabilities API. See, for example, how ComparePlus goes about sizing its icons. Thereās also a .NET example in my experimental template project.
If thatās too much trouble, just re-dimension your bitmaps to make sure they can scale up without blurring, then load them at 24x24 pixels, since thatās what the graphics device will normally choose for conventional screens using 96 DPI.