Audacity  2.2.2
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
AdornedRulerPanel Class Referencefinal

This is an Audacity Specific ruler panel which additionally has border, selection markers, play marker. More...

#include <Ruler.h>

Inheritance diagram for AdornedRulerPanel:
CellularPanel OverlayPanel BackedPanel wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Classes

class  CommonRulerHandle
 
class  QPCell
 
class  QPHandle
 
class  QuickPlayIndicatorOverlay
 
class  QuickPlayRulerOverlay
 
class  ScrubbingCell
 
class  ScrubbingHandle
 

Public Member Functions

 AdornedRulerPanel (AudacityProject *project, wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, ViewInfo *viewinfo=NULL)
 
 ~AdornedRulerPanel ()
 
int GetRulerHeight ()
 
wxRect GetInnerRect () const
 
void SetLeftOffset (int offset)
 
void DrawSelection ()
 
void SetPlayRegion (double playRegionStart, double playRegionEnd)
 
void ClearPlayRegion ()
 
void GetPlayRegion (double *playRegionStart, double *playRegionEnd)
 
void GetMaxSize (wxCoord *width, wxCoord *height)
 
void InvalidateRuler ()
 
void UpdatePrefs ()
 
void ReCreateButtons ()
 
void RegenerateTooltips ()
 
void UpdateQuickPlayPos (wxCoord &mousePosX, bool shiftDown)
 
bool ShowingScrubRuler () const
 
void OnToggleScrubRuler ()
 
void OnToggleScrubRulerFromMenu (wxCommandEvent &)
 
void SetPanelSize ()
 
void DrawBothOverlays ()
 
void DoDrawIndicator (wxDC *dc, wxCoord xx, bool playing, int width, bool scrub, bool seek)
 
void UpdateButtonStates ()
 
AudacityProjectGetProject () const override
 
- Public Member Functions inherited from CellularPanel
 CellularPanel (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, ViewInfo *viewInfo, long style=wxTAB_TRAVERSAL|wxNO_BORDER)
 
 ~CellularPanel () override
 
UIHandlePtr Target ()
 
std::shared_ptr< TrackPanelCellLastCell () const
 
bool IsMouseCaptured ()
 Determines if a modal tool is active. More...
 
wxCoord MostRecentXCoord () const
 
void HandleCursorForPresentMouseState (bool doHit=true)
 
- 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)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static int GetRulerHeight (bool showScrubBar)
 

Private Types

enum  MenuChoice { MenuChoice::QuickPlay, MenuChoice::Scrub }
 
enum  MouseEventState {
  mesNone, mesDraggingPlayRegionStart, mesDraggingPlayRegionEnd, mesSelectingPlayRegionClick,
  mesSelectingPlayRegionRange
}
 

Private Member Functions

void OnRecordStartStop (wxCommandEvent &evt)
 
void OnPaint (wxPaintEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 
void UpdateRects ()
 
void HandleQPClick (wxMouseEvent &event, wxCoord mousePosX)
 
void HandleQPDrag (wxMouseEvent &event, wxCoord mousePosX)
 
void HandleQPRelease (wxMouseEvent &event)
 
void StartQPPlay (bool looped, bool cutPreview)
 
void DoDrawBackground (wxDC *dc)
 
void DoDrawEdge (wxDC *dc)
 
void DoDrawMarks (wxDC *dc, bool)
 
void DoDrawSelection (wxDC *dc)
 
void DoDrawPlayRegion (wxDC *dc)
 
void ShowContextMenu (MenuChoice choice, const wxPoint *pPosition)
 
double Pos2Time (int p, bool ignoreFisheye=false)
 
int Time2Pos (double t, bool ignoreFisheye=false)
 
bool IsWithinMarker (int mousePosX, double markerTime)
 
void ShowMenu (const wxPoint &pos)
 
void ShowScrubMenu (const wxPoint &pos)
 
void DragSelection ()
 
void HandleSnapping ()
 
void OnToggleQuickPlay (wxCommandEvent &evt)
 
void OnSyncSelToQuickPlay (wxCommandEvent &evt)
 
void OnTimelineToolTips (wxCommandEvent &evt)
 
void OnAutoScroll (wxCommandEvent &evt)
 
void OnLockPlayRegion (wxCommandEvent &evt)
 
void OnTogglePinnedState (wxCommandEvent &event)
 
FoundCell FindCell (int mouseX, int mouseY) override
 
wxRect FindRect (const TrackPanelCell &cell) override
 
TrackPanelCellGetFocusedCell () override
 
void SetFocusedCell () override
 
void ProcessUIHandleResult (TrackPanelCell *pClickedTrack, TrackPanelCell *pLatestCell, unsigned refreshResult) override
 
void UpdateStatusMessage (const wxString &) override
 
bool TakesFocus () const override
 
void CreateOverlays ()
 

Private Attributes

Ruler mRuler
 
AudacityProject *const mProject
 
TrackListmTracks
 
wxRect mOuter
 
wxRect mScrubZone
 
wxRect mInner
 
int mLeftOffset
 
double mIndTime
 
double mQuickPlayPosUnsnapped
 
double mQuickPlayPos
 
bool mIsSnapped
 
bool mPlayRegionLock
 
double mPlayRegionStart
 
double mPlayRegionEnd
 
double mOldPlayRegionStart
 
double mOldPlayRegionEnd
 
bool mIsRecording
 
bool mPlayRegionDragsSelection
 
bool mTimelineToolTip
 
bool mQuickPlayEnabled
 
MouseEventState mMouseEventState
 
double mLeftDownClickUnsnapped
 
double mLeftDownClick
 
bool mIsDragging
 
bool mShowScrubbing { false }
 
wxWindow * mButtons [3]
 
bool mNeedButtonUpdate { true }
 
std::unique_ptr
< QuickPlayIndicatorOverlay
mOverlay
 
std::shared_ptr< QPCellmQPCell
 
std::shared_ptr< ScrubbingCellmScrubbingCell
 

Additional Inherited Members

- Protected Member Functions inherited from CellularPanel
bool HasEscape ()
 
bool CancelDragging (bool escaping)
 
void DoContextMenu (TrackPanelCell *pCell=nullptr)
 
void ClearTargets ()
 
- Protected Attributes inherited from CellularPanel
ViewInfomViewInfo
 
wxMouseState mLastMouseState
 

Detailed Description

This is an Audacity Specific ruler panel which additionally has border, selection markers, play marker.

Once TrackPanel uses wxSizers, we will derive it from some wxWindow and the GetSize and SetSize functions will then be wxWidgets functions instead.

Definition at line 313 of file Ruler.h.

Member Enumeration Documentation

enum AdornedRulerPanel::MenuChoice
strongprivate
Enumerator
QuickPlay 
Scrub 

Definition at line 379 of file Ruler.h.

379 { QuickPlay, Scrub };
Enumerator
mesNone 
mesDraggingPlayRegionStart 
mesDraggingPlayRegionEnd 
mesSelectingPlayRegionClick 
mesSelectingPlayRegionRange 

Definition at line 433 of file Ruler.h.

Constructor & Destructor Documentation

AdornedRulerPanel::AdornedRulerPanel ( AudacityProject project,
wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
ViewInfo viewinfo = NULL 
)

Definition at line 2478 of file Ruler.cpp.

References _(), AudacityProject::GetTracks(), gPrefs, mButtons, mesNone, mIndTime, mIsDragging, mIsRecording, mIsSnapped, mLeftDownClick, mLeftOffset, mMouseEventState, mOldPlayRegionEnd, mOldPlayRegionStart, mOuter, mPlayRegionDragsSelection, mPlayRegionEnd, mPlayRegionLock, mPlayRegionStart, mQPCell, mQuickPlayEnabled, mRuler, mScrubbingCell, mTimelineToolTip, mTracks, CellularPanel::mViewInfo, OnRecordStartStop(), Ruler::SetFormat(), Ruler::SetLabelEdges(), Ruler::SetUseZoomInfo(), and Ruler::TimeFormat.

2484 : CellularPanel(parent, id, pos, size, viewinfo)
2485 , mProject(project)
2486 {
2487  mQPCell = std::make_shared<QPCell>( this );
2488  mScrubbingCell = std::make_shared<ScrubbingCell>( this );
2489 
2490  for (auto &button : mButtons)
2491  button = nullptr;
2492 
2493  SetLabel( _("Timeline") );
2494  SetName(GetLabel());
2495  SetBackgroundStyle(wxBG_STYLE_PAINT);
2496 
2497  mLeftOffset = 0;
2498  mIndTime = -1;
2499 
2500  mPlayRegionStart = -1;
2501  mPlayRegionLock = false;
2502  mPlayRegionEnd = -1;
2503  mOldPlayRegionStart = -1;
2504  mOldPlayRegionEnd = -1;
2505  mLeftDownClick = -1;
2507  mIsDragging = false;
2508 
2509  mOuter = GetClientRect();
2510 
2512  mRuler.SetLabelEdges( false );
2514 
2515  mTracks = project->GetTracks();
2516 
2517  mIsSnapped = false;
2518 
2519  mIsRecording = false;
2520 
2521  mTimelineToolTip = !!gPrefs->Read(wxT("/QuickPlay/ToolTips"), 1L);
2522  mPlayRegionDragsSelection = (gPrefs->Read(wxT("/QuickPlay/DragSelection"), 0L) == 1)? true : false;
2523  mQuickPlayEnabled = !!gPrefs->Read(wxT("/QuickPlay/QuickPlayEnabled"), 1L);
2524 
2525 #if wxUSE_TOOLTIPS
2526  wxToolTip::Enable(true);
2527 #endif
2528 
2529  wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
2531  this);
2532 }
bool mIsDragging
Definition: Ruler.h:444
bool mQuickPlayEnabled
Definition: Ruler.h:431
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
double mLeftDownClick
Definition: Ruler.h:443
ViewInfo * mViewInfo
bool mPlayRegionDragsSelection
Definition: Ruler.h:429
bool mIsSnapped
Definition: Ruler.h:404
Ruler mRuler
Definition: Ruler.h:389
double mOldPlayRegionStart
Definition: Ruler.h:409
std::shared_ptr< ScrubbingCell > mScrubbingCell
Definition: Ruler.h:489
wxRect mOuter
Definition: Ruler.h:393
MouseEventState mMouseEventState
Definition: Ruler.h:441
double mPlayRegionStart
Definition: Ruler.h:407
CellularPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, ViewInfo *viewInfo, long style=wxTAB_TRAVERSAL|wxNO_BORDER)
double mIndTime
Definition: Ruler.h:400
void SetLabelEdges(bool labelEdges)
Definition: Ruler.cpp:275
TrackList * mTracks
Definition: Ruler.h:391
bool mPlayRegionLock
Definition: Ruler.h:406
_("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
AudacityProject *const mProject
Definition: Ruler.h:390
void SetFormat(RulerFormat format)
Definition: Ruler.cpp:189
void OnRecordStartStop(wxCommandEvent &evt)
Definition: Ruler.cpp:2723
bool mTimelineToolTip
Definition: Ruler.h:430
void SetUseZoomInfo(int leftOffset, const ZoomInfo *zoomInfo)
Definition: Ruler.cpp:1607
wxWindow * mButtons[3]
Definition: Ruler.h:450
bool mIsRecording
Definition: Ruler.h:412
double mOldPlayRegionEnd
Definition: Ruler.h:410
TrackList * GetTracks()
Definition: Project.h:192
std::shared_ptr< QPCell > mQPCell
Definition: Ruler.h:486
double mPlayRegionEnd
Definition: Ruler.h:408
AdornedRulerPanel::~AdornedRulerPanel ( )

Definition at line 2534 of file Ruler.cpp.

2535 {
2536 }

Member Function Documentation

void AdornedRulerPanel::ClearPlayRegion ( )

Definition at line 3705 of file Ruler.cpp.

References AudacityProject::GetControlToolBar(), mPlayRegionEnd, mPlayRegionStart, mProject, and ControlToolBar::StopPlaying().

Referenced by HandleQPRelease().

3706 {
3708  ctb->StopPlaying();
3709 
3710  mPlayRegionStart = -1;
3711  mPlayRegionEnd = -1;
3712 
3713  Refresh();
3714 }
A ToolBar that has the main Transport buttons.
void StopPlaying(bool stopStream=true)
double mPlayRegionStart
Definition: Ruler.h:407
AudacityProject *const mProject
Definition: Ruler.h:390
ControlToolBar * GetControlToolBar()
Definition: Project.cpp:5015
double mPlayRegionEnd
Definition: Ruler.h:408
void AdornedRulerPanel::CreateOverlays ( )
private

Definition at line 3798 of file Ruler.cpp.

References mOverlay, and mProject.

Referenced by AdornedRulerPanel::QPCell::HitTest(), and AdornedRulerPanel::ScrubbingCell::HitTest().

3799 {
3800  if (!mOverlay)
3801  mOverlay =
3802  std::make_unique<QuickPlayIndicatorOverlay>( mProject );
3803 }
std::unique_ptr< QuickPlayIndicatorOverlay > mOverlay
Definition: Ruler.h:474
AudacityProject *const mProject
Definition: Ruler.h:390
void AdornedRulerPanel::DoDrawBackground ( wxDC *  dc)
private

Definition at line 3530 of file Ruler.cpp.

References mInner, mScrubZone, mShowScrubbing, and AColor::UseThemeColour().

Referenced by OnPaint().

3531 {
3532  // Draw AdornedRulerPanel border
3533  AColor::UseThemeColour( dc, clrTrackInfo );
3534  dc->DrawRectangle( mInner );
3535 
3536  if (mShowScrubbing) {
3537  // Let's distinguish the scrubbing area by using a themable
3538  // colour and a line to set it off.
3539  AColor::UseThemeColour(dc, clrScrubRuler, clrTrackPanelText );
3540  wxRect ScrubRect = mScrubZone;
3541  ScrubRect.Inflate( 1,0 );
3542  dc->DrawRectangle(ScrubRect);
3543  }
3544 }
wxRect mInner
Definition: Ruler.h:395
bool mShowScrubbing
Definition: Ruler.h:446
wxRect mScrubZone
Definition: Ruler.h:394
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1)
Definition: AColor.cpp:289
void AdornedRulerPanel::DoDrawEdge ( wxDC *  dc)
private

Definition at line 3546 of file Ruler.cpp.

References AColor::BevelTrackInfo(), BottomMargin, mOuter, and RightMargin.

Referenced by OnPaint().

3547 {
3548  wxRect r = mOuter;
3549  r.width -= RightMargin;
3550  r.height -= BottomMargin;
3551  AColor::BevelTrackInfo( *dc, true, r );
3552 
3553  // Black stroke at bottom
3554  dc->SetPen( *wxBLACK_PEN );
3555  dc->DrawLine( mOuter.x,
3556  mOuter.y + mOuter.height - 1,
3557  mOuter.x + mOuter.width,
3558  mOuter.y + mOuter.height - 1 );
3559 }
wxRect mOuter
Definition: Ruler.h:393
static void BevelTrackInfo(wxDC &dc, bool up, const wxRect &r, bool highlight=false)
Definition: AColor.cpp:262
void AdornedRulerPanel::DoDrawIndicator ( wxDC *  dc,
wxCoord  xx,
bool  playing,
int  width,
bool  scrub,
bool  seek 
)

Definition at line 3608 of file Ruler.cpp.

References ThemeBase::Bitmap(), TracksPrefs::GetPinnedHeadPreference(), AColor::IndicatorColor(), IndicatorHeightForWidth(), IndicatorOffset, and theTheme.

