Audacity  2.2.0
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 #include "../../MemoryX.h"
16 
17 class wxMouseEvent;
18 class wxMouseState;
19 #include <wx/gdicmn.h>
20 
21 class Track;
22 
23 class ButtonHandle /* not final */ : public UIHandle
24 {
25  ButtonHandle(const ButtonHandle&) = delete;
26 
27 public:
28  std::shared_ptr<Track> GetTrack() const { return mpTrack.lock(); }
29  bool IsClicked() const { return mIsClicked; }
30 
31 protected:
32  explicit ButtonHandle
33  ( const std::shared_ptr<Track> &pTrack, const wxRect &rect );
34 
35  ButtonHandle &operator=(const ButtonHandle&) = default;
36 
37  virtual ~ButtonHandle();
38 
39  // This NEW abstract virtual simplifies the duties of further subclasses.
40  // This class will decide whether to refresh the clicked cell for button state
41  // change.
42  // Subclass can decide to refresh other things and the results will be ORed.
43  virtual Result CommitChanges
44  (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) = 0;
45 
46  // Define a message for the status bar and tooltip.
47  virtual wxString Tip(const wxMouseState &state) const = 0;
48 
49  void Enter(bool forward) final override;
50 
52  (const TrackPanelMouseEvent &event, AudacityProject *pProject)
53  final override;
54 
55  Result Drag
56  (const TrackPanelMouseEvent &event, AudacityProject *pProject)
57  final override;
58 
60  (const TrackPanelMouseState &state, const AudacityProject *pProject)
61  final override;
62 
64  (const TrackPanelMouseEvent &event, AudacityProject *pProject,
65  wxWindow *pParent) final override;
66 
67  Result Cancel(AudacityProject *pProject) final override;
68 
69  std::weak_ptr<Track> mpTrack;
70  wxRect mRect;
71  bool mWasIn{ true };
72  bool mIsClicked{};
73 };
74 
75 #endif
ButtonHandle & operator=(const ButtonHandle &)=default
Definition: ButtonHandle.h:23
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) finaloverride
Definition: ButtonHandle.cpp:40
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) finaloverride
Definition: ButtonHandle.cpp:86
ButtonHandle(const ButtonHandle &)=delete
Definition: TrackPanelMouseEvent.h:27
std::shared_ptr< Track > GetTrack() const
Definition: ButtonHandle.h:28
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:161
unsigned Result
Definition: UIHandle.h:37
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) finaloverride
Definition: ButtonHandle.cpp:63
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:85
virtual wxString Tip(const wxMouseState &state) const =0
bool mIsClicked
Definition: ButtonHandle.h:72
Result Cancel(AudacityProject *pProject) finaloverride
Definition: ButtonHandle.cpp:101
bool IsClicked() const
Definition: ButtonHandle.h:29
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:69
wxRect mRect
Definition: ButtonHandle.h:70
void Enter(bool forward) finaloverride
Definition: ButtonHandle.cpp:34
virtual ~ButtonHandle()
Definition: ButtonHandle.cpp:30
virtual Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
HitTestPreview Preview(const TrackPanelMouseState &state, const AudacityProject *pProject) finaloverride
Definition: ButtonHandle.cpp:78
Definition: UIHandle.h:33
Definition: HitTestResult.h:19
bool mWasIn
Definition: ButtonHandle.h:71
Definition: TrackPanelMouseEvent.h:45