From 8b9518a90a74900a74f1290a7a6161a1dc52ee9f Mon Sep 17 00:00:00 2001 From: James Crook Date: Fri, 29 Mar 2019 22:06:03 +0000 Subject: [PATCH] Translucent background to track name (on Mac) Mac only, as mac supports translucent brushes by default. wxWidgets makes using a wxDC and wxGraphicContext at the same time complex and slow. Hence just for mac. --- src/AColor.cpp | 6 +++++- src/AColor.h | 2 +- src/TrackArtist.cpp | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/AColor.cpp b/src/AColor.cpp index ac60e400d..20cab7f17 100644 --- a/src/AColor.cpp +++ b/src/AColor.cpp @@ -26,6 +26,7 @@ It is also a place to document colour usage policy in Audacity #include #include #include +#include #include #include @@ -291,7 +292,9 @@ void AColor::BevelTrackInfo(wxDC & dc, bool up, const wxRect & r, bool highlight // Set colour of and select brush and pen. // Use -1 to omit brush or pen. // If pen omitted, then the same colour as the brush will be used. -void AColor::UseThemeColour( wxDC * dc, int iBrush, int iPen ) +// alpha for the brush is normally 255, but if set will make a difference +// on mac (only) currently. +void AColor::UseThemeColour( wxDC * dc, int iBrush, int iPen, int alpha ) { if (!inited) Init(); @@ -301,6 +304,7 @@ void AColor::UseThemeColour( wxDC * dc, int iBrush, int iPen ) wxColour col = wxColour(0,0,0); if( iBrush !=-1 ){ col = theTheme.Colour( iBrush ); + col.Set( col.Red(), col.Green(), col.Blue(), alpha); spareBrush.SetColour( col ); dc->SetBrush( spareBrush ); } diff --git a/src/AColor.h b/src/AColor.h index b1f8f4bc2..b7eb91a61 100644 --- a/src/AColor.h +++ b/src/AColor.h @@ -78,7 +78,7 @@ class AColor { static void BevelTrackInfo(wxDC & dc, bool up, const wxRect & r, bool highlight = false); static wxColour Blend(const wxColour & c1, const wxColour & c2); - static void UseThemeColour( wxDC * dc, int iBrush, int iPen=-1 ); + static void UseThemeColour( wxDC * dc, int iBrush, int iPen=-1, int alpha = 255 ); static void TrackPanelBackground(wxDC * dc, bool selected); static void Light(wxDC * dc, bool selected, bool highlight = false); diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index e7a46260a..d0d7bd786 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -338,9 +338,10 @@ void TrackArt::DrawTrack(TrackPanelDrawingContext &context, dc.SetFont(labelFont); dc.GetTextExtent( wt->GetName(), &x, &y ); dc.SetTextForeground(theTheme.Colour( clrTrackPanelText )); - // A nice improvement would be to draw the shield / background translucently. - AColor::UseThemeColour( &dc, clrTrackInfoSelected, clrTrackPanelText ); - dc.DrawRoundedRectangle( wxPoint( rect.x+7, rect.y+1 ), wxSize( x+16, y+4), 8.0 ); + // Shield's background is translucent, alpha=100, but currently + // only on mac. + AColor::UseThemeColour( &dc, clrTrackInfoSelected, clrTrackPanelText, 100 ); + dc.DrawRoundedRectangle( rect.x+7, rect.y+1, x+16, y+4, 8.0 ); dc.DrawText (wt->GetName(), rect.x+15, rect.y+3); // move right 15 pixels to avoid overwriting <- symbol } },