Audacity 3.2.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
SliderHandle Class Referenceabstract

#include <SliderHandle.h>

Inheritance diagram for SliderHandle:
[legend]
Collaboration diagram for SliderHandle:
[legend]

Public Types

using SliderFn = LWSlider *(*)(AudacityProject *, const wxRect &, Track *)
 
- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 

Public Member Functions

 SliderHandle (SliderFn sliderFn, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
 
SliderHandleoperator= (const SliderHandle &)=default
 
std::shared_ptr< const TrackFindTrack () const override
 
std::shared_ptr< TrackGetTrack () const
 
bool IsDragging () const override
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
virtual void Enter (bool forward, AudacityProject *pProject)
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape (AudacityProject *pProject) const
 
virtual bool Escape (AudacityProject *pProject)
 
virtual bool HandlesRightClick ()
 Whether the handle has any special right-button handling. More...
 
virtual Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject)=0
 
virtual Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
 
virtual Result Cancel (AudacityProject *pProject)=0
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
virtual std::shared_ptr< const TrackFindTrack () const =0
 
virtual bool IsDragging () const
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

Protected Member Functions

virtual ~SliderHandle ()
 
virtual float GetValue ()=0
 
virtual Result SetValue (AudacityProject *pProject, float newValue)=0
 
virtual Result CommitChanges (const wxMouseEvent &event, AudacityProject *pProject)=0
 
virtual TranslatableString Tip (const wxMouseState &state, AudacityProject &project) const =0
 
void Enter (bool forward, AudacityProject *) override
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) final override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) final override
 
HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject) final override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) final override
 
Result Cancel (AudacityProject *pProject) final override
 
LWSliderGetSlider (AudacityProject *pProject)
 

Protected Attributes

std::weak_ptr< TrackmpTrack
 
wxRect mRect {}
 
SliderFn mSliderFn
 
float mStartingValue {}
 
bool mIsDragging {}
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Private Member Functions

 SliderHandle (const SliderHandle &)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 
static std::shared_ptr< const TrackTrackFromChannel (const std::shared_ptr< const Channel > &pChannel)
 A frequent convenience in the definition of UIHandles. More...
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 

Detailed Description

Definition at line 22 of file SliderHandle.h.

Member Typedef Documentation

◆ SliderFn

using SliderHandle::SliderFn = LWSlider *(*)( AudacityProject*, const wxRect&, Track* )

Definition at line 27 of file SliderHandle.h.

Constructor & Destructor Documentation

◆ SliderHandle() [1/2]

SliderHandle::SliderHandle ( const SliderHandle )
privatedelete

◆ SliderHandle() [2/2]

SliderHandle::SliderHandle ( SliderFn  sliderFn,
const wxRect &  rect,
const std::shared_ptr< Track > &  pTrack 
)
explicit

Definition at line 20 of file SliderHandle.cpp.

22 : mpTrack{ pTrack }
23 , mRect{ rect }
24 , mSliderFn{ sliderFn }
25{
26}
wxRect mRect
Definition: SliderHandle.h:77
SliderFn mSliderFn
Definition: SliderHandle.h:78
std::weak_ptr< Track > mpTrack
Definition: SliderHandle.h:76

◆ ~SliderHandle()

SliderHandle::~SliderHandle ( )
protectedvirtual

Definition at line 33 of file SliderHandle.cpp.

34{
35}

Member Function Documentation

◆ Cancel()

UIHandle::Result SliderHandle::Cancel ( AudacityProject pProject)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 115 of file SliderHandle.cpp.

116{
117 wxMouseEvent event(wxEVT_LEFT_UP);
118 GetSlider( pProject )->OnMouseEvent(event);
119
120 // Undo un-committed changes to project data:
121 auto result = SetValue(pProject, mStartingValue);
122 mpTrack.reset();
123 return RefreshCode::RefreshCell | result;
124}
void OnMouseEvent(wxMouseEvent &event)
Definition: ASlider.cpp:1185
virtual Result SetValue(AudacityProject *pProject, float newValue)=0
float mStartingValue
Definition: SliderHandle.h:81
LWSlider * GetSlider(AudacityProject *pProject)

References GetSlider(), mpTrack, mStartingValue, LWSlider::OnMouseEvent(), RefreshCode::RefreshCell, and SetValue().

Here is the call graph for this function:

◆ Click()

UIHandle::Result SliderHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 47 of file SliderHandle.cpp.

49{
50 wxMouseEvent &event = evt.event;
51 using namespace RefreshCode;
52 if (!event.Button(wxMOUSE_BTN_LEFT))
53 return Cancelled;
54
55 // Come here for left click or double click
57 auto slider = GetSlider( pProject );
58 slider->OnMouseEvent(event);
59 const float newValue = slider->Get();
60
61 // Make a non-permanent change to the project data:
62 auto result = SetValue(pProject, newValue);
63
64 if (event.ButtonDClick())
65 // Just did a modal dialog in OnMouseEvent
66 // Do not start a drag
67 return result | RefreshCell | Cancelled;
68 else {
69 mIsDragging = true;
70 return result | RefreshCell;
71 }
72}
bool mIsDragging
Definition: SliderHandle.h:83
virtual float GetValue()=0
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References Cancelled, TrackPanelMouseEvent::event, GetSlider(), GetValue(), mIsDragging, mStartingValue, RefreshCode::RefreshCell, and SetValue().

Here is the call graph for this function:

◆ CommitChanges()

virtual Result SliderHandle::CommitChanges ( const wxMouseEvent &  event,
AudacityProject pProject 
)
protectedpure virtual

Implemented in VelocitySliderHandle, VolumeSliderHandle, and PanSliderHandle.

Referenced by Release().

