![]() |
Audacity 3.2.0
|
Theme management - Image loading and saving. More...
#include <Theme.h>
Classes | |
struct | RegisteredTheme |
Public Types | |
using | NameSet = std::unordered_set< wxString > |
![]() | |
using | message_type = ThemeChangeMessage |
using | CallbackReturn = std::conditional_t< true, void, bool > |
using | Callback = std::function< CallbackReturn(const ThemeChangeMessage &) > |
Type of functions that can be connected to the Publisher. More... | |
Public Member Functions | |
ThemeBase (void) | |
ThemeBase (const ThemeBase &)=delete | |
ThemeBase & | operator= (const ThemeBase &)=delete |
virtual | ~ThemeBase (void) |
virtual void | EnsureInitialised ()=0 |
FilePath | GetFilePath () |
void | SetFilePath (const FilePath &path) |
void | SwitchTheme (teThemeType Theme) |
void | LoadTheme (teThemeType Theme) |
void | RegisterImage (NameSet &allNames, int &flags, int &iIndex, char const **pXpm, const wxString &Name) |
void | RegisterImage (NameSet &allNames, int &flags, int &iIndex, const wxImage &Image, const wxString &Name) |
void | RegisterColour (NameSet &allNames, int &iIndex, const wxColour &Clr, const wxString &Name) |
teThemeType | GetFallbackThemeType () |
void | CreateImageCache () |
bool | CreateOneImageCache (teThemeType id, bool bBinarySave) |
bool | ReadImageCache (teThemeType type={}, bool bOkIfNotFound=false) |
void | LoadThemeComponents (bool bOkIfNotFound=false) |
void | LoadOneThemeComponents (teThemeType id, bool bOkIfNotFound=false) |
void | SaveThemeComponents () |
bool | SaveOneThemeComponents (teThemeType id) |
void | SaveThemeAsCode () |
void | WriteImageDefs () |
Writes a series of Macro definitions that can be used in the include file. More... | |
void | WriteImageMap () |
void | WriteOneImageMap (teThemeType id) |
void | RecolourBitmap (int iIndex, wxColour From, wxColour To) |
void | RecolourTheme () |
int | ColourDistance (wxColour &From, wxColour &To) |
wxColour & | Colour (int iIndex) |
wxBitmap & | Bitmap (int iIndex) |
wxImage & | Image (int iIndex) |
wxSize | ImageSize (int iIndex) |
void | ReplaceImage (int iIndex, wxImage *pImage) |
void | RotateImageInto (int iTo, int iFrom, bool bClockwise) |
void | SetBrushColour (wxBrush &Brush, int iIndex) |
void | SetPenColour (wxPen &Pen, int iIndex) |
wxImage | MaskedImage (char const **pXpm, char const **pMask) |
wxImage | MakeImageWithAlpha (wxBitmap &Bmp) |
void | DeleteUnusedThemes () |
![]() | |
Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={}) | |
Constructor supporting type-erased custom allocation/deletion. More... | |
Publisher (Publisher &&)=default | |
Publisher & | operator= (Publisher &&)=default |
Subscription | Subscribe (Callback callback) |
Connect a callback to the Publisher; later-connected are called earlier. More... | |
Subscription | Subscribe (Object &obj, Return(Object::*callback)(Args...)) |
Overload of Subscribe takes an object and pointer-to-member-function. More... | |
Static Public Member Functions | |
static bool | LoadPreferredTheme () |
Protected Attributes | |
FilePath | mThemeDir |
wxArrayString | mBitmapNames |
std::vector< int > | mBitmapFlags |
wxArrayString | mColourNames |
PreferredSystemAppearance | mPreferredSystemAppearance { PreferredSystemAppearance::Light } |
std::map< Identifier, ThemeSet > | mSets |
ThemeSet * | mpSet = nullptr |
Additional Inherited Members | |
![]() | |
static constexpr bool | notifies_all |
![]() | |
CallbackReturn | Publish (const ThemeChangeMessage &message) |
Send a message to connected callbacks. More... | |
Theme management - Image loading and saving.
Base for the Theme class. ThemeBase is a generic non-Audacity specific class.
using ThemeBase::NameSet = std::unordered_set<wxString> |
|
delete |
wxBitmap & ThemeBase::Bitmap | ( | int | iIndex | ) |
Referenced by anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::AddStuck(), AColor::Bevel2(), AColor::ButtonStretch(), CreateStdButtonSizer(), Exporter::CreateUserPane(), LWSlider::DrawToBitmap(), ErrorReportDialog::ErrorReportDialog(), LabelTrackView::GetGlyph(), anonymous_namespace{PlayIndicatorOverlay.cpp}::GetIndicatorBitmap(), InitProjectWindow(), MultiDialog::MultiDialog(), MeterPanel::OnPaint(), ThemedButtonWrapper< ButtonBase >::OnThemeChange(), DeviceToolBar::Populate(), MixerToolBar::Populate(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::RealtimeEffectControl(), RecolourBitmap(), ThemedButtonWrapper< ButtonBase >::SetBitmapCurrentIndex(), ThemedButtonWrapper< ButtonBase >::SetBitmapLabelIndex(), ThemedButtonWrapper< ButtonBase >::SetBitmapPressedIndex(), LogWindow::Show(), and HelpSystem::ShowHtmlText().
wxColour & ThemeBase::Colour | ( | int | iIndex | ) |
Referenced by AboutDialog::AboutDialog(), SelectionBar::AddTitle(), AlphaBlend(), ProjectWindow::ApplyUpdatedTheme(), ASlider::ASlider(), auStaticText::auStaticText(), AColor::BevelTrackInfo(), TrackInfo::CloseTitleDrawFunction(), CursorColour(), WaveTrackVRulerControls::DoDraw(), AdornedRulerPanel::DoDrawMarks(), AdornedRulerPanel::DoDrawPlayRegion(), AdornedRulerPanel::DoDrawPlayRegionLimits(), LabelTrackView::Draw(), NoteTrackAffordanceControls::Draw(), WaveTrackAffordanceControls::Draw(), TimeTrackVRulerControls::Draw(), Ruler::Label::Draw(), TrackInfo::DrawCloseButton(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), TrackInfo::DrawItems(), NoteTrack::DrawLabelControls(), anonymous_namespace{NoteTrackView.cpp}::DrawNoteTrack(), FrequencyPlotDialog::DrawPlot(), LWSlider::DrawToBitmap(), anonymous_namespace{TrackPanel.cpp}::DrawTrackName(), Grabber::Grabber(), HtmlColourOfIndex(), AColor::Init(), InitProjectWindow(), NumericTextCtrl::Layout(), LoadTheme(), MixerBoard::MakeButtonBitmap(), WaveTrackAffordanceControls::MakeTextEditHelper(), TrackInfo::MinimizeSyncLockDrawFunction(), MixerBoard::MixerBoard(), ToolManager::OnIndicatorPaint(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectControl::OnPaint(), EqualizationPanel::OnPaint(), ToolBarResizer::OnPaint(), ToolBar::OnPaint(), ToolDock::OnPaint(), NumericTextCtrl::OnPaint(), EffectAutoDuck::Panel::OnPaint(), EffectCompressorPanel::OnPaint(), EffectScienFilterPanel::OnPaint(), MixerTrackCluster::OnPaint(), MeterPanel::OnPaint(), ToolFrame::OnPaint(), ThemedWindowWrapper< WindowBase >::OnThemeChange(), ThemedButtonWrapper< ButtonBase >::OnThemeChange(), OverlayImage(), FrequencyPlotDialog::Populate(), ControlToolBar::Populate(), DeviceToolBar::Populate(), EditToolBar::Populate(), MeterToolBar::Populate(), MixerToolBar::Populate(), ScrubbingToolBar::Populate(), SelectionBar::Populate(), ToolsToolBar::Populate(), TranscriptionToolBar::Populate(), AColor::PreComputeGradient(), ProjectWindow::ProjectWindow(), RecolourTheme(), AdornedRulerPanel::ReCreateButtons(), Ruler::Ruler(), ThemedWindowWrapper< WindowBase >::SetBackgroundColorIndex(), ThemedButtonWrapper< ButtonBase >::SetBackgroundColorIndex(), ThemedWindowWrapper< WindowBase >::SetForegroundColorIndex(), ToolDock::ToolDock(), MixerBoard::UpdatePrefs(), and AColor::UseThemeColour().
int ThemeBase::ColourDistance | ( | wxColour & | From, |
wxColour & | To | ||
) |
Definition at line 307 of file Theme.cpp.
Referenced by CursorColour(), LoadTheme(), MeterPanel::OnPaint(), and RecolourTheme().
void ThemeBase::CreateImageCache | ( | ) |
Definition at line 614 of file Theme.cpp.
References CreateOneImageCache(), GetFilePath(), GetThemeCacheLookup(), anonymous_namespace{Theme.cpp}::ImageCacheFileName, key, mpSet, BasicUI::ShowMessageBox(), and XO.
Referenced by ThemePrefs::OnSaveThemeCache(), and SwitchTheme().
bool ThemeBase::CreateOneImageCache | ( | teThemeType | id, |
bool | bBinarySave | ||
) |
Definition at line 630 of file Theme.cpp.
References GetFilePath(), anonymous_namespace{Theme.cpp}::iColSize, anonymous_namespace{Theme.cpp}::ImageCacheFileName, ImageCacheHeight, ImageCacheWidth, mBitmapFlags, mBitmapNames, mColourNames, mpSet, name, SourceOutputStream::OpenFile(), PasteSubImage(), resFlagInternal, resFlagSkip, BasicUI::ShowMessageBox(), SwitchTheme(), anonymous_namespace{Theme.cpp}::ThemeCacheFileName, anonymous_namespace{Theme.cpp}::ThemeFilePrefix(), anonymous_namespace{Theme.cpp}::ThemeSubdir(), and XO.
Referenced by CreateImageCache().
void ThemeBase::DeleteUnusedThemes | ( | ) |
Referenced by ThemePrefs::Cancel(), GUIPrefs::Commit(), and ThemePrefs::Commit().
|
pure virtual |
Implemented in Theme.
Referenced by ReadImageCache(), SwitchTheme(), and WriteImageDefs().
teThemeType ThemeBase::GetFallbackThemeType | ( | ) |
Definition at line 889 of file Theme.cpp.
Referenced by ThemePrefs::OnReadThemeInternal(), and SwitchTheme().
FilePath ThemeBase::GetFilePath | ( | ) |
Definition at line 149 of file Theme.cpp.
References FileNames::DataDir(), mThemeDir, and SetFilePath().
Referenced by CreateImageCache(), CreateOneImageCache(), LoadOneThemeComponents(), ReadImageCache(), WriteImageDefs(), and WriteOneImageMap().
wxImage & ThemeBase::Image | ( | int | iIndex | ) |
Referenced by TrackArt::DrawSyncLockTiles(), ToolBar::MakeAlternateImages(), ToolBar::MakeButton(), ToolBar::MakeMacRecoloredImage(), TrackInfo::MinimizeSyncLockDrawFunction(), OverlayImage(), ReadImageCache(), RecolourBitmap(), RegisterImage(), and ToolBarGrabber::ToolBarGrabber().
wxSize ThemeBase::ImageSize | ( | int | iIndex | ) |
Referenced by EditToolBar::AddButton(), ScrubbingToolBar::AddButton(), TranscriptionToolBar::AddButton(), ControlToolBar::MakeAlternateImages(), TranscriptionToolBar::MakeAlternateImages(), ControlToolBar::MakeButton(), ToolsToolBar::MakeTool(), ReadImageCache(), and AdornedRulerPanel::ReCreateButtons().
void ThemeBase::LoadOneThemeComponents | ( | teThemeType | id, |
bool | bOkIfNotFound = false |
||
) |
JKC:
Definition at line 1043 of file Theme.cpp.
References PackedArray::begin(), anonymous_namespace{Theme.cpp}::ColorFileName, PackedArray::end(), TranslatableString::Format(), GetFilePath(), mBitmapFlags, mBitmapNames, mColourNames, mpSet, name, names, resFlagInternal, BasicUI::ShowMessageBox(), str, SwitchTheme(), anonymous_namespace{Theme.cpp}::ThemeComponent(), anonymous_namespace{Theme.cpp}::ThemeComponentsDir(), Verbatim(), and XO.
Referenced by LoadThemeComponents().
|
static |
Definition at line 162 of file Theme.cpp.
References GUITheme(), LoadTheme(), ChoiceSetting::Read(), theme, and theTheme.
Referenced by ThemePrefs::Cancel(), GUIPrefs::Commit(), ThemePrefs::Commit(), and AudacityApp::OnInit().
void ThemeBase::LoadTheme | ( | teThemeType | Theme | ) |
This function is called to load the initial Theme images. It does not though cause the GUI to refresh.
Definition at line 255 of file Theme.cpp.
References ThemeSet::bRecolourOnLoad, Colour(), ColourDistance(), mPreferredSystemAppearance, mpSet, Observer::Publisher< ThemeChangeMessage >::Publish(), RecolourTheme(), RotateImageInto(), SwitchTheme(), and theTheme.
Referenced by LoadPreferredTheme().
void ThemeBase::LoadThemeComponents | ( | bool | bOkIfNotFound = false | ) |
Definition at line 1036 of file Theme.cpp.
References GetThemeCacheLookup(), key, LoadOneThemeComponents(), and mpSet.
Referenced by App::OnInit(), and ThemePrefs::OnLoadThemeComponents().
wxImage ThemeBase::MakeImageWithAlpha | ( | wxBitmap & | Bmp | ) |
wxImage ThemeBase::MaskedImage | ( | char const ** | pXpm, |
char const ** | pMask | ||
) |
Definition at line 350 of file Theme.cpp.
bool ThemeBase::ReadImageCache | ( | teThemeType | type = {} , |
bool | bOkIfNotFound = false |
||
) |
Reads an image cache including images, cursors and colours.
type | if empty means read from an external binary file. otherwise the data is taken from a block of memory. |
bOkIfNotFound | if true means do not report absent file. |
Definition at line 904 of file Theme.cpp.
References ThemeSet::bRecolourOnLoad, Identifier::empty(), PackedArray::end(), EnsureInitialised(), GetFilePath(), GetSubImageWithAlpha(), GetThemeCacheLookup(), GUIBlendThemes, GUITheme(), anonymous_namespace{Theme.cpp}::iColSize, Image(), anonymous_namespace{Theme.cpp}::ImageCacheFileName, ImageCacheWidth, ImageSize(), Light, mBitmapFlags, mPreferredSystemAppearance, mpSet, Setting< T >::Read(), Read(), resFlagInternal, BasicUI::ShowMessageBox(), anonymous_namespace{Theme.cpp}::ThemeSubdir(), and XO.
Referenced by SwitchTheme().
void ThemeBase::RecolourBitmap | ( | int | iIndex, |
wxColour | From, | ||
wxColour | To | ||
) |
Definition at line 298 of file Theme.cpp.
References Bitmap(), ChangeImageColour(), Image(), and ReplaceImage().
Referenced by RecolourTheme().
void ThemeBase::RecolourTheme | ( | ) |
Definition at line 317 of file Theme.cpp.
References Colour(), ColourDistance(), and RecolourBitmap().
Referenced by LoadTheme().
void ThemeBase::RegisterColour | ( | NameSet & | allNames, |
int & | iIndex, | ||
const wxColour & | Clr, | ||
const wxString & | Name | ||
) |
Definition at line 449 of file Theme.cpp.
References mColourNames, ThemeSet::mColours, and mpSet.
void ThemeBase::RegisterImage | ( | NameSet & | allNames, |
int & | flags, | ||
int & | iIndex, | ||
char const ** | pXpm, | ||
const wxString & | Name | ||
) |
Definition at line 396 of file Theme.cpp.
References RegisterImage().
Referenced by RegisterImage().
void ThemeBase::RegisterImage | ( | NameSet & | allNames, |
int & | flags, | ||
int & | iIndex, | ||
const wxImage & | Image, | ||
const wxString & | Name | ||
) |
Definition at line 412 of file Theme.cpp.
References Image(), mBitmapFlags, mBitmapNames, ThemeSet::mImages, and mpSet.
void ThemeBase::ReplaceImage | ( | int | iIndex, |
wxImage * | pImage | ||
) |
Referenced by ToolBar::MakeMacRecoloredImage(), and RecolourBitmap().
void ThemeBase::RotateImageInto | ( | int | iTo, |
int | iFrom, | ||
bool | bClockwise | ||
) |
bool ThemeBase::SaveOneThemeComponents | ( | teThemeType | id | ) |
void ThemeBase::SaveThemeAsCode | ( | ) |
Referenced by App::OnInit(), and ThemePrefs::OnSaveThemeAsCode().
void ThemeBase::SaveThemeComponents | ( | ) |
void ThemeBase::SetBrushColour | ( | wxBrush & | Brush, |
int | iIndex | ||
) |
Referenced by AColor::Init(), NumericTextCtrl::Layout(), NumericTextCtrl::OnPaint(), and TrackArtist::SetColours().
void ThemeBase::SetFilePath | ( | const FilePath & | path | ) |
void ThemeBase::SetPenColour | ( | wxPen & | Pen, |
int | iIndex | ||
) |
Referenced by AColor::Init(), NumericTextCtrl::OnPaint(), and TrackArtist::SetColours().
void ThemeBase::SwitchTheme | ( | teThemeType | Theme | ) |
Definition at line 217 of file Theme.cpp.
References CreateImageCache(), EnsureInitialised(), GetFallbackThemeType(), GUITheme(), mpSet, mSets, ChoiceSetting::Read(), and ReadImageCache().
Referenced by CreateOneImageCache(), LoadOneThemeComponents(), LoadTheme(), ThemePrefs::OnLoadThemeCache(), ThemePrefs::OnReadThemeInternal(), and WriteOneImageMap().
void ThemeBase::WriteImageDefs | ( | ) |
Writes a series of Macro definitions that can be used in the include file.
Definition at line 847 of file Theme.cpp.
References EnsureInitialised(), GetFilePath(), mBitmapFlags, mBitmapNames, mpSet, resFlagCursor, resFlagInternal, resFlagNewLine, resFlagPaired, and anonymous_namespace{Theme.cpp}::ThemeImageDefsAsCee().
Referenced by ThemePrefs::OnSaveThemeAsCode().
void ThemeBase::WriteImageMap | ( | ) |
Definition at line 786 of file Theme.cpp.
References GetThemeCacheLookup(), key, mpSet, and WriteOneImageMap().
Referenced by ThemePrefs::OnSaveThemeCache().
void ThemeBase::WriteOneImageMap | ( | teThemeType | id | ) |
Writes an html file with an image map of the ImageCache Very handy for seeing what each part is for.
Definition at line 795 of file Theme.cpp.
References GetFilePath(), anonymous_namespace{Theme.cpp}::iColSize, ImageCacheWidth, anonymous_namespace{Theme.cpp}::ImageMapFileName, mBitmapFlags, mBitmapNames, mColourNames, mpSet, resFlagInternal, SwitchTheme(), and anonymous_namespace{Theme.cpp}::ThemeSubdir().
Referenced by WriteImageMap().
|
protected |
Definition at line 201 of file Theme.h.
Referenced by CreateOneImageCache(), LoadOneThemeComponents(), ReadImageCache(), RegisterImage(), WriteImageDefs(), and WriteOneImageMap().
|
protected |
Definition at line 200 of file Theme.h.
Referenced by CreateOneImageCache(), LoadOneThemeComponents(), RegisterImage(), WriteImageDefs(), and WriteOneImageMap().
|
protected |
Definition at line 202 of file Theme.h.
Referenced by CreateOneImageCache(), LoadOneThemeComponents(), RegisterColour(), and WriteOneImageMap().
|
protected |
Definition at line 204 of file Theme.h.
Referenced by LoadTheme(), and ReadImageCache().
|
protected |
Definition at line 207 of file Theme.h.
Referenced by CreateImageCache(), CreateOneImageCache(), Theme::EnsureInitialised(), LoadOneThemeComponents(), LoadTheme(), LoadThemeComponents(), ReadImageCache(), RegisterColour(), RegisterImage(), Theme::RegisterImagesAndColours(), SwitchTheme(), WriteImageDefs(), WriteImageMap(), and WriteOneImageMap().
|
protected |
Definition at line 206 of file Theme.h.
Referenced by SwitchTheme().
|
protected |
Definition at line 198 of file Theme.h.
Referenced by GetFilePath(), and SetFilePath().