Skip to content

Commit

Permalink
Make find dialog status messages color customizable via Style Configu…
Browse files Browse the repository at this point in the history
  • Loading branch information
donho committed Sep 1, 2024
1 parent 43ebe79 commit 872d6f9
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 52 deletions.
2 changes: 1 addition & 1 deletion PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2715,7 +2715,7 @@ void Notepad_plus::setupColorSampleBitmapsOnMainMenuItems()
// Adds tab colour icons
for (int i = 0; i < 5; ++i)
{
COLORREF colour = nppParam.getIndividualTabColour(i, NppDarkMode::isDarkMenuEnabled(), true);
COLORREF colour = nppParam.getIndividualTabColor(i, NppDarkMode::isDarkMenuEnabled(), true);
HBITMAP hBitmap = generateSolidColourMenuItemIcon(colour);
SetMenuItemBitmaps(_mainMenuHandle, IDM_VIEW_TAB_COLOUR_1 + i, MF_BYCOMMAND, hBitmap, hBitmap);
}
Expand Down
2 changes: 2 additions & 0 deletions PowerEditor/src/NppBigSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
addHotSpot(& _subEditView);

_findReplaceDlg.updateFinderScintilla();

_findReplaceDlg.redraw();

drawTabbarColoursFromStylerArray();

Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/NppNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
// Adds colour icons
for (int i = 0; i < 5; ++i)
{
COLORREF colour = nppParam.getIndividualTabColour(i, NppDarkMode::isDarkMenuEnabled(), true);
COLORREF colour = nppParam.getIndividualTabColor(i, NppDarkMode::isDarkMenuEnabled(), true);
HBITMAP hBitmap = generateSolidColourMenuItemIcon(colour);
SetMenuItemBitmaps(_tabPopupMenu.getMenuHandle(), IDM_VIEW_TAB_COLOUR_1 + i, MF_BYCOMMAND, hBitmap, hBitmap);
}
Expand Down
64 changes: 52 additions & 12 deletions PowerEditor/src/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8833,70 +8833,70 @@ void NppParameters::initTabCustomColors()
{
StyleArray& stylers = getMiscStylerArray();

const Style* pStyle = stylers.findByName(L"Tab color 1");
const Style* pStyle = stylers.findByName(TABBAR_INDIVIDUALCOLOR_1);
if (pStyle)
{
individualTabHues[0].changeHLSFrom(pStyle->_bgColor);
}

pStyle = stylers.findByName(L"Tab color 2");
pStyle = stylers.findByName(TABBAR_INDIVIDUALCOLOR_2);
if (pStyle)
{
individualTabHues[1].changeHLSFrom(pStyle->_bgColor);
}

pStyle = stylers.findByName(L"Tab color 3");
pStyle = stylers.findByName(TABBAR_INDIVIDUALCOLOR_3);
if (pStyle)
{
individualTabHues[2].changeHLSFrom(pStyle->_bgColor);
}

pStyle = stylers.findByName(L"Tab color 4");
pStyle = stylers.findByName(TABBAR_INDIVIDUALCOLOR_4);
if (pStyle)
{
individualTabHues[3].changeHLSFrom(pStyle->_bgColor);
}

pStyle = stylers.findByName(L"Tab color 5");
pStyle = stylers.findByName(TABBAR_INDIVIDUALCOLOR_5);
if (pStyle)
{
individualTabHues[4].changeHLSFrom(pStyle->_bgColor);
}


pStyle = stylers.findByName(L"Tab color dark mode 1");
pStyle = stylers.findByName(TABBAR_INDIVIDUALCOLOR_DM_1);
if (pStyle)
{
individualTabHuesFor_Dark[0].changeHLSFrom(pStyle->_bgColor);
}

pStyle = stylers.findByName(L"Tab color dark mode 2");
pStyle = stylers.findByName(TABBAR_INDIVIDUALCOLOR_DM_2);
if (pStyle)
{
individualTabHuesFor_Dark[1].changeHLSFrom(pStyle->_bgColor);
}

pStyle = stylers.findByName(L"Tab color dark mode 3");
pStyle = stylers.findByName(TABBAR_INDIVIDUALCOLOR_DM_3);
if (pStyle)
{
individualTabHuesFor_Dark[2].changeHLSFrom(pStyle->_bgColor);
}

pStyle = stylers.findByName(L"Tab color dark mode 4");
pStyle = stylers.findByName(TABBAR_INDIVIDUALCOLOR_DM_4);
if (pStyle)
{
individualTabHuesFor_Dark[3].changeHLSFrom(pStyle->_bgColor);
}

pStyle = stylers.findByName(L"Tab color dark mode 5");
pStyle = stylers.findByName(TABBAR_INDIVIDUALCOLOR_DM_5);
if (pStyle)
{
individualTabHuesFor_Dark[4].changeHLSFrom(pStyle->_bgColor);
}
}


void NppParameters::setIndividualTabColour(COLORREF colour2Set, int colourIndex, bool isDarkMode)
void NppParameters::setIndividualTabColor(COLORREF colour2Set, int colourIndex, bool isDarkMode)
{
if (colourIndex < 0 || colourIndex > 4) return;

Expand All @@ -8908,7 +8908,7 @@ void NppParameters::setIndividualTabColour(COLORREF colour2Set, int colourIndex,
return;
}

COLORREF NppParameters::getIndividualTabColour(int colourIndex, bool isDarkMode, bool saturated)
COLORREF NppParameters::getIndividualTabColor(int colourIndex, bool isDarkMode, bool saturated)
{
if (colourIndex < 0 || colourIndex > 4) return {};

Expand Down Expand Up @@ -8936,3 +8936,43 @@ COLORREF NppParameters::getIndividualTabColour(int colourIndex, bool isDarkMode,

return result.toRGB();
}

void NppParameters::initFindDlgStatusMsgCustomColors()
{
StyleArray& stylers = getMiscStylerArray();

const Style* pStyle = stylers.findByName(FINDDLG_STAUSNOTFOUND_COLOR);
if (pStyle)
{
findDlgStatusMessageColor[0] = pStyle->_fgColor;
}

pStyle = stylers.findByName(FINDDLG_STAUSMESSAGE_COLOR);
if (pStyle)
{
findDlgStatusMessageColor[1] = pStyle->_fgColor;
}

pStyle = stylers.findByName(FINDDLG_STAUSREACHED_COLOR);
if (pStyle)
{
findDlgStatusMessageColor[2] = pStyle->_fgColor;
}

}

void NppParameters::setFindDlgStatusMsgIndexColor(COLORREF colour2Set, int colourIndex)
{
if (colourIndex < 0 || colourIndex > 2) return;

findDlgStatusMessageColor[colourIndex] = colour2Set;

return;
}

COLORREF NppParameters::getFindDlgStatusMsgColor(int colourIndex)
{
if (colourIndex < 0 || colourIndex > 2) return black;

return findDlgStatusMessageColor[colourIndex];
}
10 changes: 8 additions & 2 deletions PowerEditor/src/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,8 @@ class NppParameters final
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}} };

std::array<COLORREF, 3> findDlgStatusMessageColor{ red, blue, darkGreen};

public:
void setShortcutDirty() { _isAnyShortcutModified = true; };
void setAdminMode(bool isAdmin) { _isAdminMode = isAdmin; }
Expand Down Expand Up @@ -2027,8 +2029,12 @@ class NppParameters final


void initTabCustomColors();
void setIndividualTabColour(COLORREF colour2Set, int colourIndex, bool isDarkMode);
COLORREF getIndividualTabColour(int colourIndex, bool isDarkMode, bool saturated);
void setIndividualTabColor(COLORREF colour2Set, int colourIndex, bool isDarkMode);
COLORREF getIndividualTabColor(int colourIndex, bool isDarkMode, bool saturated);

void initFindDlgStatusMsgCustomColors();
void setFindDlgStatusMsgIndexColor(COLORREF colour2Set, int colourIndex);
COLORREF getFindDlgStatusMsgColor(int colourIndex);

private:
void getLangKeywordsFromXmlTree();
Expand Down
21 changes: 11 additions & 10 deletions PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4955,18 +4955,19 @@ void FindReplaceDlg::drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
//printStr(L"OK"));
COLORREF fgColor = black; // black by default
PCTSTR ptStr =(PCTSTR)lpDrawItemStruct->itemData;

NppParameters& nppParamInst = NppParameters::getInstance();

if (_statusbarFindStatus == FSNotFound)
{
fgColor = _FSNotFoundTextColor;
fgColor = nppParamInst.getFindDlgStatusMsgColor(0);
}
else if (_statusbarFindStatus == FSMessage)
{
fgColor = _FSMessageTextColor;
fgColor = nppParamInst.getFindDlgStatusMsgColor(1);
}
else if (_statusbarFindStatus == FSTopReached || _statusbarFindStatus == FSEndReached)
{
fgColor = _FSReachedTextColor;
fgColor = nppParamInst.getFindDlgStatusMsgColor(2);
}
else if (_statusbarFindStatus == FSNoMessage)
{
Expand All @@ -4980,26 +4981,26 @@ void FindReplaceDlg::drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
if (_statusbarFindStatus == FSNotFound)
{
HLSColour hls;
hls.changeHLSFrom(_FSNotFoundTextColor);
hls.changeHLSFrom(nppParamInst.getFindDlgStatusMsgColor(0));
hls._lightness += 50;
hls._saturation -= 20;
fgColor = hls.toRGB(); // red
fgColor = hls.toRGB();
}
else if (_statusbarFindStatus == FSMessage)
{
HLSColour hls;
hls.changeHLSFrom(_FSMessageTextColor);
hls.changeHLSFrom(nppParamInst.getFindDlgStatusMsgColor(1));
hls._lightness += 50;
hls._saturation -= 20;
fgColor = hls.toRGB(); // blue
fgColor = hls.toRGB();
}
else if (_statusbarFindStatus == FSTopReached || _statusbarFindStatus == FSEndReached)
{
HLSColour hls;
hls.changeHLSFrom(_FSReachedTextColor);
hls.changeHLSFrom(nppParamInst.getFindDlgStatusMsgColor(2));
hls._lightness += 50;
hls._saturation -= 20;
fgColor = hls.toRGB(); // green
fgColor = hls.toRGB();
}
}

Expand Down
5 changes: 0 additions & 5 deletions PowerEditor/src/ScintillaComponent/FindReplaceDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,7 @@ protected :
static const int FR_OP_GLOBAL = 8;
static const int FR_OP_FIP = 16;
void saveInMacro(size_t cmd, int cmdType);

COLORREF _FSNotFoundTextColor = red;
COLORREF _FSMessageTextColor = blue;
COLORREF _FSReachedTextColor = darkGreen;
void drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);

bool replaceInFilesConfirmCheck(const std::wstring& directory, const std::wstring& fileTypes);
bool replaceInProjectsConfirmCheck();
bool replaceInOpenDocsConfirmCheck(void);
Expand Down
59 changes: 45 additions & 14 deletions PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM

restoreGlobalOverrideValues();
nppParamInst.initTabCustomColors();
nppParamInst.initFindDlgStatusMsgCustomColors();

_restoreInvalid = false;
_isDirty = false;
Expand Down Expand Up @@ -540,9 +541,18 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
{
TabBarPlus::setColour(_pFgColour->getColour(), (TabBarPlus::tabColourIndex)tabColourIndex, nullptr);
}
else if (isDocumentMapStyle())
else
{
ViewZoneDlg::setColour(_pFgColour->getColour(), ViewZoneDlg::ViewZoneColorIndex::focus);
int findDlgStatusMsgIndex = whichFindDlgStatusMsgColourIndex();
if (findDlgStatusMsgIndex != -1)
{
NppParameters& nppParamInst = NppParameters::getInstance();
nppParamInst.setFindDlgStatusMsgIndexColor(_pFgColour->getColour(), findDlgStatusMsgIndex);
}
else if (isDocumentMapStyle())
{
ViewZoneDlg::setColour(_pFgColour->getColour(), ViewZoneDlg::ViewZoneColorIndex::focus);
}
}
apply(applicationInfo);
return TRUE;
Expand Down Expand Up @@ -572,7 +582,7 @@ intptr_t CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
colourIndex -= TabBarPlus::individualTabColourId::id5;

NppParameters& nppParamInst = NppParameters::getInstance();
nppParamInst.setIndividualTabColour(_pBgColour->getColour(), colourIndex, NppDarkMode::isEnabled());
nppParamInst.setIndividualTabColor(_pBgColour->getColour(), colourIndex, NppDarkMode::isEnabled());
}
}

Expand Down Expand Up @@ -675,20 +685,19 @@ int WordStyleDlg::getApplicationInfo() const
(lstrcmp(styleName, L"Mark Style 3") == 0) ||
(lstrcmp(styleName, L"Mark Style 4") == 0) ||
(lstrcmp(styleName, L"Mark Style 5") == 0) ||
(lstrcmp(styleName, L"Tab color 1") == 0) ||
(lstrcmp(styleName, L"Tab color 2") == 0) ||
(lstrcmp(styleName, L"Tab color 3") == 0) ||
(lstrcmp(styleName, L"Tab color 4") == 0) ||
(lstrcmp(styleName, L"Tab color 5") == 0) ||
(lstrcmp(styleName, L"Tab color dark mode 1") == 0) ||
(lstrcmp(styleName, L"Tab color dark mode 2") == 0) ||
(lstrcmp(styleName, L"Tab color dark mode 3") == 0) ||
(lstrcmp(styleName, L"Tab color dark mode 4") == 0) ||
(lstrcmp(styleName, L"Tab color dark mode 5") == 0))
(lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_1) == 0) ||
(lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_2) == 0) ||
(lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_3) == 0) ||
(lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_4) == 0) ||
(lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_5) == 0) ||
(lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_DM_1) == 0) ||
(lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_DM_2) == 0) ||
(lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_DM_3) == 0) ||
(lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_DM_4) == 0) ||
(lstrcmp(styleName, TABBAR_INDIVIDUALCOLOR_DM_5) == 0))
{
return (GENERAL_CHANGE | COLOR_CHANGE_4_MENU);
}

return GENERAL_CHANGE;
}

Expand Down Expand Up @@ -762,6 +771,28 @@ int WordStyleDlg::whichIndividualTabColourId()
return -1;
}

int WordStyleDlg::whichFindDlgStatusMsgColourIndex()
{
constexpr size_t styleNameLen = 128;
wchar_t styleName[styleNameLen + 1] = { '\0' };

if (!WordStyleDlg::getStyleName(styleName, styleNameLen))
{
return -1;
}

if (lstrcmp(styleName, FINDDLG_STAUSNOTFOUND_COLOR) == 0)
return TabBarPlus::individualTabColourId::id0;

if (lstrcmp(styleName, FINDDLG_STAUSMESSAGE_COLOR) == 0)
return TabBarPlus::individualTabColourId::id1;

if (lstrcmp(styleName, FINDDLG_STAUSREACHED_COLOR) == 0)
return TabBarPlus::individualTabColourId::id2;

return -1;
}

bool WordStyleDlg::isDocumentMapStyle()
{
constexpr size_t styleNameLen = 128;
Expand Down
13 changes: 9 additions & 4 deletions PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@

// The following parameters are for apply() method which will re-initialize the followings GUI with modified styler:
// 2 Scintilla edit zones, Search result (displayed by Sintilla), Notepad++ GUI & components concerning theme
#define NO_VISUAL_CHANGE 0x00 // No need to apply visual effect - User ext.
#define GENERAL_CHANGE 0x01 // For Sintilla zones & Notepad++ GUI
#define THEME_CHANGE 0x02 // For the components concerning theme, for example the background color of dockable panels
#define COLOR_CHANGE_4_MENU 0x04 // For the color items displayed on the menu
#define NO_VISUAL_CHANGE 0x00 // No need to apply visual effect - User ext.
#define GENERAL_CHANGE 0x01 // For Sintilla zones & Notepad++ GUI (Tabbar, Find dialog, etc...)
#define THEME_CHANGE 0x02 // For the components concerning theme, for example the background color of dockable panels
#define COLOR_CHANGE_4_MENU 0x04 // For the color items displayed on the menu

const wchar_t FINDDLG_STAUSNOTFOUND_COLOR[64] = L"Find status: Not found";
const wchar_t FINDDLG_STAUSMESSAGE_COLOR[64] = L"Find status: Message";
const wchar_t FINDDLG_STAUSREACHED_COLOR[64] = L"Find status: Search end reached";

enum fontStyleType {BOLD_STATUS, ITALIC_STATUS, UNDERLINE_STATUS};

Expand Down Expand Up @@ -127,6 +131,7 @@ private :

int whichTabColourIndex() const;
int whichIndividualTabColourId();
int whichFindDlgStatusMsgColourIndex();
void apply(int applicationInfo);
int getApplicationInfo() const;
bool isDocumentMapStyle();
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/WinControls/TabBar/TabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode)

if (individualColourId != -1)
{
topBarColour = nppParam.getIndividualTabColour(individualColourId, isDarkMode, isFocused);
topBarColour = nppParam.getIndividualTabColor(individualColourId, isDarkMode, isFocused);
}

hBrush = ::CreateSolidBrush(topBarColour);
Expand All @@ -1300,7 +1300,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode)
}
else if (individualColourId != -1)
{
brushColour = nppParam.getIndividualTabColour(individualColourId, isDarkMode, false);
brushColour = nppParam.getIndividualTabColor(individualColourId, isDarkMode, false);
}
else
{
Expand Down
Loading

0 comments on commit 872d6f9

Please sign in to comment.