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

#include <LabelDefaultClickHandle.h>

Inheritance diagram for LabelDefaultClickHandle:
UIHandle LabelGlyphHandle LabelTextHandle

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)
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape () const
 
virtual bool Escape ()
 
virtual HitTestPreview Preview (const TrackPanelMouseState &state, const AudacityProject *pProject)=0
 
virtual void DrawExtras (DrawingPass pass, wxDC *dc, const wxRegion &updateRegion, const wxRect &panelRect)
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 

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
enum  DrawingPass { Cells, Panel }
 
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 22 of file LabelDefaultClickHandle.h.

Constructor & Destructor Documentation

LabelDefaultClickHandle::LabelDefaultClickHandle ( )

Definition at line 20 of file LabelDefaultClickHandle.cpp.

21 {
22 }
LabelDefaultClickHandle::~LabelDefaultClickHandle ( )
virtual

Definition at line 24 of file LabelDefaultClickHandle.cpp.

25 {
26 }

Member Function Documentation

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

Implements UIHandle.

Reimplemented in LabelGlyphHandle, and LabelTextHandle.

Definition at line 104 of file LabelDefaultClickHandle.cpp.

References RefreshCode::RefreshNone, and RestoreState().

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

105 {
107  RestoreState( pProject );
108  return result;
109 }
unsigned Result
Definition: UIHandle.h:37
void RestoreState(AudacityProject *pProject)
UIHandle::Result LabelDefaultClickHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Reimplemented in LabelGlyphHandle, and LabelTextHandle.

Definition at line 63 of file LabelDefaultClickHandle.cpp.

References TrackPanelMouseEvent::event, TrackListIterator::First(), Track::GetKind(), AudacityProject::GetTracks(), Track::Label, TrackListIterator::Next(), TrackPanelMouseEvent::pCell, RefreshCode::RefreshAll, LabelTrack::ResetFlags(), and LabelTrack::Unselect().

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

64 {
65  using namespace RefreshCode;
66  // Redraw to show the change of text box selection status
68 
69  if (evt.event.LeftDown())
70  {
71  SaveState( pProject );
72 
73  TrackList *const tracks = pProject->GetTracks();
74  TrackListIterator iter(tracks);
75  Track *n = iter.First();
76 
77  while (n) {
78  if (n->GetKind() == Track::Label && evt.pCell.get() != n) {
79  LabelTrack *const lt = static_cast<LabelTrack*>(n);
80  lt->ResetFlags();
81  lt->Unselect();
82  }
83  n = iter.Next();
84  }
85  }
86 
87  return result;
88 }
A list of TrackListNode items.
Definition: Track.h:612
void Unselect()
virtual int GetKind() const
Definition: Track.h:323
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:113
unsigned Result
Definition: UIHandle.h:37
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:95
void SaveState(AudacityProject *pProject)
An iterator for a TrackList.
Definition: Track.h:395
TrackList * GetTracks()
Definition: Project.h:174
void ResetFlags()
Definition: LabelTrack.cpp:268
UIHandle::Result LabelDefaultClickHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Reimplemented in LabelGlyphHandle, and LabelTextHandle.

Definition at line 91 of file LabelDefaultClickHandle.cpp.

References RefreshCode::RefreshNone.

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

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

Implements UIHandle.

Reimplemented in LabelGlyphHandle, and LabelTextHandle.

Definition at line 97 of file LabelDefaultClickHandle.cpp.

References RefreshCode::RefreshNone.

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

99 {
100  mLabelState.reset();
102 }
std::shared_ptr< LabelState > mLabelState
void LabelDefaultClickHandle::RestoreState ( AudacityProject pProject)
private

Definition at line 52 of file LabelDefaultClickHandle.cpp.

References AudacityProject::GetTracks(), TrackList::Lock(), and mLabelState.

Referenced by Cancel().

53 {
54  if ( mLabelState ) {
55  for ( const auto &pair : mLabelState->mPairs )
56  if (auto pLt = pProject->GetTracks()->Lock(pair.first))
57  pLt->RestoreFlags( pair.second );
58  mLabelState.reset();
59  }
60 }
std::shared_ptr< LabelState > mLabelState
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:727
TrackList * GetTracks()
Definition: Project.h:174
void LabelDefaultClickHandle::SaveState ( AudacityProject pProject)
private

Definition at line 32 of file LabelDefaultClickHandle.cpp.

References TrackListIterator::First(), Track::GetKind(), AudacityProject::GetTracks(), Track::Label, mLabelState, TrackListIterator::Next(), and LabelTrack::SaveFlags().

33 {
34  mLabelState = std::make_shared<LabelState>();
35  auto &pairs = mLabelState->mPairs;
36  TrackList *const tracks = pProject->GetTracks();
37  TrackListIterator iter(tracks);
38  Track *n = iter.First();
39 
40  while (n) {
41  if (n->GetKind() == Track::Label) {
42  LabelTrack *const lt = static_cast<LabelTrack*>(n);
43  pairs.push_back( std::make_pair(
44  Track::Pointer<LabelTrack>( lt ),
45  lt->SaveFlags() )
46  );
47  }
48  n = iter.Next();
49  }
50 }
std::shared_ptr< LabelState > mLabelState
A list of TrackListNode items.
Definition: Track.h:612
virtual int GetKind() const
Definition: Track.h:323
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:113
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:95
An iterator for a TrackList.
Definition: Track.h:395
Flags SaveFlags() const
Definition: LabelTrack.h:193
TrackList * GetTracks()
Definition: Project.h:174

Member Data Documentation

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

Definition at line 46 of file LabelDefaultClickHandle.h.

Referenced by RestoreState(), and SaveState().


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