Audacity 3.2.0
PlayableTrackButtonHandles.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5PlayableTrackButtonHandles.cpp
6
7Paul Licameli split from TrackPanel.cpp
8
9**********************************************************************/
11#include "PlayableTrack.h"
13#include "CommandManager.h"
14#include "Project.h"
15#include "../../../RefreshCode.h"
16#include "../../../RealtimeEffectPanel.h"
17#include "SampleTrack.h"
18#include "TrackFocus.h"
19#include "../../ui/CommonTrackInfo.h"
20#include "../../../TrackPanelMouseEvent.h"
21#include "../../../TrackUtilities.h"
22
23#include <wx/window.h>
24
26( const std::shared_ptr<Track> &pTrack, const wxRect &rect )
27 : ButtonHandle{ pTrack, rect }
28{}
29
31{
32}
33
35 (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *)
36{
37 auto pTrack = mpTrack.lock();
38 if (dynamic_cast<PlayableTrack*>(pTrack.get()))
39 TrackUtilities::DoTrackMute(*pProject, *pTrack, event.ShiftDown());
40
42}
43
45 const wxMouseState &, AudacityProject &project) const
46{
47 auto name = XO("Mute");
48 auto focused =
49 TrackFocus::Get( project ).Get() == GetTrack().get();
50 if (!focused)
51 return name;
52
53 auto &commandManager = CommandManager::Get( project );
54 ComponentInterfaceSymbol command{ wxT("TrackMute"), name };
55 return commandManager.DescribeCommandsAndShortcuts(&command, 1u);
56}
57
59(std::weak_ptr<MuteButtonHandle> &holder,
60 const wxMouseState &state, const wxRect &rect,
61 const AudacityProject *pProject, const std::shared_ptr<Track> &pTrack)
62{
63 wxRect buttonRect;
64 if ( pTrack )
65 PlayableTrackControls::GetMuteSoloRect(rect, buttonRect, false,
66 pTrack.get());
67 if ( CommonTrackInfo::HideTopItem( rect, buttonRect ) )
68 return {};
69
70 if ( pTrack && buttonRect.Contains(state.m_x, state.m_y) ) {
71 auto result = std::make_shared<MuteButtonHandle>(pTrack, buttonRect);
72 result = AssignUIHandlePtr(holder, result);
73 return result;
74 }
75 else
76 return {};
77}
78
80
82( const std::shared_ptr<Track> &pTrack, const wxRect &rect )
83 : ButtonHandle{ pTrack, rect }
84{}
85
87{
88}
89
91(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *WXUNUSED(pParent))
92{
93 auto pTrack = mpTrack.lock();
94 if (dynamic_cast<PlayableTrack*>(pTrack.get()))
95 TrackUtilities::DoTrackSolo(*pProject, *pTrack, event.ShiftDown());
96
98}
99
101 const wxMouseState &, AudacityProject &project) const
102{
103 auto name = XO("Solo");
104 auto focused =
105 TrackFocus::Get( project ).Get() == GetTrack().get();
106 if (!focused)
107 return name;
108
109 auto &commandManager = CommandManager::Get( project );
110 ComponentInterfaceSymbol command{ wxT("TrackSolo"), name };
111 return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
112}
113
115(std::weak_ptr<SoloButtonHandle> &holder,
116 const wxMouseState &state, const wxRect &rect,
117 const AudacityProject *pProject, const std::shared_ptr<Track> &pTrack)
118{
119 wxRect buttonRect;
120 if ( pTrack )
121 PlayableTrackControls::GetMuteSoloRect(rect, buttonRect, true,
122 pTrack.get());
123
124 if ( CommonTrackInfo::HideTopItem( rect, buttonRect ) )
125 return {};
126
127 if ( pTrack && buttonRect.Contains(state.m_x, state.m_y) ) {
128 auto result = std::make_shared<SoloButtonHandle>( pTrack, buttonRect );
129 result = AssignUIHandlePtr(holder, result);
130 return result;
131 }
132 else
133 return {};
134}
135
137
139( const std::shared_ptr<Track> &pTrack, const wxRect &rect )
140 : ButtonHandle{ pTrack, rect }
141{}
142
144{
145}
146
148(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)
149{
151 dynamic_cast<SampleTrack *>(mpTrack.lock().get()), true);
153}
154
156 const wxMouseState &, AudacityProject &project) const
157{
158 auto name = XO("Effects");
159 auto focused =
160 TrackFocus::Get( project ).Get() == GetTrack().get();
161 if (!focused)
162 return name;
163 else {
164 return name;
165 // Instead supply shortcut when "TrackEffects" is defined
166 /*
167 auto &commandManager = CommandManager::Get( project );
168 ComponentInterfaceSymbol command{ wxT("TrackEffects"), name };
169 return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
170 */
171 }
172}
173
175(std::weak_ptr<EffectsButtonHandle> &holder,
176 const wxMouseState &state, const wxRect &rect,
177 const AudacityProject *pProject, const std::shared_ptr<Track> &pTrack)
178{
179 wxRect buttonRect;
180 if ( pTrack )
182 pTrack.get());
183
184 if ( CommonTrackInfo::HideTopItem( rect, buttonRect ) )
185 return {};
186
187 if ( pTrack && buttonRect.Contains(state.m_x, state.m_y) ) {
188 auto result = std::make_shared<EffectsButtonHandle>( pTrack, buttonRect );
189 result = AssignUIHandlePtr(holder, result);
190 return result;
191 }
192 else
193 return {};
194}
wxT("CloseDown"))
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
XO("Cut/Copy/Paste")
Extends Track with notions of mute and solo setting.
wxString name
Definition: TagsEditor.cpp:166
const auto project
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:164
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
A UIHandle for a TrackPanel button, such as the Mute and Solo buttons.
Definition: ButtonHandle.h:26
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:74
std::shared_ptr< Track > GetTrack() const
Definition: ButtonHandle.h:30
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:318
static CommandManager & Get(AudacityProject &project)
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
TranslatableString Tip(const wxMouseState &state, AudacityProject &) const override
static UIHandlePtr HitTest(std::weak_ptr< EffectsButtonHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< Track > &pTrack)
Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
EffectsButtonHandle(const EffectsButtonHandle &)=delete
static UIHandlePtr HitTest(std::weak_ptr< MuteButtonHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< Track > &pTrack)
Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
TranslatableString Tip(const wxMouseState &state, AudacityProject &) const override
MuteButtonHandle(const MuteButtonHandle &)=delete
static void GetMuteSoloRect(const wxRect &rect, wxRect &dest, bool solo, const Track *pTrack)
static void GetEffectsButtonRect(const wxRect &rect, wxRect &dest, const Track *pTrack)
AudioTrack subclass that can also be audibly replayed by the program.
Definition: PlayableTrack.h:40
void ShowPanel(SampleTrack *track, bool focus)
static RealtimeEffectPanel & Get(AudacityProject &project)
Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
static UIHandlePtr HitTest(std::weak_ptr< SoloButtonHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< Track > &pTrack)
SoloButtonHandle(const SoloButtonHandle &)=delete
TranslatableString Tip(const wxMouseState &state, AudacityProject &) const override
Track * Get()
Definition: TrackFocus.cpp:156
Holds a msgid for the translation catalog; may also bind format arguments.
unsigned Result
Definition: UIHandle.h:40
AUDACITY_DLL_API bool HideTopItem(const wxRect &rect, const wxRect &subRect, int allowance=0)
AUDACITY_DLL_API void DoTrackSolo(AudacityProject &project, Track &track, bool exclusive)
AUDACITY_DLL_API void DoTrackMute(AudacityProject &project, Track &track, bool exclusive)
"exclusive" mute means mute the chosen track and unmute all others.