diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index d13c90a2b..508804daa 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2694,9 +2694,12 @@ void Notepad_plus::setupColorSampleBitmapsOnMainMenuItems() { IDM_SEARCH_GONEXTMARKER_DEF, SCE_UNIVERSAL_FOUND_STYLE, { IDM_SEARCH_GOPREVMARKER_DEF, IDM_SEARCH_MARKEDTOCLIP } } }; + NppParameters& nppParam = NppParameters::getInstance(); + StyleArray& styleArray = nppParam.getMiscStylerArray(); + for (size_t j = 0; j < sizeof(bitmapOnStyleMenuItemsInfo) / sizeof(bitmapOnStyleMenuItemsInfo[0]); ++j) { - const Style * pStyle = NppParameters::getInstance().getMiscStylerArray().findByID(bitmapOnStyleMenuItemsInfo[j].styleIndic); + const Style * pStyle = styleArray.findByID(bitmapOnStyleMenuItemsInfo[j].styleIndic); if (pStyle) { HBITMAP hNewBitmap = generateSolidColourMenuItemIcon(pStyle->_bgColor); @@ -2712,7 +2715,7 @@ void Notepad_plus::setupColorSampleBitmapsOnMainMenuItems() // Adds tab colour icons for (int i = 0; i < 5; ++i) { - COLORREF colour = NppDarkMode::getIndividualTabColour(i, NppDarkMode::isDarkMenuEnabled(), true); + COLORREF colour = nppParam.getIndividualTabColour(i, NppDarkMode::isDarkMenuEnabled(), true); HBITMAP hBitmap = generateSolidColourMenuItemIcon(colour); SetMenuItemBitmaps(_mainMenuHandle, IDM_VIEW_TAB_COLOUR_1 + i, MF_BYCOMMAND, hBitmap, hBitmap); } diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index b2f3402af..786d7e3a7 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -3424,47 +3424,4 @@ namespace NppDarkMode return static_cast(NppDarkMode::onCtlColor(hdc)); } - struct HLSColour - { - WORD _hue; - WORD _lightness; - WORD _saturation; - - COLORREF toRGB() const { return ColorHLSToRGB(_hue, _lightness, _saturation); } - }; - - using IndividualTabColours = std::array; - - static constexpr IndividualTabColours individualTabHuesFor_Dark { { HLSColour{37, 60, 60}, HLSColour{70, 60, 60}, HLSColour{144, 70, 60}, HLSColour{255, 60, 60}, HLSColour{195, 60, 60} } }; - static constexpr IndividualTabColours individualTabHues { { HLSColour{37, 210, 150}, HLSColour{70, 210, 150}, HLSColour{144, 210, 150}, HLSColour{255, 210, 150}, HLSColour{195, 210, 150}}}; - - - COLORREF getIndividualTabColour(int colourIndex, bool themeDependant, bool saturated) - { - if (colourIndex < 0 || colourIndex > 4) return {}; - - HLSColour result; - if (themeDependant) - { - result = individualTabHuesFor_Dark[colourIndex]; - - if (saturated) - { - result._lightness = 146U; - result._saturation = std::min(240U, result._saturation + 100U); - } - } - else - { - result = individualTabHues[colourIndex]; - - if (saturated) - { - result._lightness = 140U; - result._saturation = std::min(240U, result._saturation + 30U); - } - } - - return result.toRGB(); - } } diff --git a/PowerEditor/src/NppDarkMode.h b/PowerEditor/src/NppDarkMode.h index a5ddfed94..a2fd56608 100644 --- a/PowerEditor/src/NppDarkMode.h +++ b/PowerEditor/src/NppDarkMode.h @@ -158,8 +158,6 @@ namespace NppDarkMode HPEN getHotEdgePen(); HPEN getDisabledEdgePen(); - COLORREF getIndividualTabColour(int colourIndex, bool themeDependant, bool saturated); - void setBackgroundColor(COLORREF c); void setSofterBackgroundColor(COLORREF c); void setHotBackgroundColor(COLORREF c); diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 066a23c97..6a26c6cec 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -516,10 +516,11 @@ BOOL Notepad_plus::notify(SCNotification *notification) return TRUE; //break; + NppParameters& nppParam = NppParameters::getInstance(); + if (!_tabPopupMenu.isCreated()) { std::vector itemUnitArray; - NppParameters& nppParam = NppParameters::getInstance(); if (nppParam.hasCustomTabContextMenu()) { @@ -575,7 +576,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) // Adds colour icons for (int i = 0; i < 5; ++i) { - COLORREF colour = NppDarkMode::getIndividualTabColour(i, NppDarkMode::isDarkMenuEnabled(), true); + COLORREF colour = nppParam.getIndividualTabColour(i, NppDarkMode::isDarkMenuEnabled(), true); HBITMAP hBitmap = generateSolidColourMenuItemIcon(colour); SetMenuItemBitmaps(_tabPopupMenu.getMenuHandle(), IDM_VIEW_TAB_COLOUR_1 + i, MF_BYCOMMAND, hBitmap, hBitmap); } diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index c69aef04a..7af841aa0 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -8819,3 +8819,49 @@ EolType convertIntToFormatType(int value, EolType defvalue) return defvalue; } } + +#include + +struct HLSColour +{ + WORD _hue; + WORD _lightness; + WORD _saturation; + + COLORREF toRGB() const { return ColorHLSToRGB(_hue, _lightness, _saturation); } +}; + +using IndividualTabColours = std::array; + +static constexpr IndividualTabColours individualTabHuesFor_Dark{ { HLSColour{37, 60, 60}, HLSColour{70, 60, 60}, HLSColour{144, 70, 60}, HLSColour{255, 60, 60}, HLSColour{195, 60, 60} } }; +static constexpr IndividualTabColours individualTabHues{ { HLSColour{37, 210, 150}, HLSColour{70, 210, 150}, HLSColour{144, 210, 150}, HLSColour{255, 210, 150}, HLSColour{195, 210, 150}} }; + + +COLORREF NppParameters::getIndividualTabColour(int colourIndex, bool themeDependant, bool saturated) +{ + if (colourIndex < 0 || colourIndex > 4) return {}; + + HLSColour result; + if (themeDependant) + { + result = individualTabHuesFor_Dark[colourIndex]; + + if (saturated) + { + result._lightness = 146U; + result._saturation = std::min(240U, result._saturation + 100U); + } + } + else + { + result = individualTabHues[colourIndex]; + + if (saturated) + { + result._lightness = 140U; + result._saturation = std::min(240U, result._saturation + 30U); + } + } + + return result.toRGB(); +} diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index b94f3f0f1..05eda48e7 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -2003,6 +2003,8 @@ public: void setTheWarningHasBeenGiven(bool isEnabled) { _theWarningHasBeenGiven = isEnabled; }; bool theWarningHasBeenGiven() const { return _theWarningHasBeenGiven; } + COLORREF getIndividualTabColour(int colourIndex, bool themeDependant, bool saturated); + private: void getLangKeywordsFromXmlTree(); bool getUserParametersFromXmlTree(); diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 09c98a4b5..60bb920f4 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -1254,6 +1254,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode) // draw highlights on tabs (top bar for active tab / darkened background for inactive tab) RECT barRect = rect; + NppParameters& nppParam = NppParameters::getInstance(); if (isSelected) { hBrush = ::CreateSolidBrush(colorActiveBg); @@ -1279,7 +1280,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode) if (individualColourId != -1) { - topBarColour = NppDarkMode::getIndividualTabColour(individualColourId, isDarkMode, isFocused); + topBarColour = nppParam.getIndividualTabColour(individualColourId, isDarkMode, isFocused); } hBrush = ::CreateSolidBrush(topBarColour); @@ -1299,7 +1300,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode) } else if (individualColourId != -1) { - brushColour = NppDarkMode::getIndividualTabColour(individualColourId, isDarkMode, false); + brushColour = nppParam.getIndividualTabColour(individualColourId, isDarkMode, false); } else { diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp index 02265dc0c..941ec8080 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp @@ -157,7 +157,7 @@ LRESULT VerticalFileSwitcher::listViewNotifyCustomDraw(HWND hWnd, UINT uMsg, WPA if (colorID != -1) { - bgColor = NppDarkMode::getIndividualTabColour(colorID, isThemeDark, false); + bgColor = NppParameters::getInstance().getIndividualTabColour(colorID, isThemeDark, false); applyColor = true; } else if (isThemeDark)