From 6c98a5a2aaad37518cd3f4b7868553a18160a169 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 6 Aug 2021 17:03:30 -0400 Subject: [PATCH] In ViewInfo, remove GetLabelWidth() and add comments (cherry picked from audacity commit cef8e228f9ab6005d3e4a3a16d893aed695b669f) Signed-off-by: akleja --- src/TrackPanel.cpp | 6 +++--- src/TrackPanelResizerCell.cpp | 2 +- src/ZoomInfo.h | 6 ++++-- src/tracks/labeltrack/ui/LabelTrackView.cpp | 7 ++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index fd060d09a..daadeb392 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -26,7 +26,7 @@ TrackInfo class to draw the controls area on the left of a track, and the TrackArtist class to draw the actual waveforms. - Note that in some of the older code here, e.g., GetLabelWidth(), + Note that in some of the older code here, "Label" means the TrackInfo plus the vertical ruler. Confusing relative to LabelTrack labels. @@ -118,8 +118,8 @@ controls, and is a constant. GetVRulerWidth() is variable -- all tracks have the same ruler width at any time, but that width may be adjusted when tracks change their vertical scales. -GetLabelWidth() counts columns up to and including the VRuler. -GetLeftOffset() is yet one more -- it counts the "one pixel" column. +GetLeftOffset() counts columns up to and including the VRuler and one more, +the "one pixel" column. Cell for label has a rectangle that OMITS left, top, and bottom margins diff --git a/src/TrackPanelResizerCell.cpp b/src/TrackPanelResizerCell.cpp index f0f052009..9f688e609 100644 --- a/src/TrackPanelResizerCell.cpp +++ b/src/TrackPanelResizerCell.cpp @@ -74,7 +74,7 @@ void TrackPanelResizerCell::Draw( // Paint the left part of the background const auto artist = TrackArtist::Get( context ); - auto labelw = artist->pZoomInfo->GetLabelWidth(); + auto labelw = artist->pZoomInfo->GetLeftOffset() - 1; AColor::MediumTrackInfo( dc, pTrack->GetSelected() ); dc->DrawRectangle( rect.GetX(), rect.GetY(), labelw, rect.GetHeight() ); diff --git a/src/ZoomInfo.h b/src/ZoomInfo.h index 9d92990fc..b45d53ef2 100644 --- a/src/ZoomInfo.h +++ b/src/ZoomInfo.h @@ -98,9 +98,11 @@ public: int GetVRulerWidth() const { return mVRulerWidth; } void SetVRulerWidth( int width ) { mVRulerWidth = width; } int GetVRulerOffset() const { return kTrackInfoWidth + kLeftMargin; } - int GetLabelWidth() const { return GetVRulerOffset() + GetVRulerWidth(); } - int GetLeftOffset() const { return GetLabelWidth() + 1;} + // The x-coordinate of the start of the displayed track data + int GetLeftOffset() const + { return GetVRulerOffset() + GetVRulerWidth() + 1; } + // The number of pixel columns for display of track data int GetTracksUsableWidth() const { return diff --git a/src/tracks/labeltrack/ui/LabelTrackView.cpp b/src/tracks/labeltrack/ui/LabelTrackView.cpp index f37fa413b..a09c707dd 100644 --- a/src/tracks/labeltrack/ui/LabelTrackView.cpp +++ b/src/tracks/labeltrack/ui/LabelTrackView.cpp @@ -2253,9 +2253,10 @@ int LabelTrackView::DialogForLabelName( trackPanel.FindTrackRect( trackFocus.Get() ).GetBottomLeft(); // The start of the text in the text box will be roughly in line with the label's position // if it's a point label, or the start of its region if it's a region label. - position.x += viewInfo.GetLabelWidth() - + std::max(0, static_cast(viewInfo.TimeToPosition(region.t0()))) - -40; + position.x += + + std::max(0, static_cast(viewInfo.TimeToPosition( + viewInfo.GetLeftOffset(), region.t0()))) + - 39; position.y += 2; // just below the bottom of the track position = trackPanel.ClientToScreen(position); auto &window = GetProjectFrame( project );