17#include "../../../../HitTestResult.h"
20#include "../../../../RefreshCode.h"
21#include "../../../../Snap.h"
22#include "../../../../TrackPanelMouseEvent.h"
26#include "../../../../../images/Cursors.h"
31 , mLocation{ location }
37#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
44 static auto disabledCursor =
45 ::MakeCursor(wxCURSOR_NO_ENTRY, DisabledCursorXpm, 16, 16);
46 static wxCursor arrowCursor{ wxCURSOR_ARROW };
49 ?
XO(
"Left-Click to expand, Right-Click to remove")
50 :
XO(
"Left-Click to merge clips")),
60 const double tolerance = 0.5 / track->
GetRate();
64 fabs(time - loc.pos) < tolerance)
73 const wxRect &rect,
const wxMouseState &state,
79 if (x >= 0 && x < rect.width)
83 locRect.x = (int)(rect.x + x) - locRect.width / 2;
85 locRect.height = rect.height;
86 if (locRect.Contains(state.m_x, state.m_y))
100(std::weak_ptr<CutlineHandle> &holder,
101 const wxMouseState &state,
const wxRect &rect,
103 const std::shared_ptr<WaveTrack> &pTrack)
110 if (!
IsOverCutline(viewInfo, pTrack.get(), rect, state, &location))
113 auto result = std::make_shared<CutlineHandle>( pTrack, location );
135 const wxMouseEvent &
event = evt.
event;
150 if (event.LeftDown())
156 mEndTime = viewInfo.selectedRegion.t1();
159 double cutlineStart = 0, cutlineEnd = 0;
160 double *pCutlineStart = &cutlineStart, *pCutlineEnd = &cutlineEnd;
164 channel->ExpandCutLine(
166 if ( channel ==
mpTrack.get() )
167 pCutlineStart = pCutlineEnd =
nullptr;
170 viewInfo.selectedRegion.setTimes(cutlineStart, cutlineEnd);
182 location.clipidx1, location.clipidx2);
189 else if (event.RightDown())
191 bool removed =
false;
194 removed = channel->RemoveCutLine(
mLocation.
pos) || removed;
std::shared_ptr< UIHandle > UIHandlePtr
const int kPixelTolerance
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
CutlineHandle(const CutlineHandle &)=delete
static HitTestPreview HitPreview(bool cutline, bool unsafe)
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
WaveTrackLocation mLocation
HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject) override
std::shared_ptr< WaveTrack > mpTrack
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
void Enter(bool forward, AudacityProject *) override
static UIHandlePtr HitTest(std::weak_ptr< CutlineHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveTrack > &pTrack)
bool HandlesRightClick() override
Whether the handle has any special right-button handling.
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
Result Cancel(AudacityProject *pProject) override
bool setTimes(double t0, double t1)
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
NotifyingSelectedRegion selectedRegion
static ViewInfo & Get(AudacityProject &project)
A Track that contains audio waveform data.
double GetRate() const override
const std::vector< Location > & Get() const
int64 TimeToPosition(double time, int64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Namespace containing an enum 'what to do on a refresh?'.
int FindMergeLine(WaveTrack *track, double time)
bool IsOverCutline(const ViewInfo &viewInfo, WaveTrack *track, const wxRect &rect, const wxMouseState &state, WaveTrackLocation *pmLocation)