mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-22 14:32:58 +02:00
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.
This commit is contained in:
@@ -282,6 +282,7 @@ void Theme::RegisterColours()
|
|||||||
ThemeBase::ThemeBase(void)
|
ThemeBase::ThemeBase(void)
|
||||||
{
|
{
|
||||||
bRecolourOnLoad = false;
|
bRecolourOnLoad = false;
|
||||||
|
bRecolouringIsActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeBase::~ThemeBase(void)
|
ThemeBase::~ThemeBase(void)
|
||||||
@@ -321,6 +322,7 @@ void ThemeBase::LoadTheme( teThemeType Theme )
|
|||||||
CreateImageCache();
|
CreateImageCache();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
bRecolouringIsActive = false;
|
||||||
if( bRecolourOnLoad )
|
if( bRecolourOnLoad )
|
||||||
RecolourTheme();
|
RecolourTheme();
|
||||||
bRecolourOnLoad = false;
|
bRecolourOnLoad = false;
|
||||||
@@ -356,9 +358,10 @@ void ThemeBase::RecolourTheme()
|
|||||||
+ abs( From.Green() - To.Green() )
|
+ abs( From.Green() - To.Green() )
|
||||||
+ abs( From.Blue() - To.Blue() );
|
+ 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 )
|
if( d > 120 )
|
||||||
return;
|
return;
|
||||||
|
bRecolouringIsActive = true;
|
||||||
|
|
||||||
// A minor tint difference from standard does not need
|
// A minor tint difference from standard does not need
|
||||||
// to be recouloured either. Includes case of d==0 which is nothing
|
// to be recouloured either. Includes case of d==0 which is nothing
|
||||||
|
@@ -117,6 +117,7 @@ public:
|
|||||||
void WriteImageDefs( );
|
void WriteImageDefs( );
|
||||||
void WriteImageMap( );
|
void WriteImageMap( );
|
||||||
static bool LoadPreferredTheme();
|
static bool LoadPreferredTheme();
|
||||||
|
bool RecolouringIsActive(){ return bRecolouringIsActive;};
|
||||||
void RecolourBitmap( int iIndex, wxColour From, wxColour To );
|
void RecolourBitmap( int iIndex, wxColour From, wxColour To );
|
||||||
void RecolourTheme();
|
void RecolourTheme();
|
||||||
|
|
||||||
@@ -127,7 +128,8 @@ public:
|
|||||||
wxCursor & Cursor( int iIndex );
|
wxCursor & Cursor( int iIndex );
|
||||||
wxFont & Font( int iIndex );
|
wxFont & Font( int iIndex );
|
||||||
wxSize ImageSize( 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 );
|
void ReplaceImage( int iIndex, wxImage * pImage );
|
||||||
|
|
||||||
|
@@ -164,13 +164,18 @@ void SelectionBar::Populate()
|
|||||||
gPrefs->Read(wxT("/ShowSelectionLength"), &showSelectionLength);
|
gPrefs->Read(wxT("/ShowSelectionLength"), &showSelectionLength);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
bool bCustomRadioLabels = !theTheme.RecolouringIsActive();
|
||||||
// Can't set textcolour of radio buttons.
|
// Can't set textcolour of radio buttons.
|
||||||
// so instead we make the text empty and add in two wxStaticTexts
|
// so instead we make the text empty and add in two wxStaticTexts
|
||||||
// and we can set the colour of those.
|
// 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.
|
// 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<wxBoxSizer>(wxHORIZONTAL);
|
auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
|
||||||
mRightEndButton = safenew wxRadioButton(this, OnEndRadioID, wxT(""),
|
mRightEndButton = safenew wxRadioButton(this, OnEndRadioID, bCustomRadioLabels ? wxT("") : _("End"),
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
wxRB_GROUP);
|
wxRB_GROUP);
|
||||||
mRightEndButton->SetName(_("End"));
|
mRightEndButton->SetName(_("End"));
|
||||||
@@ -178,21 +183,27 @@ void SelectionBar::Populate()
|
|||||||
mRightEndButton->SetValue(!showSelectionLength);
|
mRightEndButton->SetValue(!showSelectionLength);
|
||||||
hSizer->Add(mRightEndButton,
|
hSizer->Add(mRightEndButton,
|
||||||
0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
|
0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
|
||||||
|
if( bCustomRadioLabels )
|
||||||
|
{
|
||||||
wxStaticText * pEndText = safenew wxStaticText(this, -1, _("End"));
|
wxStaticText * pEndText = safenew wxStaticText(this, -1, _("End"));
|
||||||
pEndText->SetForegroundColour( clrText );
|
pEndText->SetForegroundColour( clrText );
|
||||||
hSizer->Add(pEndText,
|
hSizer->Add(pEndText,
|
||||||
0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
|
0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
|
||||||
|
}
|
||||||
|
|
||||||
mRightLengthButton = safenew wxRadioButton(this, OnLengthRadioID, wxT(""));
|
mRightLengthButton = safenew wxRadioButton(this, OnLengthRadioID, bCustomRadioLabels ? wxT(""): _("Length"));
|
||||||
mRightLengthButton->SetName(_("Length"));
|
mRightLengthButton->SetName(_("Length"));
|
||||||
mRightLengthButton->SetForegroundColour( clrText );
|
mRightLengthButton->SetForegroundColour( clrText );
|
||||||
mRightLengthButton->SetValue(showSelectionLength);
|
mRightLengthButton->SetValue(showSelectionLength);
|
||||||
hSizer->Add(mRightLengthButton,
|
hSizer->Add(mRightLengthButton,
|
||||||
0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
|
0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
|
||||||
|
if( bCustomRadioLabels )
|
||||||
|
{
|
||||||
wxStaticText * pLengthText = safenew wxStaticText(this, -1, _("Length"));
|
wxStaticText * pLengthText = safenew wxStaticText(this, -1, _("Length"));
|
||||||
pLengthText->SetForegroundColour( clrText );
|
pLengthText->SetForegroundColour( clrText );
|
||||||
hSizer->Add(pLengthText,
|
hSizer->Add(pLengthText,
|
||||||
0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
|
0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
// Refer to Microsoft KB article 261192 for an explanation as
|
// Refer to Microsoft KB article 261192 for an explanation as
|
||||||
|
Reference in New Issue
Block a user