Here is the caller graph for this function:

◆ Drag()

UIHandle::Result SliderHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 74 of file SliderHandle.cpp.

76{
77 wxMouseEvent &event = evt.event;
78 using namespace RefreshCode;
79 GetSlider( pProject )->OnMouseEvent(event);
80 const float newValue = GetSlider( pProject )->Get();
81
82 // Make a non-permanent change to the project data:
83 return RefreshCell | SetValue(pProject, newValue);
84}
float Get(bool convert=true)
Definition: ASlider.cpp:1569

References TrackPanelMouseEvent::event, LWSlider::Get(), GetSlider(), LWSlider::OnMouseEvent(), RefreshCode::RefreshCell, and SetValue().

Here is the call graph for this function:

◆ Enter()

void SliderHandle::Enter ( bool  forward,
AudacityProject  
)
overrideprotectedvirtual

Reimplemented from UIHandle.

Definition at line 28 of file SliderHandle.cpp.

References UIHandle::mChangeHighlight, and RefreshCode::RefreshCell.

◆ FindTrack()

std::shared_ptr< const Track > SliderHandle::FindTrack ( ) const
overridevirtual
Returns
pointer to associated track, if any

Implements UIHandle.

Definition at line 37 of file SliderHandle.cpp.

38{
39 return mpTrack.lock();
40}

References mpTrack.

◆ GetSlider()

LWSlider * SliderHandle::GetSlider ( AudacityProject pProject)
protected

Definition at line 126 of file SliderHandle.cpp.

127{
128 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
129 return mSliderFn( pProject, mRect, pTrack.get() );
130}
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1079
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

References TrackList::Get(), TrackList::Lock(), mpTrack, mRect, and mSliderFn.

Referenced by Cancel(), Click(), Drag(), and Release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTrack()

std::shared_ptr< Track > SliderHandle::GetTrack ( ) const
inline

Definition at line 36 of file SliderHandle.h.

36{ return mpTrack.lock(); }

Referenced by anonymous_namespace{NoteTrackControls.cpp}::VelocitySliderDrawFunction().

Here is the caller graph for this function:

◆ GetValue()

virtual float SliderHandle::GetValue ( )
protectedpure virtual

Implemented in VelocitySliderHandle, VolumeSliderHandle, and PanSliderHandle.

Referenced by Click().

Here is the caller graph for this function:

◆ IsDragging()

bool SliderHandle::IsDragging ( ) const
overridevirtual

Whether the handle is dragging, affecting other panel painting; default returns false

Reimplemented from UIHandle.

Definition at line 42 of file SliderHandle.cpp.

43{
44 return mIsDragging;
45}

References mIsDragging.

◆ operator=()

SliderHandle & SliderHandle::operator= ( const SliderHandle )
default

◆ Preview()

HitTestPreview SliderHandle::Preview ( const TrackPanelMouseState state,
AudacityProject pProject 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 86 of file SliderHandle.cpp.

88{
89 // No special cursor
90 TranslatableString message;
91 if (project)
92 message = Tip(st.state, *project);
93 return { message, {}, message };
94}
const auto project
virtual TranslatableString Tip(const wxMouseState &state, AudacityProject &project) const =0
Holds a msgid for the translation catalog; may also bind format arguments.

References project, TrackPanelMouseState::state, and Tip().

Here is the call graph for this function:

◆ Release()

UIHandle::Result SliderHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
finaloverrideprotectedvirtual

Implements UIHandle.

Definition at line 96 of file SliderHandle.cpp.

99{
100 using namespace RefreshCode;
101 wxMouseEvent &event = evt.event;
102 GetSlider( pProject )->OnMouseEvent(event);
103 const float newValue = GetSlider( pProject )->Get();
104
105 Result result = RefreshCell;
106
107 // Commit changes to the project data:
108 result |= SetValue(pProject, newValue);
109 result |= CommitChanges(event, pProject);
110
111 mpTrack.reset();
112 return result;
113}
virtual Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject)=0
unsigned Result
Definition: UIHandle.h:40

References CommitChanges(), TrackPanelMouseEvent::event, LWSlider::Get(), GetSlider(), mpTrack, LWSlider::OnMouseEvent(), RefreshCode::RefreshCell, and SetValue().

Here is the call graph for this function:

◆ SetValue()

virtual Result SliderHandle::SetValue ( AudacityProject pProject,
float  newValue 
)
protectedpure virtual

Implemented in VelocitySliderHandle, VolumeSliderHandle, and PanSliderHandle.

Referenced by Cancel(), Click(), Drag(), and Release().

Here is the caller graph for this function:

◆ Tip()

virtual TranslatableString SliderHandle::Tip ( const wxMouseState &  state,
AudacityProject project 
) const
protectedpure virtual

Implemented in VelocitySliderHandle, VolumeSliderHandle, and PanSliderHandle.

Referenced by Preview().

Here is the caller graph for this function:

Member Data Documentation

◆ mIsDragging

bool SliderHandle::mIsDragging {}
protected

Definition at line 83 of file SliderHandle.h.

Referenced by Click(), and IsDragging().

◆ mpTrack

std::weak_ptr<Track> SliderHandle::mpTrack
protected

◆ mRect

wxRect SliderHandle::mRect {}
protected

Definition at line 77 of file SliderHandle.h.

Referenced by GetSlider().

◆ mSliderFn

SliderFn SliderHandle::mSliderFn
protected

Definition at line 78 of file SliderHandle.h.

Referenced by GetSlider().

◆ mStartingValue

float SliderHandle::mStartingValue {}
protected

Definition at line 81 of file SliderHandle.h.

Referenced by Cancel(), and Click().


The documentation for this class was generated from the following files: