Audacity  2.2.2
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
ButtonHandle Class Referenceabstract

#include <ButtonHandle.h>

Inheritance diagram for ButtonHandle:
UIHandle CloseButtonHandle MenuButtonHandle MinimizeButtonHandle MuteButtonHandle SoloButtonHandle

Public Member Functions

std::shared_ptr< TrackGetTrack () const
 
bool IsClicked () const
 
- 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 bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 

Protected Member Functions

 ButtonHandle (const std::shared_ptr< Track > &pTrack, const wxRect &rect)
 
ButtonHandleoperator= (const ButtonHandle &)=default
 
virtual ~ButtonHandle ()
 
virtual Result CommitChanges (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
 
virtual wxString Tip (const wxMouseState &state) const =0
 
void Enter (bool forward) finaloverride
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) finaloverride
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) finaloverride
 
HitTestPreview Preview (const TrackPanelMouseState &state, const AudacityProject *pProject) finaloverride
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) finaloverride
 
Result Cancel (AudacityProject *pProject) finaloverride
 

Protected Attributes

std::weak_ptr< TrackmpTrack
 
wxRect mRect
 
bool mWasIn { true }
 
bool mIsClicked {}
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Private Member Functions

 ButtonHandle (const ButtonHandle &)=delete
 

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 &)
 

Detailed Description

Definition at line 23 of file ButtonHandle.h.

Constructor & Destructor Documentation

ButtonHandle::ButtonHandle ( const ButtonHandle )
privatedelete
ButtonHandle::ButtonHandle ( const std::shared_ptr< Track > &  pTrack,
const wxRect &  rect 
)
explicitprotected

Definition at line 24 of file ButtonHandle.cpp.

25  : mpTrack{ pTrack }
26  , mRect{ rect }
27 {
28 }
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:69
wxRect mRect
Definition: ButtonHandle.h:70
ButtonHandle::~ButtonHandle ( )
protectedvirtual

Definition at line 30 of file ButtonHandle.cpp.

31 {
32 }

Member Function Documentation

UIHandle::Result ButtonHandle::Cancel ( AudacityProject pProject)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 101 of file ButtonHandle.cpp.

References RefreshCode::RefreshCell.

102 {
103  using namespace RefreshCode;
104  return RefreshCell; // perhaps unnecessarily if pointer is out of the box
105 }
UIHandle::Result ButtonHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 40 of file ButtonHandle.cpp.

References RefreshCode::Cancelled, TrackPanelMouseEvent::event, AudacityProject::GetTracks(), TrackList::Lock(), and RefreshCode::RefreshCell.

41 {
42  using namespace RefreshCode;
43  auto pTrack = pProject->GetTracks()->Lock(mpTrack);
44  if ( !pTrack )
45  return Cancelled;
46 
47  const wxMouseEvent &event = evt.event;
48  if (!event.Button(wxMOUSE_BTN_LEFT))
49  return Cancelled;
50 
51  // Come here for left click or double click
52  if (mRect.Contains(event.m_x, event.m_y)) {
53  mWasIn = true;
54  mIsClicked = true;
55  // Toggle visible button state
56  return RefreshCell;
57  }
58  else
59  return Cancelled;
60 }
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:738
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:69
wxRect mRect
Definition: ButtonHandle.h:70
TrackList * GetTracks()
Definition: Project.h:192
virtual Result ButtonHandle::CommitChanges ( const wxMouseEvent &  event,
AudacityProject pProject,
wxWindow *  pParent 
)
protectedpure virtual
UIHandle::Result ButtonHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 63 of file ButtonHandle.cpp.

References RefreshCode::Cancelled, TrackPanelMouseEvent::event, AudacityProject::GetTracks(), TrackList::Lock(), RefreshCode::RefreshCell, and RefreshCode::RefreshNone.

64 {
65  const wxMouseEvent &event = evt.event;
66  using namespace RefreshCode;
67  auto pTrack = pProject->GetTracks()->Lock(mpTrack);
68  if (!pTrack)
69  return Cancelled;
70 
71  auto isIn = mRect.Contains(event.m_x, event.m_y);
72  auto result = (isIn == mWasIn) ? RefreshNone : RefreshCell;
73  mWasIn = isIn;
74  return result;
75 }
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:738
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:69
wxRect mRect
Definition: ButtonHandle.h:70
TrackList * GetTracks()
Definition: Project.h:192
void ButtonHandle::Enter ( bool  forward)
finaloverrideprotectedvirtual

Reimplemented from UIHandle.

Definition at line 34 of file ButtonHandle.cpp.

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

std::shared_ptr<Track> ButtonHandle::GetTrack ( ) const
inline
bool ButtonHandle::IsClicked ( ) const
inline

Definition at line 29 of file ButtonHandle.h.

References mIsClicked.

29 { return mIsClicked; }
ButtonHandle& ButtonHandle::operator= ( const ButtonHandle )
protecteddefault
HitTestPreview ButtonHandle::Preview ( const TrackPanelMouseState state,
const AudacityProject pProject 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 78 of file ButtonHandle.cpp.

References TrackPanelMouseState::state.

79 {
80  // No special cursor
81  auto message = Tip(st.state);
82  return { message, {}, message };
83 }
virtual wxString Tip(const wxMouseState &state) const =0
UIHandle::Result ButtonHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 86 of file ButtonHandle.cpp.

References RefreshCode::Cancelled, TrackPanelMouseEvent::event, AudacityProject::GetTracks(), TrackList::Lock(), RefreshCode::RefreshCell, and RefreshCode::RefreshNone.

88 {
89  using namespace RefreshCode;
90  auto pTrack = pProject->GetTracks()->Lock(mpTrack);
91  if (!pTrack)
92  return Cancelled;
93 
94  Result result = RefreshNone;
95  const wxMouseEvent &event = evt.event;
96  if (pTrack && mRect.Contains(event.m_x, event.m_y))
97  result |= RefreshCell | CommitChanges(event, pProject, pParent);
98  return result;
99 }
unsigned Result
Definition: UIHandle.h:37
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:738
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:69
wxRect mRect
Definition: ButtonHandle.h:70
virtual Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
TrackList * GetTracks()
Definition: Project.h:192
virtual wxString ButtonHandle::Tip ( const wxMouseState &  state) const
protectedpure virtual

Member Data Documentation

bool ButtonHandle::mIsClicked {}
protected

Definition at line 72 of file ButtonHandle.h.

Referenced by IsClicked().

std::weak_ptr<Track> ButtonHandle::mpTrack
protected

Definition at line 69 of file ButtonHandle.h.

Referenced by GetTrack().

wxRect ButtonHandle::mRect
protected

Definition at line 70 of file ButtonHandle.h.

bool ButtonHandle::mWasIn { true }
protected

Definition at line 71 of file ButtonHandle.h.


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