From 4633f4f9d42d69593bde739e9746f9cba06a00ab Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 4 Nov 2018 15:57:37 -0500 Subject: [PATCH] Move drawing code for background below tracks --- src/TrackArtist.h | 1 + src/TrackPanel.cpp | 10 ---------- src/tracks/ui/BackgroundCell.cpp | 31 +++++++++++++++++++++++++++++++ src/tracks/ui/BackgroundCell.h | 8 ++++++++ 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/TrackArtist.h b/src/TrackArtist.h index 0829e70ab..47816e35c 100644 --- a/src/TrackArtist.h +++ b/src/TrackArtist.h @@ -70,6 +70,7 @@ public: PassBorders, PassControls, PassZooming, + PassBackground, NPasses }; diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 3881841ee..c49a31fee 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -973,16 +973,6 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context, auto target = Target(); - // Paint over the part below the tracks - trackRect.y += trackRect.height; - if (trackRect.y < clip.GetBottom()) { - AColor::TrackPanelBackground(dc, false); - dc->DrawRectangle(trackRect.x, - trackRect.y, - trackRect.width, - clip.height - trackRect.y); - } - // Sometimes highlight is not drawn on backing bitmap. I thought // it was because FindFocus did not return "this" on Mac, but // when I removed that test, yielding this condition: diff --git a/src/tracks/ui/BackgroundCell.cpp b/src/tracks/ui/BackgroundCell.cpp index dccb08429..c18ce9f50 100644 --- a/src/tracks/ui/BackgroundCell.cpp +++ b/src/tracks/ui/BackgroundCell.cpp @@ -11,14 +11,18 @@ Paul Licameli split from TrackPanel.cpp #include "../../Audacity.h" #include "BackgroundCell.h" +#include "../../AColor.h" #include "../../HitTestResult.h" #include "../../Project.h" #include "../../RefreshCode.h" #include "../../SelectionState.h" #include "../../Track.h" +#include "../../TrackArtist.h" #include "../../TrackPanel.h" +#include "../../TrackPanelDrawingContext.h" #include "../../TrackPanelMouseEvent.h" #include "../../UIHandle.h" +#include "../../ViewInfo.h" #include #include @@ -117,3 +121,30 @@ std::shared_ptr BackgroundCell::DoFindTrack() return {}; } +void BackgroundCell::Draw( + TrackPanelDrawingContext &context, + const wxRect &rect, unsigned iPass ) +{ + if ( iPass == TrackArtist::PassBackground ) { + auto &dc = context.dc; + // Paint over the part below the tracks + AColor::TrackPanelBackground( &dc, false ); + dc.DrawRectangle( rect ); + } +} + +wxRect BackgroundCell::DrawingArea( + const wxRect &rect, const wxRect &, unsigned iPass ) +{ + if ( iPass == TrackArtist::PassBackground ) + // If there are any tracks, extend the drawing area up, to cover the + // bottom ends of any zooming guide lines. + return { + rect.x, + rect.y - kTopMargin, + rect.width, + rect.height + kTopMargin + }; + else + return rect; +} diff --git a/src/tracks/ui/BackgroundCell.h b/src/tracks/ui/BackgroundCell.h index 7d964129d..8d3cb8f24 100644 --- a/src/tracks/ui/BackgroundCell.h +++ b/src/tracks/ui/BackgroundCell.h @@ -44,6 +44,14 @@ protected: std::shared_ptr DoFindTrack() override; private: + // TrackPanelDrawable implementation + void Draw( + TrackPanelDrawingContext &context, + const wxRect &rect, unsigned iPass ) override; + + wxRect DrawingArea( + const wxRect &rect, const wxRect &panelRect, unsigned iPass ) override; + AudacityProject *mpProject; std::weak_ptr mHandle;