mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-19 17:40:51 +02:00
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.
This commit is contained in:
parent
3760db9dff
commit
8b9518a90a
@ -26,6 +26,7 @@ It is also a place to document colour usage policy in Audacity
|
|||||||
#include <wx/colour.h>
|
#include <wx/colour.h>
|
||||||
#include <wx/dc.h>
|
#include <wx/dc.h>
|
||||||
#include <wx/dcmemory.h>
|
#include <wx/dcmemory.h>
|
||||||
|
#include <wx/graphics.h>
|
||||||
#include <wx/settings.h>
|
#include <wx/settings.h>
|
||||||
#include <wx/utils.h>
|
#include <wx/utils.h>
|
||||||
|
|
||||||
@ -291,7 +292,9 @@ void AColor::BevelTrackInfo(wxDC & dc, bool up, const wxRect & r, bool highlight
|
|||||||
// Set colour of and select brush and pen.
|
// Set colour of and select brush and pen.
|
||||||
// Use -1 to omit brush or pen.
|
// Use -1 to omit brush or pen.
|
||||||
// If pen omitted, then the same colour as the brush will be used.
|
// 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)
|
if (!inited)
|
||||||
Init();
|
Init();
|
||||||
@ -301,6 +304,7 @@ void AColor::UseThemeColour( wxDC * dc, int iBrush, int iPen )
|
|||||||
wxColour col = wxColour(0,0,0);
|
wxColour col = wxColour(0,0,0);
|
||||||
if( iBrush !=-1 ){
|
if( iBrush !=-1 ){
|
||||||
col = theTheme.Colour( iBrush );
|
col = theTheme.Colour( iBrush );
|
||||||
|
col.Set( col.Red(), col.Green(), col.Blue(), alpha);
|
||||||
spareBrush.SetColour( col );
|
spareBrush.SetColour( col );
|
||||||
dc->SetBrush( spareBrush );
|
dc->SetBrush( spareBrush );
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ class AColor {
|
|||||||
static void BevelTrackInfo(wxDC & dc, bool up, const wxRect & r, bool highlight = false);
|
static void BevelTrackInfo(wxDC & dc, bool up, const wxRect & r, bool highlight = false);
|
||||||
static wxColour Blend(const wxColour & c1, const wxColour & c2);
|
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 TrackPanelBackground(wxDC * dc, bool selected);
|
||||||
|
|
||||||
static void Light(wxDC * dc, bool selected, bool highlight = false);
|
static void Light(wxDC * dc, bool selected, bool highlight = false);
|
||||||
|
@ -338,9 +338,10 @@ void TrackArt::DrawTrack(TrackPanelDrawingContext &context,
|
|||||||
dc.SetFont(labelFont);
|
dc.SetFont(labelFont);
|
||||||
dc.GetTextExtent( wt->GetName(), &x, &y );
|
dc.GetTextExtent( wt->GetName(), &x, &y );
|
||||||
dc.SetTextForeground(theTheme.Colour( clrTrackPanelText ));
|
dc.SetTextForeground(theTheme.Colour( clrTrackPanelText ));
|
||||||
// A nice improvement would be to draw the shield / background translucently.
|
// Shield's background is translucent, alpha=100, but currently
|
||||||
AColor::UseThemeColour( &dc, clrTrackInfoSelected, clrTrackPanelText );
|
// only on mac.
|
||||||
dc.DrawRoundedRectangle( wxPoint( rect.x+7, rect.y+1 ), wxSize( x+16, y+4), 8.0 );
|
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
|
dc.DrawText (wt->GetName(), rect.x+15, rect.y+3); // move right 15 pixels to avoid overwriting <- symbol
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user