Skip to content

Commit 4e40918

Browse files
committed
sleeker UI arrows and finally refactored the tray state logic
1 parent 2f86c0a commit 4e40918

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

QuickRotate.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ bool bCloseToTray = true;
154154
bool bAutoStart = false;
155155
bool bSettingsMode = false;
156156
bool bUpdateMode = false;
157-
int bTrayToggleLP = 1;
157+
enum TrayMode { TRAY_CYCLE = 0, TRAY_LANDPORT = 1, TRAY_FLIPLANDPORT = 2 };
158+
int bTrayToggleLP = TRAY_LANDPORT;
159+
constexpr const wchar_t* TRAY_MODE_TEXTS[] = {
160+
L"Tray Click: Cycle Rotation (Next \u27F3)",
161+
L"Tray Click: Landscape \u2039-\u203A Portrait",
162+
L"Tray Click: (F) Landscape \u2039-\u203A Portrait"
163+
};
158164
wchar_t g_appDir[MAX_PATH];
159165
wchar_t g_exePath[MAX_PATH];
160166
wchar_t g_startMenuPath[MAX_PATH];
@@ -1178,14 +1184,10 @@ LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
11781184

11791185
#ifndef LITE
11801186
int halfW = (BTN_W - 10) / 2;
1181-
hSetControls[0] = CreateMyButton(h, L"\u2B05 Back", ID_BTN_BACK, BTN_X, SETTINGS_Y, halfW, BTN_SH, BS_PUSHBUTTON | WS_TABSTOP);
1187+
hSetControls[0] = CreateMyButton(h, L"\u276E Back", ID_BTN_BACK, BTN_X, SETTINGS_Y, halfW, BTN_SH, BS_PUSHBUTTON | WS_TABSTOP);
11821188
hSetControls[11] = CreateMyButton(h, L"Check Update", ID_BTN_UPDATE, BTN_X + halfW + 10, SETTINGS_Y, halfW, BTN_SH, WS_TABSTOP);
11831189
struct TogData { int idx; LPCWSTR txt; int id; int y; };
1184-
LPCWSTR trayText;
1185-
if (bTrayToggleLP == 1) trayText = L"Tray Click: Landscape \u2194 Portrait";
1186-
else if (bTrayToggleLP == 2) trayText = L"Tray Click: (F) Landscape \u2194 Portrait";
1187-
else trayText = L"Tray Click: Cycle Rotation (Next \u27F3)";
1188-
1190+
LPCWSTR trayText = TRAY_MODE_TEXTS[bTrayToggleLP % 3];
11891191
const wchar_t* themeText;
11901192
if (bThemeMode == 0) themeText = L"Theme: System Default";
11911193
else if (bThemeMode == 1) themeText = L"Theme: Light Mode";
@@ -1516,14 +1518,9 @@ LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
15161518
ForceRedraw((HWND)l);
15171519
}
15181520
else if (id == ID_CHK_TRAYMODE) {
1519-
if (bTrayToggleLP == 1) bTrayToggleLP = 2;
1520-
else if (bTrayToggleLP == 2) bTrayToggleLP = 0;
1521-
else bTrayToggleLP = 1;
1522-
const wchar_t* modeText;
1523-
if (bTrayToggleLP == 1) modeText = L"Tray Click: Landscape \u2194 Portrait";
1524-
else if (bTrayToggleLP == 2) modeText = L"Tray Click: (F) Landscape \u2194 Portrait";
1525-
else modeText = L"Tray Click: Cycle Rotation (Next \u27F3)";
1526-
SetWindowTextW(hSetControls[8], modeText);
1521+
bTrayToggleLP = (bTrayToggleLP == TRAY_LANDPORT) ? TRAY_FLIPLANDPORT :
1522+
(bTrayToggleLP == TRAY_FLIPLANDPORT) ? TRAY_CYCLE : TRAY_LANDPORT;
1523+
SetWindowTextW(hSetControls[8], TRAY_MODE_TEXTS[bTrayToggleLP % 3]);
15271524
SaveSettings();
15281525
ForceRedraw((HWND)l);
15291526
}

0 commit comments

Comments
 (0)