diff --git a/src/Theme.cpp b/src/Theme.cpp index 7696e86cb..53ca95c1a 100644 --- a/src/Theme.cpp +++ b/src/Theme.cpp @@ -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 diff --git a/src/Theme.h b/src/Theme.h index d983e3c15..1e7bd8b8c 100644 --- a/src/Theme.h +++ b/src/Theme.h @@ -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 ); diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index 2d9e1ba2e..e0a8a2c5c 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -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(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 );