Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
LabelGlyphHandle Class Referencefinal

#include <LabelGlyphHandle.h>

Inheritance diagram for LabelGlyphHandle:
[legend]
Collaboration diagram for LabelGlyphHandle:
[legend]

Public Member Functions

 LabelGlyphHandle (const std::shared_ptr< LabelTrack > &pLT, const wxRect &rect, const std::shared_ptr< LabelTrackHit > &pHit)
 
LabelGlyphHandleoperator= (const LabelGlyphHandle &)=default
 
virtual ~LabelGlyphHandle ()
 
std::shared_ptr< const TrackFindTrack () const override
 
void Enter (bool forward, AudacityProject *) override
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
Result Cancel (AudacityProject *pProject) override
 
bool StopsOnKeystroke () override
 
- Public Member Functions inherited from LabelDefaultClickHandle
 LabelDefaultClickHandle ()
 
virtual ~LabelDefaultClickHandle ()
 
LabelDefaultClickHandleoperator= (const LabelDefaultClickHandle &)=default
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
Result Cancel (AudacityProject *pProject) override
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
virtual void Enter (bool forward, AudacityProject *pProject)
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape (AudacityProject *pProject) const
 
virtual bool Escape (AudacityProject *pProject)
 
virtual bool HandlesRightClick ()
 Whether the handle has any special right-button handling. More...
 
virtual Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject)=0
 
virtual Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
 
virtual Result Cancel (AudacityProject *pProject)=0
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
virtual std::shared_ptr< const TrackFindTrack () const =0
 
virtual bool IsDragging () const
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

Static Public Member Functions

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)
 
- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 
static std::shared_ptr< const TrackTrackFromChannel (const std::shared_ptr< const Channel > &pChannel)
 A frequent convenience in the definition of UIHandles. More...
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 

Public Attributes

std::shared_ptr< LabelTrackHitmpHit {}
 

Private Member Functions

void HandleGlyphClick (LabelTrackHit &hit, const wxMouseEvent &evt, const wxRect &r, const ZoomInfo &zoomInfo, NotifyingSelectedRegion &newSel)
 
bool HandleGlyphDragRelease (AudacityProject &project, LabelTrackHit &hit, const wxMouseEvent &evt, wxRect &r, const ZoomInfo &zoomInfo, NotifyingSelectedRegion &newSel)
 
void MayAdjustLabel (LabelTrackHit &hit, int iLabel, int iEdge, bool bAllowSwapping, double fNewTime)
 
void MayMoveLabel (int iLabel, int iEdge, double fNewTime)
 

Private Attributes

std::shared_ptr< LabelTrackmpLT {}
 
wxRect mRect {}
 
int mxMouseDisplacement
 Displacement of mouse cursor from the centre being dragged. More...
 

Additional Inherited Members

- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 51 of file LabelGlyphHandle.h.

Constructor & Destructor Documentation

◆ LabelGlyphHandle()

LabelGlyphHandle::LabelGlyphHandle ( const std::shared_ptr< LabelTrack > &  pLT,
const wxRect &  rect,
const std::shared_ptr< LabelTrackHit > &  pHit 
)
explicit

Definition at line 66 of file LabelGlyphHandle.cpp.

69 : mpHit{ pHit }
70 , mpLT{ pLT }
71 , mRect{ rect }
72{
73}
std::shared_ptr< LabelTrackHit > mpHit
std::shared_ptr< LabelTrack > mpLT

◆ ~LabelGlyphHandle()

LabelGlyphHandle::~LabelGlyphHandle ( )
virtual

Definition at line 113 of file LabelGlyphHandle.cpp.

114{
115}

Member Function Documentation

◆ Cancel()

UIHandle::Result LabelGlyphHandle::Cancel ( AudacityProject pProject)
overridevirtual

Reimplemented from LabelDefaultClickHandle.

Definition at line 474 of file LabelGlyphHandle.cpp.

475{
476 ProjectHistory::Get( *pProject ).RollbackState();
477 auto result = LabelDefaultClickHandle::Cancel( pProject );
478 return result | RefreshCode::RefreshAll;
479}
Result Cancel(AudacityProject *pProject) override
static ProjectHistory & Get(AudacityProject &project)

References LabelDefaultClickHandle::Cancel(), ProjectHistory::Get(), RefreshCode::RefreshAll, and ProjectHistory::RollbackState().

