Fix the tabbar incoherent alternate icons settings while switching in dark mode

This commit is contained in:
Don HO 2021-05-20 19:08:32 +02:00
parent 585608b456
commit 156bde258f
3 changed files with 20 additions and 1 deletions

View File

@ -228,6 +228,10 @@ INT_PTR CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_generalSubDlg.setToolIconsFromStdToSmall(); _generalSubDlg.setToolIconsFromStdToSmall();
return TRUE; return TRUE;
case PREF_MSG_DISABLETABBARALTERNATEICONS:
_generalSubDlg.disableTabbarAlternateIcons();
return TRUE;
case WM_COMMAND : case WM_COMMAND :
{ {
if (LOWORD(wParam) == IDC_LIST_DLGTITLE) if (LOWORD(wParam) == IDC_LIST_DLGTITLE)
@ -380,6 +384,15 @@ void GeneralSubDlg::setToolIconsFromStdToSmall()
::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_TOOLBAR_REDUCE, 0); ::SendMessage(_hParent, WM_COMMAND, IDM_VIEW_TOOLBAR_REDUCE, 0);
} }
void GeneralSubDlg::disableTabbarAlternateIcons()
{
NppGUI& nppGUI = NppParameters::getInstance().getNppGUI();
int altIconsBit = TAB_ALTICONS;
nppGUI._tabStatus &= ~altIconsBit;
::SendDlgItemMessage(_hSelf, IDC_CHECK_TAB_ALTICONS, BM_SETCHECK, BST_UNCHECKED, 0);
}
INT_PTR CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) INT_PTR CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{ {
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();
@ -822,13 +835,17 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
nppGUI._darkmode.enableMenubar = enableDarkMode; nppGUI._darkmode.enableMenubar = enableDarkMode;
nppGUI._darkmode.enableScrollbarHack = enableDarkMode; nppGUI._darkmode.enableScrollbarHack = enableDarkMode;
// if dark mode enabled & TB_STANDARD is selected, switch to TB_SMALL // Maintain the coherence in preferences
if (nppGUI._darkmode.enable) if (nppGUI._darkmode.enable)
{ {
// For toolbar: if dark mode enabled & TB_STANDARD is selected, switch to TB_SMALL
bool isStandardChecked = false; bool isStandardChecked = false;
::SendMessage(_hParent, PREF_MSG_ISCHECKED_GENERALPAGE, IDC_RADIO_STANDARD, LPARAM(&isStandardChecked)); ::SendMessage(_hParent, PREF_MSG_ISCHECKED_GENERALPAGE, IDC_RADIO_STANDARD, LPARAM(&isStandardChecked));
if (isStandardChecked) if (isStandardChecked)
::SendMessage(_hParent, PREF_MSG_SETTOOLICONSFROMSTDTOSMALL, 0, 0); ::SendMessage(_hParent, PREF_MSG_SETTOOLICONSFROMSTDTOSMALL, 0, 0);
// For tabbar: uncheck Alternate icons checkbox
::SendMessage(_hParent, PREF_MSG_DISABLETABBARALTERNATEICONS, 0, 0);
} }
changed = true; changed = true;
break; break;

View File

@ -38,6 +38,7 @@ class GeneralSubDlg : public StaticDialog
public : public :
GeneralSubDlg() = default; GeneralSubDlg() = default;
void setToolIconsFromStdToSmall(); void setToolIconsFromStdToSmall();
void disableTabbarAlternateIcons();
private : private :
INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);

View File

@ -19,6 +19,7 @@
#define PREF_MSG_ISCHECKED_GENERALPAGE (WM_USER + 1) // wParam:checkbox/radiobutton ID in General page. lParam is type of "bool *" to get result #define PREF_MSG_ISCHECKED_GENERALPAGE (WM_USER + 1) // wParam:checkbox/radiobutton ID in General page. lParam is type of "bool *" to get result
#define PREF_MSG_SETTOOLICONSFROMSTDTOSMALL (WM_USER + 2) #define PREF_MSG_SETTOOLICONSFROMSTDTOSMALL (WM_USER + 2)
#define PREF_MSG_DISABLETABBARALTERNATEICONS (WM_USER + 3)
#define IDD_PREFERENCE_BOX 6000 #define IDD_PREFERENCE_BOX 6000
#define IDC_BUTTON_CLOSE (IDD_PREFERENCE_BOX + 1) #define IDC_BUTTON_CLOSE (IDD_PREFERENCE_BOX + 1)