Skip to content

Commit a36ed26

Browse files
committed
remember invert colors setting in advanced settings
1 parent 6fac9e9 commit a36ed26

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed

do/settings_def.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ var (
8080
"background might allow to subconsciously determine reading progress; "+
8181
"suggested values: #2828aa #28aa28 #aa2828"),
8282
mkField("InvertColors", Bool, false,
83-
"if true, TextColor and BackgroundColor will be temporarily swapped").setInternal(),
83+
"if true, TextColor and BackgroundColor of the document will be swapped"),
8484
mkField("HideScrollbars", Bool, false,
8585
"if true, hides the scrollbars but retains ability to scroll"),
8686
}

src/AppSettings.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,13 @@ bool ReloadSettings() {
308308

309309
const char* uiLanguage = str::DupTemp(gGlobalPrefs->uiLanguage);
310310
bool showToolbar = gGlobalPrefs->showToolbar;
311-
bool invertColors = gGlobalPrefs->fixedPageUI.invertColors;
312311

313312
gFileHistory.UpdateStatesSource(nullptr);
314313
CleanUpSettings();
315314

316315
ok = LoadSettings();
317316
CrashAlwaysIf(!ok || !gGlobalPrefs);
318317

319-
gGlobalPrefs->fixedPageUI.invertColors = invertColors;
320-
321318
// TODO: about window doesn't have to be at position 0
322319
if (gWindows.size() > 0 && gWindows.at(0)->IsAboutWindow()) {
323320
MainWindow* win = gWindows.at(0);

src/Settings.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ struct FixedPageUI {
6363
// subconsciously determine reading progress; suggested values: #2828aa
6464
// #28aa28 #aa2828
6565
Vec<char*>* gradientColors;
66-
// if true, TextColor and BackgroundColor will be temporarily swapped
66+
// if true, TextColor and BackgroundColor of the document will be
67+
// swapped
6768
bool invertColors;
6869
// if true, hides the scrollbars but retains ability to scroll
6970
bool hideScrollbars;
@@ -467,11 +468,12 @@ static const FieldInfo gFixedPageUIFields[] = {
467468
{offsetof(FixedPageUI, windowMargin), SettingType::Compact, (intptr_t)&gWindowMarginInfo},
468469
{offsetof(FixedPageUI, pageSpacing), SettingType::Compact, (intptr_t)&gSizeInfo},
469470
{offsetof(FixedPageUI, gradientColors), SettingType::ColorArray, 0},
471+
{offsetof(FixedPageUI, invertColors), SettingType::Bool, false},
470472
{offsetof(FixedPageUI, hideScrollbars), SettingType::Bool, false},
471473
};
472-
static const StructInfo gFixedPageUIInfo = {
473-
sizeof(FixedPageUI), 7, gFixedPageUIFields,
474-
"TextColor\0BackgroundColor\0SelectionColor\0WindowMargin\0PageSpacing\0GradientColors\0HideScrollbars"};
474+
static const StructInfo gFixedPageUIInfo = {sizeof(FixedPageUI), 8, gFixedPageUIFields,
475+
"TextColor\0BackgroundColor\0SelectionColor\0WindowMargin\0PageSpacing\0Gra"
476+
"dientColors\0InvertColors\0HideScrollbars"};
475477

476478
static const FieldInfo gWindowMargin_1_Fields[] = {
477479
{offsetof(WindowMargin, top), SettingType::Int, 0},

src/SumatraPDF.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -5285,12 +5285,14 @@ static LRESULT FrameOnCommand(MainWindow* win, HWND hwnd, UINT msg, WPARAM wp, L
52855285
}
52865286
break;
52875287

5288-
case CmdInvertColors:
5288+
case CmdInvertColors: {
52895289
gGlobalPrefs->fixedPageUI.invertColors ^= true;
52905290
UpdateDocumentColors();
52915291
UpdateControlsColors(win);
52925292
// UpdateUiForCurrentTab(win);
5293+
SaveSettings();
52935294
break;
5295+
}
52945296

52955297
case CmdNavigateBack:
52965298
if (ctrl) {

src/SumatraStartup.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,9 @@ static void UpdateGlobalPrefs(const Flags& i) {
608608
str::ReplacePtr(&gGlobalPrefs->inverseSearchCmdLine, cmdLine);
609609
gGlobalPrefs->enableTeXEnhancements = true;
610610
}
611-
gGlobalPrefs->fixedPageUI.invertColors = i.invertColors;
611+
if (i.invertColors) {
612+
gGlobalPrefs->fixedPageUI.invertColors = true;
613+
}
612614

613615
char* arg = nullptr;
614616
char* param = nullptr;

src/Theme.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,6 @@ void SetThemeByIndex(int themeIdx) {
159159
currentThemeIndex = themeIdx;
160160
gCurrentTheme = gThemes[currentThemeIndex];
161161
str::ReplaceWithCopy(&gGlobalPrefs->theme, gCurrentTheme->name);
162-
#if 0
163-
// for light theme set invertColors
164-
// don't invert for light theme, invert for dark themes
165-
gGlobalPrefs->fixedPageUI.invertColors = (themeIdx == 0);
166-
#endif
167162
UpdateAfterThemeChange();
168163
};
169164

0 commit comments

Comments
 (0)