Fix accent tooltip behaviour and enhance '(?)' static control appearence

ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/16434#issuecomment-2817077992

Close #16448
This commit is contained in:
ozone10 2025-04-20 11:11:46 +02:00 committed by Don Ho
parent 9f2326d30c
commit faec21b57e
5 changed files with 38 additions and 7 deletions

View File

@ -4020,6 +4020,19 @@ namespace NppDarkMode
return reinterpret_cast<LRESULT>(NppDarkMode::getDlgBackgroundBrush());
}
LRESULT onCtlColorDlgLinkText(HDC hdc, bool isTextEnabled)
{
if (!NppDarkMode::isEnabled())
{
::SetTextColor(hdc, ::GetSysColor(isTextEnabled ? COLOR_HOTLIGHT : COLOR_GRAYTEXT));
return FALSE;
}
::SetTextColor(hdc, isTextEnabled ? NppDarkMode::getLinkTextColor() : NppDarkMode::getDisabledTextColor());
::SetBkColor(hdc, NppDarkMode::getDlgBackgroundColor());
return reinterpret_cast<LRESULT>(NppDarkMode::getDlgBackgroundBrush());
}
LRESULT onCtlColorListbox(WPARAM wParam, LPARAM lParam)
{
auto hdc = reinterpret_cast<HDC>(wParam);

View File

@ -239,5 +239,6 @@ namespace NppDarkMode
LRESULT onCtlColorDlg(HDC hdc);
LRESULT onCtlColorError(HDC hdc);
LRESULT onCtlColorDlgStaticText(HDC hdc, bool isTextEnabled);
LRESULT onCtlColorDlgLinkText(HDC hdc, bool isTextEnabled = true);
LRESULT onCtlColorListbox(WPARAM wParam, LPARAM lParam);
}

View File

@ -59,11 +59,11 @@ BEGIN
CONTROL "Filled Fluent UI: small",IDC_RADIO_SMALLICON2,"Button",BS_AUTORADIOBUTTON,28,93,135,10
CONTROL "Filled Fluent UI: large",IDC_RADIO_BIGICON2,"Button",BS_AUTORADIOBUTTON,28,106,135,10
CONTROL "Standard icons: small",IDC_RADIO_STANDARD,"Button",BS_AUTORADIOBUTTON,28,119,135,10
GROUPBOX "Colorization",IDC_TOOLBAR_GB_COLORIZATION,171,19,250,173,BS_CENTER
CONTROL "Complete",IDC_RADIO_COMPLETE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,197,32,93,10
CONTROL "Partial",IDC_RADIO_PARTIAL,"Button",BS_AUTORADIOBUTTON,197,45,79,10
GROUPBOX "Color choice",IDC_TOOLBAR_GB_COLORCHOICE,184,67,224,115,BS_CENTER
CONTROL "Red",IDC_RADIO_RED,"Button",BS_AUTORADIOBUTTON | WS_GROUP,195,80,77,10
CONTROL "Green",IDC_RADIO_GREEN,"Button",BS_AUTORADIOBUTTON,195,94,77,10
@ -74,9 +74,9 @@ BEGIN
CONTROL "Yellow",IDC_RADIO_YELLOW,"Button",BS_AUTORADIOBUTTON,195,164,77,10
CONTROL "Default",IDC_RADIO_DEFAULTCOLOR,"Button",BS_AUTORADIOBUTTON,278,80,112,10
CONTROL "System Accent",IDC_RADIO_ACCENTCOLOR,"Button",BS_AUTORADIOBUTTON,278,94,112,10
LTEXT "(?)",IDD_ACCENT_TIP_STATIC,393,94,10,10, SS_NOTIFY
CONTROL "Custom",IDC_RADIO_CUSTOMCOLOR,"Button",BS_AUTORADIOBUTTON,278,108,112,10
LTEXT "",IDC_STATIC,310,127,1,8 // For placing the color picker on the left
LTEXT "(?)",IDD_ACCENT_TIP_STATIC,393,94,10,8,SS_NOTIFY
LTEXT "",IDC_STATIC,310,127,1,8 // For placing the color picker on the left
END
IDD_PREFERENCE_SUB_TABBAR DIALOGEX 115, 10, 460, 205

View File

@ -250,6 +250,9 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{
NppDarkMode::autoThemeChildControls(_hSelf);
if (_toolbarSubDlg._accentTip != nullptr)
NppDarkMode::setDarkTooltips(_toolbarSubDlg._accentTip, NppDarkMode::ToolTipsType::tooltip);
if (_editing2SubDlg._tip != nullptr)
NppDarkMode::setDarkTooltips(_editing2SubDlg._tip, NppDarkMode::ToolTipsType::tooltip);
@ -882,13 +885,20 @@ intptr_t CALLBACK ToolbarSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_YELLOW), enableColor);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DEFAULTCOLOR), enableColor);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_ACCENTCOLOR), enableColor);
::EnableWindow(::GetDlgItem(_hSelf, IDD_ACCENT_TIP_STATIC), enableColor);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_CUSTOMCOLOR), enableColor);
auto nStyle = ::GetWindowLongPtr(::GetDlgItem(_hSelf, IDD_ACCENT_TIP_STATIC), GWL_STYLE);
const bool isNotify = (nStyle & SS_NOTIFY) == SS_NOTIFY;
if (enableColor != isNotify)
{
nStyle ^= SS_NOTIFY;
::SetWindowLongPtr(::GetDlgItem(_hSelf, IDD_ACCENT_TIP_STATIC), GWL_STYLE, nStyle);
redrawDlgItem(IDD_ACCENT_TIP_STATIC);
}
bool useDark = static_cast<bool>(wParam) ? !NppDarkMode::isEnabled() : NppDarkMode::isEnabled();
enableIconColorPicker(enableColor && enableCustom, useDark);
if (NppDarkMode::isEnabled())
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_TOOLBAR_GB_COLORCHOICE), enableColor);
@ -907,7 +917,13 @@ intptr_t CALLBACK ToolbarSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
case WM_CTLCOLORSTATIC:
{
return NppDarkMode::onCtlColorDlg(reinterpret_cast<HDC>(wParam));
auto hdc = reinterpret_cast<HDC>(wParam);
const int dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
if (dlgCtrlID == IDD_ACCENT_TIP_STATIC)
{
return NppDarkMode::onCtlColorDlgLinkText(hdc, !isCheckedOrNot(IDC_RADIO_STANDARD));
}
return NppDarkMode::onCtlColorDlg(hdc);
}
case WM_PRINTCLIENT:

View File

@ -52,6 +52,7 @@ private :
class ToolbarSubDlg : public StaticDialog
{
friend class PreferenceDlg;
public:
ToolbarSubDlg() = default;