| 1 |
/********************************************************************** |
| 2 |
|
| 3 |
Audacity: A Digital Audio Editor |
| 4 |
|
| 5 |
WaveChannelVRulerControls.cpp |
| 6 |
|
| 7 |
Paul Licameli split from TrackPanel.cpp |
| 8 |
|
| 9 |
**********************************************************************/ |
| 10 |
|
| 11 |
|
| 12 |
#include "WaveChannelVRulerControls.h" |
| 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/LinearUpdater.h" |
| 24 |
#include "../../../../widgets/RealFormat.h" |
| 25 |
#include "../../../../widgets/Ruler.h" |
| 26 |
|
| 27 |
/////////////////////////////////////////////////////////////////////////////// |
| 28 |
Ruler &WaveChannelVRulerControls::ScratchRuler() |
| 29 |
{ |
| 30 |
static Ruler theRuler{ |
| 31 |
LinearUpdater::Instance(), RealFormat::LinearInstance() }; |
| 32 |
return theRuler; |
| 33 |
} |
| 34 |
|
| 35 |
void WaveChannelVRulerControls::DoDraw(ChannelVRulerControls &controls, |
| 36 |
TrackPanelDrawingContext &context, |
| 37 |
const wxRect &rect_, unsigned iPass) |
| 38 |
{ |
| 39 |
Ruler &vruler = ScratchRuler(); |
| 40 |
|
| 41 |
// Draw on a later pass because the bevel overpaints one pixel |
| 42 |
// out of bounds on the bottom |
| 43 |
|
| 44 |
if ( iPass == TrackArtist::PassControls ) { |
| 45 |
auto rect = rect_; |
| 46 |
--rect.width; |
| 47 |
--rect.height; |
| 48 |
|
| 49 |
auto dc = &context.dc; |
| 50 |
|
| 51 |
// Right align the ruler |
| 52 |
wxRect rr = rect; |
| 53 |
rr.width--; |
| 54 |
|
| 55 |
// Next code tests for a VRuler that is narrower than the rectangle |
| 56 |
// we are drawing into. If so, it 'right aligns' the ruler into the |
| 57 |
// rectangle. |
| 58 |
// However, it seems this occurs only because vrulerSize is not up to |
| 59 |
// date. That in turn caused Bug 2248, which was the labels being |
| 60 |
// drawn further right than they should be (in MultiView mode). |
| 61 |
// #ifdeffing out this code fixes bug 2248 |
| 62 |
#if 0 |
| 63 |
if ( t->vrulerSize.GetWidth() < rect.GetWidth()) { |
| 64 |
int adj = rr.GetWidth() - t->vrulerSize.GetWidth(); |
| 65 |
rr.x += adj; |
| 66 |
rr.width -= adj; |
| 67 |
} |
| 68 |
#endif |
| 69 |
|
| 70 |
controls.UpdateRuler(rr); |
| 71 |
|
| 72 |
vruler.SetTickColour( theTheme.Colour( clrTrackPanelText )); |
| 73 |
vruler.Draw(*dc); |
| 74 |
} |
| 75 |
} |