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

virtual std::shared_ptr<Track> CommonTrackPanelCell::FindTrack ( )
pure virtual
unsigned CommonTrackPanelCell::HandleWheelRotation ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overrideprotectedvirtual

Reimplemented from TrackPanelCell.

Definition at line 28 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().

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

Member Data Documentation

double CommonTrackPanelCell::mVertScrollRemainder
private

Definition at line 38 of file CommonTrackPanelCell.h.


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