Audacity  3.0.3
WaveTrackVRulerControls.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 WaveTrackVRulerControls.cpp
6 
7 Paul 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 
33  TrackPanelDrawingContext &context,
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 }
AllThemeResources.h
CommonTrackPanelCell::FindTrack
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:46
TrackPanelDrawingContext
Definition: TrackPanelDrawingContext.h:22
Ruler::SetTickColour
void SetTickColour(const wxColour &colour)
Definition: Ruler.h:148
Ruler::Draw
void Draw(wxDC &dc) const
Definition: Ruler.cpp:1428
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
AColor::BevelTrackInfo
static void BevelTrackInfo(wxDC &dc, bool up, const wxRect &r, bool highlight=false)
Definition: AColor.cpp:248
TrackVRulerControls
Definition: TrackVRulerControls.h:25
WaveTrackVRulerControls::DoDraw
AUDACITY_DLL_API void DoDraw(TrackVRulerControls &controls, TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Definition: WaveTrackVRulerControls.cpp:32
Ruler
Used to display a Ruler.
Definition: Ruler.h:26
Theme.h
TrackPanelDrawingContext::lastState
wxMouseState lastState
Definition: TrackPanelDrawingContext.h:25
TrackArtist::PassControls
@ PassControls
Definition: TrackArtist.h:84
WaveTrackVRulerControls.h
TrackVRulerControls::UpdateRuler
virtual void UpdateRuler(const wxRect &rect)=0
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
WaveTrackVRulerControls::ScratchRuler
AUDACITY_DLL_API Ruler & ScratchRuler()
Definition: WaveTrackVRulerControls.cpp:26
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1189
AColor.h