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<Track> GetTrack() const { return mpTrack.lock(); }
36 bool IsClicked() const { return mIsClicked; }
37
38protected:
39 virtual ~SliderHandle();
40
41 // These NEW abstract virtuals simplify the duties of further subclasses.
42 // This class will decide whether to refresh the clicked cell for slider state
43 // change.
44 // Subclass can decide to refresh other things and the results will be ORed.
45 virtual float GetValue() = 0;
46 virtual Result SetValue(AudacityProject *pProject, float newValue) = 0;
48 (const wxMouseEvent &event, AudacityProject *pProject) = 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 *) 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 // Derived class is expected to set these two before Click():
75 std::weak_ptr<Track> mpTrack;
76 wxRect mRect{};
78 LWSlider *GetSlider( AudacityProject *pProject );
79
80 float mStartingValue {};
81
82 bool mIsClicked{};
83};
84
85#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:77
std::shared_ptr< Track > GetTrack() const
Definition: SliderHandle.h:35
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
bool IsClicked() const
Definition: SliderHandle.h:36
std::weak_ptr< Track > mpTrack
Definition: SliderHandle.h:75
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:123
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:35
virtual void Enter(bool forward, AudacityProject *pProject)
Definition: UIHandle.cpp:20
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:38
virtual HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject)=0
virtual Result Cancel(AudacityProject *pProject)=0
virtual Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject)=0