mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-20 14:20:06 +02:00
Remove VisibleTrackIterator
This commit is contained in:
parent
ae2ce1ad90
commit
b94e8fec96
@ -607,29 +607,6 @@ bool SelectedTrackListOfKindIterator::Condition(Track *t)
|
|||||||
return TrackListOfKindIterator::Condition(t) && t->GetSelected();
|
return TrackListOfKindIterator::Condition(t) && t->GetSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
// VisibleTrackIterator
|
|
||||||
//
|
|
||||||
// Based on TrackListIterator returns only the currently visible tracks.
|
|
||||||
//
|
|
||||||
VisibleTrackIterator::VisibleTrackIterator(AudacityProject *project)
|
|
||||||
: TrackListCondIterator(project->GetTracks())
|
|
||||||
{
|
|
||||||
mProject = project;
|
|
||||||
mPanelRect.SetTop(mProject->mViewInfo.vpos);
|
|
||||||
mPanelRect.SetSize(mProject->GetTPTracksUsableArea());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VisibleTrackIterator::Condition(Track *t)
|
|
||||||
{
|
|
||||||
wxRect r(0, t->GetY(), 1, t->GetHeight());
|
|
||||||
if( r.Intersects(mPanelRect) )
|
|
||||||
return true;
|
|
||||||
auto partner = t->GetLink();
|
|
||||||
if ( partner && t->GetLinked() )
|
|
||||||
return Condition( partner );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SyncLockedTracksIterator
|
// SyncLockedTracksIterator
|
||||||
//
|
//
|
||||||
// Based on TrackListIterator returns only tracks belonging to the group
|
// Based on TrackListIterator returns only tracks belonging to the group
|
||||||
|
20
src/Track.h
20
src/Track.h
@ -1224,26 +1224,6 @@ class AUDACITY_DLL_API SelectedTrackListOfKindIterator final : public TrackListO
|
|||||||
bool Condition(Track *t) override;
|
bool Condition(Track *t) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
|
||||||
// VisibleTrackIterator
|
|
||||||
//
|
|
||||||
// Based on TrackListIterator returns only the currently visible tracks.
|
|
||||||
//
|
|
||||||
class AUDACITY_DLL_API VisibleTrackIterator final : public TrackListCondIterator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VisibleTrackIterator(AudacityProject *project);
|
|
||||||
virtual ~VisibleTrackIterator() {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool Condition(Track *t) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
AudacityProject *mProject;
|
|
||||||
wxRect mPanelRect;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// SyncLockedTracksIterator returns only tracks belonging to the sync-locked tracks
|
// SyncLockedTracksIterator returns only tracks belonging to the sync-locked tracks
|
||||||
// in which the starting track is a member.
|
// in which the starting track is a member.
|
||||||
class AUDACITY_DLL_API SyncLockedTracksIterator final : public TrackListIterator
|
class AUDACITY_DLL_API SyncLockedTracksIterator final : public TrackListIterator
|
||||||
|
@ -1200,8 +1200,8 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
|
|||||||
wxRect trackRect = clip;
|
wxRect trackRect = clip;
|
||||||
trackRect.height = 0; // for drawing background in no tracks case.
|
trackRect.height = 0; // for drawing background in no tracks case.
|
||||||
|
|
||||||
VisibleTrackIterator iter(GetProject());
|
for ( auto t :
|
||||||
for (const Track *t = iter.First(); t; t = iter.Next()) {
|
GetTracks()->Any< const Track >() + IsVisibleTrack{ GetProject() } ) {
|
||||||
t = t->SubstitutePendingChangedTrack().get();
|
t = t->SubstitutePendingChangedTrack().get();
|
||||||
trackRect.y = t->GetY() - mViewInfo->vpos;
|
trackRect.y = t->GetY() - mViewInfo->vpos;
|
||||||
trackRect.height = t->GetHeight();
|
trackRect.height = t->GetHeight();
|
||||||
@ -1220,8 +1220,8 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the previous track is linked to this one but isn't on the screen
|
// If the previous track is linked to this one but isn't on the screen
|
||||||
// (and thus would have been skipped by VisibleTrackIterator) we need to
|
// (and thus would have been skipped) we need to draw that track's border
|
||||||
// draw that track's border instead.
|
// instead.
|
||||||
const Track *borderTrack = t;
|
const Track *borderTrack = t;
|
||||||
wxRect borderRect = rect;
|
wxRect borderRect = rect;
|
||||||
|
|
||||||
@ -2686,10 +2686,13 @@ IteratorRange< TrackPanelCellIterator > TrackPanel::Cells()
|
|||||||
|
|
||||||
TrackPanelCellIterator::TrackPanelCellIterator(TrackPanel *trackPanel, bool begin)
|
TrackPanelCellIterator::TrackPanelCellIterator(TrackPanel *trackPanel, bool begin)
|
||||||
: mPanel{ trackPanel }
|
: mPanel{ trackPanel }
|
||||||
, mIter{ trackPanel->GetProject() }
|
, mIter{
|
||||||
|
trackPanel->GetTracks()->Any().begin()
|
||||||
|
.Filter( IsVisibleTrack( trackPanel->GetProject() ) )
|
||||||
|
}
|
||||||
{
|
{
|
||||||
if (begin) {
|
if (begin) {
|
||||||
mpTrack = Track::Pointer( mIter.First() );
|
mpTrack = Track::Pointer( *mIter );
|
||||||
if (mpTrack)
|
if (mpTrack)
|
||||||
mpCell = mpTrack;
|
mpCell = mpTrack;
|
||||||
else
|
else
|
||||||
@ -2707,7 +2710,7 @@ TrackPanelCellIterator &TrackPanelCellIterator::operator++ ()
|
|||||||
{
|
{
|
||||||
if ( mpTrack ) {
|
if ( mpTrack ) {
|
||||||
if ( ++ mType == CellType::Background )
|
if ( ++ mType == CellType::Background )
|
||||||
mType = CellType::Track, mpTrack = Track::Pointer( mIter.Next() );
|
mType = CellType::Track, mpTrack = Track::Pointer( * ++ mIter );
|
||||||
}
|
}
|
||||||
if ( mpTrack ) {
|
if ( mpTrack ) {
|
||||||
if ( mType == CellType::Label &&
|
if ( mType == CellType::Label &&
|
||||||
@ -2909,3 +2912,23 @@ unsigned TrackPanelCell::Char(wxKeyEvent &event, ViewInfo &, wxWindow *)
|
|||||||
event.Skip();
|
event.Skip();
|
||||||
return RefreshCode::RefreshNone;
|
return RefreshCode::RefreshNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IsVisibleTrack::IsVisibleTrack(AudacityProject *project)
|
||||||
|
: mPanelRect {
|
||||||
|
wxPoint{ 0, project->mViewInfo.vpos },
|
||||||
|
project->GetTPTracksUsableArea()
|
||||||
|
}
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool IsVisibleTrack::operator () (const Track *pTrack) const
|
||||||
|
{
|
||||||
|
// Need to return true if this track or a later channel intersects
|
||||||
|
// the view
|
||||||
|
return
|
||||||
|
TrackList::Channels(pTrack).StartingWith(pTrack).any_of(
|
||||||
|
[this]( const Track *pT ) {
|
||||||
|
wxRect r(0, pT->GetY(), 1, pT->GetHeight());
|
||||||
|
return r.Intersects(mPanelRect);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@ -489,6 +489,16 @@ protected:
|
|||||||
friend class GetInfoCommand;
|
friend class GetInfoCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// A predicate class
|
||||||
|
struct IsVisibleTrack
|
||||||
|
{
|
||||||
|
IsVisibleTrack(AudacityProject *project);
|
||||||
|
|
||||||
|
bool operator () (const Track *pTrack) const;
|
||||||
|
|
||||||
|
wxRect mPanelRect;
|
||||||
|
};
|
||||||
|
|
||||||
// See big pictorial comment in TrackPanel for explanation of these numbers
|
// See big pictorial comment in TrackPanel for explanation of these numbers
|
||||||
enum : int {
|
enum : int {
|
||||||
kLeftInset = 4,
|
kLeftInset = 4,
|
||||||
|
@ -53,7 +53,7 @@ private:
|
|||||||
void UpdateRect();
|
void UpdateRect();
|
||||||
|
|
||||||
TrackPanel *mPanel;
|
TrackPanel *mPanel;
|
||||||
VisibleTrackIterator mIter;
|
TrackIter<Track> mIter;
|
||||||
std::shared_ptr<Track> mpTrack;
|
std::shared_ptr<Track> mpTrack;
|
||||||
std::shared_ptr<TrackPanelCell> mpCell;
|
std::shared_ptr<TrackPanelCell> mpCell;
|
||||||
CellType mType{ CellType::Track };
|
CellType mType{ CellType::Track };
|
||||||
|
@ -484,8 +484,7 @@ void GetInfoCommand::ExploreTrackPanel( const CommandContext &context,
|
|||||||
|
|
||||||
wxRect trackRect = pWin->GetRect();
|
wxRect trackRect = pWin->GetRect();
|
||||||
|
|
||||||
VisibleTrackIterator iter(pProj);
|
for (auto t : pProj->GetTracks()->Any() + IsVisibleTrack{ pProj }) {
|
||||||
for (Track *t = iter.First(); t; t = iter.Next()) {
|
|
||||||
trackRect.y = t->GetY() - pTP->mViewInfo->vpos;
|
trackRect.y = t->GetY() - pTP->mViewInfo->vpos;
|
||||||
trackRect.height = t->GetHeight();
|
trackRect.height = t->GetHeight();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user