Audacity  3.0.3
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< TrackGetTrack () const
 
bool IsClicked () const
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape () const
 
virtual bool Escape (AudacityProject *pProject)
 
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)
 

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 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 ()
 
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 mIsClicked {}
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 23 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 28 of file NoteTrackSliderHandles.cpp.

31  : SliderHandle{ sliderFn, rect, pTrack }
32 {}

◆ ~VelocitySliderHandle()

VelocitySliderHandle::~VelocitySliderHandle ( )
virtual

Definition at line 34 of file NoteTrackSliderHandles.cpp.

35 {
36 }

Member Function Documentation

◆ CommitChanges()

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

Implements SliderHandle.

Definition at line 64 of file NoteTrackSliderHandles.cpp.

66 {
67  ProjectHistory::Get( *pProject )
68  .PushState(XO("Moved velocity slider"), XO("Velocity"),
71 }

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 38 of file NoteTrackSliderHandles.cpp.

39 {
40  return std::static_pointer_cast<NoteTrack>(mpTrack.lock());
41 }

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 43 of file NoteTrackSliderHandles.cpp.

44 {
45  if (GetNoteTrack())
46  return GetNoteTrack()->GetVelocity();
47  else
48  return 0;
49 }

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 97 of file NoteTrackSliderHandles.cpp.

101 {
102  if (!state.ButtonIsDown(wxMOUSE_BTN_LEFT))
103  return {};
104 
105  wxRect sliderRect;
106  NoteTrackControls::GetVelocityRect(rect.GetTopLeft(), sliderRect);
107  if ( TrackInfo::HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) )
108  return {};
109  if (sliderRect.Contains(state.m_x, state.m_y)) {
110  auto sliderFn =
111  []( AudacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) {
113  (sliderRect, static_cast<NoteTrack*>( pTrack ), true,
114  &TrackPanel::Get( *pProject ));
115  };
116  auto result = std::make_shared<VelocitySliderHandle>(
117  sliderFn, sliderRect, pTrack );
118  result = AssignUIHandlePtr(holder, result);
119 
120  return result;
121  }
122  else
123  return {};
124 }

References AssignUIHandlePtr(), TrackPanel::Get(), NoteTrackControls::GetVelocityRect(), TrackInfo::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 51 of file NoteTrackSliderHandles.cpp.

53 {
54  (void)pProject;//Compiler food
55  auto pTrack = GetNoteTrack();
56 
57  if (pTrack) {
58  pTrack->SetVelocity(newValue);
59  }
60 
62 }

References GetNoteTrack(), and RefreshCode::RefreshCell.

Here is the call graph for this function:

◆ StopsOnKeystroke()

bool VelocitySliderHandle::StopsOnKeystroke ( )
inlineoverrideprotectedvirtual

Reimplemented from UIHandle.

Definition at line 48 of file NoteTrackSliderHandles.h.

48 { return true; }

◆ Tip()

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

Implements SliderHandle.

Definition at line 73 of file NoteTrackSliderHandles.cpp.

75 {
77  float value = 0;
78 
79  auto pTrack = GetNoteTrack();
80  if (pTrack)
81  value = pTrack->GetVelocity();
82 
83  // LLL: Can't access the slider since Tip() is a const method and getting the slider
84  // is not, so duplicate what LWSlider does.
85 
86  if (value > 0.0f)
87  // Signed
88  val = Verbatim("%+d").Format((int)value);
89  else
90  // Zero, or signed negative
91  val = Verbatim("%d").Format((int)value);
92 
93  /* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
94  return XO("%s: %s").Format(XO("Velocity"), val);
95 }

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:
TranslatableString
Definition: Types.h:290
TrackPanel::Get
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:222
XO
#define XO(s)
Definition: Internat.h:33
VelocitySliderHandle::GetNoteTrack
std::shared_ptr< NoteTrack > GetNoteTrack() const
Definition: NoteTrackSliderHandles.cpp:38
SliderHandle
Definition: SliderHandle.h:22
SliderHandle::mpTrack
std::weak_ptr< Track > mpTrack
Definition: SliderHandle.h:74
RefreshCode::RefreshCell
@ RefreshCell
Definition: RefreshCode.h:24
kTrackInfoSliderAllowance
@ kTrackInfoSliderAllowance
Definition: ViewInfo.h:114
ProjectHistory::PushState
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Definition: ProjectHistory.cpp:89
TrackInfo::HideTopItem
bool HideTopItem(const wxRect &rect, const wxRect &subRect, int allowance=0)
Definition: TrackInfo.cpp:208
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:238
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
Verbatim
TranslatableString Verbatim(wxString str)
Definition: Types.h:573
UndoPush::CONSOLIDATE
@ CONSOLIDATE
AssignUIHandlePtr
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:147
TranslatableString::Format
TranslatableString & Format(Args &&...args) &
Definition: Types.h:363
NoteTrackControls::GetVelocityRect
static void GetVelocityRect(const wxPoint &topleft, wxRect &dest)
Definition: NoteTrackControls.cpp:235
NoteTrackControls::VelocitySlider
static LWSlider * VelocitySlider(const wxRect &sliderRect, const NoteTrack *t, bool captured, wxWindow *pParent)
Definition: NoteTrackControls.cpp:275
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
NoteTrack
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:66