Audacity  2.2.2
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
TrackPanel Class Referencefinal

The TrackPanel class coordinates updates and operations on the main part of the screen which contains multiple tracks. More...

#include <TrackPanel.h>

Inheritance diagram for TrackPanel:
OverlayPanel BackedPanel wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Classes

class  AudacityTimer
 Timer class dedicated to infomring the TrackPanel that it is time to refresh some aspect of the screen. More...
 
struct  FoundCell
 

Public Member Functions

 TrackPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const std::shared_ptr< TrackList > &tracks, ViewInfo *viewInfo, TrackPanelListener *listener, AdornedRulerPanel *ruler)
 
virtual ~TrackPanel ()
 
IteratorRange
< TrackPanelCellIterator
Cells ()
 
void UpdatePrefs ()
 
void ApplyUpdatedTheme ()
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void OnCaptureLost (wxMouseCaptureLostEvent &event)
 Should handle the case when the mouse capture is lost. More...
 
void OnCaptureKey (wxCommandEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 
void OnChar (wxKeyEvent &event)
 
void OnKeyUp (wxKeyEvent &event)
 
void OnSetFocus (wxFocusEvent &event)
 
void OnKillFocus (wxFocusEvent &event)
 
void OnContextMenu (wxContextMenuEvent &event)
 
void OnPlayback (wxCommandEvent &)
 
void OnTrackListResizing (wxCommandEvent &event)
 
void OnTrackListDeletion (wxCommandEvent &event)
 
void UpdateViewIfNoTracks ()
 
double GetMostRecentXPos ()
 
void OnIdle (wxIdleEvent &event)
 
void OnTimer (wxTimerEvent &event)
 AS: This gets called on our wx timer events. More...
 
int GetLeftOffset () const
 
void GetTracksUsableArea (int *width, int *height) const
 
void Refresh (bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
 
void RefreshTrack (Track *trk, bool refreshbacking=true)
 
void DisplaySelection ()
 Displays the bounds of the selection in the status bar. More...
 
void HandleInterruptedDrag ()
 
void Uncapture (wxMouseState *pState=nullptr)
 
bool CancelDragging ()
 
bool HandleEscapeKey (bool down)
 
void UpdateMouseState (const wxMouseState &state)
 
void HandleModifierKey ()
 
void HandlePageUpKey ()
 
void HandlePageDownKey ()
 
AudacityProjectGetProject () const
 
void ScrollIntoView (double pos)
 
void ScrollIntoView (int x)
 
void OnTrackMenu (Track *t=NULL)
 
TrackGetFirstSelectedTrack ()
 
bool IsMouseCaptured ()
 Determines if a modal tool is active. More...
 
void EnsureVisible (Track *t)
 
void VerticalScroll (float fracPosition)
 
TrackGetFocusedTrack ()
 
void SetFocusedTrack (Track *t)
 
void HandleCursorForPresentMouseState (bool doHit=true)
 
void UpdateVRulers ()
 
void UpdateVRuler (Track *t)
 
void UpdateTrackVRuler (const Track *t)
 
void UpdateVRulerSize ()
 
double GetScreenEndTime () const
 
size_t GetTrackCount () const
 
size_t GetSelectedTrackCount () const
 
void UpdateAccessibility ()
 
void MessageForScreenReader (const wxString &message)
 
void HandleWheelRotation (TrackPanelMouseEvent &tpmEvent)
 Handle mouse wheel rotation (for zoom in/out, vertical and horizontal scrolling) More...
 
void MakeParentRedrawScrollbars ()
 
wxRect FindTrackRect (const Track *target, bool label)
 
int GetLabelWidth () const
 
const TrackListGetTracks () const
 
TrackListGetTracks ()
 
ViewInfoGetViewInfo ()
 
TrackPanelListenerGetListener ()
 
AdornedRulerPanelGetRuler ()
 
void SetBackgroundCell (const std::shared_ptr< TrackPanelCell > &pCell)
 
std::shared_ptr< TrackPanelCellGetBackgroundCell ()
 
LWSliderGainSlider (const WaveTrack *wt)
 
LWSliderPanSlider (const WaveTrack *wt)
 
TrackInfoGetTrackInfo ()
 
const TrackInfoGetTrackInfo () const
 
TrackPanelAxGetAx ()
 
UIHandlePtr Target ()
 
- Public Member Functions inherited from OverlayPanel
 OverlayPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style=wxTAB_TRAVERSAL|wxNO_BORDER)
 
void AddOverlay (Overlay *pOverlay)
 
bool RemoveOverlay (Overlay *pOverlay)
 
void ClearOverlays ()
 
void DrawOverlays (bool repaint_all, wxDC *pDC=nullptr)
 
- Public Member Functions inherited from BackedPanel
 BackedPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style)
 
 ~BackedPanel ()
 
wxDC & GetBackingDC ()
 
wxDC & GetBackingDCForRepaint ()
 
void ResizeBacking ()
 
void RepairBitmap (wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
 
void DisplayBitmap (wxDC &dc)
 
void OnSize (wxSizeEvent &event)
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 

Static Public Member Functions

static bool HasSoloButton ()
 

Public Attributes

wxSize vrulerSize
 

Static Public Attributes

static TrackPanel *(* FactoryFunction )(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const std::shared_ptr< TrackList > &tracks, ViewInfo *viewInfo, TrackPanelListener *listener, AdornedRulerPanel *ruler) = TrackPanelFactory
 

Protected Member Functions

bool IsAudioActive ()
 
void HandleClick (const TrackPanelMouseEvent &tpmEvent)
 
void UpdateSelectionDisplay ()
 
void MakeParentModifyState (bool bWantsAutoSave)
 
FoundCell FindCell (int mouseX, int mouseY)
 
void HandleMotion (wxMouseState &state, bool doHit=true)
 
void HandleMotion (const TrackPanelMouseState &tpmState, bool doHit=true)
 
int GetVRulerWidth () const
 
int GetVRulerOffset () const
 
void DrawTracks (wxDC *dc)
 
void DrawEverythingElse (TrackPanelDrawingContext &context, const wxRegion &region, const wxRect &clip)
 
void DrawOutside (TrackPanelDrawingContext &context, Track *t, const wxRect &rec)
 
void HighlightFocusedTrack (wxDC *dc, const wxRect &rect)
 Draw a three-level highlight gradient around the focused track. More...
 
void DrawShadow (Track *t, wxDC *dc, const wxRect &rect)
 
void DrawBordersAroundTrack (Track *t, wxDC *dc, const wxRect &rect, const int labelw, const int vrul)
 
void DrawOutsideOfTrack (TrackPanelDrawingContext &context, Track *t, const wxRect &rect)
 
void ClearTargets ()
 
bool HasRotation ()
 
bool HasEscape ()
 
bool ChangeTarget (bool forward, bool cycle)
 

Protected Attributes

TrackInfo mTrackInfo
 
TrackPanelListenermListener
 
std::shared_ptr< TrackListmTracks
 
ViewInfomViewInfo
 
AdornedRulerPanelmRuler
 
std::unique_ptr< TrackArtistmTrackArtist
 
TrackPanel::AudacityTimer mTimer
 
int mTimeCount
 
bool mRefreshBacking
 
bool mRedrawAfterStop
 
wxMouseState mLastMouseState
 
int mMouseMostRecentX
 
int mMouseMostRecentY
 
std::unique_ptr< TrackPanelAxmAx
 
SelectedRegion mLastDrawnSelectedRegion {}
 
std::weak_ptr< TrackPanelCellmLastCell
 
std::vector< UIHandlePtrmTargets
 
size_t mTarget {}
 
unsigned mMouseOverUpdateFlags {}
 
std::weak_ptr< TrackmpClickedTrack
 
UIHandlePtr mUIHandle
 
std::shared_ptr< TrackPanelCellmpBackground
 
bool mEnableTab {}
 

Static Protected Attributes

static wxString gSoloPref
 

Friends

class TrackPanelAx
 
class ScreenshotCommand
 
class GetInfoCommand
 

Detailed Description

The TrackPanel class coordinates updates and operations on the main part of the screen which contains multiple tracks.

It uses many other classes, but in particular it uses the TrackInfo class to draw the controls area on the left of a track, and the TrackArtist class to draw the actual waveforms.

Note that in some of the older code here, e.g., GetLabelWidth(), "Label" means the TrackInfo plus the vertical ruler. Confusing relative to LabelTrack labels.

The TrackPanel manages multiple tracks and their TrackInfos.

Note that with stereo tracks there will be one TrackInfo being used by two wavetracks.

Definition at line 245 of file TrackPanel.h.

Constructor & Destructor Documentation

TrackPanel::TrackPanel ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos,
const wxSize &  size,
const std::shared_ptr< TrackList > &  tracks,
ViewInfo viewInfo,
TrackPanelListener listener,
AdornedRulerPanel ruler 
)

Definition at line 297 of file TrackPanel.cpp.

References _(), GetProject(), kBottomMargin, kRightMargin, kTopMargin, mAx, mRedrawAfterStop, mTimeCount, mTimer, mTrackArtist, mTracks, OnIdle(), OnPlayback(), OnTrackListDeletion(), OnTrackListResizing(), and TrackPanel::AudacityTimer::parent.

304  : OverlayPanel(parent, id, pos, size, wxWANTS_CHARS | wxNO_BORDER),
305  mTrackInfo(this),
306  mListener(listener),
307  mTracks(tracks),
308  mViewInfo(viewInfo),
309  mRuler(ruler),
310  mTrackArtist(nullptr),
311  mRefreshBacking(false),
312  vrulerSize(36,0)
313 #ifndef __WXGTK__ //Get rid if this pragma for gtk
314 #pragma warning( default: 4355 )
315 #endif
316 {
317  SetLabel(_("Track Panel"));
318  SetName(_("Track Panel"));
319  SetBackgroundStyle(wxBG_STYLE_PAINT);
320 
321  {
322  auto pAx = std::make_unique <TrackPanelAx>( this );
323 #if wxUSE_ACCESSIBILITY
324  // wxWidgets owns the accessible object
325  SetAccessible(mAx = pAx.release());
326 #else
327  // wxWidgets does not own the object, but we need to retain it
328  mAx = std::move(pAx);
329 #endif
330  }
331 
332  mRedrawAfterStop = false;
333 
334  mTrackArtist = std::make_unique<TrackArtist>();
335 
337 
338  mTimeCount = 0;
339  mTimer.parent = this;
340  // Timer is started after the window is visible
341  GetProject()->Bind(wxEVT_IDLE, &TrackPanel::OnIdle, this);
342 
343  // Register for tracklist updates
344  mTracks->Bind(EVT_TRACKLIST_RESIZING,
346  this);
347  mTracks->Bind(EVT_TRACKLIST_DELETION,
349  this);
350  wxTheApp->Bind(EVT_AUDIOIO_PLAYBACK,
352  this);
353 }
void OnTrackListDeletion(wxCommandEvent &event)
std::shared_ptr< TrackList > mTracks
Definition: TrackPanel.h:450
TrackPanel::AudacityTimer mTimer
void OnTrackListResizing(wxCommandEvent &event)
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
OverlayPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style=wxTAB_TRAVERSAL|wxNO_BORDER)
wxSize vrulerSize
Definition: TrackPanel.h:511
TrackInfo mTrackInfo
Definition: TrackPanel.h:434
TrackPanelListener * mListener
Definition: TrackPanel.h:448
_("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
int mTimeCount
Definition: TrackPanel.h:473
std::unique_ptr< TrackArtist > mTrackArtist
Definition: TrackPanel.h:455
bool mRefreshBacking
Definition: TrackPanel.h:475
bool mRedrawAfterStop
Definition: TrackPanel.h:483
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
void OnIdle(wxIdleEvent &event)
Definition: TrackPanel.cpp:453
std::unique_ptr< TrackPanelAx > mAx
Definition: TrackPanel.h:495
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
void OnPlayback(wxCommandEvent &)
TrackPanel::~TrackPanel ( )
virtual

Definition at line 356 of file TrackPanel.cpp.

References mTimer.

357 {
358  mTimer.Stop();
359 
360  // This can happen if a label is being edited and the user presses
361  // ALT+F4 or Command+Q
362  if (HasCapture())
363  ReleaseMouse();
364 }
TrackPanel::AudacityTimer mTimer

Member Function Documentation

void TrackPanel::ApplyUpdatedTheme ( )

Definition at line 415 of file TrackPanel.cpp.

References mTrackInfo, and TrackInfo::ReCreateSliders().

Referenced by AudacityProject::ApplyUpdatedTheme().

416 {
418 }
void ReCreateSliders()
TrackInfo mTrackInfo
Definition: TrackPanel.h:434
bool TrackPanel::CancelDragging ( )

Definition at line 721 of file TrackPanel.cpp.

References ClearTargets(), GetProject(), GetTracks(), TrackList::Lock(), mMouseOverUpdateFlags, mpClickedTrack, mRuler, mUIHandle, and Uncapture().

Referenced by HandleEscapeKey(), and OnMouseEvent().

722 {
723  if (mUIHandle) {
724  // copy shared_ptr for safety, as in HandleClick
725  auto handle = mUIHandle;
726  // UIHANDLE CANCEL
727  UIHandle::Result refreshResult = handle->Cancel(GetProject());
728  auto pTrack = GetTracks()->Lock(mpClickedTrack);
729  if (pTrack)
730  ProcessUIHandleResult(
731  this, mRuler, pTrack.get(), NULL,
732  refreshResult | mMouseOverUpdateFlags );
733  mpClickedTrack.reset();
734  mUIHandle.reset(), handle.reset(), ClearTargets();
735  Uncapture();
736  return true;
737  }
738  return false;
739 }
void Uncapture(wxMouseState *pState=nullptr)
Definition: TrackPanel.cpp:707
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
unsigned mMouseOverUpdateFlags
Definition: TrackPanel.h:517
void ClearTargets()
Definition: TrackPanel.h:529
unsigned Result
Definition: UIHandle.h:37
UIHandlePtr mUIHandle
Definition: TrackPanel.h:545
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:734
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
std::weak_ptr< Track > mpClickedTrack
Definition: TrackPanel.h:544
IteratorRange< TrackPanelCellIterator > TrackPanel::Cells ( )

Definition at line 3341 of file TrackPanel.cpp.

Referenced by FindCell().

3342 {
3343  return {
3344  TrackPanelCellIterator( this, true ),
3345  TrackPanelCellIterator( this, false )
3346  };
3347 }
bool TrackPanel::ChangeTarget ( bool  forward,
bool  cycle 
)
protected

Definition at line 978 of file TrackPanel.cpp.

References IsMouseCaptured(), mTarget, mTargets, and Target().

Referenced by HandleEscapeKey(), and OnKeyDown().

979 {
980  auto size = mTargets.size();
981 
982  auto target = Target();
983  if (target && target->HasRotation()) {
984  if(target->Rotate(forward))
985  return true;
986  else if (cycle && (size == 1 || IsMouseCaptured())) {
987  // Rotate through the states of this target only.
988  target->Enter(forward);
989  return true;
990  }
991  }
992 
993  if (!cycle &&
994  ((forward && mTarget + 1 == size) ||
995  (!forward && mTarget == 0)))
996  return false;
997 
998  if (size > 1) {
999  if (forward)
1000  ++mTarget;
1001  else
1002  mTarget += size - 1;
1003  mTarget %= size;
1004  if (Target())
1005  Target()->Enter(forward);
1006  return true;
1007  }
1008 
1009  return false;
1010 }
bool IsMouseCaptured()
Determines if a modal tool is active.
UIHandlePtr Target()
Definition: TrackPanel.h:520
size_t mTarget
Definition: TrackPanel.h:516
std::vector< UIHandlePtr > mTargets
Definition: TrackPanel.h:515
void TrackPanel::ClearTargets ( )
inlineprotected

Definition at line 529 of file TrackPanel.h.

Referenced by CancelDragging(), HandleClick(), OnCaptureLost(), and OnMouseEvent().

530  {
531  // Forget the rotation of hit test candidates when the mouse moves from
532  // cell to cell or outside of the TrackPanel entirely.
533  mLastCell.reset();
534  mTargets.clear();
535  mTarget = 0;
537  }
std::weak_ptr< TrackPanelCell > mLastCell
Definition: TrackPanel.h:514
unsigned mMouseOverUpdateFlags
Definition: TrackPanel.h:517
size_t mTarget
Definition: TrackPanel.h:516
std::vector< UIHandlePtr > mTargets
Definition: TrackPanel.h:515
void TrackPanel::DisplaySelection ( )

Displays the bounds of the selection in the status bar.

Definition at line 2836 of file TrackPanel.cpp.

References mListener, and TrackPanelListener::TP_DisplaySelection().

Referenced by OnTimer(), Refresh(), and UpdateSelectionDisplay().

2837 {
2838  if (!mListener)
2839  return;
2840 
2841  // DM: Note that the Selection Bar can actually MODIFY the selection
2842  // if snap-to mode is on!!!
2844 }
TrackPanelListener * mListener
Definition: TrackPanel.h:448
virtual void TP_DisplaySelection()=0
void TrackPanel::DrawBordersAroundTrack ( Track t,
wxDC *  dc,
const wxRect &  rect,
const int  labelw,
const int  vrul 
)
protected

Definition at line 2706 of file TrackPanel.cpp.

References Track::GetHeight(), Track::GetLinked(), kBottomMargin, kShadowThickness, kTopInset, and AColor::Line().

2709 {
2710  // Border around track and label area
2711  // leaving room for the shadow
2712  dc->SetBrush(*wxTRANSPARENT_BRUSH);
2713  dc->SetPen(*wxBLACK_PEN);
2714  dc->DrawRectangle(rect.x, rect.y,
2715  rect.width - kShadowThickness,
2716  rect.height - kShadowThickness);
2717 
2718  // between vruler and TrackInfo
2719  AColor::Line(*dc, vrul, rect.y, vrul, rect.y + rect.height - 1);
2720 
2721  // The lines at bottom of 1st track and top of second track of stereo group
2722  // Possibly replace with DrawRectangle to add left border.
2723  if (t->GetLinked()) {
2724  // The given rect has had the top inset subtracted
2725  int h1 = rect.y + t->GetHeight() - kTopInset;
2726  // h1 is the top coordinate of the second tracks' rectangle
2727  // Draw (part of) the bottom border of the top channel and top border of the bottom
2728  // At left it extends between the vertical rulers too
2729  // These lines stroke over what is otherwise "border" of each channel
2730  AColor::Line(*dc, labelw, h1 - kBottomMargin, rect.x + rect.width - 1, h1 - kBottomMargin);
2731  AColor::Line(*dc, labelw, h1 + kTopInset, rect.x + rect.width - 1, h1 + kTopInset);
2732  }
2733 }
bool GetLinked() const
Definition: Track.h:279
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:122
int GetHeight() const
Definition: Track.cpp:180
void TrackPanel::DrawEverythingElse ( TrackPanelDrawingContext context,
const wxRegion &  region,
const wxRect &  clip 
)
protected

Draws 'Everything else'. In particular it draws:

  • Drop shadow for tracks and vertical rulers.
  • Zooming Indicators.
  • Fills in space below the tracks.

Definition at line 1845 of file TrackPanel.cpp.

References UIHandle::Cells, TrackPanelDrawingContext::dc, DrawOutside(), TrackList::FindPendingChangedTrack(), TrackListCondIterator::First(), GetFocusedTrack(), Track::GetHeight(), GetLeftOffset(), Track::GetLink(), Track::GetLinked(), GetProject(), GetTracks(), GetVRulerOffset(), GetVRulerWidth(), Track::GetY(), HighlightFocusedTrack(), kBottomMargin, kTopMargin, mAx, mTrackArtist, mViewInfo, TrackListCondIterator::Next(), UIHandle::Panel, Target(), AColor::TrackPanelBackground(), and ZoomInfo::vpos.

Referenced by DrawTracks().

1848 {
1849  // We draw everything else
1850  auto dc = &context.dc;
1851  wxRect focusRect(-1, -1, 0, 0);
1852  wxRect trackRect = clip;
1853  trackRect.height = 0; // for drawing background in no tracks case.
1854 
1856  for (Track *t = iter.First(); t; t = iter.Next()) {
1857  auto other = GetTracks()->FindPendingChangedTrack(t->GetId());
1858  if (other)
1859  t = other.get();
1860  trackRect.y = t->GetY() - mViewInfo->vpos;
1861  trackRect.height = t->GetHeight();
1862 
1863  // If this track is linked to the next one, display a common
1864  // border for both, otherwise draw a normal border
1865  wxRect rect = trackRect;
1866  bool skipBorder = false;
1867  Track *l = t->GetLink();
1868 
1869  if (l && t->GetLinked()) {
1870  rect.height += l->GetHeight();
1871  }
1872  else if (l && trackRect.y >= 0) {
1873  skipBorder = true;
1874  }
1875 
1876  // If the previous track is linked to this one but isn't on the screen
1877  // (and thus would have been skipped by VisibleTrackIterator) we need to
1878  // draw that track's border instead.
1879  Track *borderTrack = t;
1880  wxRect borderRect = rect;
1881 
1882  if (l && !t->GetLinked() && trackRect.y < 0)
1883  {
1884  borderTrack = l;
1885 
1886  borderRect = trackRect;
1887  borderRect.y = l->GetY() - mViewInfo->vpos;
1888  borderRect.height = l->GetHeight();
1889 
1890  borderRect.height += t->GetHeight();
1891  }
1892 
1893  if (!skipBorder) {
1894  if (mAx->IsFocused(t)) {
1895  focusRect = borderRect;
1896  }
1897  DrawOutside(context, borderTrack, borderRect);
1898  }
1899 
1900  // Believe it or not, we can speed up redrawing if we don't
1901  // redraw the vertical ruler when only the waveform data has
1902  // changed. An example is during recording.
1903 
1904 #if DEBUG_DRAW_TIMING
1905 // wxRect rbox = region.GetBox();
1906 // wxPrintf(wxT("Update Region: %d %d %d %d\n"),
1907 // rbox.x, rbox.y, rbox.width, rbox.height);
1908 #endif
1909 
1910  if (region.Contains(0, trackRect.y, GetLeftOffset(), trackRect.height)) {
1911  wxRect rect = trackRect;
1912  rect.x += GetVRulerOffset();
1913  rect.y += kTopMargin;
1914  rect.width = GetVRulerWidth();
1915  rect.height -= (kTopMargin + kBottomMargin);
1916  mTrackArtist->DrawVRuler(context, t, rect);
1917  }
1918  }
1919 
1920  auto target = Target();
1921  if (target)
1922  target->DrawExtras(UIHandle::Cells, dc, region, clip);
1923 
1924  // Paint over the part below the tracks
1925  trackRect.y += trackRect.height;
1926  if (trackRect.y < clip.GetBottom()) {
1927  AColor::TrackPanelBackground(dc, false);
1928  dc->DrawRectangle(trackRect.x,
1929  trackRect.y,
1930  trackRect.width,
1931  clip.height - trackRect.y);
1932  }
1933 
1934  // Sometimes highlight is not drawn on backing bitmap. I thought
1935  // it was because FindFocus did not return "this" on Mac, but
1936  // when I removed that test, yielding this condition:
1937  // if (GetFocusedTrack() != NULL) {
1938  // the highlight was reportedly drawn even when something else
1939  // was the focus and no highlight should be drawn. -RBD
1940  if (GetFocusedTrack() != NULL && wxWindow::FindFocus() == this) {
1941  HighlightFocusedTrack(dc, focusRect);
1942  }
1943 
1944  if (target)
1945  target->DrawExtras(UIHandle::Panel, dc, region, clip);
1946 }
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
static void TrackPanelBackground(wxDC *dc, bool selected)
Definition: AColor.cpp:349
bool GetLinked() const
Definition: Track.h:279
void HighlightFocusedTrack(wxDC *dc, const wxRect &rect)
Draw a three-level highlight gradient around the focused track.
int GetVRulerWidth() const
UIHandlePtr Target()
Definition: TrackPanel.h:520
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
void DrawOutside(TrackPanelDrawingContext &context, Track *t, const wxRect &rec)
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
std::shared_ptr< Track > FindPendingChangedTrack(TrackId id) const
Definition: Track.cpp:1557
int vpos
Definition: ViewInfo.h:45
Track * GetLink() const
Definition: Track.cpp:269
std::unique_ptr< TrackArtist > mTrackArtist
Definition: TrackPanel.h:455
int GetY() const
Definition: Track.cpp:154
Track * GetFocusedTrack()
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
int GetLeftOffset() const
Definition: TrackPanel.h:287
std::unique_ptr< TrackPanelAx > mAx
Definition: TrackPanel.h:495
int GetHeight() const
Definition: Track.cpp:180
int GetVRulerOffset() const
Definition: TrackPanel.h:381
void TrackPanel::DrawOutside ( TrackPanelDrawingContext context,
Track t,
const wxRect &  rec 
)
protected

Definition at line 2381 of file TrackPanel.cpp.

References TrackPanelDrawingContext::dc, TrackInfo::DrawItems(), Track::GetKind(), Track::GetSelected(), kBottomMargin, kLeftInset, kLeftMargin, kTopInset, kTopMargin, kTrackInfoWidth, and Track::Wave.

Referenced by DrawEverythingElse().

2383 {
2384  auto dc = &context.dc;
2385  bool bIsWave = (t->GetKind() == Track::Wave);
2386 
2387  // Draw things that extend right of track control panel
2388  {
2389  // Start with whole track rect
2390  wxRect rect = rec;
2391  DrawOutsideOfTrack(context, t, rect);
2392 
2393  // Now exclude left, right, and top insets
2394  rect.x += kLeftInset;
2395  rect.y += kTopInset;
2396  rect.width -= kLeftInset * 2;
2397  rect.height -= kTopInset;
2398 
2399  int labelw = GetLabelWidth();
2400  int vrul = GetVRulerOffset();
2401  mTrackInfo.DrawBackground(dc, rect, t->GetSelected(), bIsWave, labelw, vrul);
2402 
2403  // Vaughan, 2010-08-24: No longer doing this.
2404  // Draw sync-lock tiles in ruler area.
2405  //if (t->IsSyncLockSelected()) {
2406  // wxRect tileFill = rect;
2407  // tileFill.x = GetVRulerOffset();
2408  // tileFill.width = GetVRulerWidth();
2409  // TrackArtist::DrawSyncLockTiles(dc, tileFill);
2410  //}
2411 
2412  DrawBordersAroundTrack(t, dc, rect, labelw, vrul);
2413  DrawShadow(t, dc, rect);
2414  }
2415 
2416  // Draw things within the track control panel
2417  wxRect rect = rec;
2418  rect.x += kLeftMargin;
2419  rect.width = kTrackInfoWidth - kLeftMargin;
2420  rect.y += kTopMargin;
2421  rect.height -= (kBottomMargin + kTopMargin);
2422 
2423  TrackInfo::DrawItems( context, rect, *t );
2424 
2425  //mTrackInfo.DrawBordersWithin( dc, rect, *t );
2426 }
int GetLabelWidth() const
Definition: TrackPanel.h:384
bool GetSelected() const
Definition: Track.h:276
static void DrawItems(TrackPanelDrawingContext &context, const wxRect &rect, const Track &track)
virtual int GetKind() const
Definition: Track.h:330
void DrawOutsideOfTrack(TrackPanelDrawingContext &context, Track *t, const wxRect &rect)
void DrawBordersAroundTrack(Track *t, wxDC *dc, const wxRect &rect, const int labelw, const int vrul)
TrackInfo mTrackInfo
Definition: TrackPanel.h:434
void DrawShadow(Track *t, wxDC *dc, const wxRect &rect)
void DrawBackground(wxDC *dc, const wxRect &rect, bool bSelected, bool bHasMuteSolo, const int labelw, const int vrul) const
int GetVRulerOffset() const
Definition: TrackPanel.h:381
void TrackPanel::DrawOutsideOfTrack ( TrackPanelDrawingContext context,
Track t,
const wxRect &  rect 
)
protected

Definition at line 2433 of file TrackPanel.cpp.

References TrackPanelDrawingContext::dc, Track::GetHeight(), Track::GetLinked(), kLeftInset, kShadowThickness, kTopInset, and AColor::TrackPanelBackground().

2434 {
2435  auto dc = &context.dc;
2436 
2437  // Fill in area outside of the track
2438  AColor::TrackPanelBackground(dc, false);
2439  wxRect side;
2440 
2441  // Area between panel border and left track border
2442  side = rect;
2443  side.width = kLeftInset;
2444  dc->DrawRectangle(side);
2445 
2446  // Area between panel border and top track border
2447  side = rect;
2448  side.height = kTopInset;
2449  dc->DrawRectangle(side);
2450 
2451  // Area between panel border and right track border
2452  side = rect;
2453  side.x += side.width - kTopInset;
2454  side.width = kTopInset;
2455  dc->DrawRectangle(side);
2456 
2457  // Area between tracks of stereo group
2458  if (t->GetLinked()) {
2459  // Paint the channel separator over (what would be) the shadow of the top
2460  // channel, and the top inset of the bottom channel
2461  side = rect;
2462  side.y += t->GetHeight() - kShadowThickness;
2463  side.height = kTopInset + kShadowThickness;
2464  dc->DrawRectangle(side);
2465  }
2466 }
static void TrackPanelBackground(wxDC *dc, bool selected)
Definition: AColor.cpp:349
bool GetLinked() const
Definition: Track.h:279
int GetHeight() const
Definition: Track.cpp:180
void TrackPanel::DrawShadow ( Track t,
wxDC *  dc,
const wxRect &  rect 
)
protected

Definition at line 2738 of file TrackPanel.cpp.

References AColor::Dark(), and AColor::Line().

2739 {
2740  int right = rect.x + rect.width - 1;
2741  int bottom = rect.y + rect.height - 1;
2742 
2743  // shadow color for lines
2744  dc->SetPen(*wxBLACK_PEN);
2745 
2746  // bottom
2747  AColor::Line(*dc, rect.x, bottom, right, bottom);
2748  // right
2749  AColor::Line(*dc, right, rect.y, right, bottom);
2750 
2751  // background color erases small parts of those lines
2752  AColor::Dark(dc, false);
2753 
2754  // bottom-left
2755  AColor::Line(*dc, rect.x, bottom, rect.x + 1, bottom);
2756  // top-right
2757  AColor::Line(*dc, right, rect.y, right, rect.y + 1);
2758 }
static void Dark(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:338
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:122
void TrackPanel::DrawTracks ( wxDC *  dc)
protected

Draw the actual track areas. We only draw the borders and the little buttons and menues and whatnot here, the actual contents of each track are drawn by the TrackArtist.

Definition at line 1810 of file TrackPanel.cpp.

References DrawEverythingElse(), drawTool, envelopeTool, AudacityProject::GetFirstVisible(), GetLabelWidth(), GetProject(), GetTracks(), ToolsToolBar::IsDown(), mLastMouseState, mListener, mTrackArtist, multiTool, mViewInfo, ViewInfo::selectedRegion, Target(), TrackPanelListener::TP_GetToolsToolBar(), and ZoomInfo::vpos.

Referenced by OnPaint().

1811 {
1812  wxRegion region = GetUpdateRegion();
1813 
1814  const wxRect clip = GetRect();
1815 
1816  wxRect panelRect = clip;
1817  panelRect.y = -mViewInfo->vpos;
1818 
1819  wxRect tracksRect = panelRect;
1820  tracksRect.x += GetLabelWidth();
1821  tracksRect.width -= GetLabelWidth();
1822 
1824  bool bMultiToolDown = pTtb->IsDown(multiTool);
1825  bool envelopeFlag = pTtb->IsDown(envelopeTool) || bMultiToolDown;
1826  bool bigPointsFlag = pTtb->IsDown(drawTool) || bMultiToolDown;
1827  bool sliderFlag = bMultiToolDown;
1828 
1829  TrackPanelDrawingContext context{ *dc, Target(), mLastMouseState };
1830 
1831  // The track artist actually draws the stuff inside each track
1832  auto first = GetProject()->GetFirstVisible();
1833  mTrackArtist->DrawTracks(context, GetTracks(), first.get(),
1834  region, tracksRect, clip,
1836  envelopeFlag, bigPointsFlag, sliderFlag);
1837 
1838  DrawEverythingElse(context, region, clip);
1839 }
int GetLabelWidth() const
Definition: TrackPanel.h:384
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
void DrawEverythingElse(TrackPanelDrawingContext &context, const wxRegion &region, const wxRect &clip)
UIHandlePtr Target()
Definition: TrackPanel.h:520
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
std::shared_ptr< Track > GetFirstVisible()
Definition: Project.cpp:2058
TrackPanelListener * mListener
Definition: TrackPanel.h:448
int vpos
Definition: ViewInfo.h:45
bool IsDown(int tool) const
std::unique_ptr< TrackArtist > mTrackArtist
Definition: TrackPanel.h:455
A kind of ToolBar with Tools on it.
Definition: ToolsToolBar.h:49
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
wxMouseState mLastMouseState
Definition: TrackPanel.h:485
virtual ToolsToolBar * TP_GetToolsToolBar()=0
void TrackPanel::EnsureVisible ( Track t)

Definition at line 2616 of file TrackPanel.cpp.

References TrackListIterator::First(), Track::GetHeight(), Track::GetLinked(), GetTracks(), mListener, mViewInfo, TrackListIterator::Next(), Refresh(), ViewInfo::scrollStep, SetFocusedTrack(), TrackPanelListener::TP_ScrollUpDown(), and ZoomInfo::vpos.

Referenced by AudacityProject::DoAddLabel(), AudacityProject::DoEffect(), AudacityProject::HandleMixAndRender(), AudacityProject::HandlePasteNothingSelected(), AudacityProject::OnFirstTrack(), AudacityProject::OnLastTrack(), OnMouseEvent(), AudacityProject::OnNewLabelTrack(), AudacityProject::OnNewStereoTrack(), AudacityProject::OnNewTimeTrack(), AudacityProject::OnNewWaveTrack(), AudacityProject::OnNextTrack(), AudacityProject::OnPaste(), AudacityProject::OnPasteNewLabel(), AudacityProject::OnPrevTrack(), AudacityProject::OnRedo(), AudacityProject::OnRemoveTracks(), AudacityProject::OnToggle(), AudacityProject::OnUndo(), and AudacityProject::ZoomAfterImport().

2617 {
2618  TrackListIterator iter(GetTracks());
2619  Track *it = NULL;
2620  Track *nt = NULL;
2621 
2622  SetFocusedTrack(t);
2623 
2624  int trackTop = 0;
2625  int trackHeight =0;
2626 
2627  for (it = iter.First(); it; it = iter.Next()) {
2628  trackTop += trackHeight;
2629  trackHeight = it->GetHeight();
2630 
2631  //find the second track if this is stereo
2632  if (it->GetLinked()) {
2633  nt = iter.Next();
2634  trackHeight += nt->GetHeight();
2635  }
2636  else {
2637  nt = it;
2638  }
2639 
2640  //We have found the track we want to ensure is visible.
2641  if ((it == t) || (nt == t)) {
2642 
2643  //Get the size of the trackpanel.
2644  int width, height;
2645  GetSize(&width, &height);
2646 
2647  if (trackTop < mViewInfo->vpos) {
2648  height = mViewInfo->vpos - trackTop + mViewInfo->scrollStep;
2649  height /= mViewInfo->scrollStep;
2650  mListener->TP_ScrollUpDown(-height);
2651  }
2652  else if (trackTop + trackHeight > mViewInfo->vpos + height) {
2653  height = (trackTop + trackHeight) - (mViewInfo->vpos + height);
2654  height = (height + mViewInfo->scrollStep + 1) / mViewInfo->scrollStep;
2655  mListener->TP_ScrollUpDown(height);
2656  }
2657 
2658  break;
2659  }
2660  }
2661  Refresh(false);
2662 }
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
bool GetLinked() const
Definition: Track.h:279
void SetFocusedTrack(Track *t)
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
int scrollStep
Definition: ViewInfo.h:177
TrackPanelListener * mListener
Definition: TrackPanel.h:448
int vpos
Definition: ViewInfo.h:45
An iterator for a TrackList.
Definition: Track.h:402
virtual bool TP_ScrollUpDown(int delta)=0
int GetHeight() const
Definition: Track.cpp:180
TrackPanel::FoundCell TrackPanel::FindCell ( int  mouseX,
int  mouseY 
)
protected

Determines which cell is under the mouse

Parameters
mouseX- mouse X position.
mouseY- mouse Y position.

Definition at line 2763 of file TrackPanel.cpp.

References Cells().

Referenced by HandleMotion(), and OnMouseEvent().

2764 {
2765  auto range = Cells();
2766  auto &iter = range.first, &end = range.second;
2767  auto prev = iter;
2768  while
2769  ( iter != end &&
2770  !(*iter).second.Contains( mouseX, mouseY ) )
2771  prev = iter++;
2772  if ( iter == end )
2773  // Default to the background cell, which is always last in the sequence,
2774  // even if it does not contain the point
2775  iter = prev;
2776  auto found = *iter;
2777  return {
2778  static_cast<CommonTrackPanelCell*>( found.first.get() )->FindTrack(),
2779  found.first,
2780  found.second
2781  };
2782 }
IteratorRange< TrackPanelCellIterator > Cells()
wxRect TrackPanel::FindTrackRect ( const Track target,
bool  label 
)

Definition at line 2787 of file TrackPanel.cpp.

References Track::GetHeight(), Track::GetLink(), Track::GetLinked(), GetVRulerOffset(), Track::GetY(), kBottomMargin, kLeftMargin, kRightMargin, kTopMargin, mViewInfo, and ZoomInfo::vpos.

Referenced by AudacityProject::DialogForLabelName(), GainSlider(), ScreenshotCommand::GetTrackRect(), OnTrackMenu(), and PanSlider().

2788 {
2789  if (!target) {
2790  return { 0, 0, 0, 0 };
2791  }
2792 
2793  wxRect rect{
2794  0,
2795  target->GetY() - mViewInfo->vpos,
2796  GetSize().GetWidth(),
2797  target->GetHeight()
2798  };
2799 
2800  // PRL: I think the following very old comment misused the term "race
2801  // condition" for a bug that happened with only a single thread. I think the
2802  // real problem referred to, was that this function could be reached, via
2803  // TrackPanelAx callbacks, during low-level operations while the TrackList
2804  // was not in a consistent state. Therefore GetLinked() did not imply
2805  // that GetLink() was not null.
2806  // Now the problem is fixed by delaying the handling of events generated
2807  // by TrackList.
2808 
2809  // Old comment:
2810  // The check for a null linked track is necessary because there's
2811  // a possible race condition between the time the 2 linked tracks
2812  // are added and when wxAccessible methods are called. This is
2813  // most evident when using Jaws.
2814  if (target->GetLinked() && target->GetLink()) {
2815  rect.height += target->GetLink()->GetHeight();
2816  }
2817 
2818  rect.x += kLeftMargin;
2819  if (label)
2820  rect.width = GetVRulerOffset() - kLeftMargin;
2821  else
2822  rect.width -= (kLeftMargin + kRightMargin);
2823 
2824  rect.y += kTopMargin;
2825  rect.height -= (kTopMargin + kBottomMargin);
2826 
2827  return rect;
2828 }
wxString label
Definition: Tags.cpp:727
bool GetLinked() const
Definition: Track.h:279
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
int vpos
Definition: ViewInfo.h:45
Track * GetLink() const
Definition: Track.cpp:269
int GetY() const
Definition: Track.cpp:154
int GetHeight() const
Definition: Track.cpp:180
int GetVRulerOffset() const
Definition: TrackPanel.h:381
LWSlider * TrackPanel::GainSlider ( const WaveTrack wt)

Definition at line 366 of file TrackPanel.cpp.

References FindTrackRect(), TrackInfo::GainSlider(), and TrackInfo::GetGainRect().

Referenced by AudacityProject::OnTrackGain(), AudacityProject::OnTrackGainDec(), and AudacityProject::OnTrackGainInc().

367 {
368  auto rect = FindTrackRect( wt, true );
369  wxRect sliderRect;
370  TrackInfo::GetGainRect( rect.GetTopLeft(), sliderRect );
371  return TrackInfo::GainSlider(sliderRect, wt, false, this);
372 }
wxRect FindTrackRect(const Track *target, bool label)
static void GetGainRect(const wxPoint &topLeft, wxRect &dest)
static LWSlider * GainSlider(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
TrackPanelAx& TrackPanel::GetAx ( )
inline

Definition at line 499 of file TrackPanel.h.

Referenced by EditCursorOverlay::Draw(), and AudacityProject::OnToggle().

499 { return *mAx; }
std::unique_ptr< TrackPanelAx > mAx
Definition: TrackPanel.h:495
std::shared_ptr< TrackPanelCell > TrackPanel::GetBackgroundCell ( )

Definition at line 2474 of file TrackPanel.cpp.

References mpBackground.

Referenced by TrackPanelCellIterator::operator++().

2475 {
2476  return mpBackground;
2477 }
std::shared_ptr< TrackPanelCell > mpBackground
Definition: TrackPanel.h:547
Track * TrackPanel::GetFirstSelectedTrack ( )

Definition at line 2592 of file TrackPanel.cpp.

References TrackListIterator::First(), Track::GetSelected(), GetTracks(), and TrackListIterator::Next().

Referenced by AudacityProject::DoEffect(), AudacityProject::OnRedo(), AudacityProject::OnUndo(), and AudacityProject::ZoomAfterImport().

2593 {
2594 
2595  TrackListIterator iter(GetTracks());
2596 
2597  Track * t;
2598  for ( t = iter.First();t!=NULL;t=iter.Next())
2599  {
2600  //Find the first selected track
2601  if(t->GetSelected())
2602  {
2603  return t;
2604  }
2605 
2606  }
2607  //if nothing is selected, return the first track
2608  t = iter.First();
2609 
2610  if(t)
2611  return t;
2612  else
2613  return NULL;
2614 }
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
bool GetSelected() const
Definition: Track.h:276
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
An iterator for a TrackList.
Definition: Track.h:402
Track * TrackPanel::GetFocusedTrack ( )
int TrackPanel::GetLabelWidth ( ) const
inline

Definition at line 384 of file TrackPanel.h.

Referenced by AudacityProject::DialogForLabelName(), DrawTracks(), GetInfoCommand::ExploreTrackPanel(), and GetMostRecentXPos().

int GetVRulerWidth() const
int GetTrackInfoWidth() const
TrackInfo mTrackInfo
Definition: TrackPanel.h:434
int TrackPanel::GetLeftOffset ( ) const
inline
TrackPanelListener* TrackPanel::GetListener ( )
inline

Definition at line 391 of file TrackPanel.h.

391 { return mListener;}
TrackPanelListener * mListener
Definition: TrackPanel.h:448
double TrackPanel::GetMostRecentXPos ( )

Definition at line 1744 of file TrackPanel.cpp.

References GetLabelWidth(), mMouseMostRecentX, mViewInfo, and ZoomInfo::PositionToTime().

Referenced by AudacityProject::OnPlayOneSecond(), and AudacityProject::OnPlayToSelection().

1745 {
1747 }
int GetLabelWidth() const
Definition: TrackPanel.h:384
int mMouseMostRecentX
Definition: TrackPanel.h:487
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ViewInfo.cpp:49
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
AudacityProject * TrackPanel::GetProject ( ) const

Gets the pointer to the AudacityProject that goes with this track panel.

Definition at line 433 of file TrackPanel.cpp.

Referenced by CancelDragging(), DrawEverythingElse(), DrawTracks(), HandleClick(), HandleWheelRotation(), IsAudioActive(), OnIdle(), OnMouseEvent(), OnTimer(), OnTrackListDeletion(), and TrackPanel().

434 {
435  //JKC casting away constness here.
436  //Do it in two stages in case 'this' is not a wxWindow.
437  //when the compiler will flag the error.
438  wxWindow const * const pConstWind = this;
439  wxWindow * pWind=(wxWindow*)pConstWind;
440 #ifdef EXPERIMENTAL_NOTEBOOK
441  pWind = pWind->GetParent(); //Page
442  wxASSERT( pWind );
443  pWind = pWind->GetParent(); //Notebook
444  wxASSERT( pWind );
445 #endif
446  pWind = pWind->GetParent(); //MainPanel
447  wxASSERT( pWind );
448  pWind = pWind->GetParent(); //Project
449  wxASSERT( pWind );
450  return (AudacityProject*)pWind;
451 }
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
AdornedRulerPanel* TrackPanel::GetRuler ( )
inline

Definition at line 392 of file TrackPanel.h.

392 { return mRuler;}
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
double TrackPanel::GetScreenEndTime ( ) const

Definition at line 548 of file TrackPanel.cpp.

References GetTracksUsableArea(), mViewInfo, and ZoomInfo::PositionToTime().

Referenced by AudacityProject::GetScreenEndTime(), HandlePageDownKey(), HandlePageUpKey(), AudacityProject::MoveWhenAudioInactive(), AudacityProject::OnBoundaryMove(), AudacityProject::ScrollingLowerBoundTime(), and AudacityProject::SeekWhenAudioInactive().

549 {
550  int width;
551  GetTracksUsableArea(&width, NULL);
552  return mViewInfo->PositionToTime(width, 0, true);
553 }
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ViewInfo.cpp:49
void GetTracksUsableArea(int *width, int *height) const
Definition: TrackPanel.cpp:421
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
size_t TrackPanel::GetSelectedTrackCount ( ) const

Definition at line 1048 of file TrackPanel.cpp.

References TrackListConstIterator::First(), GetTracks(), and TrackListConstIterator::Next().

1049 {
1050  size_t count = 0;
1051 
1053  for (auto t = iter.First(); t; t = iter.Next()) {
1054  count += t->GetSelected() ? 1:0;
1055  if( t->GetLinked() ){
1056  t = iter.Next();
1057  if( !t )
1058  break;
1059  }
1060  }
1061  return count;
1062 }
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
size_t TrackPanel::GetTrackCount ( ) const

Definition at line 1032 of file TrackPanel.cpp.

References TrackListConstIterator::First(), GetTracks(), and TrackListConstIterator::Next().

Referenced by TrackSelectHandle::Preview().

1033 {
1034  size_t count = 0;
1036  for (auto t = iter.First(); t; t = iter.Next()) {
1037  count += 1;
1038  if( t->GetLinked() ){
1039  t = iter.Next();
1040  if( !t )
1041  break;
1042  }
1043  }
1044  return count;
1045 }
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
TrackInfo* TrackPanel::GetTrackInfo ( )
inline

Definition at line 444 of file TrackPanel.h.

444 { return &mTrackInfo; }
TrackInfo mTrackInfo
Definition: TrackPanel.h:434
const TrackInfo* TrackPanel::GetTrackInfo ( ) const
inline

Definition at line 445 of file TrackPanel.h.

445 { return &mTrackInfo; }
TrackInfo mTrackInfo
Definition: TrackPanel.h:434
const TrackList* TrackPanel::GetTracks ( ) const
inline
TrackList* TrackPanel::GetTracks ( )
inline

Definition at line 389 of file TrackPanel.h.

389 { return mTracks.get(); }
std::shared_ptr< TrackList > mTracks
Definition: TrackPanel.h:450
void TrackPanel::GetTracksUsableArea ( int *  width,
int *  height 
) const
ViewInfo* TrackPanel::GetViewInfo ( )
inline

Definition at line 390 of file TrackPanel.h.

Referenced by TrackPanelCellIterator::UpdateRect().

390 { return mViewInfo;}
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
int TrackPanel::GetVRulerOffset ( ) const
inlineprotected

Definition at line 381 of file TrackPanel.h.

Referenced by DrawEverythingElse(), GetInfoCommand::ExploreTrackPanel(), FindTrackRect(), and UpdateTrackVRuler().

381 { return mTrackInfo.GetTrackInfoWidth(); }
int GetTrackInfoWidth() const
TrackInfo mTrackInfo
Definition: TrackPanel.h:434
int TrackPanel::GetVRulerWidth ( ) const
protected

Definition at line 2830 of file TrackPanel.cpp.

References vrulerSize.

Referenced by DrawEverythingElse(), GetInfoCommand::ExploreTrackPanel(), and UpdateTrackVRuler().

2831 {
2832  return vrulerSize.x;
2833 }
wxSize vrulerSize
Definition: TrackPanel.h:511
void TrackPanel::HandleClick ( const TrackPanelMouseEvent tpmEvent)
protected

Definition at line 1699 of file TrackPanel.cpp.

References RefreshCode::Cancelled, ClearTargets(), TrackPanelMouseEvent::event, GetProject(), HandleMotion(), mMouseOverUpdateFlags, mpClickedTrack, mRuler, mUIHandle, TrackPanelMouseEvent::pCell, TrackPanelMouseEvent::rect, and Target().

Referenced by OnMouseEvent().

1700 {
1701  auto pCell = tpmEvent.pCell;
1702  auto pTrack = static_cast<CommonTrackPanelCell *>( pCell.get() )->FindTrack();
1703 
1704  // Do hit test once more, in case the button really pressed was not the
1705  // one "anticipated."
1706  {
1707  TrackPanelMouseState tpmState{
1708  tpmEvent.event,
1709  tpmEvent.rect,
1710  tpmEvent.pCell
1711  };
1712  HandleMotion( tpmState );
1713  }
1714 
1715  mUIHandle = Target();
1716 
1717  if (mUIHandle) {
1718  // UIHANDLE CLICK
1719  // Make another shared pointer to the handle, in case recursive
1720  // event dispatching otherwise tries to delete the handle.
1721  auto handle = mUIHandle;
1722  UIHandle::Result refreshResult =
1723  handle->Click( tpmEvent, GetProject() );
1724  if (refreshResult & RefreshCode::Cancelled)
1725  mUIHandle.reset(), handle.reset(), ClearTargets();
1726  else {
1727  mpClickedTrack = pTrack;
1728 
1729  // Perhaps the clicked handle wants to update cursor and state message
1730  // after a click.
1731  TrackPanelMouseState tpmState{
1732  tpmEvent.event,
1733  tpmEvent.rect,
1734  tpmEvent.pCell
1735  };
1736  HandleMotion( tpmState );
1737  }
1738  ProcessUIHandleResult(
1739  this, mRuler, pTrack.get(), pTrack.get(), refreshResult);
1740  mMouseOverUpdateFlags |= refreshResult;
1741  }
1742 }
unsigned mMouseOverUpdateFlags
Definition: TrackPanel.h:517
UIHandlePtr Target()
Definition: TrackPanel.h:520
void ClearTargets()
Definition: TrackPanel.h:529
unsigned Result
Definition: UIHandle.h:37
UIHandlePtr mUIHandle
Definition: TrackPanel.h:545
std::shared_ptr< TrackPanelCell > pCell
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
std::weak_ptr< Track > mpClickedTrack
Definition: TrackPanel.h:544
void HandleMotion(wxMouseState &state, bool doHit=true)
Definition: TrackPanel.cpp:831
void TrackPanel::HandleCursorForPresentMouseState ( bool  doHit = true)

Definition at line 802 of file TrackPanel.cpp.

References HandleMotion().

Referenced by HandleEscapeKey(), HandleModifierKey(), AudacityProject::ModifyState(), OnKeyDown(), OnPlayback(), AudacityProject::PushState(), and AudacityProject::RefreshCursor().

803 {
804  // Come here on modifier key or mouse button transitions,
805  // or on starting or stopping of play or record,
806  // or change of toolbar button,
807  // and change the cursor appropriately.
808 
809  // Get the button and key states
810  auto state = ::wxGetMouseState();
811  // Remap the position
812  state.SetPosition(this->ScreenToClient(state.GetPosition()));
813 
814  HandleMotion( state, doHit );
815 }
void HandleMotion(wxMouseState &state, bool doHit=true)
Definition: TrackPanel.cpp:831
bool TrackPanel::HandleEscapeKey ( bool  down)

Definition at line 741 of file TrackPanel.cpp.

References CancelDragging(), ChangeTarget(), HandleCursorForPresentMouseState(), mUIHandle, and Target().

Referenced by OnKeyDown(), and OnKeyUp().

742 {
743  if (!down)
744  return false;
745 
746  {
747  auto target = Target();
748  if (target && target->HasEscape() && target->Escape()) {
750  return true;
751  }
752  }
753 
754  if (mUIHandle) {
755  CancelDragging();
756  return true;
757  }
758 
759  if (ChangeTarget(true, false)) {
761  return true;
762  }
763 
764  return false;
765 }
UIHandlePtr Target()
Definition: TrackPanel.h:520
UIHandlePtr mUIHandle
Definition: TrackPanel.h:545
bool CancelDragging()
Definition: TrackPanel.cpp:721
bool ChangeTarget(bool forward, bool cycle)
Definition: TrackPanel.cpp:978
void HandleCursorForPresentMouseState(bool doHit=true)
Definition: TrackPanel.cpp:802
void TrackPanel::HandleInterruptedDrag ( )

Definition at line 617 of file TrackPanel.cpp.

References mUIHandle.

Referenced by OnCaptureKey().

618 {
619  if (mUIHandle && mUIHandle->StopsOnKeystroke() ) {
620  // The bogus id isn't used anywhere, but may help with debugging.
621  // as this is sending a bogus mouse up. The mouse button is still actually down
622  // and may go up again.
623  const int idBogusUp = 2;
624  wxMouseEvent evt { wxEVT_LEFT_UP };
625  evt.SetId( idBogusUp );
626  evt.SetPosition(this->ScreenToClient(::wxGetMousePosition()));
627  this->ProcessEvent(evt);
628  }
629 }
UIHandlePtr mUIHandle
Definition: TrackPanel.h:545
void TrackPanel::HandleModifierKey ( )

Definition at line 787 of file TrackPanel.cpp.

References HandleCursorForPresentMouseState().

Referenced by OnKeyDown(), and OnKeyUp().

788 {
790 }
void HandleCursorForPresentMouseState(bool doHit=true)
Definition: TrackPanel.cpp:802
void TrackPanel::HandleMotion ( wxMouseState &  inState,
bool  doHit = true 
)
protected

TrackPanel::HandleMotion( ) sets the cursor drawn at the mouse location, and updates the status bar message. We treat certain other changes of mouse button and key state as "motions" too, and also starting and stopping of playback or recording, all of which may cause the appropriate cursor and message to change. As this procedure checks which region the mouse is over, it is appropriate to establish the message in the status bar.

Definition at line 831 of file TrackPanel.cpp.

References FindCell(), mLastMouseState, and UpdateMouseState().

Referenced by HandleClick(), HandleCursorForPresentMouseState(), OnMouseEvent(), and Uncapture().

832 {
833  UpdateMouseState( inState );
834 
835  const auto foundCell = FindCell( inState.m_x, inState.m_y );
836  auto &rect = foundCell.rect;
837  auto &pCell = foundCell.pCell;
838  const TrackPanelMouseState tpmState{ mLastMouseState, rect, pCell };
839  HandleMotion( tpmState, doHit );
840 }
void UpdateMouseState(const wxMouseState &state)
Definition: TrackPanel.cpp:767
FoundCell FindCell(int mouseX, int mouseY)
wxMouseState mLastMouseState
Definition: TrackPanel.h:485
void HandleMotion(wxMouseState &state, bool doHit=true)
Definition: TrackPanel.cpp:831
void TrackPanel::HandleMotion ( const TrackPanelMouseState tpmState,
bool  doHit = true 
)
protected

Definition at line 843 of file TrackPanel.cpp.

References _(), TrackPanelMouseState::pCell, and RefreshCode::RefreshNone.

844 {
845  auto handle = mUIHandle;
846 
847  auto newCell = tpmState.pCell;
848 
849  std::shared_ptr<Track> newTrack;
850  if ( newCell )
851  newTrack = static_cast<CommonTrackPanelCell*>( newCell.get() )->
852  FindTrack();
853 
854  wxString status{}, tooltip{};
855  wxCursor *pCursor{};
856  unsigned refreshCode = 0;
857 
858  if ( ! doHit ) {
859  // Dragging or not
860  handle = Target();
861 
862  // Assume cell does not change but target does
863  refreshCode = mMouseOverUpdateFlags;
865  }
866  else if ( !mUIHandle ) {
867  // Not yet dragging.
868 
869  auto oldCell = mLastCell.lock();
870  std::shared_ptr<Track> oldTrack;
871  if ( oldCell )
872  oldTrack = static_cast<CommonTrackPanelCell*>( oldCell.get() )->
873  FindTrack();
874 
875  unsigned updateFlags = mMouseOverUpdateFlags;
876 
877  // First check whether crossing cell to cell
878  if ( newCell == oldCell )
879  oldCell.reset();
880  else {
881  // Forget old targets
882  ClearTargets();
883  // Re-draw any highlighting
884  if (oldCell) {
885  ProcessUIHandleResult(
886  this, GetRuler(), oldTrack.get(), oldTrack.get(), updateFlags);
887  }
888  }
889 
890  auto oldHandle = Target();
891  auto oldPosition = mTarget;
892 
893  // Now do the
894  // UIHANDLE HIT TEST !
895  mTargets = newCell->HitTest(tpmState, GetProject());
896 
897  mTarget = 0;
898 
899  // Find the old target's NEW place if we can
900  if (oldHandle) {
901  auto begin = mTargets.begin(), end = mTargets.end(),
902  iter = std::find(begin, end, oldHandle);
903  if (iter != end) {
904  size_t newPosition = iter - begin;
905  if (newPosition <= oldPosition)
906  mTarget = newPosition;
907  // else, some NEW hit and this position takes priority
908  }
909  }
910 
911  handle = Target();
912 
913  mLastCell = newCell;
914 
915  if (!oldCell && oldHandle != handle)
916  // Did not move cell to cell, but did change the target
917  refreshCode = updateFlags;
918 
919  if (handle && handle != oldHandle)
920  handle->Enter(true);
921  }
922 
923  // UIHANDLE PREVIEW
924  // Update status message and cursor, whether dragging or not
925  if (handle) {
926  auto preview = handle->Preview( tpmState, GetProject() );
927  status = preview.message;
928  tooltip = preview.tooltip;
929  pCursor = preview.cursor;
930  auto code = handle->GetChangeHighlight();
931  handle->SetChangeHighlight(RefreshCode::RefreshNone);
932  refreshCode |= code;
933  mMouseOverUpdateFlags |= code;
934  }
935  if (!pCursor) {
936  static wxCursor defaultCursor{ wxCURSOR_ARROW };
937  pCursor = &defaultCursor;
938  }
939 
940  if (HasEscape())
941  /* i18n-hint Esc is a key on the keyboard */
942  status += wxT(" "), status += _("(Esc to cancel)");
944  if (tooltip != GetToolTipText()) {
945  // Unset first, by analogy with AButton
946  UnsetToolTip();
947  SetToolTip(tooltip);
948  }
949  if (pCursor)
950  SetCursor( *pCursor );
951 
952  ProcessUIHandleResult(
953  this, GetRuler(), newTrack.get(), newTrack.get(), refreshCode);
954 }
std::weak_ptr< TrackPanelCell > mLastCell
Definition: TrackPanel.h:514
unsigned mMouseOverUpdateFlags
Definition: TrackPanel.h:517
UIHandlePtr Target()
Definition: TrackPanel.h:520
void ClearTargets()
Definition: TrackPanel.h:529
UIHandlePtr mUIHandle
Definition: TrackPanel.h:545
virtual void TP_DisplayStatusMessage(const wxString &msg)=0
bool HasEscape()
Definition: TrackPanel.cpp:965
TrackPanelListener * mListener
Definition: TrackPanel.h:448
_("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
size_t mTarget
Definition: TrackPanel.h:516
std::shared_ptr< TrackPanelCell > pCell
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
std::vector< UIHandlePtr > mTargets
Definition: TrackPanel.h:515
AdornedRulerPanel * GetRuler()
Definition: TrackPanel.h:392
void TrackPanel::HandlePageDownKey ( )

Definition at line 797 of file TrackPanel.cpp.

References GetScreenEndTime(), mListener, and TrackPanelListener::TP_ScrollWindow().

Referenced by OnKeyDown().

798 {
800 }
double GetScreenEndTime() const
Definition: TrackPanel.cpp:548
virtual void TP_ScrollWindow(double scrollto)=0
TrackPanelListener * mListener
Definition: TrackPanel.h:448
void TrackPanel::HandlePageUpKey ( )

Definition at line 792 of file TrackPanel.cpp.

References GetScreenEndTime(), ZoomInfo::h, mListener, mViewInfo, and TrackPanelListener::TP_ScrollWindow().

Referenced by OnKeyDown().

793 {
795 }
double GetScreenEndTime() const
Definition: TrackPanel.cpp:548
virtual void TP_ScrollWindow(double scrollto)=0
double h
Definition: ViewInfo.h:47
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
TrackPanelListener * mListener
Definition: TrackPanel.h:448
void TrackPanel::HandleWheelRotation ( TrackPanelMouseEvent tpmEvent)

Handle mouse wheel rotation (for zoom in/out, vertical and horizontal scrolling)

Definition at line 1330 of file TrackPanel.cpp.

References TrackPanelMouseEvent::event, GetProject(), mRuler, TrackPanelMouseEvent::pCell, and TrackPanelMouseEvent::steps.

Referenced by OnMouseEvent().

1331 {
1332  auto pCell = tpmEvent.pCell;
1333  if (!pCell)
1334  return;
1335 
1336  auto &event = tpmEvent.event;
1337  double steps {};
1338 #if defined(__WXMAC__) && defined(EVT_MAGNIFY)
1339  // PRL:
1340  // Pinch and spread implemented in wxWidgets 3.1.0, or cherry-picked from
1341  // the future in custom build of 3.0.2
1342  if (event.Magnify()) {
1343  event.SetControlDown(true);
1344  steps = 2 * event.GetMagnification();
1345  }
1346  else
1347 #endif
1348  {
1349  steps = event.m_wheelRotation /
1350  (event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);
1351  }
1352 
1353  if(event.GetWheelAxis() == wxMOUSE_WHEEL_HORIZONTAL) {
1354  // Two-fingered horizontal swipe on mac is treated like shift-mousewheel
1355  event.SetShiftDown(true);
1356  // This makes the wave move in the same direction as the fingers, and the scrollbar
1357  // thumb moves oppositely
1358  steps *= -1;
1359  }
1360 
1361  tpmEvent.steps = steps;
1362 
1363  if(!event.HasAnyModifiers()) {
1364  // We will later un-skip if we do anything, but if we don't,
1365  // propagate the event up for the sake of the scrubber
1366  event.Skip();
1367  event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
1368  }
1369 
1370  unsigned result =
1371  pCell->HandleWheelRotation( tpmEvent, GetProject() );
1372  auto pTrack = static_cast<CommonTrackPanelCell*>(pCell.get())->FindTrack();
1373  ProcessUIHandleResult(
1374  this, mRuler, pTrack.get(), pTrack.get(), result);
1375 }
std::shared_ptr< TrackPanelCell > pCell
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
bool TrackPanel::HasEscape ( )
protected

Definition at line 965 of file TrackPanel.cpp.

References IsMouseCaptured(), mTarget, mTargets, and Target().

966 {
967  if (IsMouseCaptured())
968  return true;
969 
970  if (mTarget + 1 == mTargets.size() &&
971  Target() &&
972  !Target()->HasEscape())
973  return false;
974 
975  return mTargets.size() > 0;
976 }
bool IsMouseCaptured()
Determines if a modal tool is active.
UIHandlePtr Target()
Definition: TrackPanel.h:520
size_t mTarget
Definition: TrackPanel.h:516
std::vector< UIHandlePtr > mTargets
Definition: TrackPanel.h:515
bool TrackPanel::HasRotation ( )
protected

Definition at line 956 of file TrackPanel.cpp.

References mTargets, and Target().

Referenced by OnCaptureKey(), and OnKeyDown().

957 {
958  // Is there a nontrivial TAB key rotation?
959  if ( mTargets.size() > 1 )
960  return true;
961  auto target = Target();
962  return target && target->HasRotation();
963 }
UIHandlePtr Target()
Definition: TrackPanel.h:520
std::vector< UIHandlePtr > mTargets
Definition: TrackPanel.h:515
static bool TrackPanel::HasSoloButton ( )
inlinestatic

Definition at line 430 of file TrackPanel.h.

Referenced by TrackInfo::MuteAndSoloDrawFunction().

430 { return gSoloPref!=wxT("None");}
static wxString gSoloPref
Definition: TrackPanel.h:503
void TrackPanel::HighlightFocusedTrack ( wxDC *  dc,
const wxRect &  rect 
)
protected

Draw a three-level highlight gradient around the focused track.

Definition at line 2480 of file TrackPanel.cpp.

References kLeftInset, kTopInset, and AColor::TrackFocusPen().

Referenced by DrawEverythingElse().

2481 {
2482  wxRect theRect = rect;
2483  theRect.x += kLeftInset;
2484  theRect.y += kTopInset;
2485  theRect.width -= kLeftInset * 2;
2486  theRect.height -= kTopInset;
2487 
2488  dc->SetBrush(*wxTRANSPARENT_BRUSH);
2489 
2490  AColor::TrackFocusPen(dc, 0);
2491  dc->DrawRectangle(theRect.x - 1, theRect.y - 1, theRect.width + 2, theRect.height + 2);
2492 
2493  AColor::TrackFocusPen(dc, 1);
2494  dc->DrawRectangle(theRect.x - 2, theRect.y - 2, theRect.width + 4, theRect.height + 4);
2495 
2496  AColor::TrackFocusPen(dc, 2);
2497  dc->DrawRectangle(theRect.x - 3, theRect.y - 3, theRect.width + 6, theRect.height + 6);
2498 }
static void TrackFocusPen(wxDC *dc, int level)
Definition: AColor.cpp:384
bool TrackPanel::IsAudioActive ( )
protected

Definition at line 817 of file TrackPanel.cpp.

References GetProject(), and AudacityProject::IsAudioActive().

Referenced by OnTimer().

818 {
820  return p->IsAudioActive();
821 }
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
bool IsAudioActive() const
Definition: Project.cpp:1454
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
bool TrackPanel::IsMouseCaptured ( )

Determines if a modal tool is active.

Definition at line 1071 of file TrackPanel.cpp.

References mUIHandle.

Referenced by ChangeTarget(), HasEscape(), OnMouseEvent(), AudacityProject::OnRedo(), and AudacityProject::OnUndo().

1072 {
1073  return mUIHandle != NULL;
1074 }
UIHandlePtr mUIHandle
Definition: TrackPanel.h:545
void TrackPanel::MakeParentModifyState ( bool  bWantsAutoSave)
protected

Definition at line 607 of file TrackPanel.cpp.

References mListener, and TrackPanelListener::TP_ModifyState().

608 {
609  mListener->TP_ModifyState(bWantsAutoSave);
610 }
virtual void TP_ModifyState(bool bWantsAutoSave)=0
TrackPanelListener * mListener
Definition: TrackPanel.h:448
void TrackPanel::MakeParentRedrawScrollbars ( )

Definition at line 612 of file TrackPanel.cpp.

References mListener, and TrackPanelListener::TP_RedrawScrollbars().

Referenced by OnTimer().

613 {
615 }
virtual void TP_RedrawScrollbars()=0
TrackPanelListener * mListener
Definition: TrackPanel.h:448
void TrackPanel::MessageForScreenReader ( const wxString &  message)

Definition at line 1064 of file TrackPanel.cpp.

References mAx.

Referenced by AudacityProject::OnCursorClipBoundary(), AudacityProject::OnMoveToLabel(), AudacityProject::OnSelectClip(), and AudacityProject::OnSelectClipBoundary().

1065 {
1066  if (mAx)
1067  mAx->MessageForScreenReader(message);
1068 }
std::unique_ptr< TrackPanelAx > mAx
Definition: TrackPanel.h:495
void TrackPanel::OnCaptureKey ( wxCommandEvent &  event)

Definition at line 1377 of file TrackPanel.cpp.

References GetFocusedTrack(), HandleInterruptedDrag(), HasRotation(), mEnableTab, mRuler, and mViewInfo.

1378 {
1379  mEnableTab = false;
1380  wxKeyEvent *kevent = static_cast<wxKeyEvent *>(event.GetEventObject());
1381  const auto code = kevent->GetKeyCode();
1382  if ( WXK_ESCAPE != code )
1384 
1385  // TODO? Some notion of focused cell, more generally than focused tracks
1386 
1387  // Give focused track precedence
1388  Track * const t = GetFocusedTrack();
1389  if (t) {
1390  const unsigned refreshResult =
1391  ((TrackPanelCell*)t)->CaptureKey(*kevent, *mViewInfo, this);
1392  ProcessUIHandleResult(this, mRuler, t, t, refreshResult);
1393  event.Skip(kevent->GetSkipped());
1394  }
1395 
1396 #if 0
1397  // Special TAB key handling, but only if the track didn't capture it
1398  if ( !(t && !kevent->GetSkipped()) &&
1399  WXK_TAB == code && HasRotation() ) {
1400  // Override TAB navigation in wxWidgets, by not skipping
1401  event.Skip(false);
1402  mEnableTab = true;
1403  return;
1404  }
1405  else
1406 #endif
1407  if (!t)
1408  event.Skip();
1409 }
bool mEnableTab
Definition: TrackPanel.h:549
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void HandleInterruptedDrag()
Definition: TrackPanel.cpp:617
bool HasRotation()
Definition: TrackPanel.cpp:956
Track * GetFocusedTrack()
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
void TrackPanel::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Should handle the case when the mouse capture is lost.

Definition at line 1522 of file TrackPanel.cpp.

References ClearTargets(), kCaptureLostEventId, mMouseMostRecentX, mMouseMostRecentY, and OnMouseEvent().

1523 {
1524  ClearTargets();
1525 
1526  // This is bad. We are lying abou the event by saying it is a mouse up.
1527  wxMouseEvent e(wxEVT_LEFT_UP);
1528  e.SetId( kCaptureLostEventId );
1529 
1530  e.m_x = mMouseMostRecentX;
1531  e.m_y = mMouseMostRecentY;
1532 
1533  OnMouseEvent(e);
1534 }
int mMouseMostRecentX
Definition: TrackPanel.h:487
void ClearTargets()
Definition: TrackPanel.h:529
int mMouseMostRecentY
Definition: TrackPanel.h:488
const int kCaptureLostEventId
void OnMouseEvent(wxMouseEvent &event)
void TrackPanel::OnChar ( wxKeyEvent &  event)

Definition at line 1465 of file TrackPanel.cpp.

References GetFocusedTrack(), mRuler, and mViewInfo.

1466 {
1467  switch (event.GetKeyCode())
1468  {
1469  case WXK_ESCAPE:
1470  case WXK_ALT:
1471  case WXK_SHIFT:
1472  case WXK_CONTROL:
1473  case WXK_PAGEUP:
1474  case WXK_PAGEDOWN:
1475  return;
1476  }
1477 
1478  Track *const t = GetFocusedTrack();
1479  if (t) {
1480  const unsigned refreshResult =
1481  ((TrackPanelCell*)t)->Char(event, *mViewInfo, this);
1482  ProcessUIHandleResult(this, mRuler, t, t, refreshResult);
1483  }
1484  else
1485  event.Skip();
1486 }
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
Track * GetFocusedTrack()
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
void TrackPanel::OnContextMenu ( wxContextMenuEvent &  event)

Definition at line 1136 of file TrackPanel.cpp.

References OnTrackMenu().

1137 {
1138  OnTrackMenu();
1139 }
void OnTrackMenu(Track *t=NULL)
void TrackPanel::OnIdle ( wxIdleEvent &  event)

Definition at line 453 of file TrackPanel.cpp.

References GetProject(), kTimerInterval, and mTimer.

Referenced by TrackPanel().

454 {
455  // The window must be ready when the timer fires (#1401)
456  if (IsShownOnScreen())
457  {
458  mTimer.Start(kTimerInterval, FALSE);
459 
460  // Timer is started, we don't need the event anymore
461  GetProject()->Unbind(wxEVT_IDLE, &TrackPanel::OnIdle, this);
462  }
463  else
464  {
465  // Get another idle event, wx only guarantees we get one
466  // event after "some other normal events occur"
467  event.RequestMore();
468  }
469 }
TrackPanel::AudacityTimer mTimer
const int kTimerInterval
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
void OnIdle(wxIdleEvent &event)
Definition: TrackPanel.cpp:453
void TrackPanel::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1411 of file TrackPanel.cpp.

References ChangeTarget(), GetFocusedTrack(), HandleCursorForPresentMouseState(), HandleEscapeKey(), HandleModifierKey(), HandlePageDownKey(), HandlePageUpKey(), HasRotation(), mEnableTab, mRuler, and mViewInfo.

1412 {
1413  switch (event.GetKeyCode())
1414  {
1415  case WXK_ESCAPE:
1416  if(HandleEscapeKey(true))
1417  // Don't skip the event, eat it so that
1418  // AudacityApp does not also stop any playback.
1419  return;
1420  else
1421  break;
1422 
1423  case WXK_ALT:
1424  case WXK_SHIFT:
1425  case WXK_CONTROL:
1426 #ifdef __WXOSX__
1427  case WXK_RAW_CONTROL:
1428 #endif
1430  break;
1431 
1432  // Allow PageUp and PageDown keys to
1433  //scroll the Track Panel left and right
1434  case WXK_PAGEUP:
1435  HandlePageUpKey();
1436  return;
1437 
1438  case WXK_PAGEDOWN:
1440  return;
1441 
1442 #if 0
1443  case WXK_TAB:
1444  if ( mEnableTab && HasRotation() ) {
1445  ChangeTarget( !event.ShiftDown(), true );
1447  return;
1448  }
1449  else
1450  break;
1451 #endif
1452  }
1453 
1454  Track *const t = GetFocusedTrack();
1455 
1456  if (t) {
1457  const unsigned refreshResult =
1458  ((TrackPanelCell*)t)->KeyDown(event, *mViewInfo, this);
1459  ProcessUIHandleResult(this, mRuler, t, t, refreshResult);
1460  }
1461  else
1462  event.Skip();
1463 }
void HandlePageDownKey()
Definition: TrackPanel.cpp:797
void HandlePageUpKey()
Definition: TrackPanel.cpp:792
bool mEnableTab
Definition: TrackPanel.h:549
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
bool HandleEscapeKey(bool down)
Definition: TrackPanel.cpp:741
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
bool HasRotation()
Definition: TrackPanel.cpp:956
Track * GetFocusedTrack()
bool ChangeTarget(bool forward, bool cycle)
Definition: TrackPanel.cpp:978
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
void HandleCursorForPresentMouseState(bool doHit=true)
Definition: TrackPanel.cpp:802
void HandleModifierKey()
Definition: TrackPanel.cpp:787
void TrackPanel::OnKeyUp ( wxKeyEvent &  event)

Definition at line 1488 of file TrackPanel.cpp.

References GetFocusedTrack(), HandleEscapeKey(), HandleModifierKey(), mRuler, and mViewInfo.

1489 {
1490  bool didSomething = false;
1491  switch (event.GetKeyCode())
1492  {
1493  case WXK_ESCAPE:
1494  didSomething = HandleEscapeKey(false);
1495  break;
1496 
1497  case WXK_ALT:
1498  case WXK_SHIFT:
1499  case WXK_CONTROL:
1500 #ifdef __WXOSX__
1501  case WXK_RAW_CONTROL:
1502 #endif
1504  break;
1505  }
1506 
1507  if (didSomething)
1508  return;
1509 
1510  Track * const t = GetFocusedTrack();
1511  if (t) {
1512  const unsigned refreshResult =
1513  ((TrackPanelCell*)t)->KeyUp(event, *mViewInfo, this);
1514  ProcessUIHandleResult(this, mRuler, t, t, refreshResult);
1515  return;
1516  }
1517 
1518  event.Skip();
1519 }
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
bool HandleEscapeKey(bool down)
Definition: TrackPanel.cpp:741
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
Track * GetFocusedTrack()
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
void HandleModifierKey()
Definition: TrackPanel.cpp:787
void TrackPanel::OnKillFocus ( wxFocusEvent &  event)

Definition at line 2875 of file TrackPanel.cpp.

References AudacityProject::HasKeyboardCapture(), Refresh(), and AudacityProject::ReleaseKeyboard().

2876 {
2878  {
2880  }
2881  Refresh( false);
2882 }
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
static void ReleaseKeyboard(wxWindow *handler)
Definition: Project.cpp:5972
static bool HasKeyboardCapture(const wxWindow *handler)
Definition: Project.cpp:5943
void TrackPanel::OnMouseEvent ( wxMouseEvent &  event)

This handles just generic mouse events. Then, based on our current state, we forward the mouse events to various interested parties.

Definition at line 1539 of file TrackPanel.cpp.

References CancelDragging(), RefreshCode::Cancelled, ClearTargets(), EnsureVisible(), FindCell(), GetProject(), GetTracks(), HandleClick(), HandleMotion(), HandleWheelRotation(), IsMouseCaptured(), kTimerInterval, TrackList::Lock(), mLastMouseState, mMouseMostRecentX, mMouseMostRecentY, mMouseOverUpdateFlags, mpClickedTrack, mRuler, mTimer, mUIHandle, Uncapture(), and UpdateMouseState().

Referenced by OnCaptureLost().

1541 {
1542  const auto foundCell = FindCell( event.m_x, event.m_y );
1543  auto &rect = foundCell.rect;
1544  auto &pCell = foundCell.pCell;
1545  auto &pTrack = foundCell.pTrack;
1546 
1547  const auto size = GetSize();
1548  TrackPanelMouseEvent tpmEvent{ event, rect, size, pCell };
1549 
1550 #if defined(__WXMAC__) && defined(EVT_MAGNIFY)
1551  // PRL:
1552  // Pinch and spread implemented in wxWidgets 3.1.0, or cherry-picked from
1553  // the future in custom build of 3.0.2
1554  if (event.Magnify()) {
1555  HandleWheelRotation( tpmEvent );
1556  }
1557 #endif
1558 
1559  // If a mouse event originates from a keyboard context menu event then
1560  // event.GetPosition() == wxDefaultPosition. wxContextMenu events are handled in
1561  // TrackPanel::OnContextMenu(), and therefore associated mouse events are ignored here.
1562  // Not ignoring them was causing bug 613: the mouse events were interpreted as clicking
1563  // outside the tracks.
1564  if (event.GetPosition() == wxDefaultPosition && (event.RightDown() || event.RightUp())) {
1565  event.Skip();
1566  return;
1567  }
1568 
1569  if (event.m_wheelRotation != 0)
1570  HandleWheelRotation( tpmEvent );
1571 
1572  if (event.LeftDown() || event.LeftIsDown() || event.Moving()) {
1573  // Skip, even if we do something, so that the left click or drag
1574  // may have an additional effect in the scrubber.
1575  event.Skip();
1576  event.ResumePropagation(wxEVENT_PROPAGATE_MAX);
1577  }
1578 
1579  mMouseMostRecentX = event.m_x;
1580  mMouseMostRecentY = event.m_y;
1581 
1582  if (event.LeftDown()) {
1583  // The activate event is used to make the
1584  // parent window 'come alive' if it didn't have focus.
1585  wxActivateEvent e;
1586  GetParent()->GetEventHandler()->ProcessEvent(e);
1587 
1588  // wxTimers seem to be a little unreliable, so this
1589  // "primes" it to make sure it keeps going for a while...
1590 
1591  // When this timer fires, we call TrackPanel::OnTimer and
1592  // possibly update the screen for offscreen scrolling.
1593  mTimer.Stop();
1594  mTimer.Start(kTimerInterval, FALSE);
1595  }
1596 
1597  if (event.ButtonDown()) {
1598  SetFocus();
1599  }
1600 
1601  if (event.Leaving())
1602  {
1603  if ( !mUIHandle )
1604  ClearTargets();
1605 
1606  auto buttons =
1607  // Bug 1325: button state in Leaving events is unreliable on Mac.
1608  // Poll the global state instead.
1609  // event.ButtonIsDown(wxMOUSE_BTN_ANY);
1610  ::wxGetMouseState().ButtonIsDown(wxMOUSE_BTN_ANY);
1611 
1612  if(!buttons) {
1613  CancelDragging();
1614 
1615 #if defined(__WXMAC__)
1616 
1617  // We must install the cursor ourselves since the window under
1618  // the mouse is no longer this one and wx2.8.12 makes that check.
1619  // Should re-evaluate with wx3.
1620  wxSTANDARD_CURSOR->MacInstall();
1621 #endif
1622  }
1623  }
1624 
1625  if (mUIHandle) {
1626  auto pClickedTrack = GetTracks()->Lock(mpClickedTrack);
1627  if (event.Dragging()) {
1628  // UIHANDLE DRAG
1629  // copy shared_ptr for safety, as in HandleClick
1630  auto handle = mUIHandle;
1631  const UIHandle::Result refreshResult =
1632  handle->Drag( tpmEvent, GetProject() );
1633  ProcessUIHandleResult
1634  (this, mRuler, pClickedTrack.get(), pTrack.get(), refreshResult);
1635  mMouseOverUpdateFlags |= refreshResult;
1636  if (refreshResult & RefreshCode::Cancelled) {
1637  // Drag decided to abort itself
1638  mUIHandle.reset(), handle.reset(), ClearTargets();
1639  mpClickedTrack.reset();
1640  Uncapture( &event );
1641  }
1642  else {
1643  UpdateMouseState(event);
1644  TrackPanelMouseState tpmState{ mLastMouseState, rect, pCell };
1645  HandleMotion( tpmState );
1646  }
1647  }
1648  else if (event.ButtonUp()) {
1649  // UIHANDLE RELEASE
1650  unsigned moreFlags = mMouseOverUpdateFlags;
1651  UIHandle::Result refreshResult =
1652  mUIHandle->Release( tpmEvent, GetProject(), this );
1653  ProcessUIHandleResult
1654  (this, mRuler, pClickedTrack.get(), pTrack.get(),
1655  refreshResult | moreFlags);
1656  mUIHandle.reset(), ClearTargets();
1657  mpClickedTrack.reset();
1658  // will also Uncapture() below
1659  }
1660  }
1661  else if ( event.GetEventType() == wxEVT_MOTION )
1662  // Update status message and cursor, not during drag
1663  // consider it not a drag, even if button is down during motion, if
1664  // mUIHandle is null, as it becomes during interrupted drag
1665  // (e.g. by hitting space to play while dragging an envelope point)
1666  HandleMotion( event );
1667  else if ( event.ButtonDown() || event.ButtonDClick() )
1668  HandleClick( tpmEvent );
1669 
1670  if (event.ButtonDown() && IsMouseCaptured()) {
1671  if (!HasCapture())
1672  CaptureMouse();
1673  }
1674 
1675  //EnsureVisible should be called after the up-click.
1676  if (event.ButtonUp()) {
1677  Uncapture();
1678 
1679  wxRect rect;
1680 
1681  const auto foundCell = FindCell(event.m_x, event.m_y);
1682  auto t = foundCell.pTrack;
1683  if ( t )
1684  EnsureVisible(t.get());
1685  }
1686 }
1687 catch( ... )
1688 {
1689  // Abort any dragging, as if by hitting Esc
1690  if ( CancelDragging() )
1691  ;
1692  else {
1693  Uncapture();
1694  Refresh(false);
1695  }
1696  throw;
1697 }
void HandleClick(const TrackPanelMouseEvent &tpmEvent)
void Uncapture(wxMouseState *pState=nullptr)
Definition: TrackPanel.cpp:707
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
void EnsureVisible(Track *t)
int mMouseMostRecentX
Definition: TrackPanel.h:487
TrackPanel::AudacityTimer mTimer
unsigned mMouseOverUpdateFlags
Definition: TrackPanel.h:517
bool IsMouseCaptured()
Determines if a modal tool is active.
void ClearTargets()
Definition: TrackPanel.h:529
unsigned Result
Definition: UIHandle.h:37
UIHandlePtr mUIHandle
Definition: TrackPanel.h:545
const int kTimerInterval
bool CancelDragging()
Definition: TrackPanel.cpp:721
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
void UpdateMouseState(const wxMouseState &state)
Definition: TrackPanel.cpp:767
FoundCell FindCell(int mouseX, int mouseY)
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:734
void HandleWheelRotation(TrackPanelMouseEvent &tpmEvent)
Handle mouse wheel rotation (for zoom in/out, vertical and horizontal scrolling)
int mMouseMostRecentY
Definition: TrackPanel.h:488
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
wxMouseState mLastMouseState
Definition: TrackPanel.h:485
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
std::weak_ptr< Track > mpClickedTrack
Definition: TrackPanel.h:544
void HandleMotion(wxMouseState &state, bool doHit=true)
Definition: TrackPanel.cpp:831
void TrackPanel::OnPaint ( wxPaintEvent &  event)

AS: OnPaint( ) is called during the normal course of completing a repaint operation.

Definition at line 557 of file TrackPanel.cpp.

References BackedPanel::DisplayBitmap(), OverlayPanel::DrawOverlays(), DrawTracks(), BackedPanel::GetBackingDCForRepaint(), mLastDrawnSelectedRegion, mRefreshBacking, mViewInfo, BackedPanel::RepairBitmap(), and ViewInfo::selectedRegion.

558 {
560 
561 #if DEBUG_DRAW_TIMING
562  wxStopWatch sw;
563 #endif
564 
565  {
566  wxPaintDC dc(this);
567 
568  // Retrieve the damage rectangle
569  wxRect box = GetUpdateRegion().GetBox();
570 
571  // Recreate the backing bitmap if we have a full refresh
572  // (See TrackPanel::Refresh())
573  if (mRefreshBacking || (box == GetRect()))
574  {
575  // Reset (should a mutex be used???)
576  mRefreshBacking = false;
577 
578  // Redraw the backing bitmap
580 
581  // Copy it to the display
582  DisplayBitmap(dc);
583  }
584  else
585  {
586  // Copy full, possibly clipped, damage rectangle
587  RepairBitmap(dc, box.x, box.y, box.width, box.height);
588  }
589 
590  // Done with the clipped DC
591 
592  // Drawing now goes directly to the client area.
593  // DrawOverlays() may need to draw outside the clipped region.
594  // (Used to make a NEW, separate wxClientDC, but that risks flashing
595  // problems on Mac.)
596  dc.DestroyClippingRegion();
597  DrawOverlays(true, &dc);
598  }
599 
600 #if DEBUG_DRAW_TIMING
601  sw.Pause();
602  wxLogDebug(wxT("Total: %ld milliseconds"), sw.Time());
603  wxPrintf(wxT("Total: %ld milliseconds\n"), sw.Time());
604 #endif
605 }
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
SelectedRegion mLastDrawnSelectedRegion
Definition: TrackPanel.h:508
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
void DisplayBitmap(wxDC &dc)
Definition: BackedPanel.cpp:65
void RepairBitmap(wxDC &dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
Definition: BackedPanel.cpp:60
void DrawTracks(wxDC *dc)
void DrawOverlays(bool repaint_all, wxDC *pDC=nullptr)
wxDC & GetBackingDCForRepaint()
Definition: BackedPanel.cpp:35
bool mRefreshBacking
Definition: TrackPanel.h:475
void TrackPanel::OnPlayback ( wxCommandEvent &  e)

Definition at line 1098 of file TrackPanel.cpp.

References HandleCursorForPresentMouseState().

Referenced by TrackPanel().

1099 {
1100  e.Skip();
1101  // Starting or stopping of play or record affects some cursors.
1102  // Start or stop is in progress now, not completed; so delay the cursor
1103  // change until next idle time.
1104  CallAfter( [this] { HandleCursorForPresentMouseState(); } );
1105 }
void HandleCursorForPresentMouseState(bool doHit=true)
Definition: TrackPanel.cpp:802
void TrackPanel::OnSetFocus ( wxFocusEvent &  event)

Definition at line 2869 of file TrackPanel.cpp.

References GetFocusedTrack(), Refresh(), and SetFocusedTrack().

2870 {
2872  Refresh( false );
2873 }
void SetFocusedTrack(Track *t)
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
Track * GetFocusedTrack()
void TrackPanel::OnTimer ( wxTimerEvent &  event)

AS: This gets called on our wx timer events.

Definition at line 472 of file TrackPanel.cpp.

References DisplaySelection(), OverlayPanel::DrawOverlays(), AudacityProject::FixScrollbars(), gAudioIO, AudacityProject::GetAudioIOToken(), AudacityProject::GetControlToolBar(), AudioIO::GetNumCaptureChannels(), GetProject(), IsAudioActive(), AudioIO::IsAudioTokenActive(), AudioIO::IsStreamActive(), MakeParentRedrawScrollbars(), mLastDrawnSelectedRegion, mListener, mRedrawAfterStop, mRefreshBacking, mRuler, mTimeCount, mViewInfo, AudacityProject::RedrawProject(), Refresh(), ViewInfo::selectedRegion, AudacityProject::SetAudioIOToken(), ControlToolBar::StopPlaying(), TrackPanelListener::TP_ScrollUpDown(), and UpdateSelectionDisplay().

473 {
474 #ifdef __WXMAC__
475  // Unfortunate part of fix for bug 1431
476  // Without this, the toolbars hide only every other time that you press
477  // the yellow title bar button. For some reason, not every press sends
478  // us a deactivate event for the application.
479  {
480  auto project = GetProject();
481  if (project->IsIconized())
482  project->MacShowUndockedToolbars(false);
483  }
484 #endif
485 
486  mTimeCount++;
487 
488  AudacityProject *const p = GetProject();
489 
490  // Check whether we were playing or recording, but the stream has stopped.
491  if (p->GetAudioIOToken()>0 && !IsAudioActive())
492  {
493  //the stream may have been started up after this one finished (by some other project)
494  //in that case reset the buttons don't stop the stream
496  }
497 
498  // Next, check to see if we were playing or recording
499  // audio, but now Audio I/O is completely finished.
500  if (p->GetAudioIOToken()>0 &&
502  {
503  p->FixScrollbars();
504  p->SetAudioIOToken(0);
505  p->RedrawProject();
506 
507  mRedrawAfterStop = false;
508 
509  //ANSWER-ME: Was DisplaySelection added to solve a repaint problem?
511  }
514  }
515 
516  // Notify listeners for timer ticks
517  {
518  wxCommandEvent e(EVT_TRACK_PANEL_TIMER);
519  p->GetEventHandler()->ProcessEvent(e);
520  }
521 
522  DrawOverlays(false);
523  mRuler->DrawOverlays(false);
524 
526 
527  // Periodically update the display while recording
528 
529  if (!mRedrawAfterStop) {
530  mRedrawAfterStop = true;
532  mListener->TP_ScrollUpDown( 99999999 );
533  Refresh( false );
534  }
535  else {
536  if ((mTimeCount % 5) == 0) {
537  // Must tell OnPaint() to recreate the backing bitmap
538  // since we've not done a full refresh.
539  mRefreshBacking = true;
540  Refresh( false );
541  }
542  }
543  }
544  if(mTimeCount > 1000)
545  mTimeCount = 0;
546 }
void RedrawProject(const bool bForceWaveTracks=false)
Definition: Project.cpp:1378
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
bool IsStreamActive()
Returns true if the audio i/o is running at all, but not during cleanup.
Definition: AudioIO.cpp:2890
void DisplaySelection()
Displays the bounds of the selection in the status bar.
void SetAudioIOToken(int token)
Definition: Project.cpp:1449
unsigned GetNumCaptureChannels() const
Definition: AudioIO.h:399
SelectedRegion mLastDrawnSelectedRegion
Definition: TrackPanel.h:508
bool IsAudioTokenActive(int token)
Returns true if the stream is active, or even if audio I/O is busy cleaning up its data or writing to...
Definition: AudioIO.cpp:2909
void StopPlaying(bool stopStream=true)
int GetAudioIOToken() const
Definition: Project.cpp:1444
void UpdateSelectionDisplay()
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
void FixScrollbars()
Definition: Project.cpp:1896
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
bool IsAudioActive()
Definition: TrackPanel.cpp:817
void DrawOverlays(bool repaint_all, wxDC *pDC=nullptr)
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
TrackPanelListener * mListener
Definition: TrackPanel.h:448
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
int mTimeCount
Definition: TrackPanel.h:473
ControlToolBar * GetControlToolBar()
Definition: Project.cpp:5003
bool mRefreshBacking
Definition: TrackPanel.h:475
virtual bool TP_ScrollUpDown(int delta)=0
bool mRedrawAfterStop
Definition: TrackPanel.h:483
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
void MakeParentRedrawScrollbars()
Definition: TrackPanel.cpp:612
void TrackPanel::OnTrackListDeletion ( wxCommandEvent &  event)

Definition at line 1119 of file TrackPanel.cpp.

References GetFocusedTrack(), GetProject(), mUIHandle, and UpdateVRulerSize().

Referenced by TrackPanel().

1120 {
1121  if (mUIHandle) {
1122  // copy shared_ptr for safety, as in HandleClick
1123  auto handle = mUIHandle;
1124  handle->OnProjectChange(GetProject());
1125  }
1126 
1127  // If the focused track disappeared but there are still other tracks,
1128  // this reassigns focus.
1129  GetFocusedTrack();
1130 
1131  UpdateVRulerSize();
1132 
1133  e.Skip();
1134 }
UIHandlePtr mUIHandle
Definition: TrackPanel.h:545
Track * GetFocusedTrack()
AudacityProject * GetProject() const
Definition: TrackPanel.cpp:433
void UpdateVRulerSize()
void TrackPanel::OnTrackListResizing ( wxCommandEvent &  event)

Definition at line 1109 of file TrackPanel.cpp.

References UpdateVRuler().

Referenced by TrackPanel().

1110 {
1111  auto t = static_cast<TrackListEvent&>(e).mpTrack.lock();
1112  // A deleted track can trigger the event. In which case do nothing here.
1113  if( t )
1114  UpdateVRuler(t.get());
1115  e.Skip();
1116 }
TrackList is a flat linked list of tracks supporting Add, Remove, Clear, and Contains, plus serialization of the list of tracks.
Definition: Track.h:593
void UpdateVRuler(Track *t)
void TrackPanel::OnTrackMenu ( Track t = NULL)

Definition at line 2577 of file TrackPanel.cpp.

References FindTrackRect(), GetFocusedTrack(), Track::GetTrackControl(), and mRuler.

Referenced by OnContextMenu(), and AudacityProject::OnTrackMenu().

2578 {
2579  if(!t) {
2580  t = GetFocusedTrack();
2581  if(!t)
2582  return;
2583  }
2584 
2585  const auto pCell = t->GetTrackControl();
2586  const wxRect rect(FindTrackRect(t, true));
2587  const UIHandle::Result refreshResult =
2588  pCell->DoContextMenu(rect, this, NULL);
2589  ProcessUIHandleResult(this, mRuler, t, t, refreshResult);
2590 }
wxRect FindTrackRect(const Track *target, bool label)
unsigned Result
Definition: UIHandle.h:37
std::shared_ptr< TrackPanelCell > GetTrackControl()
Definition: TrackUI.cpp:81
Track * GetFocusedTrack()
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
LWSlider * TrackPanel::PanSlider ( const WaveTrack wt)

Definition at line 374 of file TrackPanel.cpp.

References FindTrackRect(), TrackInfo::GetPanRect(), and TrackInfo::PanSlider().

Referenced by AudacityProject::OnTrackPan(), AudacityProject::OnTrackPanLeft(), and AudacityProject::OnTrackPanRight().

375 {
376  auto rect = FindTrackRect( wt, true );
377  wxRect sliderRect;
378  TrackInfo::GetPanRect( rect.GetTopLeft(), sliderRect );
379  return TrackInfo::PanSlider(sliderRect, wt, false, this);
380 }
wxRect FindTrackRect(const Track *target, bool label)
static LWSlider * PanSlider(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
static void GetPanRect(const wxPoint &topLeft, wxRect &dest)
void TrackPanel::Refresh ( bool  eraseBackground = true,
const wxRect *  rect = (const wxRect *) NULL 
)
override

This method overrides Refresh() of wxWindow so that the boolean play indictaor can be set to false, so that an old play indicator that is no longer there won't get XORed (to erase it), thus redrawing it on the TrackPanel

Definition at line 1785 of file TrackPanel.cpp.

References DisplaySelection(), and mRefreshBacking.

Referenced by AudacityProject::AS_ModifySelection(), AudacityProject::AS_SetSelectionFormat(), WaveformPrefs::Commit(), AudacityProject::DoEffect(), AudacityProject::DoNextPeakFrequency(), AudacityProject::DoScroll(), AudacityProject::DoTrackMute(), AudacityProject::DoTrackSolo(), EnsureVisible(), AudacityProject::FixScrollbars(), AudacityProject::MoveTrack(), AudacityProject::MoveWhenAudioInactive(), AudacityProject::OnBoundaryMove(), AudacityProject::OnCopy(), AudacityProject::OnCopyLabels(), AudacityProject::OnCursorClipBoundary(), AudacityProject::OnCursorSelEnd(), AudacityProject::OnCursorSelStart(), AudacityProject::OnCursorTrackEnd(), AudacityProject::OnCursorTrackStart(), AudacityProject::OnCut(), OnKillFocus(), AudacityProject::OnNextTool(), AudacityProject::OnODTaskComplete(), AudacityProject::OnODTaskUpdate(), AudacityProject::OnPrevTool(), AudacityProject::OnRemoveTracks(), AudacityProject::OnSelectClip(), AudacityProject::OnSelectClipBoundary(), AudacityProject::OnSelectCursorEnd(), AudacityProject::OnSelectCursorStoredCursor(), AudacityProject::OnSelectionRestore(), AudacityProject::OnSelectStartCursor(), AudacityProject::OnSelectSyncLockSel(), AudacityProject::OnSelectTimeAndTracks(), AudacityProject::OnSelectTrackStartToEnd(), OnSetFocus(), AudacityProject::OnSetLeftSelection(), AudacityProject::OnSetRightSelection(), AudacityProject::OnShowClipping(), AudacityProject::OnSilence(), AudacityProject::OnSilenceLabels(), AudacityProject::OnSortName(), AudacityProject::OnSortTime(), AudacityProject::OnSplit(), AudacityProject::OnSyncLock(), OnTimer(), AudacityProject::PlaybackScroller::OnTimer(), SelectHandle::TimerHandler::OnTimer(), AudacityProject::OnToggleSpectralSelection(), AudacityProject::OnTrackClose(), AudacityProject::OnTrackMoveBottom(), AudacityProject::OnTrackMoveDown(), AudacityProject::OnTrackMoveTop(), AudacityProject::OnTrackMoveUp(), AudacityProject::OnZeroCrossing(), AudacityProject::OnZoomNormal(), AudacityProject::OnZoomToggle(), AudacityProject::OpenFile(), SpectrumPrefs::Preview(), AudacityProject::RedrawProject(), RefreshTrack(), AudacityProject::RemoveTrack(), SpectrumPrefs::Rollback(), ScrollIntoView(), AudacityProject::SeekWhenAudioInactive(), AudacityProject::SelectNone(), SetFocusedTrack(), AudacityProject::SetStateTo(), AudacityProject::SetSyncLock(), AudacityProject::SetTool(), AudacityProject::SkipEnd(), AudacityProject::SSBL_ModifySpectralSelection(), UpdatePrefs(), UpdateSelectionDisplay(), UpdateVRulerSize(), VerticalScroll(), and AudacityProject::ZoomInByFactor().

1787 {
1788  // Tell OnPaint() to refresh the backing bitmap.
1789  //
1790  // Originally I had the check within the OnPaint() routine and it
1791  // was working fine. That was until I found that, even though a full
1792  // refresh was requested, Windows only set the onscreen portion of a
1793  // window as damaged.
1794  //
1795  // So, if any part of the trackpanel was off the screen, full refreshes
1796  // didn't work and the display got corrupted.
1797  if( !rect || ( *rect == GetRect() ) )
1798  {
1799  mRefreshBacking = true;
1800  }
1801  wxWindow::Refresh(eraseBackground, rect);
1802  DisplaySelection();
1803 }
void DisplaySelection()
Displays the bounds of the selection in the status bar.
bool mRefreshBacking
Definition: TrackPanel.h:475
void TrackPanel::RefreshTrack ( Track trk,
bool  refreshbacking = true 
)

Definition at line 1749 of file TrackPanel.cpp.

References Track::GetHeight(), Track::GetLink(), Track::GetLinked(), Track::GetY(), kLeftInset, kRightInset, kShadowThickness, kTopInset, mRefreshBacking, mViewInfo, Refresh(), and ZoomInfo::vpos.

Referenced by AudacityProject::RefreshTPTrack(), AudacityProject::SetTrackGain(), and AudacityProject::SetTrackPan().

1750 {
1751  if (!trk)
1752  return;
1753 
1754  Track *link = trk->GetLink();
1755 
1756  if (link && !trk->GetLinked()) {
1757  trk = link;
1758  link = trk->GetLink();
1759  }
1760 
1761  // subtract insets and shadows from the rectangle, but not border
1762  // This matters because some separators do paint over the border
1763  wxRect rect(kLeftInset,
1764  -mViewInfo->vpos + trk->GetY() + kTopInset,
1765  GetRect().GetWidth() - kLeftInset - kRightInset - kShadowThickness,
1766  trk->GetHeight() - kTopInset - kShadowThickness);
1767 
1768  if (link) {
1769  rect.height += link->GetHeight();
1770  }
1771 
1772  if( refreshbacking )
1773  {
1774  mRefreshBacking = true;
1775  }
1776 
1777  Refresh( false, &rect );
1778 }
bool GetLinked() const
Definition: Track.h:279
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
int vpos
Definition: ViewInfo.h:45
Track * GetLink() const
Definition: Track.cpp:269
int GetY() const
Definition: Track.cpp:154
bool mRefreshBacking
Definition: TrackPanel.h:475
int GetHeight() const
Definition: Track.cpp:180
void TrackPanel::ScrollIntoView ( double  pos)

Definition at line 2558 of file TrackPanel.cpp.

References GetTracksUsableArea(), mListener, mViewInfo, ZoomInfo::OffsetTimeByPixels(), Refresh(), ZoomInfo::TimeToPosition(), and TrackPanelListener::TP_ScrollWindow().

Referenced by AudacityProject::HandlePasteText(), LabelTrack::KeyDown(), AudacityProject::MoveWhenAudioInactive(), AudacityProject::OnBoundaryMove(), AudacityProject::OnCursorClipBoundary(), AudacityProject::OnCursorSelEnd(), AudacityProject::OnCursorSelStart(), AudacityProject::OnCursorTrackEnd(), AudacityProject::OnCursorTrackStart(), AudacityProject::OnMoveToLabel(), AudacityProject::OnSelectClip(), ScrollIntoView(), AudacityProject::SeekWhenAudioInactive(), AudacityProject::SkipEnd(), and AudacityProject::ZoomInByFactor().

2559 {
2560  int w;
2561  GetTracksUsableArea( &w, NULL );
2562 
2563  int pixel = mViewInfo->TimeToPosition(pos);
2564  if (pixel < 0 || pixel >= w)
2565  {
2567  (mViewInfo->OffsetTimeByPixels(pos, -(w / 2)));
2568  Refresh(false);
2569  }
2570 }
double OffsetTimeByPixels(double time, wxInt64 offset, bool ignoreFisheye=false) const
Definition: ViewInfo.h:77
virtual void TP_ScrollWindow(double scrollto)=0
void GetTracksUsableArea(int *width, int *height) const
Definition: TrackPanel.cpp:421
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
wxInt64 TimeToPosition(double time, wxInt64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ViewInfo.cpp:59
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
TrackPanelListener * mListener
Definition: TrackPanel.h:448
void TrackPanel::ScrollIntoView ( int  x)

Definition at line 2572 of file TrackPanel.cpp.

References GetLeftOffset(), mViewInfo, ZoomInfo::PositionToTime(), and ScrollIntoView().

2573 {
2575 }
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ViewInfo.cpp:49
void ScrollIntoView(double pos)
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
int GetLeftOffset() const
Definition: TrackPanel.h:287
void TrackPanel::SetBackgroundCell ( const std::shared_ptr< TrackPanelCell > &  pCell)

Definition at line 2469 of file TrackPanel.cpp.

2470 {
2471  mpBackground = pCell;
2472 }
std::shared_ptr< TrackPanelCell > mpBackground
Definition: TrackPanel.h:547
void TrackPanel::SetFocusedTrack ( Track t)

Definition at line 2851 of file TrackPanel.cpp.

References AudacityProject::CaptureKeyboard(), AudacityProject::GetKeyboardCaptureHandler(), Track::GetLink(), Track::GetLinked(), mAx, Track::Pointer(), Refresh(), and AudacityProject::ReleaseKeyboard().

Referenced by SetTrackStatusCommand::ApplyInner(), EnsureVisible(), AudacityProject::HandleListSelection(), AudacityProject::HandleMixAndRender(), SelectHandle::MoveSnappingFreqSelection(), AudacityProject::OnFirstTrack(), LabelTrack::OnKeyDown(), AudacityProject::OnLastTrack(), AudacityProject::OnNextTrack(), AudacityProject::OnPrevTrack(), AudacityProject::OnRedo(), OnSetFocus(), WaveTrackMenuTable::OnSwapChannels(), AudacityProject::OnUndo(), AudacityProject::OpenFile(), AudacityProject::RemoveTrack(), and AudacityProject::SetStateTo().

2852 {
2853  // Make sure we always have the first linked track of a stereo track
2854  if (t && !t->GetLinked() && t->GetLink())
2855  t = (WaveTrack*)t->GetLink();
2856 
2857  if ( !mAx->SetFocus( Track::Pointer( t ) ) )
2858  return;
2859 
2862 
2863  if (t)
2865 
2866  Refresh( false );
2867 }
static void CaptureKeyboard(wxWindow *handler)
Definition: Project.cpp:5961
bool GetLinked() const
Definition: Track.h:279
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
static void ReleaseKeyboard(wxWindow *handler)
Definition: Project.cpp:5972
Track * GetLink() const
Definition: Track.cpp:269
std::unique_ptr< TrackPanelAx > mAx
Definition: TrackPanel.h:495
static std::shared_ptr< Subclass > Pointer(Track *t)
Definition: Track.h:137
static wxWindow * GetKeyboardCaptureHandler()
Definition: Project.cpp:5949
UIHandlePtr TrackPanel::Target ( )
inline

Definition at line 520 of file TrackPanel.h.

Referenced by ChangeTarget(), DrawEverythingElse(), DrawTracks(), HandleClick(), HandleEscapeKey(), HasEscape(), and HasRotation().

521  {
522  if (mTargets.size())
523  return mTargets[mTarget];
524  else
525  return {};
526  }
size_t mTarget
Definition: TrackPanel.h:516
std::vector< UIHandlePtr > mTargets
Definition: TrackPanel.h:515
void TrackPanel::Uncapture ( wxMouseState *  pState = nullptr)

Definition at line 707 of file TrackPanel.cpp.

References HandleMotion().

Referenced by CancelDragging(), and OnMouseEvent().

708 {
709  auto state = ::wxGetMouseState();
710  if (!pState) {
711  // Remap the position
712  state.SetPosition(this->ScreenToClient(state.GetPosition()));
713  pState = &state;
714  }
715 
716  if (HasCapture())
717  ReleaseMouse();
718  HandleMotion( *pState );
719 }
void HandleMotion(wxMouseState &state, bool doHit=true)
Definition: TrackPanel.cpp:831
void TrackPanel::UpdateAccessibility ( )

Definition at line 1025 of file TrackPanel.cpp.

References mAx.

Referenced by AudacityProject::DoTrackMute(), and AudacityProject::DoTrackSolo().

1026 {
1027  if (mAx)
1028  mAx->Updated();
1029 }
std::unique_ptr< TrackPanelAx > mAx
Definition: TrackPanel.h:495
void TrackPanel::UpdateMouseState ( const wxMouseState &  state)

Definition at line 767 of file TrackPanel.cpp.

References mLastMouseState.

Referenced by HandleMotion(), and OnMouseEvent().

768 {
769  mLastMouseState = state;
770 
771  // Simulate a down button if none, so hit test routines can anticipate
772  // which button will be clicked
773  if (!state.ButtonIsDown(wxMOUSE_BTN_ANY)) {
774 #ifdef __WXOSX__
775  if (state.RawControlDown())
776  // On Mac we can distinctly anticipate "right" click (as Control+click)
777  mLastMouseState.SetRightDown( true ),
778  mLastMouseState.SetLeftDown( false );
779  else
780 #endif
781  // Anticipate a left click by default
782  mLastMouseState.SetRightDown( false ),
783  mLastMouseState.SetLeftDown( true );
784  }
785 }
wxMouseState mLastMouseState
Definition: TrackPanel.h:485
void TrackPanel::UpdatePrefs ( )

Definition at line 394 of file TrackPanel.cpp.

References ViewInfo::bUpdateTrackIndicator, gPrefs, gSoloPref, mTrackArtist, mTrackInfo, mViewInfo, Refresh(), ViewInfo::UpdatePrefs(), TrackInfo::UpdatePrefs(), and UpdateVRulers().

Referenced by AudacityProject::OnShowClipping(), and AudacityProject::UpdatePrefs().

395 {
396  gPrefs->Read(wxT("/GUI/AutoScroll"), &mViewInfo->bUpdateTrackIndicator,
397  true);
398  gPrefs->Read(wxT("/GUI/Solo"), &gSoloPref, wxT("Simple"));
399 
401 
402  if (mTrackArtist) {
403  mTrackArtist->UpdatePrefs();
404  }
405 
406  // All vertical rulers must be recalculated since the minimum and maximum
407  // frequences may have been changed.
408  UpdateVRulers();
409 
411 
412  Refresh();
413 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
bool bUpdateTrackIndicator
Definition: ViewInfo.h:182
static wxString gSoloPref
Definition: TrackPanel.h:503
void UpdatePrefs()
Definition: ViewInfo.cpp:150
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
void UpdatePrefs()
TrackInfo mTrackInfo
Definition: TrackPanel.h:434
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
std::unique_ptr< TrackArtist > mTrackArtist
Definition: TrackPanel.h:455
void UpdateVRulers()
void TrackPanel::UpdateSelectionDisplay ( )
protected

Definition at line 1012 of file TrackPanel.cpp.

References DisplaySelection(), AdornedRulerPanel::DrawSelection(), mRuler, and Refresh().

Referenced by OnTimer().

1013 {
1014  // Full refresh since the label area may need to indicate
1015  // newly selected tracks.
1016  Refresh(false);
1017 
1018  // Make sure the ruler follows suit.
1019  mRuler->DrawSelection();
1020 
1021  // As well as the SelectionBar.
1022  DisplaySelection();
1023 }
void DisplaySelection()
Displays the bounds of the selection in the status bar.
void DrawSelection()
Definition: Ruler.cpp:3212
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
void TrackPanel::UpdateTrackVRuler ( const Track t)

Definition at line 2518 of file TrackPanel.cpp.

References Track::GetHeight(), Track::GetLink(), GetVRulerOffset(), GetVRulerWidth(), kBottomMargin, kTopMargin, and mTrackArtist.

Referenced by UpdateVRuler(), and UpdateVRulers().

2519 {
2520  wxASSERT(t);
2521  if (!t)
2522  return;
2523 
2524  wxRect rect(GetVRulerOffset(),
2525  kTopMargin,
2526  GetVRulerWidth(),
2527  t->GetHeight() - (kTopMargin + kBottomMargin));
2528 
2529  mTrackArtist->UpdateVRuler(t, rect);
2530  const Track *l = t->GetLink();
2531  if (l)
2532  {
2533  rect.height = l->GetHeight() - (kTopMargin + kBottomMargin);
2534  mTrackArtist->UpdateVRuler(l, rect);
2535  }
2536 }
int GetVRulerWidth() const
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
Track * GetLink() const
Definition: Track.cpp:269
std::unique_ptr< TrackArtist > mTrackArtist
Definition: TrackPanel.h:455
int GetHeight() const
Definition: Track.cpp:180
int GetVRulerOffset() const
Definition: TrackPanel.h:381
void TrackPanel::UpdateViewIfNoTracks ( )

Definition at line 1076 of file TrackPanel.cpp.

References ZoomInfo::GetDefaultZoom(), ZoomInfo::h, mListener, mTracks, mViewInfo, ViewInfo::selectedRegion, ZoomInfo::SetZoom(), TrackPanelListener::TP_DisplayStatusMessage(), TrackPanelListener::TP_HandleResize(), and TrackPanelListener::TP_RedrawScrollbars().

Referenced by AudacityProject::OnRemoveTracks(), and AudacityProject::OnTrackClose().

1077 {
1078  if (mTracks->empty())
1079  {
1080  // BG: There are no more tracks on screen
1081  //BG: Set zoom to normal
1083 
1084  //STM: Set selection to 0,0
1085  //PRL: and default the rest of the selection information
1087 
1088  // PRL: Following causes the time ruler to align 0 with left edge.
1089  // Bug 972
1090  mViewInfo->h = 0;
1091 
1094  mListener->TP_DisplayStatusMessage(wxT("")); //STM: Clear message if all tracks are removed
1095  }
1096 }
void SetZoom(double pixelsPerSecond)
Definition: ViewInfo.cpp:94
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
std::shared_ptr< TrackList > mTracks
Definition: TrackPanel.h:450
virtual void TP_HandleResize()=0
double h
Definition: ViewInfo.h:47
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
Defines a selected portion of a project.
virtual void TP_DisplayStatusMessage(const wxString &msg)=0
virtual void TP_RedrawScrollbars()=0
TrackPanelListener * mListener
Definition: TrackPanel.h:448
static double GetDefaultZoom()
Definition: ViewInfo.h:85
void TrackPanel::UpdateVRuler ( Track t)

Definition at line 2510 of file TrackPanel.cpp.

References UpdateTrackVRuler(), and UpdateVRulerSize().

Referenced by OnTrackListResizing().

2511 {
2512  if (t)
2513  UpdateTrackVRuler(t);
2514 
2515  UpdateVRulerSize();
2516 }
void UpdateTrackVRuler(const Track *t)
void UpdateVRulerSize()
void TrackPanel::UpdateVRulers ( )

Definition at line 2500 of file TrackPanel.cpp.

References TrackListCondIterator::First(), GetTracks(), TrackListCondIterator::Next(), UpdateTrackVRuler(), UpdateVRulerSize(), and Track::Wave.

Referenced by WaveformPrefs::Commit(), SpectrumPrefs::Preview(), SpectrumPrefs::Rollback(), and UpdatePrefs().

2501 {
2503  for (Track *t = iter.First(); t; t = iter.Next()) {
2504  UpdateTrackVRuler(t);
2505  }
2506 
2507  UpdateVRulerSize();
2508 }
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void UpdateTrackVRuler(const Track *t)
void UpdateVRulerSize()
void TrackPanel::UpdateVRulerSize ( )

Definition at line 2538 of file TrackPanel.cpp.

References TrackListIterator::First(), GetLeftOffset(), GetTracks(), mRuler, TrackListIterator::Next(), Refresh(), AdornedRulerPanel::SetLeftOffset(), Track::vrulerSize, and vrulerSize.

Referenced by OnTrackListDeletion(), UpdateVRuler(), and UpdateVRulers().

2539 {
2540  TrackListIterator iter(GetTracks());
2541  Track *t = iter.First();
2542  if (t) {
2543  wxSize s = t->vrulerSize;
2544  while (t) {
2545  s.IncTo(t->vrulerSize);
2546  t = iter.Next();
2547  }
2548  if (vrulerSize != s) {
2549  vrulerSize = s;
2550  mRuler->SetLeftOffset(GetLeftOffset()); // bevel on AdornedRuler
2551  mRuler->Refresh();
2552  }
2553  }
2554  Refresh(false);
2555 }
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
wxSize vrulerSize
Definition: TrackPanel.h:511
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
An iterator for a TrackList.
Definition: Track.h:402
int GetLeftOffset() const
Definition: TrackPanel.h:287
AdornedRulerPanel * mRuler
Definition: TrackPanel.h:453
wxSize vrulerSize
Definition: Track.h:176
void SetLeftOffset(int offset)
Definition: Ruler.cpp:3239
void TrackPanel::VerticalScroll ( float  fracPosition)

Definition at line 2666 of file TrackPanel.cpp.

References TrackListIterator::First(), Track::GetHeight(), Track::GetLinked(), GetTracks(), mListener, mViewInfo, TrackListIterator::Next(), Refresh(), ViewInfo::scrollStep, TrackPanelListener::TP_ScrollUpDown(), and ZoomInfo::vpos.

Referenced by AudacityProject::DoEffect().

2666  {
2667  TrackListIterator iter(GetTracks());
2668  Track *it = NULL;
2669  Track *nt = NULL;
2670 
2671  // Compute trackHeight
2672  int trackTop = 0;
2673  int trackHeight =0;
2674 
2675  for (it = iter.First(); it; it = iter.Next()) {
2676  trackTop += trackHeight;
2677  trackHeight = it->GetHeight();
2678 
2679  //find the second track if this is stereo
2680  if (it->GetLinked()) {
2681  nt = iter.Next();
2682  trackHeight += nt->GetHeight();
2683  }
2684  else {
2685  nt = it;
2686  }
2687  }
2688 
2689  int delta;
2690 
2691  //Get the size of the trackpanel.
2692  int width, height;
2693  GetSize(&width, &height);
2694 
2695  delta = (fracPosition * (trackTop + trackHeight - height)) - mViewInfo->vpos + mViewInfo->scrollStep;
2696  //wxLogDebug( "Scroll down by %i pixels", delta );
2697  delta /= mViewInfo->scrollStep;
2698  mListener->TP_ScrollUpDown(delta);
2699  Refresh(false);
2700 }
const TrackList * GetTracks() const
Definition: TrackPanel.h:388
bool GetLinked() const
Definition: Track.h:279
ViewInfo * mViewInfo
Definition: TrackPanel.h:451
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
int scrollStep
Definition: ViewInfo.h:177
TrackPanelListener * mListener
Definition: TrackPanel.h:448
int vpos
Definition: ViewInfo.h:45
An iterator for a TrackList.
Definition: Track.h:402
virtual bool TP_ScrollUpDown(int delta)=0
int GetHeight() const
Definition: Track.cpp:180

Friends And Related Function Documentation

friend class GetInfoCommand
friend

Definition at line 555 of file TrackPanel.h.

friend class ScreenshotCommand
friend

Definition at line 506 of file TrackPanel.h.

friend class TrackPanelAx
friend

Definition at line 490 of file TrackPanel.h.

Member Data Documentation

TrackPanel *(* TrackPanel::FactoryFunction)(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const std::shared_ptr< TrackList > &tracks, ViewInfo *viewInfo, TrackPanelListener *listener, AdornedRulerPanel *ruler) = TrackPanelFactory
static

Definition at line 395 of file TrackPanel.h.

Referenced by AudacityProject::AudacityProject().

wxString TrackPanel::gSoloPref
staticprotected

Definition at line 503 of file TrackPanel.h.

Referenced by UpdatePrefs().

std::unique_ptr<TrackPanelAx> TrackPanel::mAx
protected
bool TrackPanel::mEnableTab {}
protected

Definition at line 549 of file TrackPanel.h.

Referenced by OnCaptureKey(), and OnKeyDown().

std::weak_ptr<TrackPanelCell> TrackPanel::mLastCell
protected

Definition at line 514 of file TrackPanel.h.

SelectedRegion TrackPanel::mLastDrawnSelectedRegion {}
protected

Definition at line 508 of file TrackPanel.h.

Referenced by OnPaint(), and OnTimer().

wxMouseState TrackPanel::mLastMouseState
protected

Definition at line 485 of file TrackPanel.h.

Referenced by DrawTracks(), HandleMotion(), OnMouseEvent(), and UpdateMouseState().

TrackPanelListener* TrackPanel::mListener
protected
int TrackPanel::mMouseMostRecentX
protected

Definition at line 487 of file TrackPanel.h.

Referenced by GetMostRecentXPos(), OnCaptureLost(), and OnMouseEvent().

int TrackPanel::mMouseMostRecentY
protected

Definition at line 488 of file TrackPanel.h.

Referenced by OnCaptureLost(), and OnMouseEvent().

unsigned TrackPanel::mMouseOverUpdateFlags {}
protected

Definition at line 517 of file TrackPanel.h.

Referenced by CancelDragging(), HandleClick(), and OnMouseEvent().

std::shared_ptr<TrackPanelCell> TrackPanel::mpBackground
protected

Definition at line 547 of file TrackPanel.h.

Referenced by GetBackgroundCell().

std::weak_ptr<Track> TrackPanel::mpClickedTrack
protected

Definition at line 544 of file TrackPanel.h.

Referenced by CancelDragging(), HandleClick(), and OnMouseEvent().

bool TrackPanel::mRedrawAfterStop
protected

Definition at line 483 of file TrackPanel.h.

Referenced by OnTimer(), and TrackPanel().

bool TrackPanel::mRefreshBacking
protected

Definition at line 475 of file TrackPanel.h.

Referenced by OnPaint(), OnTimer(), Refresh(), and RefreshTrack().

AdornedRulerPanel* TrackPanel::mRuler
protected
size_t TrackPanel::mTarget {}
protected

Definition at line 516 of file TrackPanel.h.

Referenced by ChangeTarget(), and HasEscape().

std::vector<UIHandlePtr> TrackPanel::mTargets
protected

Definition at line 515 of file TrackPanel.h.

Referenced by ChangeTarget(), HasEscape(), and HasRotation().

int TrackPanel::mTimeCount
protected

Definition at line 473 of file TrackPanel.h.

Referenced by OnTimer(), and TrackPanel().

TrackPanel::AudacityTimer TrackPanel::mTimer
protected
std::unique_ptr<TrackArtist> TrackPanel::mTrackArtist
protected
TrackInfo TrackPanel::mTrackInfo
protected

Definition at line 434 of file TrackPanel.h.

Referenced by ApplyUpdatedTheme(), and UpdatePrefs().

std::shared_ptr<TrackList> TrackPanel::mTracks
protected

Definition at line 450 of file TrackPanel.h.

Referenced by TrackPanel(), and UpdateViewIfNoTracks().

UIHandlePtr TrackPanel::mUIHandle
protected
ViewInfo* TrackPanel::mViewInfo
protected
wxSize TrackPanel::vrulerSize

Definition at line 511 of file TrackPanel.h.

Referenced by GetVRulerWidth(), and UpdateVRulerSize().


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