diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index b09c89971..33cb62054 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -613,8 +613,6 @@ LRESULT Notepad_plus::init(HWND hwnd) _toolBar.init(_pPublicInterface->getHinst(), hwnd, tbStatus, toolBarIcons, sizeof(toolBarIcons) / sizeof(ToolBarButtonUnit)); - changeToolBarIcons(); - _rebarTop.init(_pPublicInterface->getHinst(), hwnd); _rebarBottom.init(_pPublicInterface->getHinst(), hwnd); _toolBar.addToRebar(&_rebarTop); @@ -5113,11 +5111,6 @@ bool Notepad_plus::addCurrentMacro() return false; } -void Notepad_plus::changeToolBarIcons() -{ - _toolBar.changeIcons(); -} - bool Notepad_plus::switchToFile(BufferID id) { int i = 0; diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 966fa83cb..1a5bd1c40 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -207,7 +207,6 @@ public: bool fileLoadSession(const TCHAR* fn = nullptr); const TCHAR * fileSaveSession(size_t nbFile, TCHAR ** fileNames, const TCHAR *sessionFile2save, bool includeFileBrowser = false); const TCHAR * fileSaveSession(size_t nbFile = 0, TCHAR** fileNames = nullptr); - void changeToolBarIcons(); bool doBlockComment(comment_mode currCommentMode); bool doStreamComment(); diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 0ead097b0..c53a6626d 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -1988,7 +1988,7 @@ void Notepad_plus::command(int id) bool isFolded = _pEditView->isCurrentLineFolded(); mode = isFolded ? fold_uncollapse : fold_collapse; } - + _pEditView->foldCurrentPos(mode); } break; @@ -2041,7 +2041,6 @@ void Notepad_plus::command(int id) if (state != TB_SMALL) { _toolBar.reduce(); - changeToolBarIcons(); } } break; @@ -2053,7 +2052,6 @@ void Notepad_plus::command(int id) if (state != TB_LARGE) { _toolBar.enlarge(); - changeToolBarIcons(); } } break; @@ -2065,7 +2063,6 @@ void Notepad_plus::command(int id) if (state != TB_SMALL2) { _toolBar.reduceToSet2(); - changeToolBarIcons(); } } break; @@ -2077,7 +2074,6 @@ void Notepad_plus::command(int id) if (state != TB_LARGE2) { _toolBar.enlargeToSet2(); - changeToolBarIcons(); } } break; diff --git a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h index 4fde88e22..64e819088 100644 --- a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h +++ b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h @@ -146,7 +146,9 @@ public : bool replaceIcon(size_t witchList, size_t iconIndex, const TCHAR *iconLocation) const { if ((witchList != HLIST_DEFAULT) && (witchList != HLIST_DISABLE) && - (witchList != HLIST_DEFAULT2) && (witchList != HLIST_DISABLE2)) + (witchList != HLIST_DEFAULT2) && (witchList != HLIST_DISABLE2) && + (witchList != HLIST_DEFAULT_DM) && (witchList != HLIST_DISABLE_DM) && + (witchList != HLIST_DEFAULT_DM2) && (witchList != HLIST_DISABLE_DM2)) return false; return _iconListVector[witchList].changeIcon(iconIndex, iconLocation); diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp index caae1389d..30737f9cb 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp @@ -92,7 +92,12 @@ void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot) locator += icoUnit._id; locator += ext; if (::PathFileExists(locator.c_str())) - _customIconVect.push_back(iconLocator(0, i, locator)); + { + _customIconVect.push_back(iconLocator(HLIST_DEFAULT, i, locator)); + _customIconVect.push_back(iconLocator(HLIST_DEFAULT2, i, locator)); + _customIconVect.push_back(iconLocator(HLIST_DEFAULT_DM, i, locator)); + _customIconVect.push_back(iconLocator(HLIST_DEFAULT_DM2, i, locator)); + } if (icoUnit.hasDisabledIcon) { @@ -102,7 +107,12 @@ void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot) locator_dis += disabled_suffix; locator_dis += ext; if (::PathFileExists(locator_dis.c_str())) - _customIconVect.push_back(iconLocator(1, i, locator_dis)); + { + _customIconVect.push_back(iconLocator(HLIST_DISABLE, i, locator_dis)); + _customIconVect.push_back(iconLocator(HLIST_DISABLE2, i, locator_dis)); + _customIconVect.push_back(iconLocator(HLIST_DISABLE_DM, i, locator_dis)); + _customIconVect.push_back(iconLocator(HLIST_DISABLE_DM2, i, locator_dis)); + } } i++; } @@ -264,10 +274,8 @@ void ToolBar::setToBmpIcons() Window::redraw(); } - void ToolBar::reset(bool create) { - if (create && _hSelf) { //Store current button state information @@ -307,6 +315,8 @@ void ToolBar::reset(bool create) // backward compatibility. ::SendMessage(_hSelf, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); ::SendMessage(_hSelf, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_HIDECLIPPEDBUTTONS); + + change2CustomIconsIfAny(); } if (!_hSelf) @@ -317,73 +327,71 @@ void ToolBar::reset(bool create) bool doOverrideToolbarIcons = _customIconVect.size() > 0; if (doOverrideToolbarIcons) { - setDefaultImageList(); - setDisableImageList(); + if (_state == TB_STANDARD) + _state = TB_SMALL; } - else // use internal icons according the settings - { - if (_state != TB_STANDARD) //If non standard icons, use custom imagelists - { - if (_state == TB_SMALL || _state == TB_LARGE) - { - if (NppDarkMode::isEnabled()) - { - setDefaultImageListDM(); - setDisableImageListDM(); - if (NppDarkMode::isWindows11()) - { - setHoveredImageListDM(); - } - } - else + if (_state != TB_STANDARD) //If non standard icons, use custom imagelists + { + if (_state == TB_SMALL || _state == TB_LARGE) + { + if (NppDarkMode::isEnabled()) + { + setDefaultImageListDM(); + setDisableImageListDM(); + + if (NppDarkMode::isWindows11()) { - setDefaultImageList(); - setDisableImageList(); + setHoveredImageListDM(); } } else { - if (NppDarkMode::isEnabled()) - { - setDefaultImageListDM2(); - setDisableImageListDM2(); - - if (NppDarkMode::isWindows11()) - { - setHoveredImageListDM2(); - } - } - else - { - setDefaultImageList2(); - setDisableImageList2(); - } + setDefaultImageList(); + setDisableImageList(); } } else { - //Else set the internal imagelist with standard bitmaps - int iconDpiDynamicalSize = NppParameters::getInstance()._dpiManager.scaleX(16); - ::SendMessage(_hSelf, TB_SETBITMAPSIZE, 0, MAKELPARAM(iconDpiDynamicalSize, iconDpiDynamicalSize)); + if (NppDarkMode::isEnabled()) + { + setDefaultImageListDM2(); + setDisableImageListDM2(); - TBADDBITMAP addbmp = { 0, 0 }; - TBADDBITMAP addbmpdyn = { 0, 0 }; - for (size_t i = 0; i < _nbButtons; ++i) - { - int icoID = _toolBarIcons.getStdIconAt(static_cast(i)); - HBITMAP hBmp = static_cast(::LoadImage(_hInst, MAKEINTRESOURCE(icoID), IMAGE_BITMAP, iconDpiDynamicalSize, iconDpiDynamicalSize, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT)); - addbmp.nID = reinterpret_cast(hBmp); - ::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast(&addbmp)); - } - if (_nbDynButtons > 0) - { - for (size_t j = 0; j < _nbDynButtons; ++j) + if (NppDarkMode::isWindows11()) { - addbmpdyn.nID = reinterpret_cast(_vDynBtnReg.at(j)._hBmp); - ::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast(&addbmpdyn)); + setHoveredImageListDM2(); } } + else + { + setDefaultImageList2(); + setDisableImageList2(); + } + } + } + else + { + //Else set the internal imagelist with standard bitmaps + int iconDpiDynamicalSize = NppParameters::getInstance()._dpiManager.scaleX(16); + ::SendMessage(_hSelf, TB_SETBITMAPSIZE, 0, MAKELPARAM(iconDpiDynamicalSize, iconDpiDynamicalSize)); + + TBADDBITMAP addbmp = { 0, 0 }; + TBADDBITMAP addbmpdyn = { 0, 0 }; + for (size_t i = 0; i < _nbButtons; ++i) + { + int icoID = _toolBarIcons.getStdIconAt(static_cast(i)); + HBITMAP hBmp = static_cast(::LoadImage(_hInst, MAKEINTRESOURCE(icoID), IMAGE_BITMAP, iconDpiDynamicalSize, iconDpiDynamicalSize, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT)); + addbmp.nID = reinterpret_cast(hBmp); + ::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast(&addbmp)); + } + if (_nbDynButtons > 0) + { + for (size_t j = 0; j < _nbDynButtons; ++j) + { + addbmpdyn.nID = reinterpret_cast(_vDynBtnReg.at(j)._hBmp); + ::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast(&addbmpdyn)); + } } } diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.h b/PowerEditor/src/WinControls/ToolBar/ToolBar.h index 447a4a8c5..3f897db3b 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.h +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.h @@ -82,7 +82,7 @@ public : return _state; }; - bool changeIcons() { + bool change2CustomIconsIfAny() { if (!_toolIcons) return false; for (size_t i = 0, len = _customIconVect.size(); i < len; ++i) @@ -113,6 +113,7 @@ private : ReBar * _pRebar = nullptr; REBARBANDINFO _rbBand = {}; std::vector _customIconVect; + TiXmlNode *_toolIcons = nullptr; void setDefaultImageList() {