parent
eac8c4094f
commit
066ef8a4a0
|
@ -17,7 +17,7 @@ enum IMMERSIVE_HC_CACHE_MODE
|
||||||
};
|
};
|
||||||
|
|
||||||
// 1903 18362
|
// 1903 18362
|
||||||
enum PreferredAppMode
|
enum class PreferredAppMode
|
||||||
{
|
{
|
||||||
Default,
|
Default,
|
||||||
AllowDark,
|
AllowDark,
|
||||||
|
@ -85,7 +85,7 @@ fnSetWindowCompositionAttribute _SetWindowCompositionAttribute = nullptr;
|
||||||
fnShouldAppsUseDarkMode _ShouldAppsUseDarkMode = nullptr;
|
fnShouldAppsUseDarkMode _ShouldAppsUseDarkMode = nullptr;
|
||||||
fnAllowDarkModeForWindow _AllowDarkModeForWindow = nullptr;
|
fnAllowDarkModeForWindow _AllowDarkModeForWindow = nullptr;
|
||||||
fnAllowDarkModeForApp _AllowDarkModeForApp = nullptr;
|
fnAllowDarkModeForApp _AllowDarkModeForApp = nullptr;
|
||||||
//fnFlushMenuThemes _FlushMenuThemes = nullptr;
|
fnFlushMenuThemes _FlushMenuThemes = nullptr;
|
||||||
fnRefreshImmersiveColorPolicyState _RefreshImmersiveColorPolicyState = nullptr;
|
fnRefreshImmersiveColorPolicyState _RefreshImmersiveColorPolicyState = nullptr;
|
||||||
fnIsDarkModeAllowedForWindow _IsDarkModeAllowedForWindow = nullptr;
|
fnIsDarkModeAllowedForWindow _IsDarkModeAllowedForWindow = nullptr;
|
||||||
fnGetIsImmersiveColorUsingHighContrast _GetIsImmersiveColorUsingHighContrast = nullptr;
|
fnGetIsImmersiveColorUsingHighContrast _GetIsImmersiveColorUsingHighContrast = nullptr;
|
||||||
|
@ -173,7 +173,15 @@ void AllowDarkModeForApp(bool allow)
|
||||||
if (_AllowDarkModeForApp)
|
if (_AllowDarkModeForApp)
|
||||||
_AllowDarkModeForApp(allow);
|
_AllowDarkModeForApp(allow);
|
||||||
else if (_SetPreferredAppMode)
|
else if (_SetPreferredAppMode)
|
||||||
_SetPreferredAppMode(allow ? ForceDark : Default);
|
_SetPreferredAppMode(allow ? PreferredAppMode::ForceDark : PreferredAppMode::Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlushMenuThemes()
|
||||||
|
{
|
||||||
|
if (_FlushMenuThemes)
|
||||||
|
{
|
||||||
|
_FlushMenuThemes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// limit dark scroll bar to specific windows and their children
|
// limit dark scroll bar to specific windows and their children
|
||||||
|
@ -204,7 +212,7 @@ bool IsWindowOrParentUsingDarkScrollBar(HWND hwnd)
|
||||||
|
|
||||||
void FixDarkScrollBar()
|
void FixDarkScrollBar()
|
||||||
{
|
{
|
||||||
HMODULE hComctl = LoadLibraryExW(L"comctl32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
HMODULE hComctl = LoadLibraryEx(L"comctl32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||||
if (hComctl)
|
if (hComctl)
|
||||||
{
|
{
|
||||||
auto addr = FindDelayLoadThunkInModule(hComctl, "uxtheme.dll", 49); // OpenNcThemeData
|
auto addr = FindDelayLoadThunkInModule(hComctl, "uxtheme.dll", 49); // OpenNcThemeData
|
||||||
|
@ -241,9 +249,9 @@ constexpr bool CheckBuildNumber(DWORD buildNumber)
|
||||||
buildNumber == 19043); // 21H1
|
buildNumber == 19043); // 21H1
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitDarkMode(bool fixDarkScrollbar, bool dark)
|
void InitDarkMode()
|
||||||
{
|
{
|
||||||
auto RtlGetNtVersionNumbers = reinterpret_cast<fnRtlGetNtVersionNumbers>(GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetNtVersionNumbers"));
|
auto RtlGetNtVersionNumbers = reinterpret_cast<fnRtlGetNtVersionNumbers>(GetProcAddress(GetModuleHandle(L"ntdll.dll"), "RtlGetNtVersionNumbers"));
|
||||||
if (RtlGetNtVersionNumbers)
|
if (RtlGetNtVersionNumbers)
|
||||||
{
|
{
|
||||||
DWORD major, minor;
|
DWORD major, minor;
|
||||||
|
@ -251,7 +259,7 @@ void InitDarkMode(bool fixDarkScrollbar, bool dark)
|
||||||
g_buildNumber &= ~0xF0000000;
|
g_buildNumber &= ~0xF0000000;
|
||||||
if (major == 10 && minor == 0 && CheckBuildNumber(g_buildNumber))
|
if (major == 10 && minor == 0 && CheckBuildNumber(g_buildNumber))
|
||||||
{
|
{
|
||||||
HMODULE hUxtheme = LoadLibraryExW(L"uxtheme.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
HMODULE hUxtheme = LoadLibraryEx(L"uxtheme.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||||
if (hUxtheme)
|
if (hUxtheme)
|
||||||
{
|
{
|
||||||
_OpenNcThemeData = reinterpret_cast<fnOpenNcThemeData>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(49)));
|
_OpenNcThemeData = reinterpret_cast<fnOpenNcThemeData>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(49)));
|
||||||
|
@ -266,7 +274,7 @@ void InitDarkMode(bool fixDarkScrollbar, bool dark)
|
||||||
else
|
else
|
||||||
_SetPreferredAppMode = reinterpret_cast<fnSetPreferredAppMode>(ord135);
|
_SetPreferredAppMode = reinterpret_cast<fnSetPreferredAppMode>(ord135);
|
||||||
|
|
||||||
//_FlushMenuThemes = reinterpret_cast<fnFlushMenuThemes>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(136)));
|
_FlushMenuThemes = reinterpret_cast<fnFlushMenuThemes>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(136)));
|
||||||
_IsDarkModeAllowedForWindow = reinterpret_cast<fnIsDarkModeAllowedForWindow>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(137)));
|
_IsDarkModeAllowedForWindow = reinterpret_cast<fnIsDarkModeAllowedForWindow>(GetProcAddress(hUxtheme, MAKEINTRESOURCEA(137)));
|
||||||
|
|
||||||
_SetWindowCompositionAttribute = reinterpret_cast<fnSetWindowCompositionAttribute>(GetProcAddress(GetModuleHandleW(L"user32.dll"), "SetWindowCompositionAttribute"));
|
_SetWindowCompositionAttribute = reinterpret_cast<fnSetWindowCompositionAttribute>(GetProcAddress(GetModuleHandleW(L"user32.dll"), "SetWindowCompositionAttribute"));
|
||||||
|
@ -276,22 +284,27 @@ void InitDarkMode(bool fixDarkScrollbar, bool dark)
|
||||||
_ShouldAppsUseDarkMode &&
|
_ShouldAppsUseDarkMode &&
|
||||||
_AllowDarkModeForWindow &&
|
_AllowDarkModeForWindow &&
|
||||||
(_AllowDarkModeForApp || _SetPreferredAppMode) &&
|
(_AllowDarkModeForApp || _SetPreferredAppMode) &&
|
||||||
//_FlushMenuThemes &&
|
_FlushMenuThemes &&
|
||||||
_IsDarkModeAllowedForWindow)
|
_IsDarkModeAllowedForWindow)
|
||||||
{
|
{
|
||||||
g_darkModeSupported = true;
|
g_darkModeSupported = true;
|
||||||
|
|
||||||
AllowDarkModeForApp(dark);
|
|
||||||
_RefreshImmersiveColorPolicyState();
|
|
||||||
|
|
||||||
g_darkModeEnabled = _ShouldAppsUseDarkMode() && !IsHighContrast();
|
|
||||||
|
|
||||||
if (fixDarkScrollbar)
|
|
||||||
{
|
|
||||||
FixDarkScrollBar();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetDarkMode(bool useDark, bool fixDarkScrollbar)
|
||||||
|
{
|
||||||
|
if (g_darkModeSupported)
|
||||||
|
{
|
||||||
|
AllowDarkModeForApp(useDark);
|
||||||
|
//_RefreshImmersiveColorPolicyState();
|
||||||
|
FlushMenuThemes();
|
||||||
|
if (useDark && fixDarkScrollbar)
|
||||||
|
{
|
||||||
|
FixDarkScrollBar();
|
||||||
|
}
|
||||||
|
g_darkModeEnabled = ShouldAppsUseDarkMode() && !IsHighContrast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,5 +13,5 @@ bool IsColorSchemeChangeMessage(LPARAM lParam);
|
||||||
bool IsColorSchemeChangeMessage(UINT message, LPARAM lParam);
|
bool IsColorSchemeChangeMessage(UINT message, LPARAM lParam);
|
||||||
void AllowDarkModeForApp(bool allow);
|
void AllowDarkModeForApp(bool allow);
|
||||||
void EnableDarkScrollBarForWindowAndChildren(HWND hwnd);
|
void EnableDarkScrollBarForWindowAndChildren(HWND hwnd);
|
||||||
void InitDarkMode(bool fixDarkScrollbar, bool dark);
|
void InitDarkMode();
|
||||||
|
void SetDarkMode(bool useDarkMode, bool fixDarkScrollbar);
|
||||||
|
|
|
@ -7515,7 +7515,7 @@ void Notepad_plus::restoreMinimizeDialogs()
|
||||||
void Notepad_plus::refreshDarkMode()
|
void Notepad_plus::refreshDarkMode()
|
||||||
{
|
{
|
||||||
SendMessage(_pPublicInterface->getHSelf(), NPPM_SETEDITORBORDEREDGE, 0, NppParameters::getInstance().getSVP()._showBorderEdge);
|
SendMessage(_pPublicInterface->getHSelf(), NPPM_SETEDITORBORDEREDGE, 0, NppParameters::getInstance().getSVP()._showBorderEdge);
|
||||||
if (NppDarkMode::isExperimentalEnabled())
|
if (NppDarkMode::isExperimentalSupported())
|
||||||
{
|
{
|
||||||
NppDarkMode::allowDarkModeForApp(NppDarkMode::isEnabled());
|
NppDarkMode::allowDarkModeForApp(NppDarkMode::isEnabled());
|
||||||
}
|
}
|
||||||
|
@ -7640,7 +7640,7 @@ void Notepad_plus::refreshDarkMode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NppDarkMode::isExperimentalEnabled())
|
if (NppDarkMode::isExperimentalSupported())
|
||||||
{
|
{
|
||||||
RECT rcClient;
|
RECT rcClient;
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ LRESULT CALLBACK Notepad_plus_Window::Notepad_plus_Proc(HWND hwnd, UINT message,
|
||||||
pM30ide->_hSelf = hwnd;
|
pM30ide->_hSelf = hwnd;
|
||||||
::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pM30ide));
|
::SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pM30ide));
|
||||||
|
|
||||||
if (NppDarkMode::isExperimentalEnabled() && NppDarkMode::isEnabled() && NppDarkMode::isScrollbarHackEnabled())
|
if (NppDarkMode::isExperimentalSupported())
|
||||||
{
|
{
|
||||||
NppDarkMode::enableDarkScrollBarForWindowAndChildren(hwnd);
|
NppDarkMode::enableDarkScrollBarForWindowAndChildren(hwnd);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ LRESULT Notepad_plus_Window::runProc(HWND hwnd, UINT message, WPARAM wParam, LPA
|
||||||
_notepad_plus_plus_core._pPublicInterface = this;
|
_notepad_plus_plus_core._pPublicInterface = this;
|
||||||
LRESULT lRet = _notepad_plus_plus_core.init(hwnd);
|
LRESULT lRet = _notepad_plus_plus_core.init(hwnd);
|
||||||
|
|
||||||
if (NppDarkMode::isExperimentalEnabled() && NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled() && NppDarkMode::isExperimentalSupported())
|
||||||
{
|
{
|
||||||
RECT rcClient;
|
RECT rcClient;
|
||||||
GetWindowRect(hwnd, &rcClient);
|
GetWindowRect(hwnd, &rcClient);
|
||||||
|
|
|
@ -97,10 +97,8 @@ namespace NppDarkMode
|
||||||
{
|
{
|
||||||
_options = configuredOptions();
|
_options = configuredOptions();
|
||||||
|
|
||||||
if (_options.enableExperimental)
|
initExperimentalDarkMode();
|
||||||
{
|
setDarkMode(_options.enable, _options.enableScrollbarHack);
|
||||||
initExperimentalDarkMode(_options.enableScrollbarHack, _options.enable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempts to apply new options from NppParameters, sends NPPM_INTERNAL_REFRESHDARKMODE to hwnd's top level parent
|
// attempts to apply new options from NppParameters, sends NPPM_INTERNAL_REFRESHDARKMODE to hwnd's top level parent
|
||||||
|
@ -114,6 +112,7 @@ namespace NppDarkMode
|
||||||
{
|
{
|
||||||
supportedChanged = true;
|
supportedChanged = true;
|
||||||
_options.enable = config.enable;
|
_options.enable = config.enable;
|
||||||
|
setDarkMode(_options.enable, _options.enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_options.enableMenubar != config.enableMenubar)
|
if (_options.enableMenubar != config.enableMenubar)
|
||||||
|
@ -144,11 +143,6 @@ namespace NppDarkMode
|
||||||
return _options.enableMenubar;
|
return _options.enableMenubar;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isExperimentalEnabled()
|
|
||||||
{
|
|
||||||
return _options.enableExperimental;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isScrollbarHackEnabled()
|
bool isScrollbarHackEnabled()
|
||||||
{
|
{
|
||||||
return _options.enableScrollbarHack;
|
return _options.enableScrollbarHack;
|
||||||
|
@ -215,7 +209,7 @@ namespace NppDarkMode
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(hwnd);
|
UNREFERENCED_PARAMETER(hwnd);
|
||||||
|
|
||||||
if (!isExperimentalEnabled())
|
if (!isExperimentalSupported())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -386,9 +380,14 @@ namespace NppDarkMode
|
||||||
|
|
||||||
// from DarkMode.h
|
// from DarkMode.h
|
||||||
|
|
||||||
void initExperimentalDarkMode(bool fixDarkScrollbar, bool dark)
|
void initExperimentalDarkMode()
|
||||||
{
|
{
|
||||||
::InitDarkMode(fixDarkScrollbar, dark);
|
::InitDarkMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDarkMode(bool useDark, bool fixDarkScrollbar)
|
||||||
|
{
|
||||||
|
::SetDarkMode(useDark, fixDarkScrollbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void allowDarkModeForApp(bool allow)
|
void allowDarkModeForApp(bool allow)
|
||||||
|
@ -401,9 +400,9 @@ namespace NppDarkMode
|
||||||
return ::AllowDarkModeForWindow(hWnd, allow);
|
return ::AllowDarkModeForWindow(hWnd, allow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTitleBarThemeColor(HWND hWnd, bool dark)
|
void setTitleBarThemeColor(HWND hWnd)
|
||||||
{
|
{
|
||||||
::SetTitleBarThemeColor(hWnd, dark);
|
::RefreshTitleBarThemeColor(hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableDarkScrollBarForWindowAndChildren(HWND hwnd)
|
void enableDarkScrollBarForWindowAndChildren(HWND hwnd)
|
||||||
|
@ -1044,12 +1043,8 @@ namespace NppDarkMode
|
||||||
|
|
||||||
void setDarkTitleBar(HWND hwnd)
|
void setDarkTitleBar(HWND hwnd)
|
||||||
{
|
{
|
||||||
bool useDark = NppDarkMode::isExperimentalEnabled() && NppDarkMode::isEnabled();
|
NppDarkMode::allowDarkModeForWindow(hwnd, NppDarkMode::isEnabled());
|
||||||
|
NppDarkMode::setTitleBarThemeColor(hwnd);
|
||||||
NppDarkMode::allowDarkModeForWindow(hwnd, useDark);
|
|
||||||
SetWindowTheme(hwnd, useDark ? L"Explorer" : nullptr, nullptr);
|
|
||||||
|
|
||||||
NppDarkMode::setTitleBarThemeColor(hwnd, useDark);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDarkExplorerTheme(HWND hwnd)
|
void setDarkExplorerTheme(HWND hwnd)
|
||||||
|
@ -1119,7 +1114,7 @@ namespace NppDarkMode
|
||||||
|
|
||||||
void setDarkListView(HWND hwnd)
|
void setDarkListView(HWND hwnd)
|
||||||
{
|
{
|
||||||
bool useDark = NppDarkMode::isEnabled() && NppDarkMode::isExperimentalEnabled();
|
bool useDark = NppDarkMode::isEnabled();
|
||||||
|
|
||||||
HWND hHeader = ListView_GetHeader(hwnd);
|
HWND hHeader = ListView_GetHeader(hwnd);
|
||||||
NppDarkMode::allowDarkModeForWindow(hHeader, useDark);
|
NppDarkMode::allowDarkModeForWindow(hHeader, useDark);
|
||||||
|
@ -1129,20 +1124,20 @@ namespace NppDarkMode
|
||||||
SetWindowTheme(hwnd, L"Explorer", nullptr);
|
SetWindowTheme(hwnd, L"Explorer", nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setExplorerTheme(HWND hwnd, bool doEnable, bool isTreeView)
|
void disableVisualStyle(HWND hwnd, bool doDisable)
|
||||||
{
|
{
|
||||||
if (isTreeView)
|
if (doDisable)
|
||||||
{
|
|
||||||
SetWindowTheme(hwnd, nullptr, nullptr);
|
|
||||||
}
|
|
||||||
else if (doEnable)
|
|
||||||
{
|
|
||||||
NppDarkMode::allowDarkModeForWindow(hwnd, NppDarkMode::isEnabled() && NppDarkMode::isExperimentalEnabled());
|
|
||||||
SetWindowTheme(hwnd, L"Explorer", nullptr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
SetWindowTheme(hwnd, L"", L"");
|
SetWindowTheme(hwnd, L"", L"");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetWindowTheme(hwnd, nullptr, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void redrawTreeViewScrollBar(HWND hwnd)
|
||||||
|
{
|
||||||
|
SetWindowTheme(hwnd, nullptr, nullptr); //hack to redraw treeview scrollbar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ namespace NppDarkMode
|
||||||
struct Options
|
struct Options
|
||||||
{
|
{
|
||||||
bool enable = false;
|
bool enable = false;
|
||||||
bool enableExperimental = false;
|
|
||||||
bool enableMenubar = false;
|
bool enableMenubar = false;
|
||||||
bool enableScrollbarHack = false;
|
bool enableScrollbarHack = false;
|
||||||
};
|
};
|
||||||
|
@ -35,8 +34,8 @@ namespace NppDarkMode
|
||||||
|
|
||||||
bool isEnabled();
|
bool isEnabled();
|
||||||
bool isDarkMenuEnabled();
|
bool isDarkMenuEnabled();
|
||||||
bool isExperimentalEnabled();
|
|
||||||
bool isScrollbarHackEnabled();
|
bool isScrollbarHackEnabled();
|
||||||
|
bool isExperimentalSupported();
|
||||||
|
|
||||||
COLORREF invertLightness(COLORREF c);
|
COLORREF invertLightness(COLORREF c);
|
||||||
COLORREF invertLightnessSofter(COLORREF c);
|
COLORREF invertLightnessSofter(COLORREF c);
|
||||||
|
@ -68,10 +67,11 @@ namespace NppDarkMode
|
||||||
void drawUAHMenuNCBottomLine(HWND hWnd);
|
void drawUAHMenuNCBottomLine(HWND hWnd);
|
||||||
|
|
||||||
// from DarkMode.h
|
// from DarkMode.h
|
||||||
void initExperimentalDarkMode(bool fixDarkScrollbar, bool dark);
|
void initExperimentalDarkMode();
|
||||||
|
void setDarkMode(bool useDark, bool fixDarkScrollbar);
|
||||||
void allowDarkModeForApp(bool allow);
|
void allowDarkModeForApp(bool allow);
|
||||||
bool allowDarkModeForWindow(HWND hWnd, bool allow);
|
bool allowDarkModeForWindow(HWND hWnd, bool allow);
|
||||||
void setTitleBarThemeColor(HWND hWnd, bool dark);
|
void setTitleBarThemeColor(HWND hWnd);
|
||||||
|
|
||||||
// enhancements to DarkMode.h
|
// enhancements to DarkMode.h
|
||||||
void enableDarkScrollBarForWindowAndChildren(HWND hwnd);
|
void enableDarkScrollBarForWindowAndChildren(HWND hwnd);
|
||||||
|
@ -91,5 +91,6 @@ namespace NppDarkMode
|
||||||
void setDarkLineAbovePanelToolbar(HWND hwnd);
|
void setDarkLineAbovePanelToolbar(HWND hwnd);
|
||||||
void setDarkListView(HWND hwnd);
|
void setDarkListView(HWND hwnd);
|
||||||
|
|
||||||
void setExplorerTheme(HWND hwnd, bool doEnable, bool isTreeView = false);
|
void disableVisualStyle(HWND hwnd, bool doDisable);
|
||||||
|
void redrawTreeViewScrollBar(HWND hwnd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5388,7 +5388,6 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
|
||||||
};
|
};
|
||||||
|
|
||||||
_nppGUI._darkmode.enable = parseYesNoBoolAttribute(TEXT("enable"));
|
_nppGUI._darkmode.enable = parseYesNoBoolAttribute(TEXT("enable"));
|
||||||
_nppGUI._darkmode.enableExperimental = parseYesNoBoolAttribute(TEXT("enableExperimental"));
|
|
||||||
_nppGUI._darkmode.enableMenubar = parseYesNoBoolAttribute(TEXT("enableMenubar"));
|
_nppGUI._darkmode.enableMenubar = parseYesNoBoolAttribute(TEXT("enableMenubar"));
|
||||||
_nppGUI._darkmode.enableScrollbarHack = parseYesNoBoolAttribute(TEXT("enableScrollbarHack"));
|
_nppGUI._darkmode.enableScrollbarHack = parseYesNoBoolAttribute(TEXT("enableScrollbarHack"));
|
||||||
}
|
}
|
||||||
|
@ -6414,7 +6413,6 @@ void NppParameters::createXmlTreeFromGUIParams()
|
||||||
};
|
};
|
||||||
|
|
||||||
setYesNoBoolAttribute(TEXT("enable"), _nppGUI._darkmode.enable);
|
setYesNoBoolAttribute(TEXT("enable"), _nppGUI._darkmode.enable);
|
||||||
setYesNoBoolAttribute(TEXT("enableExperimental"), _nppGUI._darkmode.enableExperimental);
|
|
||||||
setYesNoBoolAttribute(TEXT("enableMenubar"), _nppGUI._darkmode.enableMenubar);
|
setYesNoBoolAttribute(TEXT("enableMenubar"), _nppGUI._darkmode.enableMenubar);
|
||||||
setYesNoBoolAttribute(TEXT("enableScrollbarHack"), _nppGUI._darkmode.enableScrollbarHack);
|
setYesNoBoolAttribute(TEXT("enableScrollbarHack"), _nppGUI._darkmode.enableScrollbarHack);
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ LRESULT ListView::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
case CDDS_ITEMPREPAINT:
|
case CDDS_ITEMPREPAINT:
|
||||||
{
|
{
|
||||||
bool isDarkModeSupported = NppDarkMode::isEnabled() && NppDarkMode::isExperimentalEnabled();
|
bool isDarkModeSupported = NppDarkMode::isEnabled() && NppDarkMode::isExperimentalSupported();
|
||||||
SetTextColor(nmcd->hdc, isDarkModeSupported ? NppDarkMode::getDarkerTextColor() : GetSysColor(COLOR_BTNTEXT));
|
SetTextColor(nmcd->hdc, isDarkModeSupported ? NppDarkMode::getDarkerTextColor() : GetSysColor(COLOR_BTNTEXT));
|
||||||
return CDRF_DODEFAULT;
|
return CDRF_DODEFAULT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,8 +174,8 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||||
NppDarkMode::setDarkTooltips(_hToolbarMenu, NppDarkMode::ToolTipsType::toolbar);
|
NppDarkMode::setDarkTooltips(_hToolbarMenu, NppDarkMode::ToolTipsType::toolbar);
|
||||||
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
|
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
|
||||||
|
|
||||||
NppDarkMode::setExplorerTheme(_treeView.getHSelf(), true, true);
|
|
||||||
NppDarkMode::setDarkTooltips(_treeView.getHSelf(), NppDarkMode::ToolTipsType::treeview);
|
NppDarkMode::setDarkTooltips(_treeView.getHSelf(), NppDarkMode::ToolTipsType::treeview);
|
||||||
|
NppDarkMode::redrawTreeViewScrollBar(_treeView.getHSelf());
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,10 +197,10 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
int width = LOWORD(lParam);
|
int width = LOWORD(lParam);
|
||||||
int height = HIWORD(lParam);
|
int height = HIWORD(lParam);
|
||||||
int extraValue = NppParameters::getInstance()._dpiManager.scaleX(4);
|
int extraValue = NppParameters::getInstance()._dpiManager.scaleX(4);
|
||||||
|
|
||||||
RECT toolbarMenuRect;
|
RECT toolbarMenuRect;
|
||||||
|
@ -211,13 +211,13 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||||
HWND hwnd = _treeView.getHSelf();
|
HWND hwnd = _treeView.getHSelf();
|
||||||
if (hwnd)
|
if (hwnd)
|
||||||
::MoveWindow(hwnd, 0, toolbarMenuRect.bottom + extraValue, width, height - toolbarMenuRect.bottom - extraValue, TRUE);
|
::MoveWindow(hwnd, 0, toolbarMenuRect.bottom + extraValue, width, height - toolbarMenuRect.bottom - extraValue, TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_CONTEXTMENU:
|
case WM_CONTEXTMENU:
|
||||||
if (!_treeView.isDragging())
|
if (!_treeView.isDragging())
|
||||||
showContextMenu(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
showContextMenu(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
{
|
{
|
||||||
|
@ -248,12 +248,12 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
{
|
{
|
||||||
::DestroyWindow(_hToolbarMenu);
|
::DestroyWindow(_hToolbarMenu);
|
||||||
_treeView.destroy();
|
_treeView.destroy();
|
||||||
destroyMenus();
|
destroyMenus();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case FB_ADDFILE:
|
case FB_ADDFILE:
|
||||||
{
|
{
|
||||||
|
@ -312,9 +312,9 @@ INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default :
|
||||||
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
||||||
}
|
}
|
||||||
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -718,18 +718,10 @@ void FileBrowser::notified(LPNMHDR notification)
|
||||||
}
|
}
|
||||||
else if (notification->code == NM_CUSTOMDRAW && (notification->hwndFrom == _hToolbarMenu))
|
else if (notification->code == NM_CUSTOMDRAW && (notification->hwndFrom == _hToolbarMenu))
|
||||||
{
|
{
|
||||||
NMTBCUSTOMDRAW* nmtbcd = reinterpret_cast<NMTBCUSTOMDRAW*>(notification);
|
if (NppDarkMode::isEnabled())
|
||||||
if (nmtbcd->nmcd.dwDrawStage == CDDS_PREERASE)
|
|
||||||
{
|
{
|
||||||
if (NppDarkMode::isEnabled())
|
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notification);
|
||||||
{
|
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
|
||||||
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
|
|
||||||
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_DODEFAULT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1060,7 +1052,7 @@ void FileBrowser::addRootFolder(generic_string rootFolderPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<generic_string> patterns2Match;
|
std::vector<generic_string> patterns2Match;
|
||||||
patterns2Match.push_back(TEXT("*.*"));
|
patterns2Match.push_back(TEXT("*.*"));
|
||||||
|
|
||||||
TCHAR *label = ::PathFindFileName(rootFolderPath.c_str());
|
TCHAR *label = ::PathFindFileName(rootFolderPath.c_str());
|
||||||
TCHAR rootLabel[MAX_PATH];
|
TCHAR rootLabel[MAX_PATH];
|
||||||
|
|
|
@ -597,32 +597,10 @@ void FunctionListPanel::notified(LPNMHDR notification)
|
||||||
}
|
}
|
||||||
else if (notification->code == NM_CUSTOMDRAW && (notification->hwndFrom == _hToolbarMenu))
|
else if (notification->code == NM_CUSTOMDRAW && (notification->hwndFrom == _hToolbarMenu))
|
||||||
{
|
{
|
||||||
static bool becomeDarkMode = false;
|
|
||||||
static bool becomeLightMode = false;
|
|
||||||
if (NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
if (!becomeDarkMode)
|
|
||||||
{
|
|
||||||
NppDarkMode::setExplorerTheme(_hToolbarMenu, false);
|
|
||||||
becomeDarkMode = true;
|
|
||||||
}
|
|
||||||
becomeLightMode = false;
|
|
||||||
|
|
||||||
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notification);
|
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notification);
|
||||||
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
|
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
|
||||||
nmtbcd->clrText = NppDarkMode::getTextColor();
|
|
||||||
nmtbcd->clrHighlightHotTrack = NppDarkMode::getHighlightHotTrackColor();
|
|
||||||
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW | TBCDRF_HILITEHOTTRACK);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!becomeLightMode)
|
|
||||||
{
|
|
||||||
NppDarkMode::setExplorerTheme(_hToolbarMenu, true);
|
|
||||||
becomeLightMode = true;
|
|
||||||
}
|
|
||||||
becomeDarkMode = false;
|
|
||||||
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_DODEFAULT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -709,7 +687,7 @@ static WNDPROC oldFunclstToolbarProc = NULL;
|
||||||
static LRESULT CALLBACK funclstToolbarProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK funclstToolbarProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_CTLCOLOREDIT :
|
case WM_CTLCOLOREDIT :
|
||||||
{
|
{
|
||||||
return ::SendMessage(::GetParent(hwnd), WM_CTLCOLOREDIT, wParam, lParam);
|
return ::SendMessage(::GetParent(hwnd), WM_CTLCOLOREDIT, wParam, lParam);
|
||||||
|
@ -762,8 +740,8 @@ void FunctionListPanel::setSort(bool isEnabled)
|
||||||
|
|
||||||
INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
// Make edit field red if not found
|
// Make edit field red if not found
|
||||||
case WM_CTLCOLOREDIT :
|
case WM_CTLCOLOREDIT :
|
||||||
{
|
{
|
||||||
|
@ -811,8 +789,8 @@ INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPA
|
||||||
return (LRESULT)hBrushBackground;
|
return (LRESULT)hBrushBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_INITDIALOG :
|
case WM_INITDIALOG :
|
||||||
{
|
{
|
||||||
int editWidth = NppParameters::getInstance()._dpiManager.scaleX(100);
|
int editWidth = NppParameters::getInstance()._dpiManager.scaleX(100);
|
||||||
int editWidthSep = NppParameters::getInstance()._dpiManager.scaleX(105); //editWidth + 5
|
int editWidthSep = NppParameters::getInstance()._dpiManager.scaleX(105); //editWidth + 5
|
||||||
int editHeight = NppParameters::getInstance()._dpiManager.scaleY(20);
|
int editHeight = NppParameters::getInstance()._dpiManager.scaleY(20);
|
||||||
|
@ -891,8 +869,8 @@ INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPA
|
||||||
NppDarkMode::setDarkTooltips(_hToolbarMenu, NppDarkMode::ToolTipsType::toolbar);
|
NppDarkMode::setDarkTooltips(_hToolbarMenu, NppDarkMode::ToolTipsType::toolbar);
|
||||||
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
|
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
|
||||||
|
|
||||||
NppDarkMode::setExplorerTheme(_treeView.getHSelf(), true, true);
|
|
||||||
NppDarkMode::setDarkTooltips(_treeView.getHSelf(), NppDarkMode::ToolTipsType::treeview);
|
NppDarkMode::setDarkTooltips(_treeView.getHSelf(), NppDarkMode::ToolTipsType::treeview);
|
||||||
|
NppDarkMode::redrawTreeViewScrollBar(_treeView.getHSelf());
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -831,7 +831,6 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
case IDC_CHECK_DARKMODE_ENABLE:
|
case IDC_CHECK_DARKMODE_ENABLE:
|
||||||
bool enableDarkMode = isCheckedOrNot(static_cast<int>(wParam));
|
bool enableDarkMode = isCheckedOrNot(static_cast<int>(wParam));
|
||||||
nppGUI._darkmode.enable = enableDarkMode;
|
nppGUI._darkmode.enable = enableDarkMode;
|
||||||
nppGUI._darkmode.enableExperimental = enableDarkMode;
|
|
||||||
nppGUI._darkmode.enableMenubar = enableDarkMode;
|
nppGUI._darkmode.enableMenubar = enableDarkMode;
|
||||||
nppGUI._darkmode.enableScrollbarHack = enableDarkMode;
|
nppGUI._darkmode.enableScrollbarHack = enableDarkMode;
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
|
||||||
0,0,0,0,_hSelf, nullptr, _hInst, nullptr);
|
0,0,0,0,_hSelf, nullptr, _hInst, nullptr);
|
||||||
|
|
||||||
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
|
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
|
||||||
|
NppDarkMode::disableVisualStyle(_hToolbarMenu, NppDarkMode::isEnabled());
|
||||||
|
|
||||||
TBBUTTON tbButtons[2];
|
TBBUTTON tbButtons[2];
|
||||||
|
|
||||||
|
@ -100,9 +101,10 @@ INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
|
||||||
case NPPM_INTERNAL_REFRESHDARKMODE:
|
case NPPM_INTERNAL_REFRESHDARKMODE:
|
||||||
{
|
{
|
||||||
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
|
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
|
||||||
|
NppDarkMode::disableVisualStyle(_hToolbarMenu, NppDarkMode::isEnabled());
|
||||||
|
|
||||||
NppDarkMode::setExplorerTheme(_treeView.getHSelf(), true, true);
|
|
||||||
NppDarkMode::setDarkTooltips(_treeView.getHSelf(), NppDarkMode::ToolTipsType::treeview);
|
NppDarkMode::setDarkTooltips(_treeView.getHSelf(), NppDarkMode::ToolTipsType::treeview);
|
||||||
|
NppDarkMode::redrawTreeViewScrollBar(_treeView.getHSelf());
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,22 +124,22 @@ INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
int width = LOWORD(lParam);
|
int width = LOWORD(lParam);
|
||||||
int height = HIWORD(lParam);
|
int height = HIWORD(lParam);
|
||||||
RECT toolbarMenuRect;
|
RECT toolbarMenuRect;
|
||||||
::GetClientRect(_hToolbarMenu, &toolbarMenuRect);
|
::GetClientRect(_hToolbarMenu, &toolbarMenuRect);
|
||||||
|
|
||||||
::MoveWindow(_hToolbarMenu, 0, 0, width, toolbarMenuRect.bottom, TRUE);
|
::MoveWindow(_hToolbarMenu, 0, 0, width, toolbarMenuRect.bottom, TRUE);
|
||||||
|
|
||||||
HWND hwnd = _treeView.getHSelf();
|
HWND hwnd = _treeView.getHSelf();
|
||||||
if (hwnd)
|
if (hwnd)
|
||||||
::MoveWindow(hwnd, 0, toolbarMenuRect.bottom + 2, width, height - toolbarMenuRect.bottom - 2, TRUE);
|
::MoveWindow(hwnd, 0, toolbarMenuRect.bottom + 2, width, height - toolbarMenuRect.bottom - 2, TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_CONTEXTMENU:
|
case WM_CONTEXTMENU:
|
||||||
if (!_treeView.isDragging())
|
if (!_treeView.isDragging())
|
||||||
{
|
{
|
||||||
int xPos = GET_X_LPARAM(lParam);
|
int xPos = GET_X_LPARAM(lParam);
|
||||||
|
@ -163,7 +165,7 @@ INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
|
||||||
showContextMenu(xPos, yPos);
|
showContextMenu(xPos, yPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
{
|
{
|
||||||
|
@ -172,16 +174,16 @@ INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
{
|
{
|
||||||
_treeView.destroy();
|
_treeView.destroy();
|
||||||
destroyMenus();
|
destroyMenus();
|
||||||
::DestroyWindow(_hToolbarMenu);
|
::DestroyWindow(_hToolbarMenu);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default :
|
||||||
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
||||||
}
|
}
|
||||||
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +232,7 @@ void ProjectPanel::initMenus()
|
||||||
generic_string saveas_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEASWS, PM_SAVEASWORKSPACE);
|
generic_string saveas_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEASWS, PM_SAVEASWORKSPACE);
|
||||||
generic_string saveacopyas_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEACOPYASWS, PM_SAVEACOPYASWORKSPACE);
|
generic_string saveacopyas_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_SAVEACOPYASWS, PM_SAVEACOPYASWORKSPACE);
|
||||||
generic_string newproject_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_NEWPROJECT, PM_NEWPROJECTWORKSPACE);
|
generic_string newproject_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_NEWPROJECT, PM_NEWPROJECTWORKSPACE);
|
||||||
generic_string findinprojects_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_FINDINPROJECTSWS, PM_FINDINFILESWORKSPACE);
|
generic_string findinprojects_workspace = pNativeSpeaker->getProjectPanelLangMenuStr("WorkspaceMenu", IDM_PROJECT_FINDINPROJECTSWS, PM_FINDINFILESWORKSPACE);
|
||||||
|
|
||||||
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWWS, new_workspace.c_str());
|
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_NEWWS, new_workspace.c_str());
|
||||||
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_OPENWS, open_workspace.c_str());
|
::InsertMenu(_hWorkSpaceMenu, 0, MF_BYCOMMAND, IDM_PROJECT_OPENWS, open_workspace.c_str());
|
||||||
|
@ -451,34 +453,34 @@ bool ProjectPanel::saveWorkSpace()
|
||||||
|
|
||||||
bool ProjectPanel::writeWorkSpace(const TCHAR *projectFileName)
|
bool ProjectPanel::writeWorkSpace(const TCHAR *projectFileName)
|
||||||
{
|
{
|
||||||
//write <NotepadPlus>: use the default file name if new file name is not given
|
//write <NotepadPlus>: use the default file name if new file name is not given
|
||||||
const TCHAR * fn2write = projectFileName?projectFileName:_workSpaceFilePath.c_str();
|
const TCHAR * fn2write = projectFileName?projectFileName:_workSpaceFilePath.c_str();
|
||||||
TiXmlDocument projDoc(fn2write);
|
TiXmlDocument projDoc(fn2write);
|
||||||
TiXmlNode *root = projDoc.InsertEndChild(TiXmlElement(TEXT("NotepadPlus")));
|
TiXmlNode *root = projDoc.InsertEndChild(TiXmlElement(TEXT("NotepadPlus")));
|
||||||
|
|
||||||
TCHAR textBuffer[MAX_PATH];
|
TCHAR textBuffer[MAX_PATH];
|
||||||
TVITEM tvItem;
|
TVITEM tvItem;
|
||||||
tvItem.mask = TVIF_TEXT;
|
tvItem.mask = TVIF_TEXT;
|
||||||
tvItem.pszText = textBuffer;
|
tvItem.pszText = textBuffer;
|
||||||
tvItem.cchTextMax = MAX_PATH;
|
tvItem.cchTextMax = MAX_PATH;
|
||||||
|
|
||||||
//for each project, write <Project>
|
//for each project, write <Project>
|
||||||
HTREEITEM tvRoot = _treeView.getRoot();
|
HTREEITEM tvRoot = _treeView.getRoot();
|
||||||
if (!tvRoot)
|
if (!tvRoot)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (HTREEITEM tvProj = _treeView.getChildFrom(tvRoot);
|
for (HTREEITEM tvProj = _treeView.getChildFrom(tvRoot);
|
||||||
tvProj != NULL;
|
tvProj != NULL;
|
||||||
tvProj = _treeView.getNextSibling(tvProj))
|
tvProj = _treeView.getNextSibling(tvProj))
|
||||||
{
|
{
|
||||||
tvItem.hItem = tvProj;
|
tvItem.hItem = tvProj;
|
||||||
SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
|
SendMessage(_treeView.getHSelf(), TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
|
||||||
//printStr(tvItem.pszText);
|
//printStr(tvItem.pszText);
|
||||||
|
|
||||||
TiXmlNode *projRoot = root->InsertEndChild(TiXmlElement(TEXT("Project")));
|
TiXmlNode *projRoot = root->InsertEndChild(TiXmlElement(TEXT("Project")));
|
||||||
projRoot->ToElement()->SetAttribute(TEXT("name"), tvItem.pszText);
|
projRoot->ToElement()->SetAttribute(TEXT("name"), tvItem.pszText);
|
||||||
buildProjectXml(projRoot, tvProj, fn2write);
|
buildProjectXml(projRoot, tvProj, fn2write);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!projDoc.SaveFile())
|
if (!projDoc.SaveFile())
|
||||||
{
|
{
|
||||||
|
@ -506,7 +508,7 @@ void ProjectPanel::buildProjectXml(TiXmlNode *node, HTREEITEM hItem, const TCHAR
|
||||||
tvItem.pszText = textBuffer;
|
tvItem.pszText = textBuffer;
|
||||||
tvItem.cchTextMax = MAX_PATH;
|
tvItem.cchTextMax = MAX_PATH;
|
||||||
|
|
||||||
for (HTREEITEM hItemNode = _treeView.getChildFrom(hItem);
|
for (HTREEITEM hItemNode = _treeView.getChildFrom(hItem);
|
||||||
hItemNode != NULL;
|
hItemNode != NULL;
|
||||||
hItemNode = _treeView.getNextSibling(hItemNode))
|
hItemNode = _treeView.getNextSibling(hItemNode))
|
||||||
{
|
{
|
||||||
|
@ -817,27 +819,11 @@ void ProjectPanel::notified(LPNMHDR notification)
|
||||||
{
|
{
|
||||||
if (NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
if (!_becomeDarkMode)
|
|
||||||
{
|
|
||||||
NppDarkMode::setExplorerTheme(_hToolbarMenu, false);
|
|
||||||
_becomeDarkMode = true;
|
|
||||||
}
|
|
||||||
_becomeLightMode = false;
|
|
||||||
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notification);
|
auto nmtbcd = reinterpret_cast<LPNMTBCUSTOMDRAW>(notification);
|
||||||
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
|
FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getBackgroundBrush());
|
||||||
nmtbcd->clrText = NppDarkMode::getTextColor();
|
nmtbcd->clrText = NppDarkMode::getTextColor();
|
||||||
nmtbcd->clrHighlightHotTrack = NppDarkMode::getHighlightHotTrackColor();
|
nmtbcd->clrHighlightHotTrack = NppDarkMode::getHighlightHotTrackColor();
|
||||||
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW | TBCDRF_HILITEHOTTRACK);
|
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_NOTIFYITEMDRAW | TBCDRF_HILITEHOTTRACK);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!_becomeLightMode)
|
|
||||||
{
|
|
||||||
NppDarkMode::setExplorerTheme(_hToolbarMenu, true);
|
|
||||||
_becomeLightMode = true;
|
|
||||||
}
|
|
||||||
_becomeDarkMode = false;
|
|
||||||
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, CDRF_DODEFAULT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,13 +65,13 @@ public:
|
||||||
_panelID = panelID;
|
_panelID = panelID;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void display(bool toShow = true) const {
|
virtual void display(bool toShow = true) const {
|
||||||
DockingDlgInterface::display(toShow);
|
DockingDlgInterface::display(toShow);
|
||||||
};
|
};
|
||||||
|
|
||||||
void setParent(HWND parent2set){
|
void setParent(HWND parent2set){
|
||||||
_hParent = parent2set;
|
_hParent = parent2set;
|
||||||
};
|
};
|
||||||
|
|
||||||
void setPanelTitle(generic_string title) {
|
void setPanelTitle(generic_string title) {
|
||||||
_panelTitle = title;
|
_panelTitle = title;
|
||||||
|
@ -98,10 +98,10 @@ public:
|
||||||
|
|
||||||
virtual void setBackgroundColor(COLORREF bgColour) {
|
virtual void setBackgroundColor(COLORREF bgColour) {
|
||||||
TreeView_SetBkColor(_treeView.getHSelf(), bgColour);
|
TreeView_SetBkColor(_treeView.getHSelf(), bgColour);
|
||||||
};
|
};
|
||||||
virtual void setForegroundColor(COLORREF fgColour) {
|
virtual void setForegroundColor(COLORREF fgColour) {
|
||||||
TreeView_SetTextColor(_treeView.getHSelf(), fgColour);
|
TreeView_SetTextColor(_treeView.getHSelf(), fgColour);
|
||||||
};
|
};
|
||||||
bool enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vector<generic_string> & patterns, std::vector<generic_string> & fileNames);
|
bool enumWorkSpaceFiles(HTREEITEM tvFrom, const std::vector<generic_string> & patterns, std::vector<generic_string> & fileNames);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -117,8 +117,6 @@ protected:
|
||||||
generic_string _selDirOfFilesFromDirDlg;
|
generic_string _selDirOfFilesFromDirDlg;
|
||||||
bool _isDirty = false;
|
bool _isDirty = false;
|
||||||
int _panelID = 0;
|
int _panelID = 0;
|
||||||
bool _becomeDarkMode = false;
|
|
||||||
bool _becomeLightMode = false;
|
|
||||||
|
|
||||||
void initMenus();
|
void initMenus();
|
||||||
void destroyMenus();
|
void destroyMenus();
|
||||||
|
@ -157,8 +155,8 @@ public :
|
||||||
|
|
||||||
int doDialog(const TCHAR *fn, bool isRTL = false);
|
int doDialog(const TCHAR *fn, bool isRTL = false);
|
||||||
|
|
||||||
virtual void destroy() {
|
virtual void destroy() {
|
||||||
};
|
};
|
||||||
|
|
||||||
generic_string getFullFilePath() {
|
generic_string getFullFilePath() {
|
||||||
return _fullFilePath;
|
return _fullFilePath;
|
||||||
|
|
|
@ -43,7 +43,6 @@ void TreeView::init(HINSTANCE hInst, HWND parent, int treeViewID)
|
||||||
_hInst,
|
_hInst,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
NppDarkMode::setExplorerTheme(_hSelf, true, true);
|
|
||||||
NppDarkMode::setDarkTooltips(_hSelf, NppDarkMode::ToolTipsType::treeview);
|
NppDarkMode::setDarkTooltips(_hSelf, NppDarkMode::ToolTipsType::treeview);
|
||||||
|
|
||||||
int itemHeight = NppParameters::getInstance()._dpiManager.scaleY(CY_ITEMHEIGHT);
|
int itemHeight = NppParameters::getInstance()._dpiManager.scaleY(CY_ITEMHEIGHT);
|
||||||
|
@ -205,8 +204,8 @@ void TreeView::removeItem(HTREEITEM hTreeItem)
|
||||||
void TreeView::removeAllItems()
|
void TreeView::removeAllItems()
|
||||||
{
|
{
|
||||||
for (HTREEITEM tvProj = getRoot();
|
for (HTREEITEM tvProj = getRoot();
|
||||||
tvProj != NULL;
|
tvProj != NULL;
|
||||||
tvProj = getNextSibling(tvProj))
|
tvProj = getNextSibling(tvProj))
|
||||||
{
|
{
|
||||||
cleanSubEntries(tvProj);
|
cleanSubEntries(tvProj);
|
||||||
}
|
}
|
||||||
|
@ -329,81 +328,81 @@ void TreeView::beginDrag(NMTREEVIEW* tv)
|
||||||
if (!canDragOut(tv->itemNew.hItem))
|
if (!canDragOut(tv->itemNew.hItem))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// create dragging image for you using TVM_CREATEDRAGIMAGE
|
// create dragging image for you using TVM_CREATEDRAGIMAGE
|
||||||
// You have to delete it after drop operation, so remember it.
|
// You have to delete it after drop operation, so remember it.
|
||||||
_draggedItem = tv->itemNew.hItem;
|
_draggedItem = tv->itemNew.hItem;
|
||||||
_draggedImageList = reinterpret_cast<HIMAGELIST>(::SendMessage(_hSelf, TVM_CREATEDRAGIMAGE, 0, reinterpret_cast<LPARAM>(_draggedItem)));
|
_draggedImageList = reinterpret_cast<HIMAGELIST>(::SendMessage(_hSelf, TVM_CREATEDRAGIMAGE, 0, reinterpret_cast<LPARAM>(_draggedItem)));
|
||||||
|
|
||||||
// start dragging operation
|
// start dragging operation
|
||||||
// PARAMS: HIMAGELIST, imageIndex, xHotspot, yHotspot
|
// PARAMS: HIMAGELIST, imageIndex, xHotspot, yHotspot
|
||||||
::ImageList_BeginDrag(_draggedImageList, 0, 0, 0);
|
::ImageList_BeginDrag(_draggedImageList, 0, 0, 0);
|
||||||
::ImageList_DragEnter(_hSelf, tv->ptDrag.x, tv->ptDrag.y);
|
::ImageList_DragEnter(_hSelf, tv->ptDrag.x, tv->ptDrag.y);
|
||||||
|
|
||||||
// redirect mouse input to the parent window
|
// redirect mouse input to the parent window
|
||||||
::SetCapture(::GetParent(_hSelf));
|
::SetCapture(::GetParent(_hSelf));
|
||||||
::ShowCursor(false); // hide the cursor
|
::ShowCursor(false); // hide the cursor
|
||||||
|
|
||||||
_isItemDragged = true;
|
_isItemDragged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeView::dragItem(HWND parentHandle, int x, int y)
|
void TreeView::dragItem(HWND parentHandle, int x, int y)
|
||||||
{
|
{
|
||||||
// convert the dialog coords to control coords
|
// convert the dialog coords to control coords
|
||||||
POINT point;
|
POINT point;
|
||||||
point.x = (SHORT)x;
|
point.x = (SHORT)x;
|
||||||
point.y = (SHORT)y;
|
point.y = (SHORT)y;
|
||||||
::ClientToScreen(parentHandle, &point);
|
::ClientToScreen(parentHandle, &point);
|
||||||
::ScreenToClient(_hSelf, &point);
|
::ScreenToClient(_hSelf, &point);
|
||||||
|
|
||||||
// drag the item to the current the cursor position
|
// drag the item to the current the cursor position
|
||||||
::ImageList_DragMove(point.x, point.y);
|
::ImageList_DragMove(point.x, point.y);
|
||||||
|
|
||||||
// hide the dragged image, so the background can be refreshed
|
// hide the dragged image, so the background can be refreshed
|
||||||
::ImageList_DragShowNolock(false);
|
::ImageList_DragShowNolock(false);
|
||||||
|
|
||||||
// find out if the pointer is on an item
|
// find out if the pointer is on an item
|
||||||
// If so, highlight the item as a drop target.
|
// If so, highlight the item as a drop target.
|
||||||
TVHITTESTINFO hitTestInfo;
|
TVHITTESTINFO hitTestInfo;
|
||||||
hitTestInfo.pt.x = point.x;
|
hitTestInfo.pt.x = point.x;
|
||||||
hitTestInfo.pt.y = point.y;
|
hitTestInfo.pt.y = point.y;
|
||||||
HTREEITEM targetItem = reinterpret_cast<HTREEITEM>(::SendMessage(_hSelf, TVM_HITTEST, 0, reinterpret_cast<LPARAM>(&hitTestInfo)));
|
HTREEITEM targetItem = reinterpret_cast<HTREEITEM>(::SendMessage(_hSelf, TVM_HITTEST, 0, reinterpret_cast<LPARAM>(&hitTestInfo)));
|
||||||
if (targetItem)
|
if (targetItem)
|
||||||
{
|
{
|
||||||
::SendMessage(_hSelf, TVM_SELECTITEM, TVGN_DROPHILITE, reinterpret_cast<LPARAM>(targetItem));
|
::SendMessage(_hSelf, TVM_SELECTITEM, TVGN_DROPHILITE, reinterpret_cast<LPARAM>(targetItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
// show the dragged image
|
// show the dragged image
|
||||||
::ImageList_DragShowNolock(true);
|
::ImageList_DragShowNolock(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeView::dropItem()
|
bool TreeView::dropItem()
|
||||||
{
|
{
|
||||||
bool isFilesMoved = false;
|
bool isFilesMoved = false;
|
||||||
// get the target item
|
// get the target item
|
||||||
HTREEITEM targetItem = reinterpret_cast<HTREEITEM>(::SendMessage(_hSelf, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0));
|
HTREEITEM targetItem = reinterpret_cast<HTREEITEM>(::SendMessage(_hSelf, TVM_GETNEXTITEM, TVGN_DROPHILITE, 0));
|
||||||
|
|
||||||
// make a copy of the dragged item and insert the clone under
|
// make a copy of the dragged item and insert the clone under
|
||||||
// the target item, then, delete the original dragged item
|
// the target item, then, delete the original dragged item
|
||||||
// Note that the dragged item may have children. In this case,
|
// Note that the dragged item may have children. In this case,
|
||||||
// you have to move (copy and delete) for every child items, too.
|
// you have to move (copy and delete) for every child items, too.
|
||||||
if (canBeDropped(_draggedItem, targetItem))
|
if (canBeDropped(_draggedItem, targetItem))
|
||||||
{
|
{
|
||||||
moveTreeViewItem(_draggedItem, targetItem);
|
moveTreeViewItem(_draggedItem, targetItem);
|
||||||
isFilesMoved = true;
|
isFilesMoved = true;
|
||||||
}
|
}
|
||||||
// finish drag-and-drop operation
|
// finish drag-and-drop operation
|
||||||
::ImageList_EndDrag();
|
::ImageList_EndDrag();
|
||||||
::ImageList_Destroy(_draggedImageList);
|
::ImageList_Destroy(_draggedImageList);
|
||||||
::ReleaseCapture();
|
::ReleaseCapture();
|
||||||
::ShowCursor(true);
|
::ShowCursor(true);
|
||||||
|
|
||||||
SendMessage(_hSelf, TVM_SELECTITEM, TVGN_CARET, reinterpret_cast<LPARAM>(targetItem));
|
SendMessage(_hSelf, TVM_SELECTITEM, TVGN_CARET, reinterpret_cast<LPARAM>(targetItem));
|
||||||
SendMessage(_hSelf,TVM_SELECTITEM,TVGN_DROPHILITE,0);
|
SendMessage(_hSelf,TVM_SELECTITEM,TVGN_DROPHILITE,0);
|
||||||
|
|
||||||
// clear global variables
|
// clear global variables
|
||||||
_draggedItem = 0;
|
_draggedItem = 0;
|
||||||
_draggedImageList = 0;
|
_draggedImageList = 0;
|
||||||
_isItemDragged = false;
|
_isItemDragged = false;
|
||||||
return isFilesMoved;
|
return isFilesMoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +458,7 @@ void TreeView::moveTreeViewItem(HTREEITEM draggedItem, HTREEITEM targetItem)
|
||||||
tvDraggingItem.hItem = draggedItem;
|
tvDraggingItem.hItem = draggedItem;
|
||||||
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvDraggingItem));
|
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvDraggingItem));
|
||||||
|
|
||||||
TVINSERTSTRUCT tvInsertStruct;
|
TVINSERTSTRUCT tvInsertStruct;
|
||||||
tvInsertStruct.item = tvDraggingItem;
|
tvInsertStruct.item = tvDraggingItem;
|
||||||
tvInsertStruct.hInsertAfter = (HTREEITEM)TVI_LAST;
|
tvInsertStruct.hInsertAfter = (HTREEITEM)TVI_LAST;
|
||||||
tvInsertStruct.hParent = targetItem;
|
tvInsertStruct.hParent = targetItem;
|
||||||
|
@ -516,7 +515,7 @@ bool TreeView::swapTreeViewItem(HTREEITEM itemGoDown, HTREEITEM itemGoUp)
|
||||||
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvDownItem));
|
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvDownItem));
|
||||||
|
|
||||||
// add 2 new items
|
// add 2 new items
|
||||||
TVINSERTSTRUCT tvInsertUp;
|
TVINSERTSTRUCT tvInsertUp;
|
||||||
tvInsertUp.item = tvUpItem;
|
tvInsertUp.item = tvUpItem;
|
||||||
tvInsertUp.hInsertAfter = itemTop;
|
tvInsertUp.hInsertAfter = itemTop;
|
||||||
tvInsertUp.hParent = parentGoUp;
|
tvInsertUp.hParent = parentGoUp;
|
||||||
|
|
|
@ -102,7 +102,7 @@ LRESULT VerticalFileSwitcherListView::runProc(HWND hwnd, UINT Message, WPARAM wP
|
||||||
|
|
||||||
case CDDS_ITEMPREPAINT:
|
case CDDS_ITEMPREPAINT:
|
||||||
{
|
{
|
||||||
bool isDarkModeSupported = NppDarkMode::isEnabled() && NppDarkMode::isExperimentalEnabled();
|
bool isDarkModeSupported = NppDarkMode::isEnabled() && NppDarkMode::isExperimentalSupported();
|
||||||
SetTextColor(nmcd->hdc, isDarkModeSupported ? NppDarkMode::getDarkerTextColor() : GetSysColor(COLOR_BTNTEXT));
|
SetTextColor(nmcd->hdc, isDarkModeSupported ? NppDarkMode::getDarkerTextColor() : GetSysColor(COLOR_BTNTEXT));
|
||||||
return CDRF_DODEFAULT;
|
return CDRF_DODEFAULT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue