Audacity 3.2.0
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
AdornedRulerPanel::PlayRegionAdjustingHandle Class Referenceabstract
Inheritance diagram for AdornedRulerPanel::PlayRegionAdjustingHandle:
[legend]
Collaboration diagram for AdornedRulerPanel::PlayRegionAdjustingHandle:
[legend]

Public Member Functions

 PlayRegionAdjustingHandle (AdornedRulerPanel *pParent, wxCoord xx, MenuChoice menuChoice, wxCursor *cursor, size_t numGuides=1)
 
 PlayRegionAdjustingHandle (AdornedRulerPanel *pParent, wxCoord xx, MenuChoice menuChoice, wxCursor cursor, size_t numGuides=1)
 
void SetCursor (wxCursor cursor)
 
HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
Result Cancel (AudacityProject *pProject) override
 
bool HasEscape (AudacityProject *pProject) const override
 
bool Escape (AudacityProject *pProject) override
 
- Public Member Functions inherited from AdornedRulerPanel::CommonRulerHandle
 CommonRulerHandle (AdornedRulerPanel *pParent, wxCoord xx, MenuChoice menuChoice)
 
std::shared_ptr< const ChannelFindChannel () const override
 
bool Clicked () const
 
- 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)
 
virtual std::shared_ptr< const ChannelFindChannel () const =0
 
virtual bool IsDragging () const
 
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)
 

Protected Member Functions

double SnappedTime (AudacityProject &project, size_t ii)
 
std::pair< double, double > SnappedTimes (AudacityProject &project)
 
void Unsnap (bool use, AudacityProject *pProject)
 
virtual void DoStartAdjust (AudacityProject &, double)=0
 
virtual void DoAdjust (AudacityProject &)=0
 
void SavePlayRegion (AudacityProject &project)
 
- Protected Member Functions inherited from AdornedRulerPanel::CommonRulerHandle
bool HandlesRightClick () override
 Whether the handle has any special right-button handling. More...
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *) override
 
Result Drag (const TrackPanelMouseEvent &, AudacityProject *) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *, wxWindow *) override
 
double Time (AudacityProject &project) const
 
void StartPlay (AudacityProject &project, const wxMouseEvent &event)
 
Result Cancel (AudacityProject *) override
 
void Enter (bool, AudacityProject *) override
 

Private Attributes

wxCursor mCursor
 
size_t mNumGuides
 
SelectedRegion mOldSelectedRegion
 
double mOldStart = 0.0
 
double mOldEnd = 0.0
 
bool mWasActive = false
 
bool mSaved = false
 
bool mDragged = false
 

Additional Inherited Members

- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Static Public Member Functions inherited from AdornedRulerPanel::CommonRulerHandle
static UIHandle::Result NeedChangeHighlight (const CommonRulerHandle &oldState, const CommonRulerHandle &newState)
 
- 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)
 
- Protected Types inherited from AdornedRulerPanel::CommonRulerHandle
enum class  Button { None , Left , Right }
 
- Protected Attributes inherited from AdornedRulerPanel::CommonRulerHandle
wxWeakRef< AdornedRulerPanelmParent
 
wxCoord mX
 
wxCoord mClickedX
 
MenuChoice mChoice
 
Button mClicked { Button::None }
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 216 of file AdornedRulerPanel.cpp.

Constructor & Destructor Documentation

◆ PlayRegionAdjustingHandle() [1/2]

AdornedRulerPanel::PlayRegionAdjustingHandle::PlayRegionAdjustingHandle ( AdornedRulerPanel pParent,
wxCoord  xx,
MenuChoice  menuChoice,
wxCursor *  cursor,
size_t  numGuides = 1 
)
inline

Definition at line 218 of file AdornedRulerPanel.cpp.

222 : CommonRulerHandle{ pParent, xx, menuChoice }
223 , mNumGuides{ numGuides }
224 {
225 if (cursor) {
226 mCursor = *cursor;
227 }
228 }
CommonRulerHandle(AdornedRulerPanel *pParent, wxCoord xx, MenuChoice menuChoice)

References mCursor.

◆ PlayRegionAdjustingHandle() [2/2]

AdornedRulerPanel::PlayRegionAdjustingHandle::PlayRegionAdjustingHandle ( AdornedRulerPanel pParent,
wxCoord  xx,
MenuChoice  menuChoice,
wxCursor  cursor,
size_t  numGuides = 1 
)
inline

Definition at line 230 of file AdornedRulerPanel.cpp.

234 : CommonRulerHandle{ pParent, xx, menuChoice }
235 , mCursor{ cursor }
236 , mNumGuides{ numGuides }
237 {}

Member Function Documentation

◆ Cancel()

Result AdornedRulerPanel::PlayRegionAdjustingHandle::Cancel ( AudacityProject pProject)
inlineoverridevirtual

Restore state as before SavePlayRegion()

Reimplemented from AdornedRulerPanel::CommonRulerHandle.

Definition at line 309 of file AdornedRulerPanel.cpp.

310 {
311 using namespace RefreshCode;
312 auto result = CommonRulerHandle::Cancel(pProject);
313 if (!mSaved)
314 return result;
315
317 auto &viewInfo = ViewInfo::Get(*pProject);
318 viewInfo.selectedRegion = mOldSelectedRegion;
319 auto &playRegion = viewInfo.playRegion;
320 playRegion.SetTimes(mOldStart, mOldEnd);
321 if (!mWasActive)
322 playRegion.SetActive(false);
323
324 return RefreshAll;
325 }
Result Cancel(AudacityProject *) override
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References AdornedRulerPanel::CommonRulerHandle::Cancel(), ViewInfo::Get(), mOldEnd, mOldSelectedRegion, mOldStart, mSaved, mWasActive, and RefreshCode::RefreshAll.

Here is the call graph for this function:

◆ DoAdjust()

virtual void AdornedRulerPanel::PlayRegionAdjustingHandle::DoAdjust ( AudacityProject )
protectedpure virtual

Implemented in AdornedRulerPanel::MovePlayRegionHandle, AdornedRulerPanel::ResizePlayRegionHandle, and AdornedRulerPanel::NewPlayRegionHandle.

Referenced by Drag(), and Unsnap().

Here is the caller graph for this function:

◆ DoStartAdjust()

virtual void AdornedRulerPanel::PlayRegionAdjustingHandle::DoStartAdjust ( AudacityProject ,
double   
)
protectedpure virtual

Implemented in AdornedRulerPanel::ResizePlayRegionHandle, AdornedRulerPanel::NewPlayRegionHandle, and AdornedRulerPanel::MovePlayRegionHandle.

Referenced by Drag().

Here is the caller graph for this function:

◆ Drag()

Result AdornedRulerPanel::PlayRegionAdjustingHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
inlineoverridevirtual

Reimplemented from AdornedRulerPanel::CommonRulerHandle.

Definition at line 257 of file AdornedRulerPanel.cpp.

259 {
260 using namespace RefreshCode;
261 auto result = CommonRulerHandle::Drag(event, pProject);
262 if (0 != (result & Cancelled) || mClicked != Button::Left)
263 return result;
264
265 auto &ruler = AdornedRulerPanel::Get(*pProject);
266 mX = event.event.m_x;
267 ruler.UpdateQuickPlayPos(event.event.m_x);
268
269 if (!mDragged) {
270 if (fabs(mX - mClickedX) < SELECT_TOLERANCE_PIXEL)
271 // Don't start a drag yet for a small mouse movement
272 return RefreshNone;
273 SavePlayRegion(*pProject);
274 const auto time = SnappedTime(*pProject, 0);
275 DoStartAdjust(*pProject, time);
276 mDragged = true;
277 }
278 else
279 DoAdjust(*pProject);
280
282 DragSelection(*pProject);
283
284 return RefreshAll;
285 }
#define SELECT_TOLERANCE_PIXEL
Result Drag(const TrackPanelMouseEvent &, AudacityProject *) override
virtual void DoAdjust(AudacityProject &)=0
virtual void DoStartAdjust(AudacityProject &, double)=0
double SnappedTime(AudacityProject &project, size_t ii)
void SavePlayRegion(AudacityProject &project)
static void DragSelection(AudacityProject &project)
static AdornedRulerPanel & Get(AudacityProject &project)

References Cancelled, DoAdjust(), DoStartAdjust(), AdornedRulerPanel::CommonRulerHandle::Drag(), AdornedRulerPanel::DragSelection(), TrackPanelMouseEvent::event, AdornedRulerPanel::Get(), AdornedRulerPanel::CommonRulerHandle::Left, AdornedRulerPanel::CommonRulerHandle::mClicked, AdornedRulerPanel::CommonRulerHandle::mClickedX, mDragged, AdornedRulerPanel::mPlayRegionDragsSelection, AdornedRulerPanel::CommonRulerHandle::mX, RefreshCode::RefreshAll, RefreshCode::RefreshNone, anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), SavePlayRegion(), SELECT_TOLERANCE_PIXEL, and SnappedTime().

Here is the call graph for this function:

◆ Escape()

bool AdornedRulerPanel::PlayRegionAdjustingHandle::Escape ( AudacityProject pProject)
inlineoverridevirtual

Reimplemented from UIHandle.

Definition at line 337 of file AdornedRulerPanel.cpp.

338 {
339 if (HasEscape(pProject)) {
340 Unsnap(false, pProject);
341 return true;
342 }
343 return false;
344 }
void Unsnap(bool use, AudacityProject *pProject)
bool HasEscape(AudacityProject *pProject) const override

References HasEscape(), and Unsnap().

Here is the call graph for this function:

◆ HasEscape()

bool AdornedRulerPanel::PlayRegionAdjustingHandle::HasEscape ( AudacityProject pProject) const
inlineoverridevirtual

Reimplemented from UIHandle.

Definition at line 329 of file AdornedRulerPanel.cpp.

330 {
331 auto &ruler = AdornedRulerPanel::Get(*pProject);
332 auto values = ruler.mIsSnapped;
333 auto identity = [](auto x){ return x; }; // in the C++20 standard...
334 return std::any_of( values, values + ruler.mNumGuides, identity );
335 }
const wxChar * values

References AdornedRulerPanel::Get(), anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler(), and values.

Referenced by Escape().

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

◆ Preview()

HitTestPreview AdornedRulerPanel::PlayRegionAdjustingHandle::Preview ( const TrackPanelMouseState state,
AudacityProject pProject 
)
inlineoverridevirtual

Implements UIHandle.

Definition at line 244 of file AdornedRulerPanel.cpp.

247 {
248 mParent->SetNumGuides(mNumGuides);
249 const auto message = XO("Click and drag to define a looping region.");
250 return {
251 message,
252 &mCursor,
253 message
254 };
255 }
XO("Cut/Copy/Paste")
wxWeakRef< AdornedRulerPanel > mParent

References mCursor, mNumGuides, AdornedRulerPanel::CommonRulerHandle::mParent, and XO().

Here is the call graph for this function:

◆ Release()

Result AdornedRulerPanel::PlayRegionAdjustingHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
inlineoverridevirtual

Reimplemented from AdornedRulerPanel::CommonRulerHandle.

Definition at line 287 of file AdornedRulerPanel.cpp.

291 {
292 using namespace RefreshCode;
293 auto result = CommonRulerHandle::Release(event, pProject, pParent);
294
295 if (mClicked == Button::Left && !mDragged)
296 StartPlay(*pProject, event.event);
297
298 if (!mDragged || 0 != (result & Cancelled))
299 return result;
300
301 // Set the play region endpoints correctly even if not strictly needed
302 auto &viewInfo = ViewInfo::Get( *pProject );
303 auto &playRegion = viewInfo.playRegion;
304 playRegion.Order();
305
306 return result;
307 }
Result Release(const TrackPanelMouseEvent &event, AudacityProject *, wxWindow *) override
void StartPlay(AudacityProject &project, const wxMouseEvent &event)

References Cancelled, TrackPanelMouseEvent::event, ViewInfo::Get(), AdornedRulerPanel::CommonRulerHandle::Left, AdornedRulerPanel::CommonRulerHandle::mClicked, mDragged, AdornedRulerPanel::CommonRulerHandle::Release(), and AdornedRulerPanel::CommonRulerHandle::StartPlay().

Here is the call graph for this function:

◆ SavePlayRegion()

void AdornedRulerPanel::PlayRegionAdjustingHandle::SavePlayRegion ( AudacityProject project)
inlineprotected

Definition at line 387 of file AdornedRulerPanel.cpp.

388 {
389 auto &viewInfo = ViewInfo::Get(project);
390 mOldSelectedRegion = viewInfo.selectedRegion;
391 auto &playRegion = viewInfo.playRegion;
392 mWasActive = playRegion.Active();
393 mOldStart = playRegion.GetLastActiveStart();
394 mOldEnd = playRegion.GetLastActiveEnd();
395 if (!mWasActive)
396 playRegion.SetActive(true);
397 mSaved = true;
398 }
const auto project

References ViewInfo::Get(), mOldEnd, mOldSelectedRegion, mOldStart, mSaved, mWasActive, and project.

Referenced by Drag().

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

◆ SetCursor()

void AdornedRulerPanel::PlayRegionAdjustingHandle::SetCursor ( wxCursor  cursor)
inline

Definition at line 239 of file AdornedRulerPanel.cpp.

240 {
241 mCursor = cursor;
242 }

References mCursor.

Referenced by AdornedRulerPanel::MovePlayRegionHandle::MovePlayRegionHandle().

Here is the caller graph for this function:

◆ SnappedTime()

double AdornedRulerPanel::PlayRegionAdjustingHandle::SnappedTime ( AudacityProject project,
size_t  ii 
)
inlineprotected

Definition at line 348 of file AdornedRulerPanel.cpp.

349 {
350 const auto &ruler = AdornedRulerPanel::Get(project);
351 bool isSnapped = ruler.mIsSnapped[ii];
352 return isSnapped
353 ? ruler.mQuickPlayPos[ii]
354 : ruler.mQuickPlayPosUnsnapped[ii];
355 }

References AdornedRulerPanel::Get(), project, and anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler().

Referenced by AdornedRulerPanel::ResizePlayRegionHandle::DoAdjust(), AdornedRulerPanel::NewPlayRegionHandle::DoAdjust(), and Drag().

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

◆ SnappedTimes()

std::pair< double, double > AdornedRulerPanel::PlayRegionAdjustingHandle::SnappedTimes ( AudacityProject project)
inlineprotected

Definition at line 357 of file AdornedRulerPanel.cpp.

358 {
359 const auto &ruler = AdornedRulerPanel::Get(project);
360 for (size_t ii = 0; ii < ruler.mNumGuides; ++ii)
361 if (ruler.mIsSnapped[ii]) {
362 double time0 = ruler.mQuickPlayPos[ii];
363 double delta = time0 - ruler.mQuickPlayPosUnsnapped[ii];
364 double time1 = ruler.mQuickPlayPosUnsnapped[1 - ii] + delta;
365 if (ii == 1)
366 return { time1, time0 };
367 else
368 return { time0, time1 };
369 }
370 // No snap
371 return { ruler.mQuickPlayPos[0], ruler.mQuickPlayPos[1] };
372 }

References AdornedRulerPanel::Get(), project, and anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler().

Referenced by AdornedRulerPanel::MovePlayRegionHandle::DoAdjust().

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

◆ Unsnap()

void AdornedRulerPanel::PlayRegionAdjustingHandle::Unsnap ( bool  use,
AudacityProject pProject 
)
inlineprotected

Definition at line 374 of file AdornedRulerPanel.cpp.

375 {
376 auto &ruler = AdornedRulerPanel::Get(*pProject);
377 std::fill( ruler.mIsSnapped, ruler.mIsSnapped + ruler.mNumGuides, false );
378 // Repaint to turn the snap lines on or off
380 if (Clicked())
381 DoAdjust(*pProject);
382 }
Result mChangeHighlight
Definition: UIHandle.h:147

References AdornedRulerPanel::CommonRulerHandle::Clicked(), DoAdjust(), AdornedRulerPanel::Get(), UIHandle::mChangeHighlight, RefreshCode::RefreshAll, and anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler().

Referenced by Escape().

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

Member Data Documentation

◆ mCursor

wxCursor AdornedRulerPanel::PlayRegionAdjustingHandle::mCursor
private

Definition at line 402 of file AdornedRulerPanel.cpp.

Referenced by PlayRegionAdjustingHandle(), Preview(), and SetCursor().

◆ mDragged

bool AdornedRulerPanel::PlayRegionAdjustingHandle::mDragged = false
private

Definition at line 409 of file AdornedRulerPanel.cpp.

Referenced by Drag(), and Release().

◆ mNumGuides

size_t AdornedRulerPanel::PlayRegionAdjustingHandle::mNumGuides
private

Definition at line 403 of file AdornedRulerPanel.cpp.

Referenced by Preview().

◆ mOldEnd

double AdornedRulerPanel::PlayRegionAdjustingHandle::mOldEnd = 0.0
private

Definition at line 406 of file AdornedRulerPanel.cpp.

Referenced by Cancel(), and SavePlayRegion().

◆ mOldSelectedRegion

SelectedRegion AdornedRulerPanel::PlayRegionAdjustingHandle::mOldSelectedRegion
private

Definition at line 405 of file AdornedRulerPanel.cpp.

Referenced by Cancel(), and SavePlayRegion().

◆ mOldStart

double AdornedRulerPanel::PlayRegionAdjustingHandle::mOldStart = 0.0
private

Definition at line 406 of file AdornedRulerPanel.cpp.

Referenced by Cancel(), and SavePlayRegion().

◆ mSaved

bool AdornedRulerPanel::PlayRegionAdjustingHandle::mSaved = false
private

Definition at line 408 of file AdornedRulerPanel.cpp.

Referenced by Cancel(), and SavePlayRegion().

◆ mWasActive

bool AdornedRulerPanel::PlayRegionAdjustingHandle::mWasActive = false
private

Definition at line 407 of file AdornedRulerPanel.cpp.

Referenced by Cancel(), and SavePlayRegion().


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