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

#include <WaveTrackSliderHandles.h>

Inheritance diagram for GainSliderHandle:
Collaboration diagram for GainSliderHandle:

Public Member Functions

 GainSliderHandle (SliderFn sliderFn, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
GainSliderHandleoperator= (const GainSliderHandle &)=default
virtual ~GainSliderHandle ()
- 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< GainSliderHandle > &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

 GainSliderHandle (const GainSliderHandle &)=delete
std::shared_ptr< WaveTrackGetWaveTrack () 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 WaveTrackSliderHandles.h.

Constructor & Destructor Documentation

◆ GainSliderHandle() [1/2]

GainSliderHandle::GainSliderHandle ( const GainSliderHandle )

◆ GainSliderHandle() [2/2]

GainSliderHandle::GainSliderHandle ( SliderFn  sliderFn,
const wxRect &  rect,
const std::shared_ptr< Track > &  pTrack 

Definition at line 23 of file WaveTrackSliderHandles.cpp.

25 : SliderHandle{ sliderFn, rect, pTrack }

◆ ~GainSliderHandle()

GainSliderHandle::~GainSliderHandle ( )

Definition at line 28 of file WaveTrackSliderHandles.cpp.


Member Function Documentation

◆ CommitChanges()

UIHandle::Result GainSliderHandle::CommitChanges ( const wxMouseEvent &  event,
AudacityProject pProject 

Implements SliderHandle.

Definition at line 57 of file WaveTrackSliderHandles.cpp.

60 ProjectHistory::Get( *pProject )
61 .PushState(XO("Moved gain slider"), XO("Gain"), UndoPush::CONSOLIDATE);
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:

◆ GetValue()

float GainSliderHandle::GetValue ( )

Implements SliderHandle.

Definition at line 37 of file WaveTrackSliderHandles.cpp.

39 if (GetWaveTrack())
40 return GetWaveTrack()->GetGain();
41 else
42 return 0;
std::shared_ptr< WaveTrack > GetWaveTrack() const

References GetWaveTrack().

Here is the call graph for this function:

◆ GetWaveTrack()

std::shared_ptr< WaveTrack > GainSliderHandle::GetWaveTrack ( ) const

Definition at line 32 of file WaveTrackSliderHandles.cpp.

34 return std::static_pointer_cast<WaveTrack>(mpTrack.lock());
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:

◆ HitTest()

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

Definition at line 85 of file WaveTrackSliderHandles.cpp.

90 if (!state.ButtonIsDown(wxMOUSE_BTN_LEFT))
91 return {};
93 wxRect sliderRect;
94 WaveTrackControls::GetGainRect(rect, sliderRect);
95 if ( CommonTrackInfo::HideTopItem( rect, sliderRect))
96 return {};
97 if (sliderRect.Contains(state.m_x, state.m_y)) {
98 wxRect sliderRect2;
99 WaveTrackControls::GetGainRect(rect, sliderRect2);
100 auto sliderFn =
101 []( AudacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) {
103 (sliderRect, static_cast<WaveTrack*>( pTrack ), true,
104 &TrackPanel::Get( *pProject ));
105 };
106 auto result =
107 std::make_shared<GainSliderHandle>( sliderFn, sliderRect2, pTrack );
108 result = AssignUIHandlePtr(holder, result);
110 return result;
111 }
112 else
113 return {};
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:164
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
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
static void GetGainRect(const wxRect &rect, wxRect &dest)
static LWSlider * GainSlider(CellularPanel &panel, const WaveTrack &wt)
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
AUDACITY_DLL_API bool HideTopItem(const wxRect &rect, const wxRect &subRect, int allowance=0)

References AssignUIHandlePtr(), WaveTrackControls::GainSlider(), TrackPanel::Get(), WaveTrackControls::GetGainRect(), and CommonTrackInfo::HideTopItem().

Referenced by WaveTrackControls::HitTest().

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

◆ operator=()

GainSliderHandle & GainSliderHandle::operator= ( const GainSliderHandle )

◆ SetValue()

UIHandle::Result GainSliderHandle::SetValue ( AudacityProject pProject,
float  newValue 

Implements SliderHandle.

Definition at line 45 of file WaveTrackSliderHandles.cpp.

48 (void)pProject;//Compiler food
49 auto pTrack = GetWaveTrack();
51 if (pTrack)
52 pTrack->SetGain(newValue);

References GetWaveTrack(), and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ StopsOnKeystroke()

bool GainSliderHandle::StopsOnKeystroke ( )

Reimplemented from UIHandle.

Definition at line 44 of file WaveTrackSliderHandles.h.

44{ return true; }

◆ Tip()

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

Implements SliderHandle.

Definition at line 65 of file WaveTrackSliderHandles.cpp.

69 float value = 0;
71 auto pTrack = GetWaveTrack();
72 if (pTrack)
73 value = pTrack->GetGain();
75 // LLL: Can't access the slider since Tip() is a const method and getting the slider
76 // is not, so duplicate what LWSlider does.
78 /* i18n-hint dB abbreviates decibels */
79 val = XO("%+.1f dB").Format(LINEAR_TO_DB(value));
81 /* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
82 return XO("%s: %s").Format(XO("Gain"), val);
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:339
Holds a msgid for the translation catalog; may also bind format arguments.

References GetWaveTrack(), LINEAR_TO_DB, and XO().

Here is the call graph for this function:

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