From 933c86dce36cde1a8f4e2ba83597ec005b17b62c Mon Sep 17 00:00:00 2001 From: James Crook Date: Sun, 15 Apr 2018 13:46:03 +0100 Subject: [PATCH] Draw slider background in correct colour on MixerBoard. --- src/MixerBoard.cpp | 2 +- src/widgets/ASlider.cpp | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 2ba61ef3e..620bc2c4c 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -702,9 +702,9 @@ void MixerTrackCluster::OnPaint(wxPaintEvent & WXUNUSED(event)) wxColour col = theTheme.Colour(selected ? clrTrackInfoSelected : clrTrackInfo) ; SetBackgroundColour( col ); mMeter->SetBackgroundColour( col ); + mStaticText_TrackName->SetBackgroundColour( col ); mSlider_Gain->SetBackgroundColour( col ); mSlider_Pan->SetBackgroundColour( col ); - mStaticText_TrackName->SetBackgroundColour( col ); wxPaintDC dc(this); diff --git a/src/widgets/ASlider.cpp b/src/widgets/ASlider.cpp index 80a4300fd..a3b38e4d9 100644 --- a/src/widgets/ASlider.cpp +++ b/src/widgets/ASlider.cpp @@ -568,10 +568,12 @@ void LWSlider::OnPaint(wxDC &dc, bool highlight) thumbPos += 8-mThumbHeight/2; } - // Previously not done on mac, but with wx3.1.1. it - // needs to be. - if( mHW ) + // Draw the background. + // If we are lightweight, this has already been done for us. + if( mHW ){ + dc.SetBackground( wxBrush(mParent->GetBackgroundColour()) ); dc.Clear(); + } dc.DrawBitmap(*mBitmap, mLeft, mTop, true); const auto &thumbBitmap = @@ -622,8 +624,14 @@ void LWSlider::DrawToBitmap(wxDC & paintDC) wxMemoryDC dc; dc.SelectObject(*mBitmap); + + // The backgroundColour is the expected background colour. + // This bitmap is masked, so the colour affects anti-aliassing + // at the edges. wxColour backgroundColour = theTheme.Colour(clrTrackInfo); - dc.SetBackground(backgroundColour); + if( mHW ) + backgroundColour = mParent->GetBackgroundColour(); + dc.SetBackground(wxBrush(backgroundColour)); dc.Clear(); // Draw the line along which the thumb moves. @@ -653,12 +661,7 @@ void LWSlider::DrawToBitmap(wxDC & paintDC) // Colors dc.SetTextForeground( theTheme.Colour( clrTrackPanelText )); - - // backgroundColour should be same as clrTrackInfo. - // This setting of colours may have been necessary at one time to avoid - // antialiasing the font against white, even on dark background. - dc.SetTextBackground( theTheme.Colour( clrTrackInfo ) ); - dc.SetBackground( theTheme.Colour( clrTrackInfo ) ); + dc.SetTextBackground( backgroundColour ); // Used to use wxSOLID here, but wxTRANSPARENT is better for mac, and // works fine on windows. dc.SetBackgroundMode( wxTRANSPARENT ); @@ -753,12 +756,9 @@ void LWSlider::DrawToBitmap(wxDC & paintDC) dc.SelectObject(wxNullBitmap); // safenew, because SetMask takes ownership - // On toolbars (etc) we have a HeavyWeight control, with fixed colour background. - // So we do not need a mask. - // On the TrackPanel we use as a LightWeight control, the background colour is - // not guaranteed to be the same, so we use a mask - if( !mHW ) - mBitmap->SetMask(safenew wxMask(*mBitmap, backgroundColour)); + // We always mask. If we are HeavyWeight, the ASlider draws the + // background. + mBitmap->SetMask(safenew wxMask(*mBitmap, backgroundColour)); } void LWSlider::SetToolTipTemplate(const wxString & tip)