From 0f17b309bc6b6f7cb7c1dee93d1eba7402aaaa64 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 2 Nov 2018 10:04:11 -0400 Subject: [PATCH] Fuse the two sash-drawing functions, pass a rectangle not a track... ... and be consistent about substituting the track before finding Y and height --- src/TrackPanel.cpp | 64 ++++++++++++++++++++++++---------------------- src/TrackPanel.h | 4 +-- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index b71acc0d9..4c2830a57 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -1600,21 +1600,11 @@ void TrackPanel::DrawOutside { auto dc = &context.dc; - // Draw things that extend right of track control panel { // Start with whole track rect wxRect rect = rec; DrawOutsideOfTrack(context, rect); - { - auto channels = TrackList::Channels(t); - // omit last (perhaps, only) channel - --channels.second; - for (auto channel : channels) - // draw the sash below this channel - DrawSash(channel, dc, rect); - } - // Now exclude left, right, and top insets rect.x += kLeftInset; rect.y += kTopInset; @@ -1639,9 +1629,17 @@ void TrackPanel::DrawOutside auto channels = TrackList::Channels(t); // omit last (perhaps, only) channel --channels.second; - for (auto channel : channels) + for (auto channel : channels) { // draw the sash below this channel - DrawBordersAroundSash(channel, dc, rect, labelw); + channel = channel->SubstitutePendingChangedTrack().get(); + auto yy = + channel->GetY() - mViewInfo->vpos + channel->GetHeight() + - kBottomMargin; + wxRect sashRect{ + vrul, yy, rect.GetRight() - vrul, kSeparatorThickness + }; + DrawSash( dc, sashRect, labelw ); + } } DrawShadow( dc, rect ); @@ -1689,17 +1687,33 @@ void TrackPanel::DrawOutsideOfTrack dc->DrawRectangle(side); } -void TrackPanel::DrawSash(const Track * t, wxDC * dc, const wxRect & rect) +void TrackPanel::DrawSash( wxDC * dc, const wxRect & rect, int labelw ) { // Area between channels of a group - // Paint the channel separator over (what would be) the shadow of this - // channel, and the top inset of the following channel - wxRect side = rect; - side.y = t->GetY() - mViewInfo->vpos + t->GetHeight() - kShadowThickness; - side.height = kTopInset + kShadowThickness; - dc->DrawRectangle(side); + // Paint the channel separator over (what would be) the lower border of this + // channel, down to and including the upper border of the next channel + + ADCChanger cleanup{ dc }; + AColor::TrackPanelBackground(dc, false); + + wxRect rec{ rect }; + rec.width -= labelw - rec.x; + rec.x = labelw; + + dc->DrawRectangle( wxRect{ rec }.Inflate( 0, -kBorderThickness ) ); + + // These lines stroke over what is otherwise "border" of each channel + dc->SetBrush(*wxTRANSPARENT_BRUSH); + dc->SetPen(*wxBLACK_PEN); + const auto left = rec.GetLeft(); + const auto right = rec.GetRight(); + const auto top = rec.GetTop(); + const auto bottom = rec.GetBottom(); + AColor::Line( *dc, left, top, right, top ); + AColor::Line( *dc, left, bottom, right, bottom ); } + void TrackPanel::SetBackgroundCell (const std::shared_ptr< TrackPanelCell > &pCell) { @@ -1910,18 +1924,6 @@ void TrackPanel::DrawBordersAroundTrack(wxDC * dc, AColor::Line(*dc, vrul, rect.y, vrul, rect.y + rect.height - 1); } -void TrackPanel::DrawBordersAroundSash(const Track * t, wxDC * dc, - const wxRect & rect, const int labelw) -{ - int h1 = t->GetY() - mViewInfo->vpos + t->GetHeight(); - // h1 is the top coordinate of the following channel's rectangle - // Draw (part of) the bottom border of the top channel and top border of the bottom - // At left it extends between the vertical rulers too - // These lines stroke over what is otherwise "border" of each channel - AColor::Line(*dc, labelw, h1 - kBottomMargin, rect.x + rect.width - 1, h1 - kBottomMargin); - AColor::Line(*dc, labelw, h1 + kTopInset, rect.x + rect.width - 1, h1 + kTopInset); -} - // Given rectangle has insets subtracted left, right, and top // Stroke lines along bottom and right, which are slightly short at // bottom-left and top-right diff --git a/src/TrackPanel.h b/src/TrackPanel.h index c01b014f2..2871b87b0 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -378,11 +378,9 @@ protected: void DrawShadow ( wxDC* dc, const wxRect & rect ); void DrawBordersAroundTrack(wxDC* dc, const wxRect & rect, const int vrul); - void DrawBordersAroundSash (const Track *t, wxDC* dc, const wxRect & rect, - const int labelw); void DrawOutsideOfTrack ( TrackPanelDrawingContext &context, const wxRect & rect ); - void DrawSash (const Track *t, wxDC* dc, const wxRect & rect); + void DrawSash ( wxDC* dc, const wxRect & rect, int labelw ); public: // Set the object that performs catch-all event handling when the pointer