From 4a7a33f010b6e95d1480db93bb348840d4b82bf3 Mon Sep 17 00:00:00 2001 From: Ashfaaq18 Date: Mon, 27 Dec 2021 14:19:12 +0530 Subject: [PATCH] Fix Document List icons unchanged issue after switching to dark mode 1. Document List icons now support darkmode icons and alternate icons. 2. Fixed memory leak in code and additional code refactoring. Fix #10740, close #10956 --- PowerEditor/src/Notepad_plus.cpp | 3 +- PowerEditor/src/NppBigSwitch.cpp | 34 +++++++++++++++++++ .../DockingWnd/DockingDlgInterface.h | 4 ++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 109d0b5c0..0798c9132 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -6606,9 +6606,10 @@ void Notepad_plus::launchDocumentListPanel() if (!_pDocumentListPanel) { NppParameters& nppParams = NppParameters::getInstance(); + int tabBarStatus = nppParams.getNppGUI()._tabStatus; _pDocumentListPanel = new VerticalFileSwitcher; - HIMAGELIST hImgLst = _docTabIconList.getHandle(); + HIMAGELIST hImgLst = ((tabBarStatus & TAB_ALTICONS) ? _docTabIconListAlt.getHandle() : NppDarkMode::isEnabled() ? _docTabIconListDarkMode.getHandle() : _docTabIconList.getHandle()); _pDocumentListPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), hImgLst); NativeLangSpeaker *pNativeSpeaker = nppParams.getNativeLangSpeaker(); bool isRTL = pNativeSpeaker->isRTL(); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 0db8cffd7..76902dd7c 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -740,6 +740,40 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa { _mainDocTab.changeIcons(static_cast(lParam)); _subDocTab.changeIcons(static_cast(lParam)); + + //restart document list with the same icons as the DocTabs + if (_pDocumentListPanel) + { + if (!_pDocumentListPanel->isClosed()) // if doclist is open + { + //close the doclist + _pDocumentListPanel->display(false); + + //clean doclist + _pDocumentListPanel->destroy(); + _pDocumentListPanel = nullptr; + + //relaunch with new icons + launchDocumentListPanel(); + } + else //if doclist is closed + { + //clean doclist + _pDocumentListPanel->destroy(); + _pDocumentListPanel = nullptr; + + //relaunch doclist with new icons and close it + launchDocumentListPanel(); + if (_pDocumentListPanel) + { + _pDocumentListPanel->display(false); + _pDocumentListPanel->setClosed(true); + checkMenuItem(IDM_VIEW_DOCLIST, false); + _toolBar.setCheck(IDM_VIEW_DOCLIST, false); + } + } + } + return TRUE; } diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h index 1db2c5136..384d39690 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h @@ -63,7 +63,9 @@ public: ::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, reinterpret_cast(_hSelf)); } - virtual void destroy() {} + virtual void destroy() { + StaticDialog::destroy(); + } virtual void setBackgroundColor(COLORREF) {} virtual void setForegroundColor(COLORREF) {}