Use Explorer theme for list- and tree-views

Apply Explorer theme on list- and tree-views.
Allow dynamic change between dark and light mode in these views.
Add border to document switcher for consistency.
Refactor code in TreeView.cpp to make it consistent.

Fix #10055, close #10056
This commit is contained in:
ozone10 2021-06-22 14:44:53 +02:00 committed by Don Ho
parent 5df7c97f98
commit c8be679cde
11 changed files with 79 additions and 36 deletions

View File

@ -7545,6 +7545,15 @@ void Notepad_plus::refreshDarkMode()
::SendMessage(_pFileBrowser->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
}
if (_pAnsiCharPanel)
{
::SendMessage(_pAnsiCharPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
}
if (_pFileSwitcherPanel)
{
::SendMessage(_pFileSwitcherPanel->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
}
SendMessage(_findReplaceDlg.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
SendMessage(_incrementFindDlg.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
RedrawWindow(_pPublicInterface->getHSelf(), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN);

View File

@ -1115,4 +1115,10 @@ namespace NppDarkMode
::SendMessage(hwnd, TB_SETCOLORSCHEME, 0, reinterpret_cast<LPARAM>(&scheme));
}
void setExplorerTheme(HWND hwnd)
{
NppDarkMode::allowDarkModeForWindow(hwnd, NppDarkMode::isEnabled() && NppDarkMode::isExperimentalEnabled());
SetWindowTheme(hwnd, L"Explorer", nullptr);
}
}

View File

@ -86,4 +86,6 @@ namespace NppDarkMode
void setDarkTitleBar(HWND hwnd);
void setDarkTooltips(HWND hwnd, ToolTipsType type);
void setDarkLineAbovePanelToolbar(HWND hwnd);
void setExplorerTheme(HWND hwnd);
}

View File

@ -54,11 +54,13 @@ void ListView::init(HINSTANCE hInst, HWND parent)
throw std::runtime_error("ListView::init : CreateWindowEx() function return null");
}
NppDarkMode::setExplorerTheme(_hSelf);
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(staticProc)));
DWORD exStyle = ListView_GetExtendedListViewStyle(_hSelf);
exStyle |= LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT | _extraStyle;
exStyle |= LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT | LVS_EX_DOUBLEBUFFER | _extraStyle;
ListView_SetExtendedListViewStyle(_hSelf, exStyle);
if (_columnInfos.size())

View File

@ -27,10 +27,10 @@ void AnsiCharPanel::switchEncoding()
INT_PTR CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
{
switch (message)
{
case WM_INITDIALOG :
{
NppParameters& nppParam = NppParameters::getInstance();
NativeLangSpeaker *pNativeSpeaker = nppParam.getNativeLangSpeaker();
generic_string valStr = pNativeSpeaker->getAttrNameStr(TEXT("Value"), "AsciiInsertion", "ColumnVal");
@ -50,8 +50,14 @@ INT_PTR CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_listView.setValues(codepage==-1?0:codepage);
_listView.display();
return TRUE;
}
return TRUE;
}
case NPPM_INTERNAL_REFRESHDARKMODE:
{
NppDarkMode::setExplorerTheme(_listView.getHSelf());
return TRUE;
}
case WM_NOTIFY:
{

View File

@ -98,10 +98,10 @@ bool isRelatedRootFolder(const generic_string & relatedRoot, const generic_strin
INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
{
switch (message)
{
case WM_INITDIALOG :
{
NppParameters& nppParam = NppParameters::getInstance();
int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS | TBSTYLE_CUSTOMERASE;
_hToolbarMenu = CreateWindowEx(WS_EX_LAYOUTRTL, TOOLBARCLASSNAME, NULL, style, 0, 0, 0, 0, _hSelf, nullptr, _hInst, NULL);
@ -173,7 +173,8 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case NPPM_INTERNAL_REFRESHDARKMODE:
{
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
break;
NppDarkMode::setExplorerTheme(_treeView.getHSelf());
return TRUE;
}
case WM_MOUSEMOVE:

View File

@ -838,7 +838,8 @@ INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPA
case NPPM_INTERNAL_REFRESHDARKMODE:
{
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
break;
NppDarkMode::setExplorerTheme(_treeView.getHSelf());
return TRUE;
}
case WM_DESTROY:

View File

@ -44,10 +44,10 @@ ProjectPanel::~ProjectPanel()
INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
{
switch (message)
{
case WM_INITDIALOG :
{
ProjectPanel::initMenus();
// Create toolbar menu
@ -100,7 +100,8 @@ INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
case NPPM_INTERNAL_REFRESHDARKMODE:
{
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
break;
NppDarkMode::setExplorerTheme(_treeView.getHSelf());
return TRUE;
}
case WM_MOUSEMOVE:

View File

@ -26,17 +26,24 @@ void TreeView::init(HINSTANCE hInst, HWND parent, int treeViewID)
Window::init(hInst, parent);
_hSelf = ::GetDlgItem(parent, treeViewID);
_hSelf = CreateWindowEx(0,
WC_TREEVIEW,
TEXT("Tree View"),
WS_CHILD | WS_BORDER | WS_HSCROLL | WS_TABSTOP | TVS_LINESATROOT | TVS_HASLINES |
TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_EDITLABELS | TVS_INFOTIP,
0, 0, 0, 0,
_hParent,
NULL,
_hInst,
(LPVOID)0);
auto treeViewStyles = WS_HSCROLL | WS_TABSTOP | TVS_LINESATROOT\
| TVS_HASLINES | TVS_HASBUTTONS | TVS_SHOWSELALWAYS\
| TVS_EDITLABELS | TVS_INFOTIP | TVS_TRACKSELECT;
_hSelf = CreateWindowEx(0,
WC_TREEVIEW,
TEXT("Tree View"),
WS_CHILD | WS_BORDER | treeViewStyles,
0,
0,
0,
0,
_hParent,
nullptr,
_hInst,
nullptr);
NppDarkMode::setExplorerTheme(_hSelf);
NppDarkMode::setDarkTooltips(_hSelf, NppDarkMode::ToolTipsType::treeview);
int itemHeight = NppParameters::getInstance()._dpiManager.scaleY(CY_ITEMHEIGHT);

View File

@ -19,6 +19,7 @@
#include "VerticalFileSwitcher.h"
#include "menuCmdID.h"
#include "Parameters.h"
#include "resource.h"
int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
@ -59,16 +60,22 @@ void VerticalFileSwitcher::startColumnSort()
INT_PTR CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
{
switch (message)
{
case WM_INITDIALOG :
{
_fileListView.init(_hInst, _hSelf, _hImaLst);
_fileListView.initList();
_fileListView.display();
return TRUE;
}
return TRUE;
}
case NPPM_INTERNAL_REFRESHDARKMODE:
{
NppDarkMode::setExplorerTheme(_fileListView.getHSelf());
return TRUE;
}
case WM_NOTIFY:
{

View File

@ -41,7 +41,7 @@ void VerticalFileSwitcherListView::init(HINSTANCE hInst, HWND parent, HIMAGELIST
_hSelf = ::CreateWindow(WC_LISTVIEW,
TEXT(""),
WS_CHILD | listViewStyles,
WS_CHILD | WS_BORDER | listViewStyles,
0,
0,
0,
@ -55,12 +55,13 @@ void VerticalFileSwitcherListView::init(HINSTANCE hInst, HWND parent, HIMAGELIST
throw std::runtime_error("VerticalFileSwitcherListView::init : CreateWindowEx() function return null");
}
NppDarkMode::setExplorerTheme(_hSelf);
NppDarkMode::setDarkTooltips(_hSelf, NppDarkMode::ToolTipsType::listview);
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(staticProc)));
ListView_SetExtendedListViewStyle(_hSelf, LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT | LVS_EX_INFOTIP);
ListView_SetExtendedListViewStyle(_hSelf, LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT | LVS_EX_INFOTIP | LVS_EX_DOUBLEBUFFER);
ListView_SetItemCountEx(_hSelf, 50, LVSICF_NOSCROLL);
ListView_SetImageList(_hSelf, _hImaLst, LVSIL_SMALL);
}