Edge Enhancement
Make changing edge color dynamic. Apply color on docking panels caption, color button. Add status bar separators. Fix #10166, close #10167pull/10173/head
parent
93d91c3ee2
commit
33fa3b6198
|
@ -56,6 +56,28 @@ namespace NppDarkMode
|
|||
}
|
||||
};
|
||||
|
||||
struct Pens
|
||||
{
|
||||
HPEN edgePen = nullptr;
|
||||
|
||||
Pens(const Colors& colors)
|
||||
: edgePen(::CreatePen(PS_SOLID, 1, colors.edge))
|
||||
{}
|
||||
|
||||
~Pens()
|
||||
{
|
||||
::DeleteObject(edgePen); edgePen = nullptr;
|
||||
}
|
||||
|
||||
void change(const Colors& colors)
|
||||
{
|
||||
::DeleteObject(edgePen);
|
||||
|
||||
edgePen = ::CreatePen(PS_SOLID, 1, colors.edge);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// black (default)
|
||||
static const Colors darkColors{
|
||||
HEXRGB(0x202020), // background
|
||||
|
@ -172,16 +194,19 @@ namespace NppDarkMode
|
|||
{
|
||||
Colors _colors;
|
||||
Brushes _brushes;
|
||||
Pens _pens;
|
||||
|
||||
Theme(const Colors& colors)
|
||||
: _colors(colors)
|
||||
, _brushes(colors)
|
||||
, _pens(colors)
|
||||
{}
|
||||
|
||||
void change(const Colors& colors)
|
||||
{
|
||||
_colors = colors;
|
||||
_brushes.change(colors);
|
||||
_pens.change(colors);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -345,6 +370,8 @@ namespace NppDarkMode
|
|||
HBRUSH getDarkerBackgroundBrush() { return getTheme()._brushes.pureBackground; }
|
||||
HBRUSH getErrorBackgroundBrush() { return getTheme()._brushes.errorBackground; }
|
||||
|
||||
HPEN getEdgePen() { return getTheme()._pens.edgePen; }
|
||||
|
||||
void setBackgroundColor(COLORREF c)
|
||||
{
|
||||
Colors clrs = getTheme()._colors;
|
||||
|
@ -1100,9 +1127,7 @@ namespace NppDarkMode
|
|||
HDC hdc = BeginPaint(hWnd, &ps);
|
||||
FillRect(hdc, &ps.rcPaint, NppDarkMode::getBackgroundBrush());
|
||||
|
||||
static HPEN g_hpen = CreatePen(PS_SOLID, 1, NppDarkMode::getEdgeColor());
|
||||
|
||||
HPEN holdPen = (HPEN)SelectObject(hdc, g_hpen);
|
||||
auto holdPen = static_cast<HPEN>(::SelectObject(hdc, NppDarkMode::getEdgePen()));
|
||||
|
||||
HRGN holdClip = CreateRectRgn(0, 0, 0, 0);
|
||||
if (1 != GetClipRgn(hdc, holdClip))
|
||||
|
|
|
@ -81,6 +81,8 @@ namespace NppDarkMode
|
|||
HBRUSH getHotBackgroundBrush();
|
||||
HBRUSH getErrorBackgroundBrush();
|
||||
|
||||
HPEN getEdgePen();
|
||||
|
||||
void setBackgroundColor(COLORREF c);
|
||||
void setSofterBackgroundColor(COLORREF c);
|
||||
void setHotBackgroundColor(COLORREF c);
|
||||
|
|
|
@ -13,13 +13,12 @@
|
|||
//
|
||||
// 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 "ColourPicker.h"
|
||||
#include "ColourPopup.h"
|
||||
|
||||
|
||||
|
||||
#include "NppDarkMode.h"
|
||||
|
||||
void ColourPicker::init(HINSTANCE hInst, HWND parent)
|
||||
{
|
||||
|
@ -60,7 +59,9 @@ void ColourPicker::drawBackground(HDC hDC)
|
|||
getClientRect(rc);
|
||||
hbrush = ::CreateSolidBrush(_currentColour);
|
||||
HGDIOBJ oldObj = ::SelectObject(hDC, hbrush);
|
||||
auto holdPen = static_cast<HPEN>(::SelectObject(hDC, NppDarkMode::getEdgePen()));
|
||||
::Rectangle(hDC, 0, 0, rc.right, rc.bottom);
|
||||
::SelectObject(hDC, holdPen);
|
||||
::SelectObject(hDC, oldObj);
|
||||
//FillRect(hDC, &rc, hbrush);
|
||||
::DeleteObject(hbrush);
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "SplitterContainer.h"
|
||||
#include "ToolTip.h"
|
||||
#include "Parameters.h"
|
||||
#include "NppDarkMode.h"
|
||||
#include "localization.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -456,6 +455,8 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct)
|
|||
// begin with paint
|
||||
::SetBkMode(hDc, TRANSPARENT);
|
||||
|
||||
auto holdPen = static_cast<HPEN>(::SelectObject(hDc, NppDarkMode::isEnabled() ? NppDarkMode::getEdgePen() : hPen));
|
||||
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
bgbrush = ::CreateSolidBrush(_isActive ? NppDarkMode::getSofterBackgroundColor() : NppDarkMode::getBackgroundColor());
|
||||
|
@ -566,6 +567,7 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct)
|
|||
::SelectObject(hDc, hOldFont);
|
||||
::DeleteObject(hFont);
|
||||
}
|
||||
::SelectObject(hDc, holdPen);
|
||||
::DeleteObject(hPen);
|
||||
::DeleteObject(bgbrush);
|
||||
|
||||
|
@ -700,9 +702,7 @@ LRESULT DockingCont::runProcTab(HWND hwnd, UINT Message, WPARAM wParam, LPARAM l
|
|||
|
||||
UINT id = ::GetDlgCtrlID(hwnd);
|
||||
|
||||
static HPEN g_hpen = CreatePen(PS_SOLID, 1, NppDarkMode::getEdgeColor());
|
||||
|
||||
HPEN holdPen = (HPEN)SelectObject(hdc, g_hpen);
|
||||
auto holdPen = static_cast<HPEN>(::SelectObject(hdc, NppDarkMode::getEdgePen()));
|
||||
|
||||
HRGN holdClip = CreateRectRgn(0, 0, 0, 0);
|
||||
if (1 != GetClipRgn(hdc, holdClip))
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
// 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 <stdexcept>
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
|
@ -29,15 +28,12 @@
|
|||
//#define IDC_STATUSBAR 789
|
||||
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
defaultPartWidth = 5,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
StatusBar::~StatusBar()
|
||||
{
|
||||
delete[] _lpParts;
|
||||
|
@ -49,6 +45,7 @@ void StatusBar::init(HINSTANCE, HWND)
|
|||
assert(false and "should never be called");
|
||||
}
|
||||
|
||||
|
||||
struct StatusBarSubclassInfo
|
||||
{
|
||||
HTHEME hTheme = nullptr;
|
||||
|
@ -77,8 +74,10 @@ struct StatusBarSubclassInfo
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
constexpr UINT_PTR g_statusBarSubclassID = 42;
|
||||
|
||||
|
||||
LRESULT CALLBACK StatusBarSubclass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(uIdSubclass);
|
||||
|
@ -121,6 +120,8 @@ LRESULT CALLBACK StatusBarSubclass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(hWnd, &ps);
|
||||
|
||||
auto holdPen = static_cast<HPEN>(::SelectObject(hdc, NppDarkMode::getEdgePen()));
|
||||
|
||||
HFONT holdFont = (HFONT)::SelectObject(hdc, NppParameters::getInstance().getDefaultUIFont());
|
||||
|
||||
RECT rcClient;
|
||||
|
@ -140,6 +141,15 @@ LRESULT CALLBACK StatusBarSubclass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
continue;
|
||||
}
|
||||
|
||||
if (nParts > 2) //to not apply on status bar in find dialog
|
||||
{
|
||||
POINT edges[] = {
|
||||
{rcPart.right - 2, rcPart.top + 1},
|
||||
{rcPart.right - 2, rcPart.bottom - 3}
|
||||
};
|
||||
Polyline(hdc, edges, _countof(edges));
|
||||
}
|
||||
|
||||
RECT rcDivider = { rcPart.right - borders.vertical, rcPart.top, rcPart.right, rcPart.bottom };
|
||||
|
||||
DWORD cchText = 0;
|
||||
|
@ -198,6 +208,7 @@ LRESULT CALLBACK StatusBarSubclass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
}
|
||||
|
||||
::SelectObject(hdc, holdFont);
|
||||
::SelectObject(hdc, holdPen);
|
||||
|
||||
EndPaint(hWnd, &ps);
|
||||
return FALSE;
|
||||
|
@ -214,6 +225,7 @@ LRESULT CALLBACK StatusBarSubclass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
void StatusBar::init(HINSTANCE hInst, HWND hPere, int nbParts)
|
||||
{
|
||||
Window::init(hInst, hPere);
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
// 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 <stdexcept>
|
||||
#include "TabBar.h"
|
||||
#include "Parameters.h"
|
||||
|
@ -898,9 +896,7 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
|
|||
|
||||
UINT id = ::GetDlgCtrlID(hwnd);
|
||||
|
||||
static HPEN g_hpen = CreatePen(PS_SOLID, 1, NppDarkMode::getEdgeColor());
|
||||
|
||||
HPEN holdPen = (HPEN)SelectObject(hdc, g_hpen);
|
||||
auto holdPen = static_cast<HPEN>(::SelectObject(hdc, NppDarkMode::getEdgePen()));
|
||||
|
||||
HRGN holdClip = CreateRectRgn(0, 0, 0, 0);
|
||||
if (1 != GetClipRgn(hdc, holdClip))
|
||||
|
|
Loading…
Reference in New Issue