Automatic theme switch
It would be nice to have a System theme, which automatically picks Light or Dark depending on the active Windows Light/Dark theme.
It could read the system theme once on app start and select accordingly. With a bit more work it could automatically switch when Windows switches too.
I think that would be a very poor idea and unwanted by the majority since as you commented in other question when acidentally done is annoying but if every document was discoloured we would get more complaints. There is NO REAL theming with PDF simply alternate USER choice of displaced colour range.
I meant theming the app itself, not the PDF content.
Basically automatically choosing between Settings/Theme/Light or Settings/Theme/Dark based on the current Windows setting.
I am using an automatic Light/Dark system theme changer based on the hour (https://github.com/AutoDarkMode/Windows-Auto-Night-Mode), and when it switches between Light/Dark many apps do that too if you set them to follow the system theme.
I use Automatic Night Mode it works perfectly everything is light but dimmer at night and I have plenty of other annoying dark apps. adding such code in NOT as simple as flip the night switch.
Leaving open as a request but unless you can code such ability to not disturb status quo will perhaps be a long time coming.
The automatic application theme selection is available in many applications : web browser, office suite and even pdf reader.
For example, Adobe Reader's preferences offers "use system settings" :
https://helpx.adobe.com/acrobat/web/get-set-up/preferences-settings/set-light-dark-mode.html
Temporarily i am using https://github.com/AutoDarkMode/Windows-Auto-Night-Mode/discussions/799#discussioncomment-14168608, and am implementing it.
if (isLight) {
str::ReplaceWithCopy(&gGlobalPrefs->fixedPageUI.textColor, kDarkTextColor);
str::ReplaceWithCopy(&gGlobalPrefs->fixedPageUI.backgroundColor, kDarkBgColor);
} else {
str::ReplaceWithCopy(&gGlobalPrefs->fixedPageUI.textColor, kLightTextColor);
str::ReplaceWithCopy(&gGlobalPrefs->fixedPageUI.backgroundColor, kLightBgColor);
}
SaveSettings();
// Tried all of these for force reload of all open documents for immediate effect(but doesnt work)
UpdateDocumentColors();
UpdateControlsColors(win);
if (win) {
UpdateAfterThemeChange();
UpdateDocumentColors();
RerenderEverything();
ReloadDocument(win, false);
}
I have coded something like this while if i close and open window the text theme is changed(aka fixedui colours) it doesnt change immediately as it would with autodarkmode. how to refresh ui? any guide please
@neptotech
That thread is based on a very very old method I suggested very long ago that is no longer a good method as it was fragile then and more so now.
You should not be using foreground and background TINTS as SumatraPDF now has Themes (and custom Themes)
if (args.Length == 0)
{ Console.WriteLine("Usage: SumatraPDFTheme.exe [ Dark | "Dark from 3.5" | Darker | "Dark background Bright text" | Light | "Solarized Light" ]");
return; }
...
if (lines[i].StartsWith("Theme ="))
{
lines[i] = "Theme = args[0]"; // Change to desired theme
break;
You must respect user interaction and allow user to say yes or no and thus use already open setting (and not close) or alternatively open and close with notepad so SumatraPDF sees the interaction see how interaction is monitored
StartMonitoringDirForChangesAPC() C:\Users\WDAGUtilityAccount\Desktop\Apps\Programming\c#
SaveSettings
StartMonitoringDirForChangesAPC() C:\Users\WDAGUtilityAccount\AppData\Local\SumatraPDF
DeleteStaleFilesAsync: dir: 'C:\Users\WDAGUtilityAccount\AppData\Local\SumatraPDF-data', gIsPreRelaseBuild: 1, ver: prerel-3.6.17065-64
currTabIdx: 2
@2-5 SumatraPDF can be set to Themes and here 2 different settings files (same as a decade ago) allow user to start the app 2 different ways but the main issue is that requires 2 histories, unless the user sticks with one file and dynamic reset's like user selects a theme or presses shifted I or messes badly with custom paper tints (not recommended). Your use of a time switch over is the best solution for when theme switching should be invoked but SumatraPDF does not work that way.
@GitHubRulesOK I don't get you,
Thats exactly why I am using fixedpage ui's background,text(via setting file,via autodarkmode userscript) colour methods to get output like:
@neptotech This Thread was opened especially to ask for THEME control switching , especially for Dark to Light and back.
I have written a few utilities you can use in your timer batch files to cover your more specific CLI control one allows you to set the inbuilt themes (as currently that is not yet added to SumatraPDF DDE commands) the other 2 set the invert toggle especially to On use the Download icons then on most windows 10 or 11 they should self compile https://github.com/GitHubRulesOK/SumatraPDF-Plus/blob/master/Plus/SumatraPDFInvertOn.cmd or Off https://github.com/GitHubRulesOK/SumatraPDF-Plus/blob/master/Plus/SumatraPDFInvertOff.cmd and for setting themes https://github.com/GitHubRulesOK/SumatraPDF-Plus/blob/master/Plus/SumatraPDFTheme.cmd
For setting paper tints SumatraPDF has always had command line settings for background and foreground (but are stated as depreciating)
-set-color-range <text-hexcolor> <background-hexcolor> : Uses the given two colors for foreground and background and maps all other colors used in a document in between these
There are other ways to change the UXperience such as Gradients and Dialog colours.
Leaving open as a request but unless you can code such ability to not disturb status quo will perhaps be a long time coming.
There is an unofficial way of getting the current Windows theme, by reading a registry key. Here is a Microsoft UI library using it: https://github.com/microsoft/microsoft-ui-xaml/blob/fb7a83b668baa612b5cc594678746dd8c1f8d8bd/src/dxaml/xcp/components/theminginterop/SystemThemingInterop.cpp#L33
What I propose is the following:
on sumatra start:
if settings.Theme == "System":
is_system_theme_dark = GetWindowsSystemTheme() == "Dark"
settings.Theme = is_system_theme_dark ? "Dark" : "Light"
It's a minimal change, I don't see how it disturbs the status quo, or not respect the user preferences, since the user must first select the System theme in Sumatra settings.
As a bonus, another System+Content theme could be added, which also inverts the PDF colors in Dark mode. Of course, the user must first activate this theme too.
@2-5 Thanks for your suggestion but (as non developer) I cannot change SumatraPDF only make suggestions or help with alternative re-actions
Your suggestions are valid and I showed SumatraPDF is only recently theme aware, thus a lot of code changes may potentially still be required by a SMOP (Themes and inversion for negatives and blueprints have never been directly linked).
However whilst some setting changes can be made "run time" others need SumatraPDF to be closed and restarted so not easy to alter User Interface instantly.
My suggestion is to use the existing potential of a users "Mash-Up" by set themes and other existing abilities such as combine Dark+Inverted+ Colour Tint settings externally before Start up This is why I wrote the above utilities.