Audacity  2.2.2
Public Member Functions | Static Public Member Functions | Public Attributes | Static Private Member Functions | Private Attributes | List of all members
LabelGlyphHandle Class Referencefinal

#include <LabelGlyphHandle.h>

Inheritance diagram for LabelGlyphHandle:
LabelDefaultClickHandle UIHandle

Public Member Functions

 LabelGlyphHandle (const std::shared_ptr< LabelTrack > &pLT, const wxRect &rect, const LabelTrackHit &hit)
 
LabelGlyphHandleoperator= (const LabelGlyphHandle &)=default
 
virtual ~LabelGlyphHandle ()
 
void Enter (bool forward) override
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
HitTestPreview Preview (const TrackPanelMouseState &state, const AudacityProject *pProject) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
Result Cancel (AudacityProject *pProject) override
 
bool StopsOnKeystroke () override
 
- Public Member Functions inherited from LabelDefaultClickHandle
 LabelDefaultClickHandle ()
 
virtual ~LabelDefaultClickHandle ()
 
LabelDefaultClickHandleoperator= (const LabelDefaultClickHandle &)=default
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape () const
 
virtual bool Escape ()
 
virtual void DrawExtras (DrawingPass pass, wxDC *dc, const wxRegion &updateRegion, const wxRect &panelRect)
 
virtual void OnProjectChange (AudacityProject *pProject)
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 

Static Public Member Functions

static UIHandlePtr HitTest (std::weak_ptr< LabelGlyphHandle > &holder, const wxMouseState &state, const std::shared_ptr< LabelTrack > &pLT, const wxRect &rect)
 
static UIHandle::Result NeedChangeHighlight (const LabelGlyphHandle &oldState, const LabelGlyphHandle &newState)
 
- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 

Public Attributes

LabelTrackHit mHit {}
 

Static Private Member Functions

static HitTestPreview HitPreview (bool hitCenter)
 

Private Attributes

std::shared_ptr< LabelTrackmpLT {}
 
wxRect mRect {}
 

Additional Inherited Members

- Public Types inherited from UIHandle
enum  DrawingPass { Cells, Panel }
 
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 39 of file LabelGlyphHandle.h.

Constructor & Destructor Documentation

LabelGlyphHandle::LabelGlyphHandle ( const std::shared_ptr< LabelTrack > &  pLT,
const wxRect &  rect,
const LabelTrackHit hit 
)
explicit

Definition at line 27 of file LabelGlyphHandle.cpp.

29  : mHit{ hit }
30  , mpLT{ pLT }
31  , mRect{ rect }
32 {
33 }
std::shared_ptr< LabelTrack > mpLT
LabelTrackHit mHit
LabelGlyphHandle::~LabelGlyphHandle ( )
virtual

Definition at line 80 of file LabelGlyphHandle.cpp.

81 {
82 }

Member Function Documentation

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

Reimplemented from LabelDefaultClickHandle.

Definition at line 154 of file LabelGlyphHandle.cpp.

References LabelDefaultClickHandle::Cancel(), RefreshCode::RefreshAll, and AudacityProject::RollbackState().

155 {
156  pProject->RollbackState();
157  auto result = LabelDefaultClickHandle::Cancel( pProject );
158  return result | RefreshCode::RefreshAll;
159 }
Result Cancel(AudacityProject *pProject) override
void RollbackState()
Definition: Project.cpp:4742
UIHandle::Result LabelGlyphHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Reimplemented from LabelDefaultClickHandle.

Definition at line 85 of file LabelGlyphHandle.cpp.

References RefreshCode::Cancelled, LabelDefaultClickHandle::Click(), TrackPanelMouseEvent::event, AudacityProject::GetViewInfo(), mHit, LabelTrackHit::mIsAdjustingLabel, mpLT, mRect, RefreshCode::RefreshCell, and ViewInfo::selectedRegion.

86 {
87  auto result = LabelDefaultClickHandle::Click( evt, pProject );
88 
89  const wxMouseEvent &event = evt.event;
90 
91  ViewInfo &viewInfo = pProject->GetViewInfo();
92  mpLT->HandleGlyphClick
93  (mHit, event, mRect, viewInfo, &viewInfo.selectedRegion);
94 
95  if (! mHit.mIsAdjustingLabel )
96  {
97  // The positive hit test should have ensured otherwise
98  //wxASSERT(false);
99  result |= RefreshCode::Cancelled;
100  }
101  else
102  // redraw the track.
103  result |= RefreshCode::RefreshCell;
104 
105  // handle shift+ctrl down
106  /*if (event.ShiftDown()) { // && event.ControlDown()) {
107  lTrack->SetHighlightedByKey(true);
108  Refresh(false);
109  return;
110  }*/
111 
112  return result;
113 }
ViewInfo is used mainly to hold the zooming, selection and scroll information. It also has some statu...
Definition: ViewInfo.h:141
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
std::shared_ptr< LabelTrack > mpLT
const ViewInfo & GetViewInfo() const
Definition: Project.h:207
LabelTrackHit mHit
UIHandle::Result LabelGlyphHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Reimplemented from LabelDefaultClickHandle.

Definition at line 116 of file LabelGlyphHandle.cpp.

References LabelDefaultClickHandle::Drag(), RefreshCode::DrawOverlays, TrackPanelMouseEvent::event, AudacityProject::GetViewInfo(), mHit, mpLT, mRect, RefreshCode::RefreshAll, and ViewInfo::selectedRegion.

117 {
118  auto result = LabelDefaultClickHandle::Drag( evt, pProject );
119 
120  const wxMouseEvent &event = evt.event;
121  ViewInfo &viewInfo = pProject->GetViewInfo();
122  mpLT->HandleGlyphDragRelease
123  (mHit, event, mRect, viewInfo, &viewInfo.selectedRegion);
124 
125  // Refresh all so that the change of selection is redrawn in all tracks
127 }
ViewInfo is used mainly to hold the zooming, selection and scroll information. It also has some statu...
Definition: ViewInfo.h:141
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
std::shared_ptr< LabelTrack > mpLT
const ViewInfo & GetViewInfo() const
Definition: Project.h:207
LabelTrackHit mHit
void LabelGlyphHandle::Enter ( bool  forward)
overridevirtual

Reimplemented from UIHandle.

Definition at line 35 of file LabelGlyphHandle.cpp.

References UIHandle::mChangeHighlight, and RefreshCode::RefreshCell.

HitTestPreview LabelGlyphHandle::HitPreview ( bool  hitCenter)
staticprivate

Definition at line 49 of file LabelGlyphHandle.cpp.

References _(), and HitTest().

Referenced by Preview().

50 {
51  static wxCursor arrowCursor{ wxCURSOR_ARROW };
52  return {
53  (hitCenter
54  ? _("Drag one or more label boundaries.")
55  : _("Drag label boundary.")),
56  &arrowCursor
57  };
58 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
UIHandlePtr LabelGlyphHandle::HitTest ( std::weak_ptr< LabelGlyphHandle > &  holder,
const wxMouseState &  state,
const std::shared_ptr< LabelTrack > &  pLT,
const wxRect &  rect 
)
static

Definition at line 61 of file LabelGlyphHandle.cpp.

References AssignUIHandlePtr(), and LabelTrackHit::mEdge.

Referenced by LabelTrack::DetailedHitTest(), and HitPreview().

64 {
65  LabelTrackHit hit{};
66  pLT->OverGlyph(hit, state.m_x, state.m_y);
67 
68  // IF edge!=0 THEN we've set the cursor and we're done.
69  // signal this by setting the tip.
70  if ( hit.mEdge & 3 )
71  {
72  auto result = std::make_shared<LabelGlyphHandle>( pLT, rect, hit );
73  result = AssignUIHandlePtr(holder, result);
74  return result;
75  }
76 
77  return {};
78 }
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:162
UIHandle::Result LabelGlyphHandle::NeedChangeHighlight ( const LabelGlyphHandle oldState,
const LabelGlyphHandle newState 
)
static

Definition at line 41 of file LabelGlyphHandle.cpp.

References LabelTrackHit::mEdge, mHit, and RefreshCode::RefreshCell.

42 {
43  if (oldState.mHit.mEdge != newState.mHit.mEdge)
44  // pointer moves between the circle and the chevron
46  return 0;
47 }
LabelTrackHit mHit
LabelGlyphHandle& LabelGlyphHandle::operator= ( const LabelGlyphHandle )
default
HitTestPreview LabelGlyphHandle::Preview ( const TrackPanelMouseState state,
const AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 130 of file LabelGlyphHandle.cpp.

References HitPreview(), LabelTrackHit::mEdge, and mHit.

131 {
132  return HitPreview( (mHit.mEdge & 4 )!=0);
133 }
static HitTestPreview HitPreview(bool hitCenter)
LabelTrackHit mHit
UIHandle::Result LabelGlyphHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overridevirtual

Reimplemented from LabelDefaultClickHandle.

Definition at line 136 of file LabelGlyphHandle.cpp.

References _(), CONSOLIDATE, RefreshCode::DrawOverlays, TrackPanelMouseEvent::event, AudacityProject::GetViewInfo(), mHit, mpLT, mRect, AudacityProject::PushState(), RefreshCode::RefreshAll, LabelDefaultClickHandle::Release(), and ViewInfo::selectedRegion.

138 {
139  auto result = LabelDefaultClickHandle::Release( evt, pProject, pParent );
140 
141  const wxMouseEvent &event = evt.event;
142  ViewInfo &viewInfo = pProject->GetViewInfo();
143  if (mpLT->HandleGlyphDragRelease
144  (mHit, event, mRect, viewInfo, &viewInfo.selectedRegion)) {
145  pProject->PushState(_("Modified Label"),
146  _("Label Edit"),
148  }
149 
150  // Refresh all so that the change of selection is redrawn in all tracks
152 }
ViewInfo is used mainly to hold the zooming, selection and scroll information. It also has some statu...
Definition: ViewInfo.h:141
SelectedRegion selectedRegion
Definition: ViewInfo.h:160
std::shared_ptr< LabelTrack > mpLT
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void PushState(const wxString &desc, const wxString &shortDesc)
Definition: Project.cpp:4702
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
const ViewInfo & GetViewInfo() const
Definition: Project.h:207
LabelTrackHit mHit
bool LabelGlyphHandle::StopsOnKeystroke ( )
inlineoverridevirtual

Reimplemented from UIHandle.

Definition at line 75 of file LabelGlyphHandle.h.

75 { return true; }

Member Data Documentation

LabelTrackHit LabelGlyphHandle::mHit {}

Definition at line 77 of file LabelGlyphHandle.h.

Referenced by Click(), Drag(), NeedChangeHighlight(), Preview(), and Release().

std::shared_ptr<LabelTrack> LabelGlyphHandle::mpLT {}
private

Definition at line 83 of file LabelGlyphHandle.h.

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

wxRect LabelGlyphHandle::mRect {}
private

Definition at line 84 of file LabelGlyphHandle.h.

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


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