mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-22 14:32:58 +02:00
Define and use CommonTrackCell
This commit is contained in:
@@ -17,8 +17,9 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
|
|
||||||
#include <wx/mousestate.h>
|
#include <wx/mousestate.h>
|
||||||
|
|
||||||
TrackPanelResizerCell::TrackPanelResizerCell( std::shared_ptr<Track> pTrack )
|
TrackPanelResizerCell::TrackPanelResizerCell(
|
||||||
: mpTrack{ pTrack }
|
const std::shared_ptr<Track> &pTrack )
|
||||||
|
: CommonTrackCell{ pTrack }
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::vector<UIHandlePtr> TrackPanelResizerCell::HitTest
|
std::vector<UIHandlePtr> TrackPanelResizerCell::HitTest
|
||||||
|
@@ -15,14 +15,14 @@
|
|||||||
|
|
||||||
class TrackPanelResizeHandle;
|
class TrackPanelResizeHandle;
|
||||||
|
|
||||||
class TrackPanelResizerCell : public CommonTrackPanelCell
|
class TrackPanelResizerCell : public CommonTrackCell
|
||||||
{
|
{
|
||||||
TrackPanelResizerCell(const TrackPanelResizerCell&) = delete;
|
TrackPanelResizerCell(const TrackPanelResizerCell&) = delete;
|
||||||
TrackPanelResizerCell &operator= (const TrackPanelResizerCell&) = delete;
|
TrackPanelResizerCell &operator= (const TrackPanelResizerCell&) = delete;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
TrackPanelResizerCell( std::shared_ptr<Track> pTrack );
|
TrackPanelResizerCell( const std::shared_ptr<Track> &pTrack );
|
||||||
|
|
||||||
std::vector<UIHandlePtr> HitTest
|
std::vector<UIHandlePtr> HitTest
|
||||||
(const TrackPanelMouseState &, const AudacityProject *) override;
|
(const TrackPanelMouseState &, const AudacityProject *) override;
|
||||||
|
@@ -50,3 +50,19 @@ unsigned CommonTrackPanelCell::HandleWheelRotation
|
|||||||
auto hook = GetHook();
|
auto hook = GetHook();
|
||||||
return hook ? hook( evt, pProject ) : RefreshCode::Cancelled;
|
return hook ? hook( evt, pProject ) : RefreshCode::Cancelled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommonTrackCell::CommonTrackCell( const std::shared_ptr< Track > &parent )
|
||||||
|
: mwTrack { parent }
|
||||||
|
{}
|
||||||
|
|
||||||
|
CommonTrackCell::~CommonTrackCell() = default;
|
||||||
|
|
||||||
|
void CommonTrackCell::Reparent( const std::shared_ptr<Track> &parent )
|
||||||
|
{
|
||||||
|
mwTrack = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Track> CommonTrackCell::DoFindTrack()
|
||||||
|
{
|
||||||
|
return mwTrack.lock();
|
||||||
|
}
|
||||||
|
@@ -14,6 +14,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "../../TrackPanelCell.h"
|
#include "../../TrackPanelCell.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class Track;
|
class Track;
|
||||||
@@ -51,4 +52,20 @@ protected:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AUDACITY_DLL_API CommonTrackCell /* not final */
|
||||||
|
: public CommonTrackPanelCell
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit CommonTrackCell( const std::shared_ptr<Track> &pTrack );
|
||||||
|
|
||||||
|
~CommonTrackCell();
|
||||||
|
|
||||||
|
std::shared_ptr<Track> DoFindTrack() override;
|
||||||
|
|
||||||
|
void Reparent( const std::shared_ptr<Track> &parent );
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::weak_ptr< Track > mwTrack;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -29,7 +29,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
|
|
||||||
TrackControls::TrackControls( std::shared_ptr<Track> pTrack )
|
TrackControls::TrackControls( std::shared_ptr<Track> pTrack )
|
||||||
: mwTrack{ pTrack }
|
: CommonTrackCell{ pTrack }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,11 +37,6 @@ TrackControls::~TrackControls()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Track> TrackControls::DoFindTrack()
|
|
||||||
{
|
|
||||||
return mwTrack.lock();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<UIHandlePtr> CommonTrackControls::HitTest
|
std::vector<UIHandlePtr> CommonTrackControls::HitTest
|
||||||
(const TrackPanelMouseState &st,
|
(const TrackPanelMouseState &st,
|
||||||
const AudacityProject *WXUNUSED(project))
|
const AudacityProject *WXUNUSED(project))
|
||||||
|
@@ -22,18 +22,13 @@ class MinimizeButtonHandle;
|
|||||||
class SelectButtonHandle;
|
class SelectButtonHandle;
|
||||||
class TrackSelectHandle;
|
class TrackSelectHandle;
|
||||||
|
|
||||||
class TrackControls /* not final */ : public CommonTrackPanelCell
|
class TrackControls /* not final */ : public CommonTrackCell
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit
|
explicit
|
||||||
TrackControls( std::shared_ptr<Track> pTrack );
|
TrackControls( std::shared_ptr<Track> pTrack );
|
||||||
|
|
||||||
virtual ~TrackControls() = 0;
|
virtual ~TrackControls() = 0;
|
||||||
|
|
||||||
protected:
|
|
||||||
std::shared_ptr<Track> DoFindTrack() override;
|
|
||||||
|
|
||||||
std::weak_ptr<Track> mwTrack;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CommonTrackControls /* not final */ : public TrackControls
|
class CommonTrackControls /* not final */ : public TrackControls
|
||||||
|
Reference in New Issue
Block a user