Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SampleHandle Class Referencefinal

#include <SampleHandle.h>

Inheritance diagram for SampleHandle:
[legend]
Collaboration diagram for SampleHandle:
[legend]

Public Member Functions

 SampleHandle (const std::shared_ptr< WaveTrack > &pTrack)
 
SampleHandleoperator= (const SampleHandle &)=default
 
virtual ~SampleHandle ()
 
std::shared_ptr< WaveTrackGetTrack () const
 
void Enter (bool forward, AudacityProject *) override
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
Result Cancel (AudacityProject *pProject) override
 
bool StopsOnKeystroke () override
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
virtual void Enter (bool forward, AudacityProject *pProject)
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape (AudacityProject *pProject) const
 
virtual bool Escape (AudacityProject *pProject)
 
virtual bool HandlesRightClick ()
 Whether the handle has any special right-button handling. More...
 
virtual Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject)=0
 
virtual Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
 
virtual Result Cancel (AudacityProject *pProject)=0
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

Static Public Member Functions

static UIHandlePtr HitAnywhere (std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const std::shared_ptr< WaveTrack > &pTrack)
 
static UIHandlePtr HitTest (std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveTrack > &pTrack)
 
- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 

Private Member Functions

 SampleHandle (const SampleHandle &)=delete
 
float FindSampleEditingLevel (const wxMouseEvent &event, const ViewInfo &viewInfo, double t0)
 

Static Private Member Functions

static HitTestPreview HitPreview (const wxMouseState &state, const AudacityProject *pProject, bool unsafe)
 

Private Attributes

std::shared_ptr< WaveTrackmClickedTrack
 
wxRect mRect {}
 
sampleCount mClickedStartSample {}
 
sampleCount mLastDragSample {}
 
float mLastDragSampleValue {}
 
bool mAltKey {}
 

Additional Inherited Members

- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 24 of file SampleHandle.h.

Constructor & Destructor Documentation

◆ SampleHandle() [1/2]

SampleHandle::SampleHandle ( const SampleHandle )
privatedelete

◆ SampleHandle() [2/2]

SampleHandle::SampleHandle ( const std::shared_ptr< WaveTrack > &  pTrack)
explicit

Definition at line 38 of file SampleHandle.cpp.

39 : mClickedTrack{ pTrack }
40{
41}
std::shared_ptr< WaveTrack > mClickedTrack
Definition: SampleHandle.h:71

◆ ~SampleHandle()

SampleHandle::~SampleHandle ( )
virtual

Definition at line 164 of file SampleHandle.cpp.

165{
166}

Member Function Documentation

◆ Cancel()

UIHandle::Result SampleHandle::Cancel ( AudacityProject pProject)
overridevirtual

Implements UIHandle.

Definition at line 430 of file SampleHandle.cpp.

431{
432 mClickedTrack.reset();
433 ProjectHistory::Get( *pProject ).RollbackState();
435}
static ProjectHistory & Get(AudacityProject &project)

References ProjectHistory::Get(), mClickedTrack, RefreshCode::RefreshCell, and ProjectHistory::RollbackState().

Referenced by Drag(), and Release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Click()

UIHandle::Result SampleHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Someone has just clicked the mouse. What do we do?

We're in a track view and zoomed enough to see the samples.

Implements UIHandle.

Definition at line 190 of file SampleHandle.cpp.

192{
193 using namespace RefreshCode;
194 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
195 if ( unsafe )
196 return Cancelled;
197
198 const wxMouseEvent &event = evt.event;
199 const wxRect &rect = evt.rect;
200 const auto &viewInfo = ViewInfo::Get( *pProject );
201 const auto pTrack = mClickedTrack.get();
202
205 event, rect, viewInfo, pTrack, rect.width))
206 return Cancelled;
207
209 mRect = rect;
210
211 //If we are still around, we are drawing in earnest. Set some member data structures up:
212 //First, calculate the starting sample. To get this, we need the time
213 const double t0 =
214 adjustTime(mClickedTrack.get(), viewInfo.PositionToTime(event.m_x, rect.x));
215
216 //convert t0 to samples
217 mClickedStartSample = mClickedTrack->TimeToLongSamples(t0);
218
219 //Determine how drawing should occur. If alt is down,
220 //do a smoothing, instead of redrawing.
221 if (event.m_altDown)
222 {
223 mAltKey = true;
224 //*************************************************
225 //*** ALT-DOWN-CLICK (SAMPLE SMOOTHING) ***
226 //*************************************************
227 //
228 // Smoothing works like this: There is a smoothing kernel radius constant that
229 // determines how wide the averaging window is. Plus, there is a smoothing brush radius,
230 // which determines how many pixels wide around the selected pixel this smoothing is applied.
231 //
232 // Samples will be replaced by a mixture of the original points and the smoothed points,
233 // with a triangular mixing probability whose value at the center point is
234 // SMOOTHING_PROPORTION_MAX and at the far bounds is SMOOTHING_PROPORTION_MIN
235
236 //Get the region of samples around the selected point
237 size_t sampleRegionSize = 1 + 2 * (SMOOTHING_KERNEL_RADIUS + SMOOTHING_BRUSH_RADIUS);
238 Floats sampleRegion{ sampleRegionSize };
239 Floats newSampleRegion{ 1 + 2 * (size_t)SMOOTHING_BRUSH_RADIUS };
240
241 //Get a sample from the track to do some tricks on.
242 mClickedTrack->GetFloats(sampleRegion.get(),
244 sampleRegionSize);
245
246 //Go through each point of the smoothing brush and apply a smoothing operation.
247 for (auto jj = -SMOOTHING_BRUSH_RADIUS; jj <= SMOOTHING_BRUSH_RADIUS; ++jj) {
248 float sumOfSamples = 0;
249 for (auto ii = -SMOOTHING_KERNEL_RADIUS; ii <= SMOOTHING_KERNEL_RADIUS; ++ii) {
250 //Go through each point of the smoothing kernel and find the average
251
252 //The average is a weighted average, scaled by a weighting kernel that is simply triangular
253 // A triangular kernel across N items, with a radius of R ( 2 R + 1 points), if the farthest:
254 // points have a probability of a, the entire triangle has total probability of (R + 1)^2.
255 // For sample number ii and middle brush sample M, (R + 1 - abs(M-ii))/ ((R+1)^2) gives a
256 // legal distribution whose total probability is 1.
257 //
258 //
259 // weighting factor value
260 sumOfSamples +=
261 (SMOOTHING_KERNEL_RADIUS + 1 - abs(ii)) *
262 sampleRegion[ii + jj + SMOOTHING_KERNEL_RADIUS + SMOOTHING_BRUSH_RADIUS];
263
264 }
265 newSampleRegion[jj + SMOOTHING_BRUSH_RADIUS] =
266 sumOfSamples /
268 }
269
270
271 // Now that the NEW sample levels are determined, go through each and mix it appropriately
272 // with the original point, according to a 2-part linear function whose center has probability
273 // SMOOTHING_PROPORTION_MAX and extends out SMOOTHING_BRUSH_RADIUS, at which the probability is
274 // SMOOTHING_PROPORTION_MIN. _MIN and _MAX specify how much of the smoothed curve make it through.
275
276 float prob;
277
278 for (auto jj = -SMOOTHING_BRUSH_RADIUS; jj <= SMOOTHING_BRUSH_RADIUS; ++jj) {
279
280 prob =
282 (float)abs(jj) / SMOOTHING_BRUSH_RADIUS *
284
285 newSampleRegion[jj + SMOOTHING_BRUSH_RADIUS] =
286 newSampleRegion[jj + SMOOTHING_BRUSH_RADIUS] * prob +
288 (1 - prob);
289 }
290 //Set the sample to the point of the mouse event
291 mClickedTrack->Set((samplePtr)newSampleRegion.get(), floatSample,
293
294 // mLastDragSampleValue will not be used
295 }
296 else
297 {
298 mAltKey = false;
299 //*************************************************
300 //*** PLAIN DOWN-CLICK (NORMAL DRAWING) ***
301 //*************************************************
302
303 //Otherwise (e.g., the alt button is not down) do normal redrawing, based on the mouse position.
304 const float newLevel = FindSampleEditingLevel(event, viewInfo, t0);
305
306 //Set the sample to the point of the mouse event
308
309 mLastDragSampleValue = newLevel;
310 }
311
312 //Set the member data structures for drawing
314
315 // Sample data changed on either branch, so refresh the track display.
316 return RefreshCell;
317}
@ floatSample
Definition: SampleFormat.h:34
char * samplePtr
Definition: SampleFormat.h:49
static const int SMOOTHING_BRUSH_RADIUS
static const double SMOOTHING_PROPORTION_MAX
static const int SMOOTHING_KERNEL_RADIUS
static const double SMOOTHING_PROPORTION_MIN
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
float FindSampleEditingLevel(const wxMouseEvent &event, const ViewInfo &viewInfo, double t0)
float mLastDragSampleValue
Definition: SampleHandle.h:76
sampleCount mClickedStartSample
Definition: SampleHandle.h:74
sampleCount mLastDragSample
Definition: SampleHandle.h:75
wxRect mRect
Definition: SampleHandle.h:72
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
double adjustTime(const WaveTrack *wt, double time)
bool IsSampleEditingPossible(const wxMouseEvent &event, const wxRect &rect, const ViewInfo &viewInfo, WaveTrack *wt, int width)

References anonymous_namespace{SampleHandle.cpp}::adjustTime(), RefreshCode::Cancelled, TrackPanelMouseEvent::event, FindSampleEditingLevel(), floatSample, ViewInfo::Get(), ProjectAudioIO::Get(), ProjectAudioIO::IsAudioActive(), anonymous_namespace{SampleHandle.cpp}::IsSampleEditingPossible(), mAltKey, mClickedStartSample, mClickedTrack, mLastDragSample, mLastDragSampleValue, mRect, TrackPanelMouseEvent::rect, RefreshCode::RefreshCell, SMOOTHING_BRUSH_RADIUS, SMOOTHING_KERNEL_RADIUS, SMOOTHING_PROPORTION_MAX, and SMOOTHING_PROPORTION_MIN.

Here is the call graph for this function:

◆ Drag()

UIHandle::Result SampleHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 319 of file SampleHandle.cpp.

321{
322 using namespace RefreshCode;
323 const wxMouseEvent &event = evt.event;
324 const auto &viewInfo = ViewInfo::Get( *pProject );
325
326 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
327 if (unsafe) {
328 this->Cancel(pProject);
329 return RefreshCell | Cancelled;
330 }
331
332 //*************************************************
333 //*** DRAG-DRAWING ***
334 //*************************************************
335
336 //No dragging effects if the alt key is down--
337 //Don't allow left-right dragging for smoothing operation
338 if (mAltKey)
339 return RefreshNone;
340
341 sampleCount s0; //declare this for use below. It designates which sample number to draw.
342
343 // Figure out what time the click was at
344 //Find the point that we want to redraw at. If the control button is down,
345 //adjust only the originally clicked-on sample
346
347 if (event.m_controlDown) {
348 //*************************************************
349 //*** CTRL-DOWN (Hold Initial Sample Constant ***
350 //*************************************************
351
353 }
354 else {
355 //*************************************************
356 //*** Normal CLICK-drag (Normal drawing) ***
357 //*************************************************
358
359 //Otherwise, adjust the sample you are dragging over right now.
360 //convert this to samples
361 const double tt = viewInfo.PositionToTime(event.m_x, mRect.x);
362 s0 = mClickedTrack->TimeToLongSamples(tt);
363 }
364
365 const double t0 = mClickedTrack->LongSamplesToTime(s0);
366
367 // Do redrawing, based on the mouse position.
368 // Calculate where the mouse is located vertically (between +/- 1)
369
370 const float newLevel = FindSampleEditingLevel(event, viewInfo, t0);
371
372 //Now, redraw all samples between current and last redrawn sample, inclusive
373 //Go from the smaller to larger sample.
374 const auto start = std::min(s0, mLastDragSample);
375 const auto end = std::max(s0, mLastDragSample);
376 // Few enough samples to be drawn individually on screen will not
377 // overflow size_t:
378 const auto size = ( end - start + 1 ).as_size_t();
379 if (size == 1) {
380 mClickedTrack->Set((samplePtr)&newLevel, floatSample, start, size);
381 }
382 else {
383 std::vector<float> values(size);
384 for (auto ii = start; ii <= end; ++ii) {
385 //This interpolates each sample linearly:
386 // i - start will not overflow size_t either:
387 values[( ii - start ).as_size_t()] =
389 (ii - mLastDragSample).as_float() /
390 (s0 - mLastDragSample).as_float();
391 }
392 mClickedTrack->Set((samplePtr)&values[0], floatSample, start, size);
393 }
394
395 //Update the member data structures.
396 mLastDragSample = s0;
397 mLastDragSampleValue = newLevel;
398
399 return RefreshCell;
400}
int min(int a, int b)
const wxChar * values
Result Cancel(AudacityProject *pProject) override
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References Cancel(), RefreshCode::Cancelled, PackedArray::end(), TrackPanelMouseEvent::event, FindSampleEditingLevel(), floatSample, ViewInfo::Get(), ProjectAudioIO::Get(), ProjectAudioIO::IsAudioActive(), mAltKey, mClickedStartSample, mClickedTrack, min(), mLastDragSample, mLastDragSampleValue, mRect, RefreshCode::RefreshCell, RefreshCode::RefreshNone, size, and values.

Here is the call graph for this function:

◆ Enter()

void SampleHandle::Enter ( bool  forward,
AudacityProject  
)
overridevirtual

Reimplemented from UIHandle.

Definition at line 43 of file SampleHandle.cpp.

44{
45#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
47#endif
48}
Result mChangeHighlight
Definition: UIHandle.h:139

References UIHandle::mChangeHighlight, and RefreshCode::RefreshCell.

◆ FindSampleEditingLevel()

float SampleHandle::FindSampleEditingLevel ( const wxMouseEvent &  event,
const ViewInfo viewInfo,
double  t0 
)
private

Definition at line 437 of file SampleHandle.cpp.

439{
440 // Calculate where the mouse is located vertically (between +/- 1)
441 float zoomMin, zoomMax;
442 mClickedTrack->GetDisplayBounds(&zoomMin, &zoomMax);
443
444 const int yy = event.m_y - mRect.y;
445 const int height = mRect.GetHeight();
446 const bool dB = !mClickedTrack->GetWaveformSettings().isLinear();
447 float newLevel =
448 ::ValueOfPixel(yy, height, false, dB,
449 mClickedTrack->GetWaveformSettings().dBRange, zoomMin, zoomMax);
450
451 //Take the envelope into account
452 const auto time = viewInfo.PositionToTime(event.m_x, mRect.x);
453 Envelope *const env = mClickedTrack->GetEnvelopeAtTime(time);
454 if (env)
455 {
456 // Calculate sample as it would be rendered, so quantize time
457 double envValue = env->GetValue( t0, 1.0 / mClickedTrack->GetRate());
458 if (envValue > 0)
459 newLevel /= envValue;
460 else
461 newLevel = 0;
462
463 //Make sure the NEW level is between +/-1
464 newLevel = std::max(-1.0f, std::min(1.0f, newLevel));
465 }
466
467 return newLevel;
468}
float ValueOfPixel(int yy, int height, bool offset, bool dB, double dBRange, float zoomMin, float zoomMax)
Definition: TrackArt.cpp:105
Piecewise linear or piecewise exponential function from double to double.
Definition: Envelope.h:72
double GetValue(double t, double sampleDur=0) const
Get envelope value at time t.
Definition: Envelope.cpp:823
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:41

References Envelope::GetValue(), mClickedTrack, min(), mRect, ZoomInfo::PositionToTime(), and ValueOfPixel().

Referenced by Click(), and Drag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTrack()

std::shared_ptr< WaveTrack > SampleHandle::GetTrack ( ) const
inline

Definition at line 45 of file SampleHandle.h.

45{ return mClickedTrack; }

References mClickedTrack.

Referenced by anonymous_namespace{WaveformView.cpp}::DrawClipWaveform().

Here is the caller graph for this function:

◆ HitAnywhere()

UIHandlePtr SampleHandle::HitAnywhere ( std::weak_ptr< SampleHandle > &  holder,
const wxMouseState &  state,
const std::shared_ptr< WaveTrack > &  pTrack 
)
static

Definition at line 73 of file SampleHandle.cpp.

76{
77 auto result = std::make_shared<SampleHandle>( pTrack );
78 result = AssignUIHandlePtr(holder, result);
79 return result;
80}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151

References AssignUIHandlePtr().

Referenced by WaveformView::DetailedHitTest(), and HitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HitPreview()

HitTestPreview SampleHandle::HitPreview ( const wxMouseState &  state,
const AudacityProject pProject,
bool  unsafe 
)
staticprivate

Definition at line 50 of file SampleHandle.cpp.

52{
53 static auto disabledCursor =
54 ::MakeCursor(wxCURSOR_NO_ENTRY, DisabledCursorXpm, 16, 16);
55 static wxCursor smoothCursor{ wxCURSOR_SPRAYCAN };
56 static auto pencilCursor =
57 ::MakeCursor(wxCURSOR_PENCIL, DrawCursorXpm, 12, 22);
58
59 // TODO: message should also mention the brush. Describing the modifier key
60 // (alt, or other) varies with operating system.
61 auto message = XO("Click and drag to edit the samples");
62
63 return {
64 message,
65 (unsafe
66 ? &*disabledCursor
67 : (state.AltDown()
68 ? &smoothCursor
69 : &*pencilCursor))
70 };
71}
#define XO(s)
Definition: Internat.h:31
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:185

References MakeCursor(), and XO.

Referenced by Preview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HitTest()

UIHandlePtr SampleHandle::HitTest ( std::weak_ptr< SampleHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
const AudacityProject pProject,
const std::shared_ptr< WaveTrack > &  pTrack 
)
static

method that tells us if the mouse event landed on an editable sample

Definition at line 111 of file SampleHandle.cpp.

115{
116 const auto &viewInfo = ViewInfo::Get( *pProject );
117
120 const auto wavetrack = pTrack.get();
121 const auto time = viewInfo.PositionToTime(state.m_x, rect.x);
122
123 const double tt = adjustTime(wavetrack, time);
124 if (!SampleResolutionTest(viewInfo, wavetrack, tt, rect.width))
125 return {};
126
127 // Just get one sample.
128 float oneSample;
129 const double rate = wavetrack->GetRate();
130 const auto s0 = (sampleCount)(tt * rate + 0.5);
131 if (! wavetrack->GetFloats(&oneSample, s0, 1, fillZero,
132 // Do not propagate exception but return a failure value
133 false) )
134 return {};
135
136 // Get y distance of envelope point from center line (in pixels).
137 float zoomMin, zoomMax;
138
139 wavetrack->GetDisplayBounds(&zoomMin, &zoomMax);
140
141 double envValue = 1.0;
142 Envelope* env = wavetrack->GetEnvelopeAtTime(time);
143 if (env)
144 // Calculate sample as it would be rendered, so quantize time
145 envValue = env->GetValue( tt, 1.0 / wavetrack->GetRate() );
146
147 const bool dB = !wavetrack->GetWaveformSettings().isLinear();
148 int yValue = GetWaveYPos(oneSample * envValue,
149 zoomMin, zoomMax,
150 rect.height, dB, true,
151 wavetrack->GetWaveformSettings().dBRange, false) + rect.y;
152
153 // Get y position of mouse (in pixels)
154 int yMouse = state.m_y;
155
156 // Perhaps yTolerance should be put into preferences?
157 const int yTolerance = 10; // More tolerance on samples than on envelope.
158 if (abs(yValue - yMouse) >= yTolerance)
159 return {};
160
161 return HitAnywhere(holder, state, pTrack);
162}
@ fillZero
Definition: SampleFormat.h:54
int GetWaveYPos(float value, float min, float max, int height, bool dB, bool outer, float dBr, bool clip)
Definition: TrackArt.cpp:49
static UIHandlePtr HitAnywhere(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const std::shared_ptr< WaveTrack > &pTrack)
bool SampleResolutionTest(const ViewInfo &viewInfo, const WaveTrack *wt, double time, int width)

References anonymous_namespace{SampleHandle.cpp}::adjustTime(), fillZero, ViewInfo::Get(), Envelope::GetValue(), GetWaveYPos(), HitAnywhere(), and anonymous_namespace{SampleHandle.cpp}::SampleResolutionTest().

Referenced by WaveformView::DetailedHitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

SampleHandle & SampleHandle::operator= ( const SampleHandle )
default

◆ Preview()

HitTestPreview SampleHandle::Preview ( const TrackPanelMouseState state,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 402 of file SampleHandle.cpp.

404{
405 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
406 return HitPreview(st.state, pProject, unsafe);
407}
static HitTestPreview HitPreview(const wxMouseState &state, const AudacityProject *pProject, bool unsafe)

References ProjectAudioIO::Get(), HitPreview(), ProjectAudioIO::IsAudioActive(), and TrackPanelMouseState::state.

Here is the call graph for this function:

◆ Release()

UIHandle::Result SampleHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overridevirtual

Implements UIHandle.

Definition at line 409 of file SampleHandle.cpp.

412{
413 const bool unsafe = ProjectAudioIO::Get( *pProject ).IsAudioActive();
414 if (unsafe)
415 return this->Cancel(pProject);
416
417 //*************************************************
418 //*** UP-CLICK (Finish drawing) ***
419 //*************************************************
420 //On up-click, send the state to the undo stack
421 mClickedTrack.reset(); //Set this to NULL so it will catch improper drag events.
422 ProjectHistory::Get( *pProject ).PushState(XO("Moved Samples"),
423 XO("Sample Edit"),
425
426 // No change to draw since last drag
428}
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)

References Cancel(), CONSOLIDATE, ProjectHistory::Get(), ProjectAudioIO::Get(), ProjectAudioIO::IsAudioActive(), mClickedTrack, ProjectHistory::PushState(), RefreshCode::RefreshNone, and XO.

Here is the call graph for this function:

◆ StopsOnKeystroke()

bool SampleHandle::StopsOnKeystroke ( )
inlineoverridevirtual

Reimplemented from UIHandle.

Definition at line 65 of file SampleHandle.h.

65{ return true; }

Member Data Documentation

◆ mAltKey

bool SampleHandle::mAltKey {}
private

Definition at line 77 of file SampleHandle.h.

Referenced by Click(), and Drag().

◆ mClickedStartSample

sampleCount SampleHandle::mClickedStartSample {}
private

Definition at line 74 of file SampleHandle.h.

Referenced by Click(), and Drag().

◆ mClickedTrack

std::shared_ptr<WaveTrack> SampleHandle::mClickedTrack
private

Definition at line 71 of file SampleHandle.h.

Referenced by Cancel(), Click(), Drag(), FindSampleEditingLevel(), GetTrack(), and Release().

◆ mLastDragSample

sampleCount SampleHandle::mLastDragSample {}
private

Definition at line 75 of file SampleHandle.h.

Referenced by Click(), and Drag().

◆ mLastDragSampleValue

float SampleHandle::mLastDragSampleValue {}
private

Definition at line 76 of file SampleHandle.h.

Referenced by Click(), and Drag().

◆ mRect

wxRect SampleHandle::mRect {}
private

Definition at line 72 of file SampleHandle.h.

Referenced by Click(), Drag(), and FindSampleEditingLevel().


The documentation for this class was generated from the following files: