Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
VelocitySliderHandle Class Referencefinal

#include <NoteTrackSliderHandles.h>

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

Public Member Functions

 VelocitySliderHandle (SliderFn sliderFn, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
 
VelocitySliderHandleoperator= (const VelocitySliderHandle &)=default
 
virtual ~VelocitySliderHandle ()
 
- Public Member Functions inherited from SliderHandle
 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)
 

Static Public Member Functions

static UIHandlePtr HitTest (std::weak_ptr< VelocitySliderHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
 
- 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)
 

Protected Member Functions

float GetValue () override
 
Result SetValue (AudacityProject *pProject, float newValue) override
 
Result CommitChanges (const wxMouseEvent &event, AudacityProject *pProject) override
 
TranslatableString Tip (const wxMouseState &state, AudacityProject &) const override
 
bool StopsOnKeystroke () override
 
- Protected Member Functions inherited from SliderHandle
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)
 

Private Member Functions

 VelocitySliderHandle (const VelocitySliderHandle &)=delete
 
std::shared_ptr< NoteTrackGetNoteTrack () const
 

Additional Inherited Members

- Public Types inherited from SliderHandle
using SliderFn = LWSlider *(*)(AudacityProject *, const wxRect &, Track *)
 
- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Protected Attributes inherited from SliderHandle
std::weak_ptr< TrackmpTrack
 
wxRect mRect {}
 
SliderFn mSliderFn
 
float mStartingValue {}
 
bool mIsDragging {}
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 19 of file NoteTrackSliderHandles.h.

Constructor & Destructor Documentation

◆ VelocitySliderHandle() [1/2]

VelocitySliderHandle::VelocitySliderHandle ( const VelocitySliderHandle )
privatedelete

◆ VelocitySliderHandle() [2/2]

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

Definition at line 21 of file NoteTrackSliderHandles.cpp.

24 : SliderHandle{ sliderFn, rect, pTrack }
25{}

◆ ~VelocitySliderHandle()

VelocitySliderHandle::~VelocitySliderHandle ( )
virtual

Definition at line 27 of file NoteTrackSliderHandles.cpp.

28{
29}

Member Function Documentation

◆ CommitChanges()

UIHandle::Result VelocitySliderHandle::CommitChanges ( const wxMouseEvent &  event,
AudacityProject pProject 
)
overrideprotectedvirtual

Implements SliderHandle.

Definition at line 57 of file NoteTrackSliderHandles.cpp.

59{
60 ProjectHistory::Get( *pProject )
61 .PushState(XO("Moved velocity slider"), XO("Velocity"),
64}
XO("Cut/Copy/Paste")
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)

References CONSOLIDATE, ProjectHistory::Get(), ProjectHistory::PushState(), RefreshCode::RefreshCell, and XO().

Here is the call graph for this function:

◆ GetNoteTrack()

std::shared_ptr< NoteTrack > VelocitySliderHandle::GetNoteTrack ( ) const
private

Definition at line 31 of file NoteTrackSliderHandles.cpp.

32{
33 return std::static_pointer_cast<NoteTrack>(mpTrack.lock());
34}
std::weak_ptr< Track > mpTrack
Definition: SliderHandle.h:76

References SliderHandle::mpTrack.

Referenced by GetValue(), SetValue(), and Tip().

Here is the caller graph for this function:

◆ GetValue()

float VelocitySliderHandle::GetValue ( )
overrideprotectedvirtual

Implements SliderHandle.

Definition at line 36 of file NoteTrackSliderHandles.cpp.

37{
38 if (GetNoteTrack())
39 return GetNoteTrack()->GetVelocity();
40 else
41 return 0;
42}
std::shared_ptr< NoteTrack > GetNoteTrack() const

References GetNoteTrack().

Here is the call graph for this function:

◆ HitTest()

UIHandlePtr VelocitySliderHandle::HitTest ( std::weak_ptr< VelocitySliderHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
const std::shared_ptr< Track > &  pTrack 
)
static

Definition at line 90 of file NoteTrackSliderHandles.cpp.

94{
95 if (!state.ButtonIsDown(wxMOUSE_BTN_LEFT))
96 return {};
97
98 wxRect sliderRect;
99 NoteTrackControls::GetVelocityRect(rect.GetTopLeft(), sliderRect);
101 return {};
102 if (sliderRect.Contains(state.m_x, state.m_y)) {
103 auto sliderFn =
104 []( AudacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) {
106 (sliderRect, static_cast<NoteTrack*>( pTrack ), true,
107 &TrackPanel::Get( *pProject ));
108 };
109 auto result = std::make_shared<VelocitySliderHandle>(
110 sliderFn, sliderRect, pTrack );
111 result = AssignUIHandlePtr(holder, result);
112
113 return result;
114 }
115 else
116 return {};
117}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:164
@ kTrackInfoSliderAllowance
Definition: ViewInfo.h:100
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static LWSlider * VelocitySlider(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *pParent)
static void GetVelocityRect(const wxPoint &topleft, wxRect &dest)
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:78
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234
AUDACITY_DLL_API bool HideTopItem(const wxRect &rect, const wxRect &subRect, int allowance=0)

References AssignUIHandlePtr(), TrackPanel::Get(), NoteTrackControls::GetVelocityRect(), CommonTrackInfo::HideTopItem(), kTrackInfoSliderAllowance, and NoteTrackControls::VelocitySlider().

Referenced by NoteTrackControls::HitTest().

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

◆ operator=()

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

◆ SetValue()

UIHandle::Result VelocitySliderHandle::SetValue ( AudacityProject pProject,
float  newValue 
)
overrideprotectedvirtual

Implements SliderHandle.

Definition at line 44 of file NoteTrackSliderHandles.cpp.

46{
47 (void)pProject;//Compiler food
48 auto pTrack = GetNoteTrack();
49
50 if (pTrack) {
51 pTrack->SetVelocity(newValue);
52 }
53
55}

References GetNoteTrack(), and RefreshCode::RefreshCell.

Here is the call graph for this function:

◆ StopsOnKeystroke()

bool VelocitySliderHandle::StopsOnKeystroke ( )
inlineoverrideprotectedvirtual

Reimplemented from UIHandle.

Definition at line 44 of file NoteTrackSliderHandles.h.

44{ return true; }

◆ Tip()

TranslatableString VelocitySliderHandle::Tip ( const wxMouseState &  state,
AudacityProject project 
) const
overrideprotectedvirtual

Implements SliderHandle.

Definition at line 66 of file NoteTrackSliderHandles.cpp.

68{
70 float value = 0;
71
72 auto pTrack = GetNoteTrack();
73 if (pTrack)
74 value = pTrack->GetVelocity();
75
76 // LLL: Can't access the slider since Tip() is a const method and getting the slider
77 // is not, so duplicate what LWSlider does.
78
79 if (value > 0.0f)
80 // Signed
81 val = Verbatim("%+d").Format((int)value);
82 else
83 // Zero, or signed negative
84 val = Verbatim("%d").Format((int)value);
85
86 /* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
87 return XO("%s: %s").Format(XO("Velocity"), val);
88}
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Holds a msgid for the translation catalog; may also bind format arguments.
TranslatableString & Format(Args &&...args) &
Capture variadic format arguments (by copy) when there is no plural.

References TranslatableString::Format(), GetNoteTrack(), Verbatim(), and XO().

Here is the call graph for this function:

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