From ad8b1791b4c761bbdcd098260f25cf122535e768 Mon Sep 17 00:00:00 2001 From: ozone10 Date: Thu, 5 May 2022 16:17:48 +0200 Subject: [PATCH] Add edge highlight color in customized dark colors of Preferences dialog Fix #11642, close #11641 --- PowerEditor/installer/nativeLang/english.xml | 18 ++++---- PowerEditor/src/NppDarkMode.cpp | 7 ++++ PowerEditor/src/NppDarkMode.h | 1 + PowerEditor/src/Parameters.cpp | 13 ++++-- .../src/WinControls/Preference/preference.rc | 42 ++++++++++--------- .../WinControls/Preference/preferenceDlg.cpp | 30 ++++++++----- .../WinControls/Preference/preferenceDlg.h | 1 + .../WinControls/Preference/preference_rc.h | 2 + 8 files changed, 71 insertions(+), 43 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index ee0ea97aa..8290ffd0a 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -893,14 +893,14 @@ The comments are here for explanation, it's not necessary to translate them. - - - - - - - - + + + + + + + + @@ -911,7 +911,9 @@ The comments are here for explanation, it's not necessary to translate them. + + diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index 53b3a8ad2..be444e5e3 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -545,6 +545,13 @@ namespace NppDarkMode getTheme().change(clrs); } + void setHotEdgeColor(COLORREF c) + { + Colors clrs = getTheme()._colors; + clrs.hotEdge = c; + getTheme().change(clrs); + } + Colors getDarkModeDefaultColors() { return darkColors; diff --git a/PowerEditor/src/NppDarkMode.h b/PowerEditor/src/NppDarkMode.h index df6a26b2a..d30fad87f 100644 --- a/PowerEditor/src/NppDarkMode.h +++ b/PowerEditor/src/NppDarkMode.h @@ -129,6 +129,7 @@ namespace NppDarkMode void setDisabledTextColor(COLORREF c); void setLinkTextColor(COLORREF c); void setEdgeColor(COLORREF c); + void setHotEdgeColor(COLORREF c); Colors getDarkModeDefaultColors(); void changeCustomTheme(const Colors& colors); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 3c62693e5..1bbc99f9b 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5582,13 +5582,17 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) if (val) _nppGUI._darkmode._customColors.disabledText = i; + val = element->Attribute(TEXT("customColorLinkText"), &i); + if (val) + _nppGUI._darkmode._customColors.linkText = i; + val = element->Attribute(TEXT("customColorEdge"), &i); if (val) _nppGUI._darkmode._customColors.edge = i; - - val = element->Attribute(TEXT("customColorLinkText"), &i); + + val = element->Attribute(TEXT("customColorHotEdge"), &i); if (val) - _nppGUI._darkmode._customColors.linkText = i; + _nppGUI._darkmode._customColors.hotEdge = i; } } } @@ -6683,8 +6687,9 @@ void NppParameters::createXmlTreeFromGUIParams() GUIConfigElement->SetAttribute(TEXT("customColorText"), _nppGUI._darkmode._customColors.text); GUIConfigElement->SetAttribute(TEXT("customColorDarkText"), _nppGUI._darkmode._customColors.darkerText); GUIConfigElement->SetAttribute(TEXT("customColorDisabledText"), _nppGUI._darkmode._customColors.disabledText); - GUIConfigElement->SetAttribute(TEXT("customColorEdge"), _nppGUI._darkmode._customColors.edge); GUIConfigElement->SetAttribute(TEXT("customColorLinkText"), _nppGUI._darkmode._customColors.linkText); + GUIConfigElement->SetAttribute(TEXT("customColorEdge"), _nppGUI._darkmode._customColors.edge); + GUIConfigElement->SetAttribute(TEXT("customColorHotEdge"), _nppGUI._darkmode._customColors.hotEdge); } // diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 6dbc015ea..2d5c44a1d 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -110,26 +110,28 @@ IDD_PREFERENCE_SUB_DARKMODE DIALOGEX 0, 0, 455, 185 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - CONTROL "Enable &dark mode",IDC_CHECK_DARKMODE_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,20,150,10 - CONTROL "Black tone",IDC_RADIO_DARKMODE_BLACK, "Button",BS_AUTORADIOBUTTON | WS_GROUP,35,40,90,10 - CONTROL "Red tone",IDC_RADIO_DARKMODE_RED, "Button",BS_AUTORADIOBUTTON ,35,55,90,10 - CONTROL "Green tone",IDC_RADIO_DARKMODE_GREEN, "Button",BS_AUTORADIOBUTTON ,35,70,90,10 - CONTROL "Blue tone",IDC_RADIO_DARKMODE_BLUE, "Button",BS_AUTORADIOBUTTON ,35,85,90,10 - CONTROL "Purple tone",IDC_RADIO_DARKMODE_PURPLE, "Button",BS_AUTORADIOBUTTON ,35,100,90,10 - CONTROL "Cyan tone",IDC_RADIO_DARKMODE_CYAN, "Button",BS_AUTORADIOBUTTON ,35,115,90,10 - CONTROL "Olive tone",IDC_RADIO_DARKMODE_OLIVE, "Button",BS_AUTORADIOBUTTON ,35,130,90,10 - CONTROL "Customized tone",IDC_RADIO_DARKMODE_CUSTOMIZED, "Button",BS_AUTORADIOBUTTON,135,40,120,10 - LTEXT "Top", IDD_CUSTOMIZED_COLOR1_STATIC,165,60,100,8 - LTEXT "Menu hot track", IDD_CUSTOMIZED_COLOR2_STATIC,165,80,100,8 - LTEXT "Active", IDD_CUSTOMIZED_COLOR3_STATIC,165,100,100,8 - LTEXT "Main", IDD_CUSTOMIZED_COLOR4_STATIC,165,120,100,8 - LTEXT "Error", IDD_CUSTOMIZED_COLOR5_STATIC,165,140,100,8 - LTEXT "Text", IDD_CUSTOMIZED_COLOR6_STATIC,280,60,100,8 - LTEXT "Darker text", IDD_CUSTOMIZED_COLOR7_STATIC,280,80,100,8 - LTEXT "Disabled text", IDD_CUSTOMIZED_COLOR8_STATIC,280,100,100,8 - LTEXT "Edge", IDD_CUSTOMIZED_COLOR9_STATIC,280,120,100,8 - LTEXT "Link", IDD_CUSTOMIZED_COLOR10_STATIC,280,140,100,8 - PUSHBUTTON "Reset",IDD_CUSTOMIZED_RESET_BUTTON,360,140,45,14 + CONTROL "Enable &dark mode",IDC_CHECK_DARKMODE_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,12,150,10 + GROUPBOX "Tones",IDC_DARKMODE_TONES_GB_STATIC,10,25,440,154,BS_CENTER + CONTROL "Black",IDC_RADIO_DARKMODE_BLACK,"Button",BS_AUTORADIOBUTTON | WS_GROUP,15,35,80,10 + CONTROL "Red",IDC_RADIO_DARKMODE_RED,"Button",BS_AUTORADIOBUTTON ,15,50,80,10 + CONTROL "Green",IDC_RADIO_DARKMODE_GREEN,"Button",BS_AUTORADIOBUTTON ,15,65,80,10 + CONTROL "Blue",IDC_RADIO_DARKMODE_BLUE,"Button",BS_AUTORADIOBUTTON ,15,80,80,10 + CONTROL "Purple",IDC_RADIO_DARKMODE_PURPLE,"Button",BS_AUTORADIOBUTTON ,15,95,80,10 + CONTROL "Cyan",IDC_RADIO_DARKMODE_CYAN,"Button",BS_AUTORADIOBUTTON ,15,110,80,10 + CONTROL "Olive",IDC_RADIO_DARKMODE_OLIVE,"Button",BS_AUTORADIOBUTTON ,15,125,80,10 + CONTROL "Customized",IDC_RADIO_DARKMODE_CUSTOMIZED,"Button",BS_AUTORADIOBUTTON,100,35,120,10 + LTEXT "Top",IDD_CUSTOMIZED_COLOR1_STATIC,125,55,95,8 + LTEXT "Menu hot track",IDD_CUSTOMIZED_COLOR2_STATIC,125,75,95,8 + LTEXT "Active",IDD_CUSTOMIZED_COLOR3_STATIC,125,95,95,8 + LTEXT "Main",IDD_CUSTOMIZED_COLOR4_STATIC,125,115,95,8 + LTEXT "Error",IDD_CUSTOMIZED_COLOR5_STATIC,125,135,95,8 + LTEXT "Text",IDD_CUSTOMIZED_COLOR6_STATIC,240,55,95,8 + LTEXT "Darker text",IDD_CUSTOMIZED_COLOR7_STATIC,240,75,95,8 + LTEXT "Disabled text",IDD_CUSTOMIZED_COLOR8_STATIC,240,95,95,8 + LTEXT "Link",IDD_CUSTOMIZED_COLOR10_STATIC, 240,115,95,8 + LTEXT "Edge",IDD_CUSTOMIZED_COLOR9_STATIC,355,55,94,8 + LTEXT "Edge highlight",IDD_CUSTOMIZED_COLOR11_STATIC,355,75,94,8 + PUSHBUTTON "Reset",IDD_CUSTOMIZED_RESET_BUTTON,252,155,45,14 END IDD_PREFERENCE_SUB_MARGING_BORDER_EDGE DIALOGEX 0, 0, 455, 185 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index e43bd8642..437c9c384 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -951,6 +951,7 @@ void DarkModeSubDlg::enableCustomizedColorCtrls(bool doEnable) ::EnableWindow(_pDisabledTextColorPicker->getHSelf(), doEnable); ::EnableWindow(_pEdgeColorPicker->getHSelf(), doEnable); ::EnableWindow(_pLinkColorPicker->getHSelf(), doEnable); + ::EnableWindow(_pHotEdgeColorPicker->getHSelf(), doEnable); ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_RESET_BUTTON), doEnable); @@ -966,6 +967,7 @@ void DarkModeSubDlg::enableCustomizedColorCtrls(bool doEnable) _pDisabledTextColorPicker->setColour(NppDarkMode::getDisabledTextColor()); _pEdgeColorPicker->setColour(NppDarkMode::getEdgeColor()); _pLinkColorPicker->setColour(NppDarkMode::getLinkTextColor()); + _pHotEdgeColorPicker->setColour(NppDarkMode::getHotEdgeColor()); redraw(); } @@ -1039,6 +1041,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA _pDisabledTextColorPicker = new ColourPicker; _pEdgeColorPicker = new ColourPicker; _pLinkColorPicker = new ColourPicker; + _pHotEdgeColorPicker = new ColourPicker; _pBackgroundColorPicker->init(_hInst, _hSelf); _pSofterBackgroundColorPicker->init(_hInst, _hSelf); @@ -1051,6 +1054,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA _pDisabledTextColorPicker->init(_hInst, _hSelf); _pEdgeColorPicker->init(_hInst, _hSelf); _pLinkColorPicker->init(_hInst, _hSelf); + _pHotEdgeColorPicker->init(_hInst, _hSelf); int cpDynamicalWidth = NppParameters::getInstance()._dpiManager.scaleX(25); int cpDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(25); @@ -1065,6 +1069,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA move2CtrlLeft(IDD_CUSTOMIZED_COLOR8_STATIC, _pDisabledTextColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight); move2CtrlLeft(IDD_CUSTOMIZED_COLOR9_STATIC, _pEdgeColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight); move2CtrlLeft(IDD_CUSTOMIZED_COLOR10_STATIC, _pLinkColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight); + move2CtrlLeft(IDD_CUSTOMIZED_COLOR11_STATIC, _pHotEdgeColorPicker->getHSelf(), cpDynamicalWidth, cpDynamicalHeight); _pBackgroundColorPicker->display(); _pSofterBackgroundColorPicker->display(); @@ -1076,6 +1081,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA _pDisabledTextColorPicker->display(); _pEdgeColorPicker->display(); _pLinkColorPicker->display(); + _pHotEdgeColorPicker->display(); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_BLACK), nppGUI._darkmode._isEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_RED), nppGUI._darkmode._isEnabled); @@ -1093,11 +1099,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA case WM_CTLCOLORDLG: { - if (NppDarkMode::isEnabled()) - { - return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); - } - break; + return NppDarkMode::onCtlColorDarker(reinterpret_cast(wParam)); } case WM_CTLCOLORSTATIC: @@ -1114,7 +1116,8 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA dlgCtrlID == IDD_CUSTOMIZED_COLOR7_STATIC || dlgCtrlID == IDD_CUSTOMIZED_COLOR8_STATIC || dlgCtrlID == IDD_CUSTOMIZED_COLOR9_STATIC || - dlgCtrlID == IDD_CUSTOMIZED_COLOR10_STATIC); + dlgCtrlID == IDD_CUSTOMIZED_COLOR10_STATIC || + dlgCtrlID == IDD_CUSTOMIZED_COLOR11_STATIC); //set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text if (isStaticText) { @@ -1122,11 +1125,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled); } - if (NppDarkMode::isEnabled()) - { - return NppDarkMode::onCtlColorDarker(hdcStatic); - } - return FALSE; + return NppDarkMode::onCtlColorDarker(hdcStatic); } case WM_PRINTCLIENT: @@ -1150,6 +1149,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA _pDisabledTextColorPicker->destroy(); _pEdgeColorPicker->destroy(); _pLinkColorPicker->destroy(); + _pHotEdgeColorPicker->destroy(); delete _pBackgroundColorPicker; delete _pSofterBackgroundColorPicker; @@ -1161,6 +1161,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA delete _pDisabledTextColorPicker; delete _pEdgeColorPicker; delete _pLinkColorPicker; + delete _pHotEdgeColorPicker; } case WM_COMMAND: @@ -1346,6 +1347,12 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA NppDarkMode::setLinkTextColor(c); nppGUI._darkmode._customColors.linkText = c; } + else if (reinterpret_cast(lParam) == _pHotEdgeColorPicker->getHSelf()) + { + c = _pHotEdgeColorPicker->getColour(); + NppDarkMode::setHotEdgeColor(c); + nppGUI._darkmode._customColors.hotEdge = c; + } else { return FALSE; @@ -1382,6 +1389,7 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA _pDisabledTextColorPicker->setColour(disabledColor); _pEdgeColorPicker->setColour(disabledColor); _pLinkColorPicker->setColour(disabledColor); + _pHotEdgeColorPicker->setColour(disabledColor); redraw(); } diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 3327d7301..5a4c1d346 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -71,6 +71,7 @@ private: ColourPicker* _pDisabledTextColorPicker = nullptr; ColourPicker* _pEdgeColorPicker = nullptr; ColourPicker* _pLinkColorPicker = nullptr; + ColourPicker* _pHotEdgeColorPicker = nullptr; intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); void enableCustomizedColorCtrls(bool doEnable); diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 2f884482d..dbe9c12ea 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -416,5 +416,7 @@ #define IDD_CUSTOMIZED_COLOR8_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 23) #define IDD_CUSTOMIZED_COLOR9_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 24) #define IDD_CUSTOMIZED_COLOR10_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 25) + #define IDD_CUSTOMIZED_COLOR11_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 26) #define IDD_CUSTOMIZED_RESET_BUTTON (IDD_PREFERENCE_SUB_DARKMODE + 30) + #define IDC_DARKMODE_TONES_GB_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 35) #endif //PREFERENCE_RC_H