Audacity 3.2.0
WaveTrackVRulerControls.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5WaveTrackVRulerControls.cpp
6
7Paul Licameli split from TrackPanel.cpp
8
9**********************************************************************/
10
11
13
14#include "../../../../RefreshCode.h"
15#include "../../../../TrackPanelMouseEvent.h"
16#include "../../../../WaveTrack.h"
17
18#include "AColor.h"
19#include "AllThemeResources.h"
20#include "Theme.h"
21#include "../../../../TrackArtist.h"
22#include "../../../../TrackPanelDrawingContext.h"
23#include "../../../../widgets/Ruler.h"
24
27{
28 static Ruler theRuler;
29 return theRuler;
30}
31
34 const wxRect &rect_, unsigned iPass )
35{
36 Ruler &vruler = ScratchRuler();
37
38 // Draw on a later pass because the bevel overpaints one pixel
39 // out of bounds on the bottom
40
41 if ( iPass == TrackArtist::PassControls ) {
42 auto rect = rect_;
43 --rect.width;
44 --rect.height;
45
46 auto dc = &context.dc;
47
48 // All waves have a ruler in the info panel
49 // The ruler needs a bevelled surround.
50 wxRect bev = rect;
51 bev.Inflate(-1, 0);
52 bev.width += 1;
53
54 bool highlight = false;
55#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
56 highlight = rect.Contains(context.lastState.GetPosition());
57#endif
58
59 AColor::BevelTrackInfo(*dc, true, bev, highlight);
60
61 // Right align the ruler
62 wxRect rr = rect;
63 rr.width--;
64
65 auto t = controls.FindTrack();
66 if ( !t )
67 return;
68
69// Next code tests for a VRuler that is narrower than the rectangle
70// we are drawing into. If so, it 'right aligns' the ruler into the
71// rectangle.
72// However, it seems this occurs only because vrulerSize is not up to
73// date. That in turn caused Bug 2248, which was the labels being
74// drawn further right than they should be (in MultiView mode).
75// #ifdeffing out this code fixes bug 2248
76#if 0
77 if ( t->vrulerSize.GetWidth() < rect.GetWidth()) {
78 int adj = rr.GetWidth() - t->vrulerSize.GetWidth();
79 rr.x += adj;
80 rr.width -= adj;
81 }
82#endif
83
84 controls.UpdateRuler(rr);
85
86 vruler.SetTickColour( theTheme.Colour( clrTrackPanelText ));
87 vruler.Draw(*dc);
88 }
89}
THEME_API Theme theTheme
Definition: Theme.cpp:82
static void BevelTrackInfo(wxDC &dc, bool up, const wxRect &r, bool highlight=false)
Definition: AColor.cpp:340
std::shared_ptr< Track > FindTrack()
Used to display a Ruler.
Definition: Ruler.h:26
void SetTickColour(const wxColour &colour)
Definition: Ruler.h:148
void Draw(wxDC &dc) const
Definition: Ruler.cpp:1428
wxColour & Colour(int iIndex)
virtual void UpdateRuler(const wxRect &rect)=0
AUDACITY_DLL_API Ruler & ScratchRuler()
AUDACITY_DLL_API void DoDraw(TrackVRulerControls &controls, TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)