Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ThemedAButtonWrapper< AButtonBase > Class Template Referencefinal

#include <ThemedWrappers.h>

Inheritance diagram for ThemedAButtonWrapper< AButtonBase >:
[legend]
Collaboration diagram for ThemedAButtonWrapper< AButtonBase >:
[legend]

Public Member Functions

template<typename... Args>
 ThemedAButtonWrapper (Args &&... args)
 
void SetImageIndices (int setIndex, int up, int over, int down, int overDown, int disabled)
 
void SetBackgroundColorIndex (int index)
 
void SetForegroundColorIndex (int index)
 
void SetTranslatableLabel (TranslatableString label)
 
void UpdatePrefs () override
 
- Public Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 

Private Member Functions

void OnThemeChange (ThemeChangeMessage message)
 

Private Attributes

Observer::Subscription mThemeChangeSubscription
 
std::map< int, std::array< int, AButton::AButtonStateCount > > mSets
 
int mBackgroundColorIndex {-1}
 
int mForegroundColorIndex {-1}
 
std::optional< TranslatableStringmTranslatableLabel
 

Additional Inherited Members

- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 

Detailed Description

template<typename AButtonBase>
class ThemedAButtonWrapper< AButtonBase >

Definition at line 191 of file ThemedWrappers.h.

Constructor & Destructor Documentation

◆ ThemedAButtonWrapper()

template<typename AButtonBase >
template<typename... Args>
ThemedAButtonWrapper< AButtonBase >::ThemedAButtonWrapper ( Args &&...  args)
inline

Definition at line 204 of file ThemedWrappers.h.

204 : AButtonBase( std::forward<Args>(args)... )
205 {
208 }
THEME_API Theme theTheme
Definition: Theme.cpp:82
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
Observer::Subscription mThemeChangeSubscription
void OnThemeChange(ThemeChangeMessage message)

References ThemedAButtonWrapper< AButtonBase >::mThemeChangeSubscription, ThemedAButtonWrapper< AButtonBase >::OnThemeChange(), Observer::Publisher< Message, NotifyAll >::Subscribe(), and theTheme.

Here is the call graph for this function:

Member Function Documentation

◆ OnThemeChange()

template<typename AButtonBase >
void ThemedAButtonWrapper< AButtonBase >::OnThemeChange ( ThemeChangeMessage  message)
inlineprivate

Definition at line 255 of file ThemedWrappers.h.

256 {
257 if (message.appearance)
258 {
259 for(const auto& p : mSets)
260 AButtonBase::SetAlternateImages(
261 p.first,
267 );
268
269 if(mBackgroundColorIndex != -1)
270 AButtonBase::SetBackgroundColour(theTheme.Colour(mBackgroundColorIndex));
271
272 if(mForegroundColorIndex != -1)
273 AButtonBase::SetForegroundColour(theTheme.Colour(mForegroundColorIndex));
274
275 AButtonBase::Refresh(false);
276 }
277 }
@ AButtonUp
Definition: AButton.h:120
@ AButtonDis
Definition: AButton.h:124
@ AButtonOver
Definition: AButton.h:121
@ AButtonDown
Definition: AButton.h:122
@ AButtonOverDown
Definition: AButton.h:123
wxColour & Colour(int iIndex)
wxImage & Image(int iIndex)
std::map< int, std::array< int, AButton::AButtonStateCount > > mSets
std::optional< PreferredSystemAppearance > appearance
Definition: Theme.h:111

References AButton::AButtonDis, AButton::AButtonDown, AButton::AButtonOver, AButton::AButtonOverDown, AButton::AButtonUp, ThemeChangeMessage::appearance, ThemeBase::Colour(), ThemeBase::Image(), ThemedAButtonWrapper< AButtonBase >::mBackgroundColorIndex, ThemedAButtonWrapper< AButtonBase >::mForegroundColorIndex, ThemedAButtonWrapper< AButtonBase >::mSets, and theTheme.

Referenced by ThemedAButtonWrapper< AButtonBase >::ThemedAButtonWrapper().

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

◆ SetBackgroundColorIndex()

template<typename AButtonBase >
void ThemedAButtonWrapper< AButtonBase >::SetBackgroundColorIndex ( int  index)
inline

Definition at line 223 of file ThemedWrappers.h.

224 {
225 mBackgroundColorIndex = index;
226 if(index != -1)
227 AButtonBase::SetBackgroundColour(theTheme.Colour(mBackgroundColorIndex));
228 }

References ThemeBase::Colour(), ThemedAButtonWrapper< AButtonBase >::mBackgroundColorIndex, and theTheme.

Here is the call graph for this function:

◆ SetForegroundColorIndex()

template<typename AButtonBase >
void ThemedAButtonWrapper< AButtonBase >::SetForegroundColorIndex ( int  index)
inline

Definition at line 230 of file ThemedWrappers.h.

231 {
232 mForegroundColorIndex = index;
233 if(index != -1)
234 AButtonBase::SetForegroundColour(theTheme.Colour(mForegroundColorIndex));
235 }

References ThemeBase::Colour(), ThemedAButtonWrapper< AButtonBase >::mForegroundColorIndex, and theTheme.

Here is the call graph for this function:

◆ SetImageIndices()

template<typename AButtonBase >
void ThemedAButtonWrapper< AButtonBase >::SetImageIndices ( int  setIndex,
int  up,
int  over,
int  down,
int  overDown,
int  disabled 
)
inline

Definition at line 210 of file ThemedWrappers.h.

211 {
212 mSets[setIndex] = { up, over, down, overDown, disabled };
213 AButtonBase::SetAlternateImages(
214 setIndex,
215 theTheme.Image(up),
216 theTheme.Image(over),
217 theTheme.Image(down),
218 theTheme.Image(overDown),
219 theTheme.Image(disabled)
220 );
221 }

References ThemeBase::Image(), ThemedAButtonWrapper< AButtonBase >::mSets, and theTheme.

Here is the call graph for this function:

◆ SetTranslatableLabel()

template<typename AButtonBase >
void ThemedAButtonWrapper< AButtonBase >::SetTranslatableLabel ( TranslatableString  label)
inline

Definition at line 237 of file ThemedWrappers.h.

238 {
239 mTranslatableLabel = std::move(label);
240 AButtonBase::SetLabel(*mTranslatableLabel);
241 }
TranslatableString label
Definition: TagsEditor.cpp:165
std::optional< TranslatableString > mTranslatableLabel

References label, and ThemedAButtonWrapper< AButtonBase >::mTranslatableLabel.

◆ UpdatePrefs()

template<typename AButtonBase >
void ThemedAButtonWrapper< AButtonBase >::UpdatePrefs ( )
inlineoverridevirtual

Implements PrefsListener.

Definition at line 243 of file ThemedWrappers.h.

244 {
247 {
248 AButtonBase::SetLabel(*mTranslatableLabel);
249 AButtonBase::Refresh(false);
250 }
251 }
virtual void UpdatePrefs()=0
Definition: Prefs.cpp:154

References ThemedAButtonWrapper< AButtonBase >::mTranslatableLabel, and PrefsListener::UpdatePrefs().

Here is the call graph for this function:

Member Data Documentation

◆ mBackgroundColorIndex

template<typename AButtonBase >
int ThemedAButtonWrapper< AButtonBase >::mBackgroundColorIndex {-1}
private

◆ mForegroundColorIndex

template<typename AButtonBase >
int ThemedAButtonWrapper< AButtonBase >::mForegroundColorIndex {-1}
private

◆ mSets

template<typename AButtonBase >
std::map<int, std::array<int, AButton::AButtonStateCount> > ThemedAButtonWrapper< AButtonBase >::mSets
private

◆ mThemeChangeSubscription

template<typename AButtonBase >
Observer::Subscription ThemedAButtonWrapper< AButtonBase >::mThemeChangeSubscription
private

◆ mTranslatableLabel

template<typename AButtonBase >
std::optional<TranslatableString> ThemedAButtonWrapper< AButtonBase >::mTranslatableLabel
private

The documentation for this class was generated from the following file: