mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 13:54:54 +02:00
Fix customizing toolbar icon messed with dark mode
Ref:
d85b9a7464 (commitcomment-74498214)
This commit is contained in:
parent
b25f37646d
commit
fa3ba7e389
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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<int32_t>(i));
|
||||
HBITMAP hBmp = static_cast<HBITMAP>(::LoadImage(_hInst, MAKEINTRESOURCE(icoID), IMAGE_BITMAP, iconDpiDynamicalSize, iconDpiDynamicalSize, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT));
|
||||
addbmp.nID = reinterpret_cast<UINT_PTR>(hBmp);
|
||||
::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast<LPARAM>(&addbmp));
|
||||
}
|
||||
if (_nbDynButtons > 0)
|
||||
{
|
||||
for (size_t j = 0; j < _nbDynButtons; ++j)
|
||||
if (NppDarkMode::isWindows11())
|
||||
{
|
||||
addbmpdyn.nID = reinterpret_cast<UINT_PTR>(_vDynBtnReg.at(j)._hBmp);
|
||||
::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast<LPARAM>(&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<int32_t>(i));
|
||||
HBITMAP hBmp = static_cast<HBITMAP>(::LoadImage(_hInst, MAKEINTRESOURCE(icoID), IMAGE_BITMAP, iconDpiDynamicalSize, iconDpiDynamicalSize, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT));
|
||||
addbmp.nID = reinterpret_cast<UINT_PTR>(hBmp);
|
||||
::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast<LPARAM>(&addbmp));
|
||||
}
|
||||
if (_nbDynButtons > 0)
|
||||
{
|
||||
for (size_t j = 0; j < _nbDynButtons; ++j)
|
||||
{
|
||||
addbmpdyn.nID = reinterpret_cast<UINT_PTR>(_vDynBtnReg.at(j)._hBmp);
|
||||
::SendMessage(_hSelf, TB_ADDBITMAP, 1, reinterpret_cast<LPARAM>(&addbmpdyn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<iconLocator> _customIconVect;
|
||||
|
||||
TiXmlNode *_toolIcons = nullptr;
|
||||
|
||||
void setDefaultImageList() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user