Audacity 3.2.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
LabelDefaultClickHandle Class Reference

#include <LabelDefaultClickHandle.h>

Inheritance diagram for LabelDefaultClickHandle:
[legend]
Collaboration diagram for LabelDefaultClickHandle:
[legend]

Classes

struct  LabelState
 

Public Member Functions

 LabelDefaultClickHandle ()
 
virtual ~LabelDefaultClickHandle ()
 
LabelDefaultClickHandleoperator= (const LabelDefaultClickHandle &)=default
 
Result Click (const TrackPanelMouseEvent &event, 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
 
- 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 TrackFindTrack () 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)
 

Private Member Functions

void SaveState (AudacityProject *pProject)
 
void RestoreState (AudacityProject *pProject)
 

Private Attributes

std::shared_ptr< LabelStatemLabelState
 

Additional Inherited Members

- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 
static std::shared_ptr< const TrackTrackFromChannel (const std::shared_ptr< const Channel > &pChannel)
 A frequent convenience in the definition of UIHandles. More...
 
- 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 Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 21 of file LabelDefaultClickHandle.h.

Constructor & Destructor Documentation

◆ LabelDefaultClickHandle()

LabelDefaultClickHandle::LabelDefaultClickHandle ( )

Definition at line 21 of file LabelDefaultClickHandle.cpp.

22{
23}

◆ ~LabelDefaultClickHandle()

LabelDefaultClickHandle::~LabelDefaultClickHandle ( )
virtual

Definition at line 25 of file LabelDefaultClickHandle.cpp.

26{
27}

Member Function Documentation

◆ Cancel()

UIHandle::Result LabelDefaultClickHandle::Cancel ( AudacityProject pProject)
overridevirtual

Implements UIHandle.

Reimplemented in LabelGlyphHandle, and LabelTextHandle.

Definition at line 97 of file LabelDefaultClickHandle.cpp.

98{
100 RestoreState( pProject );
101 return result;
102}
void RestoreState(AudacityProject *pProject)
unsigned Result
Definition: UIHandle.h:40

References RefreshCode::RefreshNone, and RestoreState().

Referenced by LabelGlyphHandle::Cancel(), and LabelTextHandle::Cancel().

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

◆ Click()

UIHandle::Result LabelDefaultClickHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Reimplemented in LabelGlyphHandle, and LabelTextHandle.

Definition at line 60 of file LabelDefaultClickHandle.cpp.

62{
63 using namespace RefreshCode;
64 // Redraw to show the change of text box selection status
66
67 if (evt.event.LeftDown())
68 {
69 SaveState( pProject );
70
71 const auto pLT = evt.pCell.get();
72 for (auto lt : TrackList::Get(*pProject).Any<LabelTrack>()) {
73 if (pLT != &ChannelView::Get(*lt)) {
74 auto &view = LabelTrackView::Get( *lt );
75 view.ResetFlags();
76 }
77 }
78 }
79
80 return result;
81}
static ChannelView & Get(Channel &channel)
void SaveState(AudacityProject *pProject)
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:98
static LabelTrackView & Get(LabelTrack &)
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References TrackList::Any(), TrackPanelMouseEvent::event, TrackList::Get(), ChannelView::Get(), LabelTrackView::Get(), TrackPanelMouseEvent::pCell, RefreshCode::RefreshAll, and SaveState().

Referenced by LabelGlyphHandle::Click(), and LabelTextHandle::Click().

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

◆ Drag()

UIHandle::Result LabelDefaultClickHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Reimplemented in LabelGlyphHandle, and LabelTextHandle.

Definition at line 83 of file LabelDefaultClickHandle.cpp.

85{
87}

References RefreshCode::RefreshNone.

Referenced by LabelGlyphHandle::Drag(), and LabelTextHandle::Drag().

Here is the caller graph for this function:

◆ operator=()

LabelDefaultClickHandle & LabelDefaultClickHandle::operator= ( const LabelDefaultClickHandle )
default

◆ Release()

UIHandle::Result LabelDefaultClickHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overridevirtual

Implements UIHandle.

Reimplemented in LabelGlyphHandle, and LabelTextHandle.

Definition at line 89 of file LabelDefaultClickHandle.cpp.

92{
93 mLabelState.reset();
95}
std::shared_ptr< LabelState > mLabelState

References mLabelState, and RefreshCode::RefreshNone.

Referenced by LabelGlyphHandle::Release(), and LabelTextHandle::Release().

Here is the caller graph for this function:

◆ RestoreState()

void LabelDefaultClickHandle::RestoreState ( AudacityProject pProject)
private

Definition at line 48 of file LabelDefaultClickHandle.cpp.

49{
50 if ( mLabelState ) {
51 for ( const auto &pair : mLabelState->mPairs )
52 if (auto pLt = TrackList::Get( *pProject ).Lock(pair.first)) {
53 auto &view = LabelTrackView::Get( *pLt );
54 view.RestoreFlags( pair.second );
55 }
56 mLabelState.reset();
57 }
58}
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1079

References TrackList::Get(), LabelTrackView::Get(), TrackList::Lock(), and mLabelState.

Referenced by Cancel().

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

◆ SaveState()

void LabelDefaultClickHandle::SaveState ( AudacityProject pProject)
private

Definition at line 35 of file LabelDefaultClickHandle.cpp.

36{
37 mLabelState = std::make_shared<LabelState>();
38 auto &pairs = mLabelState->mPairs;
39 auto &tracks = TrackList::Get( *pProject );
40
41 for (auto lt : tracks.Any<LabelTrack>()) {
42 auto &view = LabelTrackView::Get( *lt );
43 pairs.push_back( std::make_pair(
44 lt->SharedPointer<LabelTrack>(), view.SaveFlags() ) );
45 }
46}
const auto tracks

References TrackList::Get(), LabelTrackView::Get(), mLabelState, and tracks.

Referenced by Click().

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

Member Data Documentation

◆ mLabelState

std::shared_ptr< LabelState > LabelDefaultClickHandle::mLabelState
private

Definition at line 46 of file LabelDefaultClickHandle.h.

Referenced by Release(), RestoreState(), and SaveState().


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