Make top bar indicate applied tab color for unfocused view

- use new dpi scaled metrics.
- replace c-casts.

Fix #15140, close #15160
pull/15165/head
ozone10 6 months ago committed by Don Ho
parent 382c33e99a
commit ef840de150

@ -250,7 +250,7 @@ void TabBar::reSizeTo(RECT & rc2Ajust)
::SetWindowLongPtr(_hSelf, GWL_STYLE, style);
tabsHight = rowCount * (larger - smaller) + marge;
tabsHight += GetSystemMetrics(_isVertical ? SM_CXEDGE : SM_CYEDGE);
tabsHight += _dpiManager.getSystemMetricsForDpi(_isVertical ? SM_CXEDGE : SM_CYEDGE);
if (_isVertical)
{
@ -1148,7 +1148,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode)
::SetBkMode(hDC, TRANSPARENT);
HBRUSH hBrush = ::CreateSolidBrush(colorInactiveBgBase);
::FillRect(hDC, &rect, hBrush);
::DeleteObject((HGDIOBJ)hBrush);
::DeleteObject(static_cast<HGDIOBJ>(hBrush));
// equalize drawing areas of active and inactive tabs
int paddingDynamicTwoX = _dpiManager.scale(2);
@ -1156,10 +1156,9 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode)
if (isSelected && !isDarkMode)
{
// the drawing area of the active tab extends on all borders by default
rect.top += ::GetSystemMetrics(SM_CYEDGE);
rect.bottom -= ::GetSystemMetrics(SM_CYEDGE);
rect.left += ::GetSystemMetrics(SM_CXEDGE);
rect.right -= ::GetSystemMetrics(SM_CXEDGE);
const int xEdge = _dpiManager.getSystemMetricsForDpi(SM_CXEDGE);
const int yEdge = _dpiManager.getSystemMetricsForDpi(SM_CYEDGE);
::InflateRect(&rect, -xEdge, -yEdge);
// the active tab is also slightly higher by default (use this to shift the tab cotent up bx two pixels if tobBar is not drawn)
if (_isVertical)
{
@ -1228,20 +1227,18 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode)
barRect.bottom = barRect.top + topBarHeight;
}
if (::SendMessage(_hParent, NPPM_INTERNAL_ISFOCUSEDTAB, 0, reinterpret_cast<LPARAM>(_hSelf)))
{
COLORREF topBarColour = _activeTopBarFocusedColour; // #FAAA3C
const bool isFocused = ::SendMessage(_hParent, NPPM_INTERNAL_ISFOCUSEDTAB, 0, reinterpret_cast<LPARAM>(_hSelf));
COLORREF topBarColour = isFocused ? _activeTopBarFocusedColour : _activeTopBarUnfocusedColour; // #FAAA3C, #FAD296
if (individualColourId != -1)
{
topBarColour = NppDarkMode::getIndividualTabColour(individualColourId, isDarkMode, true);
topBarColour = NppDarkMode::getIndividualTabColour(individualColourId, isDarkMode, isFocused);
}
hBrush = ::CreateSolidBrush(topBarColour);
}
else
hBrush = ::CreateSolidBrush(_activeTopBarUnfocusedColour); // #FAD296
::FillRect(hDC, &barRect, hBrush);
::DeleteObject((HGDIOBJ)hBrush);
::DeleteObject(static_cast<HGDIOBJ>(hBrush));
}
}
else // inactive tabs
@ -1264,7 +1261,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct, bool isDarkMode)
hBrush = ::CreateSolidBrush(brushColour);
::FillRect(hDC, &inactiveRect, hBrush);
::DeleteObject((HGDIOBJ)hBrush);
::DeleteObject(static_cast<HGDIOBJ>(hBrush));
}
if (isDarkMode && hasMultipleLines)

Loading…
Cancel
Save