Audacity 3.2.0
ChannelVRulerControls.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ChannelVRulerControls.cpp
6
7Paul Licameli split from TrackPanel.cpp
8
9**********************************************************************/
10
11
13
14#include "ChannelView.h"
15
16#include "AColor.h"
17#include "Track.h"
18#include "../../TrackArtist.h"
19#include "../../TrackPanelDrawingContext.h"
20#include "ViewInfo.h"
21
22#include <wx/cursor.h>
23#include <wx/dc.h>
24#include <wx/translation.h>
25
27 const std::shared_ptr<ChannelView> &pChannelView)
28 : mwChannelView{ pChannelView }
29{
30}
31
33{
34}
35
37{
38 return *trackView.GetVRulerControls();
39}
40
42 const ChannelView &trackView)
43{
44 return *trackView.GetVRulerControls();
45}
46
47std::shared_ptr<Track> ChannelVRulerControls::DoFindTrack()
48{
49 const auto pView = mwChannelView.lock();
50 if (pView)
51 return pView->FindTrack();
52 return {};
53}
54
55std::vector<UIHandlePtr> ChannelVRulerControls::HitTest(
57{
58 return std::vector<UIHandlePtr>{};
59}
60
62 TrackPanelDrawingContext &context, const wxRect &rect_,
63 int zoomStart, int zoomEnd)
64{
65 // Draw a dashed rectangle, its right side disappearing in the black right
66 // border of the track area, which is not part of this cell but right of it.
67 auto &dc = context.dc;
68
69 dc.SetBrush(*wxTRANSPARENT_BRUSH);
70 dc.SetPen(*wxBLACK_DASHED_PEN);
71
72 wxRect rect {
73 rect_.x,
74 std::min( zoomStart, zoomEnd),
75 rect_.width,
76 1 + abs( zoomEnd - zoomStart)
77 };
78
79 dc.DrawRectangle(rect);
80}
81
83 const wxRect &rect, const wxRect &panelRect)
84{
85 // TODO: Don't use the constant kRightMargin, but somehow discover the
86 // neighboring track rectangle
87 return {
88 // Left edge of the rectangle disappears in the vertical line at
89 // left edge of the ruler
90 rect.x,
91 rect.y,
92 // Extend the dashed rectangle right up to the track border
93 (panelRect.width - kRightMargin + kBorderThickness) - rect.x,
94 rect.height
95 };
96}
97
100 const wxRect &rect_, unsigned iPass)
101{
102 // Common initial part of drawing for all subtypes
103 if ( iPass == TrackArtist::PassMargins ) {
104 auto rect = rect_;
105 --rect.width;
106
107 auto dc = &context.dc;
108
109
110 // Paint the background
111 auto pTrack = FindTrack();
112 AColor::MediumTrackInfo(dc, pTrack && pTrack->GetSelected() );
113 dc->DrawRectangle( rect );
114
115 // Stroke the left border
116 dc->SetPen(*wxBLACK_PEN);
117 {
118 const auto left = rect.GetLeft();
119 AColor::Line( *dc, left, rect.GetTop(), left, rect.GetBottom() );
120 }
121 }
122}
123
126 const wxRect &rect, const wxRect &, unsigned iPass)
127{
128 // Common area change for all subclasses when drawing the controls
129 // A bevel extends below one pixel outside of the hit-test area
130 if (iPass == TrackArtist::PassControls)
131 return { rect.x, rect.y, rect.width, rect.height + 1 };
132 else
133 return rect;
134}
int min(int a, int b)
declares abstract base class Track, TrackList, and iterators over TrackList
@ kRightMargin
Definition: ZoomInfo.h:28
@ kBorderThickness
Definition: ZoomInfo.h:22
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
static void MediumTrackInfo(wxDC *dc, bool selected)
Definition: AColor.cpp:433
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
std::weak_ptr< ChannelView > mwChannelView
ChannelVRulerControls(const std::shared_ptr< ChannelView > &pChannelView)
std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *pProject) override
static ChannelVRulerControls & Get(ChannelView &)
void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
static wxRect ZoomingArea(const wxRect &rect, const wxRect &panelRect)
std::shared_ptr< Track > DoFindTrack() override
static void DrawZooming(TrackPanelDrawingContext &context, const wxRect &rect, int zoomStart, int zoomEnd)
wxRect DrawingArea(TrackPanelDrawingContext &, const wxRect &rect, const wxRect &panelRect, unsigned iPass) override
std::shared_ptr< ChannelVRulerControls > GetVRulerControls()
std::shared_ptr< Track > FindTrack()