Here is the call graph for this function:

◆ Click()

UIHandle::Result LabelGlyphHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Reimplemented from LabelDefaultClickHandle.

Definition at line 201 of file LabelGlyphHandle.cpp.

203{
204 auto result = LabelDefaultClickHandle::Click( evt, pProject );
205
206 const wxMouseEvent &event = evt.event;
207 auto& selectionState = SelectionState::Get(*pProject);
208 auto& tracks = TrackList::Get(*pProject);
209
210 auto &viewInfo = ViewInfo::Get( *pProject );
212 *mpHit, event, mRect, viewInfo, viewInfo.selectedRegion);
213
214 if (! mpHit->mIsAdjustingLabel )
215 {
216 // The positive hit test should have ensured otherwise
217 //wxASSERT(false);
218 result |= RefreshCode::Cancelled;
219 }
220 else
221 // redraw the track.
222 result |= RefreshCode::RefreshCell;
223
224 return result;
225}
const auto tracks
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
void HandleGlyphClick(LabelTrackHit &hit, const wxMouseEvent &evt, const wxRect &r, const ZoomInfo &zoomInfo, NotifyingSelectedRegion &newSel)
static SelectionState & Get(AudacityProject &project)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References RefreshCode::Cancelled, LabelDefaultClickHandle::Click(), TrackPanelMouseEvent::event, ViewInfo::Get(), SelectionState::Get(), TrackList::Get(), HandleGlyphClick(), mpHit, mRect, RefreshCode::RefreshCell, and tracks.

Here is the call graph for this function:

◆ Drag()

UIHandle::Result LabelGlyphHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Reimplemented from LabelDefaultClickHandle.

Definition at line 419 of file LabelGlyphHandle.cpp.

421{
422 auto result = LabelDefaultClickHandle::Drag( evt, pProject );
423
424 const wxMouseEvent &event = evt.event;
425 auto &viewInfo = ViewInfo::Get( *pProject );
427 *pProject, *mpHit, event, mRect, viewInfo, viewInfo.selectedRegion);
428
429 // Refresh all so that the change of selection is redrawn in all tracks
431}
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
bool HandleGlyphDragRelease(AudacityProject &project, LabelTrackHit &hit, const wxMouseEvent &evt, wxRect &r, const ZoomInfo &zoomInfo, NotifyingSelectedRegion &newSel)

References LabelDefaultClickHandle::Drag(), RefreshCode::DrawOverlays, TrackPanelMouseEvent::event, ViewInfo::Get(), HandleGlyphDragRelease(), mpHit, mRect, and RefreshCode::RefreshAll.

Here is the call graph for this function:

◆ Enter()

void LabelGlyphHandle::Enter ( bool  forward,
AudacityProject  
)
overridevirtual

Reimplemented from UIHandle.

Definition at line 75 of file LabelGlyphHandle.cpp.

References UIHandle::mChangeHighlight, and RefreshCode::RefreshCell.

◆ FindTrack()

std::shared_ptr< const Track > LabelGlyphHandle::FindTrack ( ) const
overridevirtual
Returns
pointer to associated track, if any

Implements UIHandle.

Definition at line 117 of file LabelGlyphHandle.cpp.

118{
119 return mpLT;
120}

References mpLT.

◆ HandleGlyphClick()

void LabelGlyphHandle::HandleGlyphClick ( LabelTrackHit hit,
const wxMouseEvent &  evt,
const wxRect &  r,
const ZoomInfo zoomInfo,
NotifyingSelectedRegion newSel 
)
private

Definition at line 122 of file LabelGlyphHandle.cpp.

126{
127 if (evt.ButtonDown())
128 {
129 //OverGlyph sets mMouseOverLabel to be the chosen label.
130 const auto pTrack = mpLT;
131 LabelTrackView::OverGlyph(*pTrack, hit, evt.m_x, evt.m_y);
132
133 hit.mIsAdjustingLabel = evt.Button(wxMOUSE_BTN_LEFT) &&
134 ( hit.mEdge & 3 ) != 0;
135
136 if (hit.mIsAdjustingLabel)
137 {
138 auto& view = LabelTrackView::Get(*pTrack);
139 view.ResetTextSelection();
140
141 double t = 0.0;
142
143 // When we start dragging the label(s) we don't want them to jump.
144 // so we calculate the displacement of the mouse from the drag center
145 // and use that in subsequent dragging calculations. The mouse stays
146 // at the same relative displacement throughout dragging.
147
148 // However, if two label's edges are being dragged
149 // then the displacement is relative to the initial average
150 // position of them, and in that case there can be a jump of at most
151 // a few pixels to bring the two label boundaries to exactly the same
152 // position when we start dragging.
153
154 // Dragging of three label edges at the same time is not supported (yet).
155
156 const auto &mLabels = pTrack->GetLabels();
157 if( ( hit.mMouseOverLabelRight >= 0 ) &&
158 ( hit.mMouseOverLabelLeft >= 0 )
159 )
160 {
161 t = (mLabels[ hit.mMouseOverLabelRight ].getT1() +
162 mLabels[ hit.mMouseOverLabelLeft ].getT0()) / 2.0f;
163
164 // If we're moving two edges of same label then it's a move
165 // (label is shrunk to zero and size of zero is preserved)
166 // If we're on a boundary between two different labels,
167 // then it's an adjust.
168 // In both cases the two points coalesce.
169 //
170 // NOTE: seems that it's not necessary that hitting the both
171 // left and right handles mean that we're dealing with a point,
172 // but the range will be turned into a point on click
173 bool isPointLabel = hit.mMouseOverLabelLeft == hit.mMouseOverLabelRight;
174 // Except! We don't coalesce if both ends are from the same label and
175 // we have deliberately chosen to preserve length, by holding shift down.
176 if (!(isPointLabel && evt.ShiftDown()))
177 {
178 MayAdjustLabel(hit, hit.mMouseOverLabelLeft, -1, false, t);
179 MayAdjustLabel(hit, hit.mMouseOverLabelRight, 1, false, t);
180 wxASSERT(mLabels[hit.mMouseOverLabelRight].getT1() ==
181 mLabels[hit.mMouseOverLabelLeft].getT0());
182 }
183 }
184 else if( hit.mMouseOverLabelRight >=0)
185 {
186 t = mLabels[ hit.mMouseOverLabelRight ].getT1();
187 }
188 else if( hit.mMouseOverLabelLeft >=0)
189 {
190 t = mLabels[ hit.mMouseOverLabelLeft ].getT0();
191 }
192 else if (hit.mMouseOverLabel >= 0)
193 {
194 t = mLabels[hit.mMouseOverLabel].getT0();
195 }
196 mxMouseDisplacement = zoomInfo.TimeToPosition(t, r.x) - evt.m_x;
197 }
198 }
199}
void MayAdjustLabel(LabelTrackHit &hit, int iLabel, int iEdge, bool bAllowSwapping, double fNewTime)
int mxMouseDisplacement
Displacement of mouse cursor from the centre being dragged.
static LabelTrackView & Get(LabelTrack &)
static void OverGlyph(const LabelTrack &track, LabelTrackHit &hit, int x, int y)
int64 TimeToPosition(double time, int64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ZoomInfo.cpp:44
int mMouseOverLabelRight
Keeps track of which left label the mouse is currently over.
int mMouseOverLabelLeft
Keeps track of which (ranged) label the mouse is currently over.
bool mIsAdjustingLabel
Keeps track of which right label the mouse is currently over.

References LabelTrackView::Get(), MayAdjustLabel(), LabelTrackHit::mEdge, LabelTrackHit::mIsAdjustingLabel, LabelTrackHit::mMouseOverLabel, LabelTrackHit::mMouseOverLabelLeft, LabelTrackHit::mMouseOverLabelRight, mpLT, mxMouseDisplacement, LabelTrackView::OverGlyph(), and ZoomInfo::TimeToPosition().

Referenced by Click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleGlyphDragRelease()

bool LabelGlyphHandle::HandleGlyphDragRelease ( AudacityProject project,
LabelTrackHit hit,
const wxMouseEvent &  evt,
wxRect &  r,
const ZoomInfo zoomInfo,
NotifyingSelectedRegion newSel 
)
private

Definition at line 291 of file LabelGlyphHandle.cpp.

296{
297 const auto pTrack = mpLT;
298 const auto &mLabels = pTrack->GetLabels();
299 if(evt.LeftUp())
300 {
301 bool updated = false;
302 if( hit.mMouseOverLabelLeft >= 0 ) {
303 auto labelStruct = mLabels[ hit.mMouseOverLabelLeft ];
304 updated |= labelStruct.updated;
305 labelStruct.updated = false;
306 pTrack->SetLabel( hit.mMouseOverLabelLeft, labelStruct );
307 }
308 if( hit.mMouseOverLabelRight >= 0 ) {
309 auto labelStruct = mLabels[ hit.mMouseOverLabelRight ];
310 updated |= labelStruct.updated;
311 labelStruct.updated = false;
312 pTrack->SetLabel( hit.mMouseOverLabelRight, labelStruct );
313 }
314
315 if (hit.mMouseOverLabel >= 0)
316 {
317 auto labelStruct = mLabels[hit.mMouseOverLabel];
318 if (!labelStruct.updated)
319 {
320 //happens on click over bar between handles (without moving a cursor)
321 newSel = labelStruct.selectedRegion;
322
323 // IF the user clicked a label, THEN select all other tracks by Label
324 // do nothing if at least one other track is selected
325 auto& selectionState = SelectionState::Get(project);
327
328 bool done = tracks.Selected().any_of(
329 [&](const Track* track) { return track != static_cast<Track*>(pTrack.get()); }
330 );
331
332 if (!done) {
333 //otherwise, select all tracks
334 for (auto t : tracks)
335 selectionState.SelectTrack(*t, true, true);
336 }
337
338 // Do this after, for its effect on TrackPanel's memory of last selected
339 // track (which affects shift-click actions)
340 selectionState.SelectTrack(*pTrack, true, true);
341
342 // PRL: bug1659 -- make selection change undo correctly
344
345 auto& view = LabelTrackView::Get(*pTrack);
346 view.SetNavigationIndex(hit.mMouseOverLabel);
347 }
348 else
349 {
350 labelStruct.updated = false;
351 pTrack->SetLabel(hit.mMouseOverLabel, labelStruct);
352 updated = true;
353 }
354 }
355
356 hit.mIsAdjustingLabel = false;
357 hit.mMouseOverLabelLeft = -1;
358 hit.mMouseOverLabelRight = -1;
359 hit.mMouseOverLabel = -1;
360 return updated;
361 }
362
363 if(evt.Dragging())
364 {
365 //If we are currently adjusting a label,
366 //just reset its value and redraw.
367 // LL: Constrain to inside track rectangle for now. Should be changed
368 // to allow scrolling while dragging labels
369 int x = Constrain( evt.m_x + mxMouseDisplacement - r.x, 0, r.width);
370
371 double fNewX = zoomInfo.PositionToTime(x, 0);
372 // Moving the whole ranged label(s)
373 if (hit.mMouseOverLabel != -1)
374 {
375 if (evt.ShiftDown())
376 {
377 auto dt = fNewX - mLabels[hit.mMouseOverLabel].getT0();
378 for (auto i = 0, count = static_cast<int>(mLabels.size()); i < count; ++i)
379 MayMoveLabel(i, -1, mLabels[i].getT0() + dt);
380 }
381 else
382 MayMoveLabel(hit.mMouseOverLabel, -1, fNewX);
383 }
384 // If we're on the 'dot' and nowe're moving,
385 // Though shift-down inverts that.
386 // and if both edges the same, then we're always moving the label.
387 else if((hit.mMouseOverLabelLeft == hit.mMouseOverLabelRight) || evt.ShiftDown())
388 {
389 MayMoveLabel( hit.mMouseOverLabelLeft, -1, fNewX );
390 MayMoveLabel( hit.mMouseOverLabelRight, +1, fNewX );
391 }
392 else
393 {
394 // If exactly one edge is selected we allow swapping
395 bool bAllowSwapping =
396 (hit.mMouseOverLabelLeft >= 0) !=
397 (hit.mMouseOverLabelRight >= 0);
398 MayAdjustLabel( hit, hit.mMouseOverLabelLeft, -1, bAllowSwapping, fNewX );
399 MayAdjustLabel( hit, hit.mMouseOverLabelRight, +1, bAllowSwapping, fNewX );
400 }
401
402 const auto &view = LabelTrackView::Get( *pTrack );
403 auto navigationIndex = view.GetNavigationIndex(project);
404 if(navigationIndex != -1 &&
405 (navigationIndex == hit.mMouseOverLabel ||
406 navigationIndex == hit.mMouseOverLabelLeft ||
407 navigationIndex == hit.mMouseOverLabelRight))
408 {
409 //Set the selection region to be equal to
410 //the NEW size of the label.
411 newSel = mLabels[navigationIndex].selectedRegion;
412 }
413 pTrack->SortLabels();
414 }
415
416 return false;
417}
static int Constrain(int value, int min, int max)
const auto project
void MayMoveLabel(int iLabel, int iEdge, double fNewTime)
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:34

References Constrain(), ProjectAudioIO::Get(), SelectionState::Get(), TrackList::Get(), LabelTrackView::Get(), ProjectAudioIO::IsAudioActive(), MayAdjustLabel(), MayMoveLabel(), LabelTrackHit::mIsAdjustingLabel, LabelTrackHit::mMouseOverLabel, LabelTrackHit::mMouseOverLabelLeft, LabelTrackHit::mMouseOverLabelRight, mpLT, mxMouseDisplacement, ZoomInfo::PositionToTime(), project, and tracks.

Referenced by Drag(), and Release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HitTest()

UIHandlePtr LabelGlyphHandle::HitTest ( std::weak_ptr< LabelGlyphHandle > &  holder,
const wxMouseState &  state,
const std::shared_ptr< LabelTrack > &  pLT,
const wxRect &  rect 
)
static

Definition at line 89 of file LabelGlyphHandle.cpp.

93{
94 // Allocate on heap because there are pointers to it when it is bound as
95 // an event sink, therefore it's not copyable; make it shared so
96 // LabelGlyphHandle can be copyable:
97 auto pHit = std::make_shared<LabelTrackHit>( pLT );
98
99 LabelTrackView::OverGlyph(*pLT, *pHit, state.m_x, state.m_y);
100
101 // IF edge!=0 THEN we've set the cursor and we're done.
102 // signal this by setting the tip.
103 if ( pHit->mEdge & 3 )
104 {
105 auto result = std::make_shared<LabelGlyphHandle>( pLT, rect, pHit );
106 result = AssignUIHandlePtr(holder, result);
107 return result;
108 }
109
110 return {};
111}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:164

References AssignUIHandlePtr(), and LabelTrackView::OverGlyph().

Referenced by LabelTrackView::DetailedHitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MayAdjustLabel()

void LabelGlyphHandle::MayAdjustLabel ( LabelTrackHit hit,
int  iLabel,
int  iEdge,
bool  bAllowSwapping,
double  fNewTime 
)
private

If the index is for a real label, adjust its left or right boundary. @iLabel - index of label, -1 for none. @iEdge - which edge is requested to move, -1 for left +1 for right. @bAllowSwapping - if we can switch which edge is being dragged. fNewTime - the NEW time for this edge of the label.

Definition at line 232 of file LabelGlyphHandle.cpp.

234{
235 if( iLabel < 0 )
236 return;
237
238 const auto pTrack = mpLT;
239 const auto &mLabels = pTrack->GetLabels();
240 auto labelStruct = mLabels[ iLabel ];
241
242 // Adjust the requested edge.
243 bool flipped = labelStruct.AdjustEdge( iEdge, fNewTime );
244 // If the edges did not swap, then we are done.
245 if( ! flipped ) {
246 pTrack->SetLabel( iLabel, labelStruct );
247 return;
248 }
249
250 // If swapping's not allowed we must also move the edge
251 // we didn't move. Then we're done.
252 if( !bAllowSwapping )
253 {
254 labelStruct.AdjustEdge( -iEdge, fNewTime );
255 pTrack->SetLabel( iLabel, labelStruct );
256 return;
257 }
258
259 pTrack->SetLabel( iLabel, labelStruct );
260
261 // Swap our record of what we are dragging.
263}
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:634

References LabelTrackHit::mMouseOverLabelLeft, LabelTrackHit::mMouseOverLabelRight, mpLT, and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by HandleGlyphClick(), and HandleGlyphDragRelease().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MayMoveLabel()

void LabelGlyphHandle::MayMoveLabel ( int  iLabel,
int  iEdge,
double  fNewTime 
)
private

Definition at line 266 of file LabelGlyphHandle.cpp.

267{
268 if( iLabel < 0 )
269 return;
270
271 const auto pTrack = mpLT;
272 const auto &mLabels = pTrack->GetLabels();
273 auto labelStruct = mLabels[ iLabel ];
274 labelStruct.MoveLabel( iEdge, fNewTime );
275 pTrack->SetLabel( iLabel, labelStruct );
276}

References mpLT.

Referenced by HandleGlyphDragRelease().

Here is the caller graph for this function:

◆ NeedChangeHighlight()

UIHandle::Result LabelGlyphHandle::NeedChangeHighlight ( const LabelGlyphHandle oldState,
const LabelGlyphHandle newState 
)
static

Definition at line 80 of file LabelGlyphHandle.cpp.

82{
83 if (oldState.mpHit->mEdge != newState.mpHit->mEdge)
84 // pointer moves between the circle and the chevron
86 return 0;
87}

References mpHit, and RefreshCode::RefreshCell.

◆ operator=()

LabelGlyphHandle & LabelGlyphHandle::operator= ( const LabelGlyphHandle )
default

◆ Preview()

HitTestPreview LabelGlyphHandle::Preview ( const TrackPanelMouseState state,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 433 of file LabelGlyphHandle.cpp.

435{
436 static wxCursor arrowCursor{ wxCURSOR_ARROW };
437 static auto handOpenCursor =
438 MakeCursor(wxCURSOR_HAND, RearrangeCursorXpm, 16, 16);
439 static auto handClosedCursor =
440 MakeCursor(wxCURSOR_HAND, RearrangingCursorXpm, 16, 16);
441
442 if (mpHit->mMouseOverLabel != -1)
443 {
444 return {
445 XO("Drag label. Hold shift and drag to move all labels on the same track."),
446 mpHit->mIsAdjustingLabel ? &*handClosedCursor : &*handOpenCursor
447 };
448 }
449 else if ((mpHit->mEdge & 4) != 0)
450 return { XO("Drag one or more label boundaries."), &arrowCursor };
451 else
452 return { XO("Drag label boundary."), &arrowCursor };
453}
static std::unique_ptr< wxCursor > handOpenCursor
XO("Cut/Copy/Paste")
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:189

References handOpenCursor, MakeCursor(), mpHit, and XO().

Here is the call graph for this function:

◆ Release()

UIHandle::Result LabelGlyphHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overridevirtual

Reimplemented from LabelDefaultClickHandle.

Definition at line 455 of file LabelGlyphHandle.cpp.

458{
459 auto result = LabelDefaultClickHandle::Release( evt, pProject, pParent );
460
461 const wxMouseEvent &event = evt.event;
462 auto &viewInfo = ViewInfo::Get( *pProject );
464 *pProject, *mpHit, event, mRect, viewInfo, viewInfo.selectedRegion)) {
465 ProjectHistory::Get( *pProject ).PushState(XO("Modified Label"),
466 XO("Label Edit"),
468 }
469
470 // Refresh all so that the change of selection is redrawn in all tracks
472}
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)

References CONSOLIDATE, RefreshCode::DrawOverlays, TrackPanelMouseEvent::event, ProjectHistory::Get(), ViewInfo::Get(), HandleGlyphDragRelease(), mpHit, mRect, ProjectHistory::PushState(), RefreshCode::RefreshAll, LabelDefaultClickHandle::Release(), and XO().

Here is the call graph for this function:

◆ StopsOnKeystroke()

bool LabelGlyphHandle::StopsOnKeystroke ( )
inlineoverridevirtual

Reimplemented from UIHandle.

Definition at line 87 of file LabelGlyphHandle.h.

87{ return true; }

Member Data Documentation

◆ mpHit

std::shared_ptr<LabelTrackHit> LabelGlyphHandle::mpHit {}

◆ mpLT

std::shared_ptr<LabelTrack> LabelGlyphHandle::mpLT {}
private

◆ mRect

wxRect LabelGlyphHandle::mRect {}
private

Definition at line 111 of file LabelGlyphHandle.h.

Referenced by Click(), Drag(), and Release().

◆ mxMouseDisplacement

int LabelGlyphHandle::mxMouseDisplacement
private

Displacement of mouse cursor from the centre being dragged.

Definition at line 114 of file LabelGlyphHandle.h.

Referenced by HandleGlyphClick(), and HandleGlyphDragRelease().


The documentation for this class was generated from the following files: