1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Move Y position, height, and minimized state into TrackView...

... and eliminate some unnecessary calls to SubstitutePendingChangedTrack,
because the track and the substitute store Y and height in their shared
TrackView object.

Also make GetMinimizedHeight() virtual to avoid inclusion of TrackPanel.h in
TrackView.cpp.
This commit is contained in:
Paul Licameli
2019-06-18 11:32:26 -04:00
parent 3797a5227a
commit 66e32ca35d
28 changed files with 244 additions and 225 deletions

View File

@@ -117,7 +117,7 @@ is time to refresh some aspect of the screen.
\class TrackPanel
This is a diagram of TrackPanel's division of one (non-stereo) track rectangle.
Total height equals Track::GetHeight()'s value. Total width is the wxWindow's
Total height equals TrackView::GetHeight()'s value. Total width is the wxWindow's
width. Each charater that is not . represents one pixel.
Inset space of this track, and top inset of the next track, are used to draw the
@@ -1095,14 +1095,17 @@ void TrackPanel::RefreshTrack(Track *trk, bool refreshbacking)
return;
trk = *GetTracks()->FindLeader(trk);
auto &view = TrackView::Get( *trk );
const auto GetHeight = []( const Track *track )
{ return TrackView::Get( *track ).GetHeight(); };
auto height =
TrackList::Channels(trk).sum( &Track::GetHeight )
TrackList::Channels(trk).sum( GetHeight )
- kTopInset - kShadowThickness;
// subtract insets and shadows from the rectangle, but not border
// This matters because some separators do paint over the border
wxRect rect(kLeftInset,
-mViewInfo->vpos + trk->GetY() + kTopInset,
-mViewInfo->vpos + view.GetY() + kTopInset,
GetRect().GetWidth() - kLeftInset - kRightInset - kShadowThickness,
height);
@@ -1224,11 +1227,11 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
bool first = true;
for (auto channel : channels) {
focused = focused || mAx->IsFocused(channel);
channel = channel->SubstitutePendingChangedTrack().get();
auto &view = TrackView::Get( *channel );
if (first)
first = false,
teamRect.y = channel->GetY() - mViewInfo->vpos + kTopMargin;
teamRect.height += channel->GetHeight();
teamRect.y = view.GetY() - mViewInfo->vpos + kTopMargin;
teamRect.height += view.GetHeight();
}
if (focused) {
@@ -1248,10 +1251,11 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
#endif
for (auto channel : channels) {
auto &view = TrackView::Get( *channel );
bool bSelected = channel->GetSelected();
channel = channel->SubstitutePendingChangedTrack().get();
trackRect.y = channel->GetY() - mViewInfo->vpos + kTopMargin;
trackRect.height = channel->GetHeight();
trackRect.y = view.GetY() - mViewInfo->vpos + kTopMargin;
trackRect.height = view.GetHeight();
if (region.Contains(
0, trackRect.y, GetLeftOffset(), trackRect.height)) {
wxRect rect{
@@ -1794,10 +1798,10 @@ void TrackPanel::DrawOutside
// omit last (perhaps, only) channel
--channels.second;
for (auto channel : channels) {
auto &view = TrackView::Get( *channel );
// draw the sash below this channel
channel = channel->SubstitutePendingChangedTrack().get();
auto yy =
channel->GetY() - mViewInfo->vpos + channel->GetHeight()
view.GetY() - mViewInfo->vpos + view.GetHeight()
- kBottomMargin;
wxRect sashRect{
vrul, yy, rect.GetRight() - vrul, kSeparatorThickness
@@ -1980,7 +1984,8 @@ void TrackPanel::UpdateTrackVRuler(const Track *t)
for (auto channel : TrackList::Channels(t)) {
rect.height = channel->GetHeight() - (kTopMargin + kBottomMargin);
auto &view = TrackView::Get( *channel );
rect.height = view.GetHeight() - (kTopMargin + kBottomMargin);
mTrackArtist->UpdateVRuler(channel, rect);
}
}
@@ -2048,7 +2053,9 @@ void TrackPanel::EnsureVisible(Track * t)
trackTop += trackHeight;
auto channels = TrackList::Channels(it);
trackHeight = channels.sum( &Track::GetHeight );
const auto GetHeight = []( const Track *track )
{ return TrackView::Get( *track ).GetHeight(); };
trackHeight = channels.sum( GetHeight );
//We have found the track we want to ensure is visible.
if (channels.contains(t)) {
@@ -2082,7 +2089,7 @@ void TrackPanel::VerticalScroll( float fracPosition){
int trackHeight = 0;
auto tracks = GetTracks();
auto GetHeight =
const auto GetHeight =
[&]( const Track *t ){ return tracks->GetGroupHeight(t); };
auto range = tracks->Leaders();
@@ -2223,9 +2230,8 @@ struct ChannelGroup final : TrackPanelGroup {
std::make_shared< VRulerAndChannel >(
channel->SharedPointer(), mLeftOffset ) );
if ( channel != pLast ) {
const auto substitute =
channel->SubstitutePendingChangedTrack();
yy += substitute->GetHeight();
auto &view = TrackView::Get( *channel );
yy += view.GetHeight();
refinement.emplace_back(
yy - kSeparatorThickness,
TrackView::Get( *channel ).GetResizer() );
@@ -2289,9 +2295,8 @@ struct Subgroup final : TrackPanelGroup {
for ( const auto leader : tracks.Leaders() ) {
wxCoord height = 0;
for ( auto channel : TrackList::Channels( leader ) ) {
auto substitute =
channel->SubstitutePendingChangedTrack();
height += substitute->GetHeight();
auto &view = TrackView::Get( *channel );
height += view.GetHeight();
}
refinement.emplace_back( yy,
std::make_shared< ResizingChannelGroup >(
@@ -2785,7 +2790,7 @@ unsigned DefaultTrackHeight( const TCPLines &topLines )
kTopMargin + kBottomMargin +
totalTCPLines( topLines, true ) +
totalTCPLines( commonTrackTCPBottomLines, false ) + 1;
return (unsigned) std::max( needed, (int) Track::DefaultHeight );
return (unsigned) std::max( needed, (int) TrackView::DefaultHeight );
}
}
@@ -2953,7 +2958,8 @@ bool IsVisibleTrack::operator () (const Track *pTrack) const
return
TrackList::Channels(pTrack).StartingWith(pTrack).any_of(
[this]( const Track *pT ) {
wxRect r(0, pT->GetY(), 1, pT->GetHeight());
auto &view = TrackView::Get( *pT );
wxRect r(0, view.GetY(), 1, view.GetHeight());
return r.Intersects(mPanelRect);
}
);