1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-22 22:43:01 +02:00

Demote Copy to CommonTrackCell; Track points only to that base class

This commit is contained in:
Paul Licameli
2019-06-22 10:43:55 -04:00
parent 3f1fd8ced0
commit 8793d6b475
7 changed files with 23 additions and 11 deletions

View File

@@ -263,8 +263,8 @@ class AUDACITY_DLL_API Track /* not final */
// Return another, associated TrackPanelCell object that implements // Return another, associated TrackPanelCell object that implements
// click and drag and keystrokes in the track contents. // click and drag and keystrokes in the track contents.
std::shared_ptr<TrackView> GetTrackView(); std::shared_ptr<CommonTrackCell> GetTrackView();
std::shared_ptr<const TrackView> GetTrackView() const; std::shared_ptr<const CommonTrackCell> GetTrackView() const;
// Return another, associated TrackPanelCell object that implements the // Return another, associated TrackPanelCell object that implements the
// drop-down, close and minimize buttons, etc. // drop-down, close and minimize buttons, etc.
@@ -704,7 +704,7 @@ public:
bool HandleCommonXMLAttribute(const wxChar *attr, const wxChar *value); bool HandleCommonXMLAttribute(const wxChar *attr, const wxChar *value);
protected: protected:
std::shared_ptr<TrackView> mpView; std::shared_ptr<CommonTrackCell> mpView;
std::shared_ptr<CommonTrackCell> mpControls; std::shared_ptr<CommonTrackCell> mpControls;
}; };

View File

@@ -97,7 +97,7 @@ void LabelTrackView::UnbindFrom( LabelTrack *pParent )
EVT_LABELTRACK_PERMUTED, &LabelTrackView::OnLabelPermuted, this ); EVT_LABELTRACK_PERMUTED, &LabelTrackView::OnLabelPermuted, this );
} }
void LabelTrackView::Copy( const TrackView &other ) void LabelTrackView::Copy( const CommonTrackCell &other )
{ {
TrackView::Copy( other ); TrackView::Copy( other );

View File

@@ -82,7 +82,7 @@ private:
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override; std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
// Preserve some view state too for undo/redo purposes // Preserve some view state too for undo/redo purposes
void Copy( const TrackView &other ) override; void Copy( const CommonTrackCell &other ) override;
public: public:
static void DoEditLabels( static void DoEditLabels(

View File

@@ -57,6 +57,10 @@ CommonTrackCell::CommonTrackCell( const std::shared_ptr< Track > &parent )
CommonTrackCell::~CommonTrackCell() = default; CommonTrackCell::~CommonTrackCell() = default;
void CommonTrackCell::Copy( const CommonTrackCell & )
{
}
void CommonTrackCell::Reparent( const std::shared_ptr<Track> &parent ) void CommonTrackCell::Reparent( const std::shared_ptr<Track> &parent )
{ {
mwTrack = parent; mwTrack = parent;

View File

@@ -62,6 +62,9 @@ public:
~CommonTrackCell(); ~CommonTrackCell();
// Copy state, for undo/redo purposes
virtual void Copy( const CommonTrackCell &other );
std::shared_ptr<Track> DoFindTrack() override; std::shared_ptr<Track> DoFindTrack() override;
virtual void Reparent( const std::shared_ptr<Track> &parent ); virtual void Reparent( const std::shared_ptr<Track> &parent );

View File

@@ -46,8 +46,13 @@ int TrackView::GetTotalHeight( const TrackList &list )
return GetCumulativeHeight( *list.Any().rbegin() ); return GetCumulativeHeight( *list.Any().rbegin() );
} }
void TrackView::Copy( const TrackView &other ) void TrackView::Copy( const CommonTrackCell &otherCell )
{ {
auto pOther = dynamic_cast< const TrackView* >( &otherCell );
if ( !pOther )
return;
auto &other = *pOther;
mMinimized = other.mMinimized; mMinimized = other.mMinimized;
// Let mY remain 0 -- TrackPositioner corrects it later // Let mY remain 0 -- TrackPositioner corrects it later
@@ -57,12 +62,12 @@ void TrackView::Copy( const TrackView &other )
TrackView &TrackView::Get( Track &track ) TrackView &TrackView::Get( Track &track )
{ {
return *track.GetTrackView(); return static_cast<TrackView&>( *track.GetTrackView() );
} }
const TrackView &TrackView::Get( const Track &track ) const TrackView &TrackView::Get( const Track &track )
{ {
return *track.GetTrackView(); return static_cast<const TrackView&>( *track.GetTrackView() );
} }
void TrackView::SetMinimized(bool isMinimized) void TrackView::SetMinimized(bool isMinimized)
@@ -105,7 +110,7 @@ void TrackView::DoSetMinimized(bool isMinimized)
mMinimized = isMinimized; mMinimized = isMinimized;
} }
std::shared_ptr<TrackView> Track::GetTrackView() std::shared_ptr<CommonTrackCell> Track::GetTrackView()
{ {
if (!mpView) if (!mpView)
// create on demand // create on demand
@@ -113,7 +118,7 @@ std::shared_ptr<TrackView> Track::GetTrackView()
return mpView; return mpView;
} }
std::shared_ptr<const TrackView> Track::GetTrackView() const std::shared_ptr<const CommonTrackCell> Track::GetTrackView() const
{ {
return const_cast<Track*>(this)->GetTrackView(); return const_cast<Track*>(this)->GetTrackView();
} }

View File

@@ -42,7 +42,7 @@ public:
static int GetTotalHeight( const TrackList &list ); static int GetTotalHeight( const TrackList &list );
// Copy view state, for undo/redo purposes // Copy view state, for undo/redo purposes
virtual void Copy( const TrackView &other ); void Copy( const CommonTrackCell &other ) override;
static TrackView &Get( Track & ); static TrackView &Get( Track & );
static const TrackView &Get( const Track & ); static const TrackView &Get( const Track & );