From ffbf3af0293c72936ba5641189a3517d88211b45 Mon Sep 17 00:00:00 2001 From: ozone10 Date: Thu, 17 Jun 2021 16:02:14 +0200 Subject: [PATCH] Make DarkMode title bar to apply on all dialog on dark mode Also remove border from clipboard history panel. Close #10023 --- PowerEditor/src/Notepad_plus.cpp | 15 +++++++++++---- PowerEditor/src/NppBigSwitch.cpp | 6 +----- PowerEditor/src/NppDarkMode.cpp | 17 +++++++++++++++++ PowerEditor/src/NppDarkMode.h | 1 + .../src/ScintillaComponent/FindReplaceDlg.cpp | 6 ------ .../ClipboardHistory/clipboardHistoryPanel.rc | 2 +- .../WinControls/StaticDialog/StaticDialog.cpp | 5 +++++ 7 files changed, 36 insertions(+), 16 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 26f62fd65..4dce1b8c1 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -7512,11 +7512,18 @@ void Notepad_plus::refreshDarkMode() if (NppDarkMode::isExperimentalEnabled()) { NppDarkMode::allowDarkModeForApp(NppDarkMode::isEnabled()); - NppDarkMode::allowDarkModeForWindow(_pPublicInterface->getHSelf(), NppDarkMode::isEnabled()); - NppDarkMode::allowDarkModeForWindow(_findReplaceDlg.getHSelf(), NppDarkMode::isEnabled()); - NppDarkMode::setTitleBarThemeColor(_pPublicInterface->getHSelf(), NppDarkMode::isEnabled()); - NppDarkMode::setTitleBarThemeColor(_findReplaceDlg.getHSelf(), NppDarkMode::isEnabled()); } + NppDarkMode::setDarkTitleBar(_pPublicInterface->getHSelf()); + + for (auto &hwndDlg : _hModelessDlgs) + { + NppDarkMode::setDarkTitleBar(hwndDlg); + } + for (auto &docCont : _dockingManager.getContainerInfo()) + { + NppDarkMode::setDarkTitleBar(docCont->getCaptionWnd()); + } + SendMessage(_findReplaceDlg.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); SendMessage(_incrementFindDlg.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); RedrawWindow(_pPublicInterface->getHSelf(), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 1b92df1dc..26b0ebedd 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -94,11 +94,7 @@ LRESULT Notepad_plus_Window::runProc(HWND hwnd, UINT message, WPARAM wParam, LPA { try { - if (NppDarkMode::isExperimentalEnabled()) - { - NppDarkMode::allowDarkModeForWindow(hwnd, NppDarkMode::isEnabled()); - NppDarkMode::setTitleBarThemeColor(hwnd, NppDarkMode::isEnabled()); - } + NppDarkMode::setDarkTitleBar(hwnd); _notepad_plus_plus_core._pPublicInterface = this; LRESULT lRet = _notepad_plus_plus_core.init(hwnd); diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index 5ff2593dc..29fcbda97 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -1039,6 +1039,23 @@ namespace NppDarkMode autoSubclassAndThemeChildControls(hwndParent, false, true); } + void setDarkTitleBar(HWND hwnd) + { + bool useDark = NppDarkMode::isExperimentalEnabled() && NppDarkMode::isEnabled(); + + NppDarkMode::allowDarkModeForWindow(hwnd, useDark); + NppDarkMode::setTitleBarThemeColor(hwnd, useDark); + + if (useDark) + { + SetWindowTheme(hwnd, L"Explorer", nullptr); + } + else + { + SetWindowTheme(hwnd, nullptr, nullptr); + } + } + void setDarkTooltips(HWND hwnd, ToolTipsType type) { if (NppDarkMode::isEnabled()) diff --git a/PowerEditor/src/NppDarkMode.h b/PowerEditor/src/NppDarkMode.h index 588428703..7ff6b2a05 100644 --- a/PowerEditor/src/NppDarkMode.h +++ b/PowerEditor/src/NppDarkMode.h @@ -82,5 +82,6 @@ namespace NppDarkMode void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true); void autoThemeChildControls(HWND hwndParent); + void setDarkTitleBar(HWND hwnd); void setDarkTooltips(HWND hwnd, ToolTipsType type); } diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 5bb843688..054f5d9de 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -884,12 +884,6 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM case WM_INITDIALOG : { - if (NppDarkMode::isExperimentalEnabled()) - { - NppDarkMode::allowDarkModeForWindow(_hSelf, NppDarkMode::isEnabled()); - NppDarkMode::setTitleBarThemeColor(_hSelf, NppDarkMode::isEnabled()); - } - NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); diff --git a/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.rc b/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.rc index 4f328485c..142e573d8 100644 --- a/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.rc +++ b/PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.rc @@ -24,5 +24,5 @@ EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE CAPTION "Clipboard History" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - LISTBOX IDC_LIST_CLIPBOARD,50,44,78,120,LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LISTBOX IDC_LIST_CLIPBOARD,50,44,78,120,LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP | NOT WS_BORDER END diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp index ae900f1be..e7f675d9b 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp @@ -18,6 +18,7 @@ #include #include "StaticDialog.h" #include "Common.h" +#include "NppDarkMode.h" StaticDialog::~StaticDialog() { @@ -222,6 +223,8 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent) return; } + NppDarkMode::setDarkTitleBar(_hSelf); + // if the destination of message NPPM_MODELESSDIALOG is not its parent, then it's the grand-parent ::SendMessage(msgDestParent ? _hParent : (::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, reinterpret_cast(_hSelf)); } @@ -232,6 +235,8 @@ INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, L { case WM_INITDIALOG: { + NppDarkMode::setDarkTitleBar(hwnd); + StaticDialog *pStaticDlg = reinterpret_cast(lParam); pStaticDlg->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, static_cast(lParam));