Audacity  3.0.3
ButtonHandle.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 ButtonHandle.h
6 
7 Paul Licameli
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_BUTTON_HANDLE__
12 #define __AUDACITY_BUTTON_HANDLE__
13 
14 #include "../../UIHandle.h"
15 
16 class wxMouseEvent;
17 class wxMouseState;
18 
19 class Track;
20 class TranslatableString;
21 
22 
25 class AUDACITY_DLL_API ButtonHandle /* not final */ : public UIHandle
26 {
27  ButtonHandle(const ButtonHandle&) = delete;
28 
29 public:
30  std::shared_ptr<Track> GetTrack() const { return mpTrack.lock(); }
31  bool IsClicked() const { return mIsClicked; }
32 
33 protected:
34  explicit ButtonHandle
35  ( const std::shared_ptr<Track> &pTrack, const wxRect &rect );
36 
37  ButtonHandle &operator=(const ButtonHandle&) = default;
38 
39  virtual ~ButtonHandle();
40 
41  // This NEW abstract virtual simplifies the duties of further subclasses.
42  // This class will decide whether to refresh the clicked cell for button state
43  // change.
44  // Subclass can decide to refresh other things and the results will be ORed.
46  (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) = 0;
47 
48  // Define a message for the status bar and tooltip.
50  const wxMouseState &state, AudacityProject &project) const = 0;
51 
52  void Enter(bool forward, AudacityProject *) final override;
53 
55  (const TrackPanelMouseEvent &event, AudacityProject *pProject)
56  final override;
57 
58  Result Drag
59  (const TrackPanelMouseEvent &event, AudacityProject *pProject)
60  final override;
61 
63  (const TrackPanelMouseState &state, AudacityProject *pProject)
64  final override;
65 
67  (const TrackPanelMouseEvent &event, AudacityProject *pProject,
68  wxWindow *pParent) final override;
69 
70  Result Cancel(AudacityProject *pProject) final override;
71 
72  std::weak_ptr<Track> mpTrack;
73  wxRect mRect;
74  bool mWasIn{ true };
75  bool mIsClicked{};
76 };
77 
78 #endif
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
ButtonHandle::IsClicked
bool IsClicked() const
Definition: ButtonHandle.h:31
UIHandle::Preview
virtual HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject)=0
ButtonHandle::operator=
ButtonHandle & operator=(const ButtonHandle &)=default
ButtonHandle::mpTrack
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:72
ButtonHandle::GetTrack
std::shared_ptr< Track > GetTrack() const
Definition: ButtonHandle.h:30
UIHandle
Short-lived drawing and event-handling object associated with a TrackPanelCell.
Definition: UIHandle.h:34
ButtonHandle
A UIHandle for a TrackPanel button, such as the Mute and Solo buttons.
Definition: ButtonHandle.h:26
ButtonHandle::CommitChanges
virtual Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
UIHandle::Result
unsigned Result
Definition: UIHandle.h:37
UIHandle::Click
virtual Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
ButtonHandle::Tip
virtual TranslatableString Tip(const wxMouseState &state, AudacityProject &project) const =0
UIHandle::Cancel
virtual Result Cancel(AudacityProject *pProject)=0
HitTestPreview
Definition: HitTestResult.h:20
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:238
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
TrackPanelMouseEvent
Definition: TrackPanelMouseEvent.h:46
TrackPanelMouseState
Definition: TrackPanelMouseEvent.h:28
UIHandle::Enter
virtual void Enter(bool forward, AudacityProject *pProject)
Definition: UIHandle.cpp:20
UIHandle::Drag
virtual Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
UIHandle::Release
virtual Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
ButtonHandle::ButtonHandle
ButtonHandle(const ButtonHandle &)=delete
ButtonHandle::mRect
wxRect mRect
Definition: ButtonHandle.h:73