Fix plugin icons added on toolbar not taking effect for Fluent UI icon sets
NPPM_ADDTOOLBARICON take structure struct toolbarIcons { HBITMAP hToolbarBmp; HICON hToolbarIcon; }; as argument, both hToolbarBmp & hToolbarIcon should not be null to take effect.
This commit is contained in:
parent
156bde258f
commit
9a2dcaa5f8
|
@ -55,6 +55,7 @@ IDI_CHAMELEON ICON "icons/chameleon.ico"
|
||||||
//IDI_JESUISCHARLIE ICON "icons/Je_suis_Charlie.ico"
|
//IDI_JESUISCHARLIE ICON "icons/Je_suis_Charlie.ico"
|
||||||
//IDI_GILETJAUNE ICON "icons/giletJaune.ico"
|
//IDI_GILETJAUNE ICON "icons/giletJaune.ico"
|
||||||
//IDI_SAMESEXMARRIAGE ICON "icons/same-sexMarriageTaiwan.ico"
|
//IDI_SAMESEXMARRIAGE ICON "icons/same-sexMarriageTaiwan.ico"
|
||||||
|
IDI_ICONABSENT ICON "icons/iconAbsent.ico"
|
||||||
|
|
||||||
//
|
//
|
||||||
// TOOLBAR ICO - set 1
|
// TOOLBAR ICO - set 1
|
||||||
|
|
|
@ -49,29 +49,7 @@ void IconList::addIcon(int iconID) const
|
||||||
ImageList_AddIcon(_hImglst, hIcon);
|
ImageList_AddIcon(_hImglst, hIcon);
|
||||||
::DestroyIcon(hIcon);
|
::DestroyIcon(hIcon);
|
||||||
};
|
};
|
||||||
/*
|
|
||||||
bool IconList::addInvertIcon(int iconID) const
|
|
||||||
{
|
|
||||||
HICON hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(iconID));
|
|
||||||
if (!hIcon)
|
|
||||||
throw std::runtime_error("IconList::addIcon : LoadIcon() function return null");
|
|
||||||
|
|
||||||
HICON hColorInvertedIcon = invertColour(hIcon);
|
|
||||||
|
|
||||||
if (hColorInvertedIcon)
|
|
||||||
ImageList_AddIcon(_hImglst, hColorInvertedIcon);
|
|
||||||
|
|
||||||
::DestroyIcon(hIcon);
|
|
||||||
|
|
||||||
return hColorInvertedIcon != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
HICON IconList::invertColour(HICON hIcon) const
|
|
||||||
{
|
|
||||||
// Light mode in, dark mode out
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void IconList::addIcon(HICON hIcon) const
|
void IconList::addIcon(HICON hIcon) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,6 @@ public :
|
||||||
};
|
};
|
||||||
HIMAGELIST getHandle() const {return _hImglst;};
|
HIMAGELIST getHandle() const {return _hImglst;};
|
||||||
void addIcon(int iconID) const;
|
void addIcon(int iconID) const;
|
||||||
//bool addInvertIcon(int iconID) const;
|
|
||||||
void addIcon(HICON hIcon) const;
|
void addIcon(HICON hIcon) const;
|
||||||
|
|
||||||
bool changeIcon(int index, const TCHAR *iconLocation) const;
|
bool changeIcon(int index, const TCHAR *iconLocation) const;
|
||||||
|
@ -48,8 +47,6 @@ private :
|
||||||
int *_pIconIDArray = nullptr;
|
int *_pIconIDArray = nullptr;
|
||||||
int _iconIDArraySize = 0;
|
int _iconIDArraySize = 0;
|
||||||
int _iconSize = 0;
|
int _iconSize = 0;
|
||||||
|
|
||||||
//HICON invertColour(HICON hIcon) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -21,9 +21,20 @@
|
||||||
#include "FindReplaceDlg_rc.h"
|
#include "FindReplaceDlg_rc.h"
|
||||||
|
|
||||||
#include "NppDarkMode.h"
|
#include "NppDarkMode.h"
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
const int WS_TOOLBARSTYLE = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER;
|
const int WS_TOOLBARSTYLE = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER;
|
||||||
|
|
||||||
|
ToolBar::ToolBar()
|
||||||
|
{
|
||||||
|
_hIconAbsent = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_ICONABSENT), IMAGE_ICON, 16, 16, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolBar::~ToolBar()
|
||||||
|
{
|
||||||
|
::DestroyIcon(_hIconAbsent);
|
||||||
|
}
|
||||||
|
|
||||||
void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
|
void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
|
||||||
{
|
{
|
||||||
_toolIcons = toolIconsDocRoot->FirstChild(TEXT("NotepadPlus"));
|
_toolIcons = toolIconsDocRoot->FirstChild(TEXT("NotepadPlus"));
|
||||||
|
@ -96,6 +107,7 @@ void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
|
||||||
bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBarButtonUnit *buttonUnitArray, int arraySize)
|
bool ToolBar::init( HINSTANCE hInst, HWND hPere, toolBarStatusType type, ToolBarButtonUnit *buttonUnitArray, int arraySize)
|
||||||
{
|
{
|
||||||
Window::init(hInst, hPere);
|
Window::init(hInst, hPere);
|
||||||
|
|
||||||
_state = type;
|
_state = type;
|
||||||
int iconSize = NppParameters::getInstance()._dpiManager.scaleX(_state == TB_LARGE || _state == TB_LARGE2 ? 32 : 16);
|
int iconSize = NppParameters::getInstance()._dpiManager.scaleX(_state == TB_LARGE || _state == TB_LARGE2 ? 32 : 16);
|
||||||
|
|
||||||
|
@ -351,22 +363,13 @@ void ToolBar::reset(bool create)
|
||||||
|
|
||||||
if (create)
|
if (create)
|
||||||
{ //if the toolbar has been recreated, readd the buttons
|
{ //if the toolbar has been recreated, readd the buttons
|
||||||
size_t nbBtnToAdd = (_state == TB_STANDARD?_nbTotalButtons:_nbButtons);
|
_nbCurrentButtons = _nbTotalButtons;
|
||||||
_nbCurrentButtons = nbBtnToAdd;
|
|
||||||
WORD btnSize = (_state == TB_LARGE?32:16);
|
WORD btnSize = (_state == TB_LARGE?32:16);
|
||||||
::SendMessage(_hSelf, TB_SETBUTTONSIZE , 0, MAKELONG(btnSize, btnSize));
|
::SendMessage(_hSelf, TB_SETBUTTONSIZE , 0, MAKELONG(btnSize, btnSize));
|
||||||
::SendMessage(_hSelf, TB_ADDBUTTONS, nbBtnToAdd, reinterpret_cast<LPARAM>(_pTBB));
|
::SendMessage(_hSelf, TB_ADDBUTTONS, _nbTotalButtons, reinterpret_cast<LPARAM>(_pTBB));
|
||||||
|
|
||||||
HIMAGELIST hImgLst = (HIMAGELIST)::SendMessage(_hSelf, TB_GETIMAGELIST, 0, 0);
|
|
||||||
for (size_t j = 0; j < _nbDynButtons; ++j)
|
|
||||||
{
|
|
||||||
ImageList_AddIcon(hImgLst, _vDynBtnReg.at(j)._hIcon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
::SendMessage(_hSelf, TB_AUTOSIZE, 0, 0);
|
::SendMessage(_hSelf, TB_AUTOSIZE, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (_pRebar)
|
if (_pRebar)
|
||||||
{
|
{
|
||||||
_rbBand.hwndChild = getHSelf();
|
_rbBand.hwndChild = getHSelf();
|
||||||
|
@ -387,7 +390,7 @@ void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* tIcon)
|
||||||
DynamicCmdIcoBmp dynList;
|
DynamicCmdIcoBmp dynList;
|
||||||
dynList._message = messageID;
|
dynList._message = messageID;
|
||||||
dynList._hBmp = tIcon->hToolbarBmp;
|
dynList._hBmp = tIcon->hToolbarBmp;
|
||||||
dynList._hIcon = tIcon->hToolbarIcon;
|
dynList._hIcon = tIcon->hToolbarIcon ? tIcon->hToolbarIcon : _hIconAbsent;
|
||||||
_vDynBtnReg.push_back(dynList);
|
_vDynBtnReg.push_back(dynList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,8 @@ class TiXmlNode;
|
||||||
class ToolBar : public Window
|
class ToolBar : public Window
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
ToolBar() = default;
|
ToolBar();
|
||||||
virtual ~ToolBar() = default;
|
~ToolBar();
|
||||||
|
|
||||||
void initTheme(TiXmlDocument *toolIconsDocRoot);
|
void initTheme(TiXmlDocument *toolIconsDocRoot);
|
||||||
virtual bool init(HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
virtual bool init(HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
||||||
|
@ -113,6 +113,7 @@ private :
|
||||||
REBARBANDINFO _rbBand;
|
REBARBANDINFO _rbBand;
|
||||||
std::vector<iconLocator> _customIconVect;
|
std::vector<iconLocator> _customIconVect;
|
||||||
TiXmlNode *_toolIcons = nullptr;
|
TiXmlNode *_toolIcons = nullptr;
|
||||||
|
HICON _hIconAbsent = nullptr;
|
||||||
|
|
||||||
void setDefaultImageList() {
|
void setDefaultImageList() {
|
||||||
::SendMessage(_hSelf, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(_toolBarIcons.getDefaultLst()));
|
::SendMessage(_hSelf, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(_toolBarIcons.getDefaultLst()));
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 790 B |
|
@ -39,6 +39,7 @@
|
||||||
//#define IDI_GILETJAUNE 102
|
//#define IDI_GILETJAUNE 102
|
||||||
//#define IDI_SAMESEXMARRIAGE 102
|
//#define IDI_SAMESEXMARRIAGE 102
|
||||||
#define IDR_RT_MANIFEST 103
|
#define IDR_RT_MANIFEST 103
|
||||||
|
#define IDI_ICONABSENT 104
|
||||||
|
|
||||||
//
|
//
|
||||||
// TOOLBAR ICO - set 1
|
// TOOLBAR ICO - set 1
|
||||||
|
|
Loading…
Reference in New Issue