mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 09:20:16 +01:00
TrackList emits more events for certain changes of state of tracks...
... Also rewrote some of the existing event handling so all events from TrackList are of the same, custom event class, and distinguishing addition from resizing events, though this distinction is not yet used
This commit is contained in:
@@ -91,9 +91,22 @@ void Track::Init(const Track &orig)
|
||||
mChannel = orig.mChannel;
|
||||
}
|
||||
|
||||
void Track::SetName( const wxString &n )
|
||||
{
|
||||
if ( mName != n ) {
|
||||
mName = n;
|
||||
Notify();
|
||||
}
|
||||
}
|
||||
|
||||
void Track::SetSelected(bool s)
|
||||
{
|
||||
mSelected = s;
|
||||
if (mSelected != s) {
|
||||
mSelected = s;
|
||||
auto pList = mList.lock();
|
||||
if (pList)
|
||||
pList->SelectionEvent( Pointer( this ) );
|
||||
}
|
||||
}
|
||||
|
||||
void Track::Merge(const Track &orig)
|
||||
@@ -328,6 +341,13 @@ bool Track::IsSyncLockSelected() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void Track::Notify( int code )
|
||||
{
|
||||
auto pList = mList.lock();
|
||||
if (pList)
|
||||
pList->DataEvent( Pointer(this), code );
|
||||
}
|
||||
|
||||
void Track::SyncLockAdjust(double oldT1, double newT1)
|
||||
{
|
||||
if (newT1 > oldT1) {
|
||||
@@ -367,6 +387,22 @@ void PlayableTrack::Merge( const Track &orig )
|
||||
AudioTrack::Merge( *pOrig );
|
||||
}
|
||||
|
||||
void PlayableTrack::SetMute( bool m )
|
||||
{
|
||||
if ( mMute != m ) {
|
||||
mMute = m;
|
||||
Notify();
|
||||
}
|
||||
}
|
||||
|
||||
void PlayableTrack::SetSolo( bool s )
|
||||
{
|
||||
if ( mSolo != s ) {
|
||||
mSolo = s;
|
||||
Notify();
|
||||
}
|
||||
}
|
||||
|
||||
// Serialize, not with tags of its own, but as attributes within a tag.
|
||||
void PlayableTrack::WriteXMLAttributes(XMLWriter &xmlFile) const
|
||||
{
|
||||
@@ -513,9 +549,12 @@ std::pair<Track *, Track *> TrackList::FindSyncLockGroup(Track *pMember) const
|
||||
// is managing. Any other classes that may be interested in get these updates
|
||||
// should use TrackList::Connect() or TrackList::Bind().
|
||||
//
|
||||
wxDEFINE_EVENT(EVT_TRACKLIST_PERMUTED, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_TRACKLIST_RESIZING, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_TRACKLIST_DELETION, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_TRACKLIST_TRACK_DATA_CHANGE, TrackListEvent);
|
||||
wxDEFINE_EVENT(EVT_TRACKLIST_SELECTION_CHANGE, TrackListEvent);
|
||||
wxDEFINE_EVENT(EVT_TRACKLIST_PERMUTED, TrackListEvent);
|
||||
wxDEFINE_EVENT(EVT_TRACKLIST_RESIZING, TrackListEvent);
|
||||
wxDEFINE_EVENT(EVT_TRACKLIST_ADDITION, TrackListEvent);
|
||||
wxDEFINE_EVENT(EVT_TRACKLIST_DELETION, TrackListEvent);
|
||||
|
||||
// same value as in the default constructed TrackId:
|
||||
long TrackList::sCounter = -1;
|
||||
@@ -592,26 +631,42 @@ void TrackList::RecalcPositions(TrackNodePointer node)
|
||||
UpdatePendingTracks();
|
||||
}
|
||||
|
||||
void TrackList::SelectionEvent( const std::shared_ptr<Track> &pTrack )
|
||||
{
|
||||
// wxWidgets will own the event object
|
||||
QueueEvent(
|
||||
safenew TrackListEvent{ EVT_TRACKLIST_SELECTION_CHANGE, pTrack } );
|
||||
}
|
||||
|
||||
void TrackList::DataEvent( const std::shared_ptr<Track> &pTrack, int code )
|
||||
{
|
||||
// wxWidgets will own the event object
|
||||
QueueEvent(
|
||||
safenew TrackListEvent{ EVT_TRACKLIST_TRACK_DATA_CHANGE, pTrack, code } );
|
||||
}
|
||||
|
||||
void TrackList::PermutationEvent()
|
||||
{
|
||||
auto e = std::make_unique<wxCommandEvent>(EVT_TRACKLIST_PERMUTED);
|
||||
// wxWidgets will own the event object
|
||||
QueueEvent(e.release());
|
||||
QueueEvent( safenew TrackListEvent{ EVT_TRACKLIST_PERMUTED } );
|
||||
}
|
||||
|
||||
void TrackList::DeletionEvent()
|
||||
{
|
||||
auto e = std::make_unique<wxCommandEvent>(EVT_TRACKLIST_DELETION);
|
||||
// wxWidgets will own the event object
|
||||
QueueEvent(e.release());
|
||||
QueueEvent( safenew TrackListEvent{ EVT_TRACKLIST_DELETION } );
|
||||
}
|
||||
|
||||
void TrackList::AdditionEvent(TrackNodePointer node)
|
||||
{
|
||||
// wxWidgets will own the event object
|
||||
QueueEvent( safenew TrackListEvent{ EVT_TRACKLIST_ADDITION, *node.first } );
|
||||
}
|
||||
|
||||
void TrackList::ResizingEvent(TrackNodePointer node)
|
||||
{
|
||||
auto e = std::make_unique<TrackListEvent>(EVT_TRACKLIST_RESIZING);
|
||||
e->mpTrack = *node.first;
|
||||
// wxWidgets will own the event object
|
||||
QueueEvent(e.release());
|
||||
QueueEvent( safenew TrackListEvent{ EVT_TRACKLIST_RESIZING, *node.first } );
|
||||
}
|
||||
|
||||
auto TrackList::EmptyRange() const
|
||||
@@ -678,7 +733,7 @@ Track *TrackList::Add(std::unique_ptr<TrackKind> &&t)
|
||||
pTrack->SetOwner(mSelf, n);
|
||||
pTrack->SetId( TrackId{ ++sCounter } );
|
||||
RecalcPositions(n);
|
||||
ResizingEvent(n);
|
||||
AdditionEvent(n);
|
||||
return back().get();
|
||||
}
|
||||
|
||||
@@ -700,7 +755,7 @@ Track *TrackList::AddToHead(std::unique_ptr<TrackKind> &&t)
|
||||
pTrack->SetOwner(mSelf, n);
|
||||
pTrack->SetId( TrackId{ ++sCounter } );
|
||||
RecalcPositions(n);
|
||||
ResizingEvent(n);
|
||||
AdditionEvent(n);
|
||||
return front().get();
|
||||
}
|
||||
|
||||
@@ -717,7 +772,7 @@ Track *TrackList::Add(std::shared_ptr<TrackKind> &&t)
|
||||
t->SetOwner(mSelf, n);
|
||||
t->SetId( TrackId{ ++sCounter } );
|
||||
RecalcPositions(n);
|
||||
ResizingEvent(n);
|
||||
AdditionEvent(n);
|
||||
return back().get();
|
||||
}
|
||||
|
||||
@@ -794,7 +849,7 @@ auto TrackList::Replace(Track * t, ListOfTracks::value_type &&with) ->
|
||||
RecalcPositions(node);
|
||||
|
||||
DeletionEvent();
|
||||
ResizingEvent(node);
|
||||
AdditionEvent(node);
|
||||
}
|
||||
return holder;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user