Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
NoteTrackVZoomHandle Class Reference

#include <NoteTrackVZoomHandle.h>

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

Public Member Functions

 NoteTrackVZoomHandle (const std::shared_ptr< NoteTrack > &pTrack, const wxRect &rect, int y)
 
NoteTrackVZoomHandleoperator= (const NoteTrackVZoomHandle &)=default
 
virtual ~NoteTrackVZoomHandle ()
 
std::shared_ptr< const TrackFindTrack () const override
 
void Enter (bool forward, AudacityProject *) override
 
bool HandlesRightClick () override
 Whether the handle has any special right-button handling. More...
 
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
 
- 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< NoteTrackVZoomHandle > &holder, const wxMouseState &state, const std::shared_ptr< NoteTrack > &pTrack, const wxRect &rect)
 
- 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)
 

Private Member Functions

 NoteTrackVZoomHandle (const NoteTrackVZoomHandle &)
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
wxRect DrawingArea (TrackPanelDrawingContext &, const wxRect &rect, const wxRect &panelRect, unsigned iPass) override
 

Static Private Member Functions

static HitTestPreview HitPreview (const wxMouseState &state)
 

Private Attributes

std::weak_ptr< NoteTrackmpTrack
 
int mZoomStart
 
int mZoomEnd
 
wxRect mRect
 

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 19 of file NoteTrackVZoomHandle.h.

Constructor & Destructor Documentation

◆ NoteTrackVZoomHandle() [1/2]

NoteTrackVZoomHandle::NoteTrackVZoomHandle ( const NoteTrackVZoomHandle )
private

◆ NoteTrackVZoomHandle() [2/2]

NoteTrackVZoomHandle::NoteTrackVZoomHandle ( const std::shared_ptr< NoteTrack > &  pTrack,
const wxRect &  rect,
int  y 
)
explicit

Definition at line 52 of file NoteTrackVZoomHandle.cpp.

54 : mpTrack{ pTrack } , mZoomStart(y), mZoomEnd(y), mRect(rect)
55{
56}
std::weak_ptr< NoteTrack > mpTrack

◆ ~NoteTrackVZoomHandle()

NoteTrackVZoomHandle::~NoteTrackVZoomHandle ( )
virtual

Definition at line 96 of file NoteTrackVZoomHandle.cpp.

97{
98}

Member Function Documentation

◆ Cancel()

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

Implements UIHandle.

Definition at line 349 of file NoteTrackVZoomHandle.cpp.

350{
351 // Cancel is implemented! And there is no initial state to restore,
352 // so just return a code.
354}

References RefreshCode::RefreshAll.

◆ Click()

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

Implements UIHandle.

Definition at line 110 of file NoteTrackVZoomHandle.cpp.

112{
113 // change note track to zoom like audio track
114 // mpTrack->StartVScroll();
115
117}

References RefreshCode::RefreshNone.

◆ Drag()

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

Implements UIHandle.

Definition at line 119 of file NoteTrackVZoomHandle.cpp.

121{
122 using namespace RefreshCode;
123 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
124 if (!pTrack)
125 return Cancelled;
126
127 const wxMouseEvent &event = evt.event;
128 mZoomEnd = event.m_y;
130 // changed Note track to work like audio track
131 // pTrack->VScroll(mZoomStart, mZoomEnd);
132 return RefreshAll;
133 }
134 return RefreshNone;
135}
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1079
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
bool IsDragZooming(int zoomStart, int zoomEnd)

References Cancelled, TrackPanelMouseEvent::event, TrackList::Get(), anonymous_namespace{NoteTrackVZoomHandle.cpp}::IsDragZooming(), TrackList::Lock(), mpTrack, mZoomEnd, mZoomStart, RefreshCode::RefreshAll, and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ Draw()

void NoteTrackVZoomHandle::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 356 of file NoteTrackVZoomHandle.cpp.

359{
360 if ( iPass == TrackArtist::PassZooming ) {
361 if (!mpTrack.lock()) //? TrackList::Lock()
362 return;
363
366 context, rect, mZoomStart, mZoomEnd);
367 }
368}
static void DrawZooming(TrackPanelDrawingContext &context, const wxRect &rect, int zoomStart, int zoomEnd)

References ChannelVRulerControls::DrawZooming(), anonymous_namespace{NoteTrackVZoomHandle.cpp}::IsDragZooming(), mpTrack, mZoomEnd, mZoomStart, and TrackArtist::PassZooming.

Here is the call graph for this function:

◆ DrawingArea()

wxRect NoteTrackVZoomHandle::DrawingArea ( TrackPanelDrawingContext ,
const wxRect &  rect,
const wxRect &  panelRect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 370 of file NoteTrackVZoomHandle.cpp.

373{
374 if ( iPass == TrackArtist::PassZooming )
375 return ChannelVRulerControls::ZoomingArea(rect, panelRect);
376 else
377 return rect;
378}
static wxRect ZoomingArea(const wxRect &rect, const wxRect &panelRect)

References TrackArtist::PassZooming, and ChannelVRulerControls::ZoomingArea().

Here is the call graph for this function:

◆ Enter()

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

Reimplemented from UIHandle.

Definition at line 58 of file NoteTrackVZoomHandle.cpp.

59{
60#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
62#endif
63}
Result mChangeHighlight
Definition: UIHandle.h:152

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

◆ FindTrack()

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

Implements UIHandle.

Definition at line 100 of file NoteTrackVZoomHandle.cpp.

101{
102 return mpTrack.lock();
103}

References mpTrack.

◆ HandlesRightClick()

bool NoteTrackVZoomHandle::HandlesRightClick ( )
overridevirtual

Whether the handle has any special right-button handling.

If not, then Click() will not be called for right click. Default is always false

Reimplemented from UIHandle.

Definition at line 105 of file NoteTrackVZoomHandle.cpp.

106{
107 return true;
108}

◆ HitPreview()

HitTestPreview NoteTrackVZoomHandle::HitPreview ( const wxMouseState &  state)
staticprivate

Definition at line 65 of file NoteTrackVZoomHandle.cpp.

66{
67 static auto zoomInCursor =
68 ::MakeCursor(wxCURSOR_MAGNIFIER, ZoomInCursorXpm, 19, 15);
69 static auto zoomOutCursor =
70 ::MakeCursor(wxCURSOR_MAGNIFIER, ZoomOutCursorXpm, 19, 15);
71 static wxCursor arrowCursor{ wxCURSOR_ARROW };
72
73 const auto message =
74 XO("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.");
75
76 return {
77 message,
78 state.ShiftDown() ? &*zoomOutCursor : &*zoomInCursor
79 };
80}
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 MakeCursor(), and XO().

Referenced by Preview().

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

◆ HitTest()

UIHandlePtr NoteTrackVZoomHandle::HitTest ( std::weak_ptr< NoteTrackVZoomHandle > &  holder,
const wxMouseState &  state,
const std::shared_ptr< NoteTrack > &  pTrack,
const wxRect &  rect 
)
static

Definition at line 82 of file NoteTrackVZoomHandle.cpp.

86{
87 if (pTrack) {
88 auto result = std::make_shared<NoteTrackVZoomHandle>(
89 pTrack, rect, state.m_y);
90 result = AssignUIHandlePtr(holder, result);
91 return result;
92 }
93 return {};
94}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:164

References AssignUIHandlePtr().

Referenced by NoteTrackVRulerControls::HitTest().

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

◆ operator=()

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

◆ Preview()

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

Implements UIHandle.

Definition at line 137 of file NoteTrackVZoomHandle.cpp.

139{
140 return HitPreview(st.state);
141}
static HitTestPreview HitPreview(const wxMouseState &state)

References HitPreview(), and TrackPanelMouseState::state.

Here is the call graph for this function:

◆ Release()

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

Implements UIHandle.

Definition at line 283 of file NoteTrackVZoomHandle.cpp.

286{
287 using namespace RefreshCode;
288 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
289 if (!pTrack)
290 return RefreshNone;
291
292 const wxMouseEvent &event = evt.event;
293 //const bool shiftDown = event.ShiftDown();
294 const bool rightUp = event.RightUp();
295
296
297 // Popup menu...
298 if (
299 rightUp &&
300 !(event.ShiftDown() || event.CmdDown()))
301 {
302 InitMenuData data {
303 *pProject, pTrack.get(), mRect, RefreshNone, event.m_y
304 };
305
306 PopupMenuTable *const pTable =
308 auto pMenu = PopupMenuTable::BuildMenu(pTable, &data);
309
310 pMenu->Popup( *pParent, { event.m_x, event.m_y } );
311
312 return data.result;
313 }
314
315 if( event.GetId() == kCaptureLostEventId )
316 return RefreshAll;
317
318 NoteTrackDisplayData data{ *pTrack, evt.rect };
321 }
322 else if (event.ShiftDown() || event.RightUp()) {
323 if (event.ShiftDown() && event.RightUp()) {
324 auto &data = NoteTrackRange::Get(*pTrack);
325 auto oldBotNote = data.GetBottomNote();
326 auto oldTopNote = data.GetTopNote();
327 // Zoom out to show all notes
328 data.ZoomAllNotes(&pTrack->GetSeq());
329 if (data.GetBottomNote() == oldBotNote &&
330 data.GetTopNote() == oldTopNote) {
331 // However if we are already showing all notes, zoom out further
332 data.ZoomMaxExtent();
333 }
334 } else {
335 // Zoom out
336 data.ZoomOut(mZoomEnd);
337 }
338 }
339 else {
340 data.ZoomIn(mZoomEnd);
341 }
342
343 mZoomEnd = mZoomStart = 0;
344 ProjectHistory::Get( *pProject ).ModifyState(false);
345
346 return RefreshAll;
347}
const int kCaptureLostEventId
Temporary data used to display a note track.
void ZoomTo(int start, int end)
static NoteTrackRange & Get(const NoteTrack &track)
Allow mutative access to attached data of a const track.
static NoteTrackVRulerMenuTable & Instance()
static std::unique_ptr< PopupMenu > BuildMenu(PopupMenuTable *pTable, void *pUserData=NULL)
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)

References PopupMenuTable::BuildMenu(), ProjectHistory::Get(), TrackList::Get(), NoteTrackRange::Get(), NoteTrackVRulerMenuTable::Instance(), anonymous_namespace{NoteTrackVZoomHandle.cpp}::IsDragZooming(), kCaptureLostEventId, TrackList::Lock(), ProjectHistory::ModifyState(), RefreshCode::RefreshAll, RefreshCode::RefreshNone, and NoteTrackDisplayData::ZoomTo().

Here is the call graph for this function:

Member Data Documentation

◆ mpTrack

std::weak_ptr<NoteTrack> NoteTrackVZoomHandle::mpTrack
private

Definition at line 69 of file NoteTrackVZoomHandle.h.

Referenced by Drag(), Draw(), and FindTrack().

◆ mRect

wxRect NoteTrackVZoomHandle::mRect
private

Definition at line 72 of file NoteTrackVZoomHandle.h.

◆ mZoomEnd

int NoteTrackVZoomHandle::mZoomEnd
private

Definition at line 71 of file NoteTrackVZoomHandle.h.

Referenced by Drag(), and Draw().

◆ mZoomStart

int NoteTrackVZoomHandle::mZoomStart
private

Definition at line 71 of file NoteTrackVZoomHandle.h.

Referenced by Drag(), and Draw().


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