mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 05:45:00 +02:00
Apply dark mode on color popup
Fix use of dark mode edge color in light mode for color picker button. Properly redraw disabled color picker button. Fix #10269, close #10270
This commit is contained in:
parent
1214319839
commit
31c72b7388
@ -59,9 +59,16 @@ void ColourPicker::drawBackground(HDC hDC)
|
||||
getClientRect(rc);
|
||||
hbrush = ::CreateSolidBrush(_currentColour);
|
||||
HGDIOBJ oldObj = ::SelectObject(hDC, hbrush);
|
||||
auto holdPen = static_cast<HPEN>(::SelectObject(hDC, NppDarkMode::getEdgePen()));
|
||||
HPEN holdPen = nullptr;
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
holdPen = static_cast<HPEN>(::SelectObject(hDC, NppDarkMode::getEdgePen()));
|
||||
}
|
||||
::Rectangle(hDC, 0, 0, rc.right, rc.bottom);
|
||||
if (NppDarkMode::isEnabled() && holdPen)
|
||||
{
|
||||
::SelectObject(hDC, holdPen);
|
||||
}
|
||||
::SelectObject(hDC, oldObj);
|
||||
//FillRect(hDC, &rc, hbrush);
|
||||
::DeleteObject(hbrush);
|
||||
@ -132,6 +139,15 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
}
|
||||
|
||||
case NPPM_INTERNAL_REFRESHDARKMODE:
|
||||
{
|
||||
if (_pColourPopup)
|
||||
{
|
||||
::SendMessage(_pColourPopup->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
{
|
||||
HDC dc = (HDC)wParam;
|
||||
@ -162,7 +178,7 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if ((BOOL)wParam == FALSE)
|
||||
{
|
||||
_currentColour = ::GetSysColor(COLOR_3DFACE);
|
||||
_currentColour = NppDarkMode::isEnabled() ? NppDarkMode::getDarkerBackgroundColor() : ::GetSysColor(COLOR_3DFACE);
|
||||
redraw();
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include "ColourPopup.h"
|
||||
#include "NppDarkMode.h"
|
||||
|
||||
DWORD colourItems[] = {
|
||||
RGB( 0, 0, 0), RGB( 64, 0, 0), RGB(128, 0, 0), RGB(128, 64, 64), RGB(255, 0, 0), RGB(255, 128, 128),
|
||||
@ -82,6 +83,8 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
|
||||
|
||||
int nColor;
|
||||
for (nColor = 0 ; nColor < int(sizeof(colourItems)/sizeof(DWORD)) ; ++nColor)
|
||||
{
|
||||
@ -92,7 +95,29 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
}
|
||||
|
||||
case WM_CTLCOLORLISTBOX:
|
||||
return (LRESULT) CreateSolidBrush(GetSysColor(COLOR_3DFACE));
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
|
||||
}
|
||||
return reinterpret_cast<LRESULT>(::GetStockObject(NULL_BRUSH));
|
||||
}
|
||||
|
||||
case WM_CTLCOLORDLG:
|
||||
case WM_CTLCOLORSTATIC:
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case NPPM_INTERNAL_REFRESHDARKMODE:
|
||||
{
|
||||
NppDarkMode::autoThemeChildControls(_hSelf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_DRAWITEM:
|
||||
{
|
||||
@ -122,7 +147,9 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
hbrush = CreateSolidBrush((COLORREF)cr);
|
||||
FillRect(hdc, &rc, hbrush);
|
||||
DeleteObject(hbrush);
|
||||
FrameRect(hdc, &rc, (HBRUSH) GetStockObject(GRAY_BRUSH));
|
||||
hbrush = CreateSolidBrush(NppDarkMode::isEnabled() ? NppDarkMode::getEdgeColor() : RGB(0, 0, 0));
|
||||
FrameRect(hdc, &rc, hbrush);
|
||||
DeleteObject(hbrush);
|
||||
break;
|
||||
}
|
||||
// *** FALL THROUGH ***
|
||||
@ -133,7 +160,7 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
rc.bottom --;
|
||||
rc.right --;
|
||||
// Draw the lighted side.
|
||||
HPEN hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNSHADOW));
|
||||
HPEN hpen = CreatePen(PS_SOLID, 1, NppDarkMode::isEnabled() ? NppDarkMode::getEdgeColor() : GetSysColor(COLOR_BTNSHADOW));
|
||||
HPEN holdPen = (HPEN)SelectObject(hdc, hpen);
|
||||
MoveToEx(hdc, rc.left, rc.bottom, NULL);
|
||||
LineTo(hdc, rc.left, rc.top);
|
||||
@ -141,7 +168,7 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
SelectObject(hdc, holdPen);
|
||||
DeleteObject(hpen);
|
||||
// Draw the darkened side.
|
||||
hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_BTNHIGHLIGHT));
|
||||
hpen = CreatePen(PS_SOLID, 1, NppDarkMode::isEnabled() ? NppDarkMode::getEdgeColor() : GetSysColor(COLOR_BTNHIGHLIGHT));
|
||||
holdPen = (HPEN)SelectObject(hdc, hpen);
|
||||
LineTo(hdc, rc.right, rc.bottom);
|
||||
LineTo(hdc, rc.left, rc.bottom);
|
||||
@ -150,7 +177,7 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
}
|
||||
else
|
||||
{
|
||||
hbrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
|
||||
hbrush = CreateSolidBrush(NppDarkMode::isEnabled() ? NppDarkMode::getDarkerBackgroundColor() : GetSysColor(COLOR_3DFACE));
|
||||
FrameRect(hdc, &rc, hbrush);
|
||||
DeleteObject(hbrush);
|
||||
}
|
||||
@ -229,6 +256,3 @@ INT_PTR CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "ColourPopupResource.h"
|
||||
|
||||
IDD_COLOUR_POPUP DIALOGEX 0, 0, 132, 113
|
||||
STYLE DS_SETFONT | WS_POPUP | DS_MODALFRAME
|
||||
STYLE DS_SETFONT | WS_POPUP | WS_BORDER
|
||||
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
|
||||
BEGIN
|
||||
LISTBOX IDC_COLOUR_LIST,7,7,117,79,
|
||||
|
@ -190,6 +190,14 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
|
||||
}
|
||||
|
||||
case WM_CTLCOLORLISTBOX:
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_CTLCOLORDLG:
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
@ -228,6 +236,8 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l
|
||||
case NPPM_INTERNAL_REFRESHDARKMODE:
|
||||
{
|
||||
NppDarkMode::autoThemeChildControls(_hSelf);
|
||||
::SendMessage(_pFgColour->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
|
||||
::SendMessage(_pBgColour->getHSelf(), NPPM_INTERNAL_REFRESHDARKMODE, 0, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1123,7 +1123,8 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_OLIVE), enableDarkMode);
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_CUSTOMIZED), enableDarkMode);
|
||||
|
||||
enableCustomizedColorCtrls(enableDarkMode&& nppGUI._darkmode._colorTone == NppDarkMode::customizedTone);
|
||||
doEnableCustomizedColorCtrls = enableDarkMode && nppGUI._darkmode._colorTone == NppDarkMode::customizedTone;
|
||||
enableCustomizedColorCtrls(doEnableCustomizedColorCtrls);
|
||||
|
||||
// Maintain the coherence in preferences
|
||||
if (nppGUI._darkmode._isEnabled)
|
||||
@ -1293,6 +1294,7 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
NppDarkMode::setDarkTone(nppGUI._darkmode._colorTone);
|
||||
changed = true;
|
||||
forceRefresh = true;
|
||||
doEnableCustomizedColorCtrls = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1305,6 +1307,24 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||
|
||||
if (changed)
|
||||
{
|
||||
if (!doEnableCustomizedColorCtrls)
|
||||
{
|
||||
COLORREF disabledColor = nppGUI._darkmode._isEnabled ? NppDarkMode::getDarkerBackgroundColor() : ::GetSysColor(COLOR_3DFACE);
|
||||
|
||||
_pBackgroundColorPicker->setColour(disabledColor);
|
||||
_pSofterBackgroundColorPicker->setColour(disabledColor);
|
||||
_pHotBackgroundColorPicker->setColour(disabledColor);
|
||||
_pPureBackgroundColorPicker->setColour(disabledColor);
|
||||
_pErrorBackgroundColorPicker->setColour(disabledColor);
|
||||
_pTextColorPicker->setColour(disabledColor);
|
||||
_pDarkerTextColorPicker->setColour(disabledColor);
|
||||
_pDisabledTextColorPicker->setColour(disabledColor);
|
||||
_pEdgeColorPicker->setColour(disabledColor);
|
||||
_pLinkColorPicker->setColour(disabledColor);
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
NppDarkMode::refreshDarkMode(_hSelf, forceRefresh);
|
||||
getFocus(); // to make black mode title bar appear
|
||||
return TRUE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user