mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-12 14:47:43 +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:
parent
6bcbe417e9
commit
e08ceaf099
@ -341,6 +341,13 @@ void ThemeBase::RecolourBitmap( int iIndex, wxColour From, wxColour To )
|
|||||||
ReplaceImage( iIndex, pResult.get() );
|
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.
|
// This function coerces a theme to be more like the system colours.
|
||||||
// Only used for built in themes. For custom themes a user
|
// 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.
|
// 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 );
|
wxColour To = wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE );
|
||||||
#endif
|
#endif
|
||||||
// only recolour if recolouring is slight.
|
// only recolour if recolouring is slight.
|
||||||
int d =
|
int d = ColourDistance( From, To );
|
||||||
abs( From.Red() - To.Red() )
|
|
||||||
+ abs( From.Green() - To.Green() )
|
|
||||||
+ abs( From.Blue() - To.Blue() );
|
|
||||||
|
|
||||||
// Don't recolour if difference is too big.
|
// Don't recolour if difference is too big.
|
||||||
if( d > 120 )
|
if( d > 120 )
|
||||||
|
@ -121,7 +121,7 @@ public:
|
|||||||
void RecolourBitmap( int iIndex, wxColour From, wxColour To );
|
void RecolourBitmap( int iIndex, wxColour From, wxColour To );
|
||||||
void RecolourTheme();
|
void RecolourTheme();
|
||||||
|
|
||||||
|
int ColourDistance( wxColour & From, wxColour & To );
|
||||||
wxColour & Colour( int iIndex );
|
wxColour & Colour( int iIndex );
|
||||||
wxBitmap & Bitmap( int iIndex );
|
wxBitmap & Bitmap( int iIndex );
|
||||||
wxImage & Image( int iIndex );
|
wxImage & Image( int iIndex );
|
||||||
|
@ -595,6 +595,14 @@ void Meter::OnPaint(wxPaintEvent & WXUNUSED(event))
|
|||||||
if (mStyle == HorizontalStereoCompact || mStyle == VerticalStereoCompact)
|
if (mStyle == HorizontalStereoCompact || mStyle == VerticalStereoCompact)
|
||||||
{
|
{
|
||||||
mRuler.SetTickColour( clrText );
|
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);
|
mRuler.Draw(destDC);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user