Audacity  3.0.3
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< NoteTrackGetTrack () const
 
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 bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape () const
 
virtual bool Escape (AudacityProject *pProject)
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 

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

57  : mpTrack{ pTrack } , mZoomStart(y), mZoomEnd(y), mRect(rect)
58 {
59 }

◆ ~NoteTrackVZoomHandle()

NoteTrackVZoomHandle::~NoteTrackVZoomHandle ( )
virtual

Definition at line 104 of file NoteTrackVZoomHandle.cpp.

105 {
106 }

Member Function Documentation

◆ Cancel()

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

Implements UIHandle.

Definition at line 357 of file NoteTrackVZoomHandle.cpp.

358 {
359  // Cancel is implemented! And there is no initial state to restore,
360  // so just return a code.
362 }

References RefreshCode::RefreshAll.

◆ Click()

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

Implements UIHandle.

Definition at line 113 of file NoteTrackVZoomHandle.cpp.

115 {
116  // change note track to zoom like audio track
117  // mpTrack->StartVScroll();
118 
120 }

References RefreshCode::RefreshNone.

◆ Drag()

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

Implements UIHandle.

Definition at line 122 of file NoteTrackVZoomHandle.cpp.

124 {
125  using namespace RefreshCode;
126  auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
127  if (!pTrack)
128  return Cancelled;
129 
130  const wxMouseEvent &event = evt.event;
131  mZoomEnd = event.m_y;
133  // changed Note track to work like audio track
134  // pTrack->VScroll(mZoomStart, mZoomEnd);
135  return RefreshAll;
136  }
137  return RefreshNone;
138 }

References RefreshCode::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 364 of file NoteTrackVZoomHandle.cpp.

367 {
368  if ( iPass == TrackArtist::PassZooming ) {
369  if (!mpTrack.lock()) //? TrackList::Lock()
370  return;
371 
374  ( context, rect, mZoomStart, mZoomEnd );
375  }
376 }

References TrackVRulerControls::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 378 of file NoteTrackVZoomHandle.cpp.

381 {
382  if ( iPass == TrackArtist::PassZooming )
383  return TrackVRulerControls::ZoomingArea( rect, panelRect );
384  else
385  return rect;
386 }

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

Here is the call graph for this function:

◆ Enter()

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

Reimplemented from UIHandle.

Definition at line 61 of file NoteTrackVZoomHandle.cpp.

62 {
63 #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
65 #endif
66 }

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

◆ GetTrack()

std::shared_ptr<NoteTrack> NoteTrackVZoomHandle::GetTrack ( ) const
inline

Definition at line 37 of file NoteTrackVZoomHandle.h.

37 { return mpTrack.lock(); }

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

109 {
110  return true;
111 }

◆ HitPreview()

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

Definition at line 68 of file NoteTrackVZoomHandle.cpp.

69 {
70  static auto zoomInCursor =
71  ::MakeCursor(wxCURSOR_MAGNIFIER, ZoomInCursorXpm, 19, 15);
72  static auto zoomOutCursor =
73  ::MakeCursor(wxCURSOR_MAGNIFIER, ZoomOutCursorXpm, 19, 15);
74  static wxCursor arrowCursor{ wxCURSOR_ARROW };
75 
76  bool bVZoom;
77  gPrefs->Read(wxT("/GUI/VerticalZooming"), &bVZoom, false);
78  bVZoom &= !state.RightIsDown();
79  const auto message = bVZoom ?
80  XO("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.") :
81  XO("Right-click for menu.");
82 
83  return {
84  message,
85  bVZoom ? (state.ShiftDown() ? &*zoomOutCursor : &*zoomInCursor) : &arrowCursor
86  // , message
87  };
88 }

References bVZoom, gPrefs, 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 90 of file NoteTrackVZoomHandle.cpp.

94 {
95  if (pTrack) {
96  auto result = std::make_shared<NoteTrackVZoomHandle>(
97  pTrack, rect, state.m_y);
98  result = AssignUIHandlePtr(holder, result);
99  return result;
100  }
101  return {};
102 }

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

142 {
143  return HitPreview(st.state);
144 }

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

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

References PopupMenuTable::BuildMenu(), bVZoom, ProjectHistory::Get(), TrackList::Get(), gPrefs, NoteTrackVRulerMenuTable::Instance(), anonymous_namespace{NoteTrackVZoomHandle.cpp}::IsDragZooming(), kCaptureLostEventId, TrackList::Lock(), ProjectHistory::ModifyState(), mpTrack, mRect, mZoomEnd, mZoomStart, RefreshCode::RefreshAll, and RefreshCode::RefreshNone.

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(), GetTrack(), and Release().

◆ mRect

wxRect NoteTrackVZoomHandle::mRect
private

Definition at line 72 of file NoteTrackVZoomHandle.h.

Referenced by Release().

◆ mZoomEnd

int NoteTrackVZoomHandle::mZoomEnd
private

Definition at line 71 of file NoteTrackVZoomHandle.h.

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

◆ mZoomStart

int NoteTrackVZoomHandle::mZoomStart
private

Definition at line 71 of file NoteTrackVZoomHandle.h.

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


The documentation for this class was generated from the following files:
ProjectHistory::ModifyState
void ModifyState(bool bWantsAutoSave)
Definition: ProjectHistory.cpp:124
NoteTrackVZoomHandle::mRect
wxRect mRect
Definition: NoteTrackVZoomHandle.h:72
RefreshCode::RefreshAll
@ RefreshAll
Definition: RefreshCode.h:26
RefreshCode::RefreshNone
@ RefreshNone
Definition: RefreshCode.h:21
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
TrackList::Lock
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1542
PopupMenuTable
Definition: PopupMenuTable.h:115
NoteTrackVRulerMenuTable::Instance
static NoteTrackVRulerMenuTable & Instance()
Definition: NoteTrackVZoomHandle.cpp:216
MakeCursor
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:182
bVZoom
bool bVZoom
Definition: NoteTrackVZoomHandle.cpp:258
RefreshCode::Cancelled
@ Cancelled
Definition: RefreshCode.h:23
NoteTrackVZoomHandle::HitPreview
static HitTestPreview HitPreview(const wxMouseState &state)
Definition: NoteTrackVZoomHandle.cpp:68
XO
#define XO(s)
Definition: Internat.h:31
UIHandle::mChangeHighlight
Result mChangeHighlight
Definition: UIHandle.h:139
TrackVRulerControls::ZoomingArea
static wxRect ZoomingArea(const wxRect &rect, const wxRect &panelRect)
Definition: TrackVRulerControls.cpp:81
anonymous_namespace{NoteTrackVZoomHandle.cpp}::IsDragZooming
bool IsDragZooming(int zoomStart, int zoomEnd)
Definition: NoteTrackVZoomHandle.cpp:43
NoteTrackVZoomHandle::mpTrack
std::weak_ptr< NoteTrack > mpTrack
Definition: NoteTrackVZoomHandle.h:69
RefreshCode::RefreshCell
@ RefreshCell
Definition: RefreshCode.h:24
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
TrackVRulerControls::DrawZooming
static void DrawZooming(TrackPanelDrawingContext &context, const wxRect &rect, int zoomStart, int zoomEnd)
Definition: TrackVRulerControls.cpp:61
NoteTrackVZoomHandle::mZoomEnd
int mZoomEnd
Definition: NoteTrackVZoomHandle.h:71
NoteTrackVZoomHandle::mZoomStart
int mZoomStart
Definition: NoteTrackVZoomHandle.h:71
TrackArtist::PassZooming
@ PassZooming
Definition: TrackArtist.h:85
kCaptureLostEventId
const int kCaptureLostEventId
Definition: TrackPanelMouseEvent.h:23
PopupMenuTable::BuildMenu
static std::unique_ptr< PopupMenu > BuildMenu(PopupMenuTable *pTable, void *pUserData=NULL)
Definition: PopupMenuTable.cpp:190
AssignUIHandlePtr
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
RefreshCode
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26