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, const TranslatableString &label, const Identifier &section, bool resizable=false)
 
virtual ~ToolBar ()
 
virtual bool ShownByDefault () const
 Whether the toolbar should be shown by default. Default implementation returns true. More...
 
virtual bool HideAfterReset () const
 Default implementation returns false. More...
 
virtual DockID DefaultDockID () const
 Which dock the toolbar defaults into. Default implementation chooses the top dock. More...
 
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 GetIndex () const
 Get a value used for computing cascading positions of undocked bars. More...
 
void SetIndex (int index)
 Set a value used for computing cascading positions of undocked bars. More...
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
Identifier GetSection ()
 
ToolDockGetDock ()
 
void SetPreferredNeighbors (Identifier left, Identifier top={})
 
void SetLabel (const TranslatableString &label)
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
std::pair< Identifier, IdentifierPreferredNeighbors () const noexcept
 Defaults to (NoBarID, NoBarId) More...
 
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 Identifier ID ()
 
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
enum  DockID { TopDockID = 1 , BotDockID = 2 }
 Identifies one of the docking areas for toolbars. More...
 
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
 
Identifier mSection
 
int mIndex {0}
 

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 46 of file ShareAudioToolbar.h.

Constructor & Destructor Documentation

◆ ShareAudioToolbar()

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

Definition at line 43 of file ShareAudioToolbar.cpp.

44 : ToolBar(project, XO("Share Audio"), ID())
45{
46}
XO("Cut/Copy/Paste")
const auto project
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328

◆ ~ShareAudioToolbar()

cloud::ShareAudioToolbar::~ShareAudioToolbar ( )
override

Definition at line 48 of file ShareAudioToolbar.cpp.

49{
50}

Member Function Documentation

◆ ArrangeButtons()

void cloud::ShareAudioToolbar::ArrangeButtons ( )
private

Definition at line 185 of file ShareAudioToolbar.cpp.

186{
187 // (Re)allocate the button sizer
188 DestroySizer();
189
190 Add((mSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND);
191 mSizer->Add(mShareAudioButton, 1, wxEXPAND);
192
193 // Layout the sizer
194 mSizer->Layout();
195
196 // Layout the toolbar
197 Layout();
198
199 const auto height = 2 * toolbarSingle;
200 SetMinSize({ std::max(76, GetSizer()->GetMinSize().GetWidth()), height });
201 SetMaxSize({ -1, height });
202}
#define safenew
Definition: MemoryX.h:9
#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:709
wxBoxSizer * GetSizer()
Definition: ToolBar.cpp:701

References ToolBar::Add(), DestroySizer(), ToolBar::GetSizer(), mShareAudioButton, mSizer, safenew, 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 64 of file ShareAudioToolbar.cpp.

65{
66 ToolBar::Create(parent);
67
68 // Simulate a size event to set initial meter placement/size
69 wxSizeEvent event(GetSize(), GetId());
70 event.SetEventObject(this);
71 GetEventHandler()->ProcessEvent(event);
72}
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:492

References ToolBar::Create().

Here is the call graph for this function:

◆ DestroySizer()

void cloud::ShareAudioToolbar::DestroySizer ( )
private

Definition at line 204 of file ShareAudioToolbar.cpp.

205{
206 if (mSizer == nullptr)
207 return;
208
209 Detach(mSizer);
210
211 std::unique_ptr<wxSizer> { mSizer }; // DELETE it
212 mSizer = nullptr;
213}
void Detach(wxWindow *window)
Definition: ToolBar.cpp:775

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 124 of file ShareAudioToolbar.cpp.

125{
126 auto gAudioIO = AudioIOBase::Get();
127
128 const bool audioStreamActive = gAudioIO &&
129 gAudioIO->IsStreamActive() && !gAudioIO->IsMonitoring();
130
131 bool hasAudio = false;
132
133 for (const auto& track : TrackList::Get(mProject).Any<PlayableTrack>())
134 {
135 if (track->GetStartTime() != track->GetEndTime())
136 {
137 hasAudio = true;
138 break;
139 }
140 }
141
142 mShareAudioButton->SetEnabled(hasAudio && !audioStreamActive);
143}
void SetEnabled(bool state)
Definition: AButton.h:182
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:94
AudacityProject & mProject
Definition: ToolBar.h:248
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347

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 52 of file ShareAudioToolbar.cpp.

53{
54 auto& toolManager = ToolManager::Get(project);
55 return *static_cast<ShareAudioToolbar*>(
56 toolManager.GetToolBar(ID()));
57}
static ToolManager & Get(AudacityProject &project)
ShareAudioToolbar(AudacityProject &project)

References ToolManager::Get(), ID(), and project.

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 59 of file ShareAudioToolbar.cpp.

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

References Get(), and project.

Here is the call graph for this function:

◆ ID()

Identifier cloud::ShareAudioToolbar::ID ( )
static

Definition at line 38 of file ShareAudioToolbar.cpp.

39{
40 return wxT("Share Audio");
41}
wxT("CloseDown"))

References wxT().

Referenced by Get(), and RegenerateTooltips().

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

◆ MakeShareAudioButton()

void cloud::ShareAudioToolbar::MakeShareAudioButton ( )
private

Definition at line 159 of file ShareAudioToolbar.cpp.

160{
162 //i18n-hint: Share audio button text, keep as short as possible
163 mShareAudioButton->SetLabel(XO("Share Audio"));
166 theTheme.Image(bmpRecoloredUpSmall),
167 theTheme.Image(bmpRecoloredUpHiliteSmall),
168 theTheme.Image(bmpRecoloredDownSmall),
169 theTheme.Image(bmpRecoloredHiliteSmall),
170 theTheme.Image(bmpRecoloredUpSmall));
171 mShareAudioButton->SetIcon(theTheme.Image(bmpShareAudio));
172 mShareAudioButton->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
173
174 mShareAudioButton->Bind(
175 wxEVT_BUTTON,
176 [this](auto)
177 {
178 audiocom::ShareAudioDialog dlg(mProject, &ProjectWindow::Get(mProject));
179 dlg.ShowModal();
180
182 });
183}
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:147
void SetImages(const wxImage &up, const wxImage &over, const wxImage &down, const wxImage &overDown, const wxImage &dis)
Definition: AButton.cpp:205
void PopUp()
Definition: AButton.cpp:585
@ FrameButton
Definition: AButton.h:114
void SetIcon(const wxImage &icon)
Definition: AButton.cpp:226
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:189
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 97 of file ShareAudioToolbar.cpp.

98{
100 SetBackgroundColour(theTheme.Colour(clrMedium));
102
103#if wxUSE_TOOLTIPS
105 wxToolTip::Enable(true);
106 wxToolTip::SetDelay(1000);
107#endif
108
109 // Set default order and mode
111}
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:837
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 145 of file ShareAudioToolbar.cpp.

146{
147 // ToolBar::ReCreateButtons() will get rid of its sizer and
148 // since we've attached our sizer to it, ours will get deleted too
149 // so clean ours up first.
150 DestroySizer();
151
153
155
157}
virtual void ReCreateButtons()
Definition: ToolBar.cpp:533
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 74 of file ShareAudioToolbar.cpp.

75{
76#if wxUSE_TOOLTIPS
77 for (long iWinID = ID_SHARE_AUDIO_BUTTON; iWinID < BUTTON_COUNT; iWinID++)
78 {
79 auto pCtrl = static_cast<AButton*>(this->FindWindow(iWinID));
81 switch (iWinID)
82 {
84 name = ID();
85 break;
86 }
87
88 std::vector<ComponentInterfaceSymbol> commands(
89 1u, { name, Verbatim(pCtrl->GetLabel()) });
90
92 mProject, *pCtrl, commands.data(), commands.size());
93 }
94#endif
95}
const TranslatableString name
Definition: Distortion.cpp:76
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:259
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:970

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

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 113 of file ShareAudioToolbar.cpp.

114{
115#ifndef USE_AQUA_THEME
116 const auto s = mSizer->GetSize();
117 const auto p = mSizer->GetPosition();
118
119 wxRect bevelRect(p.x, p.y, s.GetWidth() - 1, s.GetHeight() - 1);
120 AColor::Bevel(*dc, true, bevelRect);
121#endif
122}
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 43 of file ShareAudioToolbar.h.

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

◆ mSizer

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

Definition at line 44 of file ShareAudioToolbar.h.

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


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