Fix Doc Switcher panel not follow theme in dark mode

Plus add highlightHotTrackColor in dark mode & clean up.
pull/10088/head
Don Ho 2021-06-30 16:02:34 +02:00
parent 36ea7e8b3e
commit 60105d68f7
6 changed files with 27 additions and 34 deletions

View File

@ -27,6 +27,7 @@ namespace NppDarkMode
COLORREF darkerText = 0; COLORREF darkerText = 0;
COLORREF disabledText = 0; COLORREF disabledText = 0;
COLORREF edge = 0; COLORREF edge = 0;
COLORREF highlightHotTrack = 0;
}; };
struct Brushes struct Brushes
@ -64,7 +65,8 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor HEXRGB(0x808080), // disabledTextColor
HEXRGB(0x808080) // edgeColor HEXRGB(0x808080), // edgeColor
HEXRGB(0x414141) // highlightHotTrack
}; };
struct Theme struct Theme
@ -199,6 +201,7 @@ namespace NppDarkMode
COLORREF getDarkerTextColor() { return getTheme().colors.darkerText; } COLORREF getDarkerTextColor() { return getTheme().colors.darkerText; }
COLORREF getDisabledTextColor() { return getTheme().colors.disabledText; } COLORREF getDisabledTextColor() { return getTheme().colors.disabledText; }
COLORREF getEdgeColor() { return getTheme().colors.edge; } COLORREF getEdgeColor() { return getTheme().colors.edge; }
COLORREF getHighlightHotTrackColor() { return getTheme().colors.highlightHotTrack; }
HBRUSH getBackgroundBrush() { return getTheme().brushes.background; } HBRUSH getBackgroundBrush() { return getTheme().brushes.background; }
HBRUSH getSofterBackgroundBrush() { return getTheme().brushes.softerBackground; } HBRUSH getSofterBackgroundBrush() { return getTheme().brushes.softerBackground; }

View File

@ -51,6 +51,7 @@ namespace NppDarkMode
COLORREF getDarkerTextColor(); COLORREF getDarkerTextColor();
COLORREF getDisabledTextColor(); COLORREF getDisabledTextColor();
COLORREF getEdgeColor(); COLORREF getEdgeColor();
COLORREF getHighlightHotTrackColor();
HBRUSH getBackgroundBrush(); HBRUSH getBackgroundBrush();
HBRUSH getDarkerBackgroundBrush(); HBRUSH getDarkerBackgroundBrush();

View File

@ -133,11 +133,9 @@ INT_PTR CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
} }
becomeLightMode = false; becomeLightMode = false;
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>((LPNMHDR)lParam); auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(lParam);
SetBkMode(nmtbcd->nmcd.hdc, TRANSPARENT); SetBkMode(nmtbcd->nmcd.hdc, TRANSPARENT);
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush()); FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
nmtbcd->clrText = RGB(255, 255, 255);
SetTextColor(nmtbcd->nmcd.hdc, RGB(255, 255, 255));
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW); SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
} }
else else

View File

@ -611,12 +611,7 @@ void FunctionListPanel::notified(LPNMHDR notification)
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notification); auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notification);
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush()); FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
nmtbcd->clrText = NppDarkMode::getTextColor(); nmtbcd->clrText = NppDarkMode::getTextColor();
nmtbcd->clrHighlightHotTrack = NppDarkMode::getHighlightHotTrackColor();
// highlight color when hover
// same color when hovering above menu
// RGB(65, 65, 65) should be added to NppDarkMode.cpp
// needed because, visual style is disabled
nmtbcd->clrHighlightHotTrack = RGB(65, 65, 65);
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW | TBCDRF_HILITEHOTTRACK); SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW | TBCDRF_HILITEHOTTRACK);
} }
else else

View File

@ -828,11 +828,7 @@ void ProjectPanel::notified(LPNMHDR notification)
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notification); auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notification);
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush()); FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
nmtbcd->clrText = NppDarkMode::getTextColor(); nmtbcd->clrText = NppDarkMode::getTextColor();
// highlight color when hover nmtbcd->clrHighlightHotTrack = NppDarkMode::getHighlightHotTrackColor();
// same color when hovering above menu
// RGB(65, 65, 65) should be added to NppDarkMode.cpp
// needed because, visual style is disabled
nmtbcd->clrHighlightHotTrack = RGB(65, 65, 65);
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW | TBCDRF_HILITEHOTTRACK); SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW | TBCDRF_HILITEHOTTRACK);
} }
else else

View File

@ -80,14 +80,15 @@ INT_PTR CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
case WM_NOTIFY: case WM_NOTIFY:
{ {
switch (((LPNMHDR)lParam)->code) LPNMHDR notif = reinterpret_cast<LPNMHDR>(lParam);
switch (notif->code)
{ {
case NM_CUSTOMDRAW: case NM_CUSTOMDRAW:
{ {
static bool becomeDarkMode = false; static bool becomeDarkMode = false;
static bool becomeLightMode = false; static bool becomeLightMode = false;
HWND hHeader = ListView_GetHeader(_fileListView.getHSelf()); HWND hHeader = ListView_GetHeader(_fileListView.getHSelf());
if (NppDarkMode::isEnabled()) if (NppDarkMode::isEnabled() && (notif->hwndFrom == hHeader))
{ {
if (!becomeDarkMode) if (!becomeDarkMode)
{ {
@ -96,11 +97,9 @@ INT_PTR CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
} }
becomeLightMode = false; becomeLightMode = false;
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>((LPNMHDR)lParam); auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notif);
SetBkMode(nmtbcd->nmcd.hdc, TRANSPARENT); SetBkMode(nmtbcd->nmcd.hdc, TRANSPARENT);
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush()); FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
nmtbcd->clrText = RGB(255, 255, 255);
SetTextColor(nmtbcd->nmcd.hdc, RGB(255, 255, 255));
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW); SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
} }
else else
@ -115,6 +114,7 @@ INT_PTR CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam,
} }
} }
break; break;
case NM_DBLCLK: case NM_DBLCLK:
{ {
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;