Audacity 3.2.0
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static 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 <AdornedRulerPanel.h>

Inheritance diagram for AdornedRulerPanel:
[legend]
Collaboration diagram for AdornedRulerPanel:
[legend]

Classes

class  CommonCell
 
class  CommonRulerHandle
 
struct  MainGroup
 
class  MovePlayRegionHandle
 
class  NewPlayRegionHandle
 
class  PlayRegionAdjustingHandle
 
class  QPCell
 
struct  Resetter
 
class  ResizePlayRegionHandle
 
class  ScrubbingCell
 
class  ScrubbingHandle
 
class  ScrubbingRulerOverlay
 
struct  Subgroup
 
class  TrackPanelGuidelineOverlay
 

Public Member Functions

 AdornedRulerPanel (AudacityProject *project, wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, ViewInfo *viewinfo=NULL)
 
 ~AdornedRulerPanel ()
 
void Refresh (bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
void SetFocusFromKbd () override
 
int GetRulerHeight ()
 
wxRect GetInnerRect () const
 
void SetLeftOffset (int offset)
 
void DrawSelection ()
 
void SetPlayRegion (double playRegionStart, double playRegionEnd)
 
void ClearPlayRegion ()
 
void TogglePinnedHead ()
 
void GetMaxSize (wxCoord *width, wxCoord *height)
 
void InvalidateRuler ()
 
void UpdatePrefs () override
 
void ReCreateButtons ()
 
void UpdateQuickPlayPos (wxCoord &mousePosX)
 
bool ShowingScrubRuler () const
 
bool SetPanelSize ()
 
void DrawBothOverlays ()
 
void DoDrawScrubIndicator (wxDC *dc, wxCoord xx, int width, bool scrub, bool seek)
 
void UpdateButtonStates ()
 
void SetNumGuides (size_t nn)
 
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
 
virtual AudacityProjectGetProject () const =0
 
virtual std::shared_ptr< TrackPanelNodeRoot ()=0
 
virtual TrackPanelCellGetFocusedCell ()=0
 
virtual void SetFocusedCell ()=0
 
virtual void ProcessUIHandleResult (TrackPanelCell *pClickedCell, TrackPanelCell *pLatestCell, unsigned refreshResult)=0
 
virtual void UpdateStatusMessage (const TranslatableString &)=0
 
void Visit (Visitor &visitor)
 
void VisitCells (const SimpleCellVisitor &visitor)
 
void VisitPreorder (const SimpleNodeVisitor &visitor)
 
void VisitPostorder (const SimpleNodeVisitor &visitor)
 
FoundCell FindCell (int mouseX, int mouseY)
 
wxRect FindRect (const TrackPanelCell &cell)
 
wxRect FindRect (const std::function< bool(TrackPanelNode &) > &pred)
 
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)
 
void Draw (TrackPanelDrawingContext &context, unsigned nPasses)
 
- 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 (const std::weak_ptr< 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 TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- 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 AdornedRulerPanelGet (AudacityProject &project)
 
static const AdornedRulerPanelGet (const AudacityProject &project)
 
static void Destroy (AudacityProject &project)
 
static int GetRulerHeight (bool showScrubBar)
 
static TempAllowFocus TemporarilyAllowFocus ()
 

Private Types

enum class  MenuChoice { QuickPlay , Scrub }
 
enum  MouseEventState {
  mesNone , mesDraggingPlayRegionStart , mesDraggingPlayRegionEnd , mesSelectingPlayRegionClick ,
  mesSelectingPlayRegionRange
}
 
using TempAllowFocus = std::unique_ptr< bool, Resetter >
 

Private Member Functions

void DoIdle ()
 
void OnIdle (wxIdleEvent &evt)
 
void OnAudioStartStop (AudioIOEvent)
 
void OnPaint (wxPaintEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 
void OnLeave (wxMouseEvent &evt)
 
void OnThemeChange (wxCommandEvent &evt)
 
void OnSelectionChange (Observer::Message)
 
void DoSelectionChange (const SelectedRegion &selectedRegion)
 
bool UpdateRects ()
 
void HandleQPClick (wxMouseEvent &event, wxCoord mousePosX)
 
void HandleQPDrag (wxMouseEvent &event, wxCoord mousePosX)
 
void HandleQPRelease (wxMouseEvent &event)
 
void StartQPPlay (bool newDefault, bool cutPreview, const double *pStartTime=nullptr)
 
void DoDrawBackground (wxDC *dc)
 
void DoDrawEdge (wxDC *dc)
 
void DoDrawMarks (wxDC *dc, bool)
 
wxRect RegionRectangle (double t0, double t1) const
 
wxRect PlayRegionRectangle () const
 
wxRect SelectedRegionRectangle () const
 
void DoDrawPlayRegion (wxDC *dc, const wxRect &rectP, const wxRect &rectL, const wxRect &rectR)
 
void DoDrawPlayRegionLimits (wxDC *dc, const wxRect &rect)
 
void DoDrawOverlap (wxDC *dc, const wxRect &rect)
 
void DoDrawSelection (wxDC *dc, const wxRect &rectS, const wxRect &rectL, const wxRect &rectR)
 
void ShowContextMenu (MenuChoice choice, const wxPoint *pPosition)
 
double Pos2Time (int p, bool ignoreFisheye=false) const
 
int Time2Pos (double t, bool ignoreFisheye=false) const
 
bool IsWithinMarker (int mousePosX, double markerTime)
 
void ShowMenu (const wxPoint &pos)
 
void ShowScrubMenu (const wxPoint &pos)
 
void HandleSnapping (size_t index)
 
void OnSyncSelToQuickPlay (wxCommandEvent &evt)
 
void OnAutoScroll (wxCommandEvent &evt)
 
void OnTogglePlayRegion (wxCommandEvent &evt)
 
void OnClearPlayRegion (wxCommandEvent &evt)
 
void OnSetPlayRegionToSelection (wxCommandEvent &evt)
 
void OnPinnedButton (wxCommandEvent &event)
 
void OnTogglePinnedState (wxCommandEvent &event)
 
std::shared_ptr< TrackPanelNodeRoot () override
 
TrackPanelCellGetFocusedCell () override
 
void SetFocusedCell () override
 
void ProcessUIHandleResult (TrackPanelCell *pClickedTrack, TrackPanelCell *pLatestCell, unsigned refreshResult) override
 
void UpdateStatusMessage (const TranslatableString &) override
 
void CreateOverlays ()
 
- Private Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
virtual void UpdateSelectedPrefs (int id)
 

Static Private Member Functions

static void DragSelection (AudacityProject &project)
 
- Static Private Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

Private Attributes

Ruler mRuler
 
AudacityProject *const mProject
 
TrackListmTracks
 
wxRect mOuter
 
wxRect mScrubZone
 
wxRect mInner
 
int mLeftOffset
 
double mIndTime
 
double mQuickPlayOffset [MAX_GUIDES] {}
 
double mQuickPlayPosUnsnapped [MAX_GUIDES] {}
 
double mQuickPlayPos [MAX_GUIDES] {}
 
bool mIsSnapped [MAX_GUIDES] {}
 
size_t mNumGuides { 1 }
 
PlayRegion mOldPlayRegion
 
bool mIsRecording
 
bool mPlayRegionDragsSelection
 
bool mTimelineToolTip
 
MouseEventState mMouseEventState
 
double mLeftDownClickUnsnapped
 
double mLeftDownClick
 
bool mIsDragging
 
wxWindow * mButtons [3]
 
bool mNeedButtonUpdate { true }
 
std::shared_ptr< TrackPanelGuidelineOverlaymOverlay
 
std::shared_ptr< QPCellmQPCell
 
std::shared_ptr< ScrubbingCellmScrubbingCell
 
Observer::Subscription mAudioIOSubscription
 
Observer::Subscription mPlayRegionSubscription
 
SelectedRegion mLastDrawnSelectedRegion
 
std::pair< double, double > mLastDrawnPlayRegion {}
 
bool mLastPlayRegionActive = false
 
double mLastDrawnH {}
 
double mLastDrawnZoom {}
 

Static Private Attributes

static bool s_AcceptsFocus { false }
 
static constexpr size_t MAX_GUIDES = 2
 

Additional Inherited Members

- Public Types inherited from CellularPanel
using SimpleCellVisitor = std::function< void(const wxRect &rect, TrackPanelCell &cell) >
 
using SimpleNodeVisitor = std::function< void(const wxRect &rect, TrackPanelNode &node) >
 
- 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 26 of file AdornedRulerPanel.h.

Member Typedef Documentation

◆ TempAllowFocus

using AdornedRulerPanel::TempAllowFocus = std::unique_ptr<bool, Resetter>
private

Definition at line 118 of file AdornedRulerPanel.h.

Member Enumeration Documentation

◆ MenuChoice

enum class AdornedRulerPanel::MenuChoice
strongprivate
Enumerator
QuickPlay 
Scrub 

Definition at line 126 of file AdornedRulerPanel.h.

126{ QuickPlay, Scrub };

◆ MouseEventState

Enumerator
mesNone 
mesDraggingPlayRegionStart 
mesDraggingPlayRegionEnd 
mesSelectingPlayRegionClick 
mesSelectingPlayRegionRange 

Definition at line 180 of file AdornedRulerPanel.h.

Constructor & Destructor Documentation

◆ AdornedRulerPanel()

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

Definition at line 1253 of file AdornedRulerPanel.cpp.

1259: CellularPanel(parent, id, pos, size, viewinfo)
1260, mProject(project)
1261{
1262 SetLayoutDirection(wxLayout_LeftToRight);
1263
1264 mQPCell = std::make_shared<QPCell>( this );
1265 mScrubbingCell = std::make_shared<ScrubbingCell>( this );
1266
1267 for (auto &button : mButtons)
1268 button = nullptr;
1269
1270 SetLabel( XO("Timeline") );
1271 SetName();
1272 SetBackgroundStyle(wxBG_STYLE_PAINT);
1273
1274 mLeftOffset = 0;
1275 mIndTime = -1;
1276
1277 mLeftDownClick = -1;
1279 mIsDragging = false;
1280
1281 mOuter = GetClientRect();
1282
1284 mRuler.SetLabelEdges( false );
1286
1287 mTracks = &TrackList::Get( *project );
1288
1289 mIsRecording = false;
1290
1291 mTimelineToolTip = !!gPrefs->Read(wxT("/QuickPlay/ToolTips"), 1L);
1292 mPlayRegionDragsSelection = (gPrefs->Read(wxT("/QuickPlay/DragSelection"), 0L) == 1)? true : false;
1293
1294#if wxUSE_TOOLTIPS
1295 wxToolTip::Enable(true);
1296#endif
1297
1300
1301 // Delay until after CommandManager has been populated:
1303
1304 wxTheApp->Bind(EVT_THEME_CHANGE, &AdornedRulerPanel::OnThemeChange, this);
1305
1306 // Bind event that updates the play region
1309
1310 // And call it once to initialize it
1312}
#define XO(s)
Definition: Internat.h:31
FileConfig * gPrefs
Definition: Prefs.cpp:71
void OnSelectionChange(Observer::Message)
void UpdatePrefs() override
void OnAudioStartStop(AudioIOEvent)
std::shared_ptr< ScrubbingCell > mScrubbingCell
Observer::Subscription mAudioIOSubscription
void DoSelectionChange(const SelectedRegion &selectedRegion)
wxWindow * mButtons[3]
AudacityProject *const mProject
Observer::Subscription mPlayRegionSubscription
void OnThemeChange(wxCommandEvent &evt)
MouseEventState mMouseEventState
std::shared_ptr< QPCell > mQPCell
static AudioIO * Get()
Definition: AudioIO.cpp:140
ViewInfo * mViewInfo
CellularPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, ViewInfo *viewInfo, long style=wxTAB_TRAVERSAL|wxNO_BORDER)
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
void SetUseZoomInfo(int leftOffset, const ZoomInfo *zoomInfo)
Definition: Ruler.cpp:1680
void SetLabelEdges(bool labelEdges)
Definition: Ruler.cpp:226
void SetFormat(RulerFormat format)
Definition: Ruler.cpp:131
@ TimeFormat
Definition: Ruler.h:33
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:467
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216
void SetLabel(const TranslatableString &label)
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:38

References BasicUI::CallAfter(), DoSelectionChange(), AudioIO::Get(), TrackList::Get(), gPrefs, mAudioIOSubscription, mButtons, mesNone, mIndTime, mIsDragging, mIsRecording, mLeftDownClick, mLeftOffset, mMouseEventState, mOuter, mPlayRegionDragsSelection, mPlayRegionSubscription, mQPCell, mRuler, mScrubbingCell, mTimelineToolTip, mTracks, CellularPanel::mViewInfo, OnAudioStartStop(), OnSelectionChange(), OnThemeChange(), ViewInfo::selectedRegion, Ruler::SetFormat(), wxPanelWrapper::SetLabel(), Ruler::SetLabelEdges(), wxPanelWrapper::SetName(), Ruler::SetUseZoomInfo(), Observer::Publisher< Message, NotifyAll >::Subscribe(), Ruler::TimeFormat, UpdatePrefs(), and XO.

Here is the call graph for this function:

◆ ~AdornedRulerPanel()

AdornedRulerPanel::~AdornedRulerPanel ( )

Definition at line 1314 of file AdornedRulerPanel.cpp.

1315{
1316}

Member Function Documentation

◆ AcceptsFocus()

bool AdornedRulerPanel::AcceptsFocus ( ) const
inlineoverride

Definition at line 48 of file AdornedRulerPanel.h.

48{ return s_AcceptsFocus; }
static bool s_AcceptsFocus

◆ AcceptsFocusFromKeyboard()

bool AdornedRulerPanel::AcceptsFocusFromKeyboard ( ) const
inlineoverride

Definition at line 49 of file AdornedRulerPanel.h.

49{ return true; }

◆ ClearPlayRegion()

void AdornedRulerPanel::ClearPlayRegion ( )

Definition at line 2657 of file AdornedRulerPanel.cpp.

2658{
2659 ProjectAudioManager::Get( *mProject ).Stop();
2660
2661 auto &viewInfo = ViewInfo::Get( *GetProject() );
2662 auto &playRegion = viewInfo.playRegion;
2663 playRegion.SetTimes( -1, -1 );
2664
2665 Refresh();
2666}
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
AudacityProject * GetProject() const override
void Stop(bool stopStream=true)
static ProjectAudioManager & Get(AudacityProject &project)
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References ViewInfo::Get(), ProjectAudioManager::Get(), GetProject(), Refresh(), and ProjectAudioManager::Stop().

Here is the call graph for this function:

◆ CreateOverlays()

void AdornedRulerPanel::CreateOverlays ( )
private

Definition at line 2777 of file AdornedRulerPanel.cpp.

2778{
2779 if (!mOverlay) {
2780 mOverlay =
2781 std::make_shared<TrackPanelGuidelineOverlay>( mProject );
2782 auto pCellularPanel =
2783 dynamic_cast<CellularPanel*>( &GetProjectPanel( *GetProject() ) );
2784 if ( !pCellularPanel ) {
2785 wxASSERT( false );
2786 }
2787 else
2788 pCellularPanel->AddOverlay( mOverlay );
2789 this->AddOverlay( mOverlay->mPartner );
2790 }
2791}
AUDACITY_DLL_API wxWindow & GetProjectPanel(AudacityProject &project)
Get the main sub-window of the project frame that displays track data.
std::shared_ptr< TrackPanelGuidelineOverlay > mOverlay
Formerly part of TrackPanel, this abstract base class has no special knowledge of Track objects and i...
Definition: CellularPanel.h:34
void AddOverlay(const std::weak_ptr< Overlay > &pOverlay)

References OverlayPanel::AddOverlay(), GetProject(), GetProjectPanel(), mOverlay, and mProject.

Here is the call graph for this function:

◆ Destroy()

void AdornedRulerPanel::Destroy ( AudacityProject project)
static

Definition at line 1244 of file AdornedRulerPanel.cpp.

1245{
1246 auto *pPanel = GetAttachedWindows(project).Find( sKey );
1247 if (pPanel) {
1248 pPanel->wxWindow::Destroy();
1249 GetAttachedWindows(project).Assign( sKey, nullptr );
1250 }
1251}
AUDACITY_DLL_API AttachedWindows & GetAttachedWindows(AudacityProject &project)
Subclass * Find(const RegisteredFactory &key)
Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand...
Definition: ClientData.h:333
void Assign(const RegisteredFactory &key, ReplacementPointer &&replacement)
Reassign Site's pointer to ClientData.
Definition: ClientData.h:355
AttachedWindows::RegisteredFactory sKey

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Assign(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Find(), GetAttachedWindows(), and anonymous_namespace{AdornedRulerPanel.cpp}::sKey.

Referenced by ProjectManager::OnCloseWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoDrawBackground()

void AdornedRulerPanel::DoDrawBackground ( wxDC *  dc)
private

Definition at line 2413 of file AdornedRulerPanel.cpp.

2414{
2415 // Draw AdornedRulerPanel border
2417 dc->DrawRectangle( mInner );
2418
2419 if (ShowingScrubRuler()) {
2420 // Let's distinguish the scrubbing area by using a themable
2421 // colour and a line to set it off.
2422 AColor::UseThemeColour(dc, clrScrubRuler, TimelineTextColor() );
2423 wxRect ScrubRect = mScrubZone;
2424 ScrubRect.Inflate( 1,0 );
2425 dc->DrawRectangle(ScrubRect);
2426 }
2427}
ColorId TimelineBackgroundColor()
ColorId TimelineTextColor()
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1, int alpha=255)
Definition: AColor.cpp:349
bool ShowingScrubRuler() const

References mInner, mScrubZone, ShowingScrubRuler(), TimelineBackgroundColor(), TimelineTextColor(), and AColor::UseThemeColour().

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoDrawEdge()

void AdornedRulerPanel::DoDrawEdge ( wxDC *  dc)
private

Definition at line 2429 of file AdornedRulerPanel.cpp.

2430{
2431 wxRect r = mOuter;
2432 r.width -= RightMargin;
2433 r.height -= BottomMargin;
2434 AColor::BevelTrackInfo( *dc, true, r );
2435
2436 // Black stroke at bottom
2437 dc->SetPen( *wxBLACK_PEN );
2438 AColor::Line( *dc, mOuter.x,
2439 mOuter.y + mOuter.height - 1,
2440 mOuter.x + mOuter.width - 1 ,
2441 mOuter.y + mOuter.height - 1 );
2442}
@ RightMargin
@ BottomMargin
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
static void BevelTrackInfo(wxDC &dc, bool up, const wxRect &r, bool highlight=false)
Definition: AColor.cpp:317

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

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoDrawMarks()

void AdornedRulerPanel::DoDrawMarks ( wxDC *  dc,
bool   
)
private

Definition at line 2444 of file AdornedRulerPanel.cpp.

2445{
2446 const double min = Pos2Time(0);
2447 const double hiddenMin = Pos2Time(0, true);
2448 const double max = Pos2Time(mInner.width);
2449 const double hiddenMax = Pos2Time(mInner.width, true);
2450
2452 mRuler.SetRange( min, max, hiddenMin, hiddenMax );
2453 mRuler.Draw( *dc );
2454}
int min(int a, int b)
THEME_API Theme theTheme
Definition: Theme.cpp:82
double Pos2Time(int p, bool ignoreFisheye=false) const
void SetTickColour(const wxColour &colour)
Definition: Ruler.h:148
void Draw(wxDC &dc) const
Definition: Ruler.cpp:1428
void SetRange(double min, double max)
Definition: Ruler.cpp:188
wxColour & Colour(int iIndex)

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

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoDrawOverlap()

void AdornedRulerPanel::DoDrawOverlap ( wxDC *  dc,
const wxRect &  rect 
)
private

Definition at line 2551 of file AdornedRulerPanel.cpp.

2552{
2553 dc->SetBrush( wxBrush{ AlphaBlend(
2555 SelectionOpacity) } );
2556 dc->SetPen( *wxTRANSPARENT_PEN );
2557 dc->DrawRectangle( rect );
2558}
ColorId TimelineLimitsColor()
ColorId TimelineLoopRegionColor(bool isActive)
static wxColour AlphaBlend(ColorId fg, ColorId bg, double alpha)
constexpr double SelectionOpacity

References AlphaBlend(), mLastPlayRegionActive, SelectionOpacity, TimelineLimitsColor(), and TimelineLoopRegionColor().

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoDrawPlayRegion()

void AdornedRulerPanel::DoDrawPlayRegion ( wxDC *  dc,
const wxRect &  rectP,
const wxRect &  rectL,
const wxRect &  rectR 
)
private

Definition at line 2493 of file AdornedRulerPanel.cpp.

2495{
2496 const auto &viewInfo = ViewInfo::Get(*mProject);
2497 const auto &playRegion = viewInfo.playRegion;
2498 if (playRegion.IsLastActiveRegionClear())
2499 return;
2500
2501 const bool isActive = (mLastPlayRegionActive = playRegion.Active());
2502
2503 // Paint the selected region bolder if independently varying, else dim
2504 const auto color = TimelineLoopRegionColor(isActive);
2505 dc->SetBrush( wxBrush( theTheme.Colour( color )) );
2506 dc->SetPen( wxPen( theTheme.Colour( color )) );
2507
2508 dc->DrawRectangle( rectP.Intersect(rectL) );
2509 dc->DrawRectangle( rectP.Intersect(rectR) );
2510}

References ThemeBase::Colour(), ViewInfo::Get(), mLastPlayRegionActive, mProject, theTheme, and TimelineLoopRegionColor().

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoDrawPlayRegionLimits()

void AdornedRulerPanel::DoDrawPlayRegionLimits ( wxDC *  dc,
const wxRect &  rect 
)
private

Definition at line 2512 of file AdornedRulerPanel.cpp.

2513{
2514 // Color the edges of the play region like the ticks and numbers
2515 ADCChanger cleanup( dc );
2516 const auto edgeColour = theTheme.Colour(TimelineLimitsColor());
2517 dc->SetPen( { edgeColour } );
2518 dc->SetBrush( { edgeColour } );
2519
2520 constexpr int side = 7;
2521 constexpr int sideLessOne = side - 1;
2522
2523 // Paint two shapes, each a line plus triangle at bottom
2524 const auto left = rect.GetLeft(),
2525 right = rect.GetRight(),
2526 bottom = rect.GetBottom(),
2527 top = rect.GetTop();
2528 {
2529 wxPoint points[]{
2530 {left, bottom - sideLessOne},
2531 {left - sideLessOne, bottom},
2532 {left, bottom},
2533 {left, top},
2534 };
2535 dc->DrawPolygon( 4, points );
2536 }
2537
2538 {
2539 wxPoint points[]{
2540 {right, top},
2541 {right, bottom},
2542 {right + sideLessOne, bottom},
2543 {right, bottom - sideLessOne},
2544 };
2545 dc->DrawPolygon( 4, points );
2546 }
2547}
Makes temporary drawing context changes that you back out of, RAII style.
Definition: OverlayPanel.h:72

References ThemeBase::Colour(), theTheme, and TimelineLimitsColor().

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoDrawScrubIndicator()

void AdornedRulerPanel::DoDrawScrubIndicator ( wxDC *  dc,
wxCoord  xx,
int  width,
bool  scrub,
bool  seek 
)

Definition at line 2582 of file AdornedRulerPanel.cpp.

2584{
2585 ADCChanger changer(dc); // Undo pen and brush changes at function exit
2586
2587 wxPoint tri[ 3 ];
2588 if (seek) {
2589 auto height = IndicatorHeightForWidth(width);
2590 // Make four triangles
2591 const int TriangleWidth = width * 3 / 8;
2592
2593 // Double-double headed, left-right
2594 auto yy = ShowingScrubRuler()
2595 ? mScrubZone.y
2596 : (mInner.GetBottom() + 1) - 1 /* bevel */ - height;
2597 tri[ 0 ].x = xx - IndicatorOffset;
2598 tri[ 0 ].y = yy;
2599 tri[ 1 ].x = xx - IndicatorOffset;
2600 tri[ 1 ].y = yy + height;
2601 tri[ 2 ].x = xx - TriangleWidth;
2602 tri[ 2 ].y = yy + height / 2;
2603 dc->DrawPolygon( 3, tri );
2604
2605 tri[ 0 ].x -= TriangleWidth;
2606 tri[ 1 ].x -= TriangleWidth;
2607 tri[ 2 ].x -= TriangleWidth;
2608 dc->DrawPolygon( 3, tri );
2609
2610 tri[ 0 ].x = tri[ 1 ].x = xx + IndicatorOffset;
2611 tri[ 2 ].x = xx + TriangleWidth;
2612 dc->DrawPolygon( 3, tri );
2613
2614
2615 tri[ 0 ].x += TriangleWidth;
2616 tri[ 1 ].x += TriangleWidth;
2617 tri[ 2 ].x += TriangleWidth;
2618 dc->DrawPolygon( 3, tri );
2619 }
2620 else if (scrub) {
2621 auto height = IndicatorHeightForWidth(width);
2622 const int IndicatorHalfWidth = width / 2;
2623
2624 // Double headed, left-right
2625 auto yy = ShowingScrubRuler()
2626 ? mScrubZone.y
2627 : (mInner.GetBottom() + 1) - 1 /* bevel */ - height;
2628 tri[ 0 ].x = xx - IndicatorOffset;
2629 tri[ 0 ].y = yy;
2630 tri[ 1 ].x = xx - IndicatorOffset;
2631 tri[ 1 ].y = yy + height;
2632 tri[ 2 ].x = xx - IndicatorHalfWidth;
2633 tri[ 2 ].y = yy + height / 2;
2634 dc->DrawPolygon( 3, tri );
2635 tri[ 0 ].x = tri[ 1 ].x = xx + IndicatorOffset;
2636 tri[ 2 ].x = xx + IndicatorHalfWidth;
2637 dc->DrawPolygon( 3, tri );
2638 }
2639}
@ IndicatorOffset
int IndicatorHeightForWidth(int width)

References IndicatorHeightForWidth(), IndicatorOffset, mInner, mScrubZone, and ShowingScrubRuler().

Here is the call graph for this function:

◆ DoDrawSelection()

void AdornedRulerPanel::DoDrawSelection ( wxDC *  dc,
const wxRect &  rectS,
const wxRect &  rectL,
const wxRect &  rectR 
)
private

Definition at line 2560 of file AdornedRulerPanel.cpp.

2562{
2563 dc->SetBrush( wxBrush{ AlphaBlend(
2565 dc->SetPen( *wxTRANSPARENT_PEN );
2566 dc->DrawRectangle( rectS.Intersect(rectL) );
2567 dc->DrawRectangle( rectS.Intersect(rectR) );
2568}

References AlphaBlend(), SelectionOpacity, TimelineBackgroundColor(), and TimelineLimitsColor().

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoIdle()

void AdornedRulerPanel::DoIdle ( )
private

Definition at line 1501 of file AdornedRulerPanel.cpp.

1502{
1503 bool changed = UpdateRects();
1504 changed = SetPanelSize() || changed;
1505
1506 auto &project = *mProject;
1507 auto &viewInfo = ViewInfo::Get( project );
1508 const auto &selectedRegion = viewInfo.selectedRegion;
1509 const auto &playRegion = viewInfo.playRegion;
1510
1511 changed = changed
1512 || mLastDrawnSelectedRegion != selectedRegion
1513 || mLastDrawnPlayRegion != std::pair{
1514 playRegion.GetLastActiveStart(), playRegion.GetLastActiveEnd() }
1515 || mLastDrawnH != viewInfo.h
1516 || mLastDrawnZoom != viewInfo.GetZoom()
1517 || mLastPlayRegionActive != viewInfo.playRegion.Active()
1518 ;
1519 if (changed)
1520 // Cause ruler redraw anyway, because we may be zooming or scrolling,
1521 // showing or hiding the scrub bar, etc.
1522 Refresh();
1523}
std::pair< double, double > mLastDrawnPlayRegion
SelectedRegion mLastDrawnSelectedRegion

References ViewInfo::Get(), mLastDrawnH, mLastDrawnPlayRegion, mLastDrawnSelectedRegion, mLastDrawnZoom, mLastPlayRegionActive, mProject, Refresh(), SetPanelSize(), and UpdateRects().

Referenced by OnIdle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoSelectionChange()

void AdornedRulerPanel::DoSelectionChange ( const SelectedRegion selectedRegion)
private

Definition at line 1635 of file AdornedRulerPanel.cpp.

1637{
1638
1639 auto gAudioIO = AudioIOBase::Get();
1640 if ( !ViewInfo::Get( *mProject ).playRegion.Active() ) {
1641 // "Inactivated" play region follows the selection.
1642 SetPlayRegion( selectedRegion.t0(), selectedRegion.t1() );
1643 }
1644}
void SetPlayRegion(double playRegionStart, double playRegionEnd)
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:89
bool Active() const
Definition: ViewInfo.h:123
double t1() const
double t0() const
PlayRegion playRegion
Definition: ViewInfo.h:217

References PlayRegion::Active(), AudioIOBase::Get(), ViewInfo::Get(), ViewInfo::playRegion, SetPlayRegion(), SelectedRegion::t0(), and SelectedRegion::t1().

Referenced by AdornedRulerPanel(), OnAudioStartStop(), and OnSelectionChange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DragSelection()

void AdornedRulerPanel::DragSelection ( AudacityProject project)
staticprivate

Definition at line 2286 of file AdornedRulerPanel.cpp.

2287{
2288 auto &viewInfo = ViewInfo::Get( project );
2289 const auto &playRegion = viewInfo.playRegion;
2290 auto &selectedRegion = viewInfo.selectedRegion;
2291 selectedRegion.setT0(playRegion.GetStart(), false);
2292 selectedRegion.setT1(playRegion.GetEnd(), true);
2293}

References ViewInfo::Get().

Referenced by AdornedRulerPanel::PlayRegionAdjustingHandle::Drag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawBothOverlays()

void AdornedRulerPanel::DrawBothOverlays ( )

Definition at line 2150 of file AdornedRulerPanel.cpp.

2151{
2152 auto pCellularPanel =
2153 dynamic_cast<CellularPanel*>( &GetProjectPanel( *GetProject() ) );
2154 if ( !pCellularPanel ) {
2155 wxASSERT( false );
2156 }
2157 else
2158 pCellularPanel->DrawOverlays( false );
2159 DrawOverlays( false );
2160}
void DrawOverlays(bool repaint_all, wxDC *pDC=nullptr)

References OverlayPanel::DrawOverlays(), GetProject(), and GetProjectPanel().

Referenced by OnLeave(), and ProcessUIHandleResult().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawSelection()

void AdornedRulerPanel::DrawSelection ( )

Definition at line 2456 of file AdornedRulerPanel.cpp.

2457{
2458 Refresh();
2459}

References Refresh().

Referenced by TrackPanel::UpdateSelectionDisplay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [1/2]

AdornedRulerPanel & AdornedRulerPanel::Get ( AudacityProject project)
static

Definition at line 1233 of file AdornedRulerPanel.cpp.

1234{
1235 return GetAttachedWindows(project).Get< AdornedRulerPanel >( sKey );
1236}
This is an Audacity Specific ruler panel which additionally has border, selection markers,...
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:309

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), GetAttachedWindows(), and anonymous_namespace{AdornedRulerPanel.cpp}::sKey.

Referenced by ScrubbingToolBar::DoRegenerateTooltips(), AdornedRulerPanel::PlayRegionAdjustingHandle::Drag(), AdornedRulerPanel::TrackPanelGuidelineOverlay::Draw(), EditCursorOverlay::Draw(), PlayIndicatorOverlayBase::Draw(), ScrubbingToolBar::EnableDisableButtons(), Get(), anonymous_namespace{PlayIndicatorOverlay.cpp}::GetIndicatorBitmap(), AdornedRulerPanel::ScrubbingRulerOverlay::GetRuler(), AdornedRulerPanel::PlayRegionAdjustingHandle::HasEscape(), InitProjectWindow(), anonymous_namespace{SelectMenus.cpp}::MoveWhenAudioInactive(), EditActions::Handler::OnCut(), PlayIndicatorOverlay::OnTimer(), ScrubbingOverlay::OnTimer(), TransportActions::Handler::OnTogglePinnedHead(), ScrubForwarder::ScrubForwarder(), AdornedRulerPanel::PlayRegionAdjustingHandle::SnappedTime(), AdornedRulerPanel::PlayRegionAdjustingHandle::SnappedTimes(), AdornedRulerPanel::CommonRulerHandle::StartPlay(), AdornedRulerPanel::PlayRegionAdjustingHandle::Unsnap(), and AdornedRulerPanel::TrackPanelGuidelineOverlay::Update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [2/2]

const AdornedRulerPanel & AdornedRulerPanel::Get ( const AudacityProject project)
static

Definition at line 1238 of file AdornedRulerPanel.cpp.

1240{
1241 return Get( const_cast< AudacityProject & >( project ) );
1242}
static AdornedRulerPanel & Get(AudacityProject &project)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89

References Get().

Here is the call graph for this function:

◆ GetFocusedCell()

TrackPanelCell * AdornedRulerPanel::GetFocusedCell ( )
overrideprivatevirtual

Implements CellularPanel.

Definition at line 2751 of file AdornedRulerPanel.cpp.

2752{
2753 // No switching of focus yet to the other, scrub zone
2754 return mQPCell.get();
2755}

References mQPCell.

◆ GetInnerRect()

wxRect AdornedRulerPanel::GetInnerRect ( ) const
inline

Definition at line 55 of file AdornedRulerPanel.h.

55{ return mInner; }

Referenced by anonymous_namespace{PlayIndicatorOverlay.cpp}::GetIndicatorBitmap().

Here is the caller graph for this function:

◆ GetMaxSize()

void AdornedRulerPanel::GetMaxSize ( wxCoord *  width,
wxCoord *  height 
)

Definition at line 2668 of file AdornedRulerPanel.cpp.

2669{
2670 mRuler.GetMaxSize(width, height);
2671}
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:1603

References Ruler::GetMaxSize(), and mRuler.

Here is the call graph for this function:

◆ GetProject()

AudacityProject * AdornedRulerPanel::GetProject ( ) const
overridevirtual

Implements CellularPanel.

Definition at line 2745 of file AdornedRulerPanel.cpp.

2746{
2747 return mProject;
2748}

References mProject.

Referenced by ClearPlayRegion(), CreateOverlays(), DrawBothOverlays(), HandleSnapping(), OnPaint(), SetPlayRegion(), ShowingScrubRuler(), ShowMenu(), and UpdateStatusMessage().

Here is the caller graph for this function:

◆ GetRulerHeight() [1/2]

int AdornedRulerPanel::GetRulerHeight ( )
inline

Definition at line 53 of file AdornedRulerPanel.h.

References GetRulerHeight().

Referenced by ScreenshotCommand::GetPanelRect(), GetRulerHeight(), ReCreateButtons(), and SetPanelSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRulerHeight() [2/2]

int AdornedRulerPanel::GetRulerHeight ( bool  showScrubBar)
static

Definition at line 2570 of file AdornedRulerPanel.cpp.

2571{
2572 return ProperRulerHeight + (showScrubBar ? ScrubHeight : 0);
2573}
@ ProperRulerHeight
@ ScrubHeight

References ProperRulerHeight, and ScrubHeight.

◆ HandleQPClick()

void AdornedRulerPanel::HandleQPClick ( wxMouseEvent &  event,
wxCoord  mousePosX 
)
private

◆ HandleQPDrag()

void AdornedRulerPanel::HandleQPDrag ( wxMouseEvent &  event,
wxCoord  mousePosX 
)
private

◆ HandleQPRelease()

void AdornedRulerPanel::HandleQPRelease ( wxMouseEvent &  event)
private

◆ HandleSnapping()

void AdornedRulerPanel::HandleSnapping ( size_t  index)
private

Definition at line 2295 of file AdornedRulerPanel.cpp.

2296{
2297 // Play region dragging can snap to selection boundaries
2298 const auto &selectedRegion = ViewInfo::Get(*GetProject()).selectedRegion;
2299 SnapPointArray candidates;
2301 candidates = {
2302 SnapPoint{ selectedRegion.t0() },
2303 SnapPoint{ selectedRegion.t1() },
2304 };
2305 SnapManager snapManager{ *mProject, *mTracks, *mViewInfo, move(candidates) };
2306 auto results = snapManager.Snap(nullptr, mQuickPlayPos[index], false);
2307 mQuickPlayPos[index] = results.outTime;
2308 mIsSnapped[index] = results.Snapped();
2309}
std::vector< SnapPoint > SnapPointArray
Definition: Snap.h:43
bool mIsSnapped[MAX_GUIDES]
double mQuickPlayPos[MAX_GUIDES]
Definition: Snap.h:31

References ViewInfo::Get(), GetProject(), mIsSnapped, mPlayRegionDragsSelection, mProject, mQuickPlayPos, mTracks, CellularPanel::mViewInfo, and ViewInfo::selectedRegion.

Referenced by UpdateQuickPlayPos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InvalidateRuler()

void AdornedRulerPanel::InvalidateRuler ( )

Definition at line 1424 of file AdornedRulerPanel.cpp.

1425{
1427}
void Invalidate()
Definition: Ruler.cpp:345

References Ruler::Invalidate(), and mRuler.

Here is the call graph for this function:

◆ IsWithinMarker()

bool AdornedRulerPanel::IsWithinMarker ( int  mousePosX,
double  markerTime 
)
private

Definition at line 1713 of file AdornedRulerPanel.cpp.

1714{
1715 if (markerTime < 0)
1716 return false;
1717
1718 int pixelPos = Time2Pos(markerTime);
1719 int boundLeft = pixelPos - SELECT_TOLERANCE_PIXEL;
1720 int boundRight = pixelPos + SELECT_TOLERANCE_PIXEL;
1721
1722 return mousePosX >= boundLeft && mousePosX < boundRight;
1723}
#define SELECT_TOLERANCE_PIXEL
int Time2Pos(double t, bool ignoreFisheye=false) const

References SELECT_TOLERANCE_PIXEL, and Time2Pos().

Here is the call graph for this function:

◆ OnAudioStartStop()

void AdornedRulerPanel::OnAudioStartStop ( AudioIOEvent  evt)
private

Definition at line 1525 of file AdornedRulerPanel.cpp.

1526{
1527 if (evt.type == AudioIOEvent::MONITOR)
1528 return;
1529 if ( evt.type == AudioIOEvent::CAPTURE ) {
1530 if (evt.on)
1531 {
1532 mIsRecording = true;
1533 this->CellularPanel::CancelDragging( false );
1535
1537 }
1538 else {
1539 mIsRecording = false;
1541 }
1542 }
1543
1544 if ( !evt.on )
1545 // So that the play region is updated
1547}
bool CancelDragging(bool escaping)
bool on
Definition: AudioIO.h:73
enum AudioIOEvent::Type type

References CellularPanel::CancelDragging(), AudioIOEvent::CAPTURE, CellularPanel::ClearTargets(), DoSelectionChange(), mIsRecording, AudioIOEvent::MONITOR, CellularPanel::mViewInfo, AudioIOEvent::on, ViewInfo::selectedRegion, AudioIOEvent::type, and UpdateButtonStates().

Referenced by AdornedRulerPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnAutoScroll()

void AdornedRulerPanel::OnAutoScroll ( wxCommandEvent &  evt)
private

Definition at line 2320 of file AdornedRulerPanel.cpp.

2321{
2323 gPrefs->Write(wxT("/GUI/AutoScroll"), false);
2324 else
2325 gPrefs->Write(wxT("/GUI/AutoScroll"), true);
2326
2327 gPrefs->Flush();
2328
2330}
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
static void Broadcast(int id=0)
Call this static function to notify all PrefsListener objects.
Definition: Prefs.cpp:98
bool bUpdateTrackIndicator
Definition: ViewInfo.h:239
static int UpdateScrollPrefsID()
Definition: ViewInfo.cpp:327

References PrefsListener::Broadcast(), ViewInfo::bUpdateTrackIndicator, FileConfig::Flush(), gPrefs, CellularPanel::mViewInfo, and ViewInfo::UpdateScrollPrefsID().

Here is the call graph for this function:

◆ OnClearPlayRegion()

void AdornedRulerPanel::OnClearPlayRegion ( wxCommandEvent &  evt)
private

Definition at line 2338 of file AdornedRulerPanel.cpp.

2339{
2341}
void ClearPlayRegion(AudacityProject &project)

References SelectUtilities::ClearPlayRegion(), and mProject.

Here is the call graph for this function:

◆ OnIdle()

void AdornedRulerPanel::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 1495 of file AdornedRulerPanel.cpp.

1496{
1497 evt.Skip();
1498 DoIdle();
1499}

References DoIdle().

Here is the call graph for this function:

◆ OnLeave()

void AdornedRulerPanel::OnLeave ( wxMouseEvent &  evt)
private

Definition at line 1615 of file AdornedRulerPanel.cpp.

1616{
1617 evt.Skip();
1618 CallAfter([this]{
1620 });
1621}

References BasicUI::CallAfter(), and DrawBothOverlays().

Here is the call graph for this function:

◆ OnPaint()

void AdornedRulerPanel::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 1549 of file AdornedRulerPanel.cpp.

1550{
1551 const auto &viewInfo = ViewInfo::Get( *GetProject() );
1552 const auto &playRegion = viewInfo.playRegion;
1553 const auto playRegionBounds = std::pair{
1554 playRegion.GetLastActiveStart(), playRegion.GetLastActiveEnd() };
1555 mLastDrawnH = viewInfo.h;
1556 mLastDrawnZoom = viewInfo.GetZoom();
1557 mLastDrawnPlayRegion = playRegionBounds;
1558 mLastDrawnSelectedRegion = viewInfo.selectedRegion;
1559 // To do, note other fisheye state when we have that
1560
1561 wxPaintDC dc(this);
1562
1563 auto &backDC = GetBackingDCForRepaint();
1564
1565 DoDrawBackground(&backDC);
1566
1567 // Find play region rectangle, selected rectangle, and their overlap
1568 const auto rectP = PlayRegionRectangle(),
1569 rectS = SelectedRegionRectangle(),
1570 rectO = rectP.Intersect(rectS);
1571
1572 // What's left and right of the overlap? Assume same tops and bottoms
1573 const auto top = rectP.GetTop(),
1574 bottom = rectP.GetBottom();
1575 wxRect rectL{
1576 wxPoint{ 0, top }, wxPoint{ this->GetSize().GetWidth() - 1, bottom } };
1577 wxRect rectR = {};
1578 if (!rectO.IsEmpty()) {
1579 rectR = { wxPoint{ rectO.GetRight() + 1, top }, rectL.GetBottomRight() };
1580 rectL = { rectL.GetTopLeft(), wxPoint{ rectO.GetLeft() - 1, bottom } };
1581 }
1582
1583 DoDrawPlayRegion(&backDC, rectP, rectL, rectR);
1584 DoDrawOverlap(&backDC, rectO);
1585 DoDrawSelection(&backDC, rectS, rectL, rectR);
1586
1587 DoDrawPlayRegionLimits(&backDC, rectP);
1588
1589 DoDrawMarks(&backDC, true);
1590
1591 DoDrawEdge(&backDC);
1592
1593 DisplayBitmap(dc);
1594
1595 // Stroke extras direct to the client area,
1596 // maybe outside of the damaged area
1597 // As with TrackPanel, do not make a NEW wxClientDC or else Mac flashes badly!
1598 dc.DestroyClippingRegion();
1599 DrawOverlays(true, &dc);
1600}
wxRect PlayRegionRectangle() const
void DoDrawOverlap(wxDC *dc, const wxRect &rect)
wxRect SelectedRegionRectangle() const
void DoDrawMarks(wxDC *dc, bool)
void DoDrawPlayRegion(wxDC *dc, const wxRect &rectP, const wxRect &rectL, const wxRect &rectR)
void DoDrawSelection(wxDC *dc, const wxRect &rectS, const wxRect &rectL, const wxRect &rectR)
void DoDrawBackground(wxDC *dc)
void DoDrawPlayRegionLimits(wxDC *dc, const wxRect &rect)
void DoDrawEdge(wxDC *dc)
wxDC & GetBackingDCForRepaint()
Definition: BackedPanel.cpp:35
void DisplayBitmap(wxDC &dc)
Definition: BackedPanel.cpp:65

References BackedPanel::DisplayBitmap(), DoDrawBackground(), DoDrawEdge(), DoDrawMarks(), DoDrawOverlap(), DoDrawPlayRegion(), DoDrawPlayRegionLimits(), DoDrawSelection(), OverlayPanel::DrawOverlays(), ViewInfo::Get(), BackedPanel::GetBackingDCForRepaint(), GetProject(), mLastDrawnH, mLastDrawnPlayRegion, mLastDrawnSelectedRegion, mLastDrawnZoom, PlayRegionRectangle(), and SelectedRegionRectangle().

Here is the call graph for this function:

◆ OnPinnedButton()

void AdornedRulerPanel::OnPinnedButton ( wxCommandEvent &  event)
private

Definition at line 2192 of file AdornedRulerPanel.cpp.

2193{
2195}
void ShowContextMenu(MenuChoice choice, const wxPoint *pPosition)

References QuickPlay, and ShowContextMenu().

Here is the call graph for this function:

◆ OnSelectionChange()

void AdornedRulerPanel::OnSelectionChange ( Observer::Message  )
private

Definition at line 1629 of file AdornedRulerPanel.cpp.

1630{
1631 auto &selectedRegion = mViewInfo->selectedRegion;
1632 DoSelectionChange( selectedRegion );
1633}

References DoSelectionChange(), CellularPanel::mViewInfo, and ViewInfo::selectedRegion.

Referenced by AdornedRulerPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSetPlayRegionToSelection()

void AdornedRulerPanel::OnSetPlayRegionToSelection ( wxCommandEvent &  evt)
private

Definition at line 2343 of file AdornedRulerPanel.cpp.

2344{
2346}
void SetPlayRegionToSelection(AudacityProject &project)

References mProject, and SelectUtilities::SetPlayRegionToSelection().

Here is the call graph for this function:

◆ OnSize()

void AdornedRulerPanel::OnSize ( wxSizeEvent &  evt)
private

Definition at line 1602 of file AdornedRulerPanel.cpp.

1603{
1604 mOuter = GetClientRect();
1605 if (mOuter.GetWidth() == 0 || mOuter.GetHeight() == 0)
1606 {
1607 return;
1608 }
1609
1610 UpdateRects();
1611
1613}
void OnSize(wxSizeEvent &event)
Definition: BackedPanel.cpp:71

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

Here is the call graph for this function:

◆ OnSyncSelToQuickPlay()

void AdornedRulerPanel::OnSyncSelToQuickPlay ( wxCommandEvent &  evt)
private

Definition at line 2279 of file AdornedRulerPanel.cpp.

2280{
2282 gPrefs->Write(wxT("/QuickPlay/DragSelection"), mPlayRegionDragsSelection);
2283 gPrefs->Flush();
2284}

References FileConfig::Flush(), gPrefs, and mPlayRegionDragsSelection.

Here is the call graph for this function:

◆ OnThemeChange()

void AdornedRulerPanel::OnThemeChange ( wxCommandEvent &  evt)
private

Definition at line 1623 of file AdornedRulerPanel.cpp.

1624{
1625 evt.Skip();
1627}

References ReCreateButtons().

Referenced by AdornedRulerPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnTogglePinnedState()

void AdornedRulerPanel::OnTogglePinnedState ( wxCommandEvent &  event)
private

Definition at line 2197 of file AdornedRulerPanel.cpp.

2198{
2201}

References TogglePinnedHead(), and UpdateButtonStates().

Here is the call graph for this function:

◆ OnTogglePlayRegion()

void AdornedRulerPanel::OnTogglePlayRegion ( wxCommandEvent &  evt)
private

Definition at line 2333 of file AdornedRulerPanel.cpp.

2334{
2336}
void TogglePlayRegion(AudacityProject &project)

References mProject, and SelectUtilities::TogglePlayRegion().

Here is the call graph for this function:

◆ PlayRegionRectangle()

wxRect AdornedRulerPanel::PlayRegionRectangle ( ) const
private

Definition at line 2461 of file AdornedRulerPanel.cpp.

2462{
2463 const auto &viewInfo = ViewInfo::Get(*mProject);
2464 const auto &playRegion = viewInfo.playRegion;
2465 const auto t0 = playRegion.GetLastActiveStart(),
2466 t1 = playRegion.GetLastActiveEnd();
2467 return RegionRectangle(t0, t1);
2468}
wxRect RegionRectangle(double t0, double t1) const

References ViewInfo::Get(), mProject, and RegionRectangle().

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Pos2Time()

double AdornedRulerPanel::Pos2Time ( int  p,
bool  ignoreFisheye = false 
) const
private

Definition at line 1699 of file AdornedRulerPanel.cpp.

1700{
1702 , ignoreFisheye
1703 );
1704}
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:41

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

Referenced by DoDrawMarks(), and UpdateQuickPlayPos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessUIHandleResult()

void AdornedRulerPanel::ProcessUIHandleResult ( TrackPanelCell pClickedTrack,
TrackPanelCell pLatestCell,
unsigned  refreshResult 
)
overrideprivatevirtual

Implements CellularPanel.

Definition at line 2763 of file AdornedRulerPanel.cpp.

2765{
2766 if (refreshResult & RefreshCode::RefreshAll)
2767 Refresh(); // Overlays will be repainted too
2768 else if (refreshResult & RefreshCode::DrawOverlays)
2769 DrawBothOverlays(); // cheaper redrawing of guidelines only
2770}

References DrawBothOverlays(), RefreshCode::DrawOverlays, Refresh(), and RefreshCode::RefreshAll.

Here is the call graph for this function:

◆ ReCreateButtons()

void AdornedRulerPanel::ReCreateButtons ( )

Definition at line 1349 of file AdornedRulerPanel.cpp.

1350{
1351 // TODO: Should we do this to destroy the grabber??
1352 // Get rid of any children we may have
1353 // DestroyChildren();
1354
1356 SetBackgroundColour(theTheme.Colour( clrMedium ));
1357
1358 for (auto & button : mButtons) {
1359 if (button)
1360 button->Destroy();
1361 button = nullptr;
1362 }
1363
1364 size_t iButton = 0;
1365 // Make the short row of time ruler pushbottons.
1366 // Don't bother with sizers. Their sizes and positions are fixed.
1367 // Add a grabber converted to a spacer.
1368 // This makes it visually clearer that the button is a button.
1369
1370 wxPoint position( 1, 0 );
1371
1372 Grabber * pGrabber = safenew Grabber(this, this->GetId());
1373 pGrabber->SetAsSpacer( true );
1374 //pGrabber->SetSize( 10, 27 ); // default is 10,27
1375 pGrabber->SetPosition( position );
1376
1377 position.x = 12;
1378
1379 auto size = theTheme.ImageSize( bmpRecoloredUpSmall );
1380 size.y = std::min(size.y, GetRulerHeight(false));
1381
1382 auto buttonMaker = [&]
1383 (wxWindowID id, teBmps bitmap, bool toggle)
1384 {
1385 const auto button =
1387 this,
1388 bmpRecoloredUpSmall, bmpRecoloredDownSmall,
1389 bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
1390 bitmap, bitmap, bitmap,
1391 id, position, toggle, size
1392 );
1393
1394 position.x += size.GetWidth();
1395 mButtons[iButton++] = button;
1396 return button;
1397 };
1398 auto button = buttonMaker(OnTogglePinnedStateID, bmpPlayPointerPinned, true);
1400 *button, 3,
1401 bmpRecoloredUpSmall, bmpRecoloredDownSmall,
1402 bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
1403 //bmpUnpinnedPlayHead, bmpUnpinnedPlayHead, bmpUnpinnedPlayHead,
1404 bmpRecordPointer, bmpRecordPointer, bmpRecordPointer,
1405 size);
1407 *button, 2,
1408 bmpRecoloredUpSmall, bmpRecoloredDownSmall,
1409 bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
1410 //bmpUnpinnedPlayHead, bmpUnpinnedPlayHead, bmpUnpinnedPlayHead,
1411 bmpRecordPointerPinned, bmpRecordPointerPinned, bmpRecordPointerPinned,
1412 size);
1414 *button, 1,
1415 bmpRecoloredUpSmall, bmpRecoloredDownSmall,
1416 bmpRecoloredUpHiliteSmall, bmpRecoloredHiliteSmall,
1417 //bmpUnpinnedPlayHead, bmpUnpinnedPlayHead, bmpUnpinnedPlayHead,
1418 bmpPlayPointer, bmpPlayPointer, bmpPlayPointer,
1419 size);
1420
1422}
@ OnTogglePinnedStateID
int teBmps
#define safenew
Definition: MemoryX.h:10
int id
The widget to the left of a ToolBar that allows it to be dragged around to NEW positions.
Definition: Grabber.h:103
void SetAsSpacer(bool bIsSpacer)
Definition: Grabber.cpp:100
wxSize ImageSize(int iIndex)
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:873
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:840
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:802

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

