diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index 6a03438df..ce2ed20ba 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -15,21 +15,6 @@ namespace NppDarkMode { - struct Colors - { - COLORREF background = 0; - COLORREF softerBackground = 0; - COLORREF hotBackground = 0; - COLORREF pureBackground = 0; - COLORREF errorBackground = 0; - - COLORREF text = 0; - COLORREF darkerText = 0; - COLORREF disabledText = 0; - COLORREF edge = 0; - COLORREF highlightHotTrack = 0; - }; - struct Brushes { HBRUSH background = nullptr; @@ -54,6 +39,21 @@ namespace NppDarkMode ::DeleteObject(pureBackground); pureBackground = nullptr; ::DeleteObject(errorBackground); errorBackground = nullptr; } + + void change(const Colors& colors) + { + ::DeleteObject(background); + ::DeleteObject(softerBackground); + ::DeleteObject(hotBackground); + ::DeleteObject(pureBackground); + ::DeleteObject(errorBackground); + + background = ::CreateSolidBrush(colors.background); + softerBackground = ::CreateSolidBrush(colors.softerBackground); + hotBackground = ::CreateSolidBrush(colors.hotBackground); + pureBackground = ::CreateSolidBrush(colors.pureBackground); + errorBackground = ::CreateSolidBrush(colors.errorBackground); + } }; // black (default) @@ -66,8 +66,7 @@ namespace NppDarkMode HEXRGB(0xE0E0E0), // textColor HEXRGB(0xC0C0C0), // darkerTextColor HEXRGB(0x808080), // disabledTextColor - HEXRGB(0x808080), // edgeColor - HEXRGB(0x414141) // highlightHotTrack + HEXRGB(0x808080) // edgeColor }; // red tone @@ -80,8 +79,7 @@ namespace NppDarkMode HEXRGB(0xE0E0E0), // textColor HEXRGB(0xC0C0C0), // darkerTextColor HEXRGB(0x808080), // disabledTextColor - HEXRGB(0x908080), // edgeColor - HEXRGB(0x514141) // highlightHotTrack + HEXRGB(0x908080) // edgeColor }; // green tone @@ -94,8 +92,7 @@ namespace NppDarkMode HEXRGB(0xE0E0E0), // textColor HEXRGB(0xC0C0C0), // darkerTextColor HEXRGB(0x808080), // disabledTextColor - HEXRGB(0x809080), // edgeColor - HEXRGB(0x415141) // highlightHotTrack + HEXRGB(0x809080) // edgeColor }; @@ -109,8 +106,7 @@ namespace NppDarkMode HEXRGB(0xE0E0E0), // textColor HEXRGB(0xC0C0C0), // darkerTextColor HEXRGB(0x808080), // disabledTextColor - HEXRGB(0x8080A0), // edgeColor - HEXRGB(0x414161) // highlightHotTrack + HEXRGB(0x8080A0) // edgeColor }; // purple tone @@ -123,8 +119,7 @@ namespace NppDarkMode HEXRGB(0xE0E0E0), // textColor HEXRGB(0xC0C0C0), // darkerTextColor HEXRGB(0x808080), // disabledTextColor - HEXRGB(0x9080A0), // edgeColor - HEXRGB(0x514161) // highlightHotTrack + HEXRGB(0x9080A0) // edgeColor }; // cyan tone @@ -137,8 +132,7 @@ namespace NppDarkMode HEXRGB(0xE0E0E0), // textColor HEXRGB(0xC0C0C0), // darkerTextColor HEXRGB(0x808080), // disabledTextColor - HEXRGB(0x8090A0), // edgeColor - HEXRGB(0x415161) // highlightHotTrack + HEXRGB(0x8090A0) // edgeColor }; // olive tone @@ -151,8 +145,20 @@ namespace NppDarkMode HEXRGB(0xE0E0E0), // textColor HEXRGB(0xC0C0C0), // darkerTextColor HEXRGB(0x808080), // disabledTextColor - HEXRGB(0x909080), // edgeColor - HEXRGB(0x515141) // highlightHotTrack + HEXRGB(0x909080) // edgeColor + }; + + // customized + Colors darkCustomizedColors{ + HEXRGB(0x202020), // background + HEXRGB(0x404040), // softerBackground + HEXRGB(0x404040), // hotBackground + HEXRGB(0x202020), // pureBackground + HEXRGB(0xB00000), // errorBackground + HEXRGB(0xE0E0E0), // textColor + HEXRGB(0xC0C0C0), // darkerTextColor + HEXRGB(0x808080), // disabledTextColor + HEXRGB(0x808080) // edgeColor }; ColorTone g_colorToneChoice = blackTone; @@ -164,22 +170,30 @@ namespace NppDarkMode struct Theme { - Colors colors; - Brushes brushes; + Colors _colors; + Brushes _brushes; Theme(const Colors& colors) - : colors(colors) - , brushes(colors) + : _colors(colors) + , _brushes(colors) {} + + void change(const Colors& colors) + { + _colors = colors; + _brushes.change(colors); + } }; - Theme t0(darkColors); - Theme t1(darkRedColors); - Theme t2(darkGreenColors); - Theme t3(darkBlueColors); - Theme t4(darkPurpleColors); - Theme t5(darkCyanColors); - Theme t6(darkOliveColors); + Theme tDefault(darkColors); + Theme tR(darkRedColors); + Theme tG(darkGreenColors); + Theme tB(darkBlueColors); + Theme tP(darkPurpleColors); + Theme tC(darkCyanColors); + Theme tO(darkOliveColors); + + Theme tCustom(darkCustomizedColors); Theme& getTheme() @@ -187,25 +201,28 @@ namespace NppDarkMode switch (g_colorToneChoice) { case redTone: - return t1; + return tR; case greenTone: - return t2; + return tG; case blueTone: - return t3; + return tB; case purpleTone: - return t4; + return tP; case cyanTone: - return t5; + return tC; case oliveTone: - return t6; + return tO; + + case customizedTone: + return tCustom; default: - return t0; + return tDefault; } } @@ -219,6 +236,7 @@ namespace NppDarkMode opt.enableMenubar = opt.enable; g_colorToneChoice = nppGui._darkmode._colorTone; + tCustom.change(nppGui._darkmode._customColors); return opt; } @@ -311,22 +329,94 @@ namespace NppDarkMode return invert_c; } - COLORREF getBackgroundColor() { return getTheme().colors.background; } - COLORREF getSofterBackgroundColor() { return getTheme().colors.softerBackground; } - COLORREF getHotBackgroundColor() { return getTheme().colors.hotBackground; } - COLORREF getDarkerBackgroundColor() { return getTheme().colors.pureBackground; } - COLORREF getErrorBackgroundColor() { return getTheme().colors.errorBackground; } - COLORREF getTextColor() { return getTheme().colors.text; } - COLORREF getDarkerTextColor() { return getTheme().colors.darkerText; } - COLORREF getDisabledTextColor() { return getTheme().colors.disabledText; } - COLORREF getEdgeColor() { return getTheme().colors.edge; } - COLORREF getHighlightHotTrackColor() { return getTheme().colors.highlightHotTrack; } + COLORREF getBackgroundColor() { return getTheme()._colors.background; } + COLORREF getSofterBackgroundColor() { return getTheme()._colors.softerBackground; } + COLORREF getHotBackgroundColor() { return getTheme()._colors.hotBackground; } + COLORREF getDarkerBackgroundColor() { return getTheme()._colors.pureBackground; } + COLORREF getErrorBackgroundColor() { return getTheme()._colors.errorBackground; } + COLORREF getTextColor() { return getTheme()._colors.text; } + COLORREF getDarkerTextColor() { return getTheme()._colors.darkerText; } + COLORREF getDisabledTextColor() { return getTheme()._colors.disabledText; } + COLORREF getEdgeColor() { return getTheme()._colors.edge; } - HBRUSH getBackgroundBrush() { return getTheme().brushes.background; } - HBRUSH getSofterBackgroundBrush() { return getTheme().brushes.softerBackground; } - HBRUSH getHotBackgroundBrush() { return getTheme().brushes.hotBackground; } - HBRUSH getDarkerBackgroundBrush() { return getTheme().brushes.pureBackground; } - HBRUSH getErrorBackgroundBrush() { return getTheme().brushes.errorBackground; } + HBRUSH getBackgroundBrush() { return getTheme()._brushes.background; } + HBRUSH getSofterBackgroundBrush() { return getTheme()._brushes.softerBackground; } + HBRUSH getHotBackgroundBrush() { return getTheme()._brushes.hotBackground; } + HBRUSH getDarkerBackgroundBrush() { return getTheme()._brushes.pureBackground; } + HBRUSH getErrorBackgroundBrush() { return getTheme()._brushes.errorBackground; } + + void setBackgroundColor(COLORREF c) + { + Colors clrs = getTheme()._colors; + clrs.background = c; + getTheme().change(clrs); + } + + void setSofterBackgroundColor(COLORREF c) + { + Colors clrs = getTheme()._colors; + clrs.softerBackground = c; + getTheme().change(clrs); + } + + void setHotBackgroundColor(COLORREF c) + { + Colors clrs = getTheme()._colors; + clrs.hotBackground = c; + getTheme().change(clrs); + } + + void setDarkerBackgroundColor(COLORREF c) + { + Colors clrs = getTheme()._colors; + clrs.pureBackground = c; + getTheme().change(clrs); + } + + void setErrorBackgroundColor(COLORREF c) + { + Colors clrs = getTheme()._colors; + clrs.errorBackground = c; + getTheme().change(clrs); + } + + void setTextColor(COLORREF c) + { + Colors clrs = getTheme()._colors; + clrs.text = c; + getTheme().change(clrs); + } + + void setDarkerTextColor(COLORREF c) + { + Colors clrs = getTheme()._colors; + clrs.darkerText = c; + getTheme().change(clrs); + } + + void setDisabledTextColor(COLORREF c) + { + Colors clrs = getTheme()._colors; + clrs.disabledText = c; + getTheme().change(clrs); + } + + void setEdgeColor(COLORREF c) + { + Colors clrs = getTheme()._colors; + clrs.edge = c; + getTheme().change(clrs); + } + + Colors getDarkModeDefaultColors() + { + return darkColors; + } + + void changeCustomTheme(const Colors& colors) + { + tCustom.change(colors); + } // handle events diff --git a/PowerEditor/src/NppDarkMode.h b/PowerEditor/src/NppDarkMode.h index 8d22b2620..6505efe44 100644 --- a/PowerEditor/src/NppDarkMode.h +++ b/PowerEditor/src/NppDarkMode.h @@ -13,6 +13,19 @@ constexpr COLORREF HEXRGB(DWORD rrggbb) { namespace NppDarkMode { + struct Colors + { + COLORREF background = 0; + COLORREF softerBackground = 0; + COLORREF hotBackground = 0; + COLORREF pureBackground = 0; + COLORREF errorBackground = 0; + COLORREF text = 0; + COLORREF darkerText = 0; + COLORREF disabledText = 0; + COLORREF edge = 0; + }; + struct Options { bool enable = false; @@ -35,7 +48,8 @@ namespace NppDarkMode blueTone = 3, purpleTone = 4, cyanTone = 5, - oliveTone = 6 + oliveTone = 6, + customizedTone = 32 }; void initDarkMode(); // pulls options from NppParameters @@ -60,7 +74,6 @@ namespace NppDarkMode COLORREF getDarkerTextColor(); COLORREF getDisabledTextColor(); COLORREF getEdgeColor(); - COLORREF getHighlightHotTrackColor(); HBRUSH getBackgroundBrush(); HBRUSH getDarkerBackgroundBrush(); @@ -68,6 +81,19 @@ namespace NppDarkMode HBRUSH getHotBackgroundBrush(); HBRUSH getErrorBackgroundBrush(); + void setBackgroundColor(COLORREF c); + void setSofterBackgroundColor(COLORREF c); + void setHotBackgroundColor(COLORREF c); + void setDarkerBackgroundColor(COLORREF c); + void setErrorBackgroundColor(COLORREF c); + void setTextColor(COLORREF c); + void setDarkerTextColor(COLORREF c); + void setDisabledTextColor(COLORREF c); + void setEdgeColor(COLORREF c); + + Colors getDarkModeDefaultColors(); + void changeCustomTheme(const Colors& colors); + // handle events void handleSettingChange(HWND hwnd, LPARAM lParam); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index ebd8f59b7..a8657ace3 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5390,9 +5390,47 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) _nppGUI._darkmode._isEnabled = parseYesNoBoolAttribute(TEXT("enable")); int i; - const TCHAR* val = element->Attribute(TEXT("colorTone"), &i); + const TCHAR* val; + val = element->Attribute(TEXT("colorTone"), &i); if (val) _nppGUI._darkmode._colorTone = static_cast(i); + + + val = element->Attribute(TEXT("customColorTop"), &i); + if (val) + _nppGUI._darkmode._customColors.pureBackground = i; + + val = element->Attribute(TEXT("customColorMenuHotTrack"), &i); + if (val) + _nppGUI._darkmode._customColors.hotBackground = i; + + val = element->Attribute(TEXT("customColorActive"), &i); + if (val) + _nppGUI._darkmode._customColors.softerBackground = i; + + val = element->Attribute(TEXT("customColorMain"), &i); + if (val) + _nppGUI._darkmode._customColors.background = i; + + val = element->Attribute(TEXT("customColorError"), &i); + if (val) + _nppGUI._darkmode._customColors.errorBackground = i; + + val = element->Attribute(TEXT("customColorText"), &i); + if (val) + _nppGUI._darkmode._customColors.text = i; + + val = element->Attribute(TEXT("customColorDarkText"), &i); + if (val) + _nppGUI._darkmode._customColors.darkerText = i; + + val = element->Attribute(TEXT("customColorDisabledText"), &i); + if (val) + _nppGUI._darkmode._customColors.disabledText = i; + + val = element->Attribute(TEXT("customColorEdge"), &i); + if (val) + _nppGUI._darkmode._customColors.edge = i; } } } @@ -6417,6 +6455,16 @@ void NppParameters::createXmlTreeFromGUIParams() setYesNoBoolAttribute(TEXT("enable"), _nppGUI._darkmode._isEnabled); GUIConfigElement->SetAttribute(TEXT("colorTone"), _nppGUI._darkmode._colorTone); + + GUIConfigElement->SetAttribute(TEXT("customColorTop"), _nppGUI._darkmode._customColors.pureBackground); + GUIConfigElement->SetAttribute(TEXT("customColorMenuHotTrack"), _nppGUI._darkmode._customColors.hotBackground); + GUIConfigElement->SetAttribute(TEXT("customColorActive"), _nppGUI._darkmode._customColors.softerBackground); + GUIConfigElement->SetAttribute(TEXT("customColorMain"), _nppGUI._darkmode._customColors.background); + GUIConfigElement->SetAttribute(TEXT("customColorError"), _nppGUI._darkmode._customColors.errorBackground); + 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); } // diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 2896b1f7a..4d909f35f 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -781,6 +781,7 @@ struct DarkModeConf final { bool _isEnabled = false; NppDarkMode::ColorTone _colorTone = NppDarkMode::blackTone; + NppDarkMode::Colors _customColors = NppDarkMode::getDarkModeDefaultColors(); }; struct NppGUI final diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index 6c75ea1e2..a58108b56 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -89,8 +89,8 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l _hFontSizeStaticText = ::GetDlgItem(_hSelf, IDC_FONTSIZE_STATIC); _hStyleInfoStaticText = ::GetDlgItem(_hSelf, IDC_STYLEDESCRIPTION_STATIC); - colourHooker.setColour(RGB(0xFF, 0x00, 0x00)); - colourHooker.hookOn(_hStyleInfoStaticText); + _colourHooker.setColour(RGB(0xFF, 0x00, 0x00)); + _colourHooker.hookOn(_hStyleInfoStaticText); _currentThemeIndex = -1; int defaultThemeIndex = 0; @@ -137,8 +137,12 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l p1.x = p2.x = ((p1.x > p2.x)?p1.x:p2.x) + 10; p1.y -= 4; p2.y -= 4; - ::MoveWindow(reinterpret_cast(_pFgColour->getHSelf()), p1.x, p1.y, 25, 25, TRUE); - ::MoveWindow(reinterpret_cast(_pBgColour->getHSelf()), p2.x, p2.y, 25, 25, TRUE); + int cpDynamicalWidth = NppParameters::getInstance()._dpiManager.scaleX(25); + int cpDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(25); + + ::MoveWindow(reinterpret_cast(_pFgColour->getHSelf()), p1.x, p1.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + ::MoveWindow(reinterpret_cast(_pBgColour->getHSelf()), p2.x, p2.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + _pFgColour->display(); _pBgColour->display(); @@ -761,7 +765,7 @@ void WordStyleDlg::setVisualFromStyleList() // PAD for fix a display glitch wcscat_s(str, TEXT(" ")); - colourHooker.setColour(c); + _colourHooker.setColour(c); ::SetWindowText(_hStyleInfoStaticText, str); //-- 2 couleurs : fg et bg diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h index efa638416..ebd991af0 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h @@ -138,7 +138,7 @@ private : GlobalOverride _gOverride2restored; bool _restoreInvalid = false; - ColourStaticTextHooker colourHooker; + ColourStaticTextHooker _colourHooker; bool _isDirty = false; bool _isThemeDirty = false; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 6859154b0..68281a567 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -101,14 +101,24 @@ 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 - //LTEXT "* Notepad++ must be restarted to take effect completely",IDC_STATIC_DARKMODE_WARNING,20,35,310,16 - CONTROL "Black tone",IDC_RADIO_DARKMODE_BLACK, "Button",BS_AUTORADIOBUTTON | WS_GROUP,35,40,150,10 - CONTROL "Red tone",IDC_RADIO_DARKMODE_RED, "Button",BS_AUTORADIOBUTTON ,35,55,150,10 - CONTROL "Green tone",IDC_RADIO_DARKMODE_GREEN, "Button",BS_AUTORADIOBUTTON ,35,70,150,10 - CONTROL "Blue tone",IDC_RADIO_DARKMODE_BLUE, "Button",BS_AUTORADIOBUTTON ,35,85,150,10 - CONTROL "Purple tone",IDC_RADIO_DARKMODE_PURPLE, "Button",BS_AUTORADIOBUTTON ,35,100,150,10 - CONTROL "Cyan tone",IDC_RADIO_DARKMODE_CYAN, "Button",BS_AUTORADIOBUTTON ,35,115,150,10 - CONTROL "Olive tone",IDC_RADIO_DARKMODE_OLIVE, "Button",BS_AUTORADIOBUTTON ,35,130,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,140,40,120,10 + LTEXT "Top", IDD_CUSTOMIZED_COLOR1_STATIC,170,60,100,8 + LTEXT "Menu hot track", IDD_CUSTOMIZED_COLOR2_STATIC,170,80,100,8 + LTEXT "Active", IDD_CUSTOMIZED_COLOR3_STATIC,170,100,100,8 + LTEXT "Main", IDD_CUSTOMIZED_COLOR4_STATIC,170,120,100,8 + LTEXT "Error", IDD_CUSTOMIZED_COLOR5_STATIC,170,140,100,8 + LTEXT "Text", IDD_CUSTOMIZED_COLOR6_STATIC,295,60,100,8 + LTEXT "Darker text", IDD_CUSTOMIZED_COLOR7_STATIC,295,80,100,8 + LTEXT "Disable text", IDD_CUSTOMIZED_COLOR8_STATIC,295,100,100,8 + LTEXT "Edge", IDD_CUSTOMIZED_COLOR9_STATIC,295,120,100,8 + PUSHBUTTON "Reset",IDD_CUSTOMIZED_RESET_BUTTON,270,140,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 592f5ed3a..747a45f9c 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -805,6 +805,46 @@ INT_PTR CALLBACK EditingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM } +void DarkModeSubDlg::enableCustomizedColorCtrls(bool doEnable) +{ + ::EnableWindow(_pBackgroundColorPicker->getHSelf(), doEnable); + ::EnableWindow(_pSofterBackgroundColorPicker->getHSelf(), doEnable); + ::EnableWindow(_pHotBackgroundColorPicker->getHSelf(), doEnable); + ::EnableWindow(_pPureBackgroundColorPicker->getHSelf(), doEnable); + ::EnableWindow(_pErrorBackgroundColorPicker->getHSelf(), doEnable); + ::EnableWindow(_pTextColorPicker->getHSelf(), doEnable); + ::EnableWindow(_pDarkerTextColorPicker->getHSelf(), doEnable); + ::EnableWindow(_pDisabledTextColorPicker->getHSelf(), doEnable); + ::EnableWindow(_pEdgeColorPicker->getHSelf(), doEnable); + + ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR1_STATIC), doEnable); + ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR2_STATIC), doEnable); + ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR3_STATIC), doEnable); + ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR4_STATIC), doEnable); + ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR5_STATIC), doEnable); + ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR6_STATIC), doEnable); + ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR7_STATIC), doEnable); + ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR8_STATIC), doEnable); + ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR9_STATIC), doEnable); + + ::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_RESET_BUTTON), doEnable); + + if (doEnable) + { + _pBackgroundColorPicker->setColour(NppDarkMode::getBackgroundColor()); + _pSofterBackgroundColorPicker->setColour(NppDarkMode::getSofterBackgroundColor()); + _pHotBackgroundColorPicker->setColour(NppDarkMode::getHotBackgroundColor()); + _pPureBackgroundColorPicker->setColour(NppDarkMode::getDarkerBackgroundColor()); + _pErrorBackgroundColorPicker->setColour(NppDarkMode::getErrorBackgroundColor()); + _pTextColorPicker->setColour(NppDarkMode::getTextColor()); + _pDarkerTextColorPicker->setColour(NppDarkMode::getDarkerTextColor()); + _pDisabledTextColorPicker->setColour(NppDarkMode::getDisabledTextColor()); + _pEdgeColorPicker->setColour(NppDarkMode::getEdgeColor()); + + redraw(); + } +} + INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); @@ -838,9 +878,77 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM case NppDarkMode::oliveTone: id = IDC_RADIO_DARKMODE_OLIVE; break; + case NppDarkMode::customizedTone: + id = IDC_RADIO_DARKMODE_CUSTOMIZED; + break; } ::SendDlgItemMessage(_hSelf, id, BM_SETCHECK, TRUE, 0); + _pBackgroundColorPicker = new ColourPicker; + _pSofterBackgroundColorPicker = new ColourPicker; + _pHotBackgroundColorPicker = new ColourPicker; + _pPureBackgroundColorPicker = new ColourPicker; + _pErrorBackgroundColorPicker = new ColourPicker; + _pTextColorPicker = new ColourPicker; + _pDarkerTextColorPicker = new ColourPicker; + _pDisabledTextColorPicker = new ColourPicker; + _pEdgeColorPicker = new ColourPicker; + + _pBackgroundColorPicker->init(_hInst, _hSelf); + _pSofterBackgroundColorPicker->init(_hInst, _hSelf); + _pHotBackgroundColorPicker->init(_hInst, _hSelf); + _pPureBackgroundColorPicker->init(_hInst, _hSelf); + + _pErrorBackgroundColorPicker->init(_hInst, _hSelf); + _pTextColorPicker->init(_hInst, _hSelf); + _pDarkerTextColorPicker->init(_hInst, _hSelf); + _pDisabledTextColorPicker->init(_hInst, _hSelf); + _pEdgeColorPicker->init(_hInst, _hSelf); + + POINT p1, p2, p3, p4, p5, p6, p7, p8, p9; + alignWith(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR1_STATIC), _pPureBackgroundColorPicker->getHSelf(), PosAlign::left, p1); + alignWith(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR2_STATIC), _pHotBackgroundColorPicker->getHSelf(), PosAlign::left, p2); + alignWith(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR3_STATIC), _pSofterBackgroundColorPicker->getHSelf(), PosAlign::left, p3); + alignWith(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR4_STATIC), _pBackgroundColorPicker->getHSelf(), PosAlign::left, p4); + alignWith(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR5_STATIC), _pErrorBackgroundColorPicker->getHSelf(), PosAlign::left, p5); + alignWith(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR6_STATIC), _pTextColorPicker->getHSelf(), PosAlign::left, p6); + alignWith(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR7_STATIC), _pDarkerTextColorPicker->getHSelf(), PosAlign::left, p7); + alignWith(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR8_STATIC), _pDisabledTextColorPicker->getHSelf(), PosAlign::left, p8); + alignWith(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR9_STATIC), _pEdgeColorPicker->getHSelf(), PosAlign::left, p9); + + int cpDynamicalWidth = NppParameters::getInstance()._dpiManager.scaleX(25); + int cpDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(25); + + p1.x -= cpDynamicalWidth + 5; p1.y -= cpDynamicalHeight / 6; + p2.x -= cpDynamicalWidth + 5; p2.y -= cpDynamicalHeight / 6; + p3.x -= cpDynamicalWidth + 5; p3.y -= cpDynamicalHeight / 6; + p4.x -= cpDynamicalWidth + 5; p4.y -= cpDynamicalHeight / 6; + p5.x -= cpDynamicalWidth + 5; p5.y -= cpDynamicalHeight / 6; + p6.x -= cpDynamicalWidth + 5; p6.y -= cpDynamicalHeight / 6; + p7.x -= cpDynamicalWidth + 5; p7.y -= cpDynamicalHeight / 6; + p8.x -= cpDynamicalWidth + 5; p8.y -= cpDynamicalHeight / 6; + p9.x -= cpDynamicalWidth + 5; p9.y -= cpDynamicalHeight / 6; + + ::MoveWindow(reinterpret_cast(_pPureBackgroundColorPicker->getHSelf()), p1.x, p1.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + ::MoveWindow(reinterpret_cast(_pHotBackgroundColorPicker->getHSelf()), p2.x, p2.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + ::MoveWindow(reinterpret_cast(_pSofterBackgroundColorPicker->getHSelf()), p3.x, p3.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + ::MoveWindow(reinterpret_cast(_pBackgroundColorPicker->getHSelf()), p4.x, p4.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + ::MoveWindow(reinterpret_cast(_pErrorBackgroundColorPicker->getHSelf()), p5.x, p5.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + ::MoveWindow(reinterpret_cast(_pTextColorPicker->getHSelf()), p6.x, p6.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + ::MoveWindow(reinterpret_cast(_pDarkerTextColorPicker->getHSelf()), p7.x, p7.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + ::MoveWindow(reinterpret_cast(_pDisabledTextColorPicker->getHSelf()), p8.x, p8.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + ::MoveWindow(reinterpret_cast(_pEdgeColorPicker->getHSelf()), p9.x, p9.y, cpDynamicalWidth, cpDynamicalHeight, TRUE); + + _pBackgroundColorPicker->display(); + _pSofterBackgroundColorPicker->display(); + _pHotBackgroundColorPicker->display(); + _pPureBackgroundColorPicker->display(); + _pErrorBackgroundColorPicker->display(); + _pTextColorPicker->display(); + _pDarkerTextColorPicker->display(); + _pDisabledTextColorPicker->display(); + _pEdgeColorPicker->display(); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_BLACK), nppGUI._darkmode._isEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_RED), nppGUI._darkmode._isEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_GREEN), nppGUI._darkmode._isEnabled); @@ -848,17 +956,44 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_PURPLE), nppGUI._darkmode._isEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_CYAN), nppGUI._darkmode._isEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_OLIVE), nppGUI._darkmode._isEnabled); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_CUSTOMIZED), nppGUI._darkmode._isEnabled); + enableCustomizedColorCtrls(nppGUI._darkmode._isEnabled && id == IDC_RADIO_DARKMODE_CUSTOMIZED); + ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); if (enableDlgTheme) enableDlgTheme(_hSelf, ETDT_ENABLETAB); return TRUE; } + case WM_DESTROY: + { + _pBackgroundColorPicker->destroy(); + _pSofterBackgroundColorPicker->destroy(); + _pHotBackgroundColorPicker->destroy(); + _pPureBackgroundColorPicker->destroy(); + _pErrorBackgroundColorPicker->destroy(); + _pTextColorPicker->destroy(); + _pDarkerTextColorPicker->destroy(); + _pDisabledTextColorPicker->destroy(); + _pEdgeColorPicker->destroy(); + + delete _pBackgroundColorPicker; + delete _pSofterBackgroundColorPicker; + delete _pHotBackgroundColorPicker; + delete _pPureBackgroundColorPicker; + delete _pErrorBackgroundColorPicker; + delete _pTextColorPicker; + delete _pDarkerTextColorPicker; + delete _pDisabledTextColorPicker; + delete _pEdgeColorPicker; + } + case WM_COMMAND: { bool changed = false; bool forceRefresh = false; + bool doEnableCustomizedColorCtrls = false; switch (wParam) { case IDC_CHECK_DARKMODE_ENABLE: @@ -873,6 +1008,9 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_PURPLE), enableDarkMode); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_CYAN), enableDarkMode); ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_OLIVE), enableDarkMode); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_CUSTOMIZED), enableDarkMode); + + enableCustomizedColorCtrls(enableDarkMode&& nppGUI._darkmode._colorTone == NppDarkMode::customizedTone); // Maintain the coherence in preferences if (nppGUI._darkmode._isEnabled) @@ -898,6 +1036,8 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM case IDC_RADIO_DARKMODE_PURPLE: case IDC_RADIO_DARKMODE_CYAN: case IDC_RADIO_DARKMODE_OLIVE: + case IDC_RADIO_DARKMODE_CUSTOMIZED: + case IDD_CUSTOMIZED_RESET_BUTTON: if (wParam == IDC_RADIO_DARKMODE_BLACK) { if (nppGUI._darkmode._colorTone == NppDarkMode::blackTone) @@ -940,13 +1080,108 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM return TRUE; nppGUI._darkmode._colorTone = NppDarkMode::oliveTone; } + else if (wParam == IDC_RADIO_DARKMODE_CUSTOMIZED) + { + if (nppGUI._darkmode._colorTone == NppDarkMode::customizedTone) + return TRUE; + nppGUI._darkmode._colorTone = NppDarkMode::customizedTone; + doEnableCustomizedColorCtrls = true; + } + + else if (wParam == IDD_CUSTOMIZED_RESET_BUTTON) + { + nppGUI._darkmode._customColors = NppDarkMode::getDarkModeDefaultColors(); + NppDarkMode::changeCustomTheme(nppGUI._darkmode._customColors); + doEnableCustomizedColorCtrls = true; + } + // switch to chosen dark mode nppGUI._darkmode._isEnabled = true; NppDarkMode::setDarkTone(nppGUI._darkmode._colorTone); changed = true; forceRefresh = true; + + enableCustomizedColorCtrls(doEnableCustomizedColorCtrls); break; + + default: + switch (HIWORD(wParam)) + { + case CPN_COLOURPICKED: + { + COLORREF c; + if (reinterpret_cast(lParam) == _pBackgroundColorPicker->getHSelf()) + { + c = _pBackgroundColorPicker->getColour(); + NppDarkMode::setBackgroundColor(c); + nppGUI._darkmode._customColors.background = c; + } + else if (reinterpret_cast(lParam) == _pSofterBackgroundColorPicker->getHSelf()) + { + c = _pSofterBackgroundColorPicker->getColour(); + NppDarkMode::setSofterBackgroundColor(c); + nppGUI._darkmode._customColors.softerBackground = c; + } + else if (reinterpret_cast(lParam) == _pHotBackgroundColorPicker->getHSelf()) + { + c = _pHotBackgroundColorPicker->getColour(); + NppDarkMode::setHotBackgroundColor(c); + nppGUI._darkmode._customColors.hotBackground = c; + } + else if (reinterpret_cast(lParam) == _pPureBackgroundColorPicker->getHSelf()) + { + c = _pPureBackgroundColorPicker->getColour(); + NppDarkMode::setDarkerBackgroundColor(c); + nppGUI._darkmode._customColors.pureBackground = c; + } + else if (reinterpret_cast(lParam) == _pErrorBackgroundColorPicker->getHSelf()) + { + c = _pErrorBackgroundColorPicker->getColour(); + NppDarkMode::setErrorBackgroundColor(c); + nppGUI._darkmode._customColors.errorBackground = c; + } + else if (reinterpret_cast(lParam) == _pTextColorPicker->getHSelf()) + { + c = _pTextColorPicker->getColour(); + NppDarkMode::setTextColor(c); + nppGUI._darkmode._customColors.text = c; + } + else if (reinterpret_cast(lParam) == _pDarkerTextColorPicker->getHSelf()) + { + c = _pDarkerTextColorPicker->getColour(); + NppDarkMode::setDarkerTextColor(c); + nppGUI._darkmode._customColors.darkerText = c; + } + else if (reinterpret_cast(lParam) == _pDisabledTextColorPicker->getHSelf()) + { + c = _pDisabledTextColorPicker->getColour(); + NppDarkMode::setDisabledTextColor(c); + nppGUI._darkmode._customColors.disabledText = c; + } + else if (reinterpret_cast(lParam) == _pEdgeColorPicker->getHSelf()) + { + c = _pEdgeColorPicker->getColour(); + NppDarkMode::setEdgeColor(c); + nppGUI._darkmode._customColors.edge = c; + } + else + { + return FALSE; + } + + nppGUI._darkmode._isEnabled = true; + NppDarkMode::setDarkTone(nppGUI._darkmode._colorTone); + changed = true; + forceRefresh = true; + } + break; + + default: + { + return FALSE; + } + } } if (changed) diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 1910dab8a..939d28735 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -60,7 +60,18 @@ public: DarkModeSubDlg() = default; private: + ColourPicker* _pBackgroundColorPicker = nullptr; + ColourPicker* _pSofterBackgroundColorPicker = nullptr; + ColourPicker* _pHotBackgroundColorPicker = nullptr; + ColourPicker* _pPureBackgroundColorPicker = nullptr; + ColourPicker* _pErrorBackgroundColorPicker = nullptr; + ColourPicker* _pTextColorPicker = nullptr; + ColourPicker* _pDarkerTextColorPicker = nullptr; + ColourPicker* _pDisabledTextColorPicker = nullptr; + ColourPicker* _pEdgeColorPicker = nullptr; + INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); + void enableCustomizedColorCtrls(bool doEnable); }; class MarginsBorderEdgeSubDlg : public StaticDialog diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 780882e52..a166f2948 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -373,14 +373,24 @@ #define IDC_CHECK_REPLACEANDSTOP (IDD_PREFERENCE_SUB_SEARCHING + 5) #define IDD_PREFERENCE_SUB_DARKMODE 7100 //(IDD_PREFERENCE_BOX + 1100) - #define IDC_CHECK_DARKMODE_ENABLE (IDD_PREFERENCE_SUB_DARKMODE + 1) - #define IDC_RADIO_DARKMODE_BLACK (IDD_PREFERENCE_SUB_DARKMODE + 2) - #define IDC_RADIO_DARKMODE_RED (IDD_PREFERENCE_SUB_DARKMODE + 3) - #define IDC_RADIO_DARKMODE_GREEN (IDD_PREFERENCE_SUB_DARKMODE + 4) - #define IDC_RADIO_DARKMODE_BLUE (IDD_PREFERENCE_SUB_DARKMODE + 5) + #define IDC_CHECK_DARKMODE_ENABLE (IDD_PREFERENCE_SUB_DARKMODE + 1) + #define IDC_RADIO_DARKMODE_BLACK (IDD_PREFERENCE_SUB_DARKMODE + 2) + #define IDC_RADIO_DARKMODE_RED (IDD_PREFERENCE_SUB_DARKMODE + 3) + #define IDC_RADIO_DARKMODE_GREEN (IDD_PREFERENCE_SUB_DARKMODE + 4) + #define IDC_RADIO_DARKMODE_BLUE (IDD_PREFERENCE_SUB_DARKMODE + 5) //#define IDC_STATIC_DARKMODE_WARNING (IDD_PREFERENCE_SUB_DARKMODE + 6) - #define IDC_RADIO_DARKMODE_PURPLE (IDD_PREFERENCE_SUB_DARKMODE + 7) - #define IDC_RADIO_DARKMODE_CYAN (IDD_PREFERENCE_SUB_DARKMODE + 8) - #define IDC_RADIO_DARKMODE_OLIVE (IDD_PREFERENCE_SUB_DARKMODE + 9) - + #define IDC_RADIO_DARKMODE_PURPLE (IDD_PREFERENCE_SUB_DARKMODE + 7) + #define IDC_RADIO_DARKMODE_CYAN (IDD_PREFERENCE_SUB_DARKMODE + 8) + #define IDC_RADIO_DARKMODE_OLIVE (IDD_PREFERENCE_SUB_DARKMODE + 9) + #define IDC_RADIO_DARKMODE_CUSTOMIZED (IDD_PREFERENCE_SUB_DARKMODE + 15) + #define IDD_CUSTOMIZED_COLOR1_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 16) + #define IDD_CUSTOMIZED_COLOR2_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 17) + #define IDD_CUSTOMIZED_COLOR3_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 18) + #define IDD_CUSTOMIZED_COLOR4_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 19) + #define IDD_CUSTOMIZED_COLOR5_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 20) + #define IDD_CUSTOMIZED_COLOR6_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 21) + #define IDD_CUSTOMIZED_COLOR7_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 22) + #define IDD_CUSTOMIZED_COLOR8_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 23) + #define IDD_CUSTOMIZED_COLOR9_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 24) + #define IDD_CUSTOMIZED_RESET_BUTTON (IDD_PREFERENCE_SUB_DARKMODE + 30) #endif //PREFERENCE_RC_H diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp index 5652a4ec2..1fb927017 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.cpp @@ -808,9 +808,7 @@ void ProjectPanel::notified(LPNMHDR notification) case TVN_BEGINDRAG: { - //printStr(TEXT("hello")); _treeView.beginDrag((LPNMTREEVIEW)notification); - } break; } @@ -822,7 +820,7 @@ void ProjectPanel::notified(LPNMHDR notification) auto nmtbcd = reinterpret_cast(notification); FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush()); nmtbcd->clrText = NppDarkMode::getTextColor(); - nmtbcd->clrHighlightHotTrack = NppDarkMode::getHighlightHotTrackColor(); + nmtbcd->clrHighlightHotTrack = NppDarkMode::getHotBackgroundColor(); SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW | TBCDRF_HILITEHOTTRACK); } }