Audacity  3.0.3
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
ThemePrefs Class Referencefinal

A PrefsPanel that configures dynamic loading of Theme icons and colours. More...

#include <ThemePrefs.h>

Inheritance diagram for ThemePrefs:
[legend]
Collaboration diagram for ThemePrefs:
[legend]

Public Member Functions

 ThemePrefs (wxWindow *parent, wxWindowID winid)
 
 ~ThemePrefs (void)
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
bool Commit () override
 Update the preferences stored on disk. More...
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual PluginPath GetPath ()
 
virtual VendorSymbol GetVendor ()
 
virtual wxString GetVersion ()
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static void ApplyUpdatedImages ()
 
- Static Public Member Functions inherited from PrefsPanel
static FactoriesDefaultFactories ()
 

Private Member Functions

void Populate ()
 Creates the dialog and its contents. More...
 
void PopulateOrExchange (ShuttleGui &S) override
 Create the dialog contents, or exchange data with it. More...
 
void OnLoadThemeComponents (wxCommandEvent &e)
 Load Theme from multiple png files. More...
 
void OnSaveThemeComponents (wxCommandEvent &e)
 Save Theme to multiple png files. More...
 
void OnLoadThemeCache (wxCommandEvent &e)
 Load Theme from single png file. More...
 
void OnSaveThemeCache (wxCommandEvent &e)
 Save Theme to single png file. More...
 
void OnReadThemeInternal (wxCommandEvent &e)
 Read Theme from internal storage. More...
 
void OnSaveThemeAsCode (wxCommandEvent &e)
 Save Theme as C source code. More...
 

Additional Inherited Members

- Public Types inherited from PrefsPanel
using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 

Detailed Description

A PrefsPanel that configures dynamic loading of Theme icons and colours.

Provides:

See also
Themability of Audacity

Definition at line 30 of file ThemePrefs.h.

Constructor & Destructor Documentation

◆ ThemePrefs()

ThemePrefs::ThemePrefs ( wxWindow *  parent,
wxWindowID  winid 
)

Definition at line 61 of file ThemePrefs.cpp.

66 : PrefsPanel(parent, winid, XO("Theme"))
67 {
68  Populate();
69 }

◆ ~ThemePrefs()

ThemePrefs::~ThemePrefs ( void  )

Definition at line 71 of file ThemePrefs.cpp.

72 {
73 }

Member Function Documentation

◆ ApplyUpdatedImages()

void ThemePrefs::ApplyUpdatedImages ( )
static

Definition at line 215 of file ThemePrefs.cpp.

216 {
217  AColor::ReInit();
218 
219  wxCommandEvent e{ EVT_THEME_CHANGE };
220  wxTheApp->SafelyProcessEvent( e );
221 }

References AColor::ReInit().

Referenced by GUIPrefs::Commit(), OnLoadThemeCache(), OnLoadThemeComponents(), and OnReadThemeInternal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Commit()

bool ThemePrefs::Commit ( )
overridevirtual

Update the preferences stored on disk.

Implements PrefsPanel.

Definition at line 224 of file ThemePrefs.cpp.

225 {
226  ShuttleGui S(this, eIsSavingToPrefs);
228 
229  return true;
230 }

References eIsSavingToPrefs, and PopulateOrExchange().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString ThemePrefs::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 80 of file ThemePrefs.cpp.

81 {
82  return XO("Preferences for Theme");
83 }

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol ThemePrefs::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 75 of file ThemePrefs.cpp.

76 {
78 }

References THEME_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID ThemePrefs::HelpPageName ( )
overridevirtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 85 of file ThemePrefs.cpp.

86 {
87  return "Theme_Preferences";
88 }

◆ OnLoadThemeCache()

void ThemePrefs::OnLoadThemeCache ( wxCommandEvent &  e)
private

Load Theme from single png file.

Definition at line 188 of file ThemePrefs.cpp.

189 {
192 }

References ApplyUpdatedImages(), ThemeBase::ReadImageCache(), and theTheme.

Here is the call graph for this function:

◆ OnLoadThemeComponents()

void ThemePrefs::OnLoadThemeComponents ( wxCommandEvent &  e)
private

Load Theme from multiple png files.

Definition at line 175 of file ThemePrefs.cpp.

176 {
179 }

References ApplyUpdatedImages(), ThemeBase::LoadComponents(), and theTheme.

Here is the call graph for this function:

◆ OnReadThemeInternal()

void ThemePrefs::OnReadThemeInternal ( wxCommandEvent &  e)
private

Read Theme from internal storage.

Definition at line 202 of file ThemePrefs.cpp.

References ApplyUpdatedImages(), ThemeBase::GetFallbackThemeType(), ThemeBase::ReadImageCache(), and theTheme.

Here is the call graph for this function:

◆ OnSaveThemeAsCode()

void ThemePrefs::OnSaveThemeAsCode ( wxCommandEvent &  e)
private

Save Theme as C source code.

Definition at line 209 of file ThemePrefs.cpp.

210 {
212  theTheme.WriteImageDefs();// bonus - give them the Defs too.
213 }

References ThemeBase::SaveThemeAsCode(), theTheme, and ThemeBase::WriteImageDefs().

Here is the call graph for this function:

◆ OnSaveThemeCache()

void ThemePrefs::OnSaveThemeCache ( wxCommandEvent &  e)
private

Save Theme to single png file.

Definition at line 195 of file ThemePrefs.cpp.

196 {
198  theTheme.WriteImageMap();// bonus - give them the html version.
199 }

References ThemeBase::CreateImageCache(), theTheme, and ThemeBase::WriteImageMap().

Here is the call graph for this function:

◆ OnSaveThemeComponents()

void ThemePrefs::OnSaveThemeComponents ( wxCommandEvent &  e)
private

Save Theme to multiple png files.

Definition at line 182 of file ThemePrefs.cpp.

183 {
185 }

References ThemeBase::SaveComponents(), and theTheme.

Here is the call graph for this function:

◆ Populate()

void ThemePrefs::Populate ( )
private

Creates the dialog and its contents.

Definition at line 91 of file ThemePrefs.cpp.

92 {
93  // First any pre-processing for constructing the GUI.
94 
95  //------------------------- Main section --------------------
96  // Now construct the GUI itself.
97  // Use 'eIsCreatingFromPrefs' so that the GUI is
98  // initialised with values from gPrefs.
101  // ----------------------- End of main section --------------
102 }

References eIsCreatingFromPrefs, and PopulateOrExchange().

Here is the call graph for this function:

◆ PopulateOrExchange()

void ThemePrefs::PopulateOrExchange ( ShuttleGui S)
overrideprivate

Create the dialog contents, or exchange data with it.

Definition at line 105 of file ThemePrefs.cpp.

106 {
107  S.SetBorder(2);
108  S.StartScroller();
109 
110  S.StartStatic(XO("Info"));
111  {
112  S.AddFixedText(
113  XO(
114 "Themability is an experimental feature.\n\nTo try it out, click \"Save Theme Cache\" then find and modify the images and colors in\nImageCacheVxx.png using an image editor such as the Gimp.\n\nClick \"Load Theme Cache\" to load the changed images and colors back into Audacity.\n\n(Only the Transport Toolbar and the colors on the wavetrack are currently affected, even\nthough the image file shows other icons too.)")
115  );
116 
117 #ifdef _DEBUG
118  S.AddFixedText(
119  Verbatim(
120 "This is a debug version of Audacity, with an extra button, 'Output Sourcery'. This will save a\nC version of the image cache that can be compiled in as a default.")
121  );
122 #endif
123 
124  S.AddFixedText(
125  XO(
126 "Saving and loading individual theme files uses a separate file for each image, but is\notherwise the same idea.")
127  );
128  }
129  S.EndStatic();
130 
131  /* i18n-hint: && in here is an escape character to get a single & on screen,
132  * so keep it as is */
133  S.StartStatic( XO("Theme Cache - Images && Color"));
134  {
135  S.StartHorizontalLay(wxALIGN_LEFT);
136  {
137  S.Id(idSaveThemeCache).AddButton(XXO("Save Theme Cache"));
138  S.Id(idLoadThemeCache).AddButton(XXO("Load Theme Cache"));
139 
140  // This next button is only provided in Debug mode.
141  // It is for developers who are compiling Audacity themselves
142  // and who wish to generate a NEW ThemeAsCeeCode.h and compile it in.
143 #ifdef _DEBUG
144  S.Id(idSaveThemeAsCode).AddButton(Verbatim("Output Sourcery"));
145 #endif
146 
147  S.Id(idReadThemeInternal).AddButton(XXO("&Defaults"));
148  }
149  S.EndHorizontalLay();
150  }
151  S.EndStatic();
152 
153  // JKC: 'Ergonomic' details:
154  // Theme components are used much less frequently than
155  // the ImageCache. Yet it's easy to click them 'by mistake'.
156  //
157  // To reduce that risk, we use a separate box to separate them off.
158  // And choose text on the buttons that is shorter, making the
159  // buttons smaller and less tempting to click.
160  S.StartStatic( XO("Individual Theme Files"),1);
161  {
162  S.StartHorizontalLay(wxALIGN_LEFT);
163  {
164  S.Id(idSaveThemeComponents).AddButton( XXO("Save Files"));
165  S.Id(idLoadThemeComponents).AddButton( XXO("Load Files"));
166  }
167  S.EndHorizontalLay();
168  }
169  S.EndStatic();
170  S.EndScroller();
171 
172 }

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddFixedText(), ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), ShuttleGui::Id(), idLoadThemeCache, idLoadThemeComponents, idReadThemeInternal, idSaveThemeAsCode, idSaveThemeCache, idSaveThemeComponents, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), Verbatim(), XO, and XXO.

Referenced by Commit(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files:
ThemeBase::SaveComponents
void SaveComponents()
Definition: Theme.cpp:1107
AColor::ReInit
static void ReInit()
Definition: AColor.cpp:446
ThemeBase::CreateImageCache
void CreateImageCache(bool bBinarySave=true)
Definition: Theme.cpp:633
idReadThemeInternal
@ idReadThemeInternal
Definition: ThemePrefs.cpp:48
XO
#define XO(s)
Definition: Internat.h:31
THEME_PREFS_PLUGIN_SYMBOL
#define THEME_PREFS_PLUGIN_SYMBOL
Definition: ThemePrefs.h:28
ThemePrefs::Populate
void Populate()
Creates the dialog and its contents.
Definition: ThemePrefs.cpp:91
idSaveThemeComponents
@ idSaveThemeComponents
Definition: ThemePrefs.cpp:47
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:971
idSaveThemeAsCode
@ idSaveThemeAsCode
Definition: ThemePrefs.cpp:49
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:938
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1177
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1167
ThemeBase::LoadComponents
void LoadComponents(bool bOkIfNotFound=false)
Definition: Theme.cpp:1055
ShuttleGuiBase::AddFixedText
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:440
ThemeBase::GetFallbackThemeType
teThemeType GetFallbackThemeType()
Definition: Theme.cpp:891
ShuttleGuiBase::AddButton
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:360
ThemePrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Create the dialog contents, or exchange data with it.
Definition: ThemePrefs.cpp:105
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:48
ThemeBase::ReadImageCache
bool ReadImageCache(teThemeType type=themeFromFile, bool bOkIfNotFound=false)
Definition: Theme.cpp:923
ThemeBase::WriteImageMap
void WriteImageMap()
Definition: Theme.cpp:798
ThemePrefs::ApplyUpdatedImages
static void ApplyUpdatedImages()
Definition: ThemePrefs.cpp:215
idSaveThemeCache
@ idSaveThemeCache
Definition: ThemePrefs.cpp:45
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
ThemeBase::SaveThemeAsCode
void SaveThemeAsCode()
Definition: Theme.cpp:1184
idLoadThemeComponents
@ idLoadThemeComponents
Definition: ThemePrefs.cpp:46
ThemeBase::WriteImageDefs
void WriteImageDefs()
Writes a series of Macro definitions that can be used in the include file.
Definition: Theme.cpp:851
theTheme
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:203
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:47
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
PrefsPanel::PrefsPanel
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90
idLoadThemeCache
@ idLoadThemeCache
Definition: ThemePrefs.cpp:44