use std::vector to hold TrackClip; move ctor and dtor out of line

This commit is contained in:
Paul Licameli 2016-02-20 13:22:12 -05:00 committed by Paul Licameli
parent c373f4d859
commit cb7872f980
3 changed files with 31 additions and 20 deletions

View File

@ -21,13 +21,23 @@
#include <wx/arrimpl.cpp>
WX_DEFINE_USER_EXPORTED_OBJARRAY(TrackClipArray);
inline bool operator < (SnapPoint s1, SnapPoint s2)
{
return s1.t < s2.t;
}
TrackClip::TrackClip(Track *t, WaveClip *c)
{
track = origTrack = t;
dstTrack = NULL;
clip = c;
}
TrackClip::~TrackClip()
{
}
SnapManager::SnapManager(TrackList *tracks,
const ZoomInfo *zoomInfo,
const TrackClipArray *clipExclusions,
@ -126,10 +136,10 @@ void SnapManager::Reinit()
if (mClipExclusions)
{
bool skip = false;
for (size_t j = 0, cnt = mClipExclusions->GetCount(); j < cnt; ++j)
for (size_t j = 0, cnt = mClipExclusions->size(); j < cnt; ++j)
{
if (mClipExclusions->Item(j).track == waveTrack &&
mClipExclusions->Item(j).clip == clip)
if ((*mClipExclusions)[j].track == waveTrack &&
(*mClipExclusions)[j].clip == clip)
{
skip = true;
break;

View File

@ -17,7 +17,6 @@
#include <vector>
#include <wx/defs.h>
#include <wx/dynarray.h>
#include <wx/string.h>
#include "widgets/NumericTextCtrl.h"
@ -32,19 +31,21 @@ class ZoomInfo;
class TrackClip
{
public:
TrackClip(Track *t, WaveClip *c)
{
track = origTrack = t;
dstTrack = NULL;
clip = c;
}
TrackClip(Track *t, WaveClip *c);
#ifndef __AUDACITY_OLD_STD__
TrackClip(TrackClip&&) = default;
#endif
~TrackClip();
Track *track;
Track *origTrack;
Track *dstTrack;
WaveClip *clip;
};
WX_DECLARE_USER_EXPORTED_OBJARRAY(TrackClip, TrackClipArray, AUDACITY_DLL_API);
class TrackClipArray : public std::vector < TrackClip > {};
enum
{

View File

@ -1819,7 +1819,7 @@ void TrackPanel::HandleSelect(wxMouseEvent & event)
selectedClip->GetOffset(), selectedClip->GetEndTime());
}
//Also, capture this track for dragging until we up-click.
mCapturedClipArray.Add(TrackClip(w, selectedClip));
mCapturedClipArray.push_back(TrackClip(w, selectedClip));
mMouseCapture = IsSliding;
@ -3304,7 +3304,7 @@ void TrackPanel::StartSlide(wxMouseEvent & event)
// The captured clip is the focus, but we need to create a list
// of all clips that have to move, also...
mCapturedClipArray.Clear();
mCapturedClipArray.clear();
// First, if click was in selection, capture selected clips; otherwise
// just the clicked-on clip
@ -3319,7 +3319,7 @@ void TrackPanel::StartSlide(wxMouseEvent & event)
}
}
else {
mCapturedClipArray.Add(TrackClip(vt, mCapturedClip));
mCapturedClipArray.push_back(TrackClip(vt, mCapturedClip));
// Check for stereo partner
Track *partner = mTracks->GetLink(vt);
@ -3328,7 +3328,7 @@ void TrackPanel::StartSlide(wxMouseEvent & event)
FindClipAtTime(static_cast<WaveTrack*>(partner),
mViewInfo->PositionToTime(event.m_x, GetLeftOffset()));
if (clip)
mCapturedClipArray.Add(TrackClip(partner, clip));
mCapturedClipArray.push_back(TrackClip(partner, clip));
}
}
@ -3375,7 +3375,7 @@ void TrackPanel::StartSlide(wxMouseEvent & event)
} else {
mCapturedClip = NULL;
mCapturedClipArray.Clear();
mCapturedClipArray.clear();
}
mSlideUpDownOnly = event.CmdDown() && !multiToolModeActive;
@ -3440,7 +3440,7 @@ void TrackPanel::AddClipsToCaptured(Track *t, double t0, double t1)
}
if (newClip)
mCapturedClipArray.Add(TrackClip(t, clip));
mCapturedClipArray.push_back(TrackClip(t, clip));
}
it = it->GetNext();
}
@ -3467,7 +3467,7 @@ void TrackPanel::AddClipsToCaptured(Track *t, double t0, double t1)
return;
}
#endif
mCapturedClipArray.Add(TrackClip(t, NULL));
mCapturedClipArray.push_back(TrackClip(t, NULL));
}
}
}