From 1edd60790bbe8aa73ceeb9b3ffae753f1801d3d4 Mon Sep 17 00:00:00 2001 From: Peter Cawley Date: Wed, 11 Aug 2010 16:51:02 +0000 Subject: [PATCH] Improve wxRibbonMSWArtProvider's colour scheme generation when the primary and/or secondary colours are grey (see ticket #12331). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65265 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/ribbon/art_msw.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/ribbon/art_msw.cpp b/src/ribbon/art_msw.cpp index 3d42946d52..4041079aeb 100644 --- a/src/ribbon/art_msw.cpp +++ b/src/ribbon/art_msw.cpp @@ -143,21 +143,38 @@ void wxRibbonMSWArtProvider::SetColourScheme( // tertiary not used for anything // Map primary saturation from [0, 1] to [.25, .75] - primary_hsl.saturation = cos(primary_hsl.saturation * M_PI) * -0.25 + 0.5; + bool primary_is_gray = false; + const float gray_saturation_threshold = 0.01; + if(primary_hsl.saturation <= gray_saturation_threshold) + primary_is_gray = true; + else + { + primary_hsl.saturation = cos(primary_hsl.saturation * M_PI) + * -0.25 + 0.5; + } // Map primary luminance from [0, 1] to [.23, .83] primary_hsl.luminance = cos(primary_hsl.luminance * M_PI) * -0.3 + 0.53; // Map secondary saturation from [0, 1] to [0.16, 0.84] - secondary_hsl.saturation = cos(secondary_hsl.saturation * M_PI) * -0.34 + 0.5; + bool secondary_is_gray = false; + if(secondary_hsl.saturation <= gray_saturation_threshold) + secondary_is_gray = true; + else + { + secondary_hsl.saturation = cos(secondary_hsl.saturation * M_PI) + * -0.34 + 0.5; + } // Map secondary luminance from [0, 1] to [0.1, 0.9] secondary_hsl.luminance = cos(secondary_hsl.luminance * M_PI) * -0.4 + 0.5; #define LikePrimary(h, s, l) \ - primary_hsl.ShiftHue(h ## f).Saturated(s ## f).Lighter(l ## f).ToRGB() + primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \ + .Lighter(l ## f).ToRGB() #define LikeSecondary(h, s, l) \ - secondary_hsl.ShiftHue(h ## f).Saturated(s ## f).Lighter(l ## f).ToRGB() + secondary_hsl.ShiftHue(h ## f).Saturated(secondary_is_gray ? 0 : s ## f) \ + .Lighter(l ## f).ToRGB() m_page_border_pen = LikePrimary(1.4, 0.00, -0.08); -- 2.47.2