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)
 
std::shared_ptr< const ChannelFindChannel () const override
 
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)
 
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)
 

Static Public Member Functions

static UIHandlePtr HitTest (std::weak_ptr< SubViewRearrangeHandle > &holder, WaveChannelView &view, WaveChannelSubView &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 489 of file WaveChannelView.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
HotZoneWidth 

Definition at line 493 of file WaveChannelView.cpp.

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

◆ DragChoice_t

Enumerator
Upward 
Downward 
Neutral 

Definition at line 576 of file WaveChannelView.cpp.

Constructor & Destructor Documentation

◆ SubViewRearrangeHandle()

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

Definition at line 536 of file WaveChannelView.cpp.

539 : mAdjuster{ std::move( adjuster ) }
540 , mMySubView{ subViewIndex }
541 , mViewHeight{ viewHeight }
542 {
543 }

Member Function Documentation

◆ Cancel()

Result SubViewRearrangeHandle::Cancel ( AudacityProject )
inlineoverridevirtual

Implements UIHandle.

Definition at line 668 of file WaveChannelView.cpp.

669 {
670 mAdjuster.UpdateViews( true );
672 }
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 553 of file WaveChannelView.cpp.

555 {
556 using namespace RefreshCode;
557 const auto &permutation = mAdjuster.mPermutation;
558 const auto size = permutation.size();
559 if ( mMySubView >= size )
560 return Cancelled;
561
563
564 // Find y coordinate of first sub-view
565 wxCoord heightAbove = 0;
566 for (auto index = mAdjuster.mFirstSubView;
567 index != mMySubView; ++index)
568 heightAbove += mHeights[ index ];
569 mTopY = event.rect.GetTop() - heightAbove;
570
571 return RefreshNone;
572 }
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 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 574 of file WaveChannelView.cpp.

574{ 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 609 of file WaveChannelView.cpp.

610 {
611 using namespace RefreshCode;
612 auto pView = mAdjuster.mwView.lock();
613 if ( !pView )
614 return Cancelled;
615
616 switch( DragChoice( event ) ) {
617 case Upward:
618 {
620 std::swap(
623 );
624 --mMySubView;
625 break;
626 }
627 case Downward:
628 {
630 std::swap(
633 );
634 ++mMySubView;
635 break;
636 }
637 default:
638 return RefreshNone;
639 }
640
641 // Save adjustment to the track and request a redraw
642 mAdjuster.UpdateViews( false );
643 return RefreshAll;
644 }
DragChoice_t DragChoice(const TrackPanelMouseEvent &event) const
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:645
WaveChannelSubViewPlacements mNewPlacements
std::weak_ptr< WaveChannelView > mwView

References 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 578 of file WaveChannelView.cpp.

579 {
580 // Disregard x coordinate -- so the mouse need not be in any sub-view,
581 // just in the correct range of y coordinates
582 auto yy = event.event.GetY();
583 auto coord = mTopY;
584 size_t ii = mAdjuster.mFirstSubView;
585 if ( yy < mTopY )
586 return ( mMySubView == ii ) ? Neutral : Upward;
587
588 for ( auto nn = mHeights.size(); ii < nn; ++ii ) {
589 const auto height = mHeights[ ii ];
590 coord += height;
591 if ( yy < coord )
592 break;
593 }
594
595 if ( ii < mMySubView ) {
596 if ( yy < coord - mHeights[ ii ] + mHeights[ mMySubView ] )
597 return Upward;
598 }
599
600 if ( ii > mMySubView ) {
601 if( mMySubView < mHeights.size() - 1 &&
602 yy >= coord - mHeights[ mMySubView ] )
603 return Downward;
604 }
605
606 return Neutral;
607 }

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

Referenced by Drag().

Here is the caller graph for this function:

◆ FindChannel()

std::shared_ptr< const Channel > SubViewRearrangeHandle::FindChannel ( ) const
inlineoverridevirtual
Returns
pointer to associated channel, if any

Implements UIHandle.

Definition at line 545 of file WaveChannelView.cpp.

546 {
547 auto pView = mAdjuster.mwView.lock();
548 if (pView)
549 return pView->FindChannel();
550 return nullptr;
551 }

References mAdjuster, and SubViewAdjuster::mwView.

◆ HitTest()

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

Definition at line 495 of file WaveChannelView.cpp.

498 {
499 if ( !view.GetMultiView() )
500 return {};
501
502 SubViewAdjuster adjuster{ view };
503 if ( adjuster.NVisible() < 2 )
504 return {};
505
506 auto relX = state.state.GetX() - state.rect.GetLeft();
507 if ( relX >= HotZoneWidth )
508 return {};
509
510 auto index = adjuster.FindIndex( subView );
511
512 // Hit on the rearrange cursor only in the top and bottom thirds of
513 // sub-view height, leaving the rest free to hit the selection cursor
514 // first.
515 // And also exclude the top third of the topmost sub-view and bottom
516 // third of bottommost.
517 auto relY = state.state.GetY() - state.rect.GetTop();
518 auto height = state.rect.GetHeight();
519 bool hit =
520 ( ( 3 * relY < height ) && index > 0 ) // top hit
521 ||
522 ( ( 3 * relY > 2 * height ) &&
523 index < adjuster.mPermutation.size() - 1 ) // bottom
524 ;
525 if ( ! hit )
526 return {};
527
528 auto result = std::make_shared< SubViewRearrangeHandle >(
529 std::move( adjuster ),
530 index, view.GetLastHeight()
531 );
532 result = AssignUIHandlePtr( holder, result );
533 return result;
534 }
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:159
bool GetMultiView() const
wxCoord GetLastHeight() const

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

Referenced by WaveChannelSubView::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 646 of file WaveChannelView.cpp.

648 {
649 static auto hoverCursor =
650 ::MakeCursor(wxCURSOR_HAND, RearrangeCursorXpm, 16, 16);
651 static auto clickedCursor =
652 ::MakeCursor(wxCURSOR_HAND, RearrangingCursorXpm, 16, 16);
653 return {
654 XO("Click and drag to rearrange sub-views"),
655 Clicked() ? &*clickedCursor : &*hoverCursor,
656 XO("Rearrange sub-views")
657 };
658 }
XO("Cut/Copy/Paste")
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:188

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 660 of file WaveChannelView.cpp.

663 {
664 ProjectHistory::Get( *pProject ).ModifyState( false );
666 }
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 676 of file WaveChannelView.cpp.

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

◆ mHeights

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

Definition at line 677 of file WaveChannelView.cpp.

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

◆ mMySubView

size_t SubViewRearrangeHandle::mMySubView {}
private

Definition at line 681 of file WaveChannelView.cpp.

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

◆ mTopY

wxCoord SubViewRearrangeHandle::mTopY
private

Definition at line 678 of file WaveChannelView.cpp.

Referenced by Click(), and DragChoice().

◆ mViewHeight

wxCoord SubViewRearrangeHandle::mViewHeight {}
private

Definition at line 683 of file WaveChannelView.cpp.

Referenced by Click().


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