Audacity  3.0.3
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Types | Private Attributes | Static Private Attributes | Friends | List of all members
ASlider Class Reference

ASlider is a custom slider, allowing for a slicker look and feel. More...

#include <ASlider.h>

Inheritance diagram for ASlider:
[legend]
Collaboration diagram for ASlider:
[legend]

Classes

struct  Options
 
struct  Resetter
 

Public Member Functions

 ASlider (wxWindow *parent, wxWindowID id, const TranslatableString &name, const wxPoint &pos, const wxSize &size, const Options &options=Options{})
 
virtual ~ASlider ()
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
void SetFocusFromKbd () override
 
bool SetBackgroundColour (const wxColour &colour) override
 
void GetScroll (float &line, float &page)
 
void SetScroll (float line, float page)
 
void SetToolTipTemplate (const TranslatableString &tip)
 
float Get (bool convert=true)
 
void Set (float value)
 
void Increase (float steps)
 
void Decrease (float steps)
 
bool ShowDialog (wxPoint pos=wxPoint(-1, -1))
 
void SetSpeed (float speed)
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnSize (wxSizeEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void OnCaptureLost (wxMouseCaptureLostEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 
void OnSlider (wxCommandEvent &event)
 
void OnSetFocus (wxFocusEvent &event)
 
void OnKillFocus (wxFocusEvent &event)
 
void OnTimer (wxTimerEvent &event)
 
bool Enable (bool enable=true) override
 
bool IsEnabled () const
 

Static Public Member Functions

static TempAllowFocus TemporarilyAllowFocus ()
 

Protected Attributes

int mStyle
 

Private Types

using TempAllowFocus = std::unique_ptr< bool, Resetter >
 

Private Attributes

std::unique_ptr< LWSlidermLWSlider
 
bool mSliderIsFocused
 
wxTimer mTimer
 

Static Private Attributes

static bool s_AcceptsFocus { false }
 

Friends

class ASliderAx
 

Detailed Description

ASlider is a custom slider, allowing for a slicker look and feel.

It allows you to use images for the slider background and the thumb.

Definition at line 233 of file ASlider.h.

Member Typedef Documentation

◆ TempAllowFocus

using ASlider::TempAllowFocus = std::unique_ptr<bool, Resetter>
private

Definition at line 308 of file ASlider.h.

Constructor & Destructor Documentation

◆ ASlider()

ASlider::ASlider ( wxWindow *  parent,
wxWindowID  id,
const TranslatableString name,
const wxPoint &  pos,
const wxSize &  size,
const Options options = Options{} 
)

Definition at line 1585 of file ASlider.cpp.

1591 : wxPanel( parent, id, pos, size, wxWANTS_CHARS )
1592 {
1593  //wxColour Col(parent->GetBackgroundColour());
1594  //SetBackgroundColour( Col );
1595  SetBackgroundColour( theTheme.Colour( clrMedium ) );
1596  mLWSlider = std::make_unique<LWSlider>( this,
1597  name,
1598  wxPoint(0,0),
1599  size,
1600  options.style,
1601  true, // ASlider is always a heavyweight LWSlider
1602  options.popup,
1603  options.orientation);
1604  mLWSlider->mStepValue = options.stepValue;
1605  mLWSlider->SetId( id );
1606  SetName( name.Translation() );
1607 
1608  mSliderIsFocused = false;
1609  mStyle = options.style;
1610 
1611  mTimer.SetOwner(this);
1612 
1613 #if wxUSE_ACCESSIBILITY
1614  SetAccessible( safenew ASliderAx( this ) );
1615 #endif
1616 
1617  mLWSlider->SetScroll( options.line, options.page );
1618 }

References ThemeBase::Colour(), name, safenew, theTheme, and TranslatableString::Translation().

Here is the call graph for this function:

◆ ~ASlider()

ASlider::~ASlider ( )
virtual

Definition at line 1621 of file ASlider.cpp.

1622 {
1623  if(HasCapture())
1624  ReleaseMouse();
1625 }

Member Function Documentation

◆ AcceptsFocus()

bool ASlider::AcceptsFocus ( ) const
inlineoverride

Definition at line 269 of file ASlider.h.

269 { return s_AcceptsFocus; }

◆ AcceptsFocusFromKeyboard()

bool ASlider::AcceptsFocusFromKeyboard ( ) const
inlineoverride

Definition at line 270 of file ASlider.h.

270 { return true; }

◆ Decrease()

void ASlider::Decrease ( float  steps)

Definition at line 1757 of file ASlider.cpp.

1758 {
1759  mLWSlider->Decrease(steps);
1760 }

References mLWSlider.

Referenced by MixerToolBar::AdjustInputGain(), MixerToolBar::AdjustOutputGain(), and TranscriptionToolBar::AdjustPlaySpeed().

Here is the caller graph for this function:

◆ Enable()

bool ASlider::Enable ( bool  enable = true)
override

Definition at line 1772 of file ASlider.cpp.

1773 {
1774  if (mLWSlider->GetEnabled() == enable)
1775  return false;
1776 
1777  mLWSlider->SetEnabled(enable);
1778 
1779  wxWindow::Enable(enable);
1780 
1781  return true;
1782 }

References mLWSlider.

Referenced by MixerToolBar::OnAudioCapture(), MixerToolBar::Populate(), MixerToolBar::UpdateControls(), and MixerToolBar::UpdatePrefs().

Here is the caller graph for this function:

◆ Get()

float ASlider::Get ( bool  convert = true)

Definition at line 1742 of file ASlider.cpp.

1743 {
1744  return mLWSlider->Get( convert );
1745 }

References mLWSlider.

Referenced by TranscriptionToolBar::Create(), SliderDialog::Get(), MixerTrackCluster::HandleSliderGain(), MixerTrackCluster::HandleSliderPan(), TranscriptionToolBar::OnSpeedSlider(), MixerToolBar::SetMixer(), SliderDialog::TransferDataToWindow(), and MixerToolBar::UpdateControls().

Here is the caller graph for this function:

◆ GetScroll()

void ASlider::GetScroll ( float &  line,
float &  page 
)

Definition at line 1727 of file ASlider.cpp.

1728 {
1729  mLWSlider->GetScroll(line, page);
1730 }

References mLWSlider.

◆ Increase()

void ASlider::Increase ( float  steps)

Definition at line 1752 of file ASlider.cpp.

1753 {
1754  mLWSlider->Increase(steps);
1755 }

References mLWSlider.

Referenced by MixerToolBar::AdjustInputGain(), MixerToolBar::AdjustOutputGain(), and TranscriptionToolBar::AdjustPlaySpeed().

Here is the caller graph for this function:

◆ IsEnabled()

bool ASlider::IsEnabled ( ) const

Definition at line 1784 of file ASlider.cpp.

1785 {
1786  return mLWSlider->GetEnabled();
1787 }

References mLWSlider.

Referenced by MixerToolBar::SetToolTips().

Here is the caller graph for this function:

◆ OnCaptureLost()

void ASlider::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Definition at line 1699 of file ASlider.cpp.

1700 {
1701  wxMouseEvent e(wxEVT_LEFT_UP);
1702  mLWSlider->OnMouseEvent(e);
1703 }

References mLWSlider.

◆ OnErase()

void ASlider::OnErase ( wxEraseEvent &  event)

Definition at line 1660 of file ASlider.cpp.

1661 {
1662  // Ignore it to prevent flashing
1663 }

◆ OnKeyDown()

void ASlider::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1705 of file ASlider.cpp.

1706 {
1707  mLWSlider->OnKeyDown(event);
1708 }

References mLWSlider.

◆ OnKillFocus()

void ASlider::OnKillFocus ( wxFocusEvent &  event)

Definition at line 1716 of file ASlider.cpp.

1717 {
1718  mSliderIsFocused = false;
1719  Refresh();
1720 }

References mSliderIsFocused.

◆ OnMouseEvent()

void ASlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1685 of file ASlider.cpp.

1686 {
1687  if (event.Entering())
1688  {
1689  mTimer.StartOnce(1000);
1690  }
1691  else if (event.Leaving())
1692  {
1693  mTimer.Stop();
1694  }
1695 
1696  mLWSlider->OnMouseEvent(event);
1697 }

References mLWSlider, and mTimer.

Referenced by MixerTrackSlider::OnMouseEvent().

Here is the caller graph for this function:

◆ OnPaint()

void ASlider::OnPaint ( wxPaintEvent &  event)

Definition at line 1665 of file ASlider.cpp.

1666 {
1667  wxBufferedPaintDC dc(this);
1668 
1669  bool highlighted =
1670  GetClientRect().Contains(
1671  ScreenToClient(
1672  ::wxGetMousePosition() ) );
1673  mLWSlider->OnPaint(dc, highlighted);
1674 
1675  if ( mSliderIsFocused )
1676  {
1677  wxRect r( 0, 0, mLWSlider->mWidth, mLWSlider->mHeight );
1678 
1679  r.Deflate( 1, 1 );
1680 
1681  AColor::DrawFocus( dc, r );
1682  }
1683 }

References AColor::DrawFocus(), mLWSlider, and mSliderIsFocused.

Here is the call graph for this function:

◆ OnSetFocus()

void ASlider::OnSetFocus ( wxFocusEvent &  event)

Definition at line 1710 of file ASlider.cpp.

1711 {
1712  mSliderIsFocused = true;
1713  Refresh();
1714 }

References mSliderIsFocused.

◆ OnSize()

void ASlider::OnSize ( wxSizeEvent &  event)

Definition at line 1655 of file ASlider.cpp.

1656 {
1657  mLWSlider->OnSize( event );
1658 }

References mLWSlider.

◆ OnSlider()

void ASlider::OnSlider ( wxCommandEvent &  event)

Definition at line 1639 of file ASlider.cpp.

1640 {
1641 
1642  if ( event.GetId() == mLWSlider->GetId() )
1643  {
1644 #if wxUSE_ACCESSIBILITY
1645  GetAccessible()->NotifyEvent( wxACC_EVENT_OBJECT_VALUECHANGE,
1646  this,
1647  wxOBJID_CLIENT,
1648  wxACC_SELF );
1649 #endif
1650  }
1651 
1652  event.Skip();
1653 }

References mLWSlider.

◆ OnTimer()

void ASlider::OnTimer ( wxTimerEvent &  event)

Definition at line 1722 of file ASlider.cpp.

1723 {
1724  mLWSlider->ShowTip(true);
1725 }

References mLWSlider.

◆ Set()

void ASlider::Set ( float  value)

Definition at line 1747 of file ASlider.cpp.

1748 {
1749  mLWSlider->Set(value);
1750 }

References mLWSlider.

Referenced by TranscriptionToolBar::Populate(), SliderDialog::TransferDataFromWindow(), MixerToolBar::UpdateControls(), and MixerTrackCluster::UpdateForStateChange().

Here is the caller graph for this function:

◆ SetBackgroundColour()

bool ASlider::SetBackgroundColour ( const wxColour &  colour)
override

Definition at line 1627 of file ASlider.cpp.

1628 {
1629  auto res = wxPanel::SetBackgroundColour(colour);
1630 
1631  if (res && mLWSlider)
1632  {
1633  mLWSlider->Redraw();
1634  }
1635 
1636  return res;
1637 }

References mLWSlider.

Referenced by MixerTrackCluster::OnPaint().

Here is the caller graph for this function:

◆ SetFocusFromKbd()

void ASlider::SetFocusFromKbd ( )
override

Definition at line 1799 of file ASlider.cpp.

1800 {
1801  auto temp = TemporarilyAllowFocus();
1802  SetFocus();
1803 }

References TemporarilyAllowFocus().

Here is the call graph for this function:

◆ SetScroll()

void ASlider::SetScroll ( float  line,
float  page 
)

Definition at line 1732 of file ASlider.cpp.

1733 {
1734  mLWSlider->SetScroll(line, page);
1735 }

References mLWSlider.

◆ SetSpeed()

void ASlider::SetSpeed ( float  speed)

Definition at line 1767 of file ASlider.cpp.

1768 {
1769  mLWSlider->SetSpeed(speed);
1770 }

References mLWSlider.

◆ SetToolTipTemplate()

void ASlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 1737 of file ASlider.cpp.

1738 {
1739  mLWSlider->SetToolTipTemplate(tip);
1740 }

References mLWSlider.

Referenced by MixerToolBar::SetToolTips().

Here is the caller graph for this function:

◆ ShowDialog()

bool ASlider::ShowDialog ( wxPoint  pos = wxPoint(-1, -1))

Definition at line 1762 of file ASlider.cpp.

1763 {
1764  return mLWSlider->ShowDialog(pos);
1765 }

References mLWSlider.

Referenced by MixerToolBar::ShowInputGainDialog(), MixerToolBar::ShowOutputGainDialog(), and TranscriptionToolBar::ShowPlaySpeedDialog().

Here is the caller graph for this function:

◆ TemporarilyAllowFocus()

auto ASlider::TemporarilyAllowFocus ( )
static

Definition at line 1791 of file ASlider.cpp.

1791  {
1792  s_AcceptsFocus = true;
1793  return TempAllowFocus{ &s_AcceptsFocus };
1794 }

Referenced by anonymous_namespace{NavigationMenus.cpp}::NextOrPrevFrame(), ToolManager::RestoreFocus(), and SetFocusFromKbd().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ASliderAx

friend class ASliderAx
friend

Definition at line 235 of file ASlider.h.

Member Data Documentation

◆ mLWSlider

std::unique_ptr<LWSlider> ASlider::mLWSlider
private

◆ mSliderIsFocused

bool ASlider::mSliderIsFocused
private

Definition at line 315 of file ASlider.h.

Referenced by OnKillFocus(), OnPaint(), and OnSetFocus().

◆ mStyle

int ASlider::mStyle
protected

Definition at line 319 of file ASlider.h.

Referenced by MixerTrackSlider::OnMouseEvent().

◆ mTimer

wxTimer ASlider::mTimer
private

Definition at line 316 of file ASlider.h.

Referenced by OnMouseEvent().

◆ s_AcceptsFocus

bool ASlider::s_AcceptsFocus { false }
staticprivate

Definition at line 306 of file ASlider.h.


The documentation for this class was generated from the following files:
ASlider::s_AcceptsFocus
static bool s_AcceptsFocus
Definition: ASlider.h:306
ASlider::ASliderAx
friend class ASliderAx
Definition: ASlider.h:235
ASlider::SetBackgroundColour
bool SetBackgroundColour(const wxColour &colour) override
Definition: ASlider.cpp:1627
ASlider::mSliderIsFocused
bool mSliderIsFocused
Definition: ASlider.h:315
name
const TranslatableString name
Definition: Distortion.cpp:98
ASlider::mLWSlider
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:314
AColor::DrawFocus
static void DrawFocus(wxDC &dc, wxRect &r)
Definition: AColor.cpp:160
ASlider::TempAllowFocus
std::unique_ptr< bool, Resetter > TempAllowFocus
Definition: ASlider.h:308
ASlider::TemporarilyAllowFocus
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1791
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1197
ASlider::mStyle
int mStyle
Definition: ASlider.h:319
theTheme
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:203
TranslatableString::Translation
wxString Translation() const
Definition: TranslatableString.h:79
safenew
#define safenew
Definition: MemoryX.h:10
ASlider::mTimer
wxTimer mTimer
Definition: ASlider.h:316