3609 {
3610  ADCChanger changer(dc); // Undo pen and brush changes at function exit
3611 
3612  AColor::IndicatorColor( dc, playing );
3613 
3614  wxPoint tri[ 3 ];
3615  if (seek) {
3616  auto height = IndicatorHeightForWidth(width);
3617  // Make four triangles
3618  const int TriangleWidth = width * 3 / 8;
3619 
3620  // Double-double headed, left-right
3621  auto yy = mShowScrubbing
3622  ? mScrubZone.y
3623  : (mInner.GetBottom() + 1) - 1 /* bevel */ - height;
3624  tri[ 0 ].x = xx - IndicatorOffset;
3625  tri[ 0 ].y = yy;
3626  tri[ 1 ].x = xx - IndicatorOffset;
3627  tri[ 1 ].y = yy + height;
3628  tri[ 2 ].x = xx - TriangleWidth;
3629  tri[ 2 ].y = yy + height / 2;
3630  dc->DrawPolygon( 3, tri );
3631 
3632  tri[ 0 ].x -= TriangleWidth;
3633  tri[ 1 ].x -= TriangleWidth;
3634  tri[ 2 ].x -= TriangleWidth;
3635  dc->DrawPolygon( 3, tri );
3636 
3637  tri[ 0 ].x = tri[ 1 ].x = xx + IndicatorOffset;
3638  tri[ 2 ].x = xx + TriangleWidth;
3639  dc->DrawPolygon( 3, tri );
3640 
3641 
3642  tri[ 0 ].x += TriangleWidth;
3643  tri[ 1 ].x += TriangleWidth;
3644  tri[ 2 ].x += TriangleWidth;
3645  dc->DrawPolygon( 3, tri );
3646  }
3647  else if (scrub) {
3648  auto height = IndicatorHeightForWidth(width);
3649  const int IndicatorHalfWidth = width / 2;
3650 
3651  // Double headed, left-right
3652  auto yy = mShowScrubbing
3653  ? mScrubZone.y
3654  : (mInner.GetBottom() + 1) - 1 /* bevel */ - height;
3655  tri[ 0 ].x = xx - IndicatorOffset;
3656  tri[ 0 ].y = yy;
3657  tri[ 1 ].x = xx - IndicatorOffset;
3658  tri[ 1 ].y = yy + height;
3659  tri[ 2 ].x = xx - IndicatorHalfWidth;
3660  tri[ 2 ].y = yy + height / 2;
3661  dc->DrawPolygon( 3, tri );
3662  tri[ 0 ].x = tri[ 1 ].x = xx + IndicatorOffset;
3663  tri[ 2 ].x = xx + IndicatorHalfWidth;
3664  dc->DrawPolygon( 3, tri );
3665  }
3666  else {
3667  bool pinned = TracksPrefs::GetPinnedHeadPreference();
3668  wxBitmap & bmp = theTheme.Bitmap( pinned ?
3669  (playing ? bmpPlayPointerPinned : bmpRecordPointerPinned) :
3670  (playing ? bmpPlayPointer : bmpRecordPointer)
3671  );
3672  const int IndicatorHalfWidth = bmp.GetWidth() / 2;
3673  dc->DrawBitmap( bmp, xx - IndicatorHalfWidth -1, mInner.y );
3674 #if 0
3675 
3676  // Down pointing triangle
3677  auto height = IndicatorHeightForWidth(width);
3678  const int IndicatorHalfWidth = width / 2;
3679  tri[ 0 ].x = xx - IndicatorHalfWidth;
3680  tri[ 0 ].y = mInner.y;
3681  tri[ 1 ].x = xx + IndicatorHalfWidth;
3682  tri[ 1 ].y = mInner.y;
3683  tri[ 2 ].x = xx;
3684  tri[ 2 ].y = mInner.y + height;
3685  dc->DrawPolygon( 3, tri );
3686 #endif
3687  }
3688 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxRect mInner
Definition: Ruler.h:395
static void IndicatorColor(wxDC *dc, bool bIsNotRecording)
Definition: AColor.cpp:367
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1244
bool mShowScrubbing
Definition: Ruler.h:446
int IndicatorHeightForWidth(int width)
Definition: Ruler.cpp:1719
wxRect mScrubZone
Definition: Ruler.h:394
static bool GetPinnedHeadPreference()
Makes temporary drawing context changes that you back out of, RAII style.
Definition: AColor.h:42
void AdornedRulerPanel::DoDrawMarks ( wxDC *  dc,
bool   
)
private

Definition at line 3561 of file Ruler.cpp.

References ThemeBase::Colour(), Ruler::Draw(), mInner, mRuler, Pos2Time(), Ruler::SetRange(), Ruler::SetTickColour(), and theTheme.

Referenced by OnPaint().

3562 {
3563  const double min = Pos2Time(0);
3564  const double hiddenMin = Pos2Time(0, true);
3565  const double max = Pos2Time(mInner.width);
3566  const double hiddenMax = Pos2Time(mInner.width, true);
3567 
3568  mRuler.SetTickColour( theTheme.Colour( clrTrackPanelText ) );
3569  mRuler.SetRange( min, max, hiddenMin, hiddenMax );
3570  mRuler.Draw( *dc );
3571 }
void Draw(wxDC &dc)
Definition: Ruler.cpp:1324
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxRect mInner
Definition: Ruler.h:395
Ruler mRuler
Definition: Ruler.h:389
int min(int a, int b)
void SetRange(double min, double max)
Definition: Ruler.cpp:237
void SetTickColour(const wxColour &colour)
Definition: Ruler.h:151
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
double Pos2Time(int p, bool ignoreFisheye=false)
Definition: Ruler.cpp:2838
void AdornedRulerPanel::DoDrawPlayRegion ( wxDC *  dc)
private

Definition at line 3453 of file Ruler.cpp.

References GetPlayRegion(), AudacityProject::IsPlayRegionLocked(), mInner, mProject, PLAY_REGION_GLOBAL_OFFSET_Y, PLAY_REGION_RECT_HEIGHT, PLAY_REGION_RECT_WIDTH, PLAY_REGION_TRIANGLE_SIZE, AColor::PlayRegionColor(), Time2Pos(), and TopMargin.

Referenced by OnPaint().

3454 {
3455  double start, end;
3456  GetPlayRegion(&start, &end);
3457 
3458  if (start >= 0)
3459  {
3460  const int x1 = Time2Pos(start);
3461  const int x2 = Time2Pos(end)-2;
3462  int y = mInner.y - TopMargin + mInner.height/2;
3463 
3464  bool isLocked = mProject->IsPlayRegionLocked();
3465  AColor::PlayRegionColor(dc, isLocked);
3466 
3467  wxPoint tri[3];
3468  wxRect r;
3469 
3470  tri[0].x = x1;
3471  tri[0].y = y + PLAY_REGION_GLOBAL_OFFSET_Y;
3472  tri[1].x = x1 + PLAY_REGION_TRIANGLE_SIZE;
3473  tri[1].y = y - PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3474  tri[2].x = x1 + PLAY_REGION_TRIANGLE_SIZE;
3475  tri[2].y = y + PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3476  dc->DrawPolygon(3, tri);
3477 
3478  r.x = x1;
3479  r.y = y - PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3480  r.width = PLAY_REGION_RECT_WIDTH;
3481  r.height = PLAY_REGION_TRIANGLE_SIZE*2 + 1;
3482  dc->DrawRectangle(r);
3483 
3484  if (end != start)
3485  {
3486  tri[0].x = x2;
3487  tri[0].y = y + PLAY_REGION_GLOBAL_OFFSET_Y;
3488  tri[1].x = x2 - PLAY_REGION_TRIANGLE_SIZE;
3489  tri[1].y = y - PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3490  tri[2].x = x2 - PLAY_REGION_TRIANGLE_SIZE;
3491  tri[2].y = y + PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3492  dc->DrawPolygon(3, tri);
3493 
3494  r.x = x2 - PLAY_REGION_RECT_WIDTH + 1;
3495  r.y = y - PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3496  r.width = PLAY_REGION_RECT_WIDTH;
3497  r.height = PLAY_REGION_TRIANGLE_SIZE*2 + 1;
3498  dc->DrawRectangle(r);
3499 
3500  r.x = x1 + PLAY_REGION_TRIANGLE_SIZE;
3502  r.width = std::max(0, x2-x1 - PLAY_REGION_TRIANGLE_SIZE*2);
3503  r.height = PLAY_REGION_RECT_HEIGHT;
3504  dc->DrawRectangle(r);
3505  }
3506  }
3507 }
static void PlayRegionColor(wxDC *dc, bool locked)
Definition: AColor.cpp:376
wxRect mInner
Definition: Ruler.h:395
#define PLAY_REGION_RECT_WIDTH
Definition: Ruler.cpp:111
int Time2Pos(double t, bool ignoreFisheye=false)
Definition: Ruler.cpp:2845
#define PLAY_REGION_GLOBAL_OFFSET_Y
Definition: Ruler.cpp:113
AudacityProject *const mProject
Definition: Ruler.h:390
#define PLAY_REGION_TRIANGLE_SIZE
Definition: Ruler.cpp:110
#define PLAY_REGION_RECT_HEIGHT
Definition: Ruler.cpp:112
bool IsPlayRegionLocked()
Definition: Project.h:213
void GetPlayRegion(double *playRegionStart, double *playRegionEnd)
Definition: Ruler.cpp:3716
void AdornedRulerPanel::DoDrawSelection ( wxDC *  dc)
private

Definition at line 3578 of file Ruler.cpp.

References ThemeBase::Colour(), min(), mInner, CellularPanel::mViewInfo, ViewInfo::selectedRegion, SelectedRegion::t0(), SelectedRegion::t1(), theTheme, and Time2Pos().

Referenced by OnPaint().

3579 {
3580  // Draw selection
3581  const int p0 = max(1, Time2Pos(mViewInfo->selectedRegion.t0()));
3582  const int p1 = min(mInner.width, Time2Pos(mViewInfo->selectedRegion.t1()));
3583 
3584  dc->SetBrush( wxBrush( theTheme.Colour( clrRulerBackground )) );
3585  dc->SetPen( wxPen( theTheme.Colour( clrRulerBackground )) );
3586 
3587  wxRect r;
3588  r.x = p0;
3589  r.y = mInner.y;
3590  r.width = p1 - p0 - 1;
3591  r.height = mInner.height;
3592  dc->DrawRectangle( r );
3593 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
ViewInfo * mViewInfo
double t0() const
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
wxRect mInner
Definition: Ruler.h:395
double t1() const
int min(int a, int b)
int Time2Pos(double t, bool ignoreFisheye=false)
Definition: Ruler.cpp:2845
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void AdornedRulerPanel::DragSelection ( )
private

Definition at line 3404 of file Ruler.cpp.

References mPlayRegionEnd, mPlayRegionStart, CellularPanel::mViewInfo, ViewInfo::selectedRegion, SelectedRegion::setT0(), and SelectedRegion::setT1().

Referenced by HandleQPDrag().

3405 {
3408 }
ViewInfo * mViewInfo
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
double mPlayRegionStart
Definition: Ruler.h:407
bool setT1(double t, bool maySwap=true)
bool setT0(double t, bool maySwap=true)
double mPlayRegionEnd
Definition: Ruler.h:408
void AdornedRulerPanel::DrawBothOverlays ( )

Definition at line 3272 of file Ruler.cpp.

References OverlayPanel::DrawOverlays(), AudacityProject::GetTrackPanel(), and mProject.

Referenced by ControlToolBar::PlayPlayRegion(), and Scrubber::StopScrubbing().

3273 {
3274  mProject->GetTrackPanel()->DrawOverlays( false );
3275  DrawOverlays( false );
3276 }
void DrawOverlays(bool repaint_all, wxDC *pDC=nullptr)
AudacityProject *const mProject
Definition: Ruler.h:390
TrackPanel * GetTrackPanel()
Definition: Project.h:307
void AdornedRulerPanel::DrawSelection ( )

Definition at line 3573 of file Ruler.cpp.

Referenced by TrackPanel::UpdateSelectionDisplay().

3574 {
3575  Refresh();
3576 }
auto AdornedRulerPanel::FindCell ( int  mouseX,
int  mouseY 
)
overrideprivatevirtual

Implements CellularPanel.

Definition at line 3738 of file Ruler.cpp.

3739 {
3740  bool mayScrub = mProject->GetScrubber().CanScrub() &&
3742  if (mayScrub && mScrubZone.Contains(mouseX, mouseY))
3743  return { mScrubbingCell, mScrubZone };
3744 
3745  if (mInner.Contains(mouseX, mouseY))
3746  return { mQPCell, mInner };
3747 
3748  return {};
3749 }
Scrubber & GetScrubber()
Definition: Project.h:804
wxRect mInner
Definition: Ruler.h:395
std::shared_ptr< ScrubbingCell > mScrubbingCell
Definition: Ruler.h:489
bool mShowScrubbing
Definition: Ruler.h:446
wxRect mScrubZone
Definition: Ruler.h:394
bool CanScrub() const
Definition: Scrubbing.cpp:1106
AudacityProject *const mProject
Definition: Ruler.h:390
std::shared_ptr< QPCell > mQPCell
Definition: Ruler.h:486
wxRect AdornedRulerPanel::FindRect ( const TrackPanelCell cell)
overrideprivatevirtual

Implements CellularPanel.

Definition at line 3751 of file Ruler.cpp.

References mInner, mQPCell, mScrubbingCell, and mScrubZone.

3752 {
3753  if (&cell == mScrubbingCell.get())
3754  return mScrubZone;
3755  if (&cell == mQPCell.get())
3756  return mInner;
3757 
3758  return {};
3759 }
wxRect mInner
Definition: Ruler.h:395
std::shared_ptr< ScrubbingCell > mScrubbingCell
Definition: Ruler.h:489
wxRect mScrubZone
Definition: Ruler.h:394
std::shared_ptr< QPCell > mQPCell
Definition: Ruler.h:486
TrackPanelCell * AdornedRulerPanel::GetFocusedCell ( )
overrideprivatevirtual

Implements CellularPanel.

Definition at line 3768 of file Ruler.cpp.

References mQPCell.

3769 {
3770  // No switching of focus yet to the other, scrub zone
3771  return mQPCell.get();
3772 }
std::shared_ptr< QPCell > mQPCell
Definition: Ruler.h:486
wxRect AdornedRulerPanel::GetInnerRect ( ) const
inline

Definition at line 328 of file Ruler.h.

328 { return mInner; }
wxRect mInner
Definition: Ruler.h:395
void AdornedRulerPanel::GetMaxSize ( wxCoord *  width,
wxCoord *  height 
)

Definition at line 3732 of file Ruler.cpp.

References Ruler::GetMaxSize(), and mRuler.

3733 {
3734  mRuler.GetMaxSize(width, height);
3735 }
Ruler mRuler
Definition: Ruler.h:389
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:1550
void AdornedRulerPanel::GetPlayRegion ( double *  playRegionStart,
double *  playRegionEnd 
)

Definition at line 3716 of file Ruler.cpp.

References mPlayRegionEnd, and mPlayRegionStart.

Referenced by DoDrawPlayRegion(), and AudacityProject::GetPlayRegion().

3718 {
3719  if (mPlayRegionStart >= 0 && mPlayRegionEnd >= 0 &&
3721  {
3722  // swap values to make sure end > start
3723  *playRegionStart = mPlayRegionEnd;
3724  *playRegionEnd = mPlayRegionStart;
3725  } else
3726  {
3727  *playRegionStart = mPlayRegionStart;
3728  *playRegionEnd = mPlayRegionEnd;
3729  }
3730 }
double mPlayRegionStart
Definition: Ruler.h:407
double mPlayRegionEnd
Definition: Ruler.h:408
AudacityProject * AdornedRulerPanel::GetProject ( ) const
overridevirtual

Implements CellularPanel.

Definition at line 3762 of file Ruler.cpp.

References mProject.

Referenced by UpdateStatusMessage().

3763 {
3764  return mProject;
3765 }
AudacityProject *const mProject
Definition: Ruler.h:390
int AdornedRulerPanel::GetRulerHeight ( )
inline
int AdornedRulerPanel::GetRulerHeight ( bool  showScrubBar)
static

Definition at line 3595 of file Ruler.cpp.

References ProperRulerHeight, and ScrubHeight.

3596 {
3597  return ProperRulerHeight + (showScrubBar ? ScrubHeight : 0);
3598 }
void AdornedRulerPanel::HandleQPClick ( wxMouseEvent &  event,
wxCoord  mousePosX 
)
private

Definition at line 2897 of file Ruler.cpp.

References IsWithinMarker(), mesDraggingPlayRegionEnd, mesDraggingPlayRegionStart, mesSelectingPlayRegionClick, mLeftDownClick, mLeftDownClickUnsnapped, mMouseEventState, mOldPlayRegionEnd, mOldPlayRegionStart, mPlayRegionEnd, mPlayRegionLock, mPlayRegionStart, mProject, mQuickPlayPos, mQuickPlayPosUnsnapped, AudacityProject::OnUnlockPlayRegion(), and Time2Pos().

Referenced by AdornedRulerPanel::QPHandle::Click().

2898 {
2899  // Temporarily unlock locked play region
2900  if (mPlayRegionLock && evt.LeftDown()) {
2901  //mPlayRegionLock = true;
2903  }
2904 
2907  bool isWithinStart = IsWithinMarker(mousePosX, mOldPlayRegionStart);
2908  bool isWithinEnd = IsWithinMarker(mousePosX, mOldPlayRegionEnd);
2909 
2910  if (isWithinStart || isWithinEnd) {
2911  // If Quick-Play is playing from a point, we need to treat it as a click
2912  // not as dragging.
2915  // otherwise check which marker is nearer
2916  else {
2917  // Don't compare times, compare positions.
2918  //if (fabs(mQuickPlayPos - mPlayRegionStart) < fabs(mQuickPlayPos - mPlayRegionEnd))
2922  else
2924  }
2925  }
2926  else {
2927  // Clicked but not yet dragging
2929  }
2930 }
double mLeftDownClick
Definition: Ruler.h:443
double mOldPlayRegionStart
Definition: Ruler.h:409
void OnUnlockPlayRegion(const CommandContext &context)
Definition: Menus.cpp:9247
MouseEventState mMouseEventState
Definition: Ruler.h:441
double mPlayRegionStart
Definition: Ruler.h:407
double mQuickPlayPos
Definition: Ruler.h:402
bool IsWithinMarker(int mousePosX, double markerTime)
Definition: Ruler.cpp:2853
int Time2Pos(double t, bool ignoreFisheye=false)
Definition: Ruler.cpp:2845
bool mPlayRegionLock
Definition: Ruler.h:406
AudacityProject *const mProject
Definition: Ruler.h:390
double mQuickPlayPosUnsnapped
Definition: Ruler.h:401
double mOldPlayRegionEnd
Definition: Ruler.h:410
double mLeftDownClickUnsnapped
Definition: Ruler.h:442
double mPlayRegionEnd
Definition: Ruler.h:408
void AdornedRulerPanel::HandleQPDrag ( wxMouseEvent &  event,
wxCoord  mousePosX 
)
private

Definition at line 2948 of file Ruler.cpp.

References DragSelection(), IsWithinMarker(), mesDraggingPlayRegionEnd, mesDraggingPlayRegionStart, mesNone, mesSelectingPlayRegionClick, mesSelectingPlayRegionRange, mIsDragging, mLeftDownClick, mLeftDownClickUnsnapped, mMouseEventState, mOldPlayRegionEnd, mOldPlayRegionStart, mPlayRegionDragsSelection, mPlayRegionEnd, mPlayRegionLock, mPlayRegionStart, and mQuickPlayPos.

Referenced by AdornedRulerPanel::QPHandle::Click(), and AdornedRulerPanel::QPHandle::Drag().

2949 {
2950  bool isWithinClick =
2951  (mLeftDownClickUnsnapped >= 0) &&
2953  bool isWithinStart = IsWithinMarker(mousePosX, mOldPlayRegionStart);
2954  bool isWithinEnd = IsWithinMarker(mousePosX, mOldPlayRegionEnd);
2955  bool canDragSel = !mPlayRegionLock && mPlayRegionDragsSelection;
2956 
2957  switch (mMouseEventState)
2958  {
2959  case mesNone:
2960  // If close to either end of play region, snap to closest
2961  if (isWithinStart || isWithinEnd) {
2964  else
2966  }
2967  break;
2969  // Don't start dragging until beyond tolerance initial playback start
2970  if (!mIsDragging && isWithinStart)
2972  else
2973  mIsDragging = true;
2974  // avoid accidental tiny selection
2975  if (isWithinEnd)
2978  if (canDragSel) {
2979  DragSelection();
2980  }
2981  break;
2983  if (!mIsDragging && isWithinEnd) {
2985  }
2986  else
2987  mIsDragging = true;
2988  if (isWithinStart) {
2990  }
2992  if (canDragSel) {
2993  DragSelection();
2994  }
2995  break;
2997 
2998  // Don't start dragging until mouse is beyond tolerance of initial click.
2999  if (isWithinClick || mLeftDownClick == -1) {
3003  }
3004  else {
3006  }
3007  break;
3009  if (isWithinClick) {
3011  }
3012 
3013  if (mQuickPlayPos < mLeftDownClick) {
3016  }
3017  else {
3020  }
3021  if (canDragSel) {
3022  DragSelection();
3023  }
3024  break;
3025  }
3026  Refresh();
3027  Update();
3028 }
bool mIsDragging
Definition: Ruler.h:444
double mLeftDownClick
Definition: Ruler.h:443
bool mPlayRegionDragsSelection
Definition: Ruler.h:429
double mOldPlayRegionStart
Definition: Ruler.h:409
MouseEventState mMouseEventState
Definition: Ruler.h:441
double mPlayRegionStart
Definition: Ruler.h:407
double mQuickPlayPos
Definition: Ruler.h:402
bool IsWithinMarker(int mousePosX, double markerTime)
Definition: Ruler.cpp:2853
bool mPlayRegionLock
Definition: Ruler.h:406
double mOldPlayRegionEnd
Definition: Ruler.h:410
void DragSelection()
Definition: Ruler.cpp:3404
double mLeftDownClickUnsnapped
Definition: Ruler.h:442
double mPlayRegionEnd
Definition: Ruler.h:408
void AdornedRulerPanel::HandleQPRelease ( wxMouseEvent &  event)
private

Definition at line 3109 of file Ruler.cpp.

References ClearPlayRegion(), TrackList::GetEndTime(), AudacityProject::GetSel0(), AudacityProject::GetSel1(), TrackList::GetStartTime(), mesNone, mIsDragging, mLeftDownClick, mMouseEventState, mOldPlayRegionEnd, mOldPlayRegionStart, mPlayRegionEnd, mPlayRegionLock, mPlayRegionStart, mProject, mTracks, AudacityProject::OnLockPlayRegion(), SetPlayRegion(), and StartQPPlay().

Referenced by AdornedRulerPanel::QPHandle::Release().

3110 {
3112  // Swap values to ensure mPlayRegionStart < mPlayRegionEnd
3113  double tmp = mPlayRegionStart;
3115  mPlayRegionEnd = tmp;
3116  }
3117 
3118  const double t0 = mTracks->GetStartTime();
3119  const double t1 = mTracks->GetEndTime();
3120  const double sel0 = mProject->GetSel0();
3121  const double sel1 = mProject->GetSel1();
3122 
3123  // We want some audio in the selection, but we allow a dragged
3124  // region to include selected white-space and space before audio start.
3125  if (evt.ShiftDown() && (mPlayRegionStart == mPlayRegionEnd)) {
3126  // Looping the selection or project.
3127  // Disable if track selection is in white-space beyond end of tracks and
3128  // play position is outside of track contents.
3129  if (((sel1 < t0) || (sel0 > t1)) &&
3130  ((mPlayRegionStart < t0) || (mPlayRegionStart > t1))) {
3131  ClearPlayRegion();
3132  }
3133  }
3134  // Disable if beyond end.
3135  else if (mPlayRegionStart >= t1) {
3136  ClearPlayRegion();
3137  }
3138  // Disable if empty selection before start.
3139  // (allow Quick-Play region to include 'pre-roll' white space)
3140  else if (((mPlayRegionEnd - mPlayRegionStart) > 0.0) && (mPlayRegionEnd < t0)) {
3141  ClearPlayRegion();
3142  }
3143 
3145  mIsDragging = false;
3146  mLeftDownClick = -1;
3147 
3148  auto cleanup = finally( [&] {
3149  if (mPlayRegionLock) {
3150  // Restore Locked Play region
3153  // and release local lock
3154  mPlayRegionLock = false;
3155  }
3156  } );
3157 
3158  StartQPPlay(evt.ShiftDown(), evt.ControlDown());
3159 }
bool mIsDragging
Definition: Ruler.h:444
double mLeftDownClick
Definition: Ruler.h:443
double GetSel0() const
Definition: Project.h:204
double GetStartTime() const
Definition: Track.cpp:1413
double mOldPlayRegionStart
Definition: Ruler.h:409
void OnLockPlayRegion(const CommandContext &context)
Definition: Menus.cpp:9233
double GetEndTime() const
Definition: Track.cpp:1418
MouseEventState mMouseEventState
Definition: Ruler.h:441
double mPlayRegionStart
Definition: Ruler.h:407
void StartQPPlay(bool looped, bool cutPreview)
Definition: Ruler.cpp:3184
void SetPlayRegion(double playRegionStart, double playRegionEnd)
Definition: Ruler.cpp:3690
void ClearPlayRegion()
Definition: Ruler.cpp:3705
TrackList * mTracks
Definition: Ruler.h:391
bool mPlayRegionLock
Definition: Ruler.h:406
AudacityProject *const mProject
Definition: Ruler.h:390
double mOldPlayRegionEnd
Definition: Ruler.h:410
double GetSel1() const
Definition: Project.h:205
double mPlayRegionEnd
Definition: Ruler.h:408
void AdornedRulerPanel::HandleSnapping ( )
private

Definition at line 3410 of file Ruler.cpp.

References mIsSnapped, mQPCell, mQuickPlayPos, mTracks, and CellularPanel::mViewInfo.

Referenced by UpdateQuickPlayPos().

3411 {
3412  auto handle = mQPCell->mHolder.lock();
3413  if (handle) {
3414  auto &pSnapManager = handle->mSnapManager;
3415  if (! pSnapManager)
3416  pSnapManager = std::make_unique<SnapManager>(mTracks, mViewInfo);
3417 
3418  auto results = pSnapManager->Snap(NULL, mQuickPlayPos, false);
3419  mQuickPlayPos = results.outTime;
3420  mIsSnapped = results.Snapped();
3421  }
3422 }
ViewInfo * mViewInfo
bool mIsSnapped
Definition: Ruler.h:404
double mQuickPlayPos
Definition: Ruler.h:402
TrackList * mTracks
Definition: Ruler.h:391
std::shared_ptr< QPCell > mQPCell
Definition: Ruler.h:486
void AdornedRulerPanel::InvalidateRuler ( )

Definition at line 2659 of file Ruler.cpp.

References Ruler::Invalidate(), and mRuler.

2660 {
2661  mRuler.Invalidate();
2662 }
Ruler mRuler
Definition: Ruler.h:389
void Invalidate()
Definition: Ruler.cpp:372
bool AdornedRulerPanel::IsWithinMarker ( int  mousePosX,
double  markerTime 
)
private

Definition at line 2853 of file Ruler.cpp.

References SELECT_TOLERANCE_PIXEL, and Time2Pos().

Referenced by HandleQPClick(), HandleQPDrag(), and AdornedRulerPanel::QPHandle::Preview().

2854 {
2855  if (markerTime < 0)
2856  return false;
2857 
2858  int pixelPos = Time2Pos(markerTime);
2859  int boundLeft = pixelPos - SELECT_TOLERANCE_PIXEL;
2860  int boundRight = pixelPos + SELECT_TOLERANCE_PIXEL;
2861 
2862  return mousePosX >= boundLeft && mousePosX < boundRight;
2863 }
#define SELECT_TOLERANCE_PIXEL
Definition: Ruler.cpp:108
int Time2Pos(double t, bool ignoreFisheye=false)
Definition: Ruler.cpp:2845
void AdornedRulerPanel::OnAutoScroll ( wxCommandEvent &  evt)
private

Definition at line 3432 of file Ruler.cpp.

References ViewInfo::bUpdateTrackIndicator, gPrefs, mProject, CellularPanel::mViewInfo, and AudacityProject::UpdatePrefs().

3433 {
3435  gPrefs->Write(wxT("/GUI/AutoScroll"), false);
3436  else
3437  gPrefs->Write(wxT("/GUI/AutoScroll"), true);
3438  mProject->UpdatePrefs();
3439  gPrefs->Flush();
3440 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
ViewInfo * mViewInfo
bool bUpdateTrackIndicator
Definition: ViewInfo.h:182
void UpdatePrefs()
Definition: Project.cpp:1347
AudacityProject *const mProject
Definition: Ruler.h:390
void AdornedRulerPanel::OnLockPlayRegion ( wxCommandEvent &  evt)
private

Definition at line 3443 of file Ruler.cpp.

References AudacityProject::IsPlayRegionLocked(), mProject, AudacityProject::OnLockPlayRegion(), and AudacityProject::OnUnlockPlayRegion().

3444 {
3447  else
3449 }
void OnLockPlayRegion(const CommandContext &context)
Definition: Menus.cpp:9233
void OnUnlockPlayRegion(const CommandContext &context)
Definition: Menus.cpp:9247
AudacityProject *const mProject
Definition: Ruler.h:390
bool IsPlayRegionLocked()
Definition: Project.h:213
void AdornedRulerPanel::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 2743 of file Ruler.cpp.

References BackedPanel::DisplayBitmap(), DoDrawBackground(), DoDrawEdge(), DoDrawMarks(), DoDrawPlayRegion(), DoDrawSelection(), OverlayPanel::DrawOverlays(), BackedPanel::GetBackingDCForRepaint(), SelectedRegion::isPoint(), mNeedButtonUpdate, CellularPanel::mViewInfo, ReCreateButtons(), ViewInfo::selectedRegion, and UpdatePrefs().

2744 {
2745  if (mNeedButtonUpdate) {
2746  // Visit this block once only in the lifetime of this panel
2747  mNeedButtonUpdate = false;
2748  // Do this first time setting of button status texts
2749  // when we are sure the CommandManager is initialized.
2750  ReCreateButtons();
2751  // Sends a resize event, which will cause a second paint.
2752  UpdatePrefs();
2753  }
2754 
2755  wxPaintDC dc(this);
2756 
2757  auto &backDC = GetBackingDCForRepaint();
2758 
2759  DoDrawBackground(&backDC);
2760 
2762  {
2763  DoDrawSelection(&backDC);
2764  }
2765 
2766  DoDrawMarks(&backDC, true);
2767 
2768  DoDrawPlayRegion(&backDC);
2769 
2770  DoDrawEdge(&backDC);
2771 
2772  DisplayBitmap(dc);
2773 
2774  // Stroke extras direct to the client area,
2775  // maybe outside of the damaged area
2776  // As with TrackPanel, do not make a NEW wxClientDC or else Mac flashes badly!
2777  dc.DestroyClippingRegion();
2778  DrawOverlays(true, &dc);
2779 }
ViewInfo * mViewInfo
bool isPoint() const
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
void DoDrawEdge(wxDC *dc)
Definition: Ruler.cpp:3546
void DoDrawMarks(wxDC *dc, bool)
Definition: Ruler.cpp:3561
void DoDrawBackground(wxDC *dc)
Definition: Ruler.cpp:3530
void DisplayBitmap(wxDC &dc)
Definition: BackedPanel.cpp:65
void DrawOverlays(bool repaint_all, wxDC *pDC=nullptr)
wxDC & GetBackingDCForRepaint()
Definition: BackedPanel.cpp:35
void DoDrawPlayRegion(wxDC *dc)
Definition: Ruler.cpp:3453
void ReCreateButtons()
Definition: Ruler.cpp:2585
bool mNeedButtonUpdate
Definition: Ruler.h:451
void DoDrawSelection(wxDC *dc)
Definition: Ruler.cpp:3578
void UpdatePrefs()
Definition: Ruler.cpp:2561
void AdornedRulerPanel::OnRecordStartStop ( wxCommandEvent &  evt)
private

Definition at line 2723 of file Ruler.cpp.

References CellularPanel::CancelDragging(), CellularPanel::ClearTargets(), mIsRecording, RegenerateTooltips(), and UpdateButtonStates().

Referenced by AdornedRulerPanel().

2724 {
2725  evt.Skip();
2726 
2727  if (evt.GetInt() != 0)
2728  {
2729  mIsRecording = true;
2730  this->CellularPanel::CancelDragging( false );
2732 
2734  }
2735  else {
2736  mIsRecording = false;
2738  }
2739 
2741 }
void RegenerateTooltips()
Definition: Ruler.cpp:2718
bool CancelDragging(bool escaping)
bool mIsRecording
Definition: Ruler.h:412
void UpdateButtonStates()
Definition: Ruler.cpp:3278
void AdornedRulerPanel::OnSize ( wxSizeEvent &  evt)
private

Definition at line 2781 of file Ruler.cpp.

References mOuter, BackedPanel::OnSize(), and UpdateRects().

2782 {
2783  mOuter = GetClientRect();
2784  if (mOuter.GetWidth() == 0 || mOuter.GetHeight() == 0)
2785  {
2786  return;
2787  }
2788 
2789  UpdateRects();
2790 
2791  OverlayPanel::OnSize(evt);
2792 }
void OnSize(wxSizeEvent &event)
Definition: BackedPanel.cpp:70
void UpdateRects()
Definition: Ruler.cpp:2794
wxRect mOuter
Definition: Ruler.h:393
void AdornedRulerPanel::OnSyncSelToQuickPlay ( wxCommandEvent &  evt)
private

Definition at line 3397 of file Ruler.cpp.

References gPrefs, and mPlayRegionDragsSelection.

3398 {
3400  gPrefs->Write(wxT("/QuickPlay/DragSelection"), mPlayRegionDragsSelection);
3401  gPrefs->Flush();
3402 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
bool mPlayRegionDragsSelection
Definition: Ruler.h:429
void AdornedRulerPanel::OnTimelineToolTips ( wxCommandEvent &  evt)
private

Definition at line 3424 of file Ruler.cpp.

References gPrefs, mTimelineToolTip, and RegenerateTooltips().

3425 {
3426  mTimelineToolTip = (mTimelineToolTip)? false : true;
3427  gPrefs->Write(wxT("/QuickPlay/ToolTips"), mTimelineToolTip);
3428  gPrefs->Flush();
3430 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void RegenerateTooltips()
Definition: Ruler.cpp:2718
bool mTimelineToolTip
Definition: Ruler.h:430
void AdornedRulerPanel::OnTogglePinnedState ( wxCommandEvent &  event)
private

Definition at line 3306 of file Ruler.cpp.

References mProject, AudacityProject::OnTogglePinnedHead(), and UpdateButtonStates().

3307 {
3310 }
void OnTogglePinnedHead(const CommandContext &context)
Definition: Menus.cpp:3001
AudacityProject *const mProject
Definition: Ruler.h:390
void UpdateButtonStates()
Definition: Ruler.cpp:3278
void AdornedRulerPanel::OnToggleQuickPlay ( wxCommandEvent &  evt)
private

Definition at line 3389 of file Ruler.cpp.

References gPrefs, mQuickPlayEnabled, and RegenerateTooltips().

3390 {
3391  mQuickPlayEnabled = (mQuickPlayEnabled)? false : true;
3392  gPrefs->Write(wxT("/QuickPlay/QuickPlayEnabled"), mQuickPlayEnabled);
3393  gPrefs->Flush();
3395 }
bool mQuickPlayEnabled
Definition: Ruler.h:431
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void RegenerateTooltips()
Definition: Ruler.cpp:2718
void AdornedRulerPanel::OnToggleScrubRuler ( )

Definition at line 3256 of file Ruler.cpp.

References gPrefs, mShowScrubbing, and SetPanelSize().

Referenced by Scrubber::OnToggleScrubRuler().

3257 {
3259  WriteScrubEnabledPref(mShowScrubbing);
3260  gPrefs->Flush();
3261  SetPanelSize();
3262 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
bool mShowScrubbing
Definition: Ruler.h:446
void SetPanelSize()
Definition: Ruler.cpp:3264
void AdornedRulerPanel::OnToggleScrubRulerFromMenu ( wxCommandEvent &  )

Definition at line 3250 of file Ruler.cpp.

References AudacityProject::GetScrubber(), mProject, and Scrubber::OnToggleScrubRuler().

3251 {
3252  auto &scrubber = mProject->GetScrubber();
3253  scrubber.OnToggleScrubRuler(*mProject);
3254 }
Scrubber & GetScrubber()
Definition: Project.h:804
void OnToggleScrubRuler(const CommandContext &)
Definition: Scrubbing.cpp:1041
AudacityProject *const mProject
Definition: Ruler.h:390
double AdornedRulerPanel::Pos2Time ( int  p,
bool  ignoreFisheye = false 
)
private

Definition at line 2838 of file Ruler.cpp.

References mLeftOffset, CellularPanel::mViewInfo, and ZoomInfo::PositionToTime().

Referenced by DoDrawMarks(), and UpdateQuickPlayPos().

2839 {
2841  , ignoreFisheye
2842  );
2843 }
ViewInfo * mViewInfo
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ViewInfo.cpp:49
void AdornedRulerPanel::ProcessUIHandleResult ( TrackPanelCell pClickedTrack,
TrackPanelCell pLatestCell,
unsigned  refreshResult 
)
overrideprivatevirtual

Implements CellularPanel.

Definition at line 3781 of file Ruler.cpp.

References RefreshCode::DrawOverlays.

3783 {
3784  if (refreshResult & RefreshCode::DrawOverlays)
3785  DrawBothOverlays();
3786 }
void DrawBothOverlays()
Definition: Ruler.cpp:3272
void AdornedRulerPanel::ReCreateButtons ( )

Definition at line 2585 of file Ruler.cpp.

References ThemeBase::Colour(), GetRulerHeight(), ThemeBase::ImageSize(), ToolBar::MakeAlternateImages(), ToolBar::MakeButton(), mButtons, min(), safenew, Grabber::SetAsSpacer(), theTheme, and UpdateButtonStates().

Referenced by Theme::ApplyUpdatedImages(), and OnPaint().

2586 {
2587  // TODO: Should we do this to destroy the grabber??
2588  // Get rid of any children we may have
2589  // DestroyChildren();
2590 
2591  SetBackgroundColour(theTheme.Colour( clrMedium ));
2592 
2593  for (auto & button : mButtons) {
2594  if (button)
2595  button->Destroy();
2596  button = nullptr;
2597  }
2598 
2599  size_t iButton = 0;
2600  // Make the short row of time ruler pushbottons.
2601  // Don't bother with sizers. Their sizes and positions are fixed.
2602  // Add a grabber converted to a spacer.
2603  // This makes it visually clearer that the button is a button.
2604 
2605  wxPoint position( 1, 0 );
2606 
2607  Grabber * pGrabber = safenew Grabber(this, this->GetId());
2608  pGrabber->SetAsSpacer( true );
2609  //pGrabber->SetSize( 10, 27 ); // default is 10,27
2610  pGrabber->SetPosition( position );
2611 
2612  position.x = 12;
2613 
2614  auto size = theTheme.ImageSize( bmpRecoloredUpSmall );
2615  size.y = std::min(size.y, GetRulerHeight(false));
2616 
2617  auto buttonMaker = [&]
2618  (wxWindowID id, teBmps bitmap, bool toggle)
2619  {
2620  const auto button =
2622  this,
2623  bmpRecoloredUpSmall, bmpRecoloredDownSmall,
2624  bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
2625  bitmap, bitmap, bitmap,
2626  id, position, toggle, size
2627  );
2628 
2629  position.x += size.GetWidth();
2630  mButtons[iButton++] = button;
2631  return button;
2632  };
2633  auto button = buttonMaker(OnTogglePinnedStateID, bmpPlayPointerPinned, true);
2635  *button, 3,
2636  bmpRecoloredUpSmall, bmpRecoloredDownSmall,
2637  bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
2638  //bmpUnpinnedPlayHead, bmpUnpinnedPlayHead, bmpUnpinnedPlayHead,
2639  bmpRecordPointer, bmpRecordPointer, bmpRecordPointer,
2640  size);
2642  *button, 2,
2643  bmpRecoloredUpSmall, bmpRecoloredDownSmall,
2644  bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
2645  //bmpUnpinnedPlayHead, bmpUnpinnedPlayHead, bmpUnpinnedPlayHead,
2646  bmpRecordPointerPinned, bmpRecordPointerPinned, bmpRecordPointerPinned,
2647  size);
2649  *button, 1,
2650  bmpRecoloredUpSmall, bmpRecoloredDownSmall,
2651  bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
2652  //bmpUnpinnedPlayHead, bmpUnpinnedPlayHead, bmpUnpinnedPlayHead,
2653  bmpPlayPointer, bmpPlayPointer, bmpPlayPointer,
2654  size);
2655 
2657 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
int GetRulerHeight()
Definition: Ruler.h:326
int teBmps
Definition: Theme.h:28
wxSize ImageSize(int iIndex)
Definition: Theme.cpp:1257
static AButton * MakeButton(wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
Definition: ToolBar.cpp:768
#define safenew
Definition: Audacity.h:230
int min(int a, int b)
static void MakeAlternateImages(AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
Definition: ToolBar.cpp:801
void SetAsSpacer(bool bIsSpacer)
Definition: Grabber.cpp:101
The widget to the left of a ToolBar that allows it to be dragged around to NEW positions.
Definition: Grabber.h:98
wxWindow * mButtons[3]
Definition: Ruler.h:450
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void UpdateButtonStates()
Definition: Ruler.cpp:3278
void AdornedRulerPanel::RegenerateTooltips ( )

Definition at line 2718 of file Ruler.cpp.

References CellularPanel::HandleCursorForPresentMouseState().

Referenced by OnRecordStartStop(), OnTimelineToolTips(), OnToggleQuickPlay(), and UpdatePrefs().

2719 {
2720  CallAfter( [this]{ HandleCursorForPresentMouseState(); } );
2721 }
void HandleCursorForPresentMouseState(bool doHit=true)
void AdornedRulerPanel::SetFocusedCell ( )
overrideprivatevirtual

Implements CellularPanel.

Definition at line 3775 of file Ruler.cpp.

3776 {
3777 }
void AdornedRulerPanel::SetLeftOffset ( int  offset)

Definition at line 3600 of file Ruler.cpp.

References mLeftOffset, mRuler, CellularPanel::mViewInfo, and Ruler::SetUseZoomInfo().

Referenced by TrackPanel::UpdateVRulerSize().

3601 {
3602  mLeftOffset = offset;
3603  mRuler.SetUseZoomInfo(offset, mViewInfo);
3604 }
ViewInfo * mViewInfo
Ruler mRuler
Definition: Ruler.h:389
void SetUseZoomInfo(int leftOffset, const ZoomInfo *zoomInfo)
Definition: Ruler.cpp:1607
void AdornedRulerPanel::SetPanelSize ( )

Definition at line 3264 of file Ruler.cpp.

References GetRulerHeight(), and mShowScrubbing.

Referenced by OnToggleScrubRuler(), and UpdatePrefs().

3265 {
3266  wxSize size { GetSize().GetWidth(), GetRulerHeight(mShowScrubbing) };
3267  SetSize(size);
3268  SetMinSize(size);
3269  GetParent()->PostSizeEventToParent();
3270 }
int GetRulerHeight()
Definition: Ruler.h:326
bool mShowScrubbing
Definition: Ruler.h:446
void AdornedRulerPanel::SetPlayRegion ( double  playRegionStart,
double  playRegionEnd 
)

Definition at line 3690 of file Ruler.cpp.

References mesNone, mMouseEventState, mPlayRegionEnd, and mPlayRegionStart.

Referenced by AdornedRulerPanel::QPHandle::Cancel(), HandleQPRelease(), and AudacityProject::TP_DisplaySelection().

3692 {
3693  // This is called by AudacityProject to make the play region follow
3694  // the current selection. But while the user is selecting a play region
3695  // with the mouse directly in the ruler, changes from outside are blocked.
3696  if (mMouseEventState != mesNone)
3697  return;
3698 
3699  mPlayRegionStart = playRegionStart;
3700  mPlayRegionEnd = playRegionEnd;
3701 
3702  Refresh();
3703 }
MouseEventState mMouseEventState
Definition: Ruler.h:441
double mPlayRegionStart
Definition: Ruler.h:407
double mPlayRegionEnd
Definition: Ruler.h:408
void AdornedRulerPanel::ShowContextMenu ( MenuChoice  choice,
const wxPoint *  pPosition 
)
private

Definition at line 3509 of file Ruler.cpp.

References QuickPlay, Scrub, ShowMenu(), and ShowScrubMenu().

Referenced by DoContextMenu().

3510 {
3511  wxPoint position;
3512  if(pPosition)
3513  position = *pPosition;
3514  else
3515  {
3516  auto rect = GetRect();
3517  position = { rect.GetLeft() + 1, rect.GetBottom() + 1 };
3518  }
3519 
3520  switch (choice) {
3521  case MenuChoice::QuickPlay:
3522  ShowMenu(position); break;
3523  case MenuChoice::Scrub:
3524  ShowScrubMenu(position); break;
3525  default:
3526  return;
3527  }
3528 }
void ShowScrubMenu(const wxPoint &pos)
Definition: Ruler.cpp:3378
void ShowMenu(const wxPoint &pos)
Definition: Ruler.cpp:3334
bool AdornedRulerPanel::ShowingScrubRuler ( ) const
inline

Definition at line 349 of file Ruler.h.

Referenced by ScrubbingToolBar::EnableDisableButtons(), and Scrubber::ShowsBar().

349 { return mShowScrubbing; }
bool mShowScrubbing
Definition: Ruler.h:446
void AdornedRulerPanel::ShowMenu ( const wxPoint &  pos)
private

Definition at line 3334 of file Ruler.cpp.

References _(), ViewInfo::bUpdateTrackIndicator, AudacityProject::IsPlayRegionLocked(), mPlayRegionDragsSelection, mPlayRegionEnd, mPlayRegionStart, mProject, mQuickPlayEnabled, mShowScrubbing, mTimelineToolTip, and CellularPanel::mViewInfo.

Referenced by ShowContextMenu().

3335 {
3336  wxMenu rulerMenu;
3337 
3338  if (mQuickPlayEnabled)
3339  rulerMenu.Append(OnToggleQuickPlayID, _("Disable Quick-Play"));
3340  else
3341  rulerMenu.Append(OnToggleQuickPlayID, _("Enable Quick-Play"));
3342 
3343  wxMenuItem *dragitem;
3345  dragitem = rulerMenu.Append(OnSyncQuickPlaySelID, _("Disable dragging selection"));
3346  else
3347  dragitem = rulerMenu.Append(OnSyncQuickPlaySelID, _("Enable dragging selection"));
3348  dragitem->Enable(mQuickPlayEnabled && !mProject->IsPlayRegionLocked());
3349 
3350 #if wxUSE_TOOLTIPS
3351  if (mTimelineToolTip)
3352  rulerMenu.Append(OnTimelineToolTipID, _("Disable Timeline Tooltips"));
3353  else
3354  rulerMenu.Append(OnTimelineToolTipID, _("Enable Timeline Tooltips"));
3355 #endif
3356 
3358  rulerMenu.Append(OnAutoScrollID, _("Do not scroll while playing"));
3359  else
3360  rulerMenu.Append(OnAutoScrollID, _("Update display while playing"));
3361 
3362  wxMenuItem *prlitem;
3363  if (!mProject->IsPlayRegionLocked())
3364  prlitem = rulerMenu.Append(OnLockPlayRegionID, _("Lock Play Region"));
3365  else
3366  prlitem = rulerMenu.Append(OnLockPlayRegionID, _("Unlock Play Region"));
3367  prlitem->Enable(mProject->IsPlayRegionLocked() || (mPlayRegionStart != mPlayRegionEnd));
3368 
3369  wxMenuItem *ruleritem;
3370  if (mShowScrubbing)
3371  ruleritem = rulerMenu.Append(OnScrubRulerID, _("Disable Scrub Ruler"));
3372  else
3373  ruleritem = rulerMenu.Append(OnScrubRulerID, _("Enable Scrub Ruler"));
3374 
3375  PopupMenu(&rulerMenu, pos);
3376 }
bool mQuickPlayEnabled
Definition: Ruler.h:431
ViewInfo * mViewInfo
bool mPlayRegionDragsSelection
Definition: Ruler.h:429
bool bUpdateTrackIndicator
Definition: ViewInfo.h:182
double mPlayRegionStart
Definition: Ruler.h:407
bool mShowScrubbing
Definition: Ruler.h:446
_("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
AudacityProject *const mProject
Definition: Ruler.h:390
bool mTimelineToolTip
Definition: Ruler.h:430
bool IsPlayRegionLocked()
Definition: Project.h:213
double mPlayRegionEnd
Definition: Ruler.h:408
void AdornedRulerPanel::ShowScrubMenu ( const wxPoint &  pos)
private

Definition at line 3378 of file Ruler.cpp.

References AudacityProject::GetScrubber(), mProject, and Scrubber::PopulatePopupMenu().

Referenced by ShowContextMenu().

3379 {
3380  auto &scrubber = mProject->GetScrubber();
3381  PushEventHandler(&scrubber);
3382  auto cleanup = finally([this]{ PopEventHandler(); });
3383 
3384  wxMenu rulerMenu;
3385  mProject->GetScrubber().PopulatePopupMenu(rulerMenu);
3386  PopupMenu(&rulerMenu, pos);
3387 }
Scrubber & GetScrubber()
Definition: Project.h:804
AudacityProject *const mProject
Definition: Ruler.h:390
void PopulatePopupMenu(wxMenu &menu)
Definition: Scrubbing.cpp:1142
void AdornedRulerPanel::StartQPPlay ( bool  looped,
bool  cutPreview 
)
private

Definition at line 3184 of file Ruler.cpp.

References ControlToolBar::CutPreview, AudacityProject::GetControlToolBar(), AudacityProject::GetDefaultPlayOptions(), TrackList::GetEndTime(), AudacityProject::GetSel0(), AudacityProject::GetSel1(), TrackList::GetStartTime(), ControlToolBar::Looped, mPlayRegionEnd, mPlayRegionStart, mProject, mTracks, normalPlay, AudioIOStartStreamOptions::playLooped, ControlToolBar::PlayPlayRegion(), ControlToolBar::StopPlaying(), and ControlToolBar::Straight.

Referenced by HandleQPRelease().

3185 {
3186  const double t0 = mTracks->GetStartTime();
3187  const double t1 = mTracks->GetEndTime();
3188  const double sel0 = mProject->GetSel0();
3189  const double sel1 = mProject->GetSel1();
3190 
3191  // Start / Restart playback on left click.
3192  bool startPlaying = (mPlayRegionStart >= 0);
3193 
3194  if (startPlaying) {
3196  ctb->StopPlaying();
3197 
3198  bool loopEnabled = true;
3199  double start, end;
3200 
3201  if ((mPlayRegionEnd - mPlayRegionStart == 0.0) && looped) {
3202  // Loop play a point will loop either a selection or the project.
3203  if ((mPlayRegionStart > sel0) && (mPlayRegionStart < sel1)) {
3204  // we are in a selection, so use the selection
3205  start = sel0;
3206  end = sel1;
3207  } // not in a selection, so use the project
3208  else {
3209  start = t0;
3210  end = t1;
3211  }
3212  }
3213  else {
3214  start = mPlayRegionStart;
3215  end = mPlayRegionEnd;
3216  }
3217  // Looping a tiny selection may freeze, so just play it once.
3218  loopEnabled = ((end - start) > 0.001)? true : false;
3219 
3221  options.playLooped = (loopEnabled && looped);
3222 
3223  auto oldStart = mPlayRegionStart;
3224  if (!cutPreview)
3225  options.pStartTime = &oldStart;
3226  else
3227  options.timeTrack = NULL;
3228 
3229  ControlToolBar::PlayAppearance appearance =
3231  : options.playLooped ? ControlToolBar::PlayAppearance::Looped
3233 
3234  mPlayRegionStart = start;
3235  mPlayRegionEnd = end;
3236  Refresh();
3237 
3238  ctb->PlayPlayRegion((SelectedRegion(start, end)),
3239  options, PlayMode::normalPlay,
3240  appearance,
3241  false,
3242  true);
3243 
3244  }
3245 }
A ToolBar that has the main Transport buttons.
AudioIOStartStreamOptions GetDefaultPlayOptions()
Definition: Project.cpp:1301
double GetSel0() const
Definition: Project.h:204
double GetStartTime() const
Definition: Track.cpp:1413
double GetEndTime() const
Definition: Track.cpp:1418
void StopPlaying(bool stopStream=true)
double mPlayRegionStart
Definition: Ruler.h:407
Defines a selected portion of a project.
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:124
TrackList * mTracks
Definition: Ruler.h:391
AudacityProject *const mProject
Definition: Ruler.h:390
int PlayPlayRegion(const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode playMode, PlayAppearance appearance=PlayAppearance::Straight, bool backwards=false, bool playWhiteSpace=false)
ControlToolBar * GetControlToolBar()
Definition: Project.cpp:5015
double GetSel1() const
Definition: Project.h:205
double mPlayRegionEnd
Definition: Ruler.h:408
bool AdornedRulerPanel::TakesFocus ( ) const
overrideprivatevirtual

Implements CellularPanel.

Definition at line 3793 of file Ruler.cpp.

3794 {
3795  return false;
3796 }
int AdornedRulerPanel::Time2Pos ( double  t,
bool  ignoreFisheye = false 
)
private

Definition at line 2845 of file Ruler.cpp.

References mLeftOffset, CellularPanel::mViewInfo, and ZoomInfo::TimeToPosition().

Referenced by DoDrawPlayRegion(), DoDrawSelection(), HandleQPClick(), and IsWithinMarker().

2846 {
2848  , ignoreFisheye
2849  );
2850 }
ViewInfo * mViewInfo
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 AdornedRulerPanel::UpdateButtonStates ( )

Definition at line 3278 of file Ruler.cpp.

References _(), gAudioIO, TracksPrefs::GetPinnedHeadPreference(), AudioIO::IsCapturing(), label, AButton::PopUp(), ToolBar::SetButtonToolTip(), and AButton::UpdateStatus().

Referenced by PlayIndicatorOverlayBase::Draw(), OnRecordStartStop(), Scrubber::OnScrubOrSeek(), OnTogglePinnedState(), ReCreateButtons(), and UpdatePrefs().

3279 {
3280  auto common = [this]
3281  (AButton &button, const wxString &commandName, const wxString &label) {
3282  TranslatedInternalString command{ commandName, label };
3283  ToolBar::SetButtonToolTip( button, &command, 1u );
3284  button.SetLabel(button.GetToolTipText());
3285 
3286  button.UpdateStatus();
3287  };
3288 
3289  {
3290  bool state = TracksPrefs::GetPinnedHeadPreference();
3291  auto pinButton = static_cast<AButton*>(FindWindow(OnTogglePinnedStateID));
3292  if( !state )
3293  pinButton->PopUp();
3294  else
3295  pinButton->PushDown();
3296  pinButton->SetAlternateIdx(
3297  (gAudioIO->IsCapturing() ? 2 : 0) + (state ? 0 : 1));
3298  // Bug 1584: Toltip now shows what clicking will do.
3299  const auto label = state
3300  ? _("Click to unpin")
3301  : _("Click to pin");
3302  common(*pinButton, wxT("PinnedHead"), label);
3303  }
3304 }
void PopUp()
Definition: AButton.cpp:525
bool IsCapturing() const
Definition: AudioIO.cpp:5622
wxString label
Definition: Tags.cpp:733
_("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
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
static bool GetPinnedHeadPreference()
static void SetButtonToolTip(AButton &button, const TranslatedInternalString commands[], size_t nCommands)
Definition: ToolBar.cpp:826
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void UpdateStatus()
Definition: AButton.cpp:421
void AdornedRulerPanel::UpdatePrefs ( )

Definition at line 2561 of file Ruler.cpp.

References gPrefs, mRuler, mShowScrubbing, RegenerateTooltips(), TracksBehaviorsPrefs::ScrollingPreferenceDefault(), TracksBehaviorsPrefs::ScrollingPreferenceKey(), SetPanelSize(), Ruler::SetTwoTone(), UpdateButtonStates(), and UpdateRects().

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

2562 {
2563  // Update button texts for language change
2565 
2566 #ifdef EXPERIMENTAL_SCROLLING_LIMITS
2567 #ifdef EXPERIMENTAL_TWO_TONE_TIME_RULER
2568  {
2569  bool scrollBeyondZero = false;
2570  gPrefs->Read(TracksBehaviorsPrefs::ScrollingPreferenceKey(), &scrollBeyondZero,
2572  mRuler.SetTwoTone(scrollBeyondZero);
2573  }
2574 #endif
2575 #endif
2576 
2577  mShowScrubbing = ReadScrubEnabledPref();
2578  // Affected by the last
2579  UpdateRects();
2580  SetPanelSize();
2581 
2583 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
static const wxChar * ScrollingPreferenceKey()
Ruler mRuler
Definition: Ruler.h:389
void UpdateRects()
Definition: Ruler.cpp:2794
void SetTwoTone(bool twoTone)
Definition: Ruler.cpp:184
bool mShowScrubbing
Definition: Ruler.h:446
void SetPanelSize()
Definition: Ruler.cpp:3264
void RegenerateTooltips()
Definition: Ruler.cpp:2718
static bool ScrollingPreferenceDefault()
void UpdateButtonStates()
Definition: Ruler.cpp:3278
void AdornedRulerPanel::UpdateQuickPlayPos ( wxCoord &  mousePosX,
bool  shiftDown 
)

Definition at line 3312 of file Ruler.cpp.

References TrackList::GetEndTime(), TrackPanel::GetLeftOffset(), AudacityProject::GetTrackPanel(), TrackPanel::GetTracksUsableArea(), HandleSnapping(), CellularPanel::LastCell(), min(), mProject, mQPCell, mQuickPlayPos, mQuickPlayPosUnsnapped, mTracks, and Pos2Time().

Referenced by AdornedRulerPanel::QPHandle::Drag(), AdornedRulerPanel::QPCell::HitTest(), and AdornedRulerPanel::ScrubbingCell::HitTest().

3313 {
3314  // Keep Quick-Play within usable track area.
3316  int width;
3317  tp->GetTracksUsableArea(&width, NULL);
3318  mousePosX = std::max(mousePosX, tp->GetLeftOffset());
3319  mousePosX = std::min(mousePosX, tp->GetLeftOffset() + width - 1);
3320 
3322 
3323  HandleSnapping();
3324 
3325  // If not looping, restrict selection to end of project
3326  if ((LastCell() == mQPCell || mQPCell->Clicked()) && !shiftDown) {
3327  const double t1 = mTracks->GetEndTime();
3329  }
3330 }
double GetEndTime() const
Definition: Track.cpp:1418
void HandleSnapping()
Definition: Ruler.cpp:3410
std::shared_ptr< TrackPanelCell > LastCell() const
void GetTracksUsableArea(int *width, int *height) const
Definition: TrackPanel.cpp:414
double mQuickPlayPos
Definition: Ruler.h:402
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:237
TrackList * mTracks
Definition: Ruler.h:391
int min(int a, int b)
AudacityProject *const mProject
Definition: Ruler.h:390
double mQuickPlayPosUnsnapped
Definition: Ruler.h:401
TrackPanel * GetTrackPanel()
Definition: Project.h:307
int GetLeftOffset() const
Definition: TrackPanel.h:270
double Pos2Time(int p, bool ignoreFisheye=false)
Definition: Ruler.cpp:2838
std::shared_ptr< QPCell > mQPCell
Definition: Ruler.h:486
void AdornedRulerPanel::UpdateRects ( )
private

Definition at line 2794 of file Ruler.cpp.

References BottomMargin, LeftMargin, min(), mInner, mOuter, mRuler, mScrubZone, mShowScrubbing, RightMargin, ScrubHeight, Ruler::SetBounds(), and TopMargin.

Referenced by OnSize(), and UpdatePrefs().

2795 {
2796  mInner = mOuter;
2797  mInner.x += LeftMargin;
2798  mInner.width -= (LeftMargin + RightMargin);
2799 
2800  auto top = &mInner;
2801  auto bottom = &mInner;
2802 
2803  if (mShowScrubbing) {
2804  mScrubZone = mInner;
2805  auto scrubHeight = std::min(mScrubZone.height, (int)(ScrubHeight));
2806 
2807  int topHeight;
2808 #ifdef SCRUB_ABOVE
2809  top = &mScrubZone, topHeight = scrubHeight;
2810 #else
2811  auto qpHeight = mScrubZone.height - scrubHeight;
2812  bottom = &mScrubZone, topHeight = qpHeight;
2813  // Increase scrub zone height so that hit testing finds it and
2814  // not QP region, when on bottom 'edge'.
2815  mScrubZone.height+=BottomMargin;
2816 #endif
2817 
2818  top->height = topHeight;
2819  bottom->height -= topHeight;
2820  bottom->y += topHeight;
2821  }
2822 
2823  top->y += TopMargin;
2824  top->height -= TopMargin;
2825 
2826  bottom->height -= BottomMargin;
2827 
2828  if (!mShowScrubbing)
2829  mScrubZone = mInner;
2830 
2831  mRuler.SetBounds(mInner.GetLeft(),
2832  mInner.GetTop(),
2833  mInner.GetRight(),
2834  mInner.GetBottom());
2835 
2836 }
wxRect mInner
Definition: Ruler.h:395
Ruler mRuler
Definition: Ruler.h:389
void SetBounds(int left, int top, int right, int bottom)
Definition: Ruler.cpp:359
wxRect mOuter
Definition: Ruler.h:393
bool mShowScrubbing
Definition: Ruler.h:446
int min(int a, int b)
wxRect mScrubZone
Definition: Ruler.h:394
void AdornedRulerPanel::UpdateStatusMessage ( const wxString &  message)
overrideprivatevirtual

Implements CellularPanel.

Definition at line 3788 of file Ruler.cpp.

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

3789 {
3790  GetProject()->TP_DisplayStatusMessage(message);
3791 }
AudacityProject * GetProject() const override
Definition: Ruler.cpp:3762
void TP_DisplayStatusMessage(const wxString &msg) override
Definition: Project.cpp:5378

Member Data Documentation

wxWindow* AdornedRulerPanel::mButtons[3]
private

Definition at line 450 of file Ruler.h.

Referenced by AdornedRulerPanel(), and ReCreateButtons().

double AdornedRulerPanel::mIndTime
private

Definition at line 400 of file Ruler.h.

Referenced by AdornedRulerPanel().

wxRect AdornedRulerPanel::mInner
private
bool AdornedRulerPanel::mIsDragging
private

Definition at line 444 of file Ruler.h.

Referenced by AdornedRulerPanel(), HandleQPDrag(), and HandleQPRelease().

bool AdornedRulerPanel::mIsRecording
private
bool AdornedRulerPanel::mIsSnapped
private

Definition at line 404 of file Ruler.h.

Referenced by AdornedRulerPanel(), and HandleSnapping().

double AdornedRulerPanel::mLeftDownClick
private

Definition at line 443 of file Ruler.h.

Referenced by AdornedRulerPanel(), HandleQPClick(), HandleQPDrag(), and HandleQPRelease().

double AdornedRulerPanel::mLeftDownClickUnsnapped
private

Definition at line 442 of file Ruler.h.

Referenced by HandleQPClick(), and HandleQPDrag().

int AdornedRulerPanel::mLeftOffset
private

Definition at line 397 of file Ruler.h.

Referenced by AdornedRulerPanel(), Pos2Time(), SetLeftOffset(), and Time2Pos().

MouseEventState AdornedRulerPanel::mMouseEventState
private
bool AdornedRulerPanel::mNeedButtonUpdate { true }
private

Definition at line 451 of file Ruler.h.

Referenced by OnPaint().

double AdornedRulerPanel::mOldPlayRegionEnd
private
double AdornedRulerPanel::mOldPlayRegionStart
private
wxRect AdornedRulerPanel::mOuter
private

Definition at line 393 of file Ruler.h.

Referenced by AdornedRulerPanel(), DoDrawEdge(), OnSize(), and UpdateRects().

std::unique_ptr<QuickPlayIndicatorOverlay> AdornedRulerPanel::mOverlay
private

Definition at line 474 of file Ruler.h.

Referenced by CreateOverlays().

bool AdornedRulerPanel::mPlayRegionDragsSelection
private

Definition at line 429 of file Ruler.h.

Referenced by AdornedRulerPanel(), HandleQPDrag(), OnSyncSelToQuickPlay(), and ShowMenu().

double AdornedRulerPanel::mPlayRegionEnd
private
bool AdornedRulerPanel::mPlayRegionLock
private
double AdornedRulerPanel::mPlayRegionStart
private
AudacityProject* const AdornedRulerPanel::mProject
private
std::shared_ptr<QPCell> AdornedRulerPanel::mQPCell
private
bool AdornedRulerPanel::mQuickPlayEnabled
private
double AdornedRulerPanel::mQuickPlayPos
private

Definition at line 402 of file Ruler.h.

Referenced by HandleQPClick(), HandleQPDrag(), HandleSnapping(), and UpdateQuickPlayPos().

double AdornedRulerPanel::mQuickPlayPosUnsnapped
private

Definition at line 401 of file Ruler.h.

Referenced by HandleQPClick(), and UpdateQuickPlayPos().

Ruler AdornedRulerPanel::mRuler
private
std::shared_ptr<ScrubbingCell> AdornedRulerPanel::mScrubbingCell
private
wxRect AdornedRulerPanel::mScrubZone
private

Definition at line 394 of file Ruler.h.

Referenced by DoDrawBackground(), FindRect(), and UpdateRects().

bool AdornedRulerPanel::mShowScrubbing { false }
private
bool AdornedRulerPanel::mTimelineToolTip
private
TrackList* AdornedRulerPanel::mTracks
private

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