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

A UIHandle for a TrackPanel button, such as the Mute and Solo buttons. More...

#include <ButtonHandle.h>

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

Public Member Functions

std::shared_ptr< TrackGetTrack () const
 
bool IsDragging () const 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 ChannelFindChannel () 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)
 

Protected Member Functions

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

Protected Attributes

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

Private Member Functions

 ButtonHandle (const ButtonHandle &)=delete
 

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 Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 

Detailed Description

A UIHandle for a TrackPanel button, such as the Mute and Solo buttons.

Definition at line 25 of file ButtonHandle.h.

Constructor & Destructor Documentation

◆ ButtonHandle() [1/2]

ButtonHandle::ButtonHandle ( const ButtonHandle )
privatedelete

◆ ButtonHandle() [2/2]

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

Definition at line 21 of file ButtonHandle.cpp.

23 : mpTrack{ pTrack }
24 , mRect{ rect }
25{
26}
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:74
wxRect mRect
Definition: ButtonHandle.h:75

◆ ~ButtonHandle()

ButtonHandle::~ButtonHandle ( )
protectedvirtual

Definition at line 28 of file ButtonHandle.cpp.

29{
30}

Member Function Documentation

◆ Cancel()

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

Implements UIHandle.

Definition at line 111 of file ButtonHandle.cpp.

112{
113 using namespace RefreshCode;
114 return RefreshCell; // perhaps unnecessarily if pointer is out of the box
115}
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References RefreshCode::RefreshCell.

◆ Click()

UIHandle::Result ButtonHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 47 of file ButtonHandle.cpp.

49{
50 using namespace RefreshCode;
51 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
52 if ( !pTrack )
53 return Cancelled;
54
55 const wxMouseEvent &event = evt.event;
56 if (!event.Button(wxMOUSE_BTN_LEFT))
57 return Cancelled;
58
59 // Come here for left click or double click
60 if (mRect.Contains(event.m_x, event.m_y)) {
61 mWasIn = true;
62 mIsDragging = true;
63 // Toggle visible button state
64 return RefreshCell;
65 }
66 else
67 return Cancelled;
68}
bool mIsDragging
Definition: ButtonHandle.h:77
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1246
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347

References Cancelled, TrackPanelMouseEvent::event, TrackList::Get(), TrackList::Lock(), mIsDragging, mpTrack, mRect, mWasIn, and RefreshCode::RefreshCell.

Here is the call graph for this function:

◆ CommitChanges()

virtual Result ButtonHandle::CommitChanges ( const wxMouseEvent &  event,
AudacityProject pProject,
wxWindow *  pParent 
)
protectedpure virtual

Implemented in MuteButtonHandle, SoloButtonHandle, EffectsButtonHandle, SubViewCloseHandle, MinimizeButtonHandle, SelectButtonHandle, CloseButtonHandle, and MenuButtonHandle.

Referenced by Release().

Here is the caller graph for this function:

◆ Drag()

UIHandle::Result ButtonHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 70 of file ButtonHandle.cpp.

72{
73 const wxMouseEvent &event = evt.event;
74 using namespace RefreshCode;
75 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
76 if (!pTrack)
77 return Cancelled;
78
79 auto isIn = mRect.Contains(event.m_x, event.m_y);
80 auto result = (isIn == mWasIn) ? RefreshNone : RefreshCell;
81 mWasIn = isIn;
82 return result;
83}

References Cancelled, TrackPanelMouseEvent::event, TrackList::Get(), TrackList::Lock(), mpTrack, mRect, mWasIn, RefreshCode::RefreshCell, and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ Enter()

void ButtonHandle::Enter ( bool  forward,
AudacityProject  
)
finaloverrideprotectedvirtual

Reimplemented from UIHandle.

Definition at line 42 of file ButtonHandle.cpp.

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

◆ FindChannel()

std::shared_ptr< const Channel > ButtonHandle::FindChannel ( ) const
overrideprotectedvirtual
Returns
pointer to associated channel, if any

Implements UIHandle.

Definition at line 32 of file ButtonHandle.cpp.

33{
34 return std::dynamic_pointer_cast<const Channel>(mpTrack.lock());
35}

References mpTrack.

◆ GetTrack()

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

◆ IsDragging()

bool ButtonHandle::IsDragging ( ) const
overridevirtual

Whether the handle is dragging, affecting other panel painting; default returns false

Reimplemented from UIHandle.

Definition at line 37 of file ButtonHandle.cpp.

38{
39 return mIsDragging;
40}

References mIsDragging.

◆ operator=()

ButtonHandle & ButtonHandle::operator= ( const ButtonHandle )
protecteddefault

◆ Preview()

HitTestPreview ButtonHandle::Preview ( const TrackPanelMouseState state,
AudacityProject pProject 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 85 of file ButtonHandle.cpp.

87{
88 // No special cursor
89 TranslatableString message;
90 if (project)
91 message = Tip(st.state, *project);
92 return { message, {}, message };
93}
const auto project
virtual TranslatableString Tip(const wxMouseState &state, AudacityProject &project) const =0
Holds a msgid for the translation catalog; may also bind format arguments.

References project, TrackPanelMouseState::state, and Tip().

Here is the call graph for this function:

◆ Release()

UIHandle::Result ButtonHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 95 of file ButtonHandle.cpp.

98{
99 using namespace RefreshCode;
100 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
101 if (!pTrack)
102 return Cancelled;
103
104 Result result = RefreshNone;
105 const wxMouseEvent &event = evt.event;
106 if (pTrack && mRect.Contains(event.m_x, event.m_y))
107 result |= RefreshCell | CommitChanges(event, pProject, pParent);
108 return result;
109}
virtual Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
unsigned Result
Definition: UIHandle.h:39

References Cancelled, CommitChanges(), TrackPanelMouseEvent::event, TrackList::Get(), TrackList::Lock(), mpTrack, mRect, RefreshCode::RefreshCell, and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ Tip()

virtual TranslatableString ButtonHandle::Tip ( const wxMouseState &  state,
AudacityProject project 
) const
protectedpure virtual

Implemented in MuteButtonHandle, SoloButtonHandle, EffectsButtonHandle, MinimizeButtonHandle, SelectButtonHandle, MenuButtonHandle, SubViewCloseHandle, and CloseButtonHandle.

Referenced by Preview().

Here is the caller graph for this function:

Member Data Documentation

◆ mIsDragging

bool ButtonHandle::mIsDragging {}
protected

Definition at line 77 of file ButtonHandle.h.

Referenced by Click(), and IsDragging().

◆ mpTrack

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

◆ mRect

wxRect ButtonHandle::mRect
protected

Definition at line 75 of file ButtonHandle.h.

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

◆ mWasIn

bool ButtonHandle::mWasIn { true }
protected

Definition at line 76 of file ButtonHandle.h.

Referenced by Click(), and Drag().


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