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

#include <NoteTrackVRulerControls.h>

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

Public Member Functions

 NoteTrackVRulerControls (const std::shared_ptr< ChannelView > &pChannelView)
 
 ~NoteTrackVRulerControls ()
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) 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 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)
 

Private Member Functions

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

Private Attributes

std::weak_ptr< NoteTrackVZoomHandlemVZoomHandle
 

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
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) 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 18 of file NoteTrackVRulerControls.h.

Constructor & Destructor Documentation

◆ NoteTrackVRulerControls() [1/2]

NoteTrackVRulerControls::NoteTrackVRulerControls ( const NoteTrackVRulerControls )
privatedelete

◆ NoteTrackVRulerControls() [2/2]

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

Definition at line 25 of file NoteTrackVRulerControls.h.

◆ ~NoteTrackVRulerControls()

NoteTrackVRulerControls::~NoteTrackVRulerControls ( )

Definition at line 37 of file NoteTrackVRulerControls.cpp.

38{
39}

Member Function Documentation

◆ Draw()

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

Reimplemented from TrackPanelDrawable.

Definition at line 101 of file NoteTrackVRulerControls.cpp.

104{
105 ChannelVRulerControls::Draw(context, rect_, iPass);
106
107 // Draw on a later pass like other vertical rulers,
108 // although the bevel is done a little differently
109
110 if ( iPass == TrackArtist::PassControls ) {
111 // The note track draws a vertical keyboard to label pitches
112 auto track = std::static_pointer_cast<NoteTrack>( FindTrack() );
113 if ( !track )
114 return;
115
116 auto rect = rect_;
117 --rect.width;
118 --rect.height;
119
120 bool highlight = false;
121#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
122 highlight = rect.Contains(context.lastState.GetPosition());
123#endif
124
125 const auto artist = TrackArtist::Get( context );
126 UpdateRuler(rect);
127
128 auto dc = &context.dc;
129
130 dc->SetPen(highlight ? AColor::uglyPen : *wxTRANSPARENT_PEN);
131 dc->SetBrush(*wxWHITE_BRUSH);
132 wxRect bev = rect;
133 bev.x++;
134 bev.width--;
135 dc->DrawRectangle(bev);
136
137 rect.y += 1;
138 rect.height -= 1;
139
140 NoteTrackDisplayData data{ *track, rect };
141
142 wxPen hilitePen;
143 hilitePen.SetColour(120, 120, 120);
144 wxBrush blackKeyBrush;
145 blackKeyBrush.SetColour(70, 70, 70);
146
147 dc->SetBrush(blackKeyBrush);
148
149 int fontSize = 10;
150#ifdef __WXMSW__
151 fontSize = 8;
152#endif
153
154 wxFont labelFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
155 dc->SetFont(labelFont);
156
157 int octave = 0;
158 int obottom = data.GetOctaveBottom(octave);
159 int marg = data.GetNoteMargin();
160
161 while (obottom >= rect.y) {
162 dc->SetPen(*wxBLACK_PEN);
163 for (int white = 0; white < 7; white++) {
164 int pos = data.GetWhitePos(white);
165 if (obottom - pos > rect.y + marg + 1 &&
166 // don't draw too close to margin line -- it's annoying
167 obottom - pos < rect.y + rect.height - marg - 3)
168 AColor::Line(*dc, rect.x, obottom - pos,
169 rect.x + rect.width, obottom - pos);
170 }
171 wxRect br = rect;
172 br.height = data.GetPitchHeight(1);
173 br.x++;
174 br.width = 17;
175 for (int black = 0; black < 5; black++) {
176 br.y = obottom - data.GetBlackPos(black);
177 if (br.y > rect.y + marg - 2 && br.y + br.height < rect.y + rect.height - marg) {
178 dc->SetPen(hilitePen);
179 dc->DrawRectangle(br);
180 dc->SetPen(*wxBLACK_PEN);
181 AColor::Line(*dc,
182 br.x + 1, br.y + br.height - 1,
183 br.x + br.width - 1, br.y + br.height - 1);
184 AColor::Line(*dc,
185 br.x + br.width - 1, br.y + 1,
186 br.x + br.width - 1, br.y + br.height - 1);
187 }
188 }
189
190 if (octave >= 1 && octave <= 10) {
191 wxString s;
192 // ISO standard: A440 is in the 4th octave, denoted
193 // A4 <- the "4" should be a subscript.
194 s.Printf(wxT("C%d"), octave - 1);
195 wxCoord width, height;
196 dc->GetTextExtent(s, &width, &height);
197 if (obottom - height + 4 > rect.y &&
198 obottom + 4 < rect.y + rect.height) {
199 dc->SetTextForeground(wxColour(60, 60, 255));
200 dc->DrawText(s, rect.x + rect.width - width,
201 obottom - height + 2);
202 }
203 }
204 obottom = data.GetOctaveBottom(++octave);
205 }
206 // draw lines delineating the out-of-bounds margins
207 dc->SetPen(*wxBLACK_PEN);
208 // you would think the -1 offset here should be -2 to match the
209 // adjustment to rect.y (see above), but -1 produces correct output
210 AColor::Line(*dc, rect.x, rect.y + marg - 1, rect.x + rect.width, rect.y + marg - 1);
211 // since the margin gives us the bottom of the line,
212 // the extra -1 gets us to the top
213 AColor::Line(*dc, rect.x, rect.y + rect.height - marg - 1,
214 rect.x + rect.width, rect.y + rect.height - marg - 1);
215
216 }
217}
wxT("CloseDown"))
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
static wxPen uglyPen
Definition: AColor.h:141
void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
std::shared_ptr< Track > FindTrack()
Temporary data used to display a note track.
void UpdateRuler(const wxRect &rect) override
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69

