Audacity  2.3.1
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 2498 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.

2504 : CellularPanel(parent, id, pos, size, viewinfo)
2505 , mProject(project)
2506 {
2507  mQPCell = std::make_shared<QPCell>( this );
2508  mScrubbingCell = std::make_shared<ScrubbingCell>( this );
2509 
2510  for (auto &button : mButtons)
2511  button = nullptr;
2512 
2513  SetLabel( _("Timeline") );
2514  SetName(GetLabel());
2515  SetBackgroundStyle(wxBG_STYLE_PAINT);
2516 
2517  mLeftOffset = 0;
2518  mIndTime = -1;
2519 
2520  mPlayRegionStart = -1;
2521  mPlayRegionLock = false;
2522  mPlayRegionEnd = -1;
2523  mOldPlayRegionStart = -1;
2524  mOldPlayRegionEnd = -1;
2525  mLeftDownClick = -1;
2527  mIsDragging = false;
2528 
2529  mOuter = GetClientRect();
2530 
2532  mRuler.SetLabelEdges( false );
2534 
2535  mTracks = project->GetTracks();
2536 
2537  mIsSnapped = false;
2538 
2539  mIsRecording = false;
2540 
2541  mTimelineToolTip = !!gPrefs->Read(wxT("/QuickPlay/ToolTips"), 1L);
2542  mPlayRegionDragsSelection = (gPrefs->Read(wxT("/QuickPlay/DragSelection"), 0L) == 1)? true : false;
2543  mQuickPlayEnabled = !!gPrefs->Read(wxT("/QuickPlay/QuickPlayEnabled"), 1L);
2544 
2545 #if wxUSE_TOOLTIPS
2546  wxToolTip::Enable(true);
2547 #endif
2548 
2549  wxTheApp->Bind(EVT_AUDIOIO_CAPTURE,
2551  this);
2552 }
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:276
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:190
void OnRecordStartStop(wxCommandEvent &evt)
Definition: Ruler.cpp:2743
bool mTimelineToolTip
Definition: Ruler.h:430
void SetUseZoomInfo(int leftOffset, const ZoomInfo *zoomInfo)
Definition: Ruler.cpp:1614
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 2554 of file Ruler.cpp.

2555 {
2556 }

Member Function Documentation

void AdornedRulerPanel::ClearPlayRegion ( )

Definition at line 3728 of file Ruler.cpp.

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

Referenced by HandleQPRelease().

3729 {
3731  ctb->StopPlaying();
3732 
3733  mPlayRegionStart = -1;
3734  mPlayRegionEnd = -1;
3735 
3736  Refresh();
3737 }
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:4909
double mPlayRegionEnd
Definition: Ruler.h:408
void AdornedRulerPanel::CreateOverlays ( )
private

Definition at line 3823 of file Ruler.cpp.

References mOverlay, and mProject.

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

3824 {
3825  if (!mOverlay)
3826  mOverlay =
3827  std::make_unique<QuickPlayIndicatorOverlay>( mProject );
3828 }
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 3553 of file Ruler.cpp.

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

Referenced by OnPaint().

3554 {
3555  // Draw AdornedRulerPanel border
3556  AColor::UseThemeColour( dc, clrTrackInfo );
3557  dc->DrawRectangle( mInner );
3558 
3559  if (mShowScrubbing) {
3560  // Let's distinguish the scrubbing area by using a themable
3561  // colour and a line to set it off.
3562  AColor::UseThemeColour(dc, clrScrubRuler, clrTrackPanelText );
3563  wxRect ScrubRect = mScrubZone;
3564  ScrubRect.Inflate( 1,0 );
3565  dc->DrawRectangle(ScrubRect);
3566  }
3567 }
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 3569 of file Ruler.cpp.

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

Referenced by OnPaint().

3570 {
3571  wxRect r = mOuter;
3572  r.width -= RightMargin;
3573  r.height -= BottomMargin;
3574  AColor::BevelTrackInfo( *dc, true, r );
3575 
3576  // Black stroke at bottom
3577  dc->SetPen( *wxBLACK_PEN );
3578  dc->DrawLine( mOuter.x,
3579  mOuter.y + mOuter.height - 1,
3580  mOuter.x + mOuter.width,
3581  mOuter.y + mOuter.height - 1 );
3582 }
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 3631 of file Ruler.cpp.

References ThemeBase::Bitmap(), AColor::IndicatorColor(), IndicatorHeightForWidth(), IndicatorOffset, ControlToolBar::IsTransportingPinned(), and theTheme.

3632 {
3633  ADCChanger changer(dc); // Undo pen and brush changes at function exit
3634 
3635  AColor::IndicatorColor( dc, playing );
3636 
3637  wxPoint tri[ 3 ];
3638  if (seek) {
3639  auto height = IndicatorHeightForWidth(width);
3640  // Make four triangles
3641  const int TriangleWidth = width * 3 / 8;
3642 
3643  // Double-double headed, left-right
3644  auto yy = mShowScrubbing
3645  ? mScrubZone.y
3646  : (mInner.GetBottom() + 1) - 1 /* bevel */ - height;
3647  tri[ 0 ].x = xx - IndicatorOffset;
3648  tri[ 0 ].y = yy;
3649  tri[ 1 ].x = xx - IndicatorOffset;
3650  tri[ 1 ].y = yy + height;
3651  tri[ 2 ].x = xx - TriangleWidth;
3652  tri[ 2 ].y = yy + height / 2;
3653  dc->DrawPolygon( 3, tri );
3654 
3655  tri[ 0 ].x -= TriangleWidth;
3656  tri[ 1 ].x -= TriangleWidth;
3657  tri[ 2 ].x -= TriangleWidth;
3658  dc->DrawPolygon( 3, tri );
3659 
3660  tri[ 0 ].x = tri[ 1 ].x = xx + IndicatorOffset;
3661  tri[ 2 ].x = xx + TriangleWidth;
3662  dc->DrawPolygon( 3, tri );
3663 
3664 
3665  tri[ 0 ].x += TriangleWidth;
3666  tri[ 1 ].x += TriangleWidth;
3667  tri[ 2 ].x += TriangleWidth;
3668  dc->DrawPolygon( 3, tri );
3669  }
3670  else if (scrub) {
3671  auto height = IndicatorHeightForWidth(width);
3672  const int IndicatorHalfWidth = width / 2;
3673 
3674  // Double headed, left-right
3675  auto yy = mShowScrubbing
3676  ? mScrubZone.y
3677  : (mInner.GetBottom() + 1) - 1 /* bevel */ - height;
3678  tri[ 0 ].x = xx - IndicatorOffset;
3679  tri[ 0 ].y = yy;
3680  tri[ 1 ].x = xx - IndicatorOffset;
3681  tri[ 1 ].y = yy + height;
3682  tri[ 2 ].x = xx - IndicatorHalfWidth;
3683  tri[ 2 ].y = yy + height / 2;
3684  dc->DrawPolygon( 3, tri );
3685  tri[ 0 ].x = tri[ 1 ].x = xx + IndicatorOffset;
3686  tri[ 2 ].x = xx + IndicatorHalfWidth;
3687  dc->DrawPolygon( 3, tri );
3688  }
3689  else {
3690  bool pinned = ControlToolBar::IsTransportingPinned();
3691  wxBitmap & bmp = theTheme.Bitmap( pinned ?
3692  (playing ? bmpPlayPointerPinned : bmpRecordPointerPinned) :
3693  (playing ? bmpPlayPointer : bmpRecordPointer)
3694  );
3695  const int IndicatorHalfWidth = bmp.GetWidth() / 2;
3696  dc->DrawBitmap( bmp, xx - IndicatorHalfWidth -1, mInner.y );
3697 #if 0
3698 
3699  // Down pointing triangle
3700  auto height = IndicatorHeightForWidth(width);
3701  const int IndicatorHalfWidth = width / 2;
3702  tri[ 0 ].x = xx - IndicatorHalfWidth;
3703  tri[ 0 ].y = mInner.y;
3704  tri[ 1 ].x = xx + IndicatorHalfWidth;
3705  tri[ 1 ].y = mInner.y;
3706  tri[ 2 ].x = xx;
3707  tri[ 2 ].y = mInner.y + height;
3708  dc->DrawPolygon( 3, tri );
3709 #endif
3710  }
3711 }
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:1726
wxRect mScrubZone
Definition: Ruler.h:394
Makes temporary drawing context changes that you back out of, RAII style.
Definition: AColor.h:42
static bool IsTransportingPinned()
void AdornedRulerPanel::DoDrawMarks ( wxDC *  dc,
bool   
)
private

Definition at line 3584 of file Ruler.cpp.

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

Referenced by OnPaint().

3585 {
3586  const double min = Pos2Time(0);
3587  const double hiddenMin = Pos2Time(0, true);
3588  const double max = Pos2Time(mInner.width);
3589  const double hiddenMax = Pos2Time(mInner.width, true);
3590 
3591  mRuler.SetTickColour( theTheme.Colour( clrTrackPanelText ) );
3592  mRuler.SetRange( min, max, hiddenMin, hiddenMax );
3593  mRuler.Draw( *dc );
3594 }
void Draw(wxDC &dc)
Definition: Ruler.cpp:1331
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:238
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:2858
void AdornedRulerPanel::DoDrawPlayRegion ( wxDC *  dc)
private

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

3477 {
3478  double start, end;
3479  GetPlayRegion(&start, &end);
3480 
3481  if (start >= 0)
3482  {
3483  const int x1 = Time2Pos(start);
3484  const int x2 = Time2Pos(end)-2;
3485  int y = mInner.y - TopMargin + mInner.height/2;
3486 
3487  bool isLocked = mProject->IsPlayRegionLocked();
3488  AColor::PlayRegionColor(dc, isLocked);
3489 
3490  wxPoint tri[3];
3491  wxRect r;
3492 
3493  tri[0].x = x1;
3494  tri[0].y = y + PLAY_REGION_GLOBAL_OFFSET_Y;
3495  tri[1].x = x1 + PLAY_REGION_TRIANGLE_SIZE;
3496  tri[1].y = y - PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3497  tri[2].x = x1 + PLAY_REGION_TRIANGLE_SIZE;
3498  tri[2].y = y + PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3499  dc->DrawPolygon(3, tri);
3500 
3501  r.x = x1;
3502  r.y = y - PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3503  r.width = PLAY_REGION_RECT_WIDTH;
3504  r.height = PLAY_REGION_TRIANGLE_SIZE*2 + 1;
3505  dc->DrawRectangle(r);
3506 
3507  if (end != start)
3508  {
3509  tri[0].x = x2;
3510  tri[0].y = y + PLAY_REGION_GLOBAL_OFFSET_Y;
3511  tri[1].x = x2 - PLAY_REGION_TRIANGLE_SIZE;
3512  tri[1].y = y - PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3513  tri[2].x = x2 - PLAY_REGION_TRIANGLE_SIZE;
3514  tri[2].y = y + PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3515  dc->DrawPolygon(3, tri);
3516 
3517  r.x = x2 - PLAY_REGION_RECT_WIDTH + 1;
3518  r.y = y - PLAY_REGION_TRIANGLE_SIZE + PLAY_REGION_GLOBAL_OFFSET_Y;
3519  r.width = PLAY_REGION_RECT_WIDTH;
3520  r.height = PLAY_REGION_TRIANGLE_SIZE*2 + 1;
3521  dc->DrawRectangle(r);
3522 
3523  r.x = x1 + PLAY_REGION_TRIANGLE_SIZE;
3525  r.width = std::max(0, x2-x1 - PLAY_REGION_TRIANGLE_SIZE*2);
3526  r.height = PLAY_REGION_RECT_HEIGHT;
3527  dc->DrawRectangle(r);
3528  }
3529  }
3530 }
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:112
int Time2Pos(double t, bool ignoreFisheye=false)
Definition: Ruler.cpp:2865
#define PLAY_REGION_GLOBAL_OFFSET_Y
Definition: Ruler.cpp:114
AudacityProject *const mProject
Definition: Ruler.h:390
#define PLAY_REGION_TRIANGLE_SIZE
Definition: Ruler.cpp:111
#define PLAY_REGION_RECT_HEIGHT
Definition: Ruler.cpp:113
bool IsPlayRegionLocked()
Definition: Project.h:211
void GetPlayRegion(double *playRegionStart, double *playRegionEnd)
Definition: Ruler.cpp:3739
void AdornedRulerPanel::DoDrawSelection ( wxDC *  dc)
private

Definition at line 3601 of file Ruler.cpp.

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

Referenced by OnPaint().

3602 {
3603  // Draw selection
3604  const int p0 = max(1, Time2Pos(mViewInfo->selectedRegion.t0()));
3605  const int p1 = min(mInner.width, Time2Pos(mViewInfo->selectedRegion.t1()));
3606 
3607  dc->SetBrush( wxBrush( theTheme.Colour( clrRulerBackground )) );
3608  dc->SetPen( wxPen( theTheme.Colour( clrRulerBackground )) );
3609 
3610  wxRect r;
3611  r.x = p0;
3612  r.y = mInner.y;
3613  r.width = p1 - p0 - 1;
3614  r.height = mInner.height;
3615  dc->DrawRectangle( r );
3616 }
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:2865
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
void AdornedRulerPanel::DragSelection ( )
private

Definition at line 3427 of file Ruler.cpp.

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

Referenced by HandleQPDrag().

3428 {
3431 }
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 3293 of file Ruler.cpp.

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

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

3294 {
3295  mProject->GetTrackPanel()->DrawOverlays( false );
3296  DrawOverlays( false );
3297 }
void DrawOverlays(bool repaint_all, wxDC *pDC=nullptr)
AudacityProject *const mProject
Definition: Ruler.h:390
TrackPanel * GetTrackPanel()
Definition: Project.h:309
void AdornedRulerPanel::DrawSelection ( )

Definition at line 3596 of file Ruler.cpp.

Referenced by TrackPanel::UpdateSelectionDisplay().

3597 {
3598  Refresh();
3599 }
auto AdornedRulerPanel::FindCell ( int  mouseX,
int  mouseY 
)
overrideprivatevirtual

Implements CellularPanel.

Definition at line 3761 of file Ruler.cpp.

3762 {
3763  bool mayScrub = mProject->GetScrubber().CanScrub() &&
3765  if (mayScrub && mScrubZone.Contains(mouseX, mouseY))
3766  return { mScrubbingCell, mScrubZone };
3767 
3768  if (mInner.Contains(mouseX, mouseY))
3769  return { mQPCell, mInner };
3770 
3771  return {};
3772 }
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:1148
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 3774 of file Ruler.cpp.

References mInner, mQPCell, mScrubbingCell, and mScrubZone.

3775 {
3776  if (&cell == mScrubbingCell.get())
3777  return mScrubZone;
3778  if (&cell == mQPCell.get())
3779  return mInner;
3780 
3781  return {};
3782 }
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 3791 of file Ruler.cpp.

References mQPCell.

3792 {
3793  // No switching of focus yet to the other, scrub zone
3794  return mQPCell.get();
3795 }
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 3755 of file Ruler.cpp.

References Ruler::GetMaxSize(), and mRuler.

3756 {
3757  mRuler.GetMaxSize(width, height);
3758 }
Ruler mRuler
Definition: Ruler.h:389
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:1557
void AdornedRulerPanel::GetPlayRegion ( double *  playRegionStart,
double *  playRegionEnd 
)

Definition at line 3739 of file Ruler.cpp.

References mPlayRegionEnd, and mPlayRegionStart.

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

3741 {
3742  if (mPlayRegionStart >= 0 && mPlayRegionEnd >= 0 &&
3744  {
3745  // swap values to make sure end > start
3746  *playRegionStart = mPlayRegionEnd;
3747  *playRegionEnd = mPlayRegionStart;
3748  } else
3749  {
3750  *playRegionStart = mPlayRegionStart;
3751  *playRegionEnd = mPlayRegionEnd;
3752  }
3753 }
double mPlayRegionStart
Definition: Ruler.h:407
double mPlayRegionEnd
Definition: Ruler.h:408
AudacityProject * AdornedRulerPanel::GetProject ( ) const
overridevirtual

Implements CellularPanel.

Definition at line 3785 of file Ruler.cpp.

References mProject.

Referenced by UpdateStatusMessage().

3786 {
3787  return mProject;
3788 }
AudacityProject *const mProject
Definition: Ruler.h:390
int AdornedRulerPanel::GetRulerHeight ( )
inline
int AdornedRulerPanel::GetRulerHeight ( bool  showScrubBar)
static

Definition at line 3618 of file Ruler.cpp.

References ProperRulerHeight, and ScrubHeight.

3619 {
3620  return ProperRulerHeight + (showScrubBar ? ScrubHeight : 0);
3621 }
void AdornedRulerPanel::HandleQPClick ( wxMouseEvent &  event,
wxCoord  mousePosX 
)
private

Definition at line 2917 of file Ruler.cpp.

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

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

2918 {
2919  // Temporarily unlock locked play region
2920  if (mPlayRegionLock && evt.LeftDown()) {
2921  //mPlayRegionLock = true;
2923  }
2924 
2927  bool isWithinStart = IsWithinMarker(mousePosX, mOldPlayRegionStart);
2928  bool isWithinEnd = IsWithinMarker(mousePosX, mOldPlayRegionEnd);
2929 
2930  if (isWithinStart || isWithinEnd) {
2931  // If Quick-Play is playing from a point, we need to treat it as a click
2932  // not as dragging.
2935  // otherwise check which marker is nearer
2936  else {
2937  // Don't compare times, compare positions.
2938  //if (fabs(mQuickPlayPos - mPlayRegionStart) < fabs(mQuickPlayPos - mPlayRegionEnd))
2942  else
2944  }
2945  }
2946  else {
2947  // Clicked but not yet dragging
2949  }
2950 }
double mLeftDownClick
Definition: Ruler.h:443
void OnUnlockPlayRegion(const CommandContext &context)
Definition: Menus.cpp:9698
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:2873
int Time2Pos(double t, bool ignoreFisheye=false)
Definition: Ruler.cpp:2865
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
MenuCommandHandler & GetMenuCommandHandler(AudacityProject &project)
Definition: Menus.cpp:152
void AdornedRulerPanel::HandleQPDrag ( wxMouseEvent &  event,
wxCoord  mousePosX 
)
private

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

2969 {
2970  bool isWithinClick =
2971  (mLeftDownClickUnsnapped >= 0) &&
2973  bool isWithinStart = IsWithinMarker(mousePosX, mOldPlayRegionStart);
2974  bool isWithinEnd = IsWithinMarker(mousePosX, mOldPlayRegionEnd);
2975  bool canDragSel = !mPlayRegionLock && mPlayRegionDragsSelection;
2976 
2977  switch (mMouseEventState)
2978  {
2979  case mesNone:
2980  // If close to either end of play region, snap to closest
2981  if (isWithinStart || isWithinEnd) {
2984  else
2986  }
2987  break;
2989  // Don't start dragging until beyond tolerance initial playback start
2990  if (!mIsDragging && isWithinStart)
2992  else
2993  mIsDragging = true;
2994  // avoid accidental tiny selection
2995  if (isWithinEnd)
2998  if (canDragSel) {
2999  DragSelection();
3000  }
3001  break;
3003  if (!mIsDragging && isWithinEnd) {
3005  }
3006  else
3007  mIsDragging = true;
3008  if (isWithinStart) {
3010  }
3012  if (canDragSel) {
3013  DragSelection();
3014  }
3015  break;
3017 
3018  // Don't start dragging until mouse is beyond tolerance of initial click.
3019  if (isWithinClick || mLeftDownClick == -1) {
3023  }
3024  else {
3026  }
3027  break;
3029  if (isWithinClick) {
3031  }
3032 
3033  if (mQuickPlayPos < mLeftDownClick) {
3036  }
3037  else {
3040  }
3041  if (canDragSel) {
3042  DragSelection();
3043  }
3044  break;
3045  }
3046  Refresh();
3047  Update();
3048 }
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:2873
bool mPlayRegionLock
Definition: Ruler.h:406
double mOldPlayRegionEnd
Definition: Ruler.h:410
void DragSelection()
Definition: Ruler.cpp:3427
double mLeftDownClickUnsnapped
Definition: Ruler.h:442
double mPlayRegionEnd
Definition: Ruler.h:408
void AdornedRulerPanel::HandleQPRelease ( wxMouseEvent &  event)
private

Definition at line 3130 of file Ruler.cpp.

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

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

3131 {
3133  // Swap values to ensure mPlayRegionStart < mPlayRegionEnd
3134  double tmp = mPlayRegionStart;
3136  mPlayRegionEnd = tmp;
3137  }
3138 
3139  const double t0 = mTracks->GetStartTime();
3140  const double t1 = mTracks->GetEndTime();
3141  const double sel0 = mProject->GetSel0();
3142  const double sel1 = mProject->GetSel1();
3143 
3144  // We want some audio in the selection, but we allow a dragged
3145  // region to include selected white-space and space before audio start.
3146  if (evt.ShiftDown() && (mPlayRegionStart == mPlayRegionEnd)) {
3147  // Looping the selection or project.
3148  // Disable if track selection is in white-space beyond end of tracks and
3149  // play position is outside of track contents.
3150  if (((sel1 < t0) || (sel0 > t1)) &&
3151  ((mPlayRegionStart < t0) || (mPlayRegionStart > t1))) {
3152  ClearPlayRegion();
3153  }
3154  }
3155  // Disable if beyond end.
3156  else if (mPlayRegionStart >= t1) {
3157  ClearPlayRegion();
3158  }
3159  // Disable if empty selection before start.
3160  // (allow Quick-Play region to include 'pre-roll' white space)
3161  else if (((mPlayRegionEnd - mPlayRegionStart) > 0.0) && (mPlayRegionEnd < t0)) {
3162  ClearPlayRegion();
3163  }
3164 
3166  mIsDragging = false;
3167  mLeftDownClick = -1;
3168 
3169  auto cleanup = finally( [&] {
3170  if (mPlayRegionLock) {
3171  // Restore Locked Play region
3174  // and release local lock
3175  mPlayRegionLock = false;
3176  }
3177  } );
3178 
3179  StartQPPlay(evt.ShiftDown(), evt.ControlDown());
3180 }
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:1165
double mOldPlayRegionStart
Definition: Ruler.h:409
double GetEndTime() const
Definition: Track.cpp:1170
void OnLockPlayRegion(const CommandContext &context)
Definition: Menus.cpp:9680
MouseEventState mMouseEventState
Definition: Ruler.h:441
double mPlayRegionStart
Definition: Ruler.h:407
void StartQPPlay(bool looped, bool cutPreview)
Definition: Ruler.cpp:3205
void SetPlayRegion(double playRegionStart, double playRegionEnd)
Definition: Ruler.cpp:3713
void ClearPlayRegion()
Definition: Ruler.cpp:3728
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
MenuCommandHandler & GetMenuCommandHandler(AudacityProject &project)
Definition: Menus.cpp:152
void AdornedRulerPanel::HandleSnapping ( )
private

Definition at line 3433 of file Ruler.cpp.

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

Referenced by UpdateQuickPlayPos().

3434 {
3435  auto handle = mQPCell->mHolder.lock();
3436  if (handle) {
3437  auto &pSnapManager = handle->mSnapManager;
3438  if (! pSnapManager)
3439  pSnapManager = std::make_unique<SnapManager>(mTracks, mViewInfo);
3440 
3441  auto results = pSnapManager->Snap(NULL, mQuickPlayPos, false);
3442  mQuickPlayPos = results.outTime;
3443  mIsSnapped = results.Snapped();
3444  }
3445 }
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 2679 of file Ruler.cpp.

References Ruler::Invalidate(), and mRuler.

2680 {
2681  mRuler.Invalidate();
2682 }
Ruler mRuler
Definition: Ruler.h:389
void Invalidate()
Definition: Ruler.cpp:373
bool AdornedRulerPanel::IsWithinMarker ( int  mousePosX,
double  markerTime 
)
private

Definition at line 2873 of file Ruler.cpp.

References SELECT_TOLERANCE_PIXEL, and Time2Pos().

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

2874 {
2875  if (markerTime < 0)
2876  return false;
2877 
2878  int pixelPos = Time2Pos(markerTime);
2879  int boundLeft = pixelPos - SELECT_TOLERANCE_PIXEL;
2880  int boundRight = pixelPos + SELECT_TOLERANCE_PIXEL;
2881 
2882  return mousePosX >= boundLeft && mousePosX < boundRight;
2883 }
#define SELECT_TOLERANCE_PIXEL
Definition: Ruler.cpp:109
int Time2Pos(double t, bool ignoreFisheye=false)
Definition: Ruler.cpp:2865
void AdornedRulerPanel::OnAutoScroll ( wxCommandEvent &  evt)
private

Definition at line 3455 of file Ruler.cpp.

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

3456 {
3458  gPrefs->Write(wxT("/GUI/AutoScroll"), false);
3459  else
3460  gPrefs->Write(wxT("/GUI/AutoScroll"), true);
3461  mProject->UpdatePrefs();
3462  gPrefs->Flush();
3463 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
ViewInfo * mViewInfo
bool bUpdateTrackIndicator
Definition: ViewInfo.h:182
void UpdatePrefs()
Definition: Project.cpp:1361
AudacityProject *const mProject
Definition: Ruler.h:390
void AdornedRulerPanel::OnLockPlayRegion ( wxCommandEvent &  evt)
private

Definition at line 3466 of file Ruler.cpp.

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

3467 {
3470  else
3472 }
void OnUnlockPlayRegion(const CommandContext &context)
Definition: Menus.cpp:9698
void OnLockPlayRegion(const CommandContext &context)
Definition: Menus.cpp:9680
AudacityProject *const mProject
Definition: Ruler.h:390
bool IsPlayRegionLocked()
Definition: Project.h:211
MenuCommandHandler & GetMenuCommandHandler(AudacityProject &project)
Definition: Menus.cpp:152
void AdornedRulerPanel::OnPaint ( wxPaintEvent &  evt)
private

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

2764 {
2765  if (mNeedButtonUpdate) {
2766  // Visit this block once only in the lifetime of this panel
2767  mNeedButtonUpdate = false;
2768  // Do this first time setting of button status texts
2769  // when we are sure the CommandManager is initialized.
2770  ReCreateButtons();
2771  // Sends a resize event, which will cause a second paint.
2772  UpdatePrefs();
2773  }
2774 
2775  wxPaintDC dc(this);
2776 
2777  auto &backDC = GetBackingDCForRepaint();
2778 
2779  DoDrawBackground(&backDC);
2780 
2782  {
2783  DoDrawSelection(&backDC);
2784  }
2785 
2786  DoDrawMarks(&backDC, true);
2787 
2788  DoDrawPlayRegion(&backDC);
2789 
2790  DoDrawEdge(&backDC);
2791 
2792  DisplayBitmap(dc);
2793 
2794  // Stroke extras direct to the client area,
2795  // maybe outside of the damaged area
2796  // As with TrackPanel, do not make a NEW wxClientDC or else Mac flashes badly!
2797  dc.DestroyClippingRegion();
2798  DrawOverlays(true, &dc);
2799 }
ViewInfo * mViewInfo
bool isPoint() const
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
void DoDrawEdge(wxDC *dc)
Definition: Ruler.cpp:3569
void DoDrawMarks(wxDC *dc, bool)
Definition: Ruler.cpp:3584
void DoDrawBackground(wxDC *dc)
Definition: Ruler.cpp:3553
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:3476
void ReCreateButtons()
Definition: Ruler.cpp:2605
bool mNeedButtonUpdate
Definition: Ruler.h:451
void DoDrawSelection(wxDC *dc)
Definition: Ruler.cpp:3601
void UpdatePrefs()
Definition: Ruler.cpp:2581
void AdornedRulerPanel::OnRecordStartStop ( wxCommandEvent &  evt)
private

Definition at line 2743 of file Ruler.cpp.

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

Referenced by AdornedRulerPanel().

2744 {
2745  evt.Skip();
2746 
2747  if (evt.GetInt() != 0)
2748  {
2749  mIsRecording = true;
2750  this->CellularPanel::CancelDragging( false );
2752 
2754  }
2755  else {
2756  mIsRecording = false;
2758  }
2759 
2761 }
void RegenerateTooltips()
Definition: Ruler.cpp:2738
bool CancelDragging(bool escaping)
bool mIsRecording
Definition: Ruler.h:412
void UpdateButtonStates()
Definition: Ruler.cpp:3299
void AdornedRulerPanel::OnSize ( wxSizeEvent &  evt)
private

Definition at line 2801 of file Ruler.cpp.

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

2802 {
2803  mOuter = GetClientRect();
2804  if (mOuter.GetWidth() == 0 || mOuter.GetHeight() == 0)
2805  {
2806  return;
2807  }
2808 
2809  UpdateRects();
2810 
2811  OverlayPanel::OnSize(evt);
2812 }
void OnSize(wxSizeEvent &event)
Definition: BackedPanel.cpp:70
void UpdateRects()
Definition: Ruler.cpp:2814
wxRect mOuter
Definition: Ruler.h:393
void AdornedRulerPanel::OnSyncSelToQuickPlay ( wxCommandEvent &  evt)
private

Definition at line 3420 of file Ruler.cpp.

References gPrefs, and mPlayRegionDragsSelection.

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

Definition at line 3447 of file Ruler.cpp.

References gPrefs, mTimelineToolTip, and RegenerateTooltips().

3448 {
3449  mTimelineToolTip = (mTimelineToolTip)? false : true;
3450  gPrefs->Write(wxT("/QuickPlay/ToolTips"), mTimelineToolTip);
3451  gPrefs->Flush();
3453 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void RegenerateTooltips()
Definition: Ruler.cpp:2738
bool mTimelineToolTip
Definition: Ruler.h:430
void AdornedRulerPanel::OnTogglePinnedState ( wxCommandEvent &  event)
private

Definition at line 3329 of file Ruler.cpp.

References GetMenuCommandHandler(), mProject, MenuCommandHandler::OnTogglePinnedHead(), and UpdateButtonStates().

3330 {
3333 }
void OnTogglePinnedHead(const CommandContext &context)
Definition: Menus.cpp:3219
AudacityProject *const mProject
Definition: Ruler.h:390
void UpdateButtonStates()
Definition: Ruler.cpp:3299
MenuCommandHandler & GetMenuCommandHandler(AudacityProject &project)
Definition: Menus.cpp:152
void AdornedRulerPanel::OnToggleQuickPlay ( wxCommandEvent &  evt)
private

Definition at line 3412 of file Ruler.cpp.

References gPrefs, mQuickPlayEnabled, and RegenerateTooltips().

3413 {
3414  mQuickPlayEnabled = (mQuickPlayEnabled)? false : true;
3415  gPrefs->Write(wxT("/QuickPlay/QuickPlayEnabled"), mQuickPlayEnabled);
3416  gPrefs->Flush();
3418 }
bool mQuickPlayEnabled
Definition: Ruler.h:431
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void RegenerateTooltips()
Definition: Ruler.cpp:2738
void AdornedRulerPanel::OnToggleScrubRuler ( )

Definition at line 3277 of file Ruler.cpp.

References gPrefs, mShowScrubbing, and SetPanelSize().

Referenced by Scrubber::OnToggleScrubRuler().

3278 {
3280  WriteScrubEnabledPref(mShowScrubbing);
3281  gPrefs->Flush();
3282  SetPanelSize();
3283 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
bool mShowScrubbing
Definition: Ruler.h:446
void SetPanelSize()
Definition: Ruler.cpp:3285
void AdornedRulerPanel::OnToggleScrubRulerFromMenu ( wxCommandEvent &  )

Definition at line 3271 of file Ruler.cpp.

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

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

Definition at line 2858 of file Ruler.cpp.

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

Referenced by DoDrawMarks(), and UpdateQuickPlayPos().

2859 {
2861  , ignoreFisheye
2862  );
2863 }
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 3804 of file Ruler.cpp.

References RefreshCode::DrawOverlays.

3806 {
3807  (void)pLatestCell;// Compiler food
3808  (void)pClickedTrack;// Compiler food
3809  if (refreshResult & RefreshCode::DrawOverlays)
3810  DrawBothOverlays();
3811 }
void DrawBothOverlays()
Definition: Ruler.cpp:3293
void AdornedRulerPanel::ReCreateButtons ( )

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

2606 {
2607  // TODO: Should we do this to destroy the grabber??
2608  // Get rid of any children we may have
2609  // DestroyChildren();
2610 
2611  SetBackgroundColour(theTheme.Colour( clrMedium ));
2612 
2613  for (auto & button : mButtons) {
2614  if (button)
2615  button->Destroy();
2616  button = nullptr;
2617  }
2618 
2619  size_t iButton = 0;
2620  // Make the short row of time ruler pushbottons.
2621  // Don't bother with sizers. Their sizes and positions are fixed.
2622  // Add a grabber converted to a spacer.
2623  // This makes it visually clearer that the button is a button.
2624 
2625  wxPoint position( 1, 0 );
2626 
2627  Grabber * pGrabber = safenew Grabber(this, this->GetId());
2628  pGrabber->SetAsSpacer( true );
2629  //pGrabber->SetSize( 10, 27 ); // default is 10,27
2630  pGrabber->SetPosition( position );
2631 
2632  position.x = 12;
2633 
2634  auto size = theTheme.ImageSize( bmpRecoloredUpSmall );
2635  size.y = std::min(size.y, GetRulerHeight(false));
2636 
2637  auto buttonMaker = [&]
2638  (wxWindowID id, teBmps bitmap, bool toggle)
2639  {
2640  const auto button =
2642  this,
2643  bmpRecoloredUpSmall, bmpRecoloredDownSmall,
2644  bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
2645  bitmap, bitmap, bitmap,
2646  id, position, toggle, size
2647  );
2648 
2649  position.x += size.GetWidth();
2650  mButtons[iButton++] = button;
2651  return button;
2652  };
2653  auto button = buttonMaker(OnTogglePinnedStateID, bmpPlayPointerPinned, true);
2655  *button, 3,
2656  bmpRecoloredUpSmall, bmpRecoloredDownSmall,
2657  bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
2658  //bmpUnpinnedPlayHead, bmpUnpinnedPlayHead, bmpUnpinnedPlayHead,
2659  bmpRecordPointer, bmpRecordPointer, bmpRecordPointer,
2660  size);
2662  *button, 2,
2663  bmpRecoloredUpSmall, bmpRecoloredDownSmall,
2664  bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
2665  //bmpUnpinnedPlayHead, bmpUnpinnedPlayHead, bmpUnpinnedPlayHead,
2666  bmpRecordPointerPinned, bmpRecordPointerPinned, bmpRecordPointerPinned,
2667  size);
2669  *button, 1,
2670  bmpRecoloredUpSmall, bmpRecoloredDownSmall,
2671  bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
2672  //bmpUnpinnedPlayHead, bmpUnpinnedPlayHead, bmpUnpinnedPlayHead,
2673  bmpPlayPointer, bmpPlayPointer, bmpPlayPointer,
2674  size);
2675 
2677 }
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:782
#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:815
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:3299
void AdornedRulerPanel::RegenerateTooltips ( )

Definition at line 2738 of file Ruler.cpp.

References CellularPanel::HandleCursorForPresentMouseState().

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

2739 {
2740  CallAfter( [this]{ HandleCursorForPresentMouseState(); } );
2741 }
void HandleCursorForPresentMouseState(bool doHit=true)
void AdornedRulerPanel::SetFocusedCell ( )
overrideprivatevirtual

Implements CellularPanel.

Definition at line 3798 of file Ruler.cpp.

3799 {
3800 }
void AdornedRulerPanel::SetLeftOffset ( int  offset)

Definition at line 3623 of file Ruler.cpp.

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

Referenced by TrackPanel::UpdateVRulerSize().

3624 {
3625  mLeftOffset = offset;
3626  mRuler.SetUseZoomInfo(offset, mViewInfo);
3627 }
ViewInfo * mViewInfo
Ruler mRuler
Definition: Ruler.h:389
void SetUseZoomInfo(int leftOffset, const ZoomInfo *zoomInfo)
Definition: Ruler.cpp:1614
void AdornedRulerPanel::SetPanelSize ( )

Definition at line 3285 of file Ruler.cpp.

References GetRulerHeight(), and mShowScrubbing.

Referenced by OnToggleScrubRuler(), and UpdatePrefs().

3286 {
3287  wxSize size { GetSize().GetWidth(), GetRulerHeight(mShowScrubbing) };
3288  SetSize(size);
3289  SetMinSize(size);
3290  GetParent()->PostSizeEventToParent();
3291 }
int GetRulerHeight()
Definition: Ruler.h:326
bool mShowScrubbing
Definition: Ruler.h:446
void AdornedRulerPanel::SetPlayRegion ( double  playRegionStart,
double  playRegionEnd 
)

Definition at line 3713 of file Ruler.cpp.

References mesNone, mMouseEventState, mPlayRegionEnd, and mPlayRegionStart.

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

3715 {
3716  // This is called by AudacityProject to make the play region follow
3717  // the current selection. But while the user is selecting a play region
3718  // with the mouse directly in the ruler, changes from outside are blocked.
3719  if (mMouseEventState != mesNone)
3720  return;
3721 
3722  mPlayRegionStart = playRegionStart;
3723  mPlayRegionEnd = playRegionEnd;
3724 
3725  Refresh();
3726 }
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 3532 of file Ruler.cpp.

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

Referenced by DoContextMenu().

3533 {
3534  wxPoint position;
3535  if(pPosition)
3536  position = *pPosition;
3537  else
3538  {
3539  auto rect = GetRect();
3540  position = { rect.GetLeft() + 1, rect.GetBottom() + 1 };
3541  }
3542 
3543  switch (choice) {
3544  case MenuChoice::QuickPlay:
3545  ShowMenu(position); break;
3546  case MenuChoice::Scrub:
3547  ShowScrubMenu(position); break;
3548  default:
3549  return;
3550  }
3551 }
void ShowScrubMenu(const wxPoint &pos)
Definition: Ruler.cpp:3401
void ShowMenu(const wxPoint &pos)
Definition: Ruler.cpp:3357
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 3357 of file Ruler.cpp.

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

Referenced by ShowContextMenu().

3358 {
3359  wxMenu rulerMenu;
3360 
3361  if (mQuickPlayEnabled)
3362  rulerMenu.Append(OnToggleQuickPlayID, _("Disable Quick-Play"));
3363  else
3364  rulerMenu.Append(OnToggleQuickPlayID, _("Enable Quick-Play"));
3365 
3366  wxMenuItem *dragitem;
3368  dragitem = rulerMenu.Append(OnSyncQuickPlaySelID, _("Disable dragging selection"));
3369  else
3370  dragitem = rulerMenu.Append(OnSyncQuickPlaySelID, _("Enable dragging selection"));
3371  dragitem->Enable(mQuickPlayEnabled && !mProject->IsPlayRegionLocked());
3372 
3373 #if wxUSE_TOOLTIPS
3374  if (mTimelineToolTip)
3375  rulerMenu.Append(OnTimelineToolTipID, _("Disable Timeline Tooltips"));
3376  else
3377  rulerMenu.Append(OnTimelineToolTipID, _("Enable Timeline Tooltips"));
3378 #endif
3379 
3381  rulerMenu.Append(OnAutoScrollID, _("Do not scroll while playing"));
3382  else
3383  rulerMenu.Append(OnAutoScrollID, _("Update display while playing"));
3384 
3385  wxMenuItem *prlitem;
3386  if (!mProject->IsPlayRegionLocked())
3387  prlitem = rulerMenu.Append(OnLockPlayRegionID, _("Lock Play Region"));
3388  else
3389  prlitem = rulerMenu.Append(OnLockPlayRegionID, _("Unlock Play Region"));
3390  prlitem->Enable(mProject->IsPlayRegionLocked() || (mPlayRegionStart != mPlayRegionEnd));
3391 
3392  wxMenuItem *ruleritem;
3393  if (mShowScrubbing)
3394  ruleritem = rulerMenu.Append(OnScrubRulerID, _("Disable Scrub Ruler"));
3395  else
3396  ruleritem = rulerMenu.Append(OnScrubRulerID, _("Enable Scrub Ruler"));
3397 
3398  PopupMenu(&rulerMenu, pos);
3399 }
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:211
double mPlayRegionEnd
Definition: Ruler.h:408
void AdornedRulerPanel::ShowScrubMenu ( const wxPoint &  pos)
private

Definition at line 3401 of file Ruler.cpp.

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

Referenced by ShowContextMenu().

3402 {
3403  auto &scrubber = mProject->GetScrubber();
3404  PushEventHandler(&scrubber);
3405  auto cleanup = finally([this]{ PopEventHandler(); });
3406 
3407  wxMenu rulerMenu;
3408  mProject->GetScrubber().PopulatePopupMenu(rulerMenu);
3409  PopupMenu(&rulerMenu, pos);
3410 }
Scrubber & GetScrubber()
Definition: Project.h:804
AudacityProject *const mProject
Definition: Ruler.h:390
void PopulatePopupMenu(wxMenu &menu)
Definition: Scrubbing.cpp:1184
void AdornedRulerPanel::StartQPPlay ( bool  looped,
bool  cutPreview 
)
private

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

3206 {
3207  const double t0 = mTracks->GetStartTime();
3208  const double t1 = mTracks->GetEndTime();
3209  const double sel0 = mProject->GetSel0();
3210  const double sel1 = mProject->GetSel1();
3211 
3212  // Start / Restart playback on left click.
3213  bool startPlaying = (mPlayRegionStart >= 0);
3214 
3215  if (startPlaying) {
3217  ctb->StopPlaying();
3218 
3219  bool loopEnabled = true;
3220  double start, end;
3221 
3222  if ((mPlayRegionEnd - mPlayRegionStart == 0.0) && looped) {
3223  // Loop play a point will loop either a selection or the project.
3224  if ((mPlayRegionStart > sel0) && (mPlayRegionStart < sel1)) {
3225  // we are in a selection, so use the selection
3226  start = sel0;
3227  end = sel1;
3228  } // not in a selection, so use the project
3229  else {
3230  start = t0;
3231  end = t1;
3232  }
3233  }
3234  else {
3235  start = mPlayRegionStart;
3236  end = mPlayRegionEnd;
3237  }
3238  // Looping a tiny selection may freeze, so just play it once.
3239  loopEnabled = ((end - start) > 0.001)? true : false;
3240 
3242  options.playLooped = (loopEnabled && looped);
3243 
3244  auto oldStart = mPlayRegionStart;
3245  if (!cutPreview)
3246  options.pStartTime = &oldStart;
3247  else
3248  options.timeTrack = NULL;
3249 
3250  ControlToolBar::PlayAppearance appearance =
3252  : options.playLooped ? ControlToolBar::PlayAppearance::Looped
3254 
3255  mPlayRegionStart = start;
3256  mPlayRegionEnd = end;
3257  Refresh();
3258 
3259  ctb->PlayPlayRegion((SelectedRegion(start, end)),
3260  options, PlayMode::normalPlay,
3261  appearance,
3262  false,
3263  true);
3264 
3265  }
3266 }
A ToolBar that has the main Transport buttons.
AudioIOStartStreamOptions GetDefaultPlayOptions()
Definition: Project.cpp:1300
double GetSel0() const
Definition: Project.h:204
double GetStartTime() const
Definition: Track.cpp:1165
double GetEndTime() const
Definition: Track.cpp:1170
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:4909
double GetSel1() const
Definition: Project.h:205
double mPlayRegionEnd
Definition: Ruler.h:408
bool AdornedRulerPanel::TakesFocus ( ) const
overrideprivatevirtual

Implements CellularPanel.

Definition at line 3818 of file Ruler.cpp.

3819 {
3820  return false;
3821 }
int AdornedRulerPanel::Time2Pos ( double  t,
bool  ignoreFisheye = false 
)
private

Definition at line 2865 of file Ruler.cpp.

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

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

2866 {
2868  , ignoreFisheye
2869  );
2870 }
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 3299 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(), MenuCommandHandler::OnTogglePinnedHead(), OnTogglePinnedState(), ReCreateButtons(), and UpdatePrefs().

3300 {
3301  auto common = [this]
3302  (AButton &button, const wxString &commandName, const wxString &label) {
3303  TranslatedInternalString command{ commandName, label };
3304  ToolBar::SetButtonToolTip( button, &command, 1u );
3305  button.SetLabel(button.GetToolTipText());
3306 
3307  button.UpdateStatus();
3308  };
3309 
3310  {
3311  // The button always reflects the pinned head preference, even though
3312  // there is also a Playback preference that may overrule it for scrubbing
3313  bool state = TracksPrefs::GetPinnedHeadPreference();
3314  auto pinButton = static_cast<AButton*>(FindWindow(OnTogglePinnedStateID));
3315  if( !state )
3316  pinButton->PopUp();
3317  else
3318  pinButton->PushDown();
3319  pinButton->SetAlternateIdx(
3320  (gAudioIO->IsCapturing() ? 2 : 0) + (state ? 0 : 1));
3321  // Bug 1584: Toltip now shows what clicking will do.
3322  const auto label = state
3323  ? _("Click to unpin")
3324  : _("Click to pin");
3325  common(*pinButton, wxT("PinnedHead"), label);
3326  }
3327 }
void PopUp()
Definition: AButton.cpp:525
bool IsCapturing() const
Definition: AudioIO.cpp:5793
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:492
static bool GetPinnedHeadPreference()
static void SetButtonToolTip(AButton &button, const TranslatedInternalString commands[], size_t nCommands)
Definition: ToolBar.cpp:840
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void UpdateStatus()
Definition: AButton.cpp:421
void AdornedRulerPanel::UpdatePrefs ( )

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

2582 {
2583  // Update button texts for language change
2585 
2586 #ifdef EXPERIMENTAL_SCROLLING_LIMITS
2587 #ifdef EXPERIMENTAL_TWO_TONE_TIME_RULER
2588  {
2589  bool scrollBeyondZero = false;
2590  gPrefs->Read(TracksBehaviorsPrefs::ScrollingPreferenceKey(), &scrollBeyondZero,
2592  mRuler.SetTwoTone(scrollBeyondZero);
2593  }
2594 #endif
2595 #endif
2596 
2597  mShowScrubbing = ReadScrubEnabledPref();
2598  // Affected by the last
2599  UpdateRects();
2600  SetPanelSize();
2601 
2603 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
static const wxChar * ScrollingPreferenceKey()
Ruler mRuler
Definition: Ruler.h:389
void UpdateRects()
Definition: Ruler.cpp:2814
void SetTwoTone(bool twoTone)
Definition: Ruler.cpp:185
bool mShowScrubbing
Definition: Ruler.h:446
void SetPanelSize()
Definition: Ruler.cpp:3285
void RegenerateTooltips()
Definition: Ruler.cpp:2738
static bool ScrollingPreferenceDefault()
void UpdateButtonStates()
Definition: Ruler.cpp:3299
void AdornedRulerPanel::UpdateQuickPlayPos ( wxCoord &  mousePosX,
bool  shiftDown 
)

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

3336 {
3337  // Keep Quick-Play within usable track area.
3339  int width;
3340  tp->GetTracksUsableArea(&width, NULL);
3341  mousePosX = std::max(mousePosX, tp->GetLeftOffset());
3342  mousePosX = std::min(mousePosX, tp->GetLeftOffset() + width - 1);
3343 
3345 
3346  HandleSnapping();
3347 
3348  // If not looping, restrict selection to end of project
3349  if ((LastCell() == mQPCell || mQPCell->Clicked()) && !shiftDown) {
3350  const double t1 = mTracks->GetEndTime();
3352  }
3353 }
double GetEndTime() const
Definition: Track.cpp:1170
void HandleSnapping()
Definition: Ruler.cpp:3433
std::shared_ptr< TrackPanelCell > LastCell() const
void GetTracksUsableArea(int *width, int *height) const
Definition: TrackPanel.cpp:409
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:309
int GetLeftOffset() const
Definition: TrackPanel.h:270
double Pos2Time(int p, bool ignoreFisheye=false)
Definition: Ruler.cpp:2858
std::shared_ptr< QPCell > mQPCell
Definition: Ruler.h:486
void AdornedRulerPanel::UpdateRects ( )
private

Definition at line 2814 of file Ruler.cpp.

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

Referenced by OnSize(), and UpdatePrefs().

2815 {
2816  mInner = mOuter;
2817  mInner.x += LeftMargin;
2818  mInner.width -= (LeftMargin + RightMargin);
2819 
2820  auto top = &mInner;
2821  auto bottom = &mInner;
2822 
2823  if (mShowScrubbing) {
2824  mScrubZone = mInner;
2825  auto scrubHeight = std::min(mScrubZone.height, (int)(ScrubHeight));
2826 
2827  int topHeight;
2828 #ifdef SCRUB_ABOVE
2829  top = &mScrubZone, topHeight = scrubHeight;
2830 #else
2831  auto qpHeight = mScrubZone.height - scrubHeight;
2832  bottom = &mScrubZone, topHeight = qpHeight;
2833  // Increase scrub zone height so that hit testing finds it and
2834  // not QP region, when on bottom 'edge'.
2835  mScrubZone.height+=BottomMargin;
2836 #endif
2837 
2838  top->height = topHeight;
2839  bottom->height -= topHeight;
2840  bottom->y += topHeight;
2841  }
2842 
2843  top->y += TopMargin;
2844  top->height -= TopMargin;
2845 
2846  bottom->height -= BottomMargin;
2847 
2848  if (!mShowScrubbing)
2849  mScrubZone = mInner;
2850 
2851  mRuler.SetBounds(mInner.GetLeft(),
2852  mInner.GetTop(),
2853  mInner.GetRight(),
2854  mInner.GetBottom());
2855 
2856 }
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:360
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 3813 of file Ruler.cpp.

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

3814 {
3815  GetProject()->TP_DisplayStatusMessage(message);
3816 }
AudacityProject * GetProject() const override
Definition: Ruler.cpp:3785
void TP_DisplayStatusMessage(const wxString &msg) override
Definition: Project.cpp:5243

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: