mirror of
https://github.com/cookiengineer/audacity
synced 2026-02-08 12:42:03 +01:00
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.
This commit is contained in:
@@ -28,16 +28,6 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "WaveTrack.h"
|
||||
#endif
|
||||
|
||||
TrackPanelResizeHandle::TrackPanelResizeHandle()
|
||||
{
|
||||
}
|
||||
|
||||
TrackPanelResizeHandle &TrackPanelResizeHandle::Instance()
|
||||
{
|
||||
static TrackPanelResizeHandle instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
HitTestPreview TrackPanelResizeHandle::HitPreview(bool bLinked)
|
||||
{
|
||||
static wxCursor resizeCursor{ wxCURSOR_SIZENS };
|
||||
@@ -69,30 +59,14 @@ TrackPanelResizeHandle::~TrackPanelResizeHandle()
|
||||
UIHandle::Result TrackPanelResizeHandle::Click
|
||||
(const TrackPanelMouseEvent &evt, AudacityProject *pProject)
|
||||
{
|
||||
const wxMouseEvent &event = evt.event;
|
||||
const auto pCell =
|
||||
static_cast<CommonTrackPanelCell*>(evt.pCell.get());
|
||||
auto track = pCell->FindTrack().get();
|
||||
if (track && dynamic_cast< TrackControls * >( pCell )) {
|
||||
// Clicked under a label;
|
||||
// if stereo, replace left channel with the right:
|
||||
if (track && track->GetLinked())
|
||||
track = track->GetLink();
|
||||
}
|
||||
if (!track)
|
||||
return RefreshCode::Cancelled;
|
||||
|
||||
mpTrack = Track::Pointer( track );
|
||||
|
||||
/// ButtonDown means they just clicked and haven't released yet.
|
||||
/// We use this opportunity to save which track they clicked on,
|
||||
/// and the initial height of the track, so as they drag we can
|
||||
/// update the track size.
|
||||
|
||||
mMouseClickY = event.m_y;
|
||||
|
||||
TrackList *const tracks = pProject->GetTracks();
|
||||
return RefreshCode::RefreshNone;
|
||||
}
|
||||
|
||||
TrackPanelResizeHandle::TrackPanelResizeHandle
|
||||
( const std::shared_ptr<Track> &track, int y, const AudacityProject *pProject )
|
||||
: mpTrack{ track }
|
||||
, mMouseClickY( y )
|
||||
{
|
||||
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY
|
||||
if (MONO_WAVE_PAN(track)){
|
||||
//STM: Determine whether we should rescale one or two tracks
|
||||
@@ -116,11 +90,12 @@ UIHandle::Result TrackPanelResizeHandle::Click
|
||||
else
|
||||
#endif
|
||||
{
|
||||
Track *prev = tracks->GetPrev(track);
|
||||
Track *next = tracks->GetNext(track);
|
||||
auto tracks = pProject->GetTracks();
|
||||
Track *prev = tracks->GetPrev(track.get());
|
||||
Track *next = tracks->GetNext(track.get());
|
||||
|
||||
//STM: Determine whether we should rescale one or two tracks
|
||||
if (prev && prev->GetLink() == track) {
|
||||
if (prev && prev->GetLink() == track.get()) {
|
||||
// mpTrack is the lower track
|
||||
mInitialTrackHeight = track->GetHeight();
|
||||
mInitialActualHeight = track->GetActualHeight();
|
||||
@@ -146,8 +121,6 @@ UIHandle::Result TrackPanelResizeHandle::Click
|
||||
mMode = IsResizing;
|
||||
}
|
||||
}
|
||||
|
||||
return RefreshCode::RefreshNone;
|
||||
}
|
||||
|
||||
UIHandle::Result TrackPanelResizeHandle::Drag
|
||||
|
||||
Reference in New Issue
Block a user