Make toolbar dark mode support better for plugins
Tweak dark mode custom draw for plugin: - add plugin custom draw support for toolbar - make code more consistent - make plugin's authors custom draw implementation to have higher priority than one from generic dark mode ref #15078 (comment) Close #15147pull/15154/head
parent
e25e15b9b2
commit
5123016baa
|
@ -2576,7 +2576,7 @@ namespace NppDarkMode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT darkToolBarNotifyCustomDraw(LPARAM lParam)
|
LRESULT darkToolBarNotifyCustomDraw(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool isPlugin)
|
||||||
{
|
{
|
||||||
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(lParam);
|
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(lParam);
|
||||||
static int roundCornerValue = 0;
|
static int roundCornerValue = 0;
|
||||||
|
@ -2585,6 +2585,7 @@ namespace NppDarkMode
|
||||||
{
|
{
|
||||||
case CDDS_PREPAINT:
|
case CDDS_PREPAINT:
|
||||||
{
|
{
|
||||||
|
LRESULT lr = CDRF_DODEFAULT;
|
||||||
if (NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
if (NppDarkMode::isWindows11())
|
if (NppDarkMode::isWindows11())
|
||||||
|
@ -2595,9 +2596,15 @@ namespace NppDarkMode
|
||||||
}
|
}
|
||||||
|
|
||||||
::FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getDarkerBackgroundBrush());
|
::FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getDarkerBackgroundBrush());
|
||||||
return CDRF_NOTIFYITEMDRAW;
|
lr |= CDRF_NOTIFYITEMDRAW;
|
||||||
}
|
}
|
||||||
return CDRF_DODEFAULT;
|
|
||||||
|
if (isPlugin)
|
||||||
|
{
|
||||||
|
lr |= ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lr;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CDDS_ITEMPREPAINT:
|
case CDDS_ITEMPREPAINT:
|
||||||
|
@ -2622,7 +2629,13 @@ namespace NppDarkMode
|
||||||
nmtbcd->nmcd.uItemState &= ~CDIS_CHECKED;
|
nmtbcd->nmcd.uItemState &= ~CDIS_CHECKED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TBCDRF_HILITEHOTTRACK | TBCDRF_USECDCOLORS | CDRF_NOTIFYPOSTPAINT;
|
LRESULT lr = TBCDRF_HILITEHOTTRACK | TBCDRF_USECDCOLORS | CDRF_NOTIFYPOSTPAINT;
|
||||||
|
if (isPlugin)
|
||||||
|
{
|
||||||
|
lr |= ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lr;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CDDS_ITEMPOSTPAINT:
|
case CDDS_ITEMPOSTPAINT:
|
||||||
|
@ -2645,12 +2658,18 @@ namespace NppDarkMode
|
||||||
NppDarkMode::paintRoundFrameRect(nmtbcd->nmcd.hdc, nmtbcd->nmcd.rc, NppDarkMode::getHotEdgePen(), roundCornerValue, roundCornerValue);
|
NppDarkMode::paintRoundFrameRect(nmtbcd->nmcd.hdc, nmtbcd->nmcd.rc, NppDarkMode::getHotEdgePen(), roundCornerValue, roundCornerValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPlugin)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return CDRF_DODEFAULT;
|
return CDRF_DODEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return CDRF_DODEFAULT;
|
break;
|
||||||
}
|
}
|
||||||
|
return ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT darkListViewNotifyCustomDraw(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool isPlugin)
|
LRESULT darkListViewNotifyCustomDraw(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool isPlugin)
|
||||||
|
@ -2661,7 +2680,13 @@ namespace NppDarkMode
|
||||||
{
|
{
|
||||||
case CDDS_PREPAINT:
|
case CDDS_PREPAINT:
|
||||||
{
|
{
|
||||||
return CDRF_NOTIFYITEMDRAW;
|
LRESULT lr = CDRF_NOTIFYITEMDRAW;
|
||||||
|
if (isPlugin)
|
||||||
|
{
|
||||||
|
lr |= ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lr;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CDDS_ITEMPREPAINT:
|
case CDDS_ITEMPREPAINT:
|
||||||
|
@ -2691,14 +2716,14 @@ namespace NppDarkMode
|
||||||
::DrawFocusRect(lplvcd->nmcd.hdc, &lplvcd->nmcd.rc);
|
::DrawFocusRect(lplvcd->nmcd.hdc, &lplvcd->nmcd.rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT lr = CDRF_DODEFAULT;
|
LRESULT lr = CDRF_NEWFONT;
|
||||||
|
|
||||||
if (isPlugin)
|
if (isPlugin)
|
||||||
{
|
{
|
||||||
lr = ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
lr |= ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
return lr | CDRF_NEWFONT;
|
return lr;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -2715,48 +2740,54 @@ namespace NppDarkMode
|
||||||
{
|
{
|
||||||
case CDDS_PREPAINT:
|
case CDDS_PREPAINT:
|
||||||
{
|
{
|
||||||
LRESULT defaultValue = isPlugin ? DefSubclassProc(hWnd, uMsg, wParam, lParam) : CDRF_DODEFAULT;
|
LRESULT lr = NppDarkMode::isEnabled() ? CDRF_NOTIFYITEMDRAW : CDRF_DODEFAULT;
|
||||||
if (NppDarkMode::isEnabled())
|
|
||||||
|
if (isPlugin)
|
||||||
{
|
{
|
||||||
return defaultValue | CDRF_NOTIFYITEMDRAW;
|
lr |= ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
return defaultValue;
|
|
||||||
|
return lr;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CDDS_ITEMPREPAINT:
|
case CDDS_ITEMPREPAINT:
|
||||||
{
|
{
|
||||||
LRESULT defaultValue = isPlugin ? DefSubclassProc(hWnd, uMsg, wParam, lParam) : CDRF_DODEFAULT;
|
LRESULT lr = CDRF_DODEFAULT;
|
||||||
if (NppDarkMode::isEnabled() && (lptvcd->nmcd.uItemState & CDIS_SELECTED) == CDIS_SELECTED)
|
|
||||||
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
lptvcd->clrText = NppDarkMode::getTextColor();
|
if ((lptvcd->nmcd.uItemState & CDIS_SELECTED) == CDIS_SELECTED)
|
||||||
lptvcd->clrTextBk = NppDarkMode::getSofterBackgroundColor();
|
|
||||||
::FillRect(lptvcd->nmcd.hdc, &lptvcd->nmcd.rc, NppDarkMode::getSofterBackgroundBrush());
|
|
||||||
|
|
||||||
return defaultValue | CDRF_NEWFONT | CDRF_NOTIFYPOSTPAINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NppDarkMode::isEnabled() && (lptvcd->nmcd.uItemState & CDIS_HOT) == CDIS_HOT)
|
|
||||||
{
|
|
||||||
lptvcd->clrText = NppDarkMode::getTextColor();
|
|
||||||
lptvcd->clrTextBk = NppDarkMode::getHotBackgroundColor();
|
|
||||||
|
|
||||||
auto notifyResult = defaultValue;
|
|
||||||
if (g_isAtLeastWindows10 || g_treeViewStyle == TreeViewStyle::light)
|
|
||||||
{
|
{
|
||||||
::FillRect(lptvcd->nmcd.hdc, &lptvcd->nmcd.rc, NppDarkMode::getHotBackgroundBrush());
|
lptvcd->clrText = NppDarkMode::getTextColor();
|
||||||
notifyResult |= CDRF_NOTIFYPOSTPAINT;
|
lptvcd->clrTextBk = NppDarkMode::getSofterBackgroundColor();
|
||||||
}
|
::FillRect(lptvcd->nmcd.hdc, &lptvcd->nmcd.rc, NppDarkMode::getSofterBackgroundBrush());
|
||||||
|
|
||||||
return CDRF_NEWFONT | notifyResult;
|
lr |= CDRF_NEWFONT | CDRF_NOTIFYPOSTPAINT;
|
||||||
|
}
|
||||||
|
else if ((lptvcd->nmcd.uItemState & CDIS_HOT) == CDIS_HOT)
|
||||||
|
{
|
||||||
|
lptvcd->clrText = NppDarkMode::getTextColor();
|
||||||
|
lptvcd->clrTextBk = NppDarkMode::getHotBackgroundColor();
|
||||||
|
|
||||||
|
if (g_isAtLeastWindows10 || g_treeViewStyle == TreeViewStyle::light)
|
||||||
|
{
|
||||||
|
::FillRect(lptvcd->nmcd.hdc, &lptvcd->nmcd.rc, NppDarkMode::getHotBackgroundBrush());
|
||||||
|
lr |= CDRF_NOTIFYPOSTPAINT;
|
||||||
|
}
|
||||||
|
lr |= CDRF_NEWFONT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultValue;
|
if (isPlugin)
|
||||||
|
{
|
||||||
|
lr |= ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lr;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CDDS_ITEMPOSTPAINT:
|
case CDDS_ITEMPOSTPAINT:
|
||||||
{
|
{
|
||||||
LRESULT defaultValue = isPlugin ? DefSubclassProc(hWnd, uMsg, wParam, lParam) : CDRF_DODEFAULT;
|
|
||||||
|
|
||||||
if (NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
RECT rcFrame = lptvcd->nmcd.rc;
|
RECT rcFrame = lptvcd->nmcd.rc;
|
||||||
|
@ -2773,13 +2804,18 @@ namespace NppDarkMode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return defaultValue;
|
if (isPlugin)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CDRF_DODEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return isPlugin ? DefSubclassProc(hWnd, uMsg, wParam, lParam) : CDRF_DODEFAULT;
|
break;
|
||||||
}
|
}
|
||||||
|
return ::DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr UINT_PTR g_pluginDockWindowSubclassID = 42;
|
constexpr UINT_PTR g_pluginDockWindowSubclassID = 42;
|
||||||
|
@ -2888,7 +2924,7 @@ namespace NppDarkMode
|
||||||
|
|
||||||
if (wcscmp(className, TOOLBARCLASSNAME) == 0)
|
if (wcscmp(className, TOOLBARCLASSNAME) == 0)
|
||||||
{
|
{
|
||||||
return NppDarkMode::darkToolBarNotifyCustomDraw(lParam);
|
return NppDarkMode::darkToolBarNotifyCustomDraw(hWnd, uMsg, wParam, lParam, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcscmp(className, WC_LISTVIEW) == 0)
|
if (wcscmp(className, WC_LISTVIEW) == 0)
|
||||||
|
@ -3041,7 +3077,7 @@ namespace NppDarkMode
|
||||||
{
|
{
|
||||||
if (wcscmp(className, TOOLBARCLASSNAME) == 0)
|
if (wcscmp(className, TOOLBARCLASSNAME) == 0)
|
||||||
{
|
{
|
||||||
return NppDarkMode::darkToolBarNotifyCustomDraw(lParam);
|
return NppDarkMode::darkToolBarNotifyCustomDraw(hWnd, uMsg, wParam, lParam, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wcscmp(className, WC_LISTVIEW) == 0)
|
if (wcscmp(className, WC_LISTVIEW) == 0)
|
||||||
|
|
|
@ -215,9 +215,9 @@ namespace NppDarkMode
|
||||||
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true);
|
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true);
|
||||||
void autoThemeChildControls(HWND hwndParent);
|
void autoThemeChildControls(HWND hwndParent);
|
||||||
|
|
||||||
LRESULT darkToolBarNotifyCustomDraw(LPARAM lParam);
|
static LRESULT darkToolBarNotifyCustomDraw(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool isPlugin);
|
||||||
LRESULT darkListViewNotifyCustomDraw(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool isPlugin);
|
static LRESULT darkListViewNotifyCustomDraw(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool isPlugin);
|
||||||
LRESULT darkTreeViewNotifyCustomDraw(LPARAM lParam);
|
static LRESULT darkTreeViewNotifyCustomDraw(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool isPlugin);
|
||||||
|
|
||||||
void autoSubclassAndThemePluginDockWindow(HWND hwnd);
|
void autoSubclassAndThemePluginDockWindow(HWND hwnd);
|
||||||
ULONG autoSubclassAndThemePlugin(HWND hwnd, ULONG dmFlags);
|
ULONG autoSubclassAndThemePlugin(HWND hwnd, ULONG dmFlags);
|
||||||
|
|
Loading…
Reference in New Issue