Audacity  3.2.0
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle Class Reference
Inheritance diagram for anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle:
[legend]
Collaboration diagram for anonymous_namespace{WaveTrackView.cpp}::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 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 432 of file WaveTrackView.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
HotZoneWidth 

Definition at line 436 of file WaveTrackView.cpp.

436 { HotZoneWidth = 3 * kTrackInfoBtnSize / 2 };

◆ DragChoice_t

enum anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::DragChoice_t
Enumerator
Upward 
Downward 
Neutral 

Definition at line 511 of file WaveTrackView.cpp.

511 { Upward, Downward, Neutral };

Constructor & Destructor Documentation

◆ SubViewRearrangeHandle()

anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::SubViewRearrangeHandle ( SubViewAdjuster &&  adjuster,
size_t  subViewIndex,
wxCoord  viewHeight 
)
inline

Definition at line 479 of file WaveTrackView.cpp.

482  : mAdjuster{ std::move( adjuster ) }
483  , mMySubView{ subViewIndex }
484  , mViewHeight{ viewHeight }
485  {
486  }

Member Function Documentation

◆ Cancel()

Result anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::Cancel ( AudacityProject )
inlineoverridevirtual

Implements UIHandle.

Definition at line 603 of file WaveTrackView.cpp.

604  {
605  mAdjuster.UpdateViews( true );
607  }

References RefreshCode::RefreshAll.

◆ Click()

Result anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
inlineoverridevirtual

Implements UIHandle.

Definition at line 488 of file WaveTrackView.cpp.

490  {
491  using namespace RefreshCode;
492  const auto &permutation = mAdjuster.mPermutation;
493  const auto size = permutation.size();
494  if ( mMySubView >= size )
495  return Cancelled;
496 
498 
499  // Find y coordinate of first sub-view
500  wxCoord heightAbove = 0;
501  for (auto index = mAdjuster.mFirstSubView;
502  index != mMySubView; ++index)
503  heightAbove += mHeights[ index ];
504  mTopY = event.rect.GetTop() - heightAbove;
505 
506  return RefreshNone;
507  }

References RefreshCode::Cancelled, RefreshCode::RefreshNone, and size.

◆ Clicked()

bool anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::Clicked ( ) const
inline

Definition at line 509 of file WaveTrackView.cpp.

509 { return !mHeights.empty(); }

◆ Drag()

Result anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject  
)
inlineoverridevirtual

Implements UIHandle.

Definition at line 544 of file WaveTrackView.cpp.

545  {
546  using namespace RefreshCode;
547  auto pView = mAdjuster.mwView.lock();
548  if ( !pView )
549  return Cancelled;
550 
551  switch( DragChoice( event ) ) {
552  case Upward:
553  {
555  std::swap(
557  mAdjuster.mNewPlacements[ mMySubView - 1 ].index
558  );
559  --mMySubView;
560  break;
561  }
562  case Downward:
563  {
565  std::swap(
567  mAdjuster.mNewPlacements[ mMySubView + 1 ].index
568  );
569  ++mMySubView;
570  break;
571  }
572  default:
573  return RefreshNone;
574  }
575 
576  // Save adjustment to the track and request a redraw
577  mAdjuster.UpdateViews( false );
578  return RefreshAll;
579  }

References RefreshCode::Cancelled, RefreshCode::RefreshAll, RefreshCode::RefreshNone, and anonymous_namespace{NoteTrack.cpp}::swap().

Here is the call graph for this function:

◆ DragChoice()

DragChoice_t anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::DragChoice ( const TrackPanelMouseEvent event) const
inline

Definition at line 513 of file WaveTrackView.cpp.

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

◆ HitTest()

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

Definition at line 438 of file WaveTrackView.cpp.

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

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

Here is the call graph for this function:

◆ Preview()

HitTestPreview anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::Preview ( const TrackPanelMouseState state,
AudacityProject  
)
inlineoverridevirtual

Implements UIHandle.

Definition at line 581 of file WaveTrackView.cpp.

583  {
584  static auto hoverCursor =
585  ::MakeCursor(wxCURSOR_HAND, RearrangeCursorXpm, 16, 16);
586  static auto clickedCursor =
587  ::MakeCursor(wxCURSOR_HAND, RearrangingCursorXpm, 16, 16);
588  return {
589  XO("Click and drag to rearrange sub-views"),
590  Clicked() ? &*clickedCursor : &*hoverCursor,
591  XO("Rearrange sub-views")
592  };
593  }

References MakeCursor(), and XO.

Here is the call graph for this function:

◆ Release()

Result anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
inlineoverridevirtual

Implements UIHandle.

Definition at line 595 of file WaveTrackView.cpp.

598  {
599  ProjectHistory::Get( *pProject ).ModifyState( false );
601  }

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

Here is the call graph for this function:

Member Data Documentation

◆ mAdjuster

SubViewAdjuster anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::mAdjuster
private

Definition at line 611 of file WaveTrackView.cpp.

◆ mHeights

std::vector<wxCoord> anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::mHeights
private

Definition at line 612 of file WaveTrackView.cpp.

◆ mMySubView

size_t anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::mMySubView {}
private

Definition at line 616 of file WaveTrackView.cpp.

◆ mTopY

wxCoord anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::mTopY
private

Definition at line 613 of file WaveTrackView.cpp.

◆ mViewHeight

wxCoord anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::mViewHeight {}
private

Definition at line 618 of file WaveTrackView.cpp.


The documentation for this class was generated from the following file:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
ProjectHistory::ModifyState
void ModifyState(bool bWantsAutoSave)
Definition: ProjectHistory.cpp:124
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::Clicked
bool Clicked() const
Definition: WaveTrackView.cpp:509
RefreshCode::RefreshAll
@ RefreshAll
Definition: RefreshCode.h:26
RefreshCode::RefreshNone
@ RefreshNone
Definition: RefreshCode.h:21
MakeCursor
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:182
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::mMySubView
size_t mMySubView
Definition: WaveTrackView.cpp:616
anonymous_namespace{WaveTrackView.cpp}::SubViewAdjuster::UpdateViews
void UpdateViews(bool rollback)
Definition: WaveTrackView.cpp:201
anonymous_namespace{WaveTrackView.cpp}::SubViewAdjuster::mFirstSubView
size_t mFirstSubView
Definition: WaveTrackView.cpp:218
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::mAdjuster
SubViewAdjuster mAdjuster
Definition: WaveTrackView.cpp:611
RefreshCode::Cancelled
@ Cancelled
Definition: RefreshCode.h:23
XO
#define XO(s)
Definition: Internat.h:31
WaveTrackView::GetMultiView
bool GetMultiView() const
Definition: WaveTrackView.h:154
kTrackInfoBtnSize
@ kTrackInfoBtnSize
Definition: ViewInfo.h:95
WaveTrackView::GetLastHeight
wxCoord GetLastHeight() const
Definition: WaveTrackView.h:152
TrackPanelMouseState::rect
const wxRect & rect
Definition: TrackPanelMouseEvent.h:39
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::Neutral
@ Neutral
Definition: WaveTrackView.cpp:511
anonymous_namespace{WaveTrackView.cpp}::SubViewAdjuster::ComputeHeights
std::vector< wxCoord > ComputeHeights(wxCoord totalHeight)
Definition: WaveTrackView.cpp:177
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::HotZoneWidth
@ HotZoneWidth
Definition: WaveTrackView.cpp:436
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::Downward
@ Downward
Definition: WaveTrackView.cpp:511
anonymous_namespace{WaveTrackView.cpp}::SubViewAdjuster::mNewPlacements
WaveTrackSubViewPlacements mNewPlacements
Definition: WaveTrackView.cpp:214
anonymous_namespace{NoteTrack.cpp}::swap
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:753
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::DragChoice
DragChoice_t DragChoice(const TrackPanelMouseEvent &event) const
Definition: WaveTrackView.cpp:513
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::mViewHeight
wxCoord mViewHeight
Definition: WaveTrackView.cpp:618
anonymous_namespace{WaveTrackView.cpp}::SubViewAdjuster::mPermutation
std::vector< size_t > mPermutation
Definition: WaveTrackView.cpp:216
AssignUIHandlePtr
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
RefreshCode
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
anonymous_namespace{WaveTrackView.cpp}::SubViewAdjuster::mwView
std::weak_ptr< WaveTrackView > mwView
Definition: WaveTrackView.cpp:212
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::mHeights
std::vector< wxCoord > mHeights
Definition: WaveTrackView.cpp:612
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::Upward
@ Upward
Definition: WaveTrackView.cpp:511
TrackPanelMouseState::state
wxMouseState & state
Definition: TrackPanelMouseEvent.h:38
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
anonymous_namespace{WaveTrackView.cpp}::SubViewRearrangeHandle::mTopY
wxCoord mTopY
Definition: WaveTrackView.cpp:613