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

#include <ShareAudioToolbar.h>

Inheritance diagram for audacity::cloud::ShareAudioToolbar:
[legend]
Collaboration diagram for audacity::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 ()
 

Private Attributes

AButtonmShareAudioButton {}
 

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

Constructor & Destructor Documentation

◆ ShareAudioToolbar()

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

Definition at line 44 of file ShareAudioToolbar.cpp.

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

◆ ~ShareAudioToolbar()

audacity::cloud::ShareAudioToolbar::~ShareAudioToolbar ( )
override

Definition at line 49 of file ShareAudioToolbar.cpp.

50{
51}

Member Function Documentation

◆ ArrangeButtons()

void audacity::cloud::ShareAudioToolbar::ArrangeButtons ( )
private

Definition at line 178 of file ShareAudioToolbar.cpp.

179{
180 Add(mShareAudioButton, 0, wxALIGN_CENTRE | wxALL, toolbarSpacing);
181
182 SetMinSize({ std::max(76, GetSizer()->GetMinSize().GetWidth()), -1 });
183 SetMaxSize({ -1, -1 });
184
185 // Layout the toolbar
186 Layout();
187}
static constexpr auto toolbarSpacing
Preferred spacing between inner toolbar elements.
Definition: ToolBar.h:57
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(), ToolBar::GetSizer(), mShareAudioButton, and toolbarSpacing.

Referenced by Populate().

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

◆ Create()

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

Reimplemented from ToolBar.

Definition at line 65 of file ShareAudioToolbar.cpp.

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

References ToolBar::Create().

Here is the call graph for this function:

◆ EnableDisableButtons()

void audacity::cloud::ShareAudioToolbar::EnableDisableButtons ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 119 of file ShareAudioToolbar.cpp.

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

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 & audacity::cloud::ShareAudioToolbar::Get ( AudacityProject project)
static

Definition at line 53 of file ShareAudioToolbar.cpp.

54{
55 auto& toolManager = ToolManager::Get(project);
56 return *static_cast<ShareAudioToolbar*>(
57 toolManager.GetToolBar(ID()));
58}
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 & audacity::cloud::ShareAudioToolbar::Get ( const AudacityProject project)
static

Definition at line 60 of file ShareAudioToolbar.cpp.

61{
62 return Get(const_cast<AudacityProject&>(project));
63}
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 audacity::cloud::ShareAudioToolbar::ID ( )
static

Definition at line 39 of file ShareAudioToolbar.cpp.

40{
41 return wxT("Share Audio");
42}
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 audacity::cloud::ShareAudioToolbar::MakeShareAudioButton ( )
private

Definition at line 149 of file ShareAudioToolbar.cpp.

150{
151 const auto height = (toolbarSingle - toolbarMargin) * 2;
152
154 //i18n-hint: Share audio button text, keep as short as possible
155 mShareAudioButton->SetLabel(XO("Share Audio"));
158 theTheme.Image(bmpRecoloredUpSmall),
159 theTheme.Image(bmpRecoloredUpHiliteSmall),
160 theTheme.Image(bmpRecoloredDownSmall),
161 theTheme.Image(bmpRecoloredHiliteSmall),
162 theTheme.Image(bmpRecoloredUpSmall));
163 mShareAudioButton->SetIcon(theTheme.Image(bmpShareAudio));
164 mShareAudioButton->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
165
166 mShareAudioButton->Bind(wxEVT_BUTTON, [this](auto) {
167 audiocom::ShareAudioDialog dlg(
170 dlg.ShowModal();
171
173 });
174 mShareAudioButton->SetMinSize(wxSize{-1, height});
175 mShareAudioButton->SetMaxSize(wxSize{-1, height});
176}
#define safenew
Definition: MemoryX.h:10
THEME_API Theme theTheme
Definition: Theme.cpp:82
static constexpr auto toolbarSingle
Height of a single line toolbar.
Definition: ToolBar.h:53
static constexpr auto toolbarMargin
Preferred inner toolbar margin.
Definition: ToolBar.h:55
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
void SetButtonType(Type type)
Definition: AButton.cpp:148
void SetImages(const wxImage &up, const wxImage &over, const wxImage &down, const wxImage &overDown, const wxImage &dis)
Definition: AButton.cpp:221
void PopUp()
Definition: AButton.cpp:672
@ FrameTextVButton
Definition: AButton.h:115
void SetIcon(const wxImage &icon)
Definition: AButton.cpp:242
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:205
static ProjectWindow & Get(AudacityProject &project)
wxColour & Colour(int iIndex)
wxImage & Image(int iIndex)

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

Referenced by Populate().

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

◆ Populate()

void audacity::cloud::ShareAudioToolbar::Populate ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 98 of file ShareAudioToolbar.cpp.

99{
101 SetBackgroundColour(theTheme.Colour(clrMedium));
103
104#if wxUSE_TOOLTIPS
106 wxToolTip::Enable(true);
107 wxToolTip::SetDelay(1000);
108#endif
109
110 // Set default order and mode
112}
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:819

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

Here is the call graph for this function:

◆ ReCreateButtons()

void audacity::cloud::ShareAudioToolbar::ReCreateButtons ( )
overrideprivatevirtual

Reimplemented from ToolBar.

Definition at line 140 of file ShareAudioToolbar.cpp.

141{
143
145
147}
virtual void ReCreateButtons()
Definition: ToolBar.cpp:533

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

Here is the call graph for this function:

◆ RegenerateTooltips()

void audacity::cloud::ShareAudioToolbar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 75 of file ShareAudioToolbar.cpp.

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

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 audacity::cloud::ShareAudioToolbar::Repaint ( wxDC *  dc)
overrideprivatevirtual

Implements ToolBar.

Definition at line 114 of file ShareAudioToolbar.cpp.

115{
116 // this was used to add a bevel and can be removed
117}

Member Data Documentation

◆ mShareAudioButton

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

Definition at line 41 of file ShareAudioToolbar.h.

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


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