From 488cb466c364774f48e58306c5e408c763db0d87 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 4 Nov 2018 09:51:39 -0500 Subject: [PATCH] Move drawing code for track controls --- src/TrackInfo.cpp | 53 --------------- src/TrackInfo.h | 3 - src/TrackPanel.cpp | 32 --------- src/TrackPanel.h | 3 - src/tracks/ui/CommonTrackControls.cpp | 93 ++++++++++++++++++++++++++- src/tracks/ui/CommonTrackControls.h | 3 + 6 files changed, 94 insertions(+), 93 deletions(-) diff --git a/src/TrackInfo.cpp b/src/TrackInfo.cpp index d2f2a04c2..c675d4678 100644 --- a/src/TrackInfo.cpp +++ b/src/TrackInfo.cpp @@ -509,59 +509,6 @@ void TrackInfo::SetTrackInfoFont(wxDC * dc) dc->SetFont(gFont); } -#if 0 -void TrackInfo::DrawBordersWithin - ( wxDC* dc, const wxRect & rect, const Track &track ) const -{ - AColor::Dark(dc, false); // same color as border of toolbars (ToolBar::OnPaint()) - - // below close box and title bar - wxRect buttonRect; - GetTitleBarRect( rect, buttonRect ); - AColor::Line - (*dc, rect.x, buttonRect.y + buttonRect.height, - rect.width - 1, buttonRect.y + buttonRect.height); - - // between close box and title bar - AColor::Line - (*dc, buttonRect.x, buttonRect.y, - buttonRect.x, buttonRect.y + buttonRect.height - 1); - - GetMuteSoloRect( rect, buttonRect, false, true, &track ); - - bool bHasMuteSolo = dynamic_cast( &track ) != NULL; - if( bHasMuteSolo && !TrackInfo::HideTopItem( rect, buttonRect ) ) - { - // above mute/solo - AColor::Line - (*dc, rect.x, buttonRect.y, - rect.width - 1, buttonRect.y); - - // between mute/solo - // Draw this little line; if there is no solo, wide mute button will - // overpaint it later: - AColor::Line - (*dc, buttonRect.x + buttonRect.width, buttonRect.y, - buttonRect.x + buttonRect.width, buttonRect.y + buttonRect.height - 1); - - // below mute/solo - AColor::Line - (*dc, rect.x, buttonRect.y + buttonRect.height, - rect.width - 1, buttonRect.y + buttonRect.height); - } - - // left of and above minimize button - wxRect minimizeRect; - this->GetMinimizeRect(rect, minimizeRect); - AColor::Line - (*dc, minimizeRect.x - 1, minimizeRect.y, - minimizeRect.x - 1, minimizeRect.y + minimizeRect.height - 1); - AColor::Line - (*dc, minimizeRect.x, minimizeRect.y - 1, - minimizeRect.x + minimizeRect.width - 1, minimizeRect.y - 1); -} -#endif - //#define USE_BEVELS unsigned TrackInfo::DefaultTrackHeight( const TCPLines &topLines ) diff --git a/src/TrackInfo.h b/src/TrackInfo.h index c0e1d1acd..1aa58c33e 100644 --- a/src/TrackInfo.h +++ b/src/TrackInfo.h @@ -92,9 +92,6 @@ namespace TrackInfo void SetTrackInfoFont(wxDC *dc); - // void DrawBordersWithin( - // wxDC * dc, const wxRect & rect, const Track &track ) const; - void GetCloseBoxHorizontalBounds( const wxRect & rect, wxRect &dest ); void GetCloseBoxRect(const wxRect & rect, wxRect &dest); diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 13f33096f..2374069b0 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -959,7 +959,6 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context, focusRect = trackRect; focusRect.height -= kSeparatorThickness; } - DrawOutside(context, leaderTrack, trackRect); // Believe it or not, we can speed up redrawing if we don't // redraw the vertical ruler when only the waveform data has @@ -1001,37 +1000,6 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context, target->DrawExtras(UIHandle::Panel, dc, region, clip); } -void TrackPanel::DrawOutside -(TrackPanelDrawingContext &context, - const Track * t, const wxRect & rec) -{ - // Given rectangle excludes left and right margins, and encompasses a - // channel group of tracks, plus the resizer area below - - auto dc = &context.dc; - - // Start with whole track rect - wxRect rect = rec; - - // Now exclude the resizer below - rect.height -= kSeparatorThickness; - - // Vaughan, 2010-08-24: No longer doing this. - // Draw sync-lock tiles in ruler area. - //if (t->IsSyncLockSelected()) { - // wxRect tileFill = rect; - // tileFill.x = mViewInfo->GetVRulerOffset(); - // tileFill.width = mViewInfo->GetVRulerWidth(); - // TrackArt::DrawSyncLockTiles(dc, tileFill); - //} - - // Draw things within the track control panel - rect.width = kTrackInfoWidth; - TrackInfo::DrawItems( context, rect, *t ); - - //mTrackInfo.DrawBordersWithin( dc, rect, *t ); -} - void TrackPanel::SetBackgroundCell (const std::shared_ptr< TrackPanelCell > &pCell) { diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 5af6f7491..aa63405b4 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -176,9 +176,6 @@ protected: void DrawEverythingElse(TrackPanelDrawingContext &context, const wxRegion & region, const wxRect & clip); - void DrawOutside( - TrackPanelDrawingContext &context, - const Track *leaderTrack, const wxRect & teamRect); void HighlightFocusedTrack (wxDC* dc, const wxRect &rect); diff --git a/src/tracks/ui/CommonTrackControls.cpp b/src/tracks/ui/CommonTrackControls.cpp index e07b618d2..e0304c14c 100644 --- a/src/tracks/ui/CommonTrackControls.cpp +++ b/src/tracks/ui/CommonTrackControls.cpp @@ -270,16 +270,95 @@ unsigned CommonTrackControls::DoContextMenu return data.result; } +// Some old cut-and-paste legacy from TrackPanel.cpp here: +#if 0 +void TrackInfo::DrawBordersWithin + ( wxDC* dc, const wxRect & rect, const Track &track ) const +{ + AColor::Dark(dc, false); // same color as border of toolbars (ToolBar::OnPaint()) + + // below close box and title bar + wxRect buttonRect; + GetTitleBarRect( rect, buttonRect ); + AColor::Line + (*dc, rect.x, buttonRect.y + buttonRect.height, + rect.width - 1, buttonRect.y + buttonRect.height); + + // between close box and title bar + AColor::Line + (*dc, buttonRect.x, buttonRect.y, + buttonRect.x, buttonRect.y + buttonRect.height - 1); + + GetMuteSoloRect( rect, buttonRect, false, true, &track ); + + bool bHasMuteSolo = dynamic_cast( &track ) != NULL; + if( bHasMuteSolo && !TrackInfo::HideTopItem( rect, buttonRect ) ) + { + // above mute/solo + AColor::Line + (*dc, rect.x, buttonRect.y, + rect.width - 1, buttonRect.y); + + // between mute/solo + // Draw this little line; if there is no solo, wide mute button will + // overpaint it later: + AColor::Line + (*dc, buttonRect.x + buttonRect.width, buttonRect.y, + buttonRect.x + buttonRect.width, buttonRect.y + buttonRect.height - 1); + + // below mute/solo + AColor::Line + (*dc, rect.x, buttonRect.y + buttonRect.height, + rect.width - 1, buttonRect.y + buttonRect.height); + } + + // left of and above minimize button + wxRect minimizeRect; + this->GetMinimizeRect(rect, minimizeRect); + AColor::Line + (*dc, minimizeRect.x - 1, minimizeRect.y, + minimizeRect.x - 1, minimizeRect.y + minimizeRect.height - 1); + AColor::Line + (*dc, minimizeRect.x, minimizeRect.y - 1, + minimizeRect.x + minimizeRect.width - 1, minimizeRect.y - 1); +} +#endif + void CommonTrackControls::Draw( TrackPanelDrawingContext &context, - const wxRect &rect, unsigned iPass ) + const wxRect &rect_, unsigned iPass ) { if ( iPass == TrackArtist::PassMargins ) { // fill in label auto dc = &context.dc; const auto pTrack = FindTrack(); AColor::MediumTrackInfo( dc, pTrack && pTrack->GetSelected() ); - dc->DrawRectangle( rect ); + dc->DrawRectangle( rect_ ); + } + + if ( iPass == TrackArtist::PassControls ) { + // Given rectangle excludes left and right margins, and encompasses a + // channel group of tracks, plus the resizer area below + auto pTrack = FindTrack(); + // First counteract DrawingArea() correction + wxRect rect{ rect_.x, rect_.y, rect_.width - 1, rect_.height }; + + // Vaughan, 2010-08-24: No longer doing this. + // Draw sync-lock tiles in ruler area. + //if (t->IsSyncLockSelected()) { + // wxRect tileFill = rect; + // tileFill.x = mViewInfo->GetVRulerOffset(); + // tileFill.width = mViewInfo->GetVRulerWidth(); + // TrackArt::DrawSyncLockTiles(dc, tileFill); + //} + + if (pTrack) + // Draw things within the track control panel + TrackInfo::DrawItems( context, rect, *pTrack ); + + TrackInfo::DrawItems( context, rect, *FindTrack() ); + + //mTrackInfo.DrawBordersWithin( dc, rect, *t ); } // Some old cut-and-paste legacy from TrackPanel.cpp here: @@ -311,3 +390,13 @@ void CommonTrackControls::Draw( #endif } + +wxRect CommonTrackControls::DrawingArea( + const wxRect &rect, const wxRect &, unsigned iPass ) +{ + if ( iPass == TrackArtist::PassControls ) + // Some bevels spill out right + return { rect.x, rect.y, rect.width + 1, rect.height }; + else + return rect; +} diff --git a/src/tracks/ui/CommonTrackControls.h b/src/tracks/ui/CommonTrackControls.h index 0771a929d..f1780b11b 100644 --- a/src/tracks/ui/CommonTrackControls.h +++ b/src/tracks/ui/CommonTrackControls.h @@ -61,6 +61,9 @@ protected: TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass ) override; + wxRect DrawingArea( + const wxRect &rect, const wxRect &panelRect, unsigned iPass ) override; + std::weak_ptr mCloseHandle; std::weak_ptr mMenuHandle; std::weak_ptr mMinimizeHandle;