Add customizable option for individual tab color
Fix #12156, close #15509
This commit is contained in:
parent
29ff2da823
commit
a16261caaa
|
@ -475,7 +475,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
|||
// ------------ //
|
||||
// Menu Section //
|
||||
// ------------ //
|
||||
|
||||
nppParam.initTabCustomColors();
|
||||
setupColorSampleBitmapsOnMainMenuItems();
|
||||
|
||||
// Macro Menu
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <time.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include <shlobj.h>
|
||||
#include "Parameters.h"
|
||||
#include "ScintillaEditView.h"
|
||||
|
@ -8820,29 +8820,91 @@ EolType convertIntToFormatType(int value, EolType defvalue)
|
|||
}
|
||||
}
|
||||
|
||||
#include <array>
|
||||
|
||||
struct HLSColour
|
||||
void NppParameters::initTabCustomColors()
|
||||
{
|
||||
WORD _hue;
|
||||
WORD _lightness;
|
||||
WORD _saturation;
|
||||
StyleArray& stylers = getMiscStylerArray();
|
||||
|
||||
COLORREF toRGB() const { return ColorHLSToRGB(_hue, _lightness, _saturation); }
|
||||
};
|
||||
const Style* pStyle = stylers.findByName(L"Tab color 1");
|
||||
if (pStyle)
|
||||
{
|
||||
individualTabHues[0].changeHLSFrom(pStyle->_bgColor);
|
||||
}
|
||||
|
||||
using IndividualTabColours = std::array<HLSColour, 5>;
|
||||
pStyle = stylers.findByName(L"Tab color 2");
|
||||
if (pStyle)
|
||||
{
|
||||
individualTabHues[1].changeHLSFrom(pStyle->_bgColor);
|
||||
}
|
||||
|
||||
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}} };
|
||||
pStyle = stylers.findByName(L"Tab color 3");
|
||||
if (pStyle)
|
||||
{
|
||||
individualTabHues[2].changeHLSFrom(pStyle->_bgColor);
|
||||
}
|
||||
|
||||
pStyle = stylers.findByName(L"Tab color 4");
|
||||
if (pStyle)
|
||||
{
|
||||
individualTabHues[3].changeHLSFrom(pStyle->_bgColor);
|
||||
}
|
||||
|
||||
pStyle = stylers.findByName(L"Tab color 5");
|
||||
if (pStyle)
|
||||
{
|
||||
individualTabHues[4].changeHLSFrom(pStyle->_bgColor);
|
||||
}
|
||||
|
||||
|
||||
COLORREF NppParameters::getIndividualTabColour(int colourIndex, bool themeDependant, bool saturated)
|
||||
pStyle = stylers.findByName(L"Tab color dark mode 1");
|
||||
if (pStyle)
|
||||
{
|
||||
individualTabHuesFor_Dark[0].changeHLSFrom(pStyle->_bgColor);
|
||||
}
|
||||
|
||||
pStyle = stylers.findByName(L"Tab color dark mode 2");
|
||||
if (pStyle)
|
||||
{
|
||||
individualTabHuesFor_Dark[1].changeHLSFrom(pStyle->_bgColor);
|
||||
}
|
||||
|
||||
pStyle = stylers.findByName(L"Tab color dark mode 3");
|
||||
if (pStyle)
|
||||
{
|
||||
individualTabHuesFor_Dark[2].changeHLSFrom(pStyle->_bgColor);
|
||||
}
|
||||
|
||||
pStyle = stylers.findByName(L"Tab color dark mode 4");
|
||||
if (pStyle)
|
||||
{
|
||||
individualTabHuesFor_Dark[3].changeHLSFrom(pStyle->_bgColor);
|
||||
}
|
||||
|
||||
pStyle = stylers.findByName(L"Tab color dark mode 5");
|
||||
if (pStyle)
|
||||
{
|
||||
individualTabHuesFor_Dark[4].changeHLSFrom(pStyle->_bgColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NppParameters::setIndividualTabColour(COLORREF colour2Set, int colourIndex, bool isDarkMode)
|
||||
{
|
||||
if (colourIndex < 0 || colourIndex > 4) return;
|
||||
|
||||
if (isDarkMode)
|
||||
individualTabHuesFor_Dark[colourIndex].changeHLSFrom(colour2Set);
|
||||
else
|
||||
individualTabHues[colourIndex].changeHLSFrom(colour2Set);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
COLORREF NppParameters::getIndividualTabColour(int colourIndex, bool isDarkMode, bool saturated)
|
||||
{
|
||||
if (colourIndex < 0 || colourIndex > 4) return {};
|
||||
|
||||
HLSColour result;
|
||||
if (themeDependant)
|
||||
if (isDarkMode)
|
||||
{
|
||||
result = individualTabHuesFor_Dark[colourIndex];
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <assert.h>
|
||||
#include <tchar.h>
|
||||
#include <map>
|
||||
#include <array>
|
||||
#include <shlwapi.h>
|
||||
#include "ILexer.h"
|
||||
#include "Lexilla.h"
|
||||
#include "DockingCont.h"
|
||||
|
@ -1378,6 +1380,15 @@ private:
|
|||
std::wstring _stylesXmlPath;
|
||||
};
|
||||
|
||||
struct HLSColour
|
||||
{
|
||||
WORD _hue;
|
||||
WORD _lightness;
|
||||
WORD _saturation;
|
||||
|
||||
void changeHLSFrom(COLORREF rgb) { ColorRGBToHLS(rgb, &_hue, &_lightness, &_saturation); }
|
||||
COLORREF toRGB() const { return ColorHLSToRGB(_hue, _lightness, _saturation); }
|
||||
};
|
||||
|
||||
struct UdlXmlFileState final {
|
||||
TiXmlDocument* _udlXmlDoc = nullptr;
|
||||
|
@ -1897,6 +1908,9 @@ private:
|
|||
|
||||
std::wstring _loadedSessionFullFilePath;
|
||||
|
||||
std::array<HLSColour, 5> individualTabHuesFor_Dark{ { HLSColour{37, 60, 60}, HLSColour{70, 60, 60}, HLSColour{144, 70, 60}, HLSColour{255, 60, 60}, HLSColour{195, 60, 60} } };
|
||||
std::array<HLSColour, 5> individualTabHues{ { HLSColour{37, 210, 150}, HLSColour{70, 210, 150}, HLSColour{144, 210, 150}, HLSColour{255, 210, 150}, HLSColour{195, 210, 150}} };
|
||||
|
||||
public:
|
||||
void setShortcutDirty() { _isAnyShortcutModified = true; };
|
||||
void setAdminMode(bool isAdmin) { _isAdminMode = isAdmin; }
|
||||
|
@ -2003,7 +2017,10 @@ public:
|
|||
void setTheWarningHasBeenGiven(bool isEnabled) { _theWarningHasBeenGiven = isEnabled; };
|
||||
bool theWarningHasBeenGiven() const { return _theWarningHasBeenGiven; }
|
||||
|
||||
COLORREF getIndividualTabColour(int colourIndex, bool themeDependant, bool saturated);
|
||||
|
||||
void initTabCustomColors();
|
||||
void setIndividualTabColour(COLORREF colour2Set, int colourIndex, bool isDarkMode);
|
||||
COLORREF getIndividualTabColour(int colourIndex, bool isDarkMode, bool saturated);
|
||||
|
||||
private:
|
||||
void getLangKeywordsFromXmlTree();
|
||||
|
|
|
@ -359,6 +359,7 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
|||
}
|
||||
|
||||
restoreGlobalOverrideValues();
|
||||
nppParamInst.initTabCustomColors();
|
||||
|
||||
_restoreInvalid = false;
|
||||
_isDirty = false;
|
||||
|
@ -554,6 +555,20 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
|||
{
|
||||
ViewZoneDlg::setColour(_pBgColour->getColour(), ViewZoneDlg::ViewZoneColorIndex::frost);
|
||||
}
|
||||
else
|
||||
{
|
||||
int colourIndex = whichIndividualTabColourId();
|
||||
|
||||
if (colourIndex != -1)
|
||||
{
|
||||
if (colourIndex >= TabBarPlus::individualTabColourId::id5)
|
||||
colourIndex -= TabBarPlus::individualTabColourId::id5;
|
||||
|
||||
NppParameters& nppParamInst = NppParameters::getInstance();
|
||||
nppParamInst.setIndividualTabColour(_pBgColour->getColour(), colourIndex, NppDarkMode::isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
apply();
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -658,6 +673,51 @@ int WordStyleDlg::whichTabColourIndex()
|
|||
return -1;
|
||||
}
|
||||
|
||||
int WordStyleDlg::whichIndividualTabColourId()
|
||||
{
|
||||
constexpr size_t styleNameLen = 128;
|
||||
wchar_t styleName[styleNameLen + 1] = { '\0' };
|
||||
|
||||
if (!WordStyleDlg::getStyleName(styleName, styleNameLen))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_1) == 0)
|
||||
return TabBarPlus::individualTabColourId::id0;
|
||||
|
||||
if (lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_2) == 0)
|
||||
return TabBarPlus::individualTabColourId::id1;
|
||||
|
||||
if (lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_3) == 0)
|
||||
return TabBarPlus::individualTabColourId::id2;
|
||||
|
||||
if (lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_4) == 0)
|
||||
return TabBarPlus::individualTabColourId::id3;
|
||||
|
||||
if (lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_5) == 0)
|
||||
return TabBarPlus::individualTabColourId::id4;
|
||||
|
||||
|
||||
if (lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_DM_1) == 0)
|
||||
return TabBarPlus::individualTabColourId::id5;
|
||||
|
||||
if (lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_DM_2) == 0)
|
||||
return TabBarPlus::individualTabColourId::id6;
|
||||
|
||||
if (lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_DM_3) == 0)
|
||||
return TabBarPlus::individualTabColourId::id7;
|
||||
|
||||
if (lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_DM_4) == 0)
|
||||
return TabBarPlus::individualTabColourId::id8;
|
||||
|
||||
if (lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_DM_5) == 0)
|
||||
return TabBarPlus::individualTabColourId::id9;
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool WordStyleDlg::isDocumentMapStyle()
|
||||
{
|
||||
constexpr size_t styleNameLen = 128;
|
||||
|
|
|
@ -119,6 +119,7 @@ private :
|
|||
bool getStyleName(wchar_t *styleName, const size_t styleNameLen);
|
||||
|
||||
int whichTabColourIndex();
|
||||
int whichIndividualTabColourId();
|
||||
bool isDocumentMapStyle();
|
||||
void move2CtrlRight(int ctrlID, HWND handle2Move, int handle2MoveWidth, int handle2MoveHeight);
|
||||
void updateColour(bool which);
|
||||
|
|
|
@ -47,6 +47,18 @@ const wchar_t TABBAR_ACTIVEUNFOCUSEDINDCATOR[64] = L"Active tab unfocused indica
|
|||
const wchar_t TABBAR_ACTIVETEXT[64] = L"Active tab text";
|
||||
const wchar_t TABBAR_INACTIVETEXT[64] = L"Inactive tabs";
|
||||
|
||||
const wchar_t TABBAR_INDIVIDUALCOLOR_1[64] = L"Tab color 1";
|
||||
const wchar_t TABBAR_INDIVIDUALCOLOR_2[64] = L"Tab color 2";
|
||||
const wchar_t TABBAR_INDIVIDUALCOLOR_3[64] = L"Tab color 3";
|
||||
const wchar_t TABBAR_INDIVIDUALCOLOR_4[64] = L"Tab color 4";
|
||||
const wchar_t TABBAR_INDIVIDUALCOLOR_5[64] = L"Tab color 5";
|
||||
|
||||
const wchar_t TABBAR_INDIVIDUALCOLOR_DM_1[64] = L"Tab color dark mode 1";
|
||||
const wchar_t TABBAR_INDIVIDUALCOLOR_DM_2[64] = L"Tab color dark mode 2";
|
||||
const wchar_t TABBAR_INDIVIDUALCOLOR_DM_3[64] = L"Tab color dark mode 3";
|
||||
const wchar_t TABBAR_INDIVIDUALCOLOR_DM_4[64] = L"Tab color dark mode 4";
|
||||
const wchar_t TABBAR_INDIVIDUALCOLOR_DM_5[64] = L"Tab color dark mode 5";
|
||||
|
||||
constexpr int g_TabIconSize = 16;
|
||||
constexpr int g_TabHeight = 22;
|
||||
constexpr int g_TabHeightLarge = 25;
|
||||
|
@ -157,6 +169,10 @@ public :
|
|||
activeText, activeFocusedTop, activeUnfocusedTop, inactiveText, inactiveBg
|
||||
};
|
||||
|
||||
enum individualTabColourId {
|
||||
id0, id1, id2, id3, id4, id5, id6, id7, id8, id9
|
||||
};
|
||||
|
||||
static void doDragNDrop(bool justDoIt) {
|
||||
_doDragNDrop = justDoIt;
|
||||
};
|
||||
|
|
|
@ -1580,6 +1580,16 @@
|
|||
<WidgetStyle name="Active tab unfocused indicator" styleID="0" fgColor="FFCAB0" />
|
||||
<WidgetStyle name="Active tab text" styleID="0" fgColor="000000" />
|
||||
<WidgetStyle name="Inactive tabs" styleID="0" fgColor="808080" bgColor="C0C0C0" />
|
||||
<WidgetStyle name="Tab color 1" styleID="0" bgColor="F3F0CB" />
|
||||
<WidgetStyle name="Tab color 2" styleID="0" bgColor="DBF3CB" />
|
||||
<WidgetStyle name="Tab color 3" styleID="0" bgColor="CBDBF3" />
|
||||
<WidgetStyle name="Tab color 4" styleID="0" bgColor="F3DBCB" />
|
||||
<WidgetStyle name="Tab color 5" styleID="0" bgColor="F3CBEE" />
|
||||
<WidgetStyle name="Tab color dark mode 1" styleID="0" bgColor="807848" />
|
||||
<WidgetStyle name="Tab color dark mode 2" styleID="0" bgColor="568048" />
|
||||
<WidgetStyle name="Tab color dark mode 3" styleID="0" bgColor="507094" />
|
||||
<WidgetStyle name="Tab color dark mode 4" styleID="0" bgColor="804849" />
|
||||
<WidgetStyle name="Tab color dark mode 5" styleID="0" bgColor="754880" />
|
||||
<WidgetStyle name="URL hovered" styleID="0" fgColor="0000FF" />
|
||||
<WidgetStyle name="Document map" styleID="0" fgColor="FF8000" bgColor="FFFFFF" />
|
||||
<WidgetStyle name="EOL custom color" styleID="0" fgColor="DADADA" />
|
||||
|
|
Loading…
Reference in New Issue