vcl/source/control/button.cxx |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 68b225bfbf51391b517dd483181e40e4a4c3fe31
Author:     bykivi <kivader.ma...@gmail.com>
AuthorDate: Tue Mar 23 13:41:30 2021 +0100
Commit:     Andreas Heinisch <andreas.heini...@yahoo.de>
CommitDate: Sat Apr 10 15:21:17 2021 +0200

    tdf#141195:fix button text color with default background color
    
    Change-Id: I2f30282e5e1f5e303be2802529f693be4968620d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112989
    Tested-by: Jenkins
    Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de>

diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 2d68ab5f05c9..f2c413de8478 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -693,7 +693,20 @@ void 
PushButton::ImplDrawPushButtonFrame(vcl::RenderContext& rRenderContext,
         AllSettings aSettings = rRenderContext.GetSettings();
         AllSettings aOldSettings = aSettings;
         StyleSettings aStyleSettings = aSettings.GetStyleSettings();
-        aStyleSettings.Set3DColors(GetControlBackground());
+        if (nStyle & DrawButtonFlags::Highlight)
+        {
+            // with the custom background, native highlight do nothing, so 
code bellow mimic
+            // native highlight by changing luminance
+            Color controlBackgroundColorHighlighted = GetControlBackground();
+            sal_uInt8 colorLuminance = 
controlBackgroundColorHighlighted.GetLuminance();
+            if (colorLuminance < 205)
+                controlBackgroundColorHighlighted.IncreaseLuminance(50);
+            else
+                controlBackgroundColorHighlighted.DecreaseLuminance(50);
+            aStyleSettings.Set3DColors(controlBackgroundColorHighlighted);
+        }
+        else
+            aStyleSettings.Set3DColors(GetControlBackground());
         aSettings.SetStyleSettings(aStyleSettings);
 
         // Call OutputDevice::SetSettings() explicitly, as rRenderContext may
@@ -769,11 +782,7 @@ void PushButton::ImplDrawPushButtonContent(OutputDevice 
*pDev, DrawFlags nDrawFl
     if (nDrawFlags & DrawFlags::Mono)
         aColor = COL_BLACK;
 
-    // Custom foreground color is reasonable on stock controls only. Stock 
controls are used if a custom background has been set
-    // (and thus no native controls are able to be used) or no native controls 
are available.
-
-    else if (IsControlForeground()
-             && (IsControlBackground() || 
!IsNativeControlSupported(ControlType::Pushbutton, ControlPart::Entire)))
+    else if (IsControlForeground())
         aColor = GetControlForeground();
 
     // Button types with possibly different text coloring are flat buttons and 
regular buttons. Regular buttons may be action
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to