From 6bcbe417e997a2af0e0913f3f0c63508ae638238 Mon Sep 17 00:00:00 2001 From: James Crook Date: Wed, 26 Apr 2017 15:35:57 +0100 Subject: [PATCH] Make SelectionBar end/length radio buttons behave normally They had lost the focus/voice-over functionality because I added code to draw them in the theme colour. Now I disable that code, IF recolouring is both set and active. This will happen for example, if Hi-Contrast is used with the Hi-Contrast system theme. --- src/Theme.cpp | 5 ++++- src/Theme.h | 4 +++- src/toolbars/SelectionBar.cpp | 33 ++++++++++++++++++++++----------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/Theme.cpp b/src/Theme.cpp index 1757725ce..c2709b9d8 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -282,6 +282,7 @@ void Theme::RegisterColours() ThemeBase::ThemeBase(void) { bRecolourOnLoad = false; + bRecolouringIsActive = false; } ThemeBase::~ThemeBase(void) @@ -321,6 +322,7 @@ void ThemeBase::LoadTheme( teThemeType Theme ) CreateImageCache(); #endif } + bRecolouringIsActive = false; if( bRecolourOnLoad ) RecolourTheme(); bRecolourOnLoad = false; @@ -356,9 +358,10 @@ void ThemeBase::RecolourTheme() + abs( From.Green() - To.Green() ) + abs( From.Blue() - To.Blue() ); - // Don't recolour if difference is too big, or no difference. + // 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 diff --git a/src/Theme.h b/src/Theme.h index 98ab20b7c..e6e820681 100644 --- a/src/Theme.h +++ b/src/Theme.h @@ -117,6 +117,7 @@ public: void WriteImageDefs( ); void WriteImageMap( ); static bool LoadPreferredTheme(); + bool RecolouringIsActive(){ return bRecolouringIsActive;}; void RecolourBitmap( int iIndex, wxColour From, wxColour To ); void RecolourTheme(); @@ -127,7 +128,8 @@ public: wxCursor & Cursor( int iIndex ); wxFont & Font( int iIndex ); wxSize ImageSize( int iIndex ); - bool bRecolourOnLoad; + bool bRecolourOnLoad; // Request to recolour. + bool bRecolouringIsActive; // We're actually doing it. void ReplaceImage( int iIndex, wxImage * pImage ); diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index 696b9f729..2d9e1ba2e 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -164,13 +164,18 @@ void SelectionBar::Populate() gPrefs->Read(wxT("/ShowSelectionLength"), &showSelectionLength); { + bool bCustomRadioLabels = !theTheme.RecolouringIsActive(); // 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. - // Slight regression relative ot Audacity in that this text is not + // Slight regression relative ot Audacity, in that this text is not // clickable/active. You have to click on the actual button. + // And can't tab between and hear the labels with voice over. + // So VI users should use blend themes (which is the default). + // 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(wxHORIZONTAL); - mRightEndButton = safenew wxRadioButton(this, OnEndRadioID, wxT(""), + mRightEndButton = safenew wxRadioButton(this, OnEndRadioID, bCustomRadioLabels ? wxT("") : _("End"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); mRightEndButton->SetName(_("End")); @@ -178,21 +183,27 @@ void SelectionBar::Populate() mRightEndButton->SetValue(!showSelectionLength); hSizer->Add(mRightEndButton, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); - wxStaticText * pEndText = safenew wxStaticText(this, -1, _("End")); - pEndText->SetForegroundColour( clrText ); - hSizer->Add(pEndText, - 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); + if( bCustomRadioLabels ) + { + wxStaticText * pEndText = safenew wxStaticText(this, -1, _("End")); + pEndText->SetForegroundColour( clrText ); + hSizer->Add(pEndText, + 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); + } - mRightLengthButton = safenew wxRadioButton(this, OnLengthRadioID, wxT("")); + mRightLengthButton = safenew wxRadioButton(this, OnLengthRadioID, bCustomRadioLabels ? wxT(""): _("Length")); mRightLengthButton->SetName(_("Length")); mRightLengthButton->SetForegroundColour( clrText ); mRightLengthButton->SetValue(showSelectionLength); hSizer->Add(mRightLengthButton, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); - wxStaticText * pLengthText = safenew wxStaticText(this, -1, _("Length")); - pLengthText->SetForegroundColour( clrText ); - hSizer->Add(pLengthText, - 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); + if( bCustomRadioLabels ) + { + wxStaticText * pLengthText = safenew wxStaticText(this, -1, _("Length")); + pLengthText->SetForegroundColour( clrText ); + hSizer->Add(pLengthText, + 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); + } #if defined(__WXMSW__) // Refer to Microsoft KB article 261192 for an explanation as