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< TrackGetTrack () const
 
bool IsClicked () const
 
- 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)
 
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 mIsClicked {}
 
- 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 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:76
SliderFn mSliderFn
Definition: SliderHandle.h:77
std::weak_ptr< Track > mpTrack
Definition: SliderHandle.h:75

◆ ~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 105 of file SliderHandle.cpp.

106{
107 wxMouseEvent event(wxEVT_LEFT_UP);
108 GetSlider( pProject )->OnMouseEvent(event);
109
110 // Undo un-committed changes to project data:
111 auto result = SetValue(pProject, mStartingValue);
112 mpTrack.reset();
113 return RefreshCode::RefreshCell | result;
114}
void OnMouseEvent(wxMouseEvent &event)
Definition: ASlider.cpp:1169
virtual Result SetValue(AudacityProject *pProject, float newValue)=0
float mStartingValue
Definition: SliderHandle.h:80
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 37 of file SliderHandle.cpp.

39{
40 wxMouseEvent &event = evt.event;
41 using namespace RefreshCode;
42 if (!event.Button(wxMOUSE_BTN_LEFT))
43 return Cancelled;
44
45 // Come here for left click or double click
47 auto slider = GetSlider( pProject );
48 slider->OnMouseEvent(event);
49 const float newValue = slider->Get();
50
51 // Make a non-permanent change to the project data:
52 auto result = SetValue(pProject, newValue);
53
54 if (event.ButtonDClick())
55 // Just did a modal dialog in OnMouseEvent
56 // Do not start a drag
57 return result | RefreshCell | Cancelled;
58 else {
59 mIsClicked = true;
60 return result | RefreshCell;
61 }
62}
virtual float GetValue()=0
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References RefreshCode::Cancelled, TrackPanelMouseEvent::event, GetSlider(), GetValue(), mIsClicked, 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 GainSliderHandle, 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 64 of file SliderHandle.cpp.

66{
67 wxMouseEvent &event = evt.event;
68 using namespace RefreshCode;
69 GetSlider( pProject )->OnMouseEvent(event);
70 const float newValue = GetSlider( pProject )->Get();
71
72 // Make a non-permanent change to the project data:
73 return RefreshCell | SetValue(pProject, newValue);
74}
float Get(bool convert=true)
Definition: ASlider.cpp:1555

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.

◆ GetSlider()

LWSlider * SliderHandle::GetSlider ( AudacityProject pProject)
protected

Definition at line 116 of file SliderHandle.cpp.

117{
118 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
119 return mSliderFn( pProject, mRect, pTrack.get() );
120}
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1606
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:487

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 35 of file SliderHandle.h.

35{ return mpTrack.lock(); }

◆ GetValue()

virtual float SliderHandle::GetValue ( )
protectedpure virtual

Implemented in GainSliderHandle, and PanSliderHandle.

Referenced by Click().

Here is the caller graph for this function:

◆ IsClicked()

bool SliderHandle::IsClicked ( ) const
inline

Definition at line 36 of file SliderHandle.h.

36{ return mIsClicked; }

◆ operator=()

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

◆ Preview()

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

Implements UIHandle.

Definition at line 76 of file SliderHandle.cpp.

78{
79 // No special cursor
80 TranslatableString message;
81 if (project)
82 message = Tip(st.state, *project);
83 return { message, {}, message };
84}
virtual TranslatableString Tip(const wxMouseState &state, AudacityProject &project) const =0
Holds a msgid for the translation catalog; may also bind format arguments.

References 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 86 of file SliderHandle.cpp.

89{
90 using namespace RefreshCode;
91 wxMouseEvent &event = evt.event;
92 GetSlider( pProject )->OnMouseEvent(event);
93 const float newValue = GetSlider( pProject )->Get();
94
95 Result result = RefreshCell;
96
97 // Commit changes to the project data:
98 result |= SetValue(pProject, newValue);
99 result |= CommitChanges(event, pProject);
100
101 mpTrack.reset();
102 return result;
103}
virtual Result CommitChanges(const wxMouseEvent &event, AudacityProject *pProject)=0
unsigned Result
Definition: UIHandle.h:38

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 GainSliderHandle, 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 GainSliderHandle, and PanSliderHandle.

Referenced by Preview().

Here is the caller graph for this function:

Member Data Documentation

◆ mIsClicked

bool SliderHandle::mIsClicked {}
protected

Definition at line 82 of file SliderHandle.h.

Referenced by Click().

◆ mpTrack

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

◆ mRect

wxRect SliderHandle::mRect {}
protected

Definition at line 76 of file SliderHandle.h.

Referenced by GetSlider().

◆ mSliderFn

SliderFn SliderHandle::mSliderFn
protected

Definition at line 77 of file SliderHandle.h.

Referenced by GetSlider().

◆ mStartingValue

float SliderHandle::mStartingValue {}
protected

Definition at line 80 of file SliderHandle.h.

Referenced by Cancel(), and Click().


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