mirror of
https://codeberg.org/tenacityteam/tenacity
synced 2025-09-27 16:56:19 +02:00
Reapply theme coloring
Upstream got rid of theme recoloring, but I thought ours worked pretty
good, so I decided to reapply it. This commit also reapplies commit
ee370f0e13
.
Actually, upstream's new dark theme blends pretty well with Breeze Dark
under KDE on Arch Linux. Still, our themes will be reintroduced (and set
as default).
Co-authored-by: akleja <storspov@gmail.com>
Signed-off-by: Avery King <avery98@pm.me>
This commit is contained in:
@@ -77,6 +77,9 @@ bool App::OnInit()
|
|||||||
// Leave no persistent side-effect on preferences
|
// Leave no persistent side-effect on preferences
|
||||||
SettingScope scope;
|
SettingScope scope;
|
||||||
|
|
||||||
|
// Don't blend colors
|
||||||
|
GUIBlendThemes.Write(false);
|
||||||
|
|
||||||
// So that the program can interpret PNG
|
// So that the program can interpret PNG
|
||||||
wxInitAllImageHandlers();
|
wxInitAllImageHandlers();
|
||||||
|
|
||||||
|
@@ -262,6 +262,27 @@ void ThemeBase::LoadTheme( teThemeType Theme )
|
|||||||
RotateImageInto( bmpRecordBeside, bmpRecordBelow, false );
|
RotateImageInto( bmpRecordBeside, bmpRecordBelow, false );
|
||||||
RotateImageInto( bmpRecordBesideDisabled, bmpRecordBelowDisabled, false );
|
RotateImageInto( bmpRecordBesideDisabled, bmpRecordBelowDisabled, false );
|
||||||
|
|
||||||
|
// Other modifications of images happening only when the setting
|
||||||
|
// GUIBlendThemes is true
|
||||||
|
if ( mpSet->bRecolourOnLoad ) {
|
||||||
|
RecolourTheme();
|
||||||
|
|
||||||
|
wxColor Back = theTheme.Colour( clrTrackInfo );
|
||||||
|
wxColor CurrentText = theTheme.Colour( clrTrackPanelText );
|
||||||
|
wxColor DesiredText = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
|
||||||
|
|
||||||
|
int TextColourDifference = ColourDistance( CurrentText, DesiredText );
|
||||||
|
|
||||||
|
// 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 ( TextColourDifference != 0 ) {
|
||||||
|
int ContrastLevel = ColourDistance( Back, DesiredText );
|
||||||
|
if ( ContrastLevel > 250 )
|
||||||
|
Colour( clrTrackPanelText ) = DesiredText;
|
||||||
|
}
|
||||||
|
mpSet->bRecolourOnLoad = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Next line is not required as we haven't yet built the GUI
|
// Next line is not required as we haven't yet built the GUI
|
||||||
// when this function is (or should be) called.
|
// when this function is (or should be) called.
|
||||||
// AColor::ApplyUpdatedImages();
|
// AColor::ApplyUpdatedImages();
|
||||||
@@ -289,6 +310,35 @@ int ThemeBase::ColourDistance( wxColour & From, wxColour & To ){
|
|||||||
+ abs( From.Blue() - To.Blue() );
|
+ abs( From.Blue() - To.Blue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function coerces a theme to be more like the system colours.
|
||||||
|
// 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.
|
||||||
|
void ThemeBase::RecolourTheme()
|
||||||
|
{
|
||||||
|
wxColour From = Colour( clrMedium );
|
||||||
|
#if defined( __WXGTK__ )
|
||||||
|
wxColour To = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND );
|
||||||
|
#else
|
||||||
|
wxColour To = wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Don't recolour if difference is too big.
|
||||||
|
int d = ColourDistance( From, To );
|
||||||
|
if( d > 120 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
Colour( clrMedium ) = To;
|
||||||
|
RecolourBitmap( bmpUpButtonLarge, From, To );
|
||||||
|
RecolourBitmap( bmpDownButtonLarge, From, To );
|
||||||
|
RecolourBitmap( bmpHiliteButtonLarge, From, To );
|
||||||
|
RecolourBitmap( bmpUpButtonSmall, From, To );
|
||||||
|
RecolourBitmap( bmpDownButtonSmall, From, To );
|
||||||
|
RecolourBitmap( bmpHiliteButtonSmall, From, To );
|
||||||
|
|
||||||
|
Colour( clrTrackInfo ) = To;
|
||||||
|
RecolourBitmap( bmpUpButtonExpand, From, To );
|
||||||
|
}
|
||||||
|
|
||||||
wxImage ThemeBase::MaskedImage( char const ** pXpm, char const ** pMask )
|
wxImage ThemeBase::MaskedImage( char const ** pXpm, char const ** pMask )
|
||||||
{
|
{
|
||||||
wxBitmap Bmp1( pXpm );
|
wxBitmap Bmp1( pXpm );
|
||||||
@@ -851,6 +901,8 @@ bool ThemeBase::ReadImageCache( teThemeType type, bool bOkIfNotFound)
|
|||||||
// ImageCache.InitAlpha();
|
// ImageCache.InitAlpha();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
mpSet->bRecolourOnLoad = GUIBlendThemes.Read();
|
||||||
|
|
||||||
using namespace BasicUI;
|
using namespace BasicUI;
|
||||||
|
|
||||||
if( type.empty() || type == "custom" )
|
if( type.empty() || type == "custom" )
|
||||||
@@ -1317,3 +1369,5 @@ ChoiceSetting &GUITheme()
|
|||||||
|
|
||||||
return setting;
|
return setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BoolSetting GUIBlendThemes{ wxT("/GUI/BlendThemes"), true };
|
||||||
|
@@ -105,6 +105,7 @@ struct ThemeSet
|
|||||||
std::vector<wxColour> mColours;
|
std::vector<wxColour> mColours;
|
||||||
|
|
||||||
bool bInitialised = false;
|
bool bInitialised = false;
|
||||||
|
bool bRecolourOnLoad = false; // Request to recolour
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ThemeChangeMessage {
|
struct ThemeChangeMessage {
|
||||||
@@ -171,6 +172,7 @@ public:
|
|||||||
void WriteOneImageMap( teThemeType id );
|
void WriteOneImageMap( teThemeType id );
|
||||||
static bool LoadPreferredTheme();
|
static bool LoadPreferredTheme();
|
||||||
void RecolourBitmap( int iIndex, wxColour From, wxColour To );
|
void RecolourBitmap( int iIndex, wxColour From, wxColour To );
|
||||||
|
void RecolourTheme();
|
||||||
|
|
||||||
int ColourDistance( wxColour & From, wxColour & To );
|
int ColourDistance( wxColour & From, wxColour & To );
|
||||||
wxColour & Colour( int iIndex );
|
wxColour & Colour( int iIndex );
|
||||||
@@ -219,6 +221,10 @@ public:
|
|||||||
|
|
||||||
extern THEME_API Theme theTheme;
|
extern THEME_API Theme theTheme;
|
||||||
|
|
||||||
|
extern THEME_API BoolSetting
|
||||||
|
GUIBlendThemes
|
||||||
|
;
|
||||||
|
|
||||||
extern THEME_API ChoiceSetting
|
extern THEME_API ChoiceSetting
|
||||||
&GUITheme()
|
&GUITheme()
|
||||||
;
|
;
|
||||||
|
@@ -142,6 +142,8 @@ void GUIPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
S.TieCheckBox(XXO("Re&tain labels if selection snaps to a label"),
|
S.TieCheckBox(XXO("Re&tain labels if selection snaps to a label"),
|
||||||
{wxT("/GUI/RetainLabels"),
|
{wxT("/GUI/RetainLabels"),
|
||||||
false});
|
false});
|
||||||
|
S.TieCheckBox(XXO("B&lend system and Tenacity theme"),
|
||||||
|
GUIBlendThemes);
|
||||||
#ifndef __WXMAC__
|
#ifndef __WXMAC__
|
||||||
/* i18n-hint: RTL stands for 'Right to Left' */
|
/* i18n-hint: RTL stands for 'Right to Left' */
|
||||||
S.TieCheckBox(XXO("Use mostly Left-to-Right layouts in RTL languages"),
|
S.TieCheckBox(XXO("Use mostly Left-to-Right layouts in RTL languages"),
|
||||||
|
@@ -57,6 +57,21 @@ BEGIN_EVENT_TABLE(ThemePrefs, PrefsPanel)
|
|||||||
EVT_BUTTON(idSaveThemeAsCode, ThemePrefs::OnSaveThemeAsCode)
|
EVT_BUTTON(idSaveThemeAsCode, ThemePrefs::OnSaveThemeAsCode)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
static bool ConfirmSave()
|
||||||
|
{
|
||||||
|
if (!GUIBlendThemes.Read())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
using namespace BasicUI;
|
||||||
|
const auto message = Verbatim(
|
||||||
|
"\"Blend system and TEnacity theme\" in Interface Preferences was on.\n"
|
||||||
|
"This may cause images to to be re-saved with slight changes of color."
|
||||||
|
);
|
||||||
|
|
||||||
|
return MessageBoxResult::Cancel != ShowMessageBox(message,
|
||||||
|
MessageBoxOptions{}.CancelButton().IconStyle(Icon::Warning));
|
||||||
|
}
|
||||||
|
|
||||||
ThemePrefs::ThemePrefs(wxWindow * parent, wxWindowID winid)
|
ThemePrefs::ThemePrefs(wxWindow * parent, wxWindowID winid)
|
||||||
/* i18n-hint: A theme is a consistent visual style across an application's
|
/* i18n-hint: A theme is a consistent visual style across an application's
|
||||||
graphical user interface, including choices of colors, and similarity of images
|
graphical user interface, including choices of colors, and similarity of images
|
||||||
@@ -181,6 +196,8 @@ void ThemePrefs::OnLoadThemeComponents(wxCommandEvent & WXUNUSED(event))
|
|||||||
/// Save Theme to multiple png files.
|
/// Save Theme to multiple png files.
|
||||||
void ThemePrefs::OnSaveThemeComponents(wxCommandEvent & WXUNUSED(event))
|
void ThemePrefs::OnSaveThemeComponents(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
if (!ConfirmSave()) return;
|
||||||
|
|
||||||
wxBusyCursor busy;
|
wxBusyCursor busy;
|
||||||
theTheme.SaveThemeComponents();
|
theTheme.SaveThemeComponents();
|
||||||
}
|
}
|
||||||
@@ -196,6 +213,8 @@ void ThemePrefs::OnLoadThemeCache(wxCommandEvent & WXUNUSED(event))
|
|||||||
/// Save Themes, each to a single png file.
|
/// Save Themes, each to a single png file.
|
||||||
void ThemePrefs::OnSaveThemeCache(wxCommandEvent & WXUNUSED(event))
|
void ThemePrefs::OnSaveThemeCache(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
if (!ConfirmSave()) return;
|
||||||
|
|
||||||
wxBusyCursor busy;
|
wxBusyCursor busy;
|
||||||
theTheme.CreateImageCache();
|
theTheme.CreateImageCache();
|
||||||
theTheme.WriteImageMap();// bonus - give them the html version.
|
theTheme.WriteImageMap();// bonus - give them the html version.
|
||||||
@@ -212,6 +231,8 @@ void ThemePrefs::OnReadThemeInternal(wxCommandEvent & WXUNUSED(event))
|
|||||||
/// Save Theme as C source code.
|
/// Save Theme as C source code.
|
||||||
void ThemePrefs::OnSaveThemeAsCode(wxCommandEvent & WXUNUSED(event))
|
void ThemePrefs::OnSaveThemeAsCode(wxCommandEvent & WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
if (!ConfirmSave()) return;
|
||||||
|
|
||||||
wxBusyCursor busy;
|
wxBusyCursor busy;
|
||||||
theTheme.SaveThemeAsCode();
|
theTheme.SaveThemeAsCode();
|
||||||
theTheme.WriteImageDefs();// bonus - give them the Defs too.
|
theTheme.WriteImageDefs();// bonus - give them the Defs too.
|
||||||
|
Reference in New Issue
Block a user