Audacity  2.2.2
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:
UIHandle

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) override
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
HitTestPreview Preview (const TrackPanelMouseState &state, const 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 bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape () const
 
virtual bool Escape ()
 
virtual void DrawExtras (DrawingPass pass, wxDC *dc, const wxRegion &updateRegion, const wxRect &panelRect)
 
virtual void OnProjectChange (AudacityProject *pProject)
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 

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 &)
 

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
enum  DrawingPass { Cells, Panel }
 
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 26 of file SampleHandle.h.

Constructor & Destructor Documentation

SampleHandle::SampleHandle ( const SampleHandle )
privatedelete
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:73
SampleHandle::~SampleHandle ( )
virtual

Definition at line 166 of file SampleHandle.cpp.

167 {
168 }

Member Function Documentation

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

Implements UIHandle.

Definition at line 446 of file SampleHandle.cpp.

References RefreshCode::RefreshCell, and AudacityProject::RollbackState().

447 {
448  pProject->RollbackState();
449  mClickedTrack.reset();
451 }
std::shared_ptr< WaveTrack > mClickedTrack
Definition: SampleHandle.h:73
void RollbackState()
Definition: Project.cpp:4742
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 207 of file SampleHandle.cpp.

References RefreshCode::Cancelled, Drag(), TrackPanelMouseEvent::event, floatSample, AudacityProject::GetViewInfo(), AudacityProject::IsAudioActive(), ZoomInfo::PositionToTime(), TrackPanelMouseEvent::rect, RefreshCode::RefreshCell, SMOOTHING_BRUSH_RADIUS, SMOOTHING_KERNEL_RADIUS, SMOOTHING_PROPORTION_MAX, and SMOOTHING_PROPORTION_MIN.

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

Implements UIHandle.

Definition at line 336 of file SampleHandle.cpp.

References RefreshCode::Cancelled, TrackPanelMouseEvent::event, floatSample, AudacityProject::GetViewInfo(), AudacityProject::IsAudioActive(), min(), ZoomInfo::PositionToTime(), RefreshCode::RefreshCell, and RefreshCode::RefreshNone.

Referenced by Click().

