mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-08 08:27:43 +02:00
Better document GetHeight of TrackView, rename GetY...
... And explain rectangle calculations in TrackPanel::RefreshTrack (cherry picked from audacity commit 1a9b4d16e7bf6ec1878b483faa23153619d00894) Signed-off-by: akleja <storspov@gmail.com>
This commit is contained in:
parent
e8fb7b2803
commit
cfc1bf35e7
@ -102,6 +102,9 @@ bool AudacityPrintout::OnPrintPage(int WXUNUSED(page))
|
|||||||
r.x = 0;
|
r.x = 0;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
r.width = width;
|
r.width = width;
|
||||||
|
// Note that the views as printed might not have the same proportional
|
||||||
|
// heights as displayed on the screen, because the fixed-sized separators
|
||||||
|
// are counted in those heights but not printed
|
||||||
auto trackHeight = (int)(view.GetHeight() * scale);
|
auto trackHeight = (int)(view.GetHeight() * scale);
|
||||||
r.height = trackHeight;
|
r.height = trackHeight;
|
||||||
|
|
||||||
|
@ -752,23 +752,30 @@ void TrackPanel::RefreshTrack(Track *trk, bool refreshbacking)
|
|||||||
if (!trk)
|
if (!trk)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Always move to the first channel of the group, and use only
|
||||||
|
// the sum of channel heights, not the height of any channel alone!
|
||||||
trk = *GetTracks()->FindLeader(trk);
|
trk = *GetTracks()->FindLeader(trk);
|
||||||
auto &view = TrackView::Get( *trk );
|
auto &view = TrackView::Get( *trk );
|
||||||
auto height =
|
auto height =
|
||||||
TrackList::Channels(trk).sum( TrackView::GetTrackHeight )
|
TrackList::Channels(trk).sum( TrackView::GetTrackHeight );
|
||||||
- kTopInset - kShadowThickness;
|
|
||||||
|
|
||||||
// subtract insets and shadows from the rectangle, but not border
|
// Set rectangle top according to the scrolling position, `vpos`
|
||||||
|
// Subtract the inset (above) and shadow (below) from the height of the
|
||||||
|
// rectangle, but not the border
|
||||||
// This matters because some separators do paint over the border
|
// This matters because some separators do paint over the border
|
||||||
wxRect rect(kLeftInset,
|
const auto top =
|
||||||
-mViewInfo->vpos + view.GetY() + kTopInset,
|
-mViewInfo->vpos + view.GetCumulativeHeightBefore() + kTopInset;
|
||||||
GetRect().GetWidth() - kLeftInset - kRightInset - kShadowThickness,
|
height -= (kTopInset + kShadowThickness);
|
||||||
height);
|
|
||||||
|
// Width also subtracts insets (left and right) plus shadow (right)
|
||||||
|
const auto left = kLeftInset;
|
||||||
|
const auto width = GetRect().GetWidth()
|
||||||
|
- (kLeftInset + kRightInset + kShadowThickness);
|
||||||
|
|
||||||
|
wxRect rect(left, top, width, height);
|
||||||
|
|
||||||
if( refreshbacking )
|
if( refreshbacking )
|
||||||
{
|
|
||||||
mRefreshBacking = true;
|
mRefreshBacking = true;
|
||||||
}
|
|
||||||
|
|
||||||
Refresh( false, &rect );
|
Refresh( false, &rect );
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ int TrackView::GetCumulativeHeight( const Track *pTrack )
|
|||||||
if ( !pTrack )
|
if ( !pTrack )
|
||||||
return 0;
|
return 0;
|
||||||
auto &view = Get( *pTrack );
|
auto &view = Get( *pTrack );
|
||||||
return view.GetY() + view.GetHeight();
|
return view.GetCumulativeHeightBefore() + view.GetHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TrackView::GetTotalHeight( const TrackList &list )
|
int TrackView::GetTotalHeight( const TrackList &list )
|
||||||
@ -179,8 +179,10 @@ std::shared_ptr<CommonTrackCell> TrackView::DoGetAffordanceControls()
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Attach an object to each project. It receives track list events and updates
|
/*!
|
||||||
// track Y coordinates
|
Attached to each project, it receives track list events and maintains the
|
||||||
|
cache of cumulative track view heights for use by TrackPanel.
|
||||||
|
*/
|
||||||
struct TrackPositioner final : ClientData::Base, wxEvtHandler
|
struct TrackPositioner final : ClientData::Base, wxEvtHandler
|
||||||
{
|
{
|
||||||
AudacityProject &mProject;
|
AudacityProject &mProject;
|
||||||
@ -214,7 +216,7 @@ struct TrackPositioner final : ClientData::Base, wxEvtHandler
|
|||||||
|
|
||||||
while( auto pTrack = *iter ) {
|
while( auto pTrack = *iter ) {
|
||||||
auto &view = TrackView::Get( *pTrack );
|
auto &view = TrackView::Get( *pTrack );
|
||||||
view.SetY( yy );
|
view.SetCumulativeHeightBefore( yy );
|
||||||
yy += view.GetHeight();
|
yy += view.GetHeight();
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
@ -49,16 +49,24 @@ public:
|
|||||||
bool GetMinimized() const { return mMinimized; }
|
bool GetMinimized() const { return mMinimized; }
|
||||||
void SetMinimized( bool minimized );
|
void SetMinimized( bool minimized );
|
||||||
|
|
||||||
int GetY() const { return mY; }
|
//! @return cached sum of `GetHeight()` of all preceding tracks
|
||||||
|
int GetCumulativeHeightBefore() const { return mY; }
|
||||||
|
|
||||||
//! @return height of the track when expanded
|
//! @return height of the track when expanded
|
||||||
int GetExpandedHeight() const { return mHeight; }
|
int GetExpandedHeight() const { return mHeight; }
|
||||||
|
|
||||||
//! @return height of the track when collapsed
|
//! @return height of the track when collapsed
|
||||||
virtual int GetMinimizedHeight() const = 0;
|
virtual int GetMinimizedHeight() const = 0;
|
||||||
|
|
||||||
|
//! @return height of the track as it now appears, expanded or collapsed
|
||||||
|
/*!
|
||||||
|
Total "height" of channels of a track includes padding areas above and
|
||||||
|
below it.
|
||||||
|
*/
|
||||||
int GetHeight() const;
|
int GetHeight() const;
|
||||||
|
|
||||||
void SetY(int y) { DoSetY( y ); }
|
//! Set cached value dependent on position within the track list
|
||||||
|
void SetCumulativeHeightBefore(int y) { DoSetY( y ); }
|
||||||
|
|
||||||
/*! Sets height for expanded state.
|
/*! Sets height for expanded state.
|
||||||
Does not expand a track if it is now collapsed.
|
Does not expand a track if it is now collapsed.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user