Audacity 3.2.0
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 251 of file ASlider.h.

Member Typedef Documentation

◆ TempAllowFocus

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

Definition at line 334 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 1623 of file ASlider.cpp.

1629: wxPanel( parent, id, pos, size, wxWANTS_CHARS )
1630{
1631 //wxColour Col(parent->GetBackgroundColour());
1632 //SetBackgroundColour( Col );
1633 SetBackgroundColour( theTheme.Colour( clrMedium ) );
1634 mLWSlider = std::make_unique<LWSlider>( this,
1635 name,
1636 wxPoint(0,0),
1637 size,
1638 options.style,
1639 options.showLabels,
1640 options.drawTicks,
1641 options.drawTrack,
1642 options.alwaysHideTip,
1643 true, // ASlider is always a heavyweight LWSlider
1644 options.popup,
1645 options.orientation);
1646 mLWSlider->mStepValue = options.stepValue;
1647 mLWSlider->SetId( id );
1648 SetName( name.Translation() );
1649
1650 mSliderIsFocused = false;
1651 mStyle = options.style;
1652
1653 mTimer.SetOwner(this);
1654
1655#if wxUSE_ACCESSIBILITY
1656 SetAccessible( safenew ASliderAx( this ) );
1657#endif
1658
1659 mLWSlider->SetScroll( options.line, options.page );
1660}
const TranslatableString name
Definition: Distortion.cpp:82
#define safenew
Definition: MemoryX.h:10
THEME_API Theme theTheme
Definition: Theme.cpp:82
friend class ASliderAx
Definition: ASlider.h:253
int mStyle
Definition: ASlider.h:345
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:340
bool mSliderIsFocused
Definition: ASlider.h:341
bool SetBackgroundColour(const wxColour &colour) override
Definition: ASlider.cpp:1669
wxTimer mTimer
Definition: ASlider.h:342
wxColour & Colour(int iIndex)
wxString Translation() const

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

Here is the call graph for this function:

◆ ~ASlider()

ASlider::~ASlider ( )
virtual

Definition at line 1663 of file ASlider.cpp.

1664{
1665 if(HasCapture())
1666 ReleaseMouse();
1667}

Member Function Documentation

◆ AcceptsFocus()

bool ASlider::AcceptsFocus ( ) const
inlineoverride

Definition at line 295 of file ASlider.h.

295{ return s_AcceptsFocus; }
static bool s_AcceptsFocus
Definition: ASlider.h:332

◆ AcceptsFocusFromKeyboard()

bool ASlider::AcceptsFocusFromKeyboard ( ) const
inlineoverride

Definition at line 296 of file ASlider.h.

296{ return true; }

◆ Decrease()

void ASlider::Decrease ( float  steps)

Definition at line 1799 of file ASlider.cpp.

1800{
1801 mLWSlider->Decrease(steps);
1802}

References mLWSlider.

Referenced by TranscriptionToolBar::AdjustPlaySpeed().

Here is the caller graph for this function:

◆ Enable()

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

Definition at line 1814 of file ASlider.cpp.

1815{
1816 if (mLWSlider->GetEnabled() == enable)
1817 return false;
1818
1819 mLWSlider->SetEnabled(enable);
1820
1821 wxWindow::Enable(enable);
1822
1823 return true;
1824}

References mLWSlider.

◆ Get()

float ASlider::Get ( bool  convert = true)

Definition at line 1784 of file ASlider.cpp.

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

References mLWSlider.

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

Here is the caller graph for this function:

◆ GetScroll()

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

Definition at line 1769 of file ASlider.cpp.

1770{
1771 mLWSlider->GetScroll(line, page);
1772}

References mLWSlider.

◆ Increase()

void ASlider::Increase ( float  steps)

Definition at line 1794 of file ASlider.cpp.

1795{
1796 mLWSlider->Increase(steps);
1797}

References mLWSlider.

Referenced by TranscriptionToolBar::AdjustPlaySpeed().

Here is the caller graph for this function:

◆ IsEnabled()

bool ASlider::IsEnabled ( ) const

Definition at line 1826 of file ASlider.cpp.

1827{
1828 return mLWSlider->GetEnabled();
1829}

References mLWSlider.

◆ OnCaptureLost()

void ASlider::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Definition at line 1741 of file ASlider.cpp.

1742{
1743 wxMouseEvent e(wxEVT_LEFT_UP);
1744 mLWSlider->OnMouseEvent(e);
1745}

References mLWSlider.

◆ OnErase()

void ASlider::OnErase ( wxEraseEvent &  event)

Definition at line 1702 of file ASlider.cpp.

1703{
1704 // Ignore it to prevent flashing
1705}

◆ OnKeyDown()

void ASlider::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1747 of file ASlider.cpp.

1748{
1749 mLWSlider->OnKeyDown(event);
1750}

References mLWSlider.

◆ OnKillFocus()

void ASlider::OnKillFocus ( wxFocusEvent &  event)

Definition at line 1758 of file ASlider.cpp.

1759{
1760 mSliderIsFocused = false;
1761 Refresh();
1762}

References mSliderIsFocused.

◆ OnMouseEvent()

void ASlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1727 of file ASlider.cpp.

1728{
1729 if (event.Entering())
1730 {
1731 mTimer.StartOnce(1000);
1732 }
1733 else if (event.Leaving())
1734 {
1735 mTimer.Stop();
1736 }
1737
1738 mLWSlider->OnMouseEvent(event);
1739}

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 1707 of file ASlider.cpp.

1708{
1709 wxBufferedPaintDC dc(this);
1710
1711 bool highlighted =
1712 GetClientRect().Contains(
1713 ScreenToClient(
1714 ::wxGetMousePosition() ) );
1715 mLWSlider->OnPaint(dc, highlighted);
1716
1717 if ( mSliderIsFocused )
1718 {
1719 wxRect r( 0, 0, mLWSlider->mWidth, mLWSlider->mHeight );
1720
1721 r.Deflate( 1, 1 );
1722
1723 AColor::DrawFocus( dc, r );
1724 }
1725}
static void DrawFocus(wxDC &dc, wxRect &r)
Definition: AColor.cpp:235

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

Here is the call graph for this function:

◆ OnSetFocus()

void ASlider::OnSetFocus ( wxFocusEvent &  event)

Definition at line 1752 of file ASlider.cpp.

1753{
1754 mSliderIsFocused = true;
1755 Refresh();
1756}

References mSliderIsFocused.

◆ OnSize()

void ASlider::OnSize ( wxSizeEvent &  event)

Definition at line 1697 of file ASlider.cpp.

1698{
1699 mLWSlider->OnSize( event );
1700}

References mLWSlider.

◆ OnSlider()

void ASlider::OnSlider ( wxCommandEvent &  event)

Definition at line 1681 of file ASlider.cpp.

1682{
1683
1684 if ( event.GetId() == mLWSlider->GetId() )
1685 {
1686#if wxUSE_ACCESSIBILITY
1687 GetAccessible()->NotifyEvent( wxACC_EVENT_OBJECT_VALUECHANGE,
1688 this,
1689 wxOBJID_CLIENT,
1690 wxACC_SELF );
1691#endif
1692 }
1693
1694 event.Skip();
1695}

References mLWSlider.

◆ OnTimer()

void ASlider::OnTimer ( wxTimerEvent &  event)

Definition at line 1764 of file ASlider.cpp.

1765{
1766 mLWSlider->ShowTip(true);
1767}

References mLWSlider.

◆ Set()

void ASlider::Set ( float  value)

Definition at line 1789 of file ASlider.cpp.

1790{
1791 mLWSlider->Set(value);
1792}

References mLWSlider.

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

Here is the caller graph for this function:

◆ SetBackgroundColour()

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

Definition at line 1669 of file ASlider.cpp.

1670{
1671 auto res = wxPanel::SetBackgroundColour(colour);
1672
1673 if (res && mLWSlider)
1674 {
1675 mLWSlider->Redraw();
1676 }
1677
1678 return res;
1679}

References mLWSlider.

Referenced by MixerTrackCluster::OnPaint().

Here is the caller graph for this function:

◆ SetFocusFromKbd()

void ASlider::SetFocusFromKbd ( )
override

Definition at line 1841 of file ASlider.cpp.

1842{
1843 auto temp = TemporarilyAllowFocus();
1844 SetFocus();
1845}
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1833

References TemporarilyAllowFocus().

Here is the call graph for this function:

◆ SetScroll()

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

Definition at line 1774 of file ASlider.cpp.

1775{
1776 mLWSlider->SetScroll(line, page);
1777}

References mLWSlider.

◆ SetSpeed()

void ASlider::SetSpeed ( float  speed)

Definition at line 1809 of file ASlider.cpp.

1810{
1811 mLWSlider->SetSpeed(speed);
1812}

References mLWSlider.

◆ SetToolTipTemplate()

void ASlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 1779 of file ASlider.cpp.

1780{
1781 mLWSlider->SetToolTipTemplate(tip);
1782}

References mLWSlider.

◆ ShowDialog()

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

Definition at line 1804 of file ASlider.cpp.

1805{
1806 return mLWSlider->ShowDialog(pos);
1807}

References mLWSlider.

Referenced by TranscriptionToolBar::ShowPlaySpeedDialog().

Here is the caller graph for this function:

◆ TemporarilyAllowFocus()

auto ASlider::TemporarilyAllowFocus ( )
static

Definition at line 1833 of file ASlider.cpp.

1833 {
1834 s_AcceptsFocus = true;
1835 return TempAllowFocus{ &s_AcceptsFocus };
1836}
std::unique_ptr< bool, Resetter > TempAllowFocus
Definition: ASlider.h:334

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 253 of file ASlider.h.

Member Data Documentation

◆ mLWSlider

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

◆ mSliderIsFocused

bool ASlider::mSliderIsFocused
private

Definition at line 341 of file ASlider.h.

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

◆ mStyle

int ASlider::mStyle
protected

Definition at line 345 of file ASlider.h.

Referenced by MixerTrackSlider::OnMouseEvent().

◆ mTimer

wxTimer ASlider::mTimer
private

Definition at line 342 of file ASlider.h.

Referenced by OnMouseEvent().

◆ s_AcceptsFocus

bool ASlider::s_AcceptsFocus { false }
staticprivate

Definition at line 332 of file ASlider.h.


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