Audacity  2.3.1
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:
UIHandle

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) override
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
HitTestPreview Preview (const TrackPanelMouseState &state, const AudacityProject *pProject) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
Result Cancel (AudacityProject *pProject) override
 
void DrawExtras (DrawingPass pass, wxDC *dc, const wxRegion &updateRegion, const wxRect &panelRect) 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 ()
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 

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 &)
 

Private Member Functions

 NoteTrackVZoomHandle (const NoteTrackVZoomHandle &)
 

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
enum  DrawingPass { Cells, Panel }
 
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 21 of file NoteTrackVZoomHandle.h.

Constructor & Destructor Documentation

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

Definition at line 55 of file NoteTrackVZoomHandle.cpp.

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

Definition at line 103 of file NoteTrackVZoomHandle.cpp.

104 {
105 }

Member Function Documentation

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

Implements UIHandle.

Definition at line 319 of file NoteTrackVZoomHandle.cpp.

References RefreshCode::RefreshAll.

320 {
321  // Cancel is implemented! And there is no initial state to restore,
322  // so just return a code.
324 }
UIHandle::Result NoteTrackVZoomHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 108 of file NoteTrackVZoomHandle.cpp.

References RefreshCode::RefreshNone.

109 {
110  // change note track to zoom like audio track
111  // mpTrack->StartVScroll();
112 
114 }
UIHandle::Result NoteTrackVZoomHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 117 of file NoteTrackVZoomHandle.cpp.

References Cancelled, TrackPanelMouseEvent::event, AudacityProject::GetTracks(), TrackList::Lock(), mpTrack, mZoomEnd, mZoomStart, RefreshCode::RefreshAll, and RefreshCode::RefreshNone.

118 {
119  using namespace RefreshCode;
120  auto pTrack = pProject->GetTracks()->Lock(mpTrack);
121  if (!pTrack)
122  return Cancelled;
123 
124  const wxMouseEvent &event = evt.event;
125  mZoomEnd = event.m_y;
126  if (IsDragZooming(mZoomStart, mZoomEnd)) {
127  // changed Note track to work like audio track
128  // pTrack->VScroll(mZoomStart, mZoomEnd);
129  return RefreshAll;
130  }
131  return RefreshNone;
132 }
std::weak_ptr< NoteTrack > mpTrack
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1435
TrackList * GetTracks()
Definition: Project.h:209
void NoteTrackVZoomHandle::DrawExtras ( DrawingPass  pass,
wxDC *  dc,
const wxRegion &  updateRegion,
const wxRect &  panelRect 
)
overridevirtual

Reimplemented from UIHandle.

Definition at line 327 of file NoteTrackVZoomHandle.cpp.

References UIHandle::Cells, TrackVRulerControls::DrawZooming(), mpTrack, mRect, mZoomEnd, and mZoomStart.

328 {
329  if (!mpTrack.lock()) //? TrackList::Lock()
330  return;
331 
332  if ( pass == UIHandle::Cells &&
333  IsDragZooming( mZoomStart, mZoomEnd ) )
335  ( dc, mRect, panelRect, mZoomStart, mZoomEnd );
336 }
std::weak_ptr< NoteTrack > mpTrack
static void DrawZooming(wxDC *dc, const wxRect &cellRect, const wxRect &panelRect, int zoomStart, int zoomEnd)
void NoteTrackVZoomHandle::Enter ( bool  forward)
overridevirtual

Reimplemented from UIHandle.

Definition at line 60 of file NoteTrackVZoomHandle.cpp.

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

61 {
62 #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
64 #endif
65 }
Result mChangeHighlight
Definition: UIHandle.h:150
std::shared_ptr<NoteTrack> NoteTrackVZoomHandle::GetTrack ( ) const
inline

Definition at line 39 of file NoteTrackVZoomHandle.h.

References mpTrack.

39 { return mpTrack.lock(); }
std::weak_ptr< NoteTrack > mpTrack
HitTestPreview NoteTrackVZoomHandle::HitPreview ( const wxMouseState &  state)
staticprivate

Definition at line 67 of file NoteTrackVZoomHandle.cpp.

References _(), gPrefs, HitTest(), and MakeCursor().

Referenced by Preview().

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  _("Click to vertically zoom in. Shift-click to zoom out. Drag to specify a zoom region.") :
80  _("Right-click for menu.");
81 
82  return {
83  message,
84  bVZoom ? (state.ShiftDown() ? &*zoomOutCursor : &*zoomInCursor) : &arrowCursor
85  // , message
86  };
87 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:177
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.

References AssignUIHandlePtr().

Referenced by HitPreview(), and NoteTrackVRulerControls::HitTest().

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:162
NoteTrackVZoomHandle& NoteTrackVZoomHandle::operator= ( const NoteTrackVZoomHandle )
default
HitTestPreview NoteTrackVZoomHandle::Preview ( const TrackPanelMouseState state,
const AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 135 of file NoteTrackVZoomHandle.cpp.

References HitPreview(), and TrackPanelMouseState::state.

136 {
137  return HitPreview(st.state);
138 }
static HitTestPreview HitPreview(const wxMouseState &state)
UIHandle::Result NoteTrackVZoomHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overridevirtual

Implements UIHandle.

Definition at line 243 of file NoteTrackVZoomHandle.cpp.

References PopupMenuTable::BuildMenu(), TrackPanelMouseEvent::event, gPrefs, NoteTrackVRulerMenuTable::Instance(), kCaptureLostEventId, mpTrack, mRect, mZoomEnd, mZoomStart, TrackPanelMouseEvent::rect, RefreshCode::RefreshAll, and RefreshCode::RefreshNone.

245 {
246  using namespace RefreshCode;
247  auto pTrack = pProject->GetTracks()->Lock(mpTrack);
248  if (!pTrack)
249  return RefreshNone;
250 
251  const wxMouseEvent &event = evt.event;
252  //const bool shiftDown = event.ShiftDown();
253  const bool rightUp = event.RightUp();
254 
255 
256  bool bVZoom;
257  gPrefs->Read(wxT("/GUI/VerticalZooming"), &bVZoom, false);
258 
259  // Popup menu...
260  if (
261  rightUp &&
262  !(event.ShiftDown() || event.CmdDown()))
263  {
264  InitMenuData data {
265  pTrack.get(), mRect, RefreshCode::RefreshNone, event.m_y
266  };
267 
268  PopupMenuTable *const pTable =
270  std::unique_ptr<PopupMenuTable::Menu>
271  pMenu(PopupMenuTable::BuildMenu(pParent, pTable, &data));
272 
273  // Accelerators only if zooming enabled.
274  if( !bVZoom )
275  {
276  wxMenuItemList & L = pMenu->GetMenuItems();
277  // let's iterate over the list in STL syntax
278  wxMenuItemList::iterator iter;
279  for (iter = L.begin(); iter != L.end(); ++iter)
280  {
281  wxMenuItem *pItem = *iter;
282  // Remove accelerator, if any.
283  pItem->SetItemLabel( (pItem->GetItemLabel() + "\t" ).BeforeFirst('\t') );
284  }
285  }
286 
287  pParent->PopupMenu(pMenu.get(), event.m_x, event.m_y);
288 
289  return data.result;
290  }
291 
292  bVZoom &= event.GetId() != kCaptureLostEventId;
293  if( !bVZoom )
294  return RefreshAll;
295 
296  if (IsDragZooming(mZoomStart, mZoomEnd)) {
297  pTrack->ZoomTo(evt.rect, mZoomStart, mZoomEnd);
298  }
299  else if (event.ShiftDown() || event.RightUp()) {
300  if (event.ShiftDown() && event.RightUp()) {
301  // Zoom out completely
302  pTrack->SetBottomNote(0);
303  pTrack->SetPitchHeight(evt.rect.height, 1);
304  } else {
305  // Zoom out
306  pTrack->ZoomOut(evt.rect, mZoomEnd);
307  }
308  }
309  else {
310  pTrack->ZoomIn(evt.rect, mZoomEnd);
311  }
312 
313  mZoomEnd = mZoomStart = 0;
314  pProject->ModifyState(true);
315 
316  return RefreshAll;
317 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
std::weak_ptr< NoteTrack > mpTrack
static NoteTrackVRulerMenuTable & Instance()
static std::unique_ptr< Menu > BuildMenu(wxEvtHandler *pParent, PopupMenuTable *pTable, void *pUserData=NULL)
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1435
void ModifyState(bool bWantsAutoSave)
Definition: Project.cpp:4660
const int kCaptureLostEventId
TrackList * GetTracks()
Definition: Project.h:209

Member Data Documentation

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

Definition at line 65 of file NoteTrackVZoomHandle.h.

Referenced by Drag(), DrawExtras(), GetTrack(), and Release().

wxRect NoteTrackVZoomHandle::mRect
private

Definition at line 68 of file NoteTrackVZoomHandle.h.

Referenced by DrawExtras(), and Release().

int NoteTrackVZoomHandle::mZoomEnd
private

Definition at line 67 of file NoteTrackVZoomHandle.h.

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

int NoteTrackVZoomHandle::mZoomStart
private

Definition at line 67 of file NoteTrackVZoomHandle.h.

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


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