Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TimeTrackVRulerControls Class Referencefinal

#include <TimeTrackVRulerControls.h>

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

Public Member Functions

 TimeTrackVRulerControls (const std::shared_ptr< ChannelView > &pChannelView)
 
 ~TimeTrackVRulerControls ()
 
std::shared_ptr< TimeTrackFindTimeTrack ()
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *) override
 
- Public Member Functions inherited from ChannelVRulerControls
 ChannelVRulerControls (const std::shared_ptr< ChannelView > &pChannelView)
 
virtual ~ChannelVRulerControls ()=0
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject) override
 
virtual void UpdateRuler (const wxRect &rect)=0
 
std::shared_ptr< const ChannelViewGetChannelView () const
 
- Public Member Functions inherited from CommonChannelCell
 CommonChannelCell (const std::shared_ptr< Channel > &pChannel)
 Construct from a channel. More...
 
 ~CommonChannelCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
void Reparent (const std::shared_ptr< Track > &parent, size_t iChannel) override
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
template<typename Subtype = Channel>
auto FindChannel () -> std::shared_ptr< Subtype >
 May return null. More...
 
template<typename Subtype = const Channel>
auto FindChannel () const -> std::enable_if_t< std::is_const_v< Subtype >, std::shared_ptr< Subtype > >
 May return null. More...
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
std::shared_ptr< TrackFindTrack ()
 
std::shared_ptr< const TrackFindTrack () const
 
virtual std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject)
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &)=delete
 
TrackPanelCelloperator= (const TrackPanelCell &)=delete
 
virtual ~TrackPanelCell ()=0
 
virtual HitTestPreview DefaultPreview (const TrackPanelMouseState &state, const AudacityProject *pProject)
 
virtual std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject)=0
 
virtual unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject)
 
virtual std::shared_ptr< TrackPanelCellContextMenuDelegate ()
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject)
 
virtual unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned LoseFocus (AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 
- Public Member Functions inherited from ChannelAttachment
virtual ~ChannelAttachment ()
 
virtual void CopyTo (Track &track, size_t iChannel) const
 Copy state, for undo/redo purposes. More...
 
virtual void Reparent (const std::shared_ptr< Track > &parent, size_t iChannel)
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
virtual void WriteXMLAttributes (XMLWriter &writer, size_t iChannel) const
 Serialize persistent attributes. More...
 
virtual bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView, size_t iChannel)
 Deserialize an attribute, returning true if recognized. More...
 

Private Member Functions

 TimeTrackVRulerControls (const TimeTrackVRulerControls &)=delete
 
TimeTrackVRulerControlsoperator= (const TimeTrackVRulerControls &)=delete
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
void UpdateRuler (const wxRect &rect) override
 

Private Attributes

std::weak_ptr< TimeTrackVZoomHandlemVZoomHandle
 

Additional Inherited Members

- Static Public Member Functions inherited from ChannelVRulerControls
static ChannelVRulerControlsGet (ChannelView &)
 
static const ChannelVRulerControlsGet (const ChannelView &)
 
static void DrawZooming (TrackPanelDrawingContext &context, const wxRect &rect, int zoomStart, int zoomEnd)
 
static wxRect ZoomingArea (const wxRect &rect, const wxRect &panelRect)
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 
- Protected Member Functions inherited from ChannelVRulerControls
std::shared_ptr< TrackDoFindTrack () override
 
wxRect DrawingArea (TrackPanelDrawingContext &, const wxRect &rect, const wxRect &panelRect, unsigned iPass) override
 
TrackGetTrack () const
 
- Protected Member Functions inherited from CommonTrackPanelCell
virtual std::shared_ptr< TrackDoFindTrack ()=0
 
unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
- Protected Attributes inherited from ChannelVRulerControls
std::weak_ptr< ChannelViewmwChannelView
 

Detailed Description

Definition at line 21 of file TimeTrackVRulerControls.h.

Constructor & Destructor Documentation

◆ TimeTrackVRulerControls() [1/2]

TimeTrackVRulerControls::TimeTrackVRulerControls ( const TimeTrackVRulerControls )
privatedelete

◆ TimeTrackVRulerControls() [2/2]

TimeTrackVRulerControls::TimeTrackVRulerControls ( const std::shared_ptr< ChannelView > &  pChannelView)
inlineexplicit

Definition at line 28 of file TimeTrackVRulerControls.h.

◆ ~TimeTrackVRulerControls()

TimeTrackVRulerControls::~TimeTrackVRulerControls ( )

Definition at line 33 of file TimeTrackVRulerControls.cpp.

34{
35}

Member Function Documentation

◆ Draw()

void TimeTrackVRulerControls::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 73 of file TimeTrackVRulerControls.cpp.

76{
77 ChannelVRulerControls::Draw(context, rect_, iPass);
78
79 // Draw on a later pass because the bevel overpaints one pixel
80 // out of bounds on the bottom
81
82 if (iPass == TrackArtist::PassControls) {
83 auto t = FindTimeTrack();
84 if (!t)
85 return;
86
87 auto rect = rect_;
88 --rect.width;
89 --rect.height;
90
91 auto dc = &context.dc;
92
93 // Right align the ruler
94 wxRect rr = rect;
95 rr.width--;
96 const auto &size =
97 ChannelView::Get(*static_cast<TimeTrack*>(t.get())).vrulerSize;
98 if (size.first < rect.GetWidth()) {
99 int adj = rr.GetWidth() - size.first;
100 rr.x += adj;
101 rr.width -= adj;
102 }
103
104 UpdateRuler(rr);
105
106 auto vruler = &ruler();
107
108 vruler->SetTickColour(theTheme.Colour(clrTrackPanelText));
109 vruler->Draw(*dc);
110 }
111}
THEME_API Theme theTheme
Definition: Theme.cpp:82
static ChannelView & Get(Channel &channel)
std::pair< int, int > vrulerSize
Definition: ChannelView.h:129
wxColour & Colour(int iIndex)
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:24
void UpdateRuler(const wxRect &rect) override
std::shared_ptr< TimeTrack > FindTimeTrack()
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)

References ThemeBase::Colour(), TrackPanelDrawingContext::dc, TrackPanelDrawable::Draw(), FindTimeTrack(), ChannelView::Get(), TrackArtist::PassControls, anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), size, theTheme, UpdateRuler(), and ChannelView::vrulerSize.

Here is the call graph for this function:

◆ FindTimeTrack()

std::shared_ptr< TimeTrack > TimeTrackVRulerControls::FindTimeTrack ( )

Definition at line 37 of file TimeTrackVRulerControls.cpp.

38{
39 return FindChannel<TimeTrack>();
40}

Referenced by Draw(), HitTest(), and UpdateRuler().

Here is the caller graph for this function:

◆ HitTest()

std::vector< UIHandlePtr > TimeTrackVRulerControls::HitTest ( const TrackPanelMouseState state,
const AudacityProject pProject 
)
overridevirtual

Implements TrackPanelCell.

Definition at line 52 of file TimeTrackVRulerControls.cpp.

55{
56 std::vector<UIHandlePtr> results;
57
58 if ( st.state.GetX() <= st.rect.GetRight() - kGuard ) {
59 if (const auto pTrack = FindTimeTrack()) {
60 auto result = std::make_shared<TimeTrackVZoomHandle>(
61 pTrack, st.rect, st.state.m_y );
62 result = AssignUIHandlePtr(mVZoomHandle, result);
63 results.push_back(result);
64 }
65 }
66
67 auto more = ChannelVRulerControls::HitTest(st, pProject);
68 std::copy(more.begin(), more.end(), std::back_inserter(results));
69
70 return results;
71}
const int kGuard
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:164
std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *pProject) override
std::weak_ptr< TimeTrackVZoomHandle > mVZoomHandle
void copy(const T *src, T *dst, int32_t n)
Definition: VectorOps.h:40

References AssignUIHandlePtr(), staffpad::vo::copy(), FindTimeTrack(), ChannelVRulerControls::HitTest(), kGuard, mVZoomHandle, TrackPanelMouseState::rect, and TrackPanelMouseState::state.

Here is the call graph for this function:

◆ operator=()

TimeTrackVRulerControls & TimeTrackVRulerControls::operator= ( const TimeTrackVRulerControls )
privatedelete

◆ UpdateRuler()

void TimeTrackVRulerControls::UpdateRuler ( const wxRect &  rect)
overrideprivatevirtual

Implements ChannelVRulerControls.

Definition at line 113 of file TimeTrackVRulerControls.cpp.

114{
115 const auto tt = FindTimeTrack();
116 if (!tt)
117 return;
118 auto vruler = &ruler();
119
120 float min, max;
121 min = tt->GetRangeLower() * 100.0;
122 max = tt->GetRangeUpper() * 100.0;
123
124 vruler->SetDbMirrorValue( 0.0 );
125 vruler->SetBounds(
126 rect.x, rect.y, rect.x + rect.width, rect.y + rect.height - 1);
127 vruler->SetOrientation(wxVERTICAL);
128 vruler->SetRange(max, min);
129 vruler->SetFormat(tt->GetDisplayLog()
132 vruler->SetUnits({});
133 vruler->SetLabelEdges(false);
134 if (tt->GetDisplayLog())
135 vruler->SetUpdater(&LogarithmicUpdater::Instance());
136 else
137 vruler->SetUpdater(&LinearUpdater::Instance());
138
139 auto &size = ChannelView::Get(*tt).vrulerSize;
140 vruler->GetMaxSize(&size.first, &size.second);
141}
int min(int a, int b)
static const LinearUpdater & Instance()
static const LogarithmicUpdater & Instance()
static const RealFormat & LinearInstance()
Definition: RealFormat.cpp:14
static const RealFormat & LogInstance()
Definition: RealFormat.cpp:20

References FindTimeTrack(), ChannelView::Get(), LinearUpdater::Instance(), LogarithmicUpdater::Instance(), RealFormat::LinearInstance(), RealFormat::LogInstance(), min(), anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), size, and ChannelView::vrulerSize.

Referenced by Draw().

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

Member Data Documentation

◆ mVZoomHandle

std::weak_ptr<TimeTrackVZoomHandle> TimeTrackVRulerControls::mVZoomHandle
private

Definition at line 48 of file TimeTrackVRulerControls.h.

Referenced by HitTest().


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