diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index 766e7d16f..190aaa87a 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -78,6 +78,7 @@ audio tracks. #include "prefs/TracksPrefs.h" #include "prefs/WaveformSettings.h" #include "Spectrum.h" +#include "TrackPanel.h" #include "ViewInfo.h" #include "widgets/Ruler.h" #include "Theme.h" @@ -165,11 +166,6 @@ int TrackArtist::GetBottom(NoteTrack *t, const wxRect &rect) TrackArtist::TrackArtist() { - mMarginLeft = 0; - mMarginTop = 0; - mMarginRight = 0; - mMarginBottom = 0; - mdBrange = ENV_DB_RANGE; mShowClipping = false; mSampleDisplay = 1;// Stem plots by default. @@ -230,27 +226,20 @@ void TrackArtist::SetColours( int iColorIndex) } } -void TrackArtist::SetMargins(int left, int top, int right, int bottom) -{ - mMarginLeft = left; - mMarginTop = top; - mMarginRight = right; - mMarginBottom = bottom; -} - void TrackArtist::DrawTracks(TrackPanelDrawingContext &context, const TrackList * tracks, const wxRegion & reg, - const wxRect & rect, - const wxRect & clip, + const wxRect & clip, int leftOffset, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo, bool drawEnvelope, bool bigPoints, bool drawSliders) { - // Copy the horizontal extent of rect; will later change only the vertical. - wxRect teamRect = rect; + // Fix the horizontal extent; will later change only the vertical extent. + wxRect teamRect{ + clip.x + leftOffset, 0, clip.width - (leftOffset + kRightMargin), 0 + }; bool hasSolo = false; for (const Track *t : *tracks) { @@ -262,19 +251,6 @@ void TrackArtist::DrawTracks(TrackPanelDrawingContext &context, } } -#if defined(DEBUG_CLIENT_AREA) - // Change the +0 to +1 or +2 to see the bounding box - mMarginLeft = 1+0; mMarginTop = 5+0; mMarginRight = 6+0; mMarginBottom = 2+0; - - // This just shows what the passed in rectangles enclose - dc.SetPen(wxColour(*wxGREEN)); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(rect); - dc.SetPen(wxColour(*wxBLUE)); - dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(clip); -#endif - gPrefs->Read(wxT("/GUI/ShowTrackNameInWaveform"), &mbShowTrackNameInWaveform, false); for(auto leader : tracks->Leaders()) { @@ -293,15 +269,6 @@ void TrackArtist::DrawTracks(TrackPanelDrawingContext &context, break; for (auto t : group) { -#if defined(DEBUG_CLIENT_AREA) - // Filled rectangle to show the interior of the client area - wxRect zr = trackRect; - zr.x+=1; zr.y+=5; zr.width-=7; zr.height-=7; - dc.SetPen(*wxCYAN_PEN); - dc.SetBrush(*wxRED_BRUSH); - dc.DrawRectangle(zr); -#endif - // For various reasons, the code will break if we display one // of a stereo pair of tracks but not the other - for example, // if you try to edit the envelope of one track when its linked @@ -313,10 +280,10 @@ void TrackArtist::DrawTracks(TrackPanelDrawingContext &context, if (teamRect.Intersects(clip) && reg.Contains(teamRect)) { t = t->SubstitutePendingChangedTrack().get(); wxRect trackRect { - rect.x + mMarginLeft, - t->GetY() - zoomInfo.vpos + mMarginTop, - rect.width - (mMarginLeft + mMarginRight), - t->GetHeight() - (mMarginTop + mMarginBottom) + teamRect.x, + t->GetY() - zoomInfo.vpos + kTopMargin, + teamRect.width, + t->GetHeight() - (kTopMargin + kBottomMargin) }; DrawTrack(context, t, trackRect, selectedRegion, zoomInfo, diff --git a/src/TrackArtist.h b/src/TrackArtist.h index 4cb3d43fc..87933e914 100644 --- a/src/TrackArtist.h +++ b/src/TrackArtist.h @@ -57,7 +57,7 @@ class AUDACITY_DLL_API TrackArtist { void DrawTracks(TrackPanelDrawingContext &context, const TrackList *tracks, const wxRegion & reg, - const wxRect & rect, const wxRect & clip, + const wxRect &clip, int leftOffset, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo, bool drawEnvelope, bool bigPoints, bool drawSliders); @@ -73,8 +73,6 @@ class AUDACITY_DLL_API TrackArtist { void UpdateVRuler(const Track *t, const wxRect & rect); - void SetMargins(int left, int top, int right, int bottom); - void UpdatePrefs(); void SetBackgroundBrushes(wxBrush unselectedBrushIn, wxBrush selectedBrushIn, @@ -182,11 +180,6 @@ class AUDACITY_DLL_API TrackArtist { int mSampleDisplay; bool mbShowTrackNameInWaveform; // "/GUI/ShowTrackNameInWaveform" - int mMarginLeft; - int mMarginTop; - int mMarginRight; - int mMarginBottom; - wxBrush blankBrush; wxBrush unselectedBrush; wxBrush selectedBrush; diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index ab29e3185..b71acc0d9 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -242,8 +242,6 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, mTrackArtist = std::make_unique(); - mTrackArtist->SetMargins(1, kTopMargin, kRightMargin, kBottomMargin); - mTimeCount = 0; mTimer.parent = this; // Timer is started after the window is visible @@ -1053,13 +1051,6 @@ void TrackPanel::DrawTracks(wxDC * dc) const wxRect clip = GetRect(); - wxRect panelRect = clip; - panelRect.y = -mViewInfo->vpos; - - wxRect tracksRect = panelRect; - tracksRect.x += GetLabelWidth(); - tracksRect.width -= GetLabelWidth(); - ToolsToolBar *pTtb = mListener->TP_GetToolsToolBar(); bool bMultiToolDown = pTtb->IsDown(multiTool); bool envelopeFlag = pTtb->IsDown(envelopeTool) || bMultiToolDown; @@ -1070,7 +1061,7 @@ void TrackPanel::DrawTracks(wxDC * dc) // The track artist actually draws the stuff inside each track mTrackArtist->DrawTracks(context, GetTracks(), - region, tracksRect, clip, + region, clip, GetLeftOffset(), mViewInfo->selectedRegion, *mViewInfo, envelopeFlag, bigPointsFlag, sliderFlag); @@ -1608,13 +1599,12 @@ void TrackPanel::DrawOutside const Track * t, const wxRect & rec) { auto dc = &context.dc; - const auto wt = track_cast(t); // Draw things that extend right of track control panel { // Start with whole track rect wxRect rect = rec; - DrawOutsideOfTrack(context, t, rect); + DrawOutsideOfTrack(context, rect); { auto channels = TrackList::Channels(t); @@ -1632,8 +1622,7 @@ void TrackPanel::DrawOutside rect.height -= kTopInset; int labelw = GetLabelWidth(); - int vrul = GetVRulerOffset(); - mTrackInfo.DrawBackground(dc, rect, t->GetSelected(), (wt != nullptr), labelw, vrul); + mTrackInfo.DrawBackground( dc, rect, t->GetSelected(), labelw ); // Vaughan, 2010-08-24: No longer doing this. // Draw sync-lock tiles in ruler area. @@ -1644,6 +1633,7 @@ void TrackPanel::DrawOutside // TrackArtist::DrawSyncLockTiles(dc, tileFill); //} + int vrul = GetVRulerOffset(); DrawBordersAroundTrack(dc, rect, vrul); { auto channels = TrackList::Channels(t); @@ -1654,7 +1644,7 @@ void TrackPanel::DrawOutside DrawBordersAroundSash(channel, dc, rect, labelw); } - DrawShadow(t, dc, rect); + DrawShadow( dc, rect ); } // Draw things within the track control panel @@ -1674,9 +1664,8 @@ void TrackPanel::DrawOutside // If linked to a following channel, also paint the separator area, which // overlaps the next track rectangle's top void TrackPanel::DrawOutsideOfTrack -(TrackPanelDrawingContext &context, const Track * t, const wxRect & rect) +(TrackPanelDrawingContext &context, const wxRect & rect) { - (void)t;// Compiler food auto dc = &context.dc; // Fill in area outside of the track @@ -1734,13 +1723,16 @@ void TrackPanel::HighlightFocusedTrack(wxDC * dc, const wxRect & rect) dc->SetBrush(*wxTRANSPARENT_BRUSH); AColor::TrackFocusPen(dc, 0); - dc->DrawRectangle(theRect.x - 1, theRect.y - 1, theRect.width + 2, theRect.height + 2); + theRect.Inflate(1); + dc->DrawRectangle(theRect); AColor::TrackFocusPen(dc, 1); - dc->DrawRectangle(theRect.x - 2, theRect.y - 2, theRect.width + 4, theRect.height + 4); + theRect.Inflate(1); + dc->DrawRectangle(theRect); AColor::TrackFocusPen(dc, 2); - dc->DrawRectangle(theRect.x - 3, theRect.y - 3, theRect.width + 6, theRect.height + 6); + theRect.Inflate(1); + dc->DrawRectangle(theRect); } void TrackPanel::UpdateVRulers() @@ -1933,7 +1925,7 @@ void TrackPanel::DrawBordersAroundSash(const Track * t, wxDC * dc, // 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 -void TrackPanel::DrawShadow(const Track * /* t */ , wxDC * dc, const wxRect & rect) +void TrackPanel::DrawShadow( wxDC * dc, const wxRect & rect ) { int right = rect.x + rect.width - 1; int bottom = rect.y + rect.height - 1; @@ -2458,6 +2450,7 @@ void TrackInfo::SetTrackInfoFont(wxDC * dc) dc->SetFont(gFont); } +#if 0 void TrackInfo::DrawBordersWithin ( wxDC* dc, const wxRect & rect, const Track &track ) const { @@ -2508,17 +2501,14 @@ void TrackInfo::DrawBordersWithin (*dc, minimizeRect.x, minimizeRect.y - 1, minimizeRect.x + minimizeRect.width - 1, minimizeRect.y - 1); } +#endif //#define USE_BEVELS // Paint the whole given rectangle some fill color -void TrackInfo::DrawBackground(wxDC * dc, const wxRect & rect, bool bSelected, - bool bHasMuteSolo, const int labelw, const int vrul) const +void TrackInfo::DrawBackground( + wxDC * dc, const wxRect & rect, bool bSelected, const int labelw) const { - //compiler food. - static_cast(bHasMuteSolo); - static_cast(vrul); - // fill in label wxRect fill = rect; fill.width = labelw - kLeftInset; @@ -2527,7 +2517,9 @@ void TrackInfo::DrawBackground(wxDC * dc, const wxRect & rect, bool bSelected, #ifdef USE_BEVELS // This branch is not now used - // PRL: todo: banish magic numbers + // PRL: todo: banish magic numbers. + // PRL: vrul was the x coordinate of left edge of the vertical ruler. + // PRL: bHasMuteSolo was true iff the track was WaveTrack. if( bHasMuteSolo ) { int ylast = rect.height-20; diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 552757b48..c01b014f2 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -151,8 +151,10 @@ public: static void SetTrackInfoFont(wxDC *dc); - void DrawBackground(wxDC * dc, const wxRect & rect, bool bSelected, bool bHasMuteSolo, const int labelw, const int vrul) const; - void DrawBordersWithin(wxDC * dc, const wxRect & rect, const Track &track ) const; + void DrawBackground( + wxDC * dc, const wxRect & rect, bool bSelected, const int labelw ) const; + // void DrawBordersWithin( + // wxDC * dc, const wxRect & rect, const Track &track ) const; static void GetCloseBoxHorizontalBounds( const wxRect & rect, wxRect &dest ); static void GetCloseBoxRect(const wxRect & rect, wxRect &dest); @@ -373,14 +375,13 @@ protected: const Track *leaderTrack, const wxRect & teamRect); void HighlightFocusedTrack (wxDC* dc, const wxRect &rect); - void DrawShadow (const Track *t, wxDC* dc, const wxRect & rect); + 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 Track *t, const wxRect & rect); + TrackPanelDrawingContext &context, const wxRect & rect ); void DrawSash (const Track *t, wxDC* dc, const wxRect & rect); public: