mirror of
https://github.com/cookiengineer/audacity
synced 2026-04-23 06:23:49 +02:00
Change the track view copy function...
... It is const, renamed CopyTo, and invokes the create-on-demand factory in the destination track; this means Track.cpp doesn't need to do that, and so does not need TrackView.h
This commit is contained in:
@@ -41,8 +41,6 @@ and TimeTrack.
|
||||
|
||||
#include "InconsistencyException.h"
|
||||
|
||||
#include "tracks/ui/TrackView.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
//Disable truncation warnings
|
||||
#pragma warning( disable : 4786 )
|
||||
@@ -115,7 +113,7 @@ Track::Holder Track::Duplicate() const
|
||||
|
||||
if (mpView)
|
||||
// Copy view state that might be important to undo/redo
|
||||
TrackView::Get( *result ).Copy( *mpView );
|
||||
mpView->CopyTo( *result );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -97,13 +97,14 @@ void LabelTrackView::UnbindFrom( LabelTrack *pParent )
|
||||
EVT_LABELTRACK_PERMUTED, &LabelTrackView::OnLabelPermuted, this );
|
||||
}
|
||||
|
||||
void LabelTrackView::Copy( const CommonTrackCell &other )
|
||||
void LabelTrackView::CopyTo( Track &track ) const
|
||||
{
|
||||
TrackView::Copy( other );
|
||||
TrackView::CopyTo( track );
|
||||
auto &other = TrackView::Get( track );
|
||||
|
||||
if ( const auto pOther = dynamic_cast< const LabelTrackView* >( &other ) ) {
|
||||
// only one field is important to preserve in undo/redo history
|
||||
mSelIndex = pOther->mSelIndex;
|
||||
pOther->mSelIndex = mSelIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
||||
// Preserve some view state too for undo/redo purposes
|
||||
void Copy( const CommonTrackCell &other ) override;
|
||||
void CopyTo( Track &track ) const override;
|
||||
|
||||
public:
|
||||
static void DoEditLabels(
|
||||
|
||||
@@ -57,7 +57,7 @@ CommonTrackCell::CommonTrackCell( const std::shared_ptr< Track > &parent )
|
||||
|
||||
CommonTrackCell::~CommonTrackCell() = default;
|
||||
|
||||
void CommonTrackCell::Copy( const CommonTrackCell & )
|
||||
void CommonTrackCell::CopyTo( Track& ) const
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ public:
|
||||
~CommonTrackCell();
|
||||
|
||||
// Copy state, for undo/redo purposes
|
||||
virtual void Copy( const CommonTrackCell &other );
|
||||
// The default does nothing
|
||||
virtual void CopyTo( Track &track ) const;
|
||||
|
||||
std::shared_ptr<Track> DoFindTrack() override;
|
||||
|
||||
|
||||
@@ -46,18 +46,15 @@ int TrackView::GetTotalHeight( const TrackList &list )
|
||||
return GetCumulativeHeight( *list.Any().rbegin() );
|
||||
}
|
||||
|
||||
void TrackView::Copy( const CommonTrackCell &otherCell )
|
||||
void TrackView::CopyTo( Track &track ) const
|
||||
{
|
||||
auto pOther = dynamic_cast< const TrackView* >( &otherCell );
|
||||
if ( !pOther )
|
||||
return;
|
||||
auto &other = *pOther;
|
||||
auto &other = Get( track );
|
||||
|
||||
mMinimized = other.mMinimized;
|
||||
other.mMinimized = mMinimized;
|
||||
|
||||
// Let mY remain 0 -- TrackPositioner corrects it later
|
||||
mY = 0;
|
||||
mHeight = other.mHeight;
|
||||
other.mY = 0;
|
||||
other.mHeight = mHeight;
|
||||
}
|
||||
|
||||
TrackView &TrackView::Get( Track &track )
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
static int GetTotalHeight( const TrackList &list );
|
||||
|
||||
// Copy view state, for undo/redo purposes
|
||||
void Copy( const CommonTrackCell &other ) override;
|
||||
void CopyTo( Track &track ) const override;
|
||||
|
||||
static TrackView &Get( Track & );
|
||||
static const TrackView &Get( const Track & );
|
||||
|
||||
Reference in New Issue
Block a user