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