337 {
338  using namespace RefreshCode;
339  const wxMouseEvent &event = evt.event;
340  const ViewInfo &viewInfo = pProject->GetViewInfo();
341 
342  const bool unsafe = pProject->IsAudioActive();
343  if (unsafe) {
344  this->Cancel(pProject);
345  return RefreshCell | Cancelled;
346  }
347 
348  //*************************************************
349  //*** DRAG-DRAWING ***
350  //*************************************************
351 
352  //No dragging effects if the alt key is down--
353  //Don't allow left-right dragging for smoothing operation
354  if (mAltKey)
355  return RefreshNone;
356 
357  sampleCount s0; //declare this for use below. It designates which sample number to draw.
358 
359  // Figure out what time the click was at
360  //Find the point that we want to redraw at. If the control button is down,
361  //adjust only the originally clicked-on sample
362 
363  if (event.m_controlDown) {
364  //*************************************************
365  //*** CTRL-DOWN (Hold Initial Sample Constant ***
366  //*************************************************
367 
368  s0 = mClickedStartSample;
369  }
370  else {
371  //*************************************************
372  //*** Normal CLICK-drag (Normal drawing) ***
373  //*************************************************
374 
375  //Otherwise, adjust the sample you are dragging over right now.
376  //convert this to samples
377  const double tt = viewInfo.PositionToTime(event.m_x, mRect.x);
378  s0 = mClickedTrack->TimeToLongSamples(tt);
379  }
380 
381  const double t0 = mClickedTrack->LongSamplesToTime(s0);
382 
383  // Do redrawing, based on the mouse position.
384  // Calculate where the mouse is located vertically (between +/- 1)
385 
386  const float newLevel = FindSampleEditingLevel(event, viewInfo, t0);
387 
388  //Now, redraw all samples between current and last redrawn sample, inclusive
389  //Go from the smaller to larger sample.
390  const auto start = std::min(s0, mLastDragSample);
391  const auto end = std::max(s0, mLastDragSample);
392  // Few enough samples to be drawn individually on screen will not
393  // overflow size_t:
394  const auto size = ( end - start + 1 ).as_size_t();
395  if (size == 1) {
396  mClickedTrack->Set((samplePtr)&newLevel, floatSample, start, size);
397  }
398  else {
399  std::vector<float> values(size);
400  for (auto ii = start; ii <= end; ++ii) {
401  //This interpolates each sample linearly:
402  // i - start will not overflow size_t either:
403  values[( ii - start ).as_size_t()] =
405  (ii - mLastDragSample).as_float() /
406  (s0 - mLastDragSample).as_float();
407  }
408  mClickedTrack->Set((samplePtr)&values[0], floatSample, start, size);
409  }
410 
411  //Update the member data structures.
412  mLastDragSample = s0;
413  mLastDragSampleValue = newLevel;
414 
415  return RefreshCell;
416 }
wxRect mRect
Definition: SampleHandle.h:74
ViewInfo is used mainly to hold the zooming, selection and scroll information. It also has some statu...
Definition: ViewInfo.h:141
Result Cancel(AudacityProject *pProject) override
std::shared_ptr< WaveTrack > mClickedTrack
Definition: SampleHandle.h:73
float mLastDragSampleValue
Definition: SampleHandle.h:78
sampleCount mLastDragSample
Definition: SampleHandle.h:77
sampleCount mClickedStartSample
Definition: SampleHandle.h:76
char * samplePtr
Definition: Types.h:203
int min(int a, int b)
bool IsAudioActive() const
Definition: Project.cpp:1454
const ViewInfo & GetViewInfo() const
Definition: Project.h:207
float FindSampleEditingLevel(const wxMouseEvent &event, const ViewInfo &viewInfo, double t0)
void SampleHandle::Enter ( bool  forward)
overridevirtual

Reimplemented from UIHandle.

Definition at line 43 of file SampleHandle.cpp.

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

44 {
45 #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
47 #endif
48 }
Result mChangeHighlight
Definition: UIHandle.h:150
float SampleHandle::FindSampleEditingLevel ( const wxMouseEvent &  event,
const ViewInfo viewInfo,
double  t0 
)
private

Definition at line 454 of file SampleHandle.cpp.

References Envelope::GetValue(), min(), and ValueOfPixel().

455 {
456  // Calculate where the mouse is located vertically (between +/- 1)
457  float zoomMin, zoomMax;
458  mClickedTrack->GetDisplayBounds(&zoomMin, &zoomMax);
459 
460  const int yy = event.m_y - mRect.y;
461  const int height = mRect.GetHeight();
462  const bool dB = !mClickedTrack->GetWaveformSettings().isLinear();
463  float newLevel =
464  ::ValueOfPixel(yy, height, false, dB,
465  mClickedTrack->GetWaveformSettings().dBRange, zoomMin, zoomMax);
466 
467  //Take the envelope into account
468  Envelope *const env = mClickedTrack->GetEnvelopeAtX(event.m_x);
469  if (env)
470  {
471  // Calculate sample as it would be rendered, so quantize time
472  double envValue = env->GetValue( t0, 1.0 / mClickedTrack->GetRate());
473  if (envValue > 0)
474  newLevel /= envValue;
475  else
476  newLevel = 0;
477 
478  //Make sure the NEW level is between +/-1
479  newLevel = std::max(-1.0f, std::min(1.0f, newLevel));
480  }
481 
482  return newLevel;
483 }
wxRect mRect
Definition: SampleHandle.h:74
std::shared_ptr< WaveTrack > mClickedTrack
Definition: SampleHandle.h:73
Draggable curve used in TrackPanel for varying amplification.
Definition: Envelope.h:77
float ValueOfPixel(int yy, int height, bool offset, bool dB, double dBRange, float zoomMin, float zoomMax)
int min(int a, int b)
std::shared_ptr<WaveTrack> SampleHandle::GetTrack ( ) const
inline

Definition at line 47 of file SampleHandle.h.

References mClickedTrack.

Referenced by TrackArtist::DrawClipWaveform().

47 { return mClickedTrack; }
std::shared_ptr< WaveTrack > mClickedTrack
Definition: SampleHandle.h:73
UIHandlePtr SampleHandle::HitAnywhere ( std::weak_ptr< SampleHandle > &  holder,
const wxMouseState &  state,
const std::shared_ptr< WaveTrack > &  pTrack 
)
static

Definition at line 74 of file SampleHandle.cpp.

References AssignUIHandlePtr().

Referenced by WaveTrack::DetailedHitTest().

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:162
HitTestPreview SampleHandle::HitPreview ( const wxMouseState &  state,
const AudacityProject pProject,
bool  unsafe 
)
staticprivate

Definition at line 51 of file SampleHandle.cpp.

References _(), and MakeCursor().

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 = _("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 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:274
UIHandlePtr SampleHandle::HitTest ( std::weak_ptr< SampleHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
const AudacityProject pProject,
const std::shared_ptr< WaveTrack > &  pTrack 
)
static

Definition at line 112 of file SampleHandle.cpp.

References WaveformSettings::dBRange, fillZero, floatSample, WaveTrack::Get(), WaveTrack::GetDisplay(), WaveTrack::GetDisplayBounds(), WaveTrack::GetEnvelopeAtX(), WaveTrack::GetRate(), Envelope::GetValue(), AudacityProject::GetViewInfo(), WaveTrack::GetWaveformSettings(), GetWaveYPos(), if(), WaveformSettings::isLinear(), ZoomInfo::PositionToTime(), and WaveTrack::Waveform.

Referenced by WaveTrack::DetailedHitTest().

115 {
116  const ViewInfo &viewInfo = pProject->GetViewInfo();
117 
118  WaveTrack *wavetrack = pTrack.get();
119 
120  const int displayType = wavetrack->GetDisplay();
121  if (WaveTrack::Waveform != displayType)
122  return {}; // Not a wave, so return.
123 
124  const double tt =
125  adjustTime(wavetrack, viewInfo.PositionToTime(state.m_x, rect.x));
126  if (!SampleResolutionTest(viewInfo, wavetrack, tt, rect.width))
127  return {};
128 
129  // Just get one sample.
130  float oneSample;
131  const double rate = wavetrack->GetRate();
132  const auto s0 = (sampleCount)(tt * rate + 0.5);
133  if (! wavetrack->Get((samplePtr)&oneSample, floatSample, s0, 1, fillZero,
134  // Do not propagate exception but return a failure value
135  false) )
136  return {};
137 
138  // Get y distance of envelope point from center line (in pixels).
139  float zoomMin, zoomMax;
140 
141  wavetrack->GetDisplayBounds(&zoomMin, &zoomMax);
142 
143  double envValue = 1.0;
144  Envelope* env = wavetrack->GetEnvelopeAtX(state.GetX());
145  if (env)
146  // Calculate sample as it would be rendered, so quantize time
147  envValue = env->GetValue( tt, 1.0 / wavetrack->GetRate() );
148 
149  const bool dB = !wavetrack->GetWaveformSettings().isLinear();
150  int yValue = GetWaveYPos(oneSample * envValue,
151  zoomMin, zoomMax,
152  rect.height, dB, true,
153  wavetrack->GetWaveformSettings().dBRange, false) + rect.y;
154 
155  // Get y position of mouse (in pixels)
156  int yMouse = state.m_y;
157 
158  // Perhaps yTolerance should be put into preferences?
159  const int yTolerance = 10; // More tolerance on samples than on envelope.
160  if (abs(yValue - yMouse) >= yTolerance)
161  return {};
162 
163  return HitAnywhere(holder, state, pTrack);
164 }
bool isLinear() const
ViewInfo is used mainly to hold the zooming, selection and scroll information. It also has some statu...
Definition: ViewInfo.h:141
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:738
Envelope * GetEnvelopeAtX(int xcoord)
Definition: WaveTrack.cpp:2211
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ViewInfo.cpp:49
Draggable curve used in TrackPanel for varying amplification.
Definition: Envelope.h:77
void GetDisplayBounds(float *min, float *max) const
Definition: WaveTrack.cpp:325
static UIHandlePtr HitAnywhere(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const std::shared_ptr< WaveTrack > &pTrack)
char * samplePtr
Definition: Types.h:203
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
if(pTrack &&pTrack->GetDisplay()!=WaveTrack::Spectrum)
double GetValue(double t, double sampleDur=0) const
Get envelope value at time t.
Definition: Envelope.cpp:1114
double GetRate() const
Definition: WaveTrack.cpp:398
bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumCopied=nullptr) const
Definition: WaveTrack.cpp:1971
WaveTrackDisplay GetDisplay() const
Definition: WaveTrack.h:593
int GetWaveYPos(float value, float min, float max, int height, bool dB, bool outer, float dBr, bool clip)
const ViewInfo & GetViewInfo() const
Definition: Project.h:207
SampleHandle& SampleHandle::operator= ( const SampleHandle )
default
HitTestPreview SampleHandle::Preview ( const TrackPanelMouseState state,
const AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 419 of file SampleHandle.cpp.

References AudacityProject::IsAudioActive(), and TrackPanelMouseState::state.

420 {
421  const bool unsafe = pProject->IsAudioActive();
422  return HitPreview(st.state, pProject, unsafe);
423 }
static HitTestPreview HitPreview(const wxMouseState &state, const AudacityProject *pProject, bool unsafe)
bool IsAudioActive() const
Definition: Project.cpp:1454
UIHandle::Result SampleHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overridevirtual

Implements UIHandle.

Definition at line 426 of file SampleHandle.cpp.

References _(), AUTOSAVE, CONSOLIDATE, AudacityProject::IsAudioActive(), AudacityProject::PushState(), and RefreshCode::RefreshNone.

428 {
429  const bool unsafe = pProject->IsAudioActive();
430  if (unsafe)
431  return this->Cancel(pProject);
432 
433  //*************************************************
434  //*** UP-CLICK (Finish drawing) ***
435  //*************************************************
436  //On up-click, send the state to the undo stack
437  mClickedTrack.reset(); //Set this to NULL so it will catch improper drag events.
438  pProject->PushState(_("Moved Samples"),
439  _("Sample Edit"),
441 
442  // No change to draw since last drag
444 }
Result Cancel(AudacityProject *pProject) override
std::shared_ptr< WaveTrack > mClickedTrack
Definition: SampleHandle.h:73
bool IsAudioActive() const
Definition: Project.cpp:1454
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void PushState(const wxString &desc, const wxString &shortDesc)
Definition: Project.cpp:4702
bool SampleHandle::StopsOnKeystroke ( )
inlineoverridevirtual

Reimplemented from UIHandle.

Definition at line 67 of file SampleHandle.h.

67 { return true; }

Member Data Documentation

bool SampleHandle::mAltKey {}
private

Definition at line 79 of file SampleHandle.h.

sampleCount SampleHandle::mClickedStartSample {}
private

Definition at line 76 of file SampleHandle.h.

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

Definition at line 73 of file SampleHandle.h.

Referenced by GetTrack().

sampleCount SampleHandle::mLastDragSample {}
private

Definition at line 77 of file SampleHandle.h.

float SampleHandle::mLastDragSampleValue {}
private

Definition at line 78 of file SampleHandle.h.

wxRect SampleHandle::mRect {}
private

Definition at line 74 of file SampleHandle.h.


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