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

Bug 1630 - Accessibility of the length/end radio buttons

For Light and Classic themes that use black text, we'll use the length/end buttons because Windows uses black for text.
For Dark and HiContrast themes that use a light colour for text, we'll use the length/end buttons IF the OS is set to use the exact same colour for text.
That for example happens if we use Microsoft's HiContrast2 and our HiContrast theme.

If the OS and theme text colour differ, then if we set blend theme colours option, which is the default, we might still use the OS colour for text in Audacity.  That will happen if the OS colour has decent contrast to our theme's background colour.   Decent is defined as more than 250 difference in RGB values.  If we use the OS colour for text, then we get the proper length/end buttons.

Note that this adds a new feature to the theme blending, in that the text colour will often adapt.  Useful when using custom text colours with HiContrast2.  When the text colour adapts, we will continue to get proper length/end buttons.

Advice to users is to match OS and Audacity themes, and use the blend option.  When themes don't match, it may be desirable to disable blending.
This commit is contained in:
James Crook 2017-04-28 15:42:33 +01:00
parent 47c6ac3233
commit 6102c774ee
3 changed files with 25 additions and 10 deletions

View File

@ -282,7 +282,7 @@ void Theme::RegisterColours()
ThemeBase::ThemeBase(void)
{
bRecolourOnLoad = false;
bRecolouringIsActive = false;
bIsUsingSystemTextColour = false;
}
ThemeBase::~ThemeBase(void)
@ -322,9 +322,25 @@ void ThemeBase::LoadTheme( teThemeType Theme )
CreateImageCache();
#endif
}
bRecolouringIsActive = false;
if( bRecolourOnLoad )
RecolourTheme();
wxColor Back = theTheme.Colour( clrTrackInfo );
wxColor CurrentText = theTheme.Colour( clrTrackPanelText );
wxColor DesiredText = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
int TextColourDifference = ColourDistance( CurrentText, DesiredText );
bIsUsingSystemTextColour = ( TextColourDifference == 0 );
// Theming is very accepting of alternative text colours. They just need to
// have decent contrast to the background colour, if we're blending themes.
if( !bIsUsingSystemTextColour ){
int ContrastLevel = ColourDistance( Back, DesiredText );
bIsUsingSystemTextColour = bRecolourOnLoad && (ContrastLevel > 250);
if( bIsUsingSystemTextColour )
Colour( clrTrackPanelText ) = DesiredText;
}
bRecolourOnLoad = false;
// Next line is not required as we haven't yet built the GUI
@ -365,7 +381,6 @@ void ThemeBase::RecolourTheme()
// Don't recolour if difference is too big.
if( d > 120 )
return;
bRecolouringIsActive = true;
// A minor tint difference from standard does not need
// to be recouloured either. Includes case of d==0 which is nothing

View File

@ -117,7 +117,7 @@ public:
void WriteImageDefs( );
void WriteImageMap( );
static bool LoadPreferredTheme();
bool RecolouringIsActive(){ return bRecolouringIsActive;};
bool IsUsingSyestemTextColour(){ return bIsUsingSystemTextColour;};
void RecolourBitmap( int iIndex, wxColour From, wxColour To );
void RecolourTheme();
@ -129,7 +129,7 @@ public:
wxFont & Font( int iIndex );
wxSize ImageSize( int iIndex );
bool bRecolourOnLoad; // Request to recolour.
bool bRecolouringIsActive; // We're actually doing it.
bool bIsUsingSystemTextColour;
void ReplaceImage( int iIndex, wxImage * pImage );

View File

@ -164,7 +164,7 @@ void SelectionBar::Populate()
gPrefs->Read(wxT("/ShowSelectionLength"), &showSelectionLength);
{
bool bCustomRadioLabels = !theTheme.RecolouringIsActive();
bool bSysTextColour = theTheme.IsUsingSyestemTextColour();
// Can't set textcolour of radio buttons.
// so instead we make the text empty and add in two wxStaticTexts
// and we can set the colour of those.
@ -175,7 +175,7 @@ void SelectionBar::Populate()
// Should not be a hardship for them, as themes make little difference
// for them, except Hi-Contrast, which should be used with recolouring.
auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
mRightEndButton = safenew wxRadioButton(this, OnEndRadioID, bCustomRadioLabels ? wxT("") : _("End"),
mRightEndButton = safenew wxRadioButton(this, OnEndRadioID, bSysTextColour ? _("End") : wxT("") ,
wxDefaultPosition, wxDefaultSize,
wxRB_GROUP);
mRightEndButton->SetName(_("End"));
@ -183,7 +183,7 @@ void SelectionBar::Populate()
mRightEndButton->SetValue(!showSelectionLength);
hSizer->Add(mRightEndButton,
0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
if( bCustomRadioLabels )
if( !bSysTextColour )
{
wxStaticText * pEndText = safenew wxStaticText(this, -1, _("End"));
pEndText->SetForegroundColour( clrText );
@ -191,13 +191,13 @@ void SelectionBar::Populate()
0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
}
mRightLengthButton = safenew wxRadioButton(this, OnLengthRadioID, bCustomRadioLabels ? wxT(""): _("Length"));
mRightLengthButton = safenew wxRadioButton(this, OnLengthRadioID,bSysTextColour ? _("Length") : wxT("") );
mRightLengthButton->SetName(_("Length"));
mRightLengthButton->SetForegroundColour( clrText );
mRightLengthButton->SetValue(showSelectionLength);
hSizer->Add(mRightLengthButton,
0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
if( bCustomRadioLabels )
if( !bSysTextColour )
{
wxStaticText * pLengthText = safenew wxStaticText(this, -1, _("Length"));
pLengthText->SetForegroundColour( clrText );