Add fluent icons for treeview

ref #14959

Close #15532

Signed-off-by: ozone10 <positronix10@gmail.com>
This commit is contained in:
ozone10 2024-08-10 18:50:55 +02:00 committed by Don Ho
parent ae1d09cab8
commit f751ecaf04
31 changed files with 189 additions and 31 deletions

View File

@ -370,6 +370,26 @@ IDI_PROJECT_FILEINVALID ICON "icons/standard/panels/treeview/proj
IDI_FB_ROOTOPEN ICON "icons/standard/panels/treeview/fb_root_open.ico"
IDI_FB_ROOTCLOSE ICON "icons/standard/panels/treeview/fb_root_close.ico"
IDI_PROJECT_WORKSPACE_DM ICON "icons/dark/panels/treeview/project_work_space.ico"
IDI_PROJECT_WORKSPACEDIRTY_DM ICON "icons/dark/panels/treeview/project_work_space_dirty.ico"
IDI_PROJECT_PROJECT_DM ICON "icons/dark/panels/treeview/project_root.ico"
IDI_PROJECT_FOLDEROPEN_DM ICON "icons/dark/panels/treeview/project_folder_open.ico"
IDI_PROJECT_FOLDERCLOSE_DM ICON "icons/dark/panels/treeview/project_folder_close.ico"
IDI_PROJECT_FILE_DM ICON "icons/dark/panels/treeview/project_file.ico"
IDI_PROJECT_FILEINVALID_DM ICON "icons/dark/panels/treeview/project_file_invalid.ico"
IDI_FB_ROOTOPEN_DM ICON "icons/dark/panels/treeview/fb_root_open.ico"
IDI_FB_ROOTCLOSE_DM ICON "icons/dark/panels/treeview/fb_root_close.ico"
IDI_PROJECT_WORKSPACE2 ICON "icons/light/panels/treeview/project_work_space.ico"
IDI_PROJECT_WORKSPACEDIRTY2 ICON "icons/light/panels/treeview/project_work_space_dirty.ico"
IDI_PROJECT_PROJECT2 ICON "icons/light/panels/treeview/project_root.ico"
IDI_PROJECT_FOLDEROPEN2 ICON "icons/light/panels/treeview/project_folder_open.ico"
IDI_PROJECT_FOLDERCLOSE2 ICON "icons/light/panels/treeview/project_folder_close.ico"
IDI_PROJECT_FILE2 ICON "icons/light/panels/treeview/project_file.ico"
IDI_PROJECT_FILEINVALID2 ICON "icons/light/panels/treeview/project_file_invalid.ico"
IDI_FB_ROOTOPEN2 ICON "icons/light/panels/treeview/fb_root_open.ico"
IDI_FB_ROOTCLOSE2 ICON "icons/light/panels/treeview/fb_root_close.ico"
IDI_FB_SELECTCURRENTFILE ICON "icons/standard/panels/toolbar/fb_select_current_file.ico"
IDI_FB_FOLDALL ICON "icons/standard/panels/toolbar/fb_fold_all.ico"
IDI_FB_EXPANDALL ICON "icons/standard/panels/toolbar/fb_expand_all.ico"
@ -381,6 +401,12 @@ IDI_FB_EXPANDALL_DM ICON "icons/dark/panels/toolbar/fb_expand
IDI_FUNCLIST_NODE ICON "icons/standard/panels/treeview/funcList_node.ico"
IDI_FUNCLIST_LEAF ICON "icons/standard/panels/treeview/funcList_leaf.ico"
IDI_FUNCLIST_NODE_DM ICON "icons/dark/panels/treeview/funcList_node.ico"
IDI_FUNCLIST_LEAF_DM ICON "icons/dark/panels/treeview/funcList_leaf.ico"
IDI_FUNCLIST_NODE2 ICON "icons/light/panels/treeview/funcList_node.ico"
IDI_FUNCLIST_LEAF2 ICON "icons/light/panels/treeview/funcList_leaf.ico"
IDI_FUNCLIST_SORTBUTTON ICON "icons/standard/panels/toolbar/funclstSort.ico"
IDI_FUNCLIST_RELOADBUTTON ICON "icons/standard/panels/toolbar/funclstReload.ico"
IDI_FUNCLIST_PREFERENCEBUTTON ICON "icons/standard/panels/toolbar/funclstPreferences.ico"

View File

@ -3253,6 +3253,12 @@ namespace NppDarkMode
}
}
TreeViewStyle getTreeViewStyle()
{
const auto style = g_treeViewStyle;
return style;
}
void setTreeViewStyle(HWND hwnd)
{
auto style = static_cast<long>(::GetWindowLongPtr(hwnd, GWL_STYLE));

View File

@ -226,6 +226,7 @@ namespace NppDarkMode
void disableVisualStyle(HWND hwnd, bool doDisable);
void calculateTreeViewStyle();
TreeViewStyle getTreeViewStyle();
void setTreeViewStyle(HWND hwnd);
bool isThemeDark();
void setBorder(HWND hwnd, bool border = true);

View File

@ -180,7 +180,12 @@ intptr_t CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
FileBrowser::initPopupMenus();
std::vector<int> imgIds{ IDI_FB_ROOTOPEN, IDI_FB_ROOTCLOSE, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE };
std::vector<int> imgIds = _treeView.getImageIds(
{ IDI_FB_ROOTOPEN, IDI_FB_ROOTCLOSE, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE }
, { IDI_FB_ROOTOPEN_DM, IDI_FB_ROOTCLOSE_DM, IDI_PROJECT_FOLDEROPEN_DM, IDI_PROJECT_FOLDERCLOSE_DM, IDI_PROJECT_FILE_DM }
, { IDI_FB_ROOTOPEN2, IDI_FB_ROOTCLOSE2, IDI_PROJECT_FOLDEROPEN2, IDI_PROJECT_FOLDERCLOSE2, IDI_PROJECT_FILE2 }
);
_treeView.init(_hInst, _hSelf, ID_FILEBROWSERTREEVIEW);
_treeView.setImageList(imgIds);
@ -213,6 +218,15 @@ intptr_t CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
::SendMessage(_hToolbarMenu, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(_iconListVector.at(NppDarkMode::isEnabled() ? 1 : 0)));
}
NppDarkMode::setTreeViewStyle(_treeView.getHSelf());
std::vector<int> imgIds = _treeView.getImageIds(
{ IDI_FB_ROOTOPEN, IDI_FB_ROOTCLOSE, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE }
, { IDI_FB_ROOTOPEN_DM, IDI_FB_ROOTCLOSE_DM, IDI_PROJECT_FOLDEROPEN_DM, IDI_PROJECT_FOLDERCLOSE_DM, IDI_PROJECT_FILE_DM }
, { IDI_FB_ROOTOPEN2, IDI_FB_ROOTCLOSE2, IDI_PROJECT_FOLDEROPEN2, IDI_PROJECT_FOLDERCLOSE2, IDI_PROJECT_FILE2 }
);
_treeView.setImageList(imgIds);
return TRUE;
}

View File

