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

Member Typedef Documentation

◆ TempAllowFocus

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

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

1679: wxPanel( parent, id, pos, size, wxWANTS_CHARS )
1680{
1681 //wxColour Col(parent->GetBackgroundColour());
1682 //SetBackgroundColour( Col );
1683 SetBackgroundColour( theTheme.Colour( clrMedium ) );
1684 mLWSlider = std::make_unique<LWSlider>( this,
1685 name,
1686 wxPoint(0,0),
1687 size,
1688 options.style,
1689 options.showLabels,
1690 options.drawTicks,
1691 options.drawTrack,
1692 options.alwaysHideTip,
1693 true, // ASlider is always a heavyweight LWSlider
1694 options.popup,
1695 options.orientation);
1696 mLWSlider->mStepValue = options.stepValue;
1697 mLWSlider->SetId( id );
1698 SetName( name.Translation() );
1699
1700 mSliderIsFocused = false;
1701 mStyle = options.style;
1702
1703 mTimer.SetOwner(this);
1704
1705#if wxUSE_ACCESSIBILITY
1706 SetAccessible( safenew ASliderAx( this ) );
1707#endif
1708
1709 mLWSlider->SetScroll( options.line, options.page );
1710}
const TranslatableString name
Definition: Distortion.cpp:76
#define safenew
Definition: MemoryX.h:9
THEME_API Theme theTheme
Definition: Theme.cpp:82
friend class ASliderAx
Definition: ASlider.h:261
int mStyle
Definition: ASlider.h:353
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:348
bool mSliderIsFocused
Definition: ASlider.h:349
bool SetBackgroundColour(const wxColour &colour) override
Definition: ASlider.cpp:1719
wxTimer mTimer
Definition: ASlider.h:350
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 1713 of file ASlider.cpp.

1714{
1715 if(HasCapture())
1716 ReleaseMouse();
1717}

Member Function Documentation

◆ AcceptsFocus()

bool ASlider::AcceptsFocus ( ) const
inlineoverride

Definition at line 303 of file ASlider.h.

303{ return s_AcceptsFocus; }
static bool s_AcceptsFocus
Definition: ASlider.h:340

◆ AcceptsFocusFromKeyboard()

bool ASlider::AcceptsFocusFromKeyboard ( ) const
inlineoverride

Definition at line 304 of file ASlider.h.

304{ return true; }

◆ Decrease()

void ASlider::Decrease ( float  steps)

Definition at line 1850 of file ASlider.cpp.

1851{
1852 mLWSlider->Decrease(steps);
1853}

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

1866{
1867 if (mLWSlider->GetEnabled() == enable)
1868 return false;
1869
1870 mLWSlider->SetEnabled(enable);
1871
1872 wxWindow::Enable(enable);
1873
1874 return true;
1875}

References mLWSlider.

◆ Get()

float ASlider::Get ( bool  convert = true)

Definition at line 1835 of file ASlider.cpp.

1836{
1837 return mLWSlider->Get( convert );
1838}

References mLWSlider.

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

Here is the caller graph for this function:

◆ GetScroll()

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

Definition at line 1820 of file ASlider.cpp.

1821{
1822 mLWSlider->GetScroll(line, page);
1823}

References mLWSlider.

◆ Increase()

void ASlider::Increase ( float  steps)

Definition at line 1845 of file ASlider.cpp.

1846{
1847 mLWSlider->Increase(steps);
1848}

References mLWSlider.

Referenced by TranscriptionToolBar::AdjustPlaySpeed().

Here is the caller graph for this function:

◆ IsEnabled()

bool ASlider::IsEnabled ( ) const

Definition at line 1877 of file ASlider.cpp.

1878{
1879 return mLWSlider->GetEnabled();
1880}

References mLWSlider.

◆ OnCaptureLost()

void ASlider::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Definition at line 1791 of file ASlider.cpp.

1792{
1793 wxMouseEvent e(wxEVT_LEFT_UP);
1794 mLWSlider->OnMouseEvent(e);
1795}

References mLWSlider.

◆ OnErase()

void ASlider::OnErase ( wxEraseEvent &  event)

Definition at line 1752 of file ASlider.cpp.

1753{
1754 // Ignore it to prevent flashing
1755}

◆ OnKeyDown()

void ASlider::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1797 of file ASlider.cpp.

1798{
1799 mLWSlider->OnKeyDown(event);
1800}

References mLWSlider.

◆ OnKillFocus()

void ASlider::OnKillFocus ( wxFocusEvent &  event)

Definition at line 1808 of file ASlider.cpp.

1809{
1810 mLWSlider->OnKillFocus();
1811 mSliderIsFocused = false;
1812 Refresh();
1813}

References mLWSlider, and mSliderIsFocused.

◆ OnMouseEvent()

void ASlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1777 of file ASlider.cpp.

