mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-11 09:31:13 +02:00
Don't define any Track members outside of Track.cpp
This commit is contained in:
parent
dc9e436dde
commit
9e731390f6
@ -138,6 +138,26 @@ void Track::SetOwner
|
||||
mNode = node;
|
||||
}
|
||||
|
||||
const std::shared_ptr<CommonTrackCell> &Track::GetTrackView()
|
||||
{
|
||||
return mpView;
|
||||
}
|
||||
|
||||
void Track::SetTrackView( const std::shared_ptr<CommonTrackCell> &pView )
|
||||
{
|
||||
mpView = pView;
|
||||
}
|
||||
|
||||
const std::shared_ptr<CommonTrackCell> &Track::GetTrackControls()
|
||||
{
|
||||
return mpControls;
|
||||
}
|
||||
|
||||
void Track::SetTrackControls( const std::shared_ptr<CommonTrackCell> &pControls )
|
||||
{
|
||||
mpControls = pControls;
|
||||
}
|
||||
|
||||
int Track::GetIndex() const
|
||||
{
|
||||
return mIndex;
|
||||
@ -1270,13 +1290,3 @@ void TrackFactory::Destroy( AudacityProject &project )
|
||||
{
|
||||
project.AttachedObjects::Assign( key2, nullptr );
|
||||
}
|
||||
|
||||
template<> auto DoGetControls::Implementation() -> Function {
|
||||
return nullptr;
|
||||
}
|
||||
static DoGetControls registerDoGetControls;
|
||||
|
||||
template<> auto DoGetView::Implementation() -> Function {
|
||||
return nullptr;
|
||||
}
|
||||
static DoGetView registerDoGetView;
|
||||
|
36
src/Track.h
36
src/Track.h
@ -261,15 +261,15 @@ class AUDACITY_DLL_API Track /* not final */
|
||||
public:
|
||||
mutable wxSize vrulerSize;
|
||||
|
||||
// Return another, associated TrackPanelCell object that implements
|
||||
// click and drag and keystrokes in the track contents.
|
||||
std::shared_ptr<CommonTrackCell> GetTrackView();
|
||||
std::shared_ptr<const CommonTrackCell> GetTrackView() const;
|
||||
// These are exposed only for the purposes of the TrackView class, to
|
||||
// initialize the pointer on demand
|
||||
const std::shared_ptr<CommonTrackCell> &GetTrackView();
|
||||
void SetTrackView( const std::shared_ptr<CommonTrackCell> &pView );
|
||||
|
||||
// Return another, associated TrackPanelCell object that implements the
|
||||
// drop-down, close and minimize buttons, etc.
|
||||
std::shared_ptr<TrackPanelCell> GetTrackControls();
|
||||
std::shared_ptr<const TrackPanelCell> GetTrackControls() const;
|
||||
// These are exposed only for the purposes of the TrackControls class, to
|
||||
// initialize the pointer on demand
|
||||
const std::shared_ptr<CommonTrackCell> &GetTrackControls();
|
||||
void SetTrackControls( const std::shared_ptr<CommonTrackCell> &pControls );
|
||||
|
||||
// Return another, associated TrackPanelCell object that implements the
|
||||
|
||||
@ -1588,24 +1588,4 @@ class AUDACITY_DLL_API TrackFactory final
|
||||
#endif
|
||||
};
|
||||
|
||||
#include "AttachedVirtualFunction.h"
|
||||
|
||||
struct DoGetControlsTag;
|
||||
|
||||
using DoGetControls =
|
||||
AttachedVirtualFunction<
|
||||
DoGetControlsTag,
|
||||
std::shared_ptr< TrackControls >,
|
||||
Track
|
||||
>;
|
||||
|
||||
struct DoGetViewTag;
|
||||
|
||||
using DoGetView =
|
||||
AttachedVirtualFunction<
|
||||
DoGetViewTag,
|
||||
std::shared_ptr< TrackView >,
|
||||
Track
|
||||
>;
|
||||
|
||||
#endif
|
||||
|
@ -24,11 +24,20 @@ TrackControls::~TrackControls()
|
||||
|
||||
TrackControls &TrackControls::Get( Track &track )
|
||||
{
|
||||
return *static_cast<TrackControls*>( track.GetTrackControls().get() );
|
||||
auto pControls =
|
||||
std::static_pointer_cast<TrackControls>( track.GetTrackControls() );
|
||||
if (!pControls)
|
||||
// create on demand
|
||||
track.SetTrackControls( pControls = DoGetControls::Call( track ) );
|
||||
return *pControls;
|
||||
}
|
||||
|
||||
const TrackControls &TrackControls::Get( const Track &track )
|
||||
{
|
||||
return *static_cast<const TrackControls*>( track.GetTrackControls().get() );
|
||||
return Get( const_cast< Track& >( track ) );
|
||||
}
|
||||
|
||||
template<> auto DoGetControls::Implementation() -> Function {
|
||||
return nullptr;
|
||||
}
|
||||
static DoGetControls registerDoGetControls;
|
||||
|
@ -28,4 +28,15 @@ public:
|
||||
virtual ~TrackControls() = 0;
|
||||
};
|
||||
|
||||
#include "AttachedVirtualFunction.h"
|
||||
|
||||
struct DoGetControlsTag;
|
||||
|
||||
using DoGetControls =
|
||||
AttachedVirtualFunction<
|
||||
DoGetControlsTag,
|
||||
std::shared_ptr< TrackControls >,
|
||||
Track
|
||||
>;
|
||||
|
||||
#endif
|
||||
|
@ -59,12 +59,16 @@ void TrackView::CopyTo( Track &track ) const
|
||||
|
||||
TrackView &TrackView::Get( Track &track )
|
||||
{
|
||||
return static_cast<TrackView&>( *track.GetTrackView() );
|
||||
auto pView = std::static_pointer_cast<TrackView>( track.GetTrackView() );
|
||||
if (!pView)
|
||||
// create on demand
|
||||
track.SetTrackView( pView = DoGetView::Call( track ) );
|
||||
return *pView;
|
||||
}
|
||||
|
||||
const TrackView &TrackView::Get( const Track &track )
|
||||
{
|
||||
return static_cast<const TrackView&>( *track.GetTrackView() );
|
||||
return Get( const_cast< Track& >( track ) );
|
||||
}
|
||||
|
||||
void TrackView::SetMinimized(bool isMinimized)
|
||||
@ -107,32 +111,6 @@ void TrackView::DoSetMinimized(bool isMinimized)
|
||||
mMinimized = isMinimized;
|
||||
}
|
||||
|
||||
std::shared_ptr<CommonTrackCell> Track::GetTrackView()
|
||||
{
|
||||
if (!mpView)
|
||||
// create on demand
|
||||
mpView = DoGetView::Call( *this );
|
||||
return mpView;
|
||||
}
|
||||
|
||||
std::shared_ptr<const CommonTrackCell> Track::GetTrackView() const
|
||||
{
|
||||
return const_cast<Track*>(this)->GetTrackView();
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackPanelCell> Track::GetTrackControls()
|
||||
{
|
||||
if (!mpControls)
|
||||
// create on demand
|
||||
mpControls = DoGetControls::Call( *this );
|
||||
return mpControls;
|
||||
}
|
||||
|
||||
std::shared_ptr<const TrackPanelCell> Track::GetTrackControls() const
|
||||
{
|
||||
return const_cast< Track* >( this )->GetTrackControls();
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> TrackView::GetVRulerControls()
|
||||
{
|
||||
if (!mpVRulerControls)
|
||||
@ -233,3 +211,8 @@ static const AudacityProject::AttachedObjects::RegisteredFactory key{
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<> auto DoGetView::Implementation() -> Function {
|
||||
return nullptr;
|
||||
}
|
||||
static DoGetView registerDoGetView;
|
||||
|
@ -93,4 +93,15 @@ private:
|
||||
int mHeight{ DefaultHeight };
|
||||
};
|
||||
|
||||
#include "AttachedVirtualFunction.h"
|
||||
|
||||
struct DoGetViewTag;
|
||||
|
||||
using DoGetView =
|
||||
AttachedVirtualFunction<
|
||||
DoGetViewTag,
|
||||
std::shared_ptr< TrackView >,
|
||||
Track
|
||||
>;
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user