Audacity  2.2.2
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
CommonTrackPanelCell Class Referenceabstract

#include <CommonTrackPanelCell.h>

Inheritance diagram for CommonTrackPanelCell:
TrackPanelCell BackgroundCell Track TrackControls TrackPanelResizerCell TrackVRulerControls AudioTrack LabelTrack TimeTrack LabelTrackControls NoteTrackControls TimeTrackControls WaveTrackControls LabelTrackVRulerControls NoteTrackVRulerControls TimeTrackVRulerControls WaveTrackVRulerControls

Public Member Functions

 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
virtual std::shared_ptr< TrackFindTrack ()=0
 
- Public Member Functions inherited from TrackPanelCell
virtual ~TrackPanelCell ()=0
 
virtual std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject)=0
 
virtual std::shared_ptr
< TrackPanelCell
ContextMenuDelegate ()
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, wxPoint *pPosition)
 
virtual unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
virtual unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 
virtual unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent)
 

Protected Member Functions

unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 

Private Attributes

double mVertScrollRemainder
 

Detailed Description

Definition at line 20 of file CommonTrackPanelCell.h.

Constructor & Destructor Documentation

CommonTrackPanelCell::CommonTrackPanelCell ( )
inline

Definition at line 24 of file CommonTrackPanelCell.h.

26  {}
CommonTrackPanelCell::~CommonTrackPanelCell ( )
pure virtual

Definition at line 23 of file CommonTrackPanelCell.cpp.

24 {
25 }

Member Function Documentation

HitTestPreview CommonTrackPanelCell::DefaultPreview ( const TrackPanelMouseState ,
const AudacityProject  
)
overridevirtual

Reimplemented from TrackPanelCell.

Definition at line 28 of file CommonTrackPanelCell.cpp.

29 {
30  static wxCursor defaultCursor{ wxCURSOR_ARROW };
31  return { {}, &defaultCursor, {} };
32 }
virtual std::shared_ptr<Track> CommonTrackPanelCell::FindTrack ( )
pure virtual
unsigned CommonTrackPanelCell::HandleWheelRotation ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overrideprotectedvirtual

Reimplemented from TrackPanelCell.

Definition at line 35 of file CommonTrackPanelCell.cpp.

References RefreshCode::Cancelled, TrackList::empty(), TrackPanelMouseEvent::event, RefreshCode::FixScrollbars, TrackList::GetEndTime(), TrackPanel::GetLeftOffset(), AudacityProject::GetScreenEndTime(), AudacityProject::GetScrubber(), AudacityProject::GetTrackPanel(), AudacityProject::GetTracks(), AudacityProject::GetViewInfo(), RefreshCode::RefreshAll, TrackPanelMouseEvent::steps, AudacityProject::TP_ScrollUpDown(), AudacityProject::TP_ScrollWindow(), AudacityProject::ZoomInByFactor(), and AudacityProject::ZoomOutByFactor().

36 {
37  using namespace RefreshCode;
38 
39  if (pProject->GetTracks()->empty())
40  // Scrolling and Zoom in and out commands are disabled when there are no tracks.
41  // This should be disabled too for consistency. Otherwise
42  // you do see changes in the time ruler.
43  return Cancelled;
44 
45  unsigned result = RefreshAll;
46  const wxMouseEvent &event = evt.event;
47  ViewInfo &viewInfo = pProject->GetViewInfo();
48  Scrubber &scrubber = pProject->GetScrubber();
49  const auto steps = evt.steps;
50 
51  if (event.ShiftDown()
52  // Don't pan during smooth scrolling. That would conflict with keeping
53  // the play indicator centered.
54  && !scrubber.IsScrollScrubbing()
55  )
56  {
57  // MM: Scroll left/right when used with Shift key down
58  pProject->TP_ScrollWindow(
59  viewInfo.OffsetTimeByPixels(
60  viewInfo.PositionToTime(0), 50.0 * -steps));
61  }
62  else if (event.CmdDown())
63  {
64 #if 0
65  // JKC: Alternative scroll wheel zooming code
66  // using AudacityProject zooming, which is smarter,
67  // it keeps selections on screen and centred if it can,
68  // also this ensures mousewheel and zoom buttons give same result.
69  double ZoomFactor = pow(2.0, steps);
70  AudacityProject *p = GetProject();
71  if( steps > 0 )
72  p->ZoomInByFactor( ZoomFactor );
73  else
74  p->ZoomOutByFactor( ZoomFactor );
75 #endif
76  // MM: Zoom in/out when used with Control key down
77  // We're converting pixel positions to times,
78  // counting pixels from the left edge of the track.
79  int trackLeftEdge = pProject->GetTrackPanel()->GetLeftOffset();
80 
81  // Time corresponding to mouse position
82  wxCoord xx;
83  double center_h;
84  double mouse_h = viewInfo.PositionToTime(event.m_x, trackLeftEdge);
85 
86  // Scrubbing? Expand or contract about the center, ignoring mouse position
87  if (scrubber.IsScrollScrubbing())
88  center_h = viewInfo.h + (pProject->GetScreenEndTime() - viewInfo.h) / 2.0;
89  // Zooming out? Focus on mouse.
90  else if( steps <= 0 )
91  center_h = mouse_h;
92  // No Selection? Focus on mouse.
93  else if((viewInfo.selectedRegion.t1() - viewInfo.selectedRegion.t0() ) < 0.00001 )
94  center_h = mouse_h;
95  // Before Selection? Focus on left
96  else if( mouse_h < viewInfo.selectedRegion.t0() )
97  center_h = viewInfo.selectedRegion.t0();
98  // After Selection? Focus on right
99  else if( mouse_h > viewInfo.selectedRegion.t1() )
100  center_h = viewInfo.selectedRegion.t1();
101  // Inside Selection? Focus on mouse
102  else
103  center_h = mouse_h;
104 
105  xx = viewInfo.TimeToPosition(center_h, trackLeftEdge);
106 
107  // Time corresponding to last (most far right) audio.
108  double audioEndTime = pProject->GetTracks()->GetEndTime();
109 
110 // Disabled this code to fix Bug 1923 (tricky to wheel-zoom right of waveform).
111 #if 0
112  // When zooming in in empty space, it's easy to 'lose' the waveform.
113  // This prevents it.
114  // IF zooming in
115  if (steps > 0)
116  {
117  // IF mouse is to right of audio
118  if (center_h > audioEndTime)
119  // Zooming brings far right of audio to mouse.
120  center_h = audioEndTime;
121  }
122 #endif
123 
124  wxCoord xTrackEnd = viewInfo.TimeToPosition( audioEndTime );
125  viewInfo.ZoomBy(pow(2.0, steps));
126 
127  double new_center_h = viewInfo.PositionToTime(xx, trackLeftEdge);
128  viewInfo.h += (center_h - new_center_h);
129 
130  // If wave has gone off screen, bring it back.
131  // This means that the end of the track stays where it was.
132  if( viewInfo.h > audioEndTime )
133  viewInfo.h += audioEndTime - viewInfo.PositionToTime( xTrackEnd );
134 
135 
136  result |= FixScrollbars;
137  }
138  else
139  {
140 #ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
141  if (scrubber.IsScrubbing()) {
142  scrubber.HandleScrollWheel(steps);
143  evt.event.Skip(false);
144  }
145  else
146 #endif
147  {
148  // MM: Scroll up/down when used without modifier keys
149  double lines = steps * 4 + mVertScrollRemainder;
150  mVertScrollRemainder = lines - floor(lines);
151  lines = floor(lines);
152  auto didSomething = pProject->TP_ScrollUpDown((int)-lines);
153  if (!didSomething)
154  result |= Cancelled;
155  }
156  }
157 
158  return result;
159 }
ViewInfo is used mainly to hold the zooming, selection and scroll information. It also has some statu...
Definition: ViewInfo.h:141
Scrubber & GetScrubber()
Definition: Project.h:804
void ZoomOutByFactor(double ZoomFactor)
Definition: Menus.cpp:6906
double GetEndTime() const
Definition: Track.cpp:1418
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void TP_ScrollWindow(double scrollto) override
Definition: Project.cpp:1859
double GetScreenEndTime() const
Definition: Menus.cpp:6822
TrackPanel * GetTrackPanel()
Definition: Project.h:307
int GetLeftOffset() const
Definition: TrackPanel.h:270
void ZoomInByFactor(double ZoomFactor)
Definition: Menus.cpp:6827
TrackList * GetTracks()
Definition: Project.h:192
const ViewInfo & GetViewInfo() const
Definition: Project.h:207
bool TP_ScrollUpDown(int delta) override
Definition: Project.cpp:1873
bool empty() const
Definition: Track.cpp:1229

Member Data Documentation

double CommonTrackPanelCell::mVertScrollRemainder
private

Definition at line 42 of file CommonTrackPanelCell.h.


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