Store the last used AudioMarkerInteractionObject in its own member variable to eliminate an ugly dynamic_cast

Originally committed to SVN as r6178.
This commit is contained in:
Thomas Goyne 2011-12-28 21:26:48 +00:00
parent 88ba844850
commit 6953a69cf8
2 changed files with 8 additions and 6 deletions

View file

@ -1027,10 +1027,6 @@ void AudioDisplay::OnPaint(wxPaintEvent&)
void AudioDisplay::SetDraggedObject(AudioDisplayInteractionObject *new_obj)
{
// Special case for audio markers being dragged: they use a temporary wrapper object
// which must be deleted when it is no longer used.
delete dynamic_cast<AudioMarkerInteractionObject*>(dragged_object);
dragged_object = new_obj;
if (dragged_object && !HasCapture())
@ -1162,7 +1158,8 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
if (marker)
{
RemoveTrackCursor();
SetDraggedObject(new AudioMarkerInteractionObject(marker, timing, this, controller, wxMOUSE_BTN_LEFT));
audio_marker.reset(new AudioMarkerInteractionObject(marker, timing, this, controller, wxMOUSE_BTN_LEFT));
SetDraggedObject(audio_marker.get());
return;
}
}
@ -1175,7 +1172,8 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
if (marker)
{
RemoveTrackCursor();
SetDraggedObject(new AudioMarkerInteractionObject(marker, timing, this, controller, wxMOUSE_BTN_RIGHT));
audio_marker.reset(new AudioMarkerInteractionObject(marker, timing, this, controller, wxMOUSE_BTN_RIGHT));
SetDraggedObject(audio_marker.get());
return;
}
}

View file

@ -58,6 +58,7 @@ class AudioProvider;
class AudioDisplayScrollbar;
class AudioDisplayTimeline;
class AudioDisplaySelection;
class AudioMarkerInteractionObject;
/// @class AudioDisplayInteractionObject
/// @brief Interface for objects on the audio display that can respond to mouse events
@ -122,6 +123,9 @@ class AudioDisplay: public wxWindow {
/// Timeline helper object
agi::scoped_ptr<AudioDisplayTimeline> timeline;
/// The interaction object for the last-dragged audio marker
agi::scoped_ptr<AudioMarkerInteractionObject> audio_marker;
/// Current object on display being dragged, if any
AudioDisplayInteractionObject *dragged_object;