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 IsClicked () const
 
- 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)
 
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 ()
 
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 mIsClicked {}
 
- 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:72
wxRect mRect
Definition: ButtonHandle.h:73

◆ ~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 101 of file ButtonHandle.cpp.

102{
103 using namespace RefreshCode;
104 return RefreshCell; // perhaps unnecessarily if pointer is out of the box
105}
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 37 of file ButtonHandle.cpp.

39{
40 using namespace RefreshCode;
41 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
42 if ( !pTrack )
43 return Cancelled;
44
45 const wxMouseEvent &event = evt.event;
46 if (!event.Button(wxMOUSE_BTN_LEFT))
47 return Cancelled;
48
49 // Come here for left click or double click
50 if (mRect.Contains(event.m_x, event.m_y)) {
51 mWasIn = true;
52 mIsClicked = true;
53 // Toggle visible button state
54 return RefreshCell;
55 }
56 else
57 return Cancelled;
58}
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1240
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:354

References Cancelled, TrackPanelMouseEvent::event, TrackList::Get(), TrackList::Lock(), mIsClicked, 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 60 of file ButtonHandle.cpp.

62{
63 const wxMouseEvent &event = evt.event;
64 using namespace RefreshCode;
65 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
66 if (!pTrack)
67 return Cancelled;
68
69 auto isIn = mRect.Contains(event.m_x, event.m_y);
70 auto result = (isIn == mWasIn) ? RefreshNone : RefreshCell;
71 mWasIn = isIn;
72 return result;
73}

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 32 of file ButtonHandle.cpp.

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

◆ GetTrack()

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

◆ IsClicked()

bool ButtonHandle::IsClicked ( ) const
inline

Definition at line 31 of file ButtonHandle.h.

31{ return mIsClicked; }

Referenced by TrackInfo::DrawCloseButton().

Here is the caller graph for this function:

◆ operator=()

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

◆ Preview()

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

Implements UIHandle.

Definition at line 75 of file ButtonHandle.cpp.

77{
78 // No special cursor
79 TranslatableString message;
80 if (project)
81 message = Tip(st.state, *project);
82 return { message, {}, message };
83}
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 85 of file ButtonHandle.cpp.

88{
89 using namespace RefreshCode;
90 auto pTrack = TrackList::Get( *pProject ).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}
virtual Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
unsigned Result
Definition: UIHandle.h:38

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

◆ mIsClicked

bool ButtonHandle::mIsClicked {}
protected

Definition at line 75 of file ButtonHandle.h.

Referenced by Click().

◆ mpTrack

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

◆ mRect

wxRect ButtonHandle::mRect
protected

Definition at line 73 of file ButtonHandle.h.

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

◆ mWasIn

bool ButtonHandle::mWasIn { true }
protected

Definition at line 74 of file ButtonHandle.h.

Referenced by Click(), and Drag().


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