2017-07-04 15:39:32 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
TrackPanelResizerCell.h
|
|
|
|
|
|
|
|
Paul Licameli split from TrackPanel.cpp
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_TRACK_PANEL_RESIZER_CELL__
|
|
|
|
#define __AUDACITY_TRACK_PANEL_RESIZER_CELL__
|
|
|
|
|
2019-07-09 18:45:42 +00:00
|
|
|
#include "ClientData.h" // to inherit
|
|
|
|
#include "tracks/ui/CommonTrackPanelCell.h" // to inherit
|
2017-07-04 15:39:32 +00:00
|
|
|
|
2019-07-09 18:45:42 +00:00
|
|
|
class Track;
|
Changed lifetime management of UIHandle objects, no singletons...
... Rather, construct them during hit tests (also capturing more state sooner
rather than at Click time, and adding some accessors for later use)
This also fixes bug 1677 by other means and avoids similar problems.
A cell may be implemented to re-use a previously hit handle object, not yet
clicked, in a later hit test, by remembering a weak pointer, but TrackPanel
holds the strong pointers that determine when the object is destroyed.
And the objects will surely be destroyed after drag-release, or ESC key.
For now they are also destroyed whenever not dragging, and hit-testing is
re-invoked; that will be changed later, so that the re-use mentioned above
becomes effective, but still they will be destroyed when the pointer moves
from one cell to another.
2017-07-05 20:45:55 +00:00
|
|
|
class TrackPanelResizeHandle;
|
|
|
|
|
2019-07-09 18:45:42 +00:00
|
|
|
class TrackPanelResizerCell
|
|
|
|
: public CommonTrackPanelCell
|
|
|
|
, public std::enable_shared_from_this< TrackPanelResizerCell >
|
|
|
|
, public ClientData::Base
|
2017-07-04 15:39:32 +00:00
|
|
|
{
|
|
|
|
TrackPanelResizerCell(const TrackPanelResizerCell&) = delete;
|
|
|
|
TrackPanelResizerCell &operator= (const TrackPanelResizerCell&) = delete;
|
|
|
|
public:
|
|
|
|
|
2019-07-09 18:45:42 +00:00
|
|
|
static TrackPanelResizerCell &Get( Track &track );
|
|
|
|
static const TrackPanelResizerCell &Get( const Track &track );
|
|
|
|
|
2017-07-04 15:39:32 +00:00
|
|
|
explicit
|
2019-07-09 18:45:42 +00:00
|
|
|
TrackPanelResizerCell( const std::shared_ptr<Track> &pTrack );
|
2017-07-04 15:39:32 +00:00
|
|
|
|
2017-06-29 14:34:57 +00:00
|
|
|
std::vector<UIHandlePtr> HitTest
|
2017-06-29 03:21:20 +00:00
|
|
|
(const TrackPanelMouseState &, const AudacityProject *) override;
|
2017-07-04 15:39:32 +00:00
|
|
|
|
2018-11-06 16:02:03 +00:00
|
|
|
protected:
|
2019-06-18 03:23:44 +00:00
|
|
|
std::shared_ptr<Track> DoFindTrack() override;
|
2018-11-06 16:02:03 +00:00
|
|
|
|
2017-07-04 15:39:32 +00:00
|
|
|
private:
|
2019-06-18 03:23:44 +00:00
|
|
|
// back-pointer is weak to break a cycle
|
2019-07-09 18:45:42 +00:00
|
|
|
std::weak_ptr<Track> mwTrack;
|
Changed lifetime management of UIHandle objects, no singletons...
... Rather, construct them during hit tests (also capturing more state sooner
rather than at Click time, and adding some accessors for later use)
This also fixes bug 1677 by other means and avoids similar problems.
A cell may be implemented to re-use a previously hit handle object, not yet
clicked, in a later hit test, by remembering a weak pointer, but TrackPanel
holds the strong pointers that determine when the object is destroyed.
And the objects will surely be destroyed after drag-release, or ESC key.
For now they are also destroyed whenever not dragging, and hit-testing is
re-invoked; that will be changed later, so that the re-use mentioned above
becomes effective, but still they will be destroyed when the pointer moves
from one cell to another.
2017-07-05 20:45:55 +00:00
|
|
|
|
2018-11-03 04:34:49 +00:00
|
|
|
// TrackPanelDrawable implementation
|
|
|
|
void Draw(
|
|
|
|
TrackPanelDrawingContext &context,
|
|
|
|
const wxRect &rect, unsigned iPass ) override;
|
|
|
|
|
Changed lifetime management of UIHandle objects, no singletons...
... Rather, construct them during hit tests (also capturing more state sooner
rather than at Click time, and adding some accessors for later use)
This also fixes bug 1677 by other means and avoids similar problems.
A cell may be implemented to re-use a previously hit handle object, not yet
clicked, in a later hit test, by remembering a weak pointer, but TrackPanel
holds the strong pointers that determine when the object is destroyed.
And the objects will surely be destroyed after drag-release, or ESC key.
For now they are also destroyed whenever not dragging, and hit-testing is
re-invoked; that will be changed later, so that the re-use mentioned above
becomes effective, but still they will be destroyed when the pointer moves
from one cell to another.
2017-07-05 20:45:55 +00:00
|
|
|
std::weak_ptr<TrackPanelResizeHandle> mResizeHandle;
|
2017-07-04 15:39:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|