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 ChannelFindChannel () 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 ChannelFindChannel () 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 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 54 of file NoteTrackVZoomHandle.cpp.

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

◆ ~NoteTrackVZoomHandle()

NoteTrackVZoomHandle::~NoteTrackVZoomHandle ( )
virtual

Definition at line 103 of file NoteTrackVZoomHandle.cpp.

104{
105}

Member Function Documentation

◆ Cancel()

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

Implements UIHandle.

Definition at line 364 of file NoteTrackVZoomHandle.cpp.

365{
366 // Cancel is implemented! And there is no initial state to restore,
367 // so just return a code.
369}

References RefreshCode::RefreshAll.

◆ Click()

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

Implements UIHandle.

Definition at line 117 of file NoteTrackVZoomHandle.cpp.

119{
120 // change note track to zoom like audio track
121 // mpTrack->StartVScroll();
122
124}

References RefreshCode::RefreshNone.

◆ Drag()

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

Implements UIHandle.

Definition at line 126 of file NoteTrackVZoomHandle.cpp.

128{
129 using namespace RefreshCode;
130 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
131 if (!pTrack)
132 return Cancelled;
133
134 const wxMouseEvent &event = evt.event;
135 mZoomEnd = event.m_y;
137 // changed Note track to work like audio track
138 // pTrack->VScroll(mZoomStart, mZoomEnd);
139 return RefreshAll;
140 }
141 return RefreshNone;
142}
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1228
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347
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 371 of file NoteTrackVZoomHandle.cpp.

374{
375 if ( iPass == TrackArtist::PassZooming ) {
376 if (!mpTrack.lock()) //? TrackList::Lock()
377 return;
378
381 context, rect, mZoomStart, mZoomEnd);
382 }
383}
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 385 of file NoteTrackVZoomHandle.cpp.

388{
389 if ( iPass == TrackArtist::PassZooming )
390 return ChannelVRulerControls::ZoomingArea(rect, panelRect);
391 else
392 return rect;
393}
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 60 of file NoteTrackVZoomHandle.cpp.

61{
62#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
64#endif
65}
Result mChangeHighlight
Definition: UIHandle.h:147

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

◆ FindChannel()

std::shared_ptr< const Channel > NoteTrackVZoomHandle::FindChannel ( ) const
overridevirtual
Returns
pointer to associated channel, if any

Implements UIHandle.

Definition at line 107 of file NoteTrackVZoomHandle.cpp.

108{
109 return mpTrack.lock();
110}

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 112 of file NoteTrackVZoomHandle.cpp.

113{
114 return true;
115}

◆ HitPreview()

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

Definition at line 67 of file NoteTrackVZoomHandle.cpp.

68{
69 static auto zoomInCursor =
70 ::MakeCursor(wxCURSOR_MAGNIFIER, ZoomInCursorXpm, 19, 15);
71 static auto zoomOutCursor =
72 ::MakeCursor(wxCURSOR_MAGNIFIER, ZoomOutCursorXpm, 19, 15);
73 static wxCursor arrowCursor{ wxCURSOR_ARROW };
74
75 bool bVZoom;
76 gPrefs->Read(wxT("/GUI/VerticalZooming"), &bVZoom, false);
77 bVZoom &= !state.RightIsDown();
78 const auto message = bVZoom ?
79 XO("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.") :
80 XO("Right-click for menu.");
81
82 return {
83 message,
84 bVZoom ? (state.ShiftDown() ? &*zoomOutCursor : &*zoomInCursor) : &arrowCursor
85 // , message
86 };
87}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
bool bVZoom
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:188
virtual bool Read(const wxString &key, bool *value) const =0

References bVZoom, gPrefs, MakeCursor(), audacity::BasicSettings::Read(), wxT(), 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 89 of file NoteTrackVZoomHandle.cpp.

93{
94 if (pTrack) {
95 auto result = std::make_shared<NoteTrackVZoomHandle>(
96 pTrack, rect, state.m_y);
97 result = AssignUIHandlePtr(holder, result);
98 return result;
99 }
100 return {};
101}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:159

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 144 of file NoteTrackVZoomHandle.cpp.

146{
147 return HitPreview(st.state);
148}
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 295 of file NoteTrackVZoomHandle.cpp.

298{
299 using namespace RefreshCode;
300 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
301 if (!pTrack)
302 return RefreshNone;
303
304 const wxMouseEvent &event = evt.event;
305 //const bool shiftDown = event.ShiftDown();
306 const bool rightUp = event.RightUp();
307
308
309 // Popup menu...
310 if (
311 rightUp &&
312 !(event.ShiftDown() || event.CmdDown()))
313 {
314 InitMenuData data {
315 *pProject, pTrack.get(), mRect, RefreshNone, event.m_y
316 };
317
318 PopupMenuTable *const pTable =
320 auto pMenu = PopupMenuTable::BuildMenu(pTable, &data);
321
322 pMenu->Popup( *pParent, { event.m_x, event.m_y } );
323
324 return data.result;
325 }
326
327 bool bVZoom;
328 gPrefs->Read(wxT("/GUI/VerticalZooming"), &bVZoom, false);
329 bVZoom &= event.GetId() != kCaptureLostEventId;
330 if( !bVZoom )
331 return RefreshAll;
332
333 NoteTrackDisplayData data{ *pTrack, evt.rect };
336 }
337 else if (event.ShiftDown() || event.RightUp()) {
338 if (event.ShiftDown() && event.RightUp()) {
339 auto &data = NoteTrackRange::Get(*pTrack);
340 auto oldBotNote = data.GetBottomNote();
341 auto oldTopNote = data.GetTopNote();
342 // Zoom out to show all notes
343 data.ZoomAllNotes(&pTrack->GetSeq());
344 if (data.GetBottomNote() == oldBotNote &&
345 data.GetTopNote() == oldTopNote) {
346 // However if we are already showing all notes, zoom out further
347 data.ZoomMaxExtent();
348 }
349 } else {
350 // Zoom out
351 data.ZoomOut(mZoomEnd);
352 }
353 }
354 else {
355 data.ZoomIn(mZoomEnd);
356 }
357
358 mZoomEnd = mZoomStart = 0;
359 ProjectHistory::Get( *pProject ).ModifyState(false);
360
361 return RefreshAll;
362}
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(), bVZoom, ProjectHistory::Get(), TrackList::Get(), NoteTrackRange::Get(), gPrefs, NoteTrackVRulerMenuTable::Instance(), anonymous_namespace{NoteTrackVZoomHandle.cpp}::IsDragZooming(), kCaptureLostEventId, TrackList::Lock(), ProjectHistory::ModifyState(), audacity::BasicSettings::Read(), RefreshCode::RefreshAll, RefreshCode::RefreshNone, wxT(), 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 FindChannel().

◆ 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: