Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
cloud::ShareAudioToolbar Class Referencefinal

#include <ShareAudioToolbar.h>

Inheritance diagram for cloud::ShareAudioToolbar:
[legend]
Collaboration diagram for cloud::ShareAudioToolbar:
[legend]

Public Member Functions

 ShareAudioToolbar (AudacityProject &project)
 
 ~ShareAudioToolbar () override
 
- Public Member Functions inherited from ToolBar
 ToolBar (AudacityProject &project, int type, const TranslatableString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
virtual void SetToDefaultSize ()
 
virtual void Create (wxWindow *parent)
 
virtual void EnableDisableButtons ()=0
 
virtual void ReCreateButtons ()
 
void UpdatePrefs () override
 
virtual void RegenerateTooltips ()=0
 
int GetType ()
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const TranslatableString &label)
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
wxSize GetSmartDockedSize ()
 
virtual void ResizingDone ()
 
- 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 ShareAudioToolbarGet (AudacityProject &project)
 
static const ShareAudioToolbarGet (const AudacityProject &project)
 
- Static Public Member Functions inherited from ToolBar
static AButtonMakeButton (wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
 
static AButtonMakeButton (ToolBar *parent, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const TranslatableString &label)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
 
static void SetButtonToolTip (AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
 
static void MakeButtonBackgroundsSmall ()
 
static void MakeButtonBackgroundsLarge ()
 

Private Types

enum  { ID_SHARE_AUDIO_BUTTON = 14000 , BUTTON_COUNT }
 

Private Member Functions

void Create (wxWindow *parent) override
 
void RegenerateTooltips () override
 
void Populate () override
 
void Repaint (wxDC *dc) override
 
void EnableDisableButtons () override
 
void ReCreateButtons () override
 
void MakeShareAudioButton ()
 
void ArrangeButtons ()
 
void DestroySizer ()
 

Private Attributes

AButtonmShareAudioButton {}
 
wxBoxSizer * mSizer {}
 

Additional Inherited Members

- Public Types inherited from ToolBar
using Holder = wxWindowPtr< ToolBar >
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
wxBoxSizer * GetSizer ()
 
void Add (wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
 
void Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void AddSpacer (int size=14)
 
void AddStretchSpacer (int prop=1)
 
void Detach (wxWindow *window)
 
void Detach (wxSizer *sizer)
 
void Updated ()
 
int GetResizeGrabberWidth ()
 Returns the width in pixels of the resizer element. More...
 
virtual void Populate ()=0
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
- Static Protected Member Functions inherited from ToolBar
static void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeMacRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
static void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
- Static Protected Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Attributes inherited from ToolBar
AudacityProjectmProject
 
TranslatableString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

Definition at line 19 of file ShareAudioToolbar.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_SHARE_AUDIO_BUTTON 
BUTTON_COUNT 

Definition at line 44 of file ShareAudioToolbar.h.

Constructor & Destructor Documentation

◆ ShareAudioToolbar()

cloud::ShareAudioToolbar::ShareAudioToolbar ( AudacityProject project)
explicit

Definition at line 36 of file ShareAudioToolbar.cpp.

37 : ToolBar(project, ShareAudioBarID, XO("Share Audio"), wxT("Share Audio"))
38{
39}
wxT("CloseDown"))
#define XO(s)
Definition: Internat.h:31
ToolBar(AudacityProject &project, int type, const TranslatableString &label, const wxString &section, bool resizable=false)
Definition: ToolBar.cpp:330

◆ ~ShareAudioToolbar()

cloud::ShareAudioToolbar::~ShareAudioToolbar ( )
override

Definition at line 41 of file ShareAudioToolbar.cpp.

42{
43}

Member Function Documentation

◆ ArrangeButtons()

void cloud::ShareAudioToolbar::ArrangeButtons ( )
private

Definition at line 178 of file ShareAudioToolbar.cpp.

179{
180 // (Re)allocate the button sizer
181 DestroySizer();
182
183 Add((mSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND);
184 mSizer->Add(mShareAudioButton, 1, wxEXPAND);
185
186 // Layout the sizer
187 mSizer->Layout();
188
189 // Layout the toolbar
190 Layout();
191
192 const auto height = 2 * toolbarSingle;
193 const wxSize size(GetSizer()->GetMinSize().GetWidth(), height);
194 SetMinSize(size);
195 SetMaxSize(size);
196}
#define safenew
Definition: MemoryX.h:10
#define toolbarSingle
Definition: ToolBar.h:59
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:695
wxBoxSizer * GetSizer()
Definition: ToolBar.cpp:687

References ToolBar::Add(), DestroySizer(), ToolBar::GetSizer(), mShareAudioButton, mSizer, safenew, size, and toolbarSingle.

Referenced by Populate().

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

◆ Create()

void cloud::ShareAudioToolbar::Create ( wxWindow *  parent)
overrideprivatevirtual

Reimplemented from ToolBar.

Definition at line 57 of file ShareAudioToolbar.cpp.

58{
59 ToolBar::Create(parent);
60
61 // Simulate a size event to set initial meter placement/size
62 wxSizeEvent event(GetSize(), GetId());
63 event.SetEventObject(this);
64 GetEventHandler()->ProcessEvent(event);
65}
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:484

References ToolBar::Create().

Here is the call graph for this function:

◆ DestroySizer()

void cloud::ShareAudioToolbar::DestroySizer ( )
private

Definition at line 198 of file ShareAudioToolbar.cpp.

199{
200 if (mSizer == nullptr)
201 return;
202
203 Detach(mSizer);
204
205 std::unique_ptr<wxSizer> { mSizer }; // DELETE it
206 mSizer = nullptr;
207}
void Detach(wxWindow *window)
Definition: ToolBar.cpp:761

References ToolBar::Detach(), and mSizer.

Referenced by ArrangeButtons(), and ReCreateButtons().

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

◆ EnableDisableButtons()

void cloud::ShareAudioToolbar::EnableDisableButtons ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 117 of file ShareAudioToolbar.cpp.

118{
119 auto gAudioIO = AudioIOBase::Get();
120
121 const bool audioStreamActive = gAudioIO &&
122 gAudioIO->IsStreamActive() && !gAudioIO->IsMonitoring();
123
124 bool hasAudio = false;
125
126 for (const auto& track : TrackList::Get(mProject).Leaders<PlayableTrack>())
127 {
128 if (track->GetStartTime() != track->GetEndTime())
129 {
130 hasAudio = true;
131 break;
132 }
133 }
134
135 mShareAudioButton->SetEnabled(hasAudio && !audioStreamActive);
136}
void SetEnabled(bool state)
Definition: AButton.h:182
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:91
AudacityProject & mProject
Definition: ToolBar.h:251
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486

References AudioIOBase::Get(), TrackList::Get(), ToolBar::mProject, mShareAudioButton, and AButton::SetEnabled().

Referenced by ReCreateButtons().

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

◆ Get() [1/2]

ShareAudioToolbar & cloud::ShareAudioToolbar::Get ( AudacityProject project)
static

Definition at line 45 of file ShareAudioToolbar.cpp.

46{
47 auto& toolManager = ToolManager::Get(project);
48 return *static_cast<ShareAudioToolbar*>(
49 toolManager.GetToolBar(ShareAudioBarID));
50}
static ToolManager & Get(AudacityProject &project)
ShareAudioToolbar(AudacityProject &project)

References ToolManager::Get().

Referenced by Get().

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

◆ Get() [2/2]

const ShareAudioToolbar & cloud::ShareAudioToolbar::Get ( const AudacityProject project)
static

Definition at line 52 of file ShareAudioToolbar.cpp.

53{
54 return Get(const_cast<AudacityProject&>(project));
55}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
static ShareAudioToolbar & Get(AudacityProject &project)

References Get().

Here is the call graph for this function:

◆ MakeShareAudioButton()

void cloud::ShareAudioToolbar::MakeShareAudioButton ( )
private

Definition at line 152 of file ShareAudioToolbar.cpp.

153{
155 //i18n-hint: Share audio button text, keep as short as possible
156 mShareAudioButton->SetLabel(XO("Share Audio"));
159 theTheme.Image(bmpRecoloredUpSmall),
160 theTheme.Image(bmpRecoloredUpHiliteSmall),
161 theTheme.Image(bmpRecoloredDownSmall),
162 theTheme.Image(bmpRecoloredHiliteSmall),
163 theTheme.Image(bmpRecoloredUpSmall));
164 mShareAudioButton->SetIcon(theTheme.Image(bmpShareAudio));
165 mShareAudioButton->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
166
167 mShareAudioButton->Bind(
168 wxEVT_BUTTON,
169 [this](auto)
170 {
171 audiocom::ShareAudioDialog dlg(mProject, &ProjectWindow::Get(mProject));
172 dlg.ShowModal();
173
175 });
176}
THEME_API Theme theTheme
Definition: Theme.cpp:82
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
void SetButtonType(Type type)
Definition: AButton.cpp:150
void SetImages(const wxImage &up, const wxImage &over, const wxImage &down, const wxImage &overDown, const wxImage &dis)
Definition: AButton.cpp:208
void PopUp()
Definition: AButton.cpp:588
@ FrameButton
Definition: AButton.h:114
void SetIcon(const wxImage &icon)
Definition: AButton.cpp:229
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:192
static ProjectWindow & Get(AudacityProject &project)
wxColour & Colour(int iIndex)
wxImage & Image(int iIndex)

References ThemeBase::Colour(), AButton::FrameButton, ProjectWindow::Get(), ID_SHARE_AUDIO_BUTTON, ThemeBase::Image(), ToolBar::mProject, mShareAudioButton, AButton::PopUp(), safenew, AButton::SetButtonType(), AButton::SetIcon(), AButton::SetImages(), AButton::SetLabel(), theTheme, and XO.

Referenced by Populate().

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

◆ Populate()

void cloud::ShareAudioToolbar::Populate ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 90 of file ShareAudioToolbar.cpp.

91{
93 SetBackgroundColour(theTheme.Colour(clrMedium));
95
96#if wxUSE_TOOLTIPS
98 wxToolTip::Enable(true);
99 wxToolTip::SetDelay(1000);
100#endif
101
102 // Set default order and mode
104}
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:823
void RegenerateTooltips() override

References ArrangeButtons(), ThemeBase::Colour(), ToolBar::MakeButtonBackgroundsSmall(), MakeShareAudioButton(), RegenerateTooltips(), and theTheme.

Here is the call graph for this function:

◆ ReCreateButtons()

void cloud::ShareAudioToolbar::ReCreateButtons ( )
overrideprivatevirtual

Reimplemented from ToolBar.

Definition at line 138 of file ShareAudioToolbar.cpp.

139{
140 // ToolBar::ReCreateButtons() will get rid of its sizer and
141 // since we've attached our sizer to it, ours will get deleted too
142 // so clean ours up first.
143 DestroySizer();
144
146
148
150}
virtual void ReCreateButtons()
Definition: ToolBar.cpp:525
void EnableDisableButtons() override

References DestroySizer(), EnableDisableButtons(), ToolBar::ReCreateButtons(), and RegenerateTooltips().

Here is the call graph for this function:

◆ RegenerateTooltips()

void cloud::ShareAudioToolbar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 67 of file ShareAudioToolbar.cpp.

68{
69#if wxUSE_TOOLTIPS
70 for (long iWinID = ID_SHARE_AUDIO_BUTTON; iWinID < BUTTON_COUNT; iWinID++)
71 {
72 auto pCtrl = static_cast<AButton*>(this->FindWindow(iWinID));
74 switch (iWinID)
75 {
77 name = wxT("Share Audio");
78 break;
79 }
80
81 std::vector<ComponentInterfaceSymbol> commands(
82 1u, { name, Verbatim(pCtrl->GetLabel()) });
83
85 mProject, *pCtrl, commands.data(), commands.size());
86 }
87#endif
88}
const TranslatableString name
Definition: Distortion.cpp:82
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:956

References BUTTON_COUNT, ID_SHARE_AUDIO_BUTTON, ToolBar::mProject, name, ToolBar::SetButtonToolTip(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::size(), Verbatim(), and wxT().

Referenced by Populate(), and ReCreateButtons().

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

◆ Repaint()

void cloud::ShareAudioToolbar::Repaint ( wxDC *  dc)
overrideprivatevirtual

Implements ToolBar.

Definition at line 106 of file ShareAudioToolbar.cpp.

107{
108#ifndef USE_AQUA_THEME
109 const auto s = mSizer->GetSize();
110 const auto p = mSizer->GetPosition();
111
112 wxRect bevelRect(p.x, p.y, s.GetWidth() - 1, s.GetHeight() - 1);
113 AColor::Bevel(*dc, true, bevelRect);
114#endif
115}
static void Bevel(wxDC &dc, bool up, const wxRect &r)
Definition: AColor.cpp:266

References AColor::Bevel(), and mSizer.

Here is the call graph for this function:

Member Data Documentation

◆ mShareAudioButton

AButton* cloud::ShareAudioToolbar::mShareAudioButton {}
private

Definition at line 41 of file ShareAudioToolbar.h.

Referenced by ArrangeButtons(), EnableDisableButtons(), and MakeShareAudioButton().

◆ mSizer

wxBoxSizer* cloud::ShareAudioToolbar::mSizer {}
private

Definition at line 42 of file ShareAudioToolbar.h.

Referenced by ArrangeButtons(), DestroySizer(), and Repaint().


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