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

1689: wxPanel( parent, id, pos, size, wxWANTS_CHARS )
1690{
1691 //wxColour Col(parent->GetBackgroundColour());
1692 //SetBackgroundColour( Col );
1693 SetBackgroundColour( theTheme.Colour( clrMedium ) );
1694 mLWSlider = std::make_unique<LWSlider>( this,
1695 name,
1696 wxPoint(0,0),
1697 size,
1698 options.style,
1699 options.showLabels,
1700 options.drawTicks,
1701 options.drawTrack,
1702 options.alwaysHideTip,
1703 true, // ASlider is always a heavyweight LWSlider
1704 options.popup,
1705 options.orientation);
1706 mLWSlider->mStepValue = options.stepValue;
1707 mLWSlider->SetId( id );
1708 SetName( name.Translation() );
1709
1710 mSliderIsFocused = false;
1711 mStyle = options.style;
1712
1713 mTimer.SetOwner(this);
1714
1715#if wxUSE_ACCESSIBILITY
1716 SetAccessible( safenew ASliderAx( this ) );
1717#endif
1718
1719 mLWSlider->SetScroll( options.line, options.page );
1720}
const TranslatableString name
Definition: Distortion.cpp:76
#define safenew
Definition: MemoryX.h:10
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:1729
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 1723 of file ASlider.cpp.

1724{
1725 if(HasCapture())
1726 ReleaseMouse();
1727}

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

1861{
1862 mLWSlider->Decrease(steps);
1863}

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

1876{
1877 if (mLWSlider->GetEnabled() == enable)
1878 return false;
1879
1880 mLWSlider->SetEnabled(enable);
1881
1882 wxWindow::Enable(enable);
1883
1884 return true;
1885}

References mLWSlider.

◆ Get()

float ASlider::Get ( bool  convert = true)

Definition at line 1845 of file ASlider.cpp.

1846{
1847 return mLWSlider->Get( convert );
1848}

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

1831{
1832 mLWSlider->GetScroll(line, page);
1833}

References mLWSlider.

◆ Increase()

void ASlider::Increase ( float  steps)

Definition at line 1855 of file ASlider.cpp.

1856{
1857 mLWSlider->Increase(steps);
1858}

References mLWSlider.

Referenced by TranscriptionToolBar::AdjustPlaySpeed().

Here is the caller graph for this function:

◆ IsEnabled()

bool ASlider::IsEnabled ( ) const

Definition at line 1887 of file ASlider.cpp.

1888{
1889 return mLWSlider->GetEnabled();
1890}

References mLWSlider.

◆ OnCaptureLost()

void ASlider::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Definition at line 1801 of file ASlider.cpp.

1802{
1803 wxMouseEvent e(wxEVT_LEFT_UP);
1804 mLWSlider->OnMouseEvent(e);
1805}

References mLWSlider.

◆ OnErase()

void ASlider::OnErase ( wxEraseEvent &  event)

Definition at line 1762 of file ASlider.cpp.

1763{
1764 // Ignore it to prevent flashing
1765}

◆ OnKeyDown()

void ASlider::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1807 of file ASlider.cpp.

1808{
1809 mLWSlider->OnKeyDown(event);
1810}

References mLWSlider.

◆ OnKillFocus()

void ASlider::OnKillFocus ( wxFocusEvent &  event)

Definition at line 1818 of file ASlider.cpp.

1819{
1820 mLWSlider->OnKillFocus();
1821 mSliderIsFocused = false;
1822 Refresh();
1823}

References mLWSlider, and mSliderIsFocused.

◆ OnMouseEvent()

void ASlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1787 of file ASlider.cpp.

1788{
1789 if (event.Entering())
1790 {
1791 mTimer.StartOnce(1000);
1792 }
1793 else if (event.Leaving())
1794 {
1795 mTimer.Stop();
1796 }
1797
1798 mLWSlider->OnMouseEvent(event);
1799}

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

1768{
1769 wxBufferedPaintDC dc(this);
1770
1771 bool highlighted =
1772 GetClientRect().Contains(
1773 ScreenToClient(
1774 ::wxGetMousePosition() ) );
1775 mLWSlider->OnPaint(dc, highlighted);
1776
1777 if ( mSliderIsFocused )
1778 {
1779 wxRect r( 0, 0, mLWSlider->mWidth, mLWSlider->mHeight );
1780
1781 r.Deflate( 1, 1 );
1782
1783 AColor::DrawFocus( dc, r );
1784 }
1785}
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 1812 of file ASlider.cpp.

1813{
1814 mSliderIsFocused = true;
1815 Refresh();
1816}

References mSliderIsFocused.

◆ OnSize()

void ASlider::OnSize ( wxSizeEvent &  event)

Definition at line 1757 of file ASlider.cpp.

1758{
1759 mLWSlider->OnSize( event );
1760}

References mLWSlider.

◆ OnSlider()

void ASlider::OnSlider ( wxCommandEvent &  event)

Definition at line 1741 of file ASlider.cpp.

1742{
1743
1744 if ( event.GetId() == mLWSlider->GetId() )
1745 {
1746#if wxUSE_ACCESSIBILITY
1747 GetAccessible()->NotifyEvent( wxACC_EVENT_OBJECT_VALUECHANGE,
1748 this,
1749 wxOBJID_CLIENT,
1750 wxACC_SELF );
1751#endif
1752 }
1753
1754 event.Skip();
1755}

References mLWSlider.

◆ OnTimer()

void ASlider::OnTimer ( wxTimerEvent &  event)

Definition at line 1825 of file ASlider.cpp.

1826{
1827 mLWSlider->ShowTip(true);
1828}

References mLWSlider.

◆ Set()

void ASlider::Set ( float  value)

Definition at line 1850 of file ASlider.cpp.

1851{
1852 mLWSlider->Set(value);
1853}

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

1730{
1731 auto res = wxPanel::SetBackgroundColour(colour);
1732
1733 if (res && mLWSlider)
1734 {
1735 mLWSlider->Redraw();
1736 }
1737
1738 return res;
1739}

References mLWSlider.

Referenced by MixerTrackCluster::OnPaint().

Here is the caller graph for this function:

◆ SetFocusFromKbd()

void ASlider::SetFocusFromKbd ( )
override

Definition at line 1902 of file ASlider.cpp.

1903{
1904 auto temp = TemporarilyAllowFocus();
1905 SetFocus();
1906}
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1894
void SetFocus(const WindowPlacement &focus)
Set the window that accepts keyboard input.
Definition: BasicUI.h:352

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

Here is the call graph for this function:

◆ SetScroll()

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

Definition at line 1835 of file ASlider.cpp.

1836{
1837 mLWSlider->SetScroll(line, page);
1838}

References mLWSlider.

◆ SetSpeed()

void ASlider::SetSpeed ( float  speed)

Definition at line 1870 of file ASlider.cpp.

1871{
1872 mLWSlider->SetSpeed(speed);
1873}

References mLWSlider.

◆ SetToolTipTemplate()

void ASlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 1840 of file ASlider.cpp.

1841{
1842 mLWSlider->SetToolTipTemplate(tip);
1843}

References mLWSlider.

◆ ShowDialog()

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

Definition at line 1865 of file ASlider.cpp.

1866{
1867 return mLWSlider->ShowDialog(pos);
1868}

References mLWSlider.

Referenced by TranscriptionToolBar::ShowPlaySpeedDialog().

Here is the caller graph for this function:

◆ TemporarilyAllowFocus()

auto ASlider::TemporarilyAllowFocus ( )
static

Definition at line 1894 of file ASlider.cpp.

1894 {
1895 s_AcceptsFocus = true;
1896 return TempAllowFocus{ &s_AcceptsFocus };
1897}
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: