Audacity 3.2.0
WaveTrackAffordanceHandle.cpp
Go to the documentation of this file.
1/*!********************************************************************
2*
3 Audacity: A Digital Audio Editor
4
5 @file WaveTrackAffordanceHandle.cpp
6
7 Vitaly Sverchinsky
8
9 **********************************************************************/
10
13#include "WaveChannelView.h"
14#include "ViewInfo.h"
15
16#include "../../../../RefreshCode.h"
17#include "../../../../TrackPanelMouseEvent.h"
18#include "PitchAndSpeedDialog.h"
19#include "ProjectHistory.h"
20#include "WaveClip.h"
21
22#include <wx/event.h>
23
24WaveTrackAffordanceHandle::WaveTrackAffordanceHandle(const std::shared_ptr<Track>& track, const std::shared_ptr<ClipTimes>& target)
25 : AffordanceHandle(track), mTarget(target)
26{ }
27
29{
30 // We only care about left clicks here,
31 // however we need to intercept Release events for right clicks later
32 if (event.event.GetButton() != wxMOUSE_BTN_LEFT)
34
36
38 {
39 auto affordanceControl = std::dynamic_pointer_cast<WaveTrackAffordanceControls>(event.pCell);
40
41 if (affordanceControl)
42 {
43 result |= affordanceControl->OnAffordanceClick(event, project);
44 if (!event.event.GetSkipped())//event is "consumed"
45 return result | RefreshCode::Cancelled;
46 event.event.Skip(false);
47 }
48 }
49 return result | AffordanceHandle::Click(event, project);
50}
51
53{
54 auto& viewInfo = ViewInfo::Get(*project);
55 viewInfo.selectedRegion.setTimes(mTarget->GetPlayStartTime(), mTarget->GetPlayEndTime());
56
57 ProjectHistory::Get(*project).ModifyState(false);
58
60}
61
63{
64 return true;
65}
66
68{
69 auto result = AffordanceHandle::Release(event, pProject, pParent);
70 PitchAndSpeedDialog::Get(*pProject).TryRetarget(event);
71
72 if (event.event.RightUp())
73 result |= event.pCell->DoContextMenu(event.rect, pParent, nullptr, pProject);
74
75 return result;
76}
const auto project
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
Result Click(const TrackPanelMouseEvent &evt, AudacityProject *pProject) override
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 PitchAndSpeedDialog & Get(AudacityProject &project)
void TryRetarget(const TrackPanelMouseEvent &event)
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
unsigned Result
Definition: UIHandle.h:40
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
static bool ClipDetailsVisible(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
bool HandlesRightClick() override
Whether the handle has any special right-button handling.
std::shared_ptr< ClipTimes > mTarget
WaveTrackAffordanceHandle(const std::shared_ptr< Track > &track, const std::shared_ptr< ClipTimes > &target)
Result Click(const TrackPanelMouseEvent &event, AudacityProject *project) override
UIHandle::Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
UIHandle::Result SelectAt(const TrackPanelMouseEvent &event, AudacityProject *project) override
std::shared_ptr< TrackPanelCell > pCell