Audacity 3.2.0
SliderHandle.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5SliderHandle.h
6
7Paul Licameli
8
9**********************************************************************/
10
11#ifndef __AUDACITY_SLIDER_HANDLE__
12#define __AUDACITY_SLIDER_HANDLE__
13
14#include "../../UIHandle.h"
15
16class wxMouseEvent;
17class wxMouseState;
18class LWSlider;
19class Track;
21
22class AUDACITY_DLL_API SliderHandle /* not final */ : public UIHandle
23{
24 SliderHandle(const SliderHandle&) = delete;
25
26public:
27 using SliderFn = LWSlider *(*)( AudacityProject*, const wxRect&, Track* );
28
29 explicit SliderHandle
30 ( SliderFn sliderFn, const wxRect &rect,
31 const std::shared_ptr<Track> &pTrack );
32
34
35 std::shared_ptr<const Track> FindTrack() const override;
36 std::shared_ptr<Track> GetTrack() const { return mpTrack.lock(); }
37 bool IsDragging() const override;
38
39protected:
40 virtual ~SliderHandle();
41
42 // These NEW abstract virtuals simplify the duties of further subclasses.
43 // This class will decide whether to refresh the clicked cell for slider state
44 // change.
45 // Subclass can decide to refresh other things and the results will be ORed.
46 virtual float GetValue() = 0;
47 virtual Result SetValue(AudacityProject *pProject, float newValue) = 0;
49 (const wxMouseEvent &event, AudacityProject *pProject) = 0;
50
51 // Define a message for the status bar and tooltip.
53 const wxMouseState &state, AudacityProject &project) const = 0;
54
55 void Enter(bool forward, AudacityProject *) override;
56
58 (const TrackPanelMouseEvent &event, AudacityProject *pProject)
59 final override;
60
62 (const TrackPanelMouseEvent &event, AudacityProject *pProject)
63 final override;
64
66 (const TrackPanelMouseState &state, AudacityProject *pProject)
67 final override;
68
70 (const TrackPanelMouseEvent &event, AudacityProject *pProject,
71 wxWindow *pParent) final override;
72
73 Result Cancel(AudacityProject *pProject) final override;
74
75 // Derived class is expected to set these two before Click():
76 std::weak_ptr<Track> mpTrack;
77 wxRect mRect{};
79 LWSlider *GetSlider( AudacityProject *pProject );
80
81 float mStartingValue {};
82
83 bool mIsDragging{};
84};
85
86#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
Lightweight version of ASlider. In other words it does not have a window permanently associated with ...
Definition: ASlider.h:64
virtual Result SetValue(AudacityProject *pProject, float newValue)=0
SliderHandle & operator=(const SliderHandle &)=default
LWSlider *(*)(AudacityProject *, const wxRect &, Track *) SliderFn
Definition: SliderHandle.h:27
SliderFn mSliderFn
Definition: SliderHandle.h:78
std::shared_ptr< Track > GetTrack() const
Definition: SliderHandle.h:36
SliderHandle(const SliderHandle &)=delete
virtual TranslatableString Tip(const wxMouseState &state, AudacityProject &project) const =0
virtual Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject)=0
virtual float GetValue()=0
std::weak_ptr< Track > mpTrack
Definition: SliderHandle.h:76
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