Audacity 3.2.0
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
SubViewRearrangeHandle Class Reference
Inheritance diagram for SubViewRearrangeHandle:
[legend]
Collaboration diagram for SubViewRearrangeHandle:
[legend]

Public Types

enum  { HotZoneWidth = 3 * kTrackInfoBtnSize / 2 }
 
enum  DragChoice_t { Upward , Downward , Neutral }
 
- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 

Public Member Functions

 SubViewRearrangeHandle (SubViewAdjuster &&adjuster, size_t subViewIndex, wxCoord viewHeight)
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
bool Clicked () const
 
DragChoice_t DragChoice (const TrackPanelMouseEvent &event) const
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *) override
 
HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
Result Cancel (AudacityProject *) 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 HitTest (std::weak_ptr< SubViewRearrangeHandle > &holder, WaveTrackView &view, WaveTrackSubView &subView, const TrackPanelMouseState &state)
 
- 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 Attributes

SubViewAdjuster mAdjuster
 
std::vector< wxCoord > mHeights
 
wxCoord mTopY
 
size_t mMySubView {}
 
wxCoord mViewHeight {}
 

Additional Inherited Members

- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 430 of file WaveTrackView.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
HotZoneWidth 

Definition at line 434 of file WaveTrackView.cpp.

434{ HotZoneWidth = 3 * kTrackInfoBtnSize / 2 };
@ kTrackInfoBtnSize
Definition: ViewInfo.h:95

◆ DragChoice_t

Enumerator
Upward 
Downward 
Neutral 

Definition at line 509 of file WaveTrackView.cpp.

Constructor & Destructor Documentation

◆ SubViewRearrangeHandle()

SubViewRearrangeHandle::SubViewRearrangeHandle ( SubViewAdjuster &&  adjuster,
size_t  subViewIndex,
wxCoord  viewHeight 
)
inline

Definition at line 477 of file WaveTrackView.cpp.

480 : mAdjuster{ std::move( adjuster ) }
481 , mMySubView{ subViewIndex }
482 , mViewHeight{ viewHeight }
483 {
484 }
SubViewAdjuster mAdjuster

Member Function Documentation

◆ Cancel()

Result SubViewRearrangeHandle::Cancel ( AudacityProject )
inlineoverridevirtual

Implements UIHandle.

Definition at line 601 of file WaveTrackView.cpp.

602 {
603 mAdjuster.UpdateViews( true );
605 }
void UpdateViews(bool rollback)

References mAdjuster, RefreshCode::RefreshAll, and SubViewAdjuster::UpdateViews().

Here is the call graph for this function:

◆ Click()

Result SubViewRearrangeHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
inlineoverridevirtual

Implements UIHandle.

Definition at line 486 of file WaveTrackView.cpp.

488 {
489 using namespace RefreshCode;
490 const auto &permutation = mAdjuster.mPermutation;
491 const auto size = permutation.size();
492 if ( mMySubView >= size )
493 return Cancelled;
494
496
497 // Find y coordinate of first sub-view
498 wxCoord heightAbove = 0;
499 for (auto index = mAdjuster.mFirstSubView;
500 index != mMySubView; ++index)
501 heightAbove += mHeights[ index ];
502 mTopY = event.rect.GetTop() - heightAbove;
503
504 return RefreshNone;
505 }
std::vector< wxCoord > mHeights
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
std::vector< wxCoord > ComputeHeights(wxCoord totalHeight)
std::vector< size_t > mPermutation

References RefreshCode::Cancelled, SubViewAdjuster::ComputeHeights(), mAdjuster, SubViewAdjuster::mFirstSubView, mHeights, mMySubView, SubViewAdjuster::mPermutation, mTopY, mViewHeight, RefreshCode::RefreshNone, and size.

Here is the call graph for this function:

◆ Clicked()

bool SubViewRearrangeHandle::Clicked ( ) const
inline

Definition at line 507 of file WaveTrackView.cpp.

507{ return !mHeights.empty(); }

References mHeights.

Referenced by Preview().

Here is the caller graph for this function:

◆ Drag()

Result SubViewRearrangeHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject  
)
inlineoverridevirtual

Implements UIHandle.

Definition at line 542 of file WaveTrackView.cpp.

543 {
544 using namespace RefreshCode;
545 auto pView = mAdjuster.mwView.lock();
546 if ( !pView )
547 return Cancelled;
548
549 switch( DragChoice( event ) ) {
550 case Upward:
551 {
553 std::swap(
556 );
557 --mMySubView;
558 break;
559 }
560 case Downward:
561 {
563 std::swap(
566 );
567 ++mMySubView;
568 break;
569 }
570 default:
571 return RefreshNone;
572 }
573
574 // Save adjustment to the track and request a redraw
575 mAdjuster.UpdateViews( false );
576 return RefreshAll;
577 }
DragChoice_t DragChoice(const TrackPanelMouseEvent &event) const
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:753
WaveTrackSubViewPlacements mNewPlacements
std::weak_ptr< WaveTrackView > mwView

References RefreshCode::Cancelled, Downward, DragChoice(), mAdjuster, mHeights, mMySubView, SubViewAdjuster::mNewPlacements, SubViewAdjuster::mwView, RefreshCode::RefreshAll, RefreshCode::RefreshNone, anonymous_namespace{NoteTrack.cpp}::swap(), SubViewAdjuster::UpdateViews(), and Upward.

Here is the call graph for this function:

◆ DragChoice()

DragChoice_t SubViewRearrangeHandle::DragChoice ( const TrackPanelMouseEvent event) const
inline

Definition at line 511 of file WaveTrackView.cpp.

512 {
513 // Disregard x coordinate -- so the mouse need not be in any sub-view,
514 // just in the correct range of y coordinates
515 auto yy = event.event.GetY();
516 auto coord = mTopY;
517 size_t ii = mAdjuster.mFirstSubView;
518 if ( yy < mTopY )
519 return ( mMySubView == ii ) ? Neutral : Upward;
520
521 for ( auto nn = mHeights.size(); ii < nn; ++ii ) {
522 const auto height = mHeights[ ii ];
523 coord += height;
524 if ( yy < coord )
525 break;
526 }
527
528 if ( ii < mMySubView ) {
529 if ( yy < coord - mHeights[ ii ] + mHeights[ mMySubView ] )
530 return Upward;
531 }
532
533 if ( ii > mMySubView ) {
534 if( mMySubView < mHeights.size() - 1 &&
535 yy >= coord - mHeights[ mMySubView ] )
536 return Downward;
537 }
538
539 return Neutral;
540 }

References Downward, mAdjuster, SubViewAdjuster::mFirstSubView, mHeights, mMySubView, mTopY, Neutral, and Upward.

Referenced by Drag().

Here is the caller graph for this function:

◆ HitTest()

static UIHandlePtr SubViewRearrangeHandle::HitTest ( std::weak_ptr< SubViewRearrangeHandle > &  holder,
WaveTrackView view,
WaveTrackSubView subView,
const TrackPanelMouseState state 
)
inlinestatic

Definition at line 436 of file WaveTrackView.cpp.

439 {
440 if ( !view.GetMultiView() )
441 return {};
442
443 SubViewAdjuster adjuster{ view };
444 if ( adjuster.NVisible() < 2 )
445 return {};
446
447 auto relX = state.state.GetX() - state.rect.GetLeft();
448 if ( relX >= HotZoneWidth )
449 return {};
450
451 auto index = adjuster.FindIndex( subView );
452
453 // Hit on the rearrange cursor only in the top and bottom thirds of
454 // sub-view height, leaving the rest free to hit the selection cursor
455 // first.
456 // And also exclude the top third of the topmost sub-view and bottom
457 // third of bottommost.
458 auto relY = state.state.GetY() - state.rect.GetTop();
459 auto height = state.rect.GetHeight();
460 bool hit =
461 ( ( 3 * relY < height ) && index > 0 ) // top hit
462 ||
463 ( ( 3 * relY > 2 * height ) &&
464 index < adjuster.mPermutation.size() - 1 ) // bottom
465 ;
466 if ( ! hit )
467 return {};
468
469 auto result = std::make_shared< SubViewRearrangeHandle >(
470 std::move( adjuster ),
471 index, view.GetLastHeight()
472 );
473 result = AssignUIHandlePtr( holder, result );
474 return result;
475 }
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
wxCoord GetLastHeight() const
bool GetMultiView() const

References AssignUIHandlePtr(), WaveTrackView::GetLastHeight(), WaveTrackView::GetMultiView(), HotZoneWidth, TrackPanelMouseState::rect, and TrackPanelMouseState::state.

Referenced by WaveTrackSubView::DoDetailedHitTest().

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

◆ Preview()

HitTestPreview SubViewRearrangeHandle::Preview ( const TrackPanelMouseState state,
AudacityProject  
)
inlineoverridevirtual

Implements UIHandle.

Definition at line 579 of file WaveTrackView.cpp.

581 {
582 static auto hoverCursor =
583 ::MakeCursor(wxCURSOR_HAND, RearrangeCursorXpm, 16, 16);
584 static auto clickedCursor =
585 ::MakeCursor(wxCURSOR_HAND, RearrangingCursorXpm, 16, 16);
586 return {
587 XO("Click and drag to rearrange sub-views"),
588 Clicked() ? &*clickedCursor : &*hoverCursor,
589 XO("Rearrange sub-views")
590 };
591 }
#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 Clicked(), MakeCursor(), and XO.

Here is the call graph for this function:

◆ Release()

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

Implements UIHandle.

Definition at line 593 of file WaveTrackView.cpp.

596 {
597 ProjectHistory::Get( *pProject ).ModifyState( false );
599 }
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)

References ProjectHistory::Get(), ProjectHistory::ModifyState(), and RefreshCode::RefreshNone.

Here is the call graph for this function:

Member Data Documentation

◆ mAdjuster

SubViewAdjuster SubViewRearrangeHandle::mAdjuster
private

Definition at line 609 of file WaveTrackView.cpp.

Referenced by Cancel(), Click(), Drag(), and DragChoice().

◆ mHeights

std::vector<wxCoord> SubViewRearrangeHandle::mHeights
private

Definition at line 610 of file WaveTrackView.cpp.

Referenced by Click(), Clicked(), Drag(), and DragChoice().

◆ mMySubView

size_t SubViewRearrangeHandle::mMySubView {}
private

Definition at line 614 of file WaveTrackView.cpp.

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

◆ mTopY

wxCoord SubViewRearrangeHandle::mTopY
private

Definition at line 611 of file WaveTrackView.cpp.

Referenced by Click(), and DragChoice().

◆ mViewHeight

wxCoord SubViewRearrangeHandle::mViewHeight {}
private

Definition at line 616 of file WaveTrackView.cpp.

Referenced by Click().


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