TrackVRulerControl is directly owned by TrackView not Track...
... in anticipation of making views to tracks many-to-one, but then the rulers should be one-to-one with the views. So go through the view to get the ruler. The ruler is really a left-hand extension for each view.
This commit is contained in:
parent
e90943cfe1
commit
18b4c01c51
|
@ -321,7 +321,6 @@ private:
|
|||
protected:
|
||||
std::shared_ptr<TrackView> DoGetView() override;
|
||||
std::shared_ptr<TrackControls> DoGetControls() override;
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
||||
friend class GetInfoCommand; // to get labels.
|
||||
friend class SetLabelCommand; // to set labels.
|
||||
|
|
|
@ -228,7 +228,6 @@ class AUDACITY_DLL_API NoteTrack final
|
|||
protected:
|
||||
std::shared_ptr<TrackView> DoGetView() override;
|
||||
std::shared_ptr<TrackControls> DoGetControls() override;
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
};
|
||||
|
||||
/// Data used to display a note track
|
||||
|
|
|
@ -125,7 +125,6 @@ class TimeTrack final : public Track {
|
|||
protected:
|
||||
std::shared_ptr<TrackView> DoGetView() override;
|
||||
std::shared_ptr<TrackControls> DoGetControls() override;
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ class LabelTrack;
|
|||
class TimeTrack;
|
||||
class TrackControls;
|
||||
class TrackView;
|
||||
class TrackVRulerControls;
|
||||
class TrackPanelResizerCell;
|
||||
class WaveTrack;
|
||||
class NoteTrack;
|
||||
|
@ -297,11 +296,7 @@ class AUDACITY_DLL_API Track /* not final */
|
|||
std::shared_ptr<const TrackPanelCell> GetTrackControls() const;
|
||||
|
||||
// Return another, associated TrackPanelCell object that implements the
|
||||
// mouse actions for the vertical ruler
|
||||
std::shared_ptr<TrackVRulerControls> GetVRulerControls();
|
||||
std::shared_ptr<const TrackVRulerControls> GetVRulerControls() const;
|
||||
|
||||
// Return another, associated TrackPanelCell object that implements the
|
||||
// click and drag to resize
|
||||
std::shared_ptr<TrackPanelCell> GetResizer();
|
||||
|
||||
|
@ -760,12 +755,10 @@ protected:
|
|||
// These are called to create controls on demand:
|
||||
virtual std::shared_ptr<TrackView> DoGetView() = 0;
|
||||
virtual std::shared_ptr<TrackControls> DoGetControls() = 0;
|
||||
virtual std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() = 0;
|
||||
|
||||
// These hold the controls:
|
||||
std::shared_ptr<TrackView> mpView;
|
||||
std::shared_ptr<TrackControls> mpControls;
|
||||
std::shared_ptr<TrackVRulerControls> mpVRulerContols;
|
||||
std::shared_ptr<TrackPanelResizerCell> mpResizer;
|
||||
|
||||
std::weak_ptr<SelectHandle> mSelectHandle;
|
||||
|
|
|
@ -101,7 +101,7 @@ is time to refresh some aspect of the screen.
|
|||
#include "toolbars/ControlToolBar.h"
|
||||
|
||||
#include "tracks/ui/TrackControls.h"
|
||||
#include "tracks/ui/TrackVRulerControls.h" // for inheritance relation
|
||||
#include "tracks/ui/TrackVRulerControls.h"
|
||||
|
||||
//This loads the appropriate set of cursors, depending on platform.
|
||||
#include "../images/Cursors.h"
|
||||
|
|
|
@ -701,7 +701,6 @@ private:
|
|||
protected:
|
||||
std::shared_ptr<TrackView> DoGetView() override;
|
||||
std::shared_ptr<TrackControls> DoGetControls() override;
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
};
|
||||
|
||||
// This is meant to be a short-lived object, during whose lifetime,
|
||||
|
|
|
@ -23,8 +23,8 @@ class LabelTrackVRulerControls final : public TrackVRulerControls
|
|||
|
||||
public:
|
||||
explicit
|
||||
LabelTrackVRulerControls( std::shared_ptr<Track> pTrack )
|
||||
: TrackVRulerControls( pTrack ) {}
|
||||
LabelTrackVRulerControls( const std::shared_ptr<TrackView> &pTrackView )
|
||||
: TrackVRulerControls( pTrackView ) {}
|
||||
~LabelTrackVRulerControls();
|
||||
};
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include "LabelTrackVRulerControls.h"
|
||||
#include "LabelGlyphHandle.h"
|
||||
#include "LabelTextHandle.h"
|
||||
#include "LabelTrackVRulerControls.h"
|
||||
|
||||
#include "../../../HitTestResult.h"
|
||||
#include "../../../TrackPanelMouseEvent.h"
|
||||
|
@ -54,7 +55,8 @@ std::shared_ptr<TrackControls> LabelTrack::DoGetControls()
|
|||
return std::make_shared<LabelTrackControls>( SharedPointer() );
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> LabelTrack::DoGetVRulerControls()
|
||||
std::shared_ptr<TrackVRulerControls> LabelTrackView::DoGetVRulerControls()
|
||||
{
|
||||
return std::make_shared<LabelTrackVRulerControls>( SharedPointer() );
|
||||
return
|
||||
std::make_shared<LabelTrackVRulerControls>( shared_from_this() );
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ public:
|
|||
LabelTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack } {}
|
||||
~LabelTrackView() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,8 +22,8 @@ class NoteTrackVRulerControls final : public TrackVRulerControls
|
|||
|
||||
public:
|
||||
explicit
|
||||
NoteTrackVRulerControls( std::shared_ptr<Track> pTrack )
|
||||
: TrackVRulerControls( pTrack ) {}
|
||||
NoteTrackVRulerControls( const std::shared_ptr<TrackView> &pTrackView )
|
||||
: TrackVRulerControls( pTrackView ) {}
|
||||
~NoteTrackVRulerControls();
|
||||
|
||||
std::vector<UIHandlePtr> HitTest
|
||||
|
|
|
@ -57,8 +57,10 @@ std::shared_ptr<TrackControls> NoteTrack::DoGetControls()
|
|||
return std::make_shared<NoteTrackControls>( SharedPointer() );
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> NoteTrack::DoGetVRulerControls()
|
||||
std::shared_ptr<TrackVRulerControls> NoteTrackView::DoGetVRulerControls()
|
||||
{
|
||||
return std::make_shared<NoteTrackVRulerControls>( SharedPointer() );
|
||||
return
|
||||
std::make_shared<NoteTrackVRulerControls>( shared_from_this() );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,6 +23,8 @@ public:
|
|||
NoteTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack } {}
|
||||
~NoteTrackView() override;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,8 +22,8 @@ class WaveTrackVRulerControls final : public TrackVRulerControls
|
|||
|
||||
public:
|
||||
explicit
|
||||
WaveTrackVRulerControls( std::shared_ptr<Track> pTrack )
|
||||
: TrackVRulerControls( pTrack ) {}
|
||||
WaveTrackVRulerControls( const std::shared_ptr<TrackView> &pTrackView )
|
||||
: TrackVRulerControls( pTrackView ) {}
|
||||
~WaveTrackVRulerControls();
|
||||
|
||||
std::vector<UIHandlePtr> HitTest
|
||||
|
|
|
@ -14,6 +14,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include "WaveTrackControls.h"
|
||||
#include "WaveTrackVRulerControls.h"
|
||||
|
||||
#include "WaveTrackVRulerControls.h"
|
||||
#include "../../../../HitTestResult.h"
|
||||
#include "../../../../TrackPanelMouseEvent.h"
|
||||
|
||||
|
@ -116,7 +117,8 @@ std::shared_ptr<TrackControls> WaveTrack::DoGetControls()
|
|||
return std::make_shared<WaveTrackControls>( SharedPointer() );
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> WaveTrack::DoGetVRulerControls()
|
||||
std::shared_ptr<TrackVRulerControls> WaveTrackView::DoGetVRulerControls()
|
||||
{
|
||||
return std::make_shared<WaveTrackVRulerControls>( SharedPointer() );
|
||||
return
|
||||
std::make_shared<WaveTrackVRulerControls>( shared_from_this() );
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ public:
|
|||
WaveTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack } {}
|
||||
~WaveTrackView() override;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,8 +22,8 @@ class TimeTrackVRulerControls final : public TrackVRulerControls
|
|||
|
||||
public:
|
||||
explicit
|
||||
TimeTrackVRulerControls( std::shared_ptr<Track> pTrack )
|
||||
: TrackVRulerControls( pTrack ) {}
|
||||
TimeTrackVRulerControls( const std::shared_ptr<TrackView> &pTrackView )
|
||||
: TrackVRulerControls( pTrackView ) {}
|
||||
~TimeTrackVRulerControls();
|
||||
};
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include "TimeTrackControls.h"
|
||||
#include "TimeTrackVRulerControls.h"
|
||||
|
||||
#include "TimeTrackVRulerControls.h"
|
||||
#include "../../../HitTestResult.h"
|
||||
#include "../../../TrackPanelMouseEvent.h"
|
||||
|
||||
|
@ -45,7 +46,8 @@ std::shared_ptr<TrackControls> TimeTrack::DoGetControls()
|
|||
return std::make_shared<TimeTrackControls>( SharedPointer() );
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> TimeTrack::DoGetVRulerControls()
|
||||
std::shared_ptr<TrackVRulerControls> TimeTrackView::DoGetVRulerControls()
|
||||
{
|
||||
return std::make_shared<TimeTrackVRulerControls>( SharedPointer() );
|
||||
return
|
||||
std::make_shared<TimeTrackVRulerControls>( shared_from_this() );
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ public:
|
|||
TimeTrackView( const std::shared_ptr<Track> &pTrack )
|
||||
: CommonTrackView{ pTrack } {}
|
||||
~TimeTrackView() override;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() override;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,6 +11,8 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include "../../Audacity.h"
|
||||
#include "TrackVRulerControls.h"
|
||||
|
||||
#include "TrackView.h"
|
||||
|
||||
#include "../../Track.h"
|
||||
#include "../../ViewInfo.h"
|
||||
|
||||
|
@ -18,8 +20,9 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include <wx/dc.h>
|
||||
#include <wx/translation.h>
|
||||
|
||||
TrackVRulerControls::TrackVRulerControls( std::shared_ptr<Track> pTrack )
|
||||
: mwTrack{ pTrack }
|
||||
TrackVRulerControls::TrackVRulerControls(
|
||||
const std::shared_ptr<TrackView> &pTrackView )
|
||||
: mwTrackView{ pTrackView }
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -29,17 +32,30 @@ TrackVRulerControls::~TrackVRulerControls()
|
|||
|
||||
TrackVRulerControls &TrackVRulerControls::Get( Track &track )
|
||||
{
|
||||
return *track.GetVRulerControls();
|
||||
return *TrackView::Get( track ).GetVRulerControls();
|
||||
}
|
||||
|
||||
const TrackVRulerControls &TrackVRulerControls::Get( const Track &track )
|
||||
{
|
||||
return *track.GetVRulerControls();
|
||||
return *TrackView::Get( track ).GetVRulerControls();
|
||||
}
|
||||
|
||||
TrackVRulerControls &TrackVRulerControls::Get( TrackView &trackView )
|
||||
{
|
||||
return *trackView.GetVRulerControls();
|
||||
}
|
||||
|
||||
const TrackVRulerControls &TrackVRulerControls::Get( const TrackView &trackView )
|
||||
{
|
||||
return *trackView.GetVRulerControls();
|
||||
}
|
||||
|
||||
std::shared_ptr<Track> TrackVRulerControls::DoFindTrack()
|
||||
{
|
||||
return mwTrack.lock();
|
||||
const auto pView = mwTrackView.lock();
|
||||
if ( pView )
|
||||
return pView->FindTrack();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<UIHandlePtr> TrackVRulerControls::HitTest
|
||||
|
|
|
@ -14,6 +14,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include "CommonTrackPanelCell.h"
|
||||
|
||||
class Track;
|
||||
class TrackView;
|
||||
class wxDC;
|
||||
|
||||
const int kGuard = 5; // 5 pixels to reduce risk of VZooming accidentally
|
||||
|
@ -23,13 +24,16 @@ class TrackVRulerControls /* not final */ : public CommonTrackPanelCell
|
|||
{
|
||||
public:
|
||||
explicit
|
||||
TrackVRulerControls( std::shared_ptr<Track> pTrack );
|
||||
TrackVRulerControls( const std::shared_ptr<TrackView> &pTrackView );
|
||||
|
||||
virtual ~TrackVRulerControls() = 0;
|
||||
|
||||
static TrackVRulerControls &Get( Track& );
|
||||
static const TrackVRulerControls &Get( const Track& );
|
||||
|
||||
static TrackVRulerControls &Get( TrackView& );
|
||||
static const TrackVRulerControls &Get( const TrackView& );
|
||||
|
||||
// Define a default hit test method, just for message and cursor
|
||||
std::vector<UIHandlePtr> HitTest
|
||||
(const TrackPanelMouseState &state,
|
||||
|
@ -44,7 +48,7 @@ protected:
|
|||
|
||||
Track *GetTrack() const;
|
||||
|
||||
std::weak_ptr<Track> mwTrack;
|
||||
std::weak_ptr<TrackView> mwTrackView;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -119,17 +119,17 @@ std::shared_ptr<const TrackPanelCell> Track::GetTrackControls() const
|
|||
return const_cast< Track* >( this )->GetTrackControls();
|
||||
}
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> Track::GetVRulerControls()
|
||||
std::shared_ptr<TrackVRulerControls> TrackView::GetVRulerControls()
|
||||
{
|
||||
if (!mpVRulerContols)
|
||||
if (!mpVRulerControls)
|
||||
// create on demand
|
||||
mpVRulerContols = DoGetVRulerControls();
|
||||
return mpVRulerContols;
|
||||
mpVRulerControls = DoGetVRulerControls();
|
||||
return mpVRulerControls;
|
||||
}
|
||||
|
||||
std::shared_ptr<const TrackVRulerControls> Track::GetVRulerControls() const
|
||||
std::shared_ptr<const TrackVRulerControls> TrackView::GetVRulerControls() const
|
||||
{
|
||||
return const_cast< Track* >( this )->GetVRulerControls();
|
||||
return const_cast< TrackView* >( this )->GetVRulerControls();
|
||||
}
|
||||
|
||||
#include "../../TrackPanelResizeHandle.h"
|
||||
|
|
|
@ -15,8 +15,10 @@ Paul Licameli split from class Track
|
|||
#include "CommonTrackPanelCell.h" // to inherit
|
||||
|
||||
class Track;
|
||||
class TrackVRulerControls;
|
||||
|
||||
class TrackView /* not final */ : public CommonTrackCell
|
||||
, public std::enable_shared_from_this<TrackView>
|
||||
{
|
||||
TrackView( const TrackView& ) = delete;
|
||||
TrackView &operator=( const TrackView& ) = delete;
|
||||
|
@ -29,6 +31,18 @@ public:
|
|||
|
||||
static TrackView &Get( Track & );
|
||||
static const TrackView &Get( const Track & );
|
||||
|
||||
// Return another, associated TrackPanelCell object that implements the
|
||||
// mouse actions for the vertical ruler
|
||||
std::shared_ptr<TrackVRulerControls> GetVRulerControls();
|
||||
std::shared_ptr<const TrackVRulerControls> GetVRulerControls() const;
|
||||
|
||||
protected:
|
||||
// Private factory to make appropriate object; class TrackView handles
|
||||
// memory management thereafter
|
||||
virtual std::shared_ptr<TrackVRulerControls> DoGetVRulerControls() = 0;
|
||||
|
||||
std::shared_ptr<TrackVRulerControls> mpVRulerControls;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue