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) : CommonChannelCell{ pChannelView->FindChannel() }
29 , mwChannelView{ pChannelView }
30{
31}
32
34{
35}
36
38{
39 return *trackView.GetVRulerControls();
40}
41
43 const ChannelView &trackView)
44{
45 return *trackView.GetVRulerControls();
46}
47
48std::shared_ptr<Track> ChannelVRulerControls::DoFindTrack()
49{
50 // Just pass-through to related ChannelView object
51 const auto pView = mwChannelView.lock();
52 if (pView)
53 return pView->DoFindTrack();
54 return {};
55}
56
57std::vector<UIHandlePtr> ChannelVRulerControls::HitTest(
59{
60 return std::vector<UIHandlePtr>{};
61}
62
64 TrackPanelDrawingContext &context, const wxRect &rect_,
65 int zoomStart, int zoomEnd)
66{
67 // Draw a dashed rectangle, its right side disappearing in the black right
68 // border of the track area, which is not part of this cell but right of it.
69 auto &dc = context.dc;
70
71 dc.SetBrush(*wxTRANSPARENT_BRUSH);
72 dc.SetPen(*wxBLACK_DASHED_PEN);
73
74 wxRect rect {
75 rect_.x,
76 std::min( zoomStart, zoomEnd),
77 rect_.width,
78 1 + abs( zoomEnd - zoomStart)
79 };
80
81 dc.DrawRectangle(rect);
82}
83
85 const wxRect &rect, const wxRect &panelRect)
86{
87 // TODO: Don't use the constant kRightMargin, but somehow discover the
88 // neighboring track rectangle
89 return {
90 // Left edge of the rectangle disappears in the vertical line at
91 // left edge of the ruler
92 rect.x,
93 rect.y,
94 // Extend the dashed rectangle right up to the track border
95 (panelRect.width - kRightMargin + kBorderThickness) - rect.x,
96 rect.height
97 };
98}
99
102 const wxRect &rect, const wxRect &, unsigned iPass)
103{
104 // Common area change for all subclasses when drawing the controls
105 // A bevel extends below one pixel outside of the hit-test area
106 if (iPass == TrackArtist::PassControls)
107 return { rect.x, rect.y, rect.width, rect.height + 1 };
108 else
109 return rect;
110}
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
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 &)
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()