Edge Enhancement
Make changing edge color dynamic. Apply color on docking panels caption, color button. Add status bar separators. Fix #10166, close #10167
This commit is contained in:
parent
93d91c3ee2
commit
33fa3b6198
|
@ -42,9 +42,9 @@ namespace NppDarkMode
|
|||
|
||||
void change(const Colors& colors)
|
||||
{
|
||||
::DeleteObject(background);
|
||||
::DeleteObject(background);
|
||||
::DeleteObject(softerBackground);
|
||||
::DeleteObject(hotBackground);
|
||||
::DeleteObject(hotBackground);
|
||||
::DeleteObject(pureBackground);
|
||||
::DeleteObject(errorBackground);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -138,7 +137,7 @@ tTbData* DockingCont::createToolbar(tTbData data)
|
|||
}
|
||||
|
||||
// set attached child window
|
||||
::SetParent(pTbData->hClient, ::GetDlgItem(_hSelf, IDC_CLIENT_TAB));
|
||||
::SetParent(pTbData->hClient, ::GetDlgItem(_hSelf, IDC_CLIENT_TAB));
|
||||
|
||||
// set names for captions and view toolbar
|
||||
viewToolbar(pTbData);
|
||||
|
@ -345,21 +344,21 @@ LRESULT DockingCont::runProcCaption(HWND hwnd, UINT Message, WPARAM wParam, LPAR
|
|||
{
|
||||
if (_isMouseClose == FALSE)
|
||||
{
|
||||
// keep sure that button is still down and within caption
|
||||
if ((wParam == MK_LBUTTON) && (isInRect(hwnd, pt.x, pt.y) == posCaption))
|
||||
{
|
||||
_dragFromTab = FALSE;
|
||||
NotifyParent(DMM_MOVE);
|
||||
_isMouseDown = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isMouseDown = FALSE;
|
||||
}
|
||||
// keep sure that button is still down and within caption
|
||||
if ((wParam == MK_LBUTTON) && (isInRect(hwnd, pt.x, pt.y) == posCaption))
|
||||
{
|
||||
_dragFromTab = FALSE;
|
||||
NotifyParent(DMM_MOVE);
|
||||
_isMouseDown = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isMouseDown = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL isMouseOver = _isMouseOver;
|
||||
BOOL isMouseOver = _isMouseOver;
|
||||
_isMouseOver = (isInRect(hwnd, pt.x, pt.y) == posClose ? TRUE : FALSE);
|
||||
|
||||
// if state is changed draw new
|
||||
|
@ -456,7 +455,9 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct)
|
|||
// begin with paint
|
||||
::SetBkMode(hDc, TRANSPARENT);
|
||||
|
||||
if (NppDarkMode::isEnabled())
|
||||
auto holdPen = static_cast<HPEN>(::SelectObject(hDc, NppDarkMode::isEnabled() ? NppDarkMode::getEdgePen() : hPen));
|
||||
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
bgbrush = ::CreateSolidBrush(_isActive ? NppDarkMode::getSofterBackgroundColor() : NppDarkMode::getBackgroundColor());
|
||||
SetTextColor(hDc, NppDarkMode::getTextColor());
|
||||
|
@ -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,10 +225,11 @@ 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);
|
||||
InitCommonControls();
|
||||
InitCommonControls();
|
||||
|
||||
// _hSelf = CreateStatusWindow(WS_CHILD | WS_CLIPSIBLINGS, NULL, _hParent, IDC_STATUSBAR);
|
||||
_hSelf = ::CreateWindowEx(
|
||||
|
@ -240,7 +252,7 @@ void StatusBar::init(HINSTANCE hInst, HWND hPere, int nbParts)
|
|||
if (nbParts > 0)
|
||||
_partWidthArray.resize(nbParts, defaultPartWidth);
|
||||
|
||||
// Allocate an array for holding the right edge coordinates.
|
||||
// Allocate an array for holding the right edge coordinates.
|
||||
if (_partWidthArray.size())
|
||||
_lpParts = new int[_partWidthArray.size()];
|
||||
|
||||
|
@ -285,17 +297,17 @@ int StatusBar::getHeight() const
|
|||
|
||||
void StatusBar::adjustParts(int clientWidth)
|
||||
{
|
||||
// Calculate the right edge coordinate for each part, and
|
||||
// copy the coordinates to the array.
|
||||
int nWidth = std::max<int>(clientWidth - 20, 0);
|
||||
// Calculate the right edge coordinate for each part, and
|
||||
// copy the coordinates to the array.
|
||||
int nWidth = std::max<int>(clientWidth - 20, 0);
|
||||
|
||||
for (int i = static_cast<int>(_partWidthArray.size()) - 1; i >= 0; i--)
|
||||
{
|
||||
{
|
||||
_lpParts[i] = nWidth;
|
||||
nWidth -= _partWidthArray[i];
|
||||
}
|
||||
|
||||
// Tell the status bar to create the window parts.
|
||||
// Tell the status bar to create the window parts.
|
||||
::SendMessage(_hSelf, SB_SETPARTS, _partWidthArray.size(), reinterpret_cast<LPARAM>(_lpParts));
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
@ -58,7 +56,7 @@ void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLin
|
|||
int multiLine = isMultiLine ? TCS_MULTILINE : 0;
|
||||
|
||||
int style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE |\
|
||||
TCS_FOCUSNEVER | TCS_TABS | WS_TABSTOP | vertical | multiLine;
|
||||
TCS_FOCUSNEVER | TCS_TABS | WS_TABSTOP | vertical | multiLine;
|
||||
|
||||
_hSelf = ::CreateWindowEx(
|
||||
0,
|
||||
|
@ -127,12 +125,12 @@ void TabBar::setFont(const TCHAR *fontName, int fontSize)
|
|||
::DeleteObject(_hFont);
|
||||
|
||||
_hFont = ::CreateFont( fontSize, 0,
|
||||
(_isVertical) ? 900:0,
|
||||
(_isVertical) ? 900:0,
|
||||
FW_NORMAL,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
fontName);
|
||||
(_isVertical) ? 900:0,
|
||||
(_isVertical) ? 900:0,
|
||||
FW_NORMAL,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
fontName);
|
||||
if (_hFont)
|
||||
::SendMessage(_hSelf, WM_SETFONT, reinterpret_cast<WPARAM>(_hFont), 0);
|
||||
}
|
||||
|
@ -606,20 +604,20 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
|
|||
}
|
||||
}
|
||||
|
||||
::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam);
|
||||
::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam);
|
||||
int currentTabOn = static_cast<int32_t>(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0));
|
||||
|
||||
if (wParam == 2)
|
||||
return TRUE;
|
||||
|
||||
if (_doDragNDrop)
|
||||
{
|
||||
if (_doDragNDrop)
|
||||
{
|
||||
_mightBeDragging = true;
|
||||
}
|
||||
}
|
||||
|
||||
notify(NM_CLICK, currentTabOn);
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_RBUTTONDOWN : //rightclick selects tab aswell
|
||||
|
@ -673,13 +671,13 @@ LRESULT TabBarPlus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPara
|
|||
|
||||
if (_isDragging)
|
||||
{
|
||||
exchangeItemData(p);
|
||||
exchangeItemData(p);
|
||||
|
||||
// Get cursor position of "Screen"
|
||||
// For using the function "WindowFromPoint" afterward!!!
|
||||
::GetCursorPos(&_draggingPoint);
|
||||
draggingCursor(_draggingPoint);
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -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))
|
||||
|
@ -1276,8 +1272,8 @@ void TabBarPlus::draggingCursor(POINT screenPoint)
|
|||
}
|
||||
else if (isPointInParentZone(screenPoint))
|
||||
::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_INTERDIT_TAB)));
|
||||
else // drag out of application
|
||||
::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_OUT_TAB)));
|
||||
else // drag out of application
|
||||
::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_OUT_TAB)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue