Refactoring - make tab color code on its correct place
This commit is contained in:
parent
6556b17ee2
commit
6b97e68cbb
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -3424,47 +3424,4 @@ namespace NppDarkMode
|
|||
return static_cast<INT_PTR>(NppDarkMode::onCtlColor(hdc));
|
||||
}
|
||||
|
||||
struct HLSColour
|
||||
{
|
||||
WORD _hue;
|
||||
WORD _lightness;
|
||||
WORD _saturation;
|
||||
|
||||
COLORREF toRGB() const { return ColorHLSToRGB(_hue, _lightness, _saturation); }
|
||||
};
|
||||
|
||||
using IndividualTabColours = std::array<HLSColour, 5>;
|
||||
|
||||
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<WORD>(240U, result._saturation + 100U);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = individualTabHues[colourIndex];
|
||||
|
||||
if (saturated)
|
||||
{
|
||||
result._lightness = 140U;
|
||||
result._saturation = std::min<WORD>(240U, result._saturation + 30U);
|
||||
}
|
||||
}
|
||||
|
||||
return result.toRGB();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -516,10 +516,11 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||
return TRUE;
|
||||
//break;
|
||||
|
||||
NppParameters& nppParam = NppParameters::getInstance();
|
||||
|
||||
if (!_tabPopupMenu.isCreated())
|
||||
{
|
||||
std::vector<MenuItemUnit> 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);
|
||||
}
|
||||
|
|
|
@ -8819,3 +8819,49 @@ EolType convertIntToFormatType(int value, EolType defvalue)
|
|||
return defvalue;
|
||||
}
|
||||
}
|
||||
|
||||
#include <array>
|
||||
|
||||
struct HLSColour
|
||||
{
|
||||
WORD _hue;
|
||||
WORD _lightness;
|
||||
WORD _saturation;
|
||||
|
||||
COLORREF toRGB() const { return ColorHLSToRGB(_hue, _lightness, _saturation); }
|
||||
};
|
||||
|
||||
using IndividualTabColours = std::array<HLSColour, 5>;
|
||||
|
||||
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<WORD>(240U, result._saturation + 100U);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = individualTabHues[colourIndex];
|
||||
|
||||
if (saturated)
|
||||
{
|
||||
result._lightness = 140U;
|
||||
result._saturation = std::min<WORD>(240U, result._saturation + 30U);
|
||||
}
|
||||
}
|
||||
|
||||
return result.toRGB();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue