diff --git a/src/Theme.cpp b/src/Theme.cpp index c2709b9d8..7696e86cb 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -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 ) diff --git a/src/Theme.h b/src/Theme.h index e6e820681..d983e3c15 100644 --- a/src/Theme.h +++ b/src/Theme.h @@ -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 ); diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index 89234b20f..85d160303 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -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