Audacity  2.2.2
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:
SliderHandle UIHandle

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< 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 ()
 
virtual void DrawExtras (DrawingPass pass, wxDC *dc, const wxRegion &updateRegion, const wxRect &panelRect)
 
virtual void OnProjectChange (AudacityProject *pProject)
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 

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 &)
 

Protected Member Functions

float GetValue () override
 
Result SetValue (AudacityProject *pProject, float newValue) override
 
Result CommitChanges (const wxMouseEvent &event, AudacityProject *pProject) override
 
bool StopsOnKeystroke () override
 
- Protected Member Functions inherited from SliderHandle
virtual ~SliderHandle ()
 
void Enter (bool forward) override
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) finaloverride
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) finaloverride
 
HitTestPreview Preview (const TrackPanelMouseState &state, const AudacityProject *pProject) finaloverride
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) finaloverride
 
Result Cancel (AudacityProject *pProject) finaloverride
 
LWSliderGetSlider (AudacityProject *pProject)
 

Private Member Functions

 PanSliderHandle (const PanSliderHandle &)=delete
 
std::shared_ptr< WaveTrackGetWaveTrack ()
 

Additional Inherited Members

- Public Types inherited from SliderHandle
using SliderFn = LWSlider *(*)(AudacityProject *, const wxRect &, Track *)
 
- Public Types inherited from UIHandle
enum  DrawingPass { Cells, Panel }
 
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 52 of file WaveTrackSliderHandles.h.

Constructor & Destructor Documentation

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

Definition at line 106 of file WaveTrackSliderHandles.cpp.

107  : SliderHandle{ sliderFn, rect, pTrack }
108 {}
PanSliderHandle::~PanSliderHandle ( )
virtual

Definition at line 110 of file WaveTrackSliderHandles.cpp.

111 {
112 }

Member Function Documentation

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

Implements SliderHandle.

Definition at line 150 of file WaveTrackSliderHandles.cpp.

References _(), CONSOLIDATE, AudacityProject::PushState(), and RefreshCode::RefreshCell.

151 {
152  pProject->PushState(_("Moved pan slider"), _("Pan"), UndoPush::CONSOLIDATE);
154 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void PushState(const wxString &desc, const wxString &shortDesc)
Definition: Project.cpp:4702
float PanSliderHandle::GetValue ( )
overrideprotectedvirtual

Implements SliderHandle.

Definition at line 119 of file WaveTrackSliderHandles.cpp.

References GetWaveTrack().

120 {
121  if (GetWaveTrack())
122  return GetWaveTrack()->GetPan();
123  else
124  return 0;
125 }
std::shared_ptr< WaveTrack > GetWaveTrack()
std::shared_ptr< WaveTrack > PanSliderHandle::GetWaveTrack ( )
private

Definition at line 114 of file WaveTrackSliderHandles.cpp.

References SliderHandle::mpTrack.

Referenced by GetValue(), and SetValue().

115 {
116  return std::static_pointer_cast<WaveTrack>(mpTrack.lock());
117 }
std::weak_ptr< Track > mpTrack
Definition: SliderHandle.h:71
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
UIHandlePtr PanSliderHandle::HitTest ( std::weak_ptr< PanSliderHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
const std::shared_ptr< Track > &  pTrack 
)
static

Definition at line 157 of file WaveTrackSliderHandles.cpp.

References AssignUIHandlePtr(), TrackInfo::GetPanRect(), AudacityProject::GetTrackPanel(), TrackInfo::HideTopItem(), and TrackInfo::PanSlider().

Referenced by WaveTrackControls::HitTest().

160 {
161  if (!state.ButtonIsDown(wxMOUSE_BTN_LEFT))
162  return {};
163 
164  wxRect sliderRect;
165  TrackInfo::GetPanRect(rect.GetTopLeft(), sliderRect);
166  if ( TrackInfo::HideTopItem( rect, sliderRect))
167  return {};
168  if (sliderRect.Contains(state.m_x, state.m_y)) {
169  auto sliderFn =
170  []( AudacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) {
171  return TrackInfo::PanSlider
172  (sliderRect, static_cast<WaveTrack*>( pTrack ), true,
173  const_cast<TrackPanel*>(pProject->GetTrackPanel()));
174  };
175  auto result = std::make_shared<PanSliderHandle>(
176  sliderFn, sliderRect, pTrack );
177  result = AssignUIHandlePtr(holder, result);
178 
179  return result;
180  }
181  else
182  return {};
183 }
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
static LWSlider * PanSlider(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
static bool HideTopItem(const wxRect &rect, const wxRect &subRect, int allowance=0)
TrackPanel * GetTrackPanel()
Definition: Project.h:307
static void GetPanRect(const wxPoint &topLeft, wxRect &dest)
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:162
PanSliderHandle& PanSliderHandle::operator= ( const PanSliderHandle )
default
UIHandle::Result PanSliderHandle::SetValue ( AudacityProject pProject,
float  newValue 
)
overrideprotectedvirtual

Implements SliderHandle.

Definition at line 127 of file WaveTrackSliderHandles.cpp.

References AudacityProject::GetMixerBoard(), GetWaveTrack(), RefreshCode::RefreshNone, WaveTrack::SetPan(), and MixerBoard::UpdatePan().

128 {
129  using namespace RefreshCode;
130  Result result = RefreshNone;
131  auto pTrack = GetWaveTrack();
132 
133  if (pTrack) {
134  pTrack->SetPan(newValue);
135 
136  // Assume linked track is wave or null
137  const auto link = static_cast<WaveTrack*>(pTrack->GetLink());
138  if (link)
139  link->SetPan(newValue);
140 
141  MixerBoard *const pMixerBoard = pProject->GetMixerBoard();
142  if (pMixerBoard)
143  pMixerBoard->UpdatePan(pTrack.get());
144  }
145 
146  return result;
147 }
MixerBoard * GetMixerBoard()
Definition: Project.h:516
void UpdatePan(const PlayableTrack *pTrack=NULL)
unsigned Result
Definition: UIHandle.h:37
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
std::shared_ptr< WaveTrack > GetWaveTrack()
void SetPan(float newPan) override
Definition: WaveTrack.cpp:430
bool PanSliderHandle::StopsOnKeystroke ( )
inlineoverrideprotectedvirtual

Reimplemented from UIHandle.

Definition at line 73 of file WaveTrackSliderHandles.h.

73 { return true; }

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