From 67297397d45df93bc6b7f628b210052f7a25315e Mon Sep 17 00:00:00 2001 From: ozone10 Date: Sat, 14 May 2022 21:51:24 +0200 Subject: [PATCH] Make Alternate Icons behaviour in dark mode consistent The usage of alternate icons in dark mode can be remember now though the sessions. Fix #10159, close #11674 --- PowerEditor/src/Notepad_plus.cpp | 165 +++++++++++++++++-------------- 1 file changed, 89 insertions(+), 76 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index e324d562e..c4687edea 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -235,7 +235,7 @@ LRESULT Notepad_plus::init(HWND hwnd) pIconListVector.push_back(&_docTabIconListAlt); // 1 pIconListVector.push_back(&_docTabIconListDarkMode);// 2 - unsigned char indexDocTabIcon = NppDarkMode::isEnabled() ? 2 : ((tabBarStatus & TAB_ALTICONS) ? 1 : 0); + unsigned char indexDocTabIcon = (((tabBarStatus & TAB_ALTICONS) == TAB_ALTICONS) ? 1 : NppDarkMode::isEnabled() ? 2 : 1); _mainDocTab.init(_pPublicInterface->getHinst(), hwnd, &_mainEditView, pIconListVector, indexDocTabIcon); _subDocTab.init(_pPublicInterface->getHinst(), hwnd, &_subEditView, pIconListVector, indexDocTabIcon); @@ -7713,95 +7713,65 @@ void Notepad_plus::restoreMinimizeDialogs() void Notepad_plus::refreshDarkMode(bool resetStyle) { - NppParameters& nppParams = NppParameters::getInstance(); + if (resetStyle) + { + NppParameters& nppParams = NppParameters::getInstance(); - SendMessage(_pPublicInterface->getHSelf(), NPPM_SETEDITORBORDEREDGE, 0, nppParams.getSVP()._showBorderEdge); + ::SendMessage(_pPublicInterface->getHSelf(), NPPM_SETEDITORBORDEREDGE, 0, nppParams.getSVP()._showBorderEdge); - if (resetStyle && NppDarkMode::isExperimentalSupported()) - { - NppDarkMode::allowDarkModeForApp(NppDarkMode::isEnabled()); + ::SendMessage(_subEditView.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + ::SendMessage(_mainEditView.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - NppDarkMode::setDarkTitleBar(_pPublicInterface->getHSelf()); - ::SetWindowPos(_pPublicInterface->getHSelf(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + ::SendMessage(_mainDocTab.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + ::SendMessage(_subDocTab.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - for (auto& docCont : _dockingManager.getContainerInfo()) + ::SendMessage(_findInFinderDlg.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + ::RedrawWindow(_findInFinderDlg.getHSelf(), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); + + ::SendMessage(_incrementFindDlg.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + ::RedrawWindow(_pPublicInterface->getHSelf(), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); + + if (_pProjectPanel_1) { - NppDarkMode::setDarkTitleBar(docCont->getCaptionWnd()); - ::SetWindowPos(docCont->getCaptionWnd(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + ::SendMessage(_pProjectPanel_1->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); } - - for (auto& hwndDlg : _hModelessDlgs) + if (_pProjectPanel_2) { - NppDarkMode::setDarkTitleBar(hwndDlg); - ::SendMessage(hwndDlg, NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - ::RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); - ::SetWindowPos(hwndDlg, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + ::SendMessage(_pProjectPanel_2->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); } - } - else - { - for (auto& hwndDlg : _hModelessDlgs) + if (_pProjectPanel_3) { - ::SendMessage(hwndDlg, NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - ::RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); + ::SendMessage(_pProjectPanel_3->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + } + if (_pFuncList) + { + ::SendMessage(_pFuncList->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + } + if (_pFileBrowser) + { + ::SendMessage(_pFileBrowser->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); } - } - - if (_pProjectPanel_1) - { - ::SendMessage(_pProjectPanel_1->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - } - if (_pProjectPanel_2) - { - ::SendMessage(_pProjectPanel_2->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - } - if (_pProjectPanel_3) - { - ::SendMessage(_pProjectPanel_3->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - } - if (_pFuncList) - { - ::SendMessage(_pFuncList->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - } - if (_pFileBrowser) - { - ::SendMessage(_pFileBrowser->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - } - - if (_pAnsiCharPanel) - { - ::SendMessage(_pAnsiCharPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - } - if (_pDocumentListPanel) - { - ::SendMessage(_pDocumentListPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - } - - if (_pClipboardHistoryPanel) - { - ::SendMessage(_pClipboardHistoryPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - } - - ::SendMessage(_subEditView.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - ::SendMessage(_mainEditView.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - ::SendMessage(_mainDocTab.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - ::SendMessage(_subDocTab.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + if (_pAnsiCharPanel) + { + ::SendMessage(_pAnsiCharPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + } + if (_pDocumentListPanel) + { + ::SendMessage(_pDocumentListPanel->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); - SendMessage(_pPublicInterface->getHSelf(), NPPM_INTERNAL_CHANGETABBAEICONS, 0, NppDarkMode::isEnabled() ? 2 : 0); + if (_pClipboardHistoryPanel) + { + ::SendMessage(_pClipboardHistoryPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + } - ::SendMessage(_findInFinderDlg.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); - ::RedrawWindow(_findInFinderDlg.getHSelf(), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); - if (resetStyle && NppDarkMode::isExperimentalSupported()) - { - NppDarkMode::setDarkTitleBar(_findInFinderDlg.getHSelf()); - ::SetWindowPos(_findInFinderDlg.getHSelf(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); - } + bool isChecked = _preference._generalSubDlg.isCheckedOrNot(IDC_CHECK_TAB_ALTICONS); + if (!isChecked) + { + ::SendMessage(_pPublicInterface->getHSelf(), NPPM_INTERNAL_CHANGETABBAEICONS, 0, NppDarkMode::isEnabled() ? 2 : 0); + } - if (resetStyle) - { toolBarStatusType state = _toolBar.getState(); switch (state) { @@ -7862,6 +7832,49 @@ void Notepad_plus::refreshDarkMode(bool resetStyle) ::SendMessage(_pPublicInterface->getHSelf(), WM_UPDATESCINTILLAS, 0, 0); } } + + if (NppDarkMode::isExperimentalSupported()) + { + NppDarkMode::allowDarkModeForApp(NppDarkMode::isEnabled()); + + NppDarkMode::setDarkTitleBar(_pPublicInterface->getHSelf()); + ::SetWindowPos(_pPublicInterface->getHSelf(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + + for (auto& docCont : _dockingManager.getContainerInfo()) + { + auto hwndDocCont = docCont->getCaptionWnd(); + NppDarkMode::setDarkTitleBar(hwndDocCont); + ::SetWindowPos(hwndDocCont, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + } + + for (auto& hwndDlg : _hModelessDlgs) + { + NppDarkMode::setDarkTitleBar(hwndDlg); + ::SendMessage(hwndDlg, NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + ::RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); + ::SetWindowPos(hwndDlg, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + } + + NppDarkMode::setDarkTitleBar(_findInFinderDlg.getHSelf()); + ::SetWindowPos(_findInFinderDlg.getHSelf(), nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + } + } + else + { + for (auto& docCont : _dockingManager.getContainerInfo()) + { + auto hwndDocCont = docCont->getCaptionWnd(); + ::RedrawWindow(hwndDocCont, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); + } + + for (auto& hwndDlg : _hModelessDlgs) + { + //::SendMessage(hwndDlg, NPPM_INTERNAL_REFRESHDARKMODE, 0, 0); + ::RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); + } + + ::RedrawWindow(_findInFinderDlg.getHSelf(), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); + ::RedrawWindow(_pPublicInterface->getHSelf(), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); } }