Audacity  3.0.3
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 bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape () const
 
virtual bool Escape (AudacityProject *pProject)
 
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 19 of file ButtonHandle.cpp.

21  : mpTrack{ pTrack }
22  , mRect{ rect }
23 {
24 }

◆ ~ButtonHandle()

ButtonHandle::~ButtonHandle ( )
protectedvirtual

Definition at line 26 of file ButtonHandle.cpp.

27 {
28 }

Member Function Documentation

◆ Cancel()

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

Implements UIHandle.

Definition at line 99 of file ButtonHandle.cpp.

100 {
101  using namespace RefreshCode;
102  return RefreshCell; // perhaps unnecessarily if pointer is out of the box
103 }

References RefreshCode::RefreshCell.

◆ Click()

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

Implements UIHandle.

Definition at line 35 of file ButtonHandle.cpp.

37 {
38  using namespace RefreshCode;
39  auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
40  if ( !pTrack )
41  return Cancelled;
42 
43  const wxMouseEvent &event = evt.event;
44  if (!event.Button(wxMOUSE_BTN_LEFT))
45  return Cancelled;
46 
47  // Come here for left click or double click
48  if (mRect.Contains(event.m_x, event.m_y)) {
49  mWasIn = true;
50  mIsClicked = true;
51  // Toggle visible button state
52  return RefreshCell;
53  }
54  else
55  return Cancelled;
56 }

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 MenuButtonHandle, CloseButtonHandle, SelectButtonHandle, MinimizeButtonHandle, anonymous_namespace{WaveTrackView.cpp}::SubViewCloseHandle, SoloButtonHandle, and MuteButtonHandle.

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

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

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

75 {
76  // No special cursor
77  TranslatableString message;
78  if (project)
79  message = Tip(st.state, *project);
80  return { message, {}, message };
81 }

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

86 {
87  using namespace RefreshCode;
88  auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
89  if (!pTrack)
90  return Cancelled;
91 
92  Result result = RefreshNone;
93  const wxMouseEvent &event = evt.event;
94  if (pTrack && mRect.Contains(event.m_x, event.m_y))
95  result |= RefreshCell | CommitChanges(event, pProject, pParent);
96  return result;
97 }

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 CloseButtonHandle, anonymous_namespace{WaveTrackView.cpp}::SubViewCloseHandle, MenuButtonHandle, SelectButtonHandle, MinimizeButtonHandle, SoloButtonHandle, and MuteButtonHandle.

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:
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
RefreshCode::RefreshNone
@ RefreshNone
Definition: RefreshCode.h:21
TrackList::Lock
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1523
ButtonHandle::mIsClicked
bool mIsClicked
Definition: ButtonHandle.h:75
ButtonHandle::mWasIn
bool mWasIn
Definition: ButtonHandle.h:74
ButtonHandle::mpTrack
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:72
ProgressResult::Cancelled
@ Cancelled
UIHandle::mChangeHighlight
Result mChangeHighlight
Definition: UIHandle.h:133
ButtonHandle::CommitChanges
virtual Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
UIHandle::Result
unsigned Result
Definition: UIHandle.h:37
ButtonHandle::Tip
virtual TranslatableString Tip(const wxMouseState &state, AudacityProject &project) const =0
RefreshCode::RefreshCell
@ RefreshCell
Definition: RefreshCode.h:24
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:495
RefreshCode
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
ButtonHandle::mRect
wxRect mRect
Definition: ButtonHandle.h:73