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

Define and use CommonTrackCell

This commit is contained in:
Paul Licameli
2019-06-17 14:11:31 -04:00
parent 2bb823e1b6
commit bebd709e98
6 changed files with 40 additions and 16 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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))

View File

@@ -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