Make Project Panel toolbar conform to dark mode

Close #10039
pull/10050/merge
Don Ho 2021-06-19 14:18:18 +02:00
parent a6bbdeb92e
commit e4ebeed6f9
3 changed files with 32 additions and 0 deletions

View File

@ -981,6 +981,11 @@ namespace NppDarkMode
SetWindowSubclass(hwnd, TabSubclass, g_tabSubclassID, 0);
}
void disableVisualStyle(HWND hwnd)
{
SetWindowTheme(hwnd, L"", L"");
}
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass, bool theme)
{
struct Params

View File

@ -78,6 +78,7 @@ namespace NppDarkMode
void subclassGroupboxControl(HWND hwnd);
void subclassToolbarControl(HWND hwnd);
void subclassTabControl(HWND hwnd);
void disableVisualStyle(HWND hwnd);
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true);
void autoThemeChildControls(HWND hwndParent);

View File

@ -810,6 +810,32 @@ void ProjectPanel::notified(LPNMHDR notification)
break;
}
}
else if (notification->code == NM_CUSTOMDRAW && (notification->hwndFrom == _hToolbarMenu))
{
if (NppDarkMode::isEnabled())
{
static bool isVSDisabled = false;
if (!isVSDisabled)
{
NppDarkMode::disableVisualStyle(_hToolbarMenu);
isVSDisabled = true;
}
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notification);
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
nmtbcd->clrText = NppDarkMode::getTextColor();
// 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);
}
else
{
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_DODEFAULT);
}
}
}
void ProjectPanel::setWorkSpaceDirty(bool isDirty)