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

1703: wxPanel( parent, id, pos, size, wxWANTS_CHARS )
1704{
1705 //wxColour Col(parent->GetBackgroundColour());
1706 //SetBackgroundColour( Col );
1707 SetBackgroundColour( theTheme.Colour( clrMedium ) );
1708 mLWSlider = std::make_unique<LWSlider>( this,
1709 name,
1710 wxPoint(0,0),
1711 size,
1712 options.style,
1713 options.showLabels,
1714 options.drawTicks,
1715 options.drawTrack,
1716 options.alwaysHideTip,
1717 true, // ASlider is always a heavyweight LWSlider
1718 options.popup,
1719 options.orientation);
1720 mLWSlider->mStepValue = options.stepValue;
1721 mLWSlider->SetId( id );
1722 SetName( name.Translation() );
1723
1724 mSliderIsFocused = false;
1725 mStyle = options.style;
1726
1727 mTimer.SetOwner(this);
1728
1729#if wxUSE_ACCESSIBILITY
1730 SetAccessible( safenew ASliderAx( this ) );
1731#endif
1732
1733 mLWSlider->SetScroll( options.line, options.page );
1734}
#define safenew
Definition: MemoryX.h:10
wxString name
Definition: TagsEditor.cpp:166
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:1743
wxTimer mTimer
Definition: ASlider.h:350
wxColour & Colour(int iIndex)

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

Here is the call graph for this function:

◆ ~ASlider()

ASlider::~ASlider ( )
virtual

Definition at line 1737 of file ASlider.cpp.

1738{
1739 if(HasCapture())
1740 ReleaseMouse();
1741}

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

1875{
1876 mLWSlider->Decrease(steps);
1877}

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

1890{
1891 if (mLWSlider->GetEnabled() == enable)
1892 return false;
1893
1894 mLWSlider->SetEnabled(enable);
1895
1896 wxWindow::Enable(enable);
1897
1898 return true;
1899}

References mLWSlider.

◆ Get()

float ASlider::Get ( bool  convert = true)

Definition at line 1859 of file ASlider.cpp.

1860{
1861 return mLWSlider->Get( convert );
1862}

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

1845{
1846 mLWSlider->GetScroll(line, page);
1847}

References mLWSlider.

◆ Increase()

void ASlider::Increase ( float  steps)

Definition at line 1869 of file ASlider.cpp.

1870{
1871 mLWSlider->Increase(steps);
1872}

References mLWSlider.

Referenced by TranscriptionToolBar::AdjustPlaySpeed().

Here is the caller graph for this function:

◆ IsEnabled()

bool ASlider::IsEnabled ( ) const

Definition at line 1901 of file ASlider.cpp.

1902{
1903 return mLWSlider->GetEnabled();
1904}

References mLWSlider.

◆ OnCaptureLost()

void ASlider::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Definition at line 1815 of file ASlider.cpp.

1816{
1817 wxMouseEvent e(wxEVT_LEFT_UP);
1818 mLWSlider->OnMouseEvent(e);
1819}

References mLWSlider.

◆ OnErase()

void ASlider::OnErase ( wxEraseEvent &  event)

Definition at line 1776 of file ASlider.cpp.

1777{
1778 // Ignore it to prevent flashing
1779}

◆ OnKeyDown()

void ASlider::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1821 of file ASlider.cpp.

1822{
1823 mLWSlider->OnKeyDown(event);
1824}

References mLWSlider.

◆ OnKillFocus()

void ASlider::OnKillFocus ( wxFocusEvent &  event)

Definition at line 1832 of file ASlider.cpp.

1833{
1834 mLWSlider->OnKillFocus();
1835 mSliderIsFocused = false;
1836 Refresh();
1837}

References mLWSlider, and mSliderIsFocused.

◆ OnMouseEvent()

void ASlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1801 of file ASlider.cpp.

1802{
1803 if (event.Entering())
1804 {
1805 mTimer.StartOnce(1000);
1806 }
1807 else if (event.Leaving())
1808 {
1809 mTimer.Stop();
1810 }
1811
1812 mLWSlider->OnMouseEvent(event);
1813}

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

1782{
1783 wxBufferedPaintDC dc(this);
1784
1785 bool highlighted =
1786 GetClientRect().Contains(
1787 ScreenToClient(
1788 ::wxGetMousePosition() ) );
1789 mLWSlider->OnPaint(dc, highlighted);
1790
1791 if ( mSliderIsFocused )
1792 {
1793 wxRect r( 0, 0, mLWSlider->mWidth, mLWSlider->mHeight );
1794
1795 r.Deflate( 1, 1 );
1796
1797 AColor::DrawFocus( dc, r );
1798 }
1799}
static void DrawFocus(wxDC &dc, wxRect &r)
Definition: AColor.cpp:247

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

Here is the call graph for this function:

◆ OnSetFocus()

void ASlider::OnSetFocus ( wxFocusEvent &  event)

Definition at line 1826 of file ASlider.cpp.

1827{
1828 mSliderIsFocused = true;
1829 Refresh();
1830}

References mSliderIsFocused.

◆ OnSize()

void ASlider::OnSize ( wxSizeEvent &  event)

Definition at line 1771 of file ASlider.cpp.

1772{
1773 mLWSlider->OnSize( event );
1774}

References mLWSlider.

◆ OnSlider()

void ASlider::OnSlider ( wxCommandEvent &  event)

Definition at line 1755 of file ASlider.cpp.

1756{
1757
1758 if ( event.GetId() == mLWSlider->GetId() )
1759 {
1760#if wxUSE_ACCESSIBILITY
1761 GetAccessible()->NotifyEvent( wxACC_EVENT_OBJECT_VALUECHANGE,
1762 this,
1763 wxOBJID_CLIENT,
1764 wxACC_SELF );
1765#endif
1766 }
1767
1768 event.Skip();
1769}

References mLWSlider.

◆ OnTimer()

void ASlider::OnTimer ( wxTimerEvent &  event)

Definition at line 1839 of file ASlider.cpp.

1840{
1841 mLWSlider->ShowTip(true);
1842}

References mLWSlider.

◆ Set()

void ASlider::Set ( float  value)

Definition at line 1864 of file ASlider.cpp.

1865{
1866 mLWSlider->Set(value);
1867}

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

1744{
1745 auto res = wxPanel::SetBackgroundColour(colour);
1746
1747 if (res && mLWSlider)
1748 {
1749 mLWSlider->Redraw();
1750 }
1751
1752 return res;
1753}

References mLWSlider.

Referenced by MixerTrackCluster::OnPaint().

Here is the caller graph for this function:

◆ SetFocusFromKbd()

void ASlider::SetFocusFromKbd ( )
override

Definition at line 1916 of file ASlider.cpp.

1917{
1918 auto temp = TemporarilyAllowFocus();
1919 SetFocus();
1920}
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1908
void SetFocus(const WindowPlacement &focus)
Set the window that accepts keyboard input.
Definition: BasicUI.h:392

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

Here is the call graph for this function:

◆ SetScroll()

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

Definition at line 1849 of file ASlider.cpp.

1850{
1851 mLWSlider->SetScroll(line, page);
1852}

References mLWSlider.

◆ SetSpeed()

void ASlider::SetSpeed ( float  speed)

Definition at line 1884 of file ASlider.cpp.

1885{
1886 mLWSlider->SetSpeed(speed);
1887}

References mLWSlider.

◆ SetToolTipTemplate()

void ASlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 1854 of file ASlider.cpp.

1855{
1856 mLWSlider->SetToolTipTemplate(tip);
1857}

References mLWSlider.

◆ ShowDialog()

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

Definition at line 1879 of file ASlider.cpp.

1880{
1881 return mLWSlider->ShowDialog(pos);
1882}

References mLWSlider.

Referenced by TranscriptionToolBar::ShowPlaySpeedDialog().

Here is the caller graph for this function:

◆ TemporarilyAllowFocus()

auto ASlider::TemporarilyAllowFocus ( )
static

Definition at line 1908 of file ASlider.cpp.

1908 {
1909 s_AcceptsFocus = true;
1910 return TempAllowFocus{ &s_AcceptsFocus };
1911}
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: