From 348407dfdf5fd41b99f5998463eb032128799555 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 19 Mar 2022 19:42:48 +0000 Subject: Related: tdf#118320 tabitems appear as light in darkmode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit so use a Button theme and matching button properties for drawing those instead as a workaround Change-Id: I5ba0e360adc109e80ab7ecb1ff2fd5bc84028b61 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131852 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- vcl/win/gdi/salnativewidgets-luna.cxx | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'vcl') diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx index 805db681a211..b58731f1db42 100644 --- a/vcl/win/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/gdi/salnativewidgets-luna.cxx @@ -813,6 +813,32 @@ static bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, iState = TILES_FOCUSED; // may need to draw focus rect else iState = TILES_NORMAL; + + // tabitem in tabcontrols gets drawn in "darkmode" as if it was a + // a "light" theme, so bodge this by drawing with a button instead + if (UseDarkMode()) + { + iPart = BP_PUSHBUTTON; + switch (iState) + { + case TILES_DISABLED: + iState = PBS_DISABLED; + break; + case TILES_SELECTED: + iState = PBS_PRESSED; + break; + case TILES_HOT: + iState = PBS_HOT; + break; + case TILES_FOCUSED: + iState = PBS_DEFAULTED; + break; + default: + iState = PBS_NORMAL; + break; + } + } + return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); } @@ -1148,9 +1174,18 @@ bool WinSalGraphics::drawNativeControl( ControlType nType, break; case ControlType::TabPane: case ControlType::TabBody: - case ControlType::TabItem: hTheme = getThemeHandle(mhWnd, L"Tab", mpImpl.get()); break; + case ControlType::TabItem: + if (bUseDarkMode) + { + // tabitem in tabcontrols gets drawn in "darkmode" as if it was a + // a "light" theme, so bodge this by drawing with a button instead + hTheme = getThemeHandle(mhWnd, L"Button", mpImpl.get()); + } + else + hTheme = getThemeHandle(mhWnd, L"Tab", mpImpl.get()); + break; case ControlType::Toolbar: if( nPart == ControlPart::Entire || nPart == ControlPart::Button ) hTheme = getThemeHandle(mhWnd, L"Toolbar", mpImpl.get()); -- cgit