vcl/win/gdi/salnativewidgets-luna.cxx |   37 +++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 348407dfdf5fd41b99f5998463eb032128799555
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sat Mar 19 19:42:48 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sat Mar 19 21:52:25 2022 +0100

    Related: tdf#118320 tabitems appear as light in darkmode
    
    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 <caol...@redhat.com>

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());

Reply via email to