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

#include <WaveTrackSliderHandles.h>

Inheritance diagram for PanSliderHandle:
Collaboration diagram for PanSliderHandle:

Public Member Functions

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

 PanSliderHandle (const PanSliderHandle &)=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 55 of file WaveTrackSliderHandles.h.

Constructor & Destructor Documentation

◆ PanSliderHandle() [1/2]

PanSliderHandle::PanSliderHandle ( const PanSliderHandle )

◆ PanSliderHandle() [2/2]

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

Definition at line 118 of file WaveTrackSliderHandles.cpp.

120 : SliderHandle{ sliderFn, rect, pTrack }

◆ ~PanSliderHandle()

PanSliderHandle::~PanSliderHandle ( )

Definition at line 123 of file WaveTrackSliderHandles.cpp.


Member Function Documentation

◆ CommitChanges()

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

Implements SliderHandle.

Definition at line 153 of file WaveTrackSliderHandles.cpp.

156 ProjectHistory::Get( *pProject )
157 .PushState(XO("Moved pan slider"), XO("Pan"), 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 PanSliderHandle::GetValue ( )

Implements SliderHandle.

Definition at line 132 of file WaveTrackSliderHandles.cpp.

134 if (GetWaveTrack())
135 return GetWaveTrack()->GetPan();
136 else
137 return 0;
std::shared_ptr< WaveTrack > GetWaveTrack() const

References GetWaveTrack().

Here is the call graph for this function:

◆ GetWaveTrack()

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

Definition at line 127 of file WaveTrackSliderHandles.cpp.

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

Definition at line 193 of file WaveTrackSliderHandles.cpp.

198 if (!state.ButtonIsDown(wxMOUSE_BTN_LEFT))
199 return {};
201 wxRect sliderRect;
202 WaveTrackControls::GetPanRect(rect.GetTopLeft(), sliderRect);
203 if ( CommonTrackInfo::HideTopItem( rect, sliderRect))
204 return {};
205 if (sliderRect.Contains(state.m_x, state.m_y)) {
206 auto sliderFn =
207 []( AudacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) {
209 (sliderRect, static_cast<WaveTrack*>( pTrack ), true,
210 &TrackPanel::Get( *pProject ));
211 };
212 auto result = std::make_shared<PanSliderHandle>(
213 sliderFn, sliderRect, pTrack );
214 result = AssignUIHandlePtr(holder, result);
216 return result;
217 }
218 else
219 return {};
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:159
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:122
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:233
static void GetPanRect(const wxPoint &topLeft, wxRect &dest)
static LWSlider * PanSlider(CellularPanel &panel, const WaveTrack &wt)
A Track that contains audio waveform data.
Definition: WaveTrack.h:222
AUDACITY_DLL_API bool HideTopItem(const wxRect &rect, const wxRect &subRect, int allowance=0)

References AssignUIHandlePtr(), TrackPanel::Get(), WaveTrackControls::GetPanRect(), CommonTrackInfo::HideTopItem(), and WaveTrackControls::PanSlider().

Referenced by WaveTrackControls::HitTest().

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

◆ operator=()

PanSliderHandle & PanSliderHandle::operator= ( const PanSliderHandle )

◆ SetValue()

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

Implements SliderHandle.

Definition at line 140 of file WaveTrackSliderHandles.cpp.

142 (void)pProject;//Compiler food
143 using namespace RefreshCode;
144 Result result = RefreshNone;
145 auto pTrack = GetWaveTrack();
147 if (pTrack)
148 pTrack->SetPan(newValue);
150 return result;
unsigned Result
Definition: UIHandle.h:39
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References GetWaveTrack(), and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ StopsOnKeystroke()

bool PanSliderHandle::StopsOnKeystroke ( )

Reimplemented from UIHandle.

Definition at line 79 of file WaveTrackSliderHandles.h.

79{ return true; }

◆ Tip()

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

Implements SliderHandle.

Definition at line 161 of file WaveTrackSliderHandles.cpp.

165 float value = 0.0;
167 auto pTrack = GetWaveTrack();
168 if (pTrack)
169 value = pTrack->GetPan();
171 // LLL: Can't access the slider since Tip() is a const method and getting the slider
172 // is not, so duplicate what LWSlider does.
174 if (value == 0.0)
175 {
176 val = XO("Center");
177 }
178 else
179 {
180 const auto v = 100.0f * fabsf(value);
181 if (value < 0.0)
182 /* i18n-hint: Stereo pan setting */
183 val = XO("%.0f%% Left").Format(v);
184 else
185 /* i18n-hint: Stereo pan setting */
186 val = XO("%.0f%% Right").Format(v);
187 }
189 /* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
190 return XO("%s: %s").Format(XO("Pan"), val);
Holds a msgid for the translation catalog; may also bind format arguments.

References GetWaveTrack(), and XO().

Here is the call graph for this function:

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