Audacity 3.2.0
LabelGlyphHandle.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5LabelGlyphHandle.h
6
7Paul Licameli split from TrackPanel.cpp
8
9**********************************************************************/
10
11#ifndef __AUDACITY_LABEL_GLYPH_HANDLE__
12#define __AUDACITY_LABEL_GLYPH_HANDLE__
13
15#include "Observer.h"
16
17class wxMouseState;
18class LabelTrack;
19struct LabelTrackEvent;
21class ZoomInfo;
22
34{
35 LabelTrackHit( const std::shared_ptr<LabelTrack> &pLT );
37
38 int mEdge{};
39 //This one is to distinguish ranged label from point label
40 int mMouseOverLabel{ -1 };
44
45 std::shared_ptr<LabelTrack> mpLT {};
46
48 void OnLabelPermuted( const LabelTrackEvent &e );
49};
50
52{
53public:
54 explicit LabelGlyphHandle
55 (const std::shared_ptr<LabelTrack> &pLT,
56 const wxRect &rect, const std::shared_ptr<LabelTrackHit> &pHit);
57
59
60 static UIHandlePtr HitTest
61 (std::weak_ptr<LabelGlyphHandle> &holder,
62 const wxMouseState &state,
63 const std::shared_ptr<LabelTrack> &pLT, const wxRect &rect);
64
65 virtual ~LabelGlyphHandle();
66
67 void Enter(bool forward, AudacityProject *) override;
68
70 (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
71
73 (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
74
76 (const TrackPanelMouseState &state, AudacityProject *pProject)
77 override;
78
80 (const TrackPanelMouseEvent &event, AudacityProject *pProject,
81 wxWindow *pParent) override;
82
83 Result Cancel(AudacityProject *pProject) override;
84
85 bool StopsOnKeystroke() override { return true; }
86
87 std::shared_ptr<LabelTrackHit> mpHit{};
88
90 (const LabelGlyphHandle &oldState, const LabelGlyphHandle &newState);
91
92private:
94 (LabelTrackHit &hit,
95 const wxMouseEvent & evt, const wxRect & r, const ZoomInfo &zoomInfo,
98 (AudacityProject &project,
99 LabelTrackHit &hit,
100 const wxMouseEvent & evt, wxRect & r, const ZoomInfo &zoomInfo,
102
103 void MayAdjustLabel
104 ( LabelTrackHit &hit,
105 int iLabel, int iEdge, bool bAllowSwapping, double fNewTime);
106 void MayMoveLabel( int iLabel, int iEdge, double fNewTime);
107
108 std::shared_ptr<LabelTrack> mpLT {};
109 wxRect mRect {};
110
113};
114
115#endif
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Result Cancel(AudacityProject *pProject) override
void Enter(bool forward, AudacityProject *) override
std::shared_ptr< LabelTrackHit > mpHit
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
bool StopsOnKeystroke() override
void MayAdjustLabel(LabelTrackHit &hit, int iLabel, int iEdge, bool bAllowSwapping, double fNewTime)
bool HandleGlyphDragRelease(AudacityProject &project, LabelTrackHit &hit, const wxMouseEvent &evt, wxRect &r, const ZoomInfo &zoomInfo, NotifyingSelectedRegion &newSel)
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
std::shared_ptr< LabelTrack > mpLT
static UIHandlePtr HitTest(std::weak_ptr< LabelGlyphHandle > &holder, const wxMouseState &state, const std::shared_ptr< LabelTrack > &pLT, const wxRect &rect)
static UIHandle::Result NeedChangeHighlight(const LabelGlyphHandle &oldState, const LabelGlyphHandle &newState)
void MayMoveLabel(int iLabel, int iEdge, double fNewTime)
void HandleGlyphClick(LabelTrackHit &hit, const wxMouseEvent &evt, const wxRect &r, const ZoomInfo &zoomInfo, NotifyingSelectedRegion &newSel)
LabelGlyphHandle(const std::shared_ptr< LabelTrack > &pLT, const wxRect &rect, const std::shared_ptr< LabelTrackHit > &pHit)
LabelGlyphHandle & operator=(const LabelGlyphHandle &)=default
HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject) override
int mxMouseDisplacement
Displacement of mouse cursor from the centre being dragged.
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:87
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
unsigned Result
Definition: UIHandle.h:38
int mMouseOverLabelRight
Keeps track of which left label the mouse is currently over.
LabelTrackHit(const std::shared_ptr< LabelTrack > &pLT)
int mMouseOverLabelLeft
Keeps track of which (ranged) label the mouse is currently over.
std::shared_ptr< LabelTrack > mpLT
void OnLabelPermuted(const LabelTrackEvent &e)
Observer::Subscription mSubscription
bool mIsAdjustingLabel
Keeps track of which right label the mouse is currently over.