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

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

1722{
1723 if(HasCapture())
1724 ReleaseMouse();
1725}

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

1859{
1860 mLWSlider->Decrease(steps);
1861}

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

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

References mLWSlider.

◆ Get()

float ASlider::Get ( bool  convert = true)

Definition at line 1843 of file ASlider.cpp.

1844{
1845 return mLWSlider->Get( convert );
1846}

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

1829{
1830 mLWSlider->GetScroll(line, page);
1831}

References mLWSlider.

◆ Increase()

void ASlider::Increase ( float  steps)

Definition at line 1853 of file ASlider.cpp.

1854{
1855 mLWSlider->Increase(steps);
1856}

References mLWSlider.

Referenced by TranscriptionToolBar::AdjustPlaySpeed().

Here is the caller graph for this function:

◆ IsEnabled()

bool ASlider::IsEnabled ( ) const

Definition at line 1885 of file ASlider.cpp.

1886{
1887 return mLWSlider->GetEnabled();
1888}

References mLWSlider.

◆ OnCaptureLost()

void ASlider::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Definition at line 1799 of file ASlider.cpp.

1800{
1801 wxMouseEvent e(wxEVT_LEFT_UP);
1802 mLWSlider->OnMouseEvent(e);
1803}

References mLWSlider.

◆ OnErase()

void ASlider::OnErase ( wxEraseEvent &  event)

Definition at line 1760 of file ASlider.cpp.

1761{
1762 // Ignore it to prevent flashing
1763}

◆ OnKeyDown()

void ASlider::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1805 of file ASlider.cpp.

1806{
1807 mLWSlider->OnKeyDown(event);
1808}

References mLWSlider.

◆ OnKillFocus()

void ASlider::OnKillFocus ( wxFocusEvent &  event)

Definition at line 1816 of file ASlider.cpp.

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

References mLWSlider, and mSliderIsFocused.

◆ OnMouseEvent()

void ASlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1785 of file ASlider.cpp.

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

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

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

1811{
1812 mSliderIsFocused = true;
1813 Refresh();
1814}

References mSliderIsFocused.

◆ OnSize()

void ASlider::OnSize ( wxSizeEvent &  event)

Definition at line 1755 of file ASlider.cpp.

1756{
1757 mLWSlider->OnSize( event );
1758}

References mLWSlider.

◆ OnSlider()

void ASlider::OnSlider ( wxCommandEvent &  event)

Definition at line 1739 of file ASlider.cpp.

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

References mLWSlider.

◆ OnTimer()

void ASlider::OnTimer ( wxTimerEvent &  event)

Definition at line 1823 of file ASlider.cpp.

1824{
1825 mLWSlider->ShowTip(true);
1826}

References mLWSlider.

◆ Set()

void ASlider::Set ( float  value)

Definition at line 1848 of file ASlider.cpp.

1849{
1850 mLWSlider->Set(value);
1851}

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

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

References mLWSlider.

Referenced by MixerTrackCluster::OnPaint().

Here is the caller graph for this function:

◆ SetFocusFromKbd()

void ASlider::SetFocusFromKbd ( )
override

Definition at line 1900 of file ASlider.cpp.

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

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

Here is the call graph for this function:

◆ SetScroll()

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

Definition at line 1833 of file ASlider.cpp.

1834{
1835 mLWSlider->SetScroll(line, page);
1836}

References mLWSlider.

◆ SetSpeed()

void ASlider::SetSpeed ( float  speed)

Definition at line 1868 of file ASlider.cpp.

1869{
1870 mLWSlider->SetSpeed(speed);
1871}

References mLWSlider.

◆ SetToolTipTemplate()

void ASlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 1838 of file ASlider.cpp.

1839{
1840 mLWSlider->SetToolTipTemplate(tip);
1841}

References mLWSlider.

◆ ShowDialog()

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

Definition at line 1863 of file ASlider.cpp.

1864{
1865 return mLWSlider->ShowDialog(pos);
1866}

References mLWSlider.

Referenced by TranscriptionToolBar::ShowPlaySpeedDialog().

Here is the caller graph for this function:

◆ TemporarilyAllowFocus()

auto ASlider::TemporarilyAllowFocus ( )
static

Definition at line 1892 of file ASlider.cpp.

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