@ -837,7 +837,7 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
{
FunctionListPanel::initPreferencesMenu();
NppParameters& nppParams = NppParameters::getInstance();
NppParameters& nppParam = NppParameters::getInstance();
setDpi();
const int editWidth = _dpiManager.scale(100);
@ -919,7 +919,7 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
ShowWindow(_hToolbarMenu, SW_SHOW);
// tips text for toolbar buttons
NativeLangSpeaker *pNativeSpeaker = nppParams.getNativeLangSpeaker();
NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker();
_sortTipStr = pNativeSpeaker->getAttrNameStr(_sortTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_SORTLOCALNODENAME);
_reloadTipStr = pNativeSpeaker->getAttrNameStr(_reloadTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_RELOADLOCALNODENAME);
_preferenceTipStr = pNativeSpeaker->getAttrNameStr(_preferenceTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_PREFERENCESLOCALNODENAME);
@ -943,7 +943,12 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
::SendMessage(_hSearchEdit, WM_SETFONT, reinterpret_cast<WPARAM>(_hFontSearchEdit), MAKELPARAM(TRUE, 0));
}
std::vector<int> imgIds{ IDI_FUNCLIST_ROOT, IDI_FUNCLIST_NODE, IDI_FUNCLIST_LEAF };
std::vector<int> imgIds = _treeView.getImageIds(
{ IDI_FUNCLIST_ROOT, IDI_FUNCLIST_NODE, IDI_FUNCLIST_LEAF }
, { IDI_FUNCLIST_ROOT_DM, IDI_FUNCLIST_NODE_DM, IDI_FUNCLIST_LEAF_DM }
, { IDI_FUNCLIST_ROOT2, IDI_FUNCLIST_NODE2, IDI_FUNCLIST_LEAF2 }
);
_treeView.init(_hInst, _hSelf, IDC_LIST_FUNCLIST);
_treeView.setImageList(imgIds);
_treeViewSearchResult.init(_hInst, _hSelf, IDC_LIST_FUNCLIST_AUX);
@ -967,6 +972,16 @@ intptr_t CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LP
::SendMessage(_hToolbarMenu, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(_iconListVector.at(NppDarkMode::isEnabled() ? 1 : 0)));
}
NppDarkMode::setTreeViewStyle(_treeView.getHSelf());
std::vector<int> imgIds = _treeView.getImageIds(
{ IDI_FUNCLIST_ROOT, IDI_FUNCLIST_NODE, IDI_FUNCLIST_LEAF }
, { IDI_FUNCLIST_ROOT_DM, IDI_FUNCLIST_NODE_DM, IDI_FUNCLIST_LEAF_DM }
, { IDI_FUNCLIST_ROOT2, IDI_FUNCLIST_NODE2, IDI_FUNCLIST_LEAF2 }
);
_treeView.setImageList(imgIds);
_treeViewSearchResult.setImageList(imgIds);
return TRUE;
}

View File

@ -56,7 +56,8 @@ intptr_t CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
TBBUTTON tbButtons[2]{};
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
NppParameters& nppParam = NppParameters::getInstance();
NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker();
wstring workspace_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 0, PM_WORKSPACEMENUENTRY);
wstring edit_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 1, PM_EDITMENUENTRY);
@ -77,7 +78,12 @@ intptr_t CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0);
ShowWindow(_hToolbarMenu, SW_SHOW);
std::vector<int> imgIds{ IDI_PROJECT_WORKSPACE, IDI_PROJECT_WORKSPACEDIRTY, IDI_PROJECT_PROJECT, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE, IDI_PROJECT_FILEINVALID };
std::vector<int> imgIds = _treeView.getImageIds(
{ IDI_PROJECT_WORKSPACE, IDI_PROJECT_WORKSPACEDIRTY, IDI_PROJECT_PROJECT, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE, IDI_PROJECT_FILEINVALID }
, { IDI_PROJECT_WORKSPACE_DM, IDI_PROJECT_WORKSPACEDIRTY_DM, IDI_PROJECT_PROJECT_DM, IDI_PROJECT_FOLDEROPEN_DM, IDI_PROJECT_FOLDERCLOSE_DM, IDI_PROJECT_FILE_DM, IDI_PROJECT_FILEINVALID_DM }
, { IDI_PROJECT_WORKSPACE2, IDI_PROJECT_WORKSPACEDIRTY2, IDI_PROJECT_PROJECT2, IDI_PROJECT_FOLDEROPEN2, IDI_PROJECT_FOLDERCLOSE2, IDI_PROJECT_FILE2, IDI_PROJECT_FILEINVALID2 }
);
_treeView.init(_hInst, _hSelf, ID_PROJECTTREEVIEW);
_treeView.setImageList(imgIds);
@ -105,6 +111,15 @@ intptr_t CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
NppDarkMode::autoThemeChildControls(_hSelf);
}
NppDarkMode::setTreeViewStyle(_treeView.getHSelf());
std::vector<int> imgIds = _treeView.getImageIds(
{ IDI_PROJECT_WORKSPACE, IDI_PROJECT_WORKSPACEDIRTY, IDI_PROJECT_PROJECT, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE, IDI_PROJECT_FILEINVALID }
, { IDI_PROJECT_WORKSPACE_DM, IDI_PROJECT_WORKSPACEDIRTY_DM, IDI_PROJECT_PROJECT_DM, IDI_PROJECT_FOLDEROPEN_DM, IDI_PROJECT_FOLDERCLOSE_DM, IDI_PROJECT_FILE_DM, IDI_PROJECT_FILEINVALID_DM }
, { IDI_PROJECT_WORKSPACE2, IDI_PROJECT_WORKSPACEDIRTY2, IDI_PROJECT_PROJECT2, IDI_PROJECT_FOLDEROPEN2, IDI_PROJECT_FOLDERCLOSE2, IDI_PROJECT_FILE2, IDI_PROJECT_FILEINVALID2 }
);
_treeView.setImageList(imgIds);
return TRUE;
}

View File

@ -289,6 +289,25 @@ bool TreeView::setImageList(const std::vector<int>& imageIds, int imgSize)
// Creation of image list
int dpiImgSize = DPIManagerV2::scale(imgSize, _hParent);
NppParameters& nppParam = NppParameters::getInstance();
const bool useStdIcons = nppParam.getNppGUI()._toolBarStatus == TB_STANDARD;
if (_hImaLst != nullptr)
{
int prevImageSize = 0;
::ImageList_GetIconSize(_hImaLst, &prevImageSize, nullptr);
if ((prevImageSize != dpiImgSize) || (!(useStdIcons && _tvStyleType == NppDarkMode::TreeViewStyle::classic) && _tvStyleType != NppDarkMode::getTreeViewStyle()))
{
::ImageList_Destroy(_hImaLst);
_hImaLst = nullptr;
}
else
return false;
}
if (_hImaLst == nullptr)
{
if ((_hImaLst = ::ImageList_Create(dpiImgSize, dpiImgSize, ILC_COLOR32 | ILC_MASK, nbImage, 0)) == nullptr)
return false;
@ -303,13 +322,44 @@ bool TreeView::setImageList(const std::vector<int>& imageIds, int imgSize)
::ImageList_AddIcon(_hImaLst, hIcon);
::DestroyIcon(hIcon);
}
}
// Set image list to the tree view
TreeView_SetImageList(_hSelf, _hImaLst, TVSIL_NORMAL);
_tvStyleType = useStdIcons ? NppDarkMode::TreeViewStyle::classic : NppDarkMode::getTreeViewStyle();
return true;
}
std::vector<int> TreeView::getImageIds(std::vector<int> stdIds, std::vector<int> darkIds, std::vector<int> lightIds)
{
NppParameters& nppParam = NppParameters::getInstance();
const bool useStdIcons = nppParam.getNppGUI()._toolBarStatus == TB_STANDARD;
if (useStdIcons)
{
return stdIds;
}
switch (NppDarkMode::getTreeViewStyle())
{
case NppDarkMode::TreeViewStyle::light:
{
return lightIds;
}
case NppDarkMode::TreeViewStyle::dark:
{
return darkIds;
}
case NppDarkMode::TreeViewStyle::classic:
{
return stdIds;
}
}
return stdIds;
}
void TreeView::cleanSubEntries(HTREEITEM hTreeItem)
{
for (HTREEITEM hItem = getChildFrom(hTreeItem); hItem != NULL; hItem = getNextSibling(hItem))

View File

@ -20,6 +20,7 @@
#include <commctrl.h>
#include "Window.h"
#include "Common.h"
#include "NppDarkMode.h"
struct TreeStateNode {
std::wstring _label;
@ -117,9 +118,11 @@ public:
void sort(HTREEITEM hTreeItem, bool isRecusive);
void customSorting(HTREEITEM hTreeItem, PFNTVCOMPARE sortingCallbackFunc, LPARAM lParam, bool isRecursive);
bool setImageList(const std::vector<int>& imageIds, int imgSize = 0);
std::vector<int> getImageIds(std::vector<int> stdIds, std::vector<int>darkIds, std::vector<int> lightIds);
protected:
HIMAGELIST _hImaLst = nullptr;
NppDarkMode::TreeViewStyle _tvStyleType = NppDarkMode::TreeViewStyle::classic;
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK staticProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
@ -141,4 +144,3 @@ protected:
bool canDragOut(HTREEITEM targetItem);
bool canDropIn(HTREEITEM targetItem);
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

View File

@ -276,28 +276,57 @@
#define IDI_PROJECT_FILEINVALID 607
#define IDI_FB_ROOTOPEN 608
#define IDI_FB_ROOTCLOSE 609
#define IDI_FB_SELECTCURRENTFILE 610
#define IDI_FB_FOLDALL 611
#define IDI_FB_EXPANDALL 612
#define IDI_FB_SELECTCURRENTFILE_DM 613
#define IDI_FB_FOLDALL_DM 614
#define IDI_FB_EXPANDALL_DM 615
#define IDI_PROJECT_WORKSPACE_DM 611
#define IDI_PROJECT_WORKSPACEDIRTY_DM 612
#define IDI_PROJECT_PROJECT_DM 613
#define IDI_PROJECT_FOLDEROPEN_DM 614
#define IDI_PROJECT_FOLDERCLOSE_DM 615
#define IDI_PROJECT_FILE_DM 616
#define IDI_PROJECT_FILEINVALID_DM 617
#define IDI_FB_ROOTOPEN_DM 618
#define IDI_FB_ROOTCLOSE_DM 619
#define IDI_PROJECT_WORKSPACE2 621
#define IDI_PROJECT_WORKSPACEDIRTY2 622
#define IDI_PROJECT_PROJECT2 623
#define IDI_PROJECT_FOLDEROPEN2 624
#define IDI_PROJECT_FOLDERCLOSE2 625
#define IDI_PROJECT_FILE2 626
#define IDI_PROJECT_FILEINVALID2 627
#define IDI_FB_ROOTOPEN2 628
#define IDI_FB_ROOTCLOSE2 629
#define IDI_FB_SELECTCURRENTFILE 630
#define IDI_FB_FOLDALL 631
#define IDI_FB_EXPANDALL 632
#define IDI_FB_SELECTCURRENTFILE_DM 633
#define IDI_FB_FOLDALL_DM 634
#define IDI_FB_EXPANDALL_DM 635
#define IDI_FUNCLIST_ROOT IDI_PROJECT_FILE // using same file
#define IDI_FUNCLIST_NODE 621
#define IDI_FUNCLIST_LEAF 622
#define IDI_FUNCLIST_NODE 641
#define IDI_FUNCLIST_LEAF 642
#define IDI_FUNCLIST_SORTBUTTON 631
#define IDI_FUNCLIST_RELOADBUTTON 632
#define IDI_FUNCLIST_PREFERENCEBUTTON 633
#define IDI_FUNCLIST_SORTBUTTON_DM 634
#define IDI_FUNCLIST_RELOADBUTTON_DM 635
#define IDI_FUNCLIST_PREFERENCEBUTTON_DM 636
#define IDI_FUNCLIST_ROOT_DM IDI_PROJECT_FILE_DM // using same file
#define IDI_FUNCLIST_NODE_DM 644
#define IDI_FUNCLIST_LEAF_DM 645
#define IDI_FUNCLIST_ROOT2 IDI_PROJECT_FILE2 // using same file
#define IDI_FUNCLIST_NODE2 647
#define IDI_FUNCLIST_LEAF2 648
#define IDI_FUNCLIST_SORTBUTTON 651
#define IDI_FUNCLIST_RELOADBUTTON 652
#define IDI_FUNCLIST_PREFERENCEBUTTON 653
#define IDI_FUNCLIST_SORTBUTTON_DM 654
#define IDI_FUNCLIST_RELOADBUTTON_DM 655
#define IDI_FUNCLIST_PREFERENCEBUTTON_DM 656
#define IDI_GET_INFO_FROM_TOOLTIP 641
#define IDI_GET_INFO_FROM_TOOLTIP 661