1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-05 14:18:53 +02:00

Add background to numbers on meter, IF meter bar and number colour is too similar.

This happens in Hi-Contrast theme.
This commit is contained in:
James Crook 2017-04-26 16:28:41 +01:00
parent 6bcbe417e9
commit e08ceaf099
3 changed files with 17 additions and 5 deletions

View File

@ -341,6 +341,13 @@ void ThemeBase::RecolourBitmap( int iIndex, wxColour From, wxColour To )
ReplaceImage( iIndex, pResult.get() );
}
int ThemeBase::ColourDistance( wxColour & From, wxColour & To ){
return
abs( From.Red() - To.Red() )
+ abs( From.Green() - To.Green() )
+ abs( From.Blue() - To.Blue() );
}
// This function coerces a theme to be more like the system colours.
// Only used for built in themes. For custom themes a user
// will choose a better theme for them and just not use a mismatching one.
@ -353,10 +360,7 @@ void ThemeBase::RecolourTheme()
wxColour To = wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE );
#endif
// only recolour if recolouring is slight.
int d =
abs( From.Red() - To.Red() )
+ abs( From.Green() - To.Green() )
+ abs( From.Blue() - To.Blue() );
int d = ColourDistance( From, To );
// Don't recolour if difference is too big.
if( d > 120 )

View File

@ -121,7 +121,7 @@ public:
void RecolourBitmap( int iIndex, wxColour From, wxColour To );
void RecolourTheme();
int ColourDistance( wxColour & From, wxColour & To );
wxColour & Colour( int iIndex );
wxBitmap & Bitmap( int iIndex );
wxImage & Image( int iIndex );

View File

@ -595,6 +595,14 @@ void Meter::OnPaint(wxPaintEvent & WXUNUSED(event))
if (mStyle == HorizontalStereoCompact || mStyle == VerticalStereoCompact)
{
mRuler.SetTickColour( clrText );
// If the text colour is too similar to the meter colour, then we need a background
// for the text. We require a total of at least one full-scale RGB difference.
int d = theTheme.ColourDistance( clrText, theTheme.Colour( clrMeterOutputRMSBrush ) );
if( d < 256 )
{
destDC.SetBackgroundMode( wxSOLID );
destDC.SetTextBackground( clrBoxFill );
}
mRuler.Draw(destDC);
}
#endif