1778{
1779 if (event.Entering())
1780 {
1781 mTimer.StartOnce(1000);
1782 }
1783 else if (event.Leaving())
1784 {
1785 mTimer.Stop();
1786 }
1787
1788 mLWSlider->OnMouseEvent(event);
1789}

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

1758{
1759 wxBufferedPaintDC dc(this);
1760
1761 bool highlighted =
1762 GetClientRect().Contains(
1763 ScreenToClient(
1764 ::wxGetMousePosition() ) );
1765 mLWSlider->OnPaint(dc, highlighted);
1766
1767 if ( mSliderIsFocused )
1768 {
1769 wxRect r( 0, 0, mLWSlider->mWidth, mLWSlider->mHeight );
1770
1771 r.Deflate( 1, 1 );
1772
1773 AColor::DrawFocus( dc, r );
1774 }
1775}
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 1802 of file ASlider.cpp.

1803{
1804 mSliderIsFocused = true;
1805 Refresh();
1806}

References mSliderIsFocused.

◆ OnSize()

void ASlider::OnSize ( wxSizeEvent &  event)

Definition at line 1747 of file ASlider.cpp.

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

References mLWSlider.

◆ OnSlider()

void ASlider::OnSlider ( wxCommandEvent &  event)

Definition at line 1731 of file ASlider.cpp.

1732{
1733
1734 if ( event.GetId() == mLWSlider->GetId() )
1735 {
1736#if wxUSE_ACCESSIBILITY
1737 GetAccessible()->NotifyEvent( wxACC_EVENT_OBJECT_VALUECHANGE,
1738 this,
1739 wxOBJID_CLIENT,
1740 wxACC_SELF );
1741#endif
1742 }
1743
1744 event.Skip();
1745}

References mLWSlider.

◆ OnTimer()

void ASlider::OnTimer ( wxTimerEvent &  event)

Definition at line 1815 of file ASlider.cpp.

1816{
1817 mLWSlider->ShowTip(true);
1818}

References mLWSlider.

◆ Set()

void ASlider::Set ( float  value)

Definition at line 1840 of file ASlider.cpp.

1841{
1842 mLWSlider->Set(value);
1843}

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

1720{
1721 auto res = wxPanel::SetBackgroundColour(colour);
1722
1723 if (res && mLWSlider)
1724 {
1725 mLWSlider->Redraw();
1726 }
1727
1728 return res;
1729}

References mLWSlider.

Referenced by MixerTrackCluster::OnPaint().

Here is the caller graph for this function:

◆ SetFocusFromKbd()

void ASlider::SetFocusFromKbd ( )
override

Definition at line 1892 of file ASlider.cpp.

1893{
1894 auto temp = TemporarilyAllowFocus();
1895 SetFocus();
1896}
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1884
void SetFocus(const WindowPlacement &focus)
Set the window that accepts keyboard input.
Definition: BasicUI.h:384

References BasicUI::SetFocus(), and TemporarilyAllowFocus().

Here is the call graph for this function:

◆ SetScroll()

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

Definition at line 1825 of file ASlider.cpp.

1826{
1827 mLWSlider->SetScroll(line, page);
1828}

References mLWSlider.

◆ SetSpeed()

void ASlider::SetSpeed ( float  speed)

Definition at line 1860 of file ASlider.cpp.

1861{
1862 mLWSlider->SetSpeed(speed);
1863}

References mLWSlider.

◆ SetToolTipTemplate()

void ASlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 1830 of file ASlider.cpp.

1831{
1832 mLWSlider->SetToolTipTemplate(tip);
1833}

References mLWSlider.

◆ ShowDialog()

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

Definition at line 1855 of file ASlider.cpp.

1856{
1857 return mLWSlider->ShowDialog(pos);
1858}

References mLWSlider.

Referenced by TranscriptionToolBar::ShowPlaySpeedDialog().

Here is the caller graph for this function:

◆ TemporarilyAllowFocus()

auto ASlider::TemporarilyAllowFocus ( )
static

Definition at line 1884 of file ASlider.cpp.

1884 {
1885 s_AcceptsFocus = true;
1886 return TempAllowFocus{ &s_AcceptsFocus };
1887}
std::unique_ptr< bool, Resetter > TempAllowFocus
Definition: ASlider.h:342

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

Member Data Documentation

◆ mLWSlider

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

◆ mSliderIsFocused

bool ASlider::mSliderIsFocused
private

Definition at line 349 of file ASlider.h.

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

◆ mStyle

int ASlider::mStyle
protected

Definition at line 353 of file ASlider.h.

Referenced by MixerTrackSlider::OnMouseEvent().

◆ mTimer

wxTimer ASlider::mTimer
private

Definition at line 350 of file ASlider.h.

Referenced by OnMouseEvent().

◆ s_AcceptsFocus

bool ASlider::s_AcceptsFocus { false }
staticprivate

Definition at line 340 of file ASlider.h.


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