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

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
HotZoneWidth 

Definition at line 492 of file WaveChannelView.cpp.

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

◆ DragChoice_t

Enumerator
Upward 
Downward 
Neutral 

Definition at line 575 of file WaveChannelView.cpp.

Constructor & Destructor Documentation

◆ SubViewRearrangeHandle()

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

Definition at line 535 of file WaveChannelView.cpp.

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

Member Function Documentation

◆ Cancel()

Result SubViewRearrangeHandle::Cancel ( AudacityProject )
inlineoverridevirtual

Implements UIHandle.

Definition at line 667 of file WaveChannelView.cpp.

668 {
669 mAdjuster.UpdateViews( true );
671 }
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 552 of file WaveChannelView.cpp.

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

573{ 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 608 of file WaveChannelView.cpp.

609 {
610 using namespace RefreshCode;
611 auto pView = mAdjuster.mwView.lock();
612 if ( !pView )
613 return Cancelled;
614
615 switch( DragChoice( event ) ) {
616 case Upward:
617 {
619 std::swap(
622 );
623 --mMySubView;
624 break;
625 }
626 case Downward:
627 {
629 std::swap(
632 );
633 ++mMySubView;
634 break;
635 }
636 default:
637 return RefreshNone;
638 }
639
640 // Save adjustment to the track and request a redraw
641 mAdjuster.UpdateViews( false );
642 return RefreshAll;
643 }
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 577 of file WaveChannelView.cpp.

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

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

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

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

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

647 {
648 static auto hoverCursor =
649 ::MakeCursor(wxCURSOR_HAND, RearrangeCursorXpm, 16, 16);
650 static auto clickedCursor =
651 ::MakeCursor(wxCURSOR_HAND, RearrangingCursorXpm, 16, 16);
652 return {
653 XO("Click and drag to rearrange sub-views"),
654 Clicked() ? &*clickedCursor : &*hoverCursor,
655 XO("Rearrange sub-views")
656 };
657 }
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 659 of file WaveChannelView.cpp.

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

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

◆ mHeights

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

Definition at line 676 of file WaveChannelView.cpp.

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

◆ mMySubView

size_t SubViewRearrangeHandle::mMySubView {}
private

Definition at line 680 of file WaveChannelView.cpp.

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

◆ mTopY

wxCoord SubViewRearrangeHandle::mTopY
private

Definition at line 677 of file WaveChannelView.cpp.

Referenced by Click(), and DragChoice().

◆ mViewHeight

wxCoord SubViewRearrangeHandle::mViewHeight {}
private

Definition at line 682 of file WaveChannelView.cpp.

Referenced by Click().


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