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

Loading…
Cancel
Save