Referenced by OnThemeChange(), and UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Refresh()

void AdornedRulerPanel::Refresh ( bool  eraseBackground = true,
const wxRect *  rect = (const wxRect *) NULL 
)
override

Definition at line 1318 of file AdornedRulerPanel.cpp.

1319{
1320 CellularPanel::Refresh( eraseBackground, rect );
1322}
void HandleCursorForPresentMouseState(bool doHit=true)

References BasicUI::CallAfter(), and CellularPanel::HandleCursorForPresentMouseState().

Referenced by ClearPlayRegion(), DoIdle(), DrawSelection(), ProcessUIHandleResult(), SetPlayRegion(), and TrackPanel::UpdateVRulerSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegionRectangle()

wxRect AdornedRulerPanel::RegionRectangle ( double  t0,
double  t1 
) const
private

Definition at line 2478 of file AdornedRulerPanel.cpp.

2479{
2480 int p0 = -1, p1 = -1;
2481 if (t0 == t1)
2482 // Make the rectangle off-screen horizontally, but set the height
2483 ;
2484 else {
2485 p0 = max(1, Time2Pos(t0));
2486 p1 = min(mInner.width, Time2Pos(t1));
2487 }
2488
2489 const int left = p0, top = mInner.y, right = p1, bottom = mInner.GetBottom();
2490 return { wxPoint{left, top}, wxPoint{right, bottom} };
2491}

References min(), mInner, and Time2Pos().

Referenced by PlayRegionRectangle(), and SelectedRegionRectangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Root()

std::shared_ptr< TrackPanelNode > AdornedRulerPanel::Root ( )
overrideprivatevirtual

Implements CellularPanel.

Definition at line 2739 of file AdornedRulerPanel.cpp.

2740{
2741 // Root is a throwaway object
2742 return std::make_shared< MainGroup >( *this );
2743}

◆ SelectedRegionRectangle()

wxRect AdornedRulerPanel::SelectedRegionRectangle ( ) const
private

Definition at line 2470 of file AdornedRulerPanel.cpp.

2471{
2472 const auto &viewInfo = ViewInfo::Get(*mProject);
2473 const auto &selectedRegion = viewInfo.selectedRegion;
2474 const auto t0 = selectedRegion.t0(), t1 = selectedRegion.t1();
2475 return RegionRectangle(t0, t1);
2476}

References ViewInfo::Get(), mProject, and RegionRectangle().

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFocusedCell()

void AdornedRulerPanel::SetFocusedCell ( )
overrideprivatevirtual

Implements CellularPanel.

Definition at line 2758 of file AdornedRulerPanel.cpp.

2759{
2760}

◆ SetFocusFromKbd()

void AdornedRulerPanel::SetFocusFromKbd ( )
override

Definition at line 2693 of file AdornedRulerPanel.cpp.

2694{
2695 auto temp = TemporarilyAllowFocus();
2696 SetFocus();
2697}
static TempAllowFocus TemporarilyAllowFocus()

References TemporarilyAllowFocus().

Here is the call graph for this function:

◆ SetLeftOffset()

void AdornedRulerPanel::SetLeftOffset ( int  offset)

Definition at line 2575 of file AdornedRulerPanel.cpp.

2576{
2577 mLeftOffset = offset;
2579}

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

Referenced by TrackPanel::UpdateVRulerSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetNumGuides()

void AdornedRulerPanel::SetNumGuides ( size_t  nn)

Definition at line 2680 of file AdornedRulerPanel.cpp.

2681{
2682 nn = std::min(nn, MAX_GUIDES);
2683 // If increasing the number of guides, reinitialize newer ones
2684 for (size_t ii = mNumGuides; ii < nn; ++ii) {
2685 mQuickPlayOffset[ii] = 0;
2686 mQuickPlayPosUnsnapped[ii] = 0;
2687 mQuickPlayPos[ii] = 0;
2688 mIsSnapped[ii] = false;
2689 }
2690 mNumGuides = nn;
2691}
double mQuickPlayOffset[MAX_GUIDES]
static constexpr size_t MAX_GUIDES
double mQuickPlayPosUnsnapped[MAX_GUIDES]

References MAX_GUIDES, min(), mIsSnapped, mNumGuides, mQuickPlayOffset, mQuickPlayPos, and mQuickPlayPosUnsnapped.

Here is the call graph for this function:

◆ SetPanelSize()

bool AdornedRulerPanel::SetPanelSize ( )

Definition at line 2136 of file AdornedRulerPanel.cpp.

2137{
2138 const auto oldSize = GetSize();
2139 wxSize size { oldSize.GetWidth(), GetRulerHeight(ShowingScrubRuler()) };
2140 if ( size != oldSize ) {
2141 SetSize(size);
2142 SetMinSize(size);
2143 GetParent()->PostSizeEventToParent();
2144 return true;
2145 }
2146 else
2147 return false;
2148}

References GetRulerHeight(), ShowingScrubRuler(), and size.

Referenced by DoIdle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPlayRegion()

void AdornedRulerPanel::SetPlayRegion ( double  playRegionStart,
double  playRegionEnd 
)

Definition at line 2641 of file AdornedRulerPanel.cpp.

2643{
2644 // This is called by AudacityProject to make the play region follow
2645 // the current selection. But while the user is selecting a play region
2646 // with the mouse directly in the ruler, changes from outside are blocked.
2648 return;
2649
2650 auto &viewInfo = ViewInfo::Get( *GetProject() );
2651 auto &playRegion = viewInfo.playRegion;
2652 playRegion.SetTimes( playRegionStart, playRegionEnd );
2653
2654 Refresh();
2655}

References ViewInfo::Get(), GetProject(), mesNone, mMouseEventState, and Refresh().

Referenced by DoSelectionChange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowContextMenu()

void AdornedRulerPanel::ShowContextMenu ( MenuChoice  choice,
const wxPoint *  pPosition 
)
private

Definition at line 2349 of file AdornedRulerPanel.cpp.

2351{
2352 wxPoint position;
2353 if(pPosition)
2354 position = *pPosition;
2355 else
2356 {
2357 auto rect = GetRect();
2358 //Old code put menu too low down. y position applied twice.
2359 //position = { rect.GetLeft() + 1, rect.GetBottom() + 1 };
2360
2361 // The cell does not pass in the mouse or button position.
2362 // We happen to know this is the pin/unpin button
2363 // so these magic values 'fix a bug' - but really the cell should
2364 // pass more information to work with in.
2365 position = { rect.GetLeft() + 38, rect.GetHeight()/2 + 1 };
2366 }
2367
2368 switch (choice) {
2370 ShowMenu(position);
2372 break;
2373 case MenuChoice::Scrub:
2374 ShowScrubMenu(position); break;
2375 default:
2376 return;
2377 }
2378}
void ShowScrubMenu(const wxPoint &pos)
void ShowMenu(const wxPoint &pos)

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

Referenced by OnPinnedButton().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowingScrubRuler()

bool AdornedRulerPanel::ShowingScrubRuler ( ) const

Definition at line 2732 of file AdornedRulerPanel.cpp.

2733{
2734 auto &scrubber = Scrubber::Get( *GetProject() );
2735 return scrubber.ShowsBar();
2736}
static Scrubber & Get(AudacityProject &project)
Definition: Scrubbing.cpp:202

References Scrubber::Get(), and GetProject().

Referenced by AdornedRulerPanel::Subgroup::Children(), DoDrawBackground(), DoDrawScrubIndicator(), ScrubbingToolBar::DoRegenerateTooltips(), ScrubbingToolBar::EnableDisableButtons(), SetPanelSize(), and UpdateRects().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowMenu()

void AdornedRulerPanel::ShowMenu ( const wxPoint &  pos)
private

Definition at line 2225 of file AdornedRulerPanel.cpp.

2226{
2227 const auto &viewInfo = ViewInfo::Get( *GetProject() );
2228 const auto &playRegion = viewInfo.playRegion;
2229 wxMenu rulerMenu;
2230
2231 auto pDrag = rulerMenu.AppendCheckItem(OnSyncQuickPlaySelID, _("Enable dragging selection"));
2232 pDrag->Check(mPlayRegionDragsSelection && playRegion.Active());
2233 pDrag->Enable(playRegion.Active());
2234
2235 rulerMenu.AppendCheckItem(OnAutoScrollID, _("Update display while playing"))->
2237
2238 {
2239 auto item = rulerMenu.AppendCheckItem(OnTogglePlayRegionID,
2241 item->Check(playRegion.Active());
2242 }
2243
2244 {
2245 auto item = rulerMenu.Append(OnClearPlayRegionID,
2246 /* i18n-hint Clear is a verb */
2247 _("Clear Looping Region"));
2248 }
2249
2250 {
2251 auto item = rulerMenu.Append(OnSetPlayRegionToSelectionID,
2252 _("Set Loop To Selection"));
2253 }
2254
2255 rulerMenu.AppendSeparator();
2256 rulerMenu.AppendCheckItem(OnTogglePinnedStateID, _("Pinned Play Head"))->
2258
2259 BasicMenu::Handle{ &rulerMenu }.Popup(
2261 { pos.x, pos.y }
2262 );
2263}
@ OnSetPlayRegionToSelectionID
@ OnClearPlayRegionID
@ OnAutoScrollID
@ OnTogglePlayRegionID
@ OnSyncQuickPlaySelID
#define _(s)
Definition: Internat.h:75
const TranslatableString LoopToggleText
Definition: ViewInfo.cpp:227
void Popup(const BasicUI::WindowPlacement &window, const Point &pos={})
Display the menu at pos, invoke at most one action, then hide it.
Definition: BasicMenu.cpp:207
static bool GetPinnedHeadPreference()
wxString Translation() const
TranslatableString Stripped(unsigned options=MenuCodes) const
non-mutating, constructs another TranslatableString object
Window placement information for wxWidgetsBasicUI can be constructed from a wxWindow pointer.

References _, ViewInfo::bUpdateTrackIndicator, ViewInfo::Get(), TracksPrefs::GetPinnedHeadPreference(), GetProject(), LoopToggleText, mPlayRegionDragsSelection, CellularPanel::mViewInfo, OnAutoScrollID, OnClearPlayRegionID, OnSetPlayRegionToSelectionID, OnSyncQuickPlaySelID, OnTogglePinnedStateID, OnTogglePlayRegionID, BasicMenu::Handle::Popup(), TranslatableString::Stripped(), and TranslatableString::Translation().

Referenced by ShowContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowScrubMenu()

void AdornedRulerPanel::ShowScrubMenu ( const wxPoint &  pos)
private

Definition at line 2265 of file AdornedRulerPanel.cpp.

2266{
2267 auto &scrubber = Scrubber::Get( *mProject );
2268 PushEventHandler(&scrubber);
2269 auto cleanup = finally([this]{ PopEventHandler(); });
2270
2271 wxMenu rulerMenu;
2272 scrubber.PopulatePopupMenu(rulerMenu);
2273 BasicMenu::Handle{ &rulerMenu }.Popup(
2275 { pos.x, pos.y }
2276 );
2277}

References Scrubber::Get(), mProject, and BasicMenu::Handle::Popup().

Referenced by ShowContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartQPPlay()

void AdornedRulerPanel::StartQPPlay ( bool  newDefault,
bool  cutPreview,
const double *  pStartTime = nullptr 
)
private

Definition at line 2054 of file AdornedRulerPanel.cpp.

2056{
2057 const double t0 = mTracks->GetStartTime();
2058 const double t1 = mTracks->GetEndTime();
2059 auto &viewInfo = ViewInfo::Get( *mProject );
2060 const auto &playRegion = viewInfo.playRegion;
2061 const auto &selectedRegion = viewInfo.selectedRegion;
2062 const double sel0 = selectedRegion.t0();
2063 const double sel1 = selectedRegion.t1();
2064
2065 // Start / Restart playback on left click.
2066 bool startPlaying = true; // = (playRegion.GetStart() >= 0);
2067
2068 if (startPlaying) {
2069 bool loopEnabled = true;
2070 auto oldStart = std::max(0.0, playRegion.GetStart());
2071 double start = oldStart, end = 0;
2072
2073 if (playRegion.Empty()) {
2074 // Play either a selection or the project.
2075 if (oldStart > sel0 && oldStart < sel1) {
2076 // we are in a selection, so use the selection
2077 start = sel0;
2078 end = sel1;
2079 } // not in a selection, so use the project
2080 else {
2081 start = t0;
2082 end = t1;
2083 }
2084 }
2085 else
2086 end = std::max(start, playRegion.GetEnd());
2087
2088 // Looping a tiny selection may freeze, so just play it once.
2089 loopEnabled = ((end - start) > 0.001)? true : false;
2090
2091 newDefault = (loopEnabled && newDefault);
2092 if (newDefault)
2093 cutPreview = false;
2094 auto options = DefaultPlayOptions( *mProject, newDefault );
2095
2096 if (!cutPreview) {
2097 if (pStartTime)
2098 options.pStartTime.emplace(*pStartTime);
2099 }
2100 else
2101 options.envelope = nullptr;
2102
2103 auto mode =
2104 cutPreview ? PlayMode::cutPreviewPlay
2105 : newDefault ? PlayMode::loopedPlay
2107
2108 // Stop only after deciding where to start again, because an event
2109 // callback may change the play region back to the selection
2110 auto &projectAudioManager = ProjectAudioManager::Get( *mProject );
2111 projectAudioManager.Stop();
2112
2113 // Don't change play region, assume caller set it as needed
2114 // playRegion.SetTimes( start, end );
2115 // Refresh();
2116
2117 projectAudioManager.PlayPlayRegion((SelectedRegion(start, end)),
2118 options, mode,
2119 false);
2120
2121 }
2122}
AudioIOStartStreamOptions DefaultPlayOptions(AudacityProject &project, bool newDefault)
@ cutPreviewPlay
Defines a selected portion of a project.
double GetEndTime() const
Definition: Track.cpp:1029
double GetStartTime() const
Definition: Track.cpp:1024
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for, if Traits<Type>::iterated_type is defined.
Definition: PackedArray.h:126

References cutPreviewPlay, DefaultPlayOptions(), PackedArray::end(), ViewInfo::Get(), ProjectAudioManager::Get(), TrackList::GetEndTime(), TrackList::GetStartTime(), loopedPlay, mProject, mTracks, and normalPlay.

Here is the call graph for this function:

◆ TemporarilyAllowFocus()

auto AdornedRulerPanel::TemporarilyAllowFocus ( )
static

Definition at line 2675 of file AdornedRulerPanel.cpp.

2675 {
2676 s_AcceptsFocus = true;
2677 return TempAllowFocus{ &s_AcceptsFocus };
2678}
std::unique_ptr< bool, Resetter > TempAllowFocus

Referenced by SetFocusFromKbd().

Here is the caller graph for this function:

◆ Time2Pos()

int AdornedRulerPanel::Time2Pos ( double  t,
bool  ignoreFisheye = false 
) const
private

Definition at line 1706 of file AdornedRulerPanel.cpp.

1707{
1709 , ignoreFisheye
1710 );
1711}
wxInt64 TimeToPosition(double time, wxInt64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ZoomInfo.cpp:51

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

Referenced by IsWithinMarker(), and RegionRectangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TogglePinnedHead()

void AdornedRulerPanel::TogglePinnedHead ( )

Definition at line 2793 of file AdornedRulerPanel.cpp.

2794{
2798
2799 auto &project = *mProject;
2800 // Update button image
2802
2803 auto &scrubber = Scrubber::Get( project );
2804 if (scrubber.HasMark())
2805 scrubber.SetScrollScrubbing(value);
2806}
static void ModifyAllProjectToolbarMenus()
Definition: Menus.cpp:592
static void SetPinnedHeadPreference(bool value, bool flush=false)

References Scrubber::Get(), TracksPrefs::GetPinnedHeadPreference(), MenuManager::ModifyAllProjectToolbarMenus(), mProject, TracksPrefs::SetPinnedHeadPreference(), and UpdateButtonStates().

Referenced by TransportActions::Handler::OnTogglePinnedHead(), and OnTogglePinnedState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateButtonStates()

void AdornedRulerPanel::UpdateButtonStates ( )

Definition at line 2162 of file AdornedRulerPanel.cpp.

2163{
2164 auto common = [this](
2165 AButton &button, const CommandID &commandName, const TranslatableString &label) {
2166 ComponentInterfaceSymbol command{ commandName, label };
2167 ToolBar::SetButtonToolTip( *mProject, button, &command, 1u );
2168 button.SetLabel( Verbatim( button.GetToolTipText() ) );
2169
2170 button.UpdateStatus();
2171 };
2172
2173 {
2174 // The button always reflects the pinned head preference, even though
2175 // there is also a Playback preference that may overrule it for scrubbing
2177 auto pinButton = static_cast<AButton*>(FindWindow(OnTogglePinnedStateID));
2178 if( !state )
2179 pinButton->PopUp();
2180 else
2181 pinButton->PushDown();
2182 auto gAudioIO = AudioIO::Get();
2183 pinButton->SetAlternateIdx(
2184 (gAudioIO->IsCapturing() ? 2 : 0) + (state ? 0 : 1));
2185 // Bug 1584: Tooltip now shows what clicking will do.
2186 // Bug 2357: Action of button (and hence tooltip wording) updated.
2187 const auto label = XO("Timeline Options");
2188 common(*pinButton, wxT("PinnedHead"), label);
2189 }
2190}
TranslatableString label
Definition: TagsEditor.cpp:163
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
A wxButton with mouse-over behaviour.
Definition: AButton.h:25
void UpdateStatus()
Definition: AButton.cpp:495
void PopUp()
Definition: AButton.cpp:605
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:274
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:898
Holds a msgid for the translation catalog; may also bind format arguments.

References AudioIO::Get(), TracksPrefs::GetPinnedHeadPreference(), label, mProject, OnTogglePinnedStateID, AButton::PopUp(), ToolBar::SetButtonToolTip(), AButton::SetLabel(), AButton::UpdateStatus(), Verbatim(), and XO.

Referenced by OnAudioStartStop(), OnTogglePinnedState(), ReCreateButtons(), ShowContextMenu(), TogglePinnedHead(), and UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatePrefs()

void AdornedRulerPanel::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 1324 of file AdornedRulerPanel.cpp.

1325{
1326 if (mNeedButtonUpdate) {
1327 // Visit this block once only in the lifetime of this panel
1328 mNeedButtonUpdate = false;
1329 // Do this first time setting of button status texts
1330 // when we are sure the CommandManager is initialized.
1332 }
1333
1334 // Update button texts for language change
1336
1337 mTimelineToolTip = !!gPrefs->Read(wxT("/QuickPlay/ToolTips"), 1L);
1338
1339#ifdef EXPERIMENTAL_SCROLLING_LIMITS
1340#ifdef EXPERIMENTAL_TWO_TONE_TIME_RULER
1341 {
1342 auto scrollBeyondZero = ScrollingPreference.Read();
1343 mRuler.SetTwoTone(scrollBeyondZero);
1344 }
1345#endif
1346#endif
1347}
BoolSetting ScrollingPreference
Definition: ViewInfo.cpp:338
void SetTwoTone(bool twoTone)
Definition: Ruler.cpp:126
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:185

References gPrefs, mNeedButtonUpdate, mRuler, mTimelineToolTip, Setting< T >::Read(), ReCreateButtons(), ScrollingPreference, Ruler::SetTwoTone(), and UpdateButtonStates().

Referenced by AdornedRulerPanel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateQuickPlayPos()

void AdornedRulerPanel::UpdateQuickPlayPos ( wxCoord &  mousePosX)

Definition at line 2203 of file AdornedRulerPanel.cpp.

2204{
2205 // Invoked for mouse-over preview events, or dragging, or scrub position
2206 // polling updates. Remember x coordinates, converted to times, for
2207 // drawing of guides.
2208
2209 // Keep Quick-Play within usable track area. (Dependent on zoom)
2210 const auto &viewInfo = ViewInfo::Get( *mProject );
2211 auto width = viewInfo.GetTracksUsableWidth();
2212 mousePosX = std::max(mousePosX, viewInfo.GetLeftOffset());
2213 mousePosX = std::min(mousePosX, viewInfo.GetLeftOffset() + width - 1);
2214 const auto time = Pos2Time(mousePosX);
2215
2216 for (size_t ii = 0; ii < mNumGuides; ++ii) {
2218 time + mQuickPlayOffset[ii];
2219 HandleSnapping(ii);
2220 }
2221}
void HandleSnapping(size_t index)

References ViewInfo::Get(), HandleSnapping(), min(), mNumGuides, mProject, mQuickPlayOffset, mQuickPlayPos, mQuickPlayPosUnsnapped, and Pos2Time().

Here is the call graph for this function:

◆ UpdateRects()

bool AdornedRulerPanel::UpdateRects ( )
private

Definition at line 1646 of file AdornedRulerPanel.cpp.

1647{
1648 auto inner = mOuter;
1649 wxRect scrubZone;
1650 inner.x += LeftMargin;
1651 inner.width -= (LeftMargin + RightMargin);
1652
1653 auto top = &inner;
1654 auto bottom = &inner;
1655
1656 if (ShowingScrubRuler()) {
1657 scrubZone = inner;
1658 auto scrubHeight = std::min(scrubZone.height, (int)(ScrubHeight));
1659
1660 int topHeight;
1661#ifdef SCRUB_ABOVE
1662 top = &scrubZone, topHeight = scrubHeight;
1663#else
1664 auto qpHeight = scrubZone.height - scrubHeight;
1665 bottom = &scrubZone, topHeight = qpHeight;
1666 // Increase scrub zone height so that hit testing finds it and
1667 // not QP region, when on bottom 'edge'.
1668 scrubZone.height+=BottomMargin;
1669#endif
1670
1671 top->height = topHeight;
1672 bottom->height -= topHeight;
1673 bottom->y += topHeight;
1674 }
1675
1676 top->y += TopMargin;
1677 top->height -= TopMargin;
1678
1679 bottom->height -= BottomMargin;
1680
1681 if (!ShowingScrubRuler())
1682 scrubZone = inner;
1683
1684 if ( inner == mInner && scrubZone == mScrubZone )
1685 // no changes
1686 return false;
1687
1688 mInner = inner;
1689 mScrubZone = scrubZone;
1690
1691 mRuler.SetBounds(mInner.GetLeft(),
1692 mInner.GetTop(),
1693 mInner.GetRight(),
1694 mInner.GetBottom());
1695
1696 return true;
1697}
@ LeftMargin
@ TopMargin
void SetBounds(int left, int top, int right, int bottom)
Definition: Ruler.cpp:332

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

Referenced by DoIdle(), and OnSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateStatusMessage()

void AdornedRulerPanel::UpdateStatusMessage ( const TranslatableString message)
overrideprivatevirtual

Implements CellularPanel.

Definition at line 2772 of file AdornedRulerPanel.cpp.

2773{
2774 ProjectStatus::Get( *GetProject() ).Set(message);
2775}
static ProjectStatus & Get(AudacityProject &project)
void Set(const TranslatableString &msg, StatusBarField field=mainStatusBarField)

References ProjectStatus::Get(), GetProject(), and ProjectStatus::Set().

Here is the call graph for this function:

Member Data Documentation

◆ mAudioIOSubscription

Observer::Subscription AdornedRulerPanel::mAudioIOSubscription
private

Definition at line 241 of file AdornedRulerPanel.h.

Referenced by AdornedRulerPanel().

◆ MAX_GUIDES

constexpr size_t AdornedRulerPanel::MAX_GUIDES = 2
staticconstexprprivate

Definition at line 149 of file AdornedRulerPanel.h.

Referenced by SetNumGuides().

◆ mButtons

wxWindow* AdornedRulerPanel::mButtons[3]
private

Definition at line 195 of file AdornedRulerPanel.h.

Referenced by AdornedRulerPanel(), and ReCreateButtons().

◆ mIndTime

double AdornedRulerPanel::mIndTime
private

Definition at line 147 of file AdornedRulerPanel.h.

Referenced by AdornedRulerPanel().

◆ mInner

wxRect AdornedRulerPanel::mInner
private

◆ mIsDragging

bool AdornedRulerPanel::mIsDragging
private

Definition at line 191 of file AdornedRulerPanel.h.

Referenced by AdornedRulerPanel().

◆ mIsRecording

bool AdornedRulerPanel::mIsRecording
private

Definition at line 158 of file AdornedRulerPanel.h.

Referenced by AdornedRulerPanel(), and OnAudioStartStop().

◆ mIsSnapped

bool AdornedRulerPanel::mIsSnapped[MAX_GUIDES] {}
private

Definition at line 153 of file AdornedRulerPanel.h.

Referenced by HandleSnapping(), and SetNumGuides().

◆ mLastDrawnH

double AdornedRulerPanel::mLastDrawnH {}
private

Definition at line 251 of file AdornedRulerPanel.h.

Referenced by DoIdle(), and OnPaint().

◆ mLastDrawnPlayRegion

std::pair<double, double> AdornedRulerPanel::mLastDrawnPlayRegion {}
private

Definition at line 249 of file AdornedRulerPanel.h.

Referenced by DoIdle(), and OnPaint().

◆ mLastDrawnSelectedRegion

SelectedRegion AdornedRulerPanel::mLastDrawnSelectedRegion
private

Definition at line 248 of file AdornedRulerPanel.h.

Referenced by DoIdle(), and OnPaint().

◆ mLastDrawnZoom

double AdornedRulerPanel::mLastDrawnZoom {}
private

Definition at line 252 of file AdornedRulerPanel.h.

Referenced by DoIdle(), and OnPaint().

◆ mLastPlayRegionActive

bool AdornedRulerPanel::mLastPlayRegionActive = false
private

Definition at line 250 of file AdornedRulerPanel.h.

Referenced by DoDrawOverlap(), DoDrawPlayRegion(), and DoIdle().

◆ mLeftDownClick

double AdornedRulerPanel::mLeftDownClick
private

Definition at line 190 of file AdornedRulerPanel.h.

Referenced by AdornedRulerPanel().

◆ mLeftDownClickUnsnapped

double AdornedRulerPanel::mLeftDownClickUnsnapped
private

Definition at line 189 of file AdornedRulerPanel.h.

◆ mLeftOffset

int AdornedRulerPanel::mLeftOffset
private

Definition at line 144 of file AdornedRulerPanel.h.

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

◆ mMouseEventState

MouseEventState AdornedRulerPanel::mMouseEventState
private

Definition at line 188 of file AdornedRulerPanel.h.

Referenced by AdornedRulerPanel(), and SetPlayRegion().

◆ mNeedButtonUpdate

bool AdornedRulerPanel::mNeedButtonUpdate { true }
private

Definition at line 196 of file AdornedRulerPanel.h.

Referenced by UpdatePrefs().

◆ mNumGuides

size_t AdornedRulerPanel::mNumGuides { 1 }
private

Definition at line 154 of file AdornedRulerPanel.h.

Referenced by SetNumGuides(), and UpdateQuickPlayPos().

◆ mOldPlayRegion

PlayRegion AdornedRulerPanel::mOldPlayRegion
private

Definition at line 156 of file AdornedRulerPanel.h.

◆ mOuter

wxRect AdornedRulerPanel::mOuter
private

Definition at line 140 of file AdornedRulerPanel.h.

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

◆ mOverlay

std::shared_ptr<TrackPanelGuidelineOverlay> AdornedRulerPanel::mOverlay
private

Definition at line 220 of file AdornedRulerPanel.h.

Referenced by CreateOverlays().

◆ mPlayRegionDragsSelection

bool AdornedRulerPanel::mPlayRegionDragsSelection
private

◆ mPlayRegionSubscription

Observer::Subscription AdornedRulerPanel::mPlayRegionSubscription
private

Definition at line 242 of file AdornedRulerPanel.h.

Referenced by AdornedRulerPanel().

◆ mProject

AudacityProject* const AdornedRulerPanel::mProject
private

◆ mQPCell

std::shared_ptr<QPCell> AdornedRulerPanel::mQPCell
private

◆ mQuickPlayOffset

double AdornedRulerPanel::mQuickPlayOffset[MAX_GUIDES] {}
private

Definition at line 150 of file AdornedRulerPanel.h.

Referenced by SetNumGuides(), and UpdateQuickPlayPos().

◆ mQuickPlayPos

double AdornedRulerPanel::mQuickPlayPos[MAX_GUIDES] {}
private

Definition at line 152 of file AdornedRulerPanel.h.

Referenced by HandleSnapping(), SetNumGuides(), and UpdateQuickPlayPos().

◆ mQuickPlayPosUnsnapped

double AdornedRulerPanel::mQuickPlayPosUnsnapped[MAX_GUIDES] {}
private

Definition at line 151 of file AdornedRulerPanel.h.

Referenced by SetNumGuides(), and UpdateQuickPlayPos().

◆ mRuler

Ruler AdornedRulerPanel::mRuler
private

◆ mScrubbingCell

std::shared_ptr<ScrubbingCell> AdornedRulerPanel::mScrubbingCell
private

◆ mScrubZone

wxRect AdornedRulerPanel::mScrubZone
private

◆ mTimelineToolTip

bool AdornedRulerPanel::mTimelineToolTip
private

Definition at line 178 of file AdornedRulerPanel.h.

Referenced by AdornedRulerPanel(), and UpdatePrefs().

◆ mTracks

TrackList* AdornedRulerPanel::mTracks
private

Definition at line 138 of file AdornedRulerPanel.h.

Referenced by AdornedRulerPanel(), HandleSnapping(), and StartQPPlay().

◆ s_AcceptsFocus

bool AdornedRulerPanel::s_AcceptsFocus { false }
staticprivate

Definition at line 116 of file AdornedRulerPanel.h.


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