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 std::shared_ptr<const Channel> FindChannel() const override;
68
69 void Enter(bool forward, AudacityProject *) override;
70
72 (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
73
75 (const TrackPanelMouseEvent &event, AudacityProject *pProject) override;
76
78 (const TrackPanelMouseState &state, AudacityProject *pProject)
79 override;
80
82 (const TrackPanelMouseEvent &event, AudacityProject *pProject,
83 wxWindow *pParent) override;
84
85 Result Cancel(AudacityProject *pProject) override;
86
87 bool StopsOnKeystroke() override { return true; }
88
89 std::shared_ptr<LabelTrackHit> mpHit{};
90
92 (const LabelGlyphHandle &oldState, const LabelGlyphHandle &newState);
93
94private:
96 (LabelTrackHit &hit,
97 const wxMouseEvent & evt, const wxRect & r, const ZoomInfo &zoomInfo,
101 LabelTrackHit &hit,
102 const wxMouseEvent & evt, wxRect & r, const ZoomInfo &zoomInfo,
104
105 void MayAdjustLabel
106 ( LabelTrackHit &hit,
107 int iLabel, int iEdge, bool bAllowSwapping, double fNewTime);
108 void MayMoveLabel( int iLabel, int iEdge, double fNewTime);
109
110 std::shared_ptr<LabelTrack> mpLT {};
111 wxRect mRect {};
112
115};
116
117#endif
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
const auto project
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
std::shared_ptr< const Channel > FindChannel() const 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:39
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.