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

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

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

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

Constructor & Destructor Documentation

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

Definition at line 23 of file WaveTrackSliderHandles.cpp.

24  : SliderHandle{ sliderFn, rect, pTrack }
25 {}
GainSliderHandle::~GainSliderHandle ( )
virtual

Definition at line 27 of file WaveTrackSliderHandles.cpp.

28 {
29 }

Member Function Documentation

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

Implements SliderHandle.

Definition at line 66 of file WaveTrackSliderHandles.cpp.

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

67 {
68  pProject->PushState(_("Moved gain slider"), _("Gain"), UndoPush::CONSOLIDATE);
70 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
void PushState(const wxString &desc, const wxString &shortDesc)
Definition: Project.cpp:4486
float GainSliderHandle::GetValue ( )
overrideprotectedvirtual

Implements SliderHandle.

Definition at line 36 of file WaveTrackSliderHandles.cpp.

References GetWaveTrack().

37 {
38  if (GetWaveTrack())
39  return GetWaveTrack()->GetGain();
40  else
41  return 0;
42 }
std::shared_ptr< WaveTrack > GetWaveTrack()
std::shared_ptr< WaveTrack > GainSliderHandle::GetWaveTrack ( )
private

Definition at line 31 of file WaveTrackSliderHandles.cpp.

References SliderHandle::mpTrack.

Referenced by GetValue().

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

Definition at line 73 of file WaveTrackSliderHandles.cpp.

References AssignUIHandlePtr(), TrackInfo::GainSlider(), TrackInfo::GetGainRect(), AudacityProject::GetTrackPanel(), TrackInfo::HideTopItem(), and kTrackInfoSliderAllowance.

Referenced by WaveTrackControls::HitTest().

76 {
77  if (!state.ButtonIsDown(wxMOUSE_BTN_LEFT))
78  return {};
79 
80  wxRect sliderRect;
81  TrackInfo::GetGainRect(rect.GetTopLeft(), sliderRect);
82  if ( TrackInfo::HideTopItem( rect, sliderRect, kTrackInfoSliderAllowance ) )
83  return {};
84  if (sliderRect.Contains(state.m_x, state.m_y)) {
85  wxRect sliderRect;
86  TrackInfo::GetGainRect(rect.GetTopLeft(), sliderRect);
87  auto sliderFn =
88  []( AudacityProject *pProject, const wxRect &sliderRect, Track *pTrack ) {
90  (sliderRect, static_cast<WaveTrack*>( pTrack ), true,
91  const_cast<TrackPanel*>(pProject->GetTrackPanel()));
92  };
93  auto result =
94  std::make_shared<GainSliderHandle>( sliderFn, sliderRect, pTrack );
95  result = AssignUIHandlePtr(holder, result);
96 
97  return result;
98  }
99  else
100  return {};
101 }
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:161
static void GetGainRect(const wxPoint &topLeft, wxRect &dest)
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:67
static bool HideTopItem(const wxRect &rect, const wxRect &subRect, int allowance=0)
TrackPanel * GetTrackPanel()
Definition: Project.h:292
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:162
static LWSlider * GainSlider(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
GainSliderHandle& GainSliderHandle::operator= ( const GainSliderHandle )
default
UIHandle::Result GainSliderHandle::SetValue ( AudacityProject pProject,
float  newValue 
)
overrideprotectedvirtual

Implements SliderHandle.

Definition at line 45 of file WaveTrackSliderHandles.cpp.

References AudacityProject::GetMixerBoard(), RefreshCode::RefreshNone, WaveTrack::SetGain(), and MixerBoard::UpdateGain().

46 {
47  auto pTrack = GetWaveTrack();
48 
49  if (pTrack) {
50  pTrack->SetGain(newValue);
51 
52  // Assume linked track is wave or null
53  const auto link = static_cast<WaveTrack*>(mpTrack.lock()->GetLink());
54  if (link)
55  link->SetGain(newValue);
56 
57  MixerBoard *const pMixerBoard = pProject->GetMixerBoard();
58  if (pMixerBoard)
59  pMixerBoard->UpdateGain(pTrack.get());
60  }
61 
63 }
std::weak_ptr< Track > mpTrack
Definition: SliderHandle.h:71
MixerBoard * GetMixerBoard()
Definition: Project.h:503
std::shared_ptr< WaveTrack > GetWaveTrack()
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
void UpdateGain(const PlayableTrack *pTrack)
void SetGain(float newGain)
Definition: WaveTrack.cpp:419
bool GainSliderHandle::StopsOnKeystroke ( )
inlineoverrideprotectedvirtual

Reimplemented from UIHandle.

Definition at line 41 of file WaveTrackSliderHandles.h.

41 { return true; }

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