Fix dark mode tab left-right control for floating docking containers

Fix #11683, close #11684
This commit is contained in:
ozone10 2022-05-17 08:17:11 +02:00 committed by Don Ho
parent c72dac69c5
commit def3aba4e6
5 changed files with 78 additions and 32 deletions

View File

@ -1326,6 +1326,24 @@ namespace NppDarkMode
RemoveWindowSubclass(hWnd, TabSubclass, g_tabSubclassID); RemoveWindowSubclass(hWnd, TabSubclass, g_tabSubclassID);
break; break;
} }
case WM_PARENTNOTIFY:
{
switch (LOWORD(wParam))
{
case WM_CREATE:
{
auto hwndUpdown = reinterpret_cast<HWND>(lParam);
if (NppDarkMode::subclassTabUpDownControl(hwndUpdown))
{
return 0;
}
break;
}
}
return 0;
}
} }
return DefSubclassProc(hWnd, uMsg, wParam, lParam); return DefSubclassProc(hWnd, uMsg, wParam, lParam);
} }
@ -1725,32 +1743,20 @@ namespace NppDarkMode
return DefSubclassProc(hWnd, uMsg, wParam, lParam); return DefSubclassProc(hWnd, uMsg, wParam, lParam);
} }
void subclassTabUpDownControl(HWND hwnd) bool subclassTabUpDownControl(HWND hwnd)
{ {
auto pButtonData = reinterpret_cast<DWORD_PTR>(new ButtonData()); constexpr size_t classNameLen = 16;
SetWindowSubclass(hwnd, TabUpDownSubclass, g_tabUpDownSubclassID, pButtonData); TCHAR className[classNameLen]{};
} GetClassName(hwnd, className, classNameLen);
if (wcscmp(className, UPDOWN_CLASS) == 0)
{
auto pButtonData = reinterpret_cast<DWORD_PTR>(new ButtonData());
SetWindowSubclass(hwnd, TabUpDownSubclass, g_tabUpDownSubclassID, pButtonData);
NppDarkMode::setDarkExplorerTheme(hwnd);
return true;
}
void autoSubclassAndThemeTabUpDownControl(HWND hwndParent, HWND hwndUpdown) return false;
{
EnumChildWindows(hwndParent, [](HWND hwnd, LPARAM lParam) WINAPI_LAMBDA{
auto && hwndUpdown = *reinterpret_cast<HWND*>(lParam);
if (hwndUpdown == nullptr)
{
constexpr size_t classNameLen = 16;
TCHAR className[classNameLen]{};
GetClassName(hwnd, className, classNameLen);
if (wcscmp(className, UPDOWN_CLASS) == 0)
{
hwndUpdown = hwnd;
NppDarkMode::subclassTabUpDownControl(hwndUpdown);
NppDarkMode::setDarkExplorerTheme(hwndUpdown);
::InvalidateRect(hwndUpdown, nullptr, TRUE);
::UpdateWindow(hwndUpdown);
}
}
return TRUE;
}, reinterpret_cast<LPARAM>(&hwndUpdown));
} }
void setDarkTitleBar(HWND hwnd) void setDarkTitleBar(HWND hwnd)

View File

@ -160,7 +160,7 @@ 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);
void autoSubclassAndThemeTabUpDownControl(HWND hwndParent, HWND hwndUpdown); bool subclassTabUpDownControl(HWND hwnd);
void setDarkTitleBar(HWND hwnd); void setDarkTitleBar(HWND hwnd);
void setDarkExplorerTheme(HWND hwnd); void setDarkExplorerTheme(HWND hwnd);

View File

@ -952,6 +952,25 @@ LRESULT DockingCont::runProcTab(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
} }
break; break;
} }
case WM_PARENTNOTIFY:
{
switch (LOWORD(wParam))
{
case WM_CREATE:
{
auto hwndUpdown = reinterpret_cast<HWND>(lParam);
if (NppDarkMode::subclassTabUpDownControl(hwndUpdown))
{
_hTabUpdown = hwndUpdown;
return 0;
}
break;
}
}
return 0;
}
default: default:
break; break;
} }
@ -1225,7 +1244,11 @@ void DockingCont::onSize()
rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom, rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom,
SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE);
NppDarkMode::autoSubclassAndThemeTabUpDownControl(_hContTab, _hTabUpdown); if (_hTabUpdown != nullptr)
{
::InvalidateRect(_hTabUpdown, nullptr, TRUE);
::UpdateWindow(_hTabUpdown);
}
} }
// resize client area for plugin // resize client area for plugin
@ -1246,8 +1269,6 @@ void DockingCont::onSize()
::SetWindowPos(::GetDlgItem(_hSelf, IDC_CLIENT_TAB), NULL, ::SetWindowPos(::GetDlgItem(_hSelf, IDC_CLIENT_TAB), NULL,
rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom, rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom,
SWP_NOZORDER | SWP_NOACTIVATE); SWP_NOZORDER | SWP_NOACTIVATE);
NppDarkMode::autoSubclassAndThemeTabUpDownControl(_hContTab, _hTabUpdown);
} }
// resize to float window // resize to float window
else else
@ -1269,6 +1290,12 @@ void DockingCont::onSize()
::SetWindowPos(_hContTab, NULL, ::SetWindowPos(_hContTab, NULL,
rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom, rcTemp.left, rcTemp.top, rcTemp.right, rcTemp.bottom,
SWP_NOZORDER | SWP_SHOWWINDOW); SWP_NOZORDER | SWP_SHOWWINDOW);
if (_hTabUpdown != nullptr)
{
::InvalidateRect(_hTabUpdown, nullptr, TRUE);
::UpdateWindow(_hTabUpdown);
}
} }
// resize client area for plugin // resize client area for plugin

View File

@ -241,8 +241,6 @@ void TabBar::reSizeTo(RECT & rc2Ajust)
rc2Ajust.top += tabsHight; rc2Ajust.top += tabsHight;
rc2Ajust.bottom -= tabsHight; rc2Ajust.bottom -= tabsHight;
} }
NppDarkMode::autoSubclassAndThemeTabUpDownControl(_hSelf, _hTabUpdown);
} }
@ -982,6 +980,23 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
EndPaint(hwnd, &ps); EndPaint(hwnd, &ps);
return 0; return 0;
} }
case WM_PARENTNOTIFY:
{
switch (LOWORD(wParam))
{
case WM_CREATE:
{
auto hwndUpdown = reinterpret_cast<HWND>(lParam);
if (NppDarkMode::subclassTabUpDownControl(hwndUpdown))
{
return 0;
}
break;
}
}
return 0;
}
} }
return ::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam); return ::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam);

View File

@ -114,8 +114,6 @@ protected:
long getRowCount() const { long getRowCount() const {
return long(::SendMessage(_hSelf, TCM_GETROWCOUNT, 0, 0)); return long(::SendMessage(_hSelf, TCM_GETROWCOUNT, 0, 0));
} }
private:
HWND _hTabUpdown = nullptr;
}; };