Fixed blurry disabled static texts of Preferences in Dark mode

Set static text colour in both light/dark mode directly for disable/enable action instead of EnableWindow().

Fix #10823, fix #11331, close #11342
This commit is contained in:
Ashfaaq18 2022-03-05 13:24:10 +05:30 committed by Don Ho
parent f9118dd13c
commit c3daf4448d
2 changed files with 110 additions and 36 deletions

View File

@ -83,6 +83,7 @@ void RegExtDlg::doDialog(bool isRTL)
intptr_t CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
{
NppParameters& nppParam = NppParameters::getInstance();
switch (Message)
{
case WM_INITDIALOG :
@ -92,14 +93,11 @@ intptr_t CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), false);
NppParameters& nppParam = NppParameters::getInstance();
if (!nppParam.isAdmin())
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_REGEXT_LANG_LIST), false);
::EnableWindow(::GetDlgItem(_hSelf, IDC_REGEXT_LANGEXT_LIST), false);
::EnableWindow(::GetDlgItem(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST), false);
::EnableWindow(::GetDlgItem(_hSelf, IDC_SUPPORTEDEXTS_STATIC), false);
::EnableWindow(::GetDlgItem(_hSelf, IDC_REGISTEREDEXTS_STATIC), false);
}
else
{
@ -121,11 +119,23 @@ intptr_t CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
LRESULT result = FALSE;
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
result = NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_SUPPORTEDEXTS_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDC_REGISTEREDEXTS_STATIC)
)
{
if (nppParam.isAdmin())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
}
return result;
}
case WM_PRINTCLIENT:

View File

@ -878,17 +878,6 @@ void DarkModeSubDlg::enableCustomizedColorCtrls(bool doEnable)
::EnableWindow(_pEdgeColorPicker->getHSelf(), doEnable);
::EnableWindow(_pLinkColorPicker->getHSelf(), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR1_STATIC), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR2_STATIC), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR3_STATIC), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR4_STATIC), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR5_STATIC), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR6_STATIC), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR7_STATIC), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR8_STATIC), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR9_STATIC), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR10_STATIC), doEnable);
::EnableWindow(::GetDlgItem(_hSelf, IDD_CUSTOMIZED_RESET_BUTTON), doEnable);
if (doEnable)
@ -1025,11 +1014,38 @@ intptr_t CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
LRESULT result = FALSE;
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
result = NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR1_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR2_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR3_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR4_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR5_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR6_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR7_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR8_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR9_STATIC) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_CUSTOMIZED_COLOR10_STATIC)
)
{
if (nppGUI._darkmode._isEnabled && nppGUI._darkmode._colorTone == NppDarkMode::customizedTone)
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
}
else
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
}
return result;
}
case WM_PRINTCLIENT:
@ -3363,17 +3379,50 @@ intptr_t CALLBACK BackupSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
LRESULT result = false;
if (NppDarkMode::isEnabled())
{
auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
if (dlgCtrlID == IDD_BACKUPDIR_RESTORESESSION_PATH_EDIT)
{
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
result = NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
}
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
result = NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if ((HWND)lParam == ::GetDlgItem(_hSelf, IDD_BACKUPDIR_STATIC))
{
if (BST_CHECKED != ::SendDlgItemMessage(_hSelf, IDC_RADIO_BKNONE, BM_GETCHECK, 0, 0) &&
BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_CHECK, BM_GETCHECK, 0, 0))
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
}
else
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
}
else if (
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_STATIC1) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_STATIC2) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_PATHLABEL_STATIC)
)
{
if (isCheckedOrNot(IDC_BACKUPDIR_RESTORESESSION_CHECK))
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
}
else
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
}
return result;
}
case WM_PRINTCLIENT:
@ -3516,10 +3565,7 @@ void BackupSubDlg::updateBackupGUI()
bool rememberSession = isCheckedOrNot(IDC_CHECK_REMEMBERSESSION);
bool isSnapshot = isCheckedOrNot(IDC_BACKUPDIR_RESTORESESSION_CHECK);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_RESTORESESSION_CHECK), rememberSession);
::EnableWindow(::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_STATIC1), isSnapshot);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_RESTORESESSION_EDIT), isSnapshot);
::EnableWindow(::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_STATIC2), isSnapshot);
::EnableWindow(::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_PATHLABEL_STATIC), isSnapshot);
::EnableWindow(::GetDlgItem(_hSelf, IDD_BACKUPDIR_RESTORESESSION_PATH_EDIT), isSnapshot);
bool noBackup = BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_RADIO_BKNONE, BM_GETCHECK, 0, 0);
@ -3534,13 +3580,14 @@ void BackupSubDlg::updateBackupGUI()
//::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_USERCUSTOMDIR_GRPSTATIC), isEnableGlobableCheck);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_CHECK), isEnableGlobableCheck);
::EnableWindow(::GetDlgItem(_hSelf, IDD_BACKUPDIR_STATIC), isEnableLocalCheck);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_EDIT), isEnableLocalCheck);
::EnableWindow(::GetDlgItem(_hSelf, IDD_BACKUPDIR_BROWSE_BUTTON), isEnableLocalCheck);
redraw();
}
intptr_t CALLBACK AutoCompletionSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
intptr_t CALLBACK AutoCompletionSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
NppParameters& nppParam = NppParameters::getInstance();
NppGUI & nppGUI = nppParam.getNppGUI();
@ -3581,10 +3628,6 @@ intptr_t CALLBACK AutoCompletionSubDlg::run_dlgProc(UINT message, WPARAM wParam,
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_USEENTER), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_USETAB), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_IGNORENUMBERS), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_FROM), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_CHAR), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_NOTE), FALSE);
}
::SendDlgItemMessage(_hSelf, IDC_CHECK_MAINTAININDENT, BM_SETCHECK, nppGUI._maitainIndent, 0);
@ -3663,11 +3706,34 @@ intptr_t CALLBACK AutoCompletionSubDlg::run_dlgProc(UINT message, WPARAM wParam,
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
LRESULT result = FALSE;
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
result = NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_FROM) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_CHAR) ||
(HWND)lParam == ::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_NOTE)
)
{
if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDD_AUTOC_ENABLECHECK, BM_GETCHECK, 0, 0))
{
if (NppDarkMode::isEnabled())
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
else
SetTextColor((HDC)wParam, RGB(0, 0, 0));
_nbCharVal.display(true);
}
else
{
SetTextColor((HDC)wParam, NppDarkMode::getDisabledTextColor());
_nbCharVal.display(false);
}
}
return result;
}
case WM_PRINTCLIENT:
@ -3754,10 +3820,8 @@ intptr_t CALLBACK AutoCompletionSubDlg::run_dlgProc(UINT message, WPARAM wParam,
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_USEENTER), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_USETAB), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_IGNORENUMBERS), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_FROM), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_CHAR), isEnableAutoC);
::EnableWindow(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_NOTE), isEnableAutoC);
redraw();
return TRUE;
}