Restore Splitter appearance in dark mode
Allow dynamic color change for arrows. Fix #10069, close #10199
This commit is contained in:
parent
8e38b9daba
commit
264e1924b0
|
@ -1,4 +1,4 @@
|
|||
#include "nppDarkMode.h"
|
||||
#include "NppDarkMode.h"
|
||||
|
||||
#include "DarkMode/DarkMode.h"
|
||||
#include "DarkMode/UAHMenuBar.h"
|
||||
|
@ -58,21 +58,26 @@ namespace NppDarkMode
|
|||
|
||||
struct Pens
|
||||
{
|
||||
HPEN darkerTextPen = nullptr;
|
||||
HPEN edgePen = nullptr;
|
||||
|
||||
Pens(const Colors& colors)
|
||||
: edgePen(::CreatePen(PS_SOLID, 1, colors.edge))
|
||||
: darkerTextPen(::CreatePen(PS_SOLID, 1, colors.darkerText))
|
||||
, edgePen(::CreatePen(PS_SOLID, 1, colors.edge))
|
||||
{}
|
||||
|
||||
~Pens()
|
||||
{
|
||||
::DeleteObject(darkerTextPen); darkerTextPen = nullptr;
|
||||
::DeleteObject(edgePen); edgePen = nullptr;
|
||||
}
|
||||
|
||||
void change(const Colors& colors)
|
||||
{
|
||||
::DeleteObject(darkerTextPen);
|
||||
::DeleteObject(edgePen);
|
||||
|
||||
darkerTextPen = ::CreatePen(PS_SOLID, 1, colors.darkerText);
|
||||
edgePen = ::CreatePen(PS_SOLID, 1, colors.edge);
|
||||
}
|
||||
|
||||
|
@ -369,6 +374,7 @@ namespace NppDarkMode
|
|||
HBRUSH getDarkerBackgroundBrush() { return getTheme()._brushes.pureBackground; }
|
||||
HBRUSH getErrorBackgroundBrush() { return getTheme()._brushes.errorBackground; }
|
||||
|
||||
HPEN getDarkerTextPen() { return getTheme()._pens.darkerTextPen; }
|
||||
HPEN getEdgePen() { return getTheme()._pens.edgePen; }
|
||||
|
||||
void setBackgroundColor(COLORREF c)
|
||||
|
|
|
@ -81,6 +81,7 @@ namespace NppDarkMode
|
|||
HBRUSH getHotBackgroundBrush();
|
||||
HBRUSH getErrorBackgroundBrush();
|
||||
|
||||
HPEN getDarkerTextPen();
|
||||
HPEN getEdgePen();
|
||||
|
||||
void setBackgroundColor(COLORREF c);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <windows.h>
|
||||
|
@ -398,7 +399,7 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara
|
|||
RECT rc = { 0 };
|
||||
getClientRect(rc);
|
||||
|
||||
FillRect((HDC)wParam, &rc, NppDarkMode::getSofterBackgroundBrush());
|
||||
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -522,12 +523,22 @@ void Splitter::drawSplitter()
|
|||
|
||||
bool isDarkMode = NppDarkMode::isEnabled();
|
||||
|
||||
HBRUSH hBrush = nullptr;
|
||||
HBRUSH hBrushTop = nullptr;
|
||||
|
||||
HPEN holdPen = nullptr;
|
||||
if (isDarkMode)
|
||||
{
|
||||
static HPEN g_hpen = CreatePen(PS_SOLID, 1, NppDarkMode::getDarkerTextColor());
|
||||
holdPen = (HPEN)SelectObject(hdc, g_hpen);
|
||||
FillRect(hdc, &rc, NppDarkMode::getSofterBackgroundBrush());
|
||||
hBrush = NppDarkMode::getBackgroundBrush();
|
||||
hBrushTop = NppDarkMode::getSofterBackgroundBrush();
|
||||
|
||||
holdPen = static_cast<HPEN>(::SelectObject(hdc, NppDarkMode::getDarkerTextPen()));
|
||||
::FillRect(hdc, &rc, NppDarkMode::getDarkerBackgroundBrush());
|
||||
}
|
||||
else
|
||||
{
|
||||
hBrush = ::CreateSolidBrush(RGB(0xFF, 0xFF, 0xFF));
|
||||
hBrushTop = ::GetSysColorBrush(COLOR_3DSHADOW);
|
||||
}
|
||||
|
||||
if ((_splitterSize >= 4) && (_dwFlags & SV_RESIZEWTHPERCNT))
|
||||
|
@ -560,7 +571,7 @@ void Splitter::drawSplitter()
|
|||
else
|
||||
bottom = rc.bottom;
|
||||
|
||||
while (!isDarkMode && rcToDraw1.bottom <= bottom)
|
||||
while (rcToDraw1.bottom <= bottom)
|
||||
{
|
||||
if (isVertical())
|
||||
{
|
||||
|
@ -581,8 +592,8 @@ void Splitter::drawSplitter()
|
|||
|
||||
while (rcToDraw1.right <= (isVertical() ? rc.right : rc.right - _clickZone2BR.right))
|
||||
{
|
||||
::FillRect(hdc, &rcToDraw1, (HBRUSH)(RGB(0xFF, 0xFF, 0xFF)));
|
||||
::FillRect(hdc, &rcToDraw2, (HBRUSH)(COLOR_3DSHADOW+1));
|
||||
::FillRect(hdc, &rcToDraw1, hBrush);
|
||||
::FillRect(hdc, &rcToDraw2, hBrushTop);
|
||||
|
||||
rcToDraw2.left += 4;
|
||||
rcToDraw2.right += 4;
|
||||
|
@ -601,7 +612,11 @@ void Splitter::drawSplitter()
|
|||
|
||||
if (isDarkMode)
|
||||
{
|
||||
SelectObject(hdc, holdPen);
|
||||
::SelectObject(hdc, holdPen);
|
||||
}
|
||||
else
|
||||
{
|
||||
::DeleteObject(hBrush);
|
||||
}
|
||||
|
||||
::EndPaint(_hSelf, &ps);
|
||||
|
@ -755,4 +770,3 @@ void Splitter::adjustZoneToDraw(RECT& rc2def, ZONE_TYPE whichZone)
|
|||
rc2def.right = x1;
|
||||
rc2def.bottom = y1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue