Dark find and replace dialog enhancement and fixes

1. Make color more consistent.
2. Fix bug with trackbar (Transparency option) not changing background, when changing background color.
3. Fix visual glitch.
4. Enhancement to combobox, including DPI fixes.
5. Make listbox of combobox use dark scrollbar.

Fix #10027, fix #10221, close #10220
This commit is contained in:
ozone10 2021-07-21 21:23:08 +02:00 committed by Don Ho
parent 8bf11be0b5
commit a4cfd2a126
8 changed files with 103 additions and 47 deletions

View File

@ -7521,6 +7521,8 @@ void Notepad_plus::refreshDarkMode()
for (auto &hwndDlg : _hModelessDlgs)
{
NppDarkMode::setDarkTitleBar(hwndDlg);
::SendMessage(hwndDlg, NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
::RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN);
}
for (auto &docCont : _dockingManager.getContainerInfo())
{
@ -7568,10 +7570,8 @@ void Notepad_plus::refreshDarkMode()
::SendMessage(_mainDocTab.getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
::SendMessage(_subDocTab.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);
RedrawWindow(_findReplaceDlg.getHSelf(), nullptr, nullptr, RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN);
SendMessage(_pPublicInterface->getHSelf(), NPPM_INTERNAL_CHANGETABBAEICONS, 0, NppDarkMode::isEnabled() ? 2 : 0);
toolBarStatusType state = _toolBar.getState();

View File

@ -93,7 +93,7 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor
HEXRGB(0x808080) // edgeColor
HEXRGB(0x646464) // edgeColor
};
// red tone
@ -184,7 +184,7 @@ namespace NppDarkMode
HEXRGB(0xE0E0E0), // textColor
HEXRGB(0xC0C0C0), // darkerTextColor
HEXRGB(0x808080), // disabledTextColor
HEXRGB(0x808080) // edgeColor
HEXRGB(0x646464) // edgeColor
};
ColorTone g_colorToneChoice = blackTone;
@ -983,7 +983,7 @@ namespace NppDarkMode
GetThemeBackgroundContentRect(buttonData.hTheme, hdc, BP_GROUPBOX, iStateID, &rcBackground, &rcContent);
ExcludeClipRect(hdc, rcContent.left, rcContent.top, rcContent.right, rcContent.bottom);
DrawThemeParentBackground(hwnd, hdc, &rcClient);
//DrawThemeParentBackground(hwnd, hdc, &rcClient);
DrawThemeBackground(buttonData.hTheme, hdc, BP_GROUPBOX, iStateID, &rcBackground, nullptr);
SelectClipRgn(hdc, nullptr);
@ -1129,8 +1129,8 @@ namespace NppDarkMode
}
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
FillRect(hdc, &ps.rcPaint, NppDarkMode::getBackgroundBrush());
HDC hdc = ::BeginPaint(hWnd, &ps);
::FillRect(hdc, &ps.rcPaint, NppDarkMode::getDarkerBackgroundBrush());
auto holdPen = static_cast<HPEN>(::SelectObject(hdc, NppDarkMode::getEdgePen()));
@ -1174,7 +1174,11 @@ namespace NppDarkMode
SetTextColor(hdc, (bHot || (i == nSelTab) ) ? NppDarkMode::getTextColor() : NppDarkMode::getDarkerTextColor());
FillRect(hdc, &rcItem, (i == nSelTab) ? NppDarkMode::getBackgroundBrush() : NppDarkMode::getSofterBackgroundBrush());
// for consistency getBackgroundBrush()
// would be better, than getSofterBackgroundBrush(),
// however default getBackgroundBrush() has same color
// as getDarkerBackgroundBrush()
::FillRect(hdc, &rcItem, (i == nSelTab) ? NppDarkMode::getDarkerBackgroundBrush() : NppDarkMode::getSofterBackgroundBrush());
SetBkMode(hdc, TRANSPARENT);
@ -1190,7 +1194,8 @@ namespace NppDarkMode
rcText.left += NppParameters::getInstance()._dpiManager.scaleX(6);
rcText.right -= NppParameters::getInstance()._dpiManager.scaleX(3);
if (i == nSelTab) {
if (i == nSelTab)
{
rcText.bottom -= NppParameters::getInstance()._dpiManager.scaleX(4);
}
@ -1261,32 +1266,42 @@ namespace NppDarkMode
::SelectObject(hdc, ::GetStockObject(NULL_BRUSH)); // to avoid text flicker, use only border
::Rectangle(hdc, 0, 0, rc.right, rc.bottom);
auto holdBrush = ::SelectObject(hdc, NppDarkMode::getBackgroundBrush());
// CBS_DROPDOWN text is handled by parent by WM_CTLCOLOREDIT
auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE);
if ((style & CBS_DROPDOWNLIST) == CBS_DROPDOWNLIST)
{
auto index = static_cast<int>(::SendMessage(hWnd, CB_GETCURSEL, 0, 0));
if (index != CB_ERR)
{
::SetTextColor(hdc, NppDarkMode::getTextColor());
auto bufferLen = static_cast<size_t>(::SendMessage(hWnd, CB_GETLBTEXTLEN, index, 0));
TCHAR* buffer = new TCHAR[(bufferLen + 1)];
::SendMessage(hWnd, CB_GETLBTEXT, index, reinterpret_cast<LPARAM>(buffer));
RECT textRc = rc;
textRc.left += NppParameters::getInstance()._dpiManager.scaleX(4);
textRc.right -= NppParameters::getInstance()._dpiManager.scaleX(23);
::DrawText(hdc, buffer, -1, &textRc, DT_EDITCONTROL | DT_NOPREFIX | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
delete[]buffer;
}
}
auto holdBrush = ::SelectObject(hdc, NppDarkMode::getDarkerBackgroundBrush());
RECT arrowRc = {
rc.right - NppParameters::getInstance()._dpiManager.scaleX(17), rc.top + 1,
rc.right - 1, rc.bottom - 1
};
// CBS_DROPDOWN text is handled by parent by WM_CTLCOLOREDIT
auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE);
if ((style & CBS_DROPDOWNLIST) == CBS_DROPDOWNLIST)
{
RECT bkRc = rc;
bkRc.left += 1;
bkRc.top += 1;
bkRc.right = arrowRc.left - 1;
bkRc.bottom -= 1;
::FillRect(hdc, &bkRc, NppDarkMode::getBackgroundBrush()); // erase background on item change
auto index = static_cast<int>(::SendMessage(hWnd, CB_GETCURSEL, 0, 0));
if (index != CB_ERR)
{
::SetTextColor(hdc, NppDarkMode::getTextColor());
::SetBkColor(hdc, NppDarkMode::getBackgroundColor());
auto bufferLen = static_cast<size_t>(::SendMessage(hWnd, CB_GETLBTEXTLEN, index, 0));
TCHAR* buffer = new TCHAR[(bufferLen + 1)];
::SendMessage(hWnd, CB_GETLBTEXT, index, reinterpret_cast<LPARAM>(buffer));
RECT textRc = rc;
textRc.left += 4;
textRc.right = arrowRc.left - 5;
::DrawText(hdc, buffer, -1, &textRc, DT_NOPREFIX | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
delete[]buffer;
}
}
POINT ptCursor = { 0 };
::GetCursorPos(&ptCursor);
ScreenToClient(hWnd, &ptCursor);
@ -1296,8 +1311,8 @@ namespace NppDarkMode
::SetTextColor(hdc, isHot ? NppDarkMode::getTextColor() : NppDarkMode::getDarkerTextColor());
::SetBkColor(hdc, isHot ? NppDarkMode::getHotBackgroundColor() : NppDarkMode::getBackgroundColor());
::ExtTextOut(hdc,
rc.right - NppParameters::getInstance()._dpiManager.scaleX(13),
rc.top + 4,
arrowRc.left + (arrowRc.right - arrowRc.left) / 2 - NppParameters::getInstance()._dpiManager.scaleX(4),
arrowRc.top + 3,
ETO_OPAQUE | ETO_CLIPPED,
&arrowRc, L"˅",
1,
@ -1305,8 +1320,8 @@ namespace NppDarkMode
::SetBkColor(hdc, NppDarkMode::getBackgroundColor());
POINT edge[] = {
{rc.right - NppParameters::getInstance()._dpiManager.scaleX(18), rc.top + 1},
{rc.right - NppParameters::getInstance()._dpiManager.scaleX(18), rc.bottom - 1}
{arrowRc.left - 1, arrowRc.top},
{arrowRc.left - 1, arrowRc.bottom}
};
::Polyline(hdc, edge, _countof(edge));
@ -1358,11 +1373,47 @@ namespace NppDarkMode
if ((style & CBS_DROPDOWNLIST) == CBS_DROPDOWNLIST || (style & CBS_DROPDOWN) == CBS_DROPDOWN)
{
COMBOBOXINFO cbi = {};
cbi.cbSize = sizeof(COMBOBOXINFO);
BOOL result = GetComboBoxInfo(hwnd, &cbi);
if (result == TRUE)
{
if (p.theme && cbi.hwndList)
{
//dark scrollbar for listbox of combobox
SetWindowTheme(cbi.hwndList, p.themeClassName, nullptr);
}
}
NppDarkMode::subclassComboBoxControl(hwnd);
}
return TRUE;
}
if (wcscmp(className, WC_LISTBOX) == 0)
{
if (p.theme)
{
//dark scrollbar for listbox
SetWindowTheme(hwnd, p.themeClassName, nullptr);
}
return TRUE;
}
if (wcscmp(className, WC_EDIT) == 0)
{
auto style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
bool hasScrollBar = ((style & WS_HSCROLL) == WS_HSCROLL) || ((style & WS_VSCROLL) == WS_VSCROLL);
if (p.theme && hasScrollBar)
{
//dark scrollbar for edit control
SetWindowTheme(hwnd, p.themeClassName, nullptr);
}
return TRUE;
}
if (wcscmp(className, WC_BUTTON) == 0)
{
auto nButtonStyle = ::GetWindowLongPtr(hwnd, GWL_STYLE) & 0xF;
@ -1517,6 +1568,13 @@ namespace NppDarkMode
return reinterpret_cast<LRESULT>(NppDarkMode::getSofterBackgroundBrush());
}
LRESULT onCtlColorDarker(HDC hdc)
{
::SetTextColor(hdc, NppDarkMode::getTextColor());
::SetBkColor(hdc, NppDarkMode::getDarkerBackgroundColor());
return reinterpret_cast<LRESULT>(NppDarkMode::getDarkerBackgroundBrush());
}
LRESULT onCtlColorError(HDC hdc)
{
::SetTextColor(hdc, NppDarkMode::getTextColor());

View File

@ -136,5 +136,6 @@ namespace NppDarkMode
LRESULT onCtlColor(HDC hdc);
LRESULT onCtlColorSofter(HDC hdc);
LRESULT onCtlColorDarker(HDC hdc);
LRESULT onCtlColorError(HDC hdc);
}

View File

@ -858,13 +858,13 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
break;
}
case WM_CTLCOLORLISTBOX:
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
case WM_CTLCOLORLISTBOX:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
}
@ -884,7 +884,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
{
RECT rc = { 0 };
getClientRect(rc);
FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getBackgroundBrush());
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
}
break;

View File

@ -82,7 +82,7 @@ BEGIN
CONTROL "Transparenc&y",IDC_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,254,131,80,10
CONTROL "On losing focus",IDC_TRANSPARENT_LOSSFOCUS_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,268,143,85,10
CONTROL "Always",IDC_TRANSPARENT_ALWAYS_RADIO,"Button",BS_AUTORADIOBUTTON ,268,155,85,10
CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,265,166,85,10
CONTROL "",IDC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | NOT WS_VISIBLE | WS_TABSTOP,265,166,85,10
END
IDB_INCREMENTAL_BG BITMAP "../icons/incrementalBg.bmp"

View File

@ -228,7 +228,7 @@ BEGIN
LTEXT "User language : ",IDC_LANGNAME_STATIC,0,3,63,8,0,WS_EX_RIGHT
COMBOBOX IDC_LANGNAME_COMBO,64,1,90,58,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
CONTROL "Transparency",IDC_UD_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,408,22,66,10
CONTROL "",IDC_UD_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,422,33,53,10
CONTROL "",IDC_UD_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | NOT WS_VISIBLE | WS_TABSTOP,422,33,53,10
PUSHBUTTON "Dock",IDC_DOCK_BUTTON,425,1,50,14,BS_FLAT
PUSHBUTTON "Create New...",IDC_ADDNEW_BUTTON,161,1,62,14
PUSHBUTTON "Save As...",IDC_SAVEAS_BUTTON,226,1,62,14

View File

@ -54,7 +54,7 @@ BEGIN
LTEXT "+",IDC_PLUSSYMBOL_STATIC,335,166,8,8
PUSHBUTTON "Cancel",IDCANCEL,332,222,57,14
PUSHBUTTON "Save && Close",IDC_SAVECLOSE_BUTTON,255,222,69,14
CONTROL "",IDC_SC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | NOT WS_VISIBLE | WS_TABSTOP,441,235,53,10
CONTROL "",IDC_SC_PERCENTAGE_SLIDER,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | NOT WS_VISIBLE | WS_TABSTOP,441,235,53,10
CONTROL "Transparency",IDC_SC_TRANSPARENT_CHECK,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,431,221,63,10
LISTBOX IDC_LANGUAGES_LIST,17,46,59,146,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LISTBOX IDC_STYLES_LIST,87,46,76,146,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
@ -75,6 +75,4 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,179,135,10
CONTROL "Enable global underline font style",IDC_GLOBAL_UNDERLINE_CHECK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,194,135,10
END

View File

@ -81,7 +81,7 @@ BEGIN
LTEXT "Width :",IDC_WIDTH_STATIC,81,27,37,8,0,WS_EX_RIGHT
COMBOBOX IDC_WIDTH_COMBO,125,25,40,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "Blink rate :",IDC_BLINKRATE_STATIC,57,52,60,8
CONTROL "",IDC_CARETBLINKRATE_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,134,52,67,13
CONTROL "",IDC_CARETBLINKRATE_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | WS_TABSTOP,134,52,67,13
LTEXT "S",IDC_CARETBLINKRATE_S_STATIC,203,52,12,8
LTEXT "F",IDC_CARETBLINKRATE_F_STATIC,122,52,12,8,0,WS_EX_RIGHT
GROUPBOX "Line Wrap",IDC_LW_GB_STATIC,265,6,92,66,BS_CENTER
@ -136,7 +136,7 @@ BEGIN
EDITTEXT IDC_COLUMNPOS_EDIT,126,93,125,36,ES_MULTILINE
CONTROL "Background mode",IDC_CHECK_EDGEBGMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,127,138,122,10
GROUPBOX "Border Width",IDC_BORDERWIDTH_STATIC,22,112,83,45,BS_CENTER
CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,24,125,67,13
CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | WS_TABSTOP,24,125,67,13
LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,92,126,12,8
CONTROL "No edge",IDC_CHECK_NOEDGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,142,60,10
GROUPBOX "Line Number",IDC_LINENUMBERMARGE_GB_STATIC,274,21,135,66,BS_CENTER
@ -146,13 +146,13 @@ BEGIN
CONTROL "Display bookmark",IDC_CHECK_BOOKMARKMARGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,281,163,150,10
GROUPBOX "Padding",IDC_PADDING_STATIC,274,94,135,63,BS_CENTER
RTEXT "Left",IDC_PADDINGLEFT_STATIC,280,108,45,8
CONTROL "",IDC_PADDINGLEFT_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,328,107,67,13
CONTROL "",IDC_PADDINGLEFT_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | WS_TABSTOP,328,107,67,13
LTEXT "0",IDC_PADDINGLEFTVAL_STATIC,396,108,12,8
RTEXT "Right",IDC_PADDINGRIGHT_STATIC,282,124,43,8
CONTROL "",IDC_PADDINGRIGHT_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,328,123,67,13
CONTROL "",IDC_PADDINGRIGHT_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | WS_TABSTOP,328,123,67,13
LTEXT "0",IDC_PADDINGRIGHTVAL_STATIC,396,124,12,8
RTEXT "Distraction Free",IDC_DISTRACTIONFREE_STATIC,275,140,72,8
CONTROL "",IDC_DISTRACTIONFREE_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,348,139,47,13
CONTROL "",IDC_DISTRACTIONFREE_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | TBS_TRANSPARENTBKGND | WS_TABSTOP,348,139,47,13
LTEXT "0",IDC_DISTRACTIONFREEVAL_STATIC,396,140,12,8
END
@ -478,4 +478,3 @@ BEGIN
RTEXT "Session file ext.:",IDC_SESSIONFILEEXT_STATIC,270,130,108,8
RTEXT "Workspace file ext.:",IDC_WORKSPACEFILEEXT_STATIC,270,147,108,8
END