References TrackPanelDrawingContext::dc, ChannelVRulerControls::Draw(), CommonTrackPanelCell::FindTrack(), TrackArtist::Get(), TrackPanelDrawingContext::lastState, AColor::Line(), TrackArtist::PassControls, AColor::uglyPen, UpdateRuler(), and wxT().

Here is the call graph for this function:

◆ HandleWheelRotation()

unsigned NoteTrackVRulerControls::HandleWheelRotation ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Reimplemented from TrackPanelCell.

Definition at line 62 of file NoteTrackVRulerControls.cpp.

64{
65 using namespace RefreshCode;
66 const wxMouseEvent &event = evt.event;
67
68 if (!(event.ShiftDown() || event.CmdDown()))
69 return RefreshNone;
70
71 // Always stop propagation even if the ruler didn't change. The ruler
72 // is a narrow enough target.
73 evt.event.Skip(false);
74
75 const auto pTrack = FindTrack();
76 if (!pTrack)
77 return RefreshNone;
78
79 auto steps = evt.steps;
80 const auto nt = static_cast<NoteTrack*>(pTrack.get());
81
82 if (event.CmdDown() && !event.ShiftDown()) {
83 NoteTrackDisplayData data{ *nt, evt.rect };
84 if (steps > 0)
85 data.ZoomIn(evt.event.m_y);
86 else
87 data.ZoomOut(evt.event.m_y);
88 } else if (!event.CmdDown() && event.ShiftDown()) {
89 // Scroll some fixed number of notes, independent of zoom level or track height:
90 static const int movement = 6; // 6 semitones is half an octave
91 NoteTrackRange::Get(*nt).ShiftNoteRange((int) (steps * movement));
92 } else {
93 return RefreshNone;
94 }
95
96 ProjectHistory::Get( *pProject ).ModifyState(false);
97
99}
void ZoomIn(int y)
Zooms in a constant factor (subject to zoom limits)
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:86
static NoteTrackRange & Get(const NoteTrack &track)
Allow mutative access to attached data of a const track.
void ShiftNoteRange(int offset)
Shifts all notes vertically by the given pitch.
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References TrackPanelMouseEvent::event, CommonTrackPanelCell::FindTrack(), ProjectHistory::Get(), NoteTrackRange::Get(), ProjectHistory::ModifyState(), TrackPanelMouseEvent::rect, RefreshCode::RefreshCell, RefreshCode::RefreshNone, NoteTrackRange::ShiftNoteRange(), TrackPanelMouseEvent::steps, and RefreshCode::UpdateVRuler.

Here is the call graph for this function:

◆ HitTest()

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

Implements TrackPanelCell.

Definition at line 41 of file NoteTrackVRulerControls.cpp.

44{
45 std::vector<UIHandlePtr> results;
46 UIHandlePtr result;
47
48 if ( st.state.GetX() <= st.rect.GetRight() - kGuard ) {
49 auto track = std::static_pointer_cast<NoteTrack>(FindTrack());
51 mVZoomHandle, st.state, track, st.rect);
52 if (result)
53 results.push_back(result);
54 }
55
56 auto more = ChannelVRulerControls::HitTest(st, pProject);
57 std::copy(more.begin(), more.end(), std::back_inserter(results));
58
59 return results;
60}
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
const int kGuard
std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *pProject) override
std::weak_ptr< NoteTrackVZoomHandle > mVZoomHandle
static UIHandlePtr HitTest(std::weak_ptr< NoteTrackVZoomHandle > &holder, const wxMouseState &state, const std::shared_ptr< NoteTrack > &pTrack, const wxRect &rect)
void copy(const T *src, T *dst, int32_t n)
Definition: VectorOps.h:40

References staffpad::vo::copy(), CommonTrackPanelCell::FindTrack(), ChannelVRulerControls::HitTest(), NoteTrackVZoomHandle::HitTest(), kGuard, mVZoomHandle, TrackPanelMouseState::rect, and TrackPanelMouseState::state.

Here is the call graph for this function:

◆ operator=()

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

◆ UpdateRuler()

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

Implements ChannelVRulerControls.

Definition at line 220 of file NoteTrackVRulerControls.cpp.

221{
222 // The note track isn't drawing a ruler at all!
223 // But it needs to!
224
225 const auto nt = std::static_pointer_cast<NoteTrack>(FindTrack());
226 if (!nt)
227 return;
228
229 static Ruler ruler{
231 const auto vruler = &ruler;
232
233 vruler->SetBounds(rect.x, rect.y, rect.x + 1, rect.y + rect.height - 1);
234 vruler->SetOrientation(wxVERTICAL);
235
236 auto &size = ChannelView::Get(*nt).vrulerSize;
237 vruler->GetMaxSize(&size.first, &size.second);
238}
static ChannelView & Get(Channel &channel)
std::pair< int, int > vrulerSize
Definition: ChannelView.h:128
static const LinearUpdater & Instance()
static const RealFormat & LinearInstance()
Definition: RealFormat.cpp:14
Used to display a Ruler.
Definition: Ruler.h:34
void SetBounds(int left, int top, int right, int bottom)
Definition: Ruler.cpp:304

References CommonTrackPanelCell::FindTrack(), ChannelView::Get(), LinearUpdater::Instance(), RealFormat::LinearInstance(), anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), Ruler::SetBounds(), 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<NoteTrackVZoomHandle> NoteTrackVRulerControls::mVZoomHandle
private

Definition at line 46 of file NoteTrackVRulerControls.h.

Referenced by HitTest().


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