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

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

1719{
1720 if(HasCapture())
1721 ReleaseMouse();
1722}

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

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

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

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

References mLWSlider.

◆ Get()

float ASlider::Get ( bool  convert = true)

Definition at line 1840 of file ASlider.cpp.

1841{
1842 return mLWSlider->Get( convert );
1843}

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

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

References mLWSlider.

◆ Increase()

void ASlider::Increase ( float  steps)

Definition at line 1850 of file ASlider.cpp.

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

References mLWSlider.

Referenced by TranscriptionToolBar::AdjustPlaySpeed().

Here is the caller graph for this function:

◆ IsEnabled()

bool ASlider::IsEnabled ( ) const

Definition at line 1882 of file ASlider.cpp.

1883{
1884 return mLWSlider->GetEnabled();
1885}

References mLWSlider.

◆ OnCaptureLost()

void ASlider::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Definition at line 1796 of file ASlider.cpp.

1797{
1798 wxMouseEvent e(wxEVT_LEFT_UP);
1799 mLWSlider->OnMouseEvent(e);
1800}

References mLWSlider.

◆ OnErase()

void ASlider::OnErase ( wxEraseEvent &  event)

Definition at line 1757 of file ASlider.cpp.

1758{
1759 // Ignore it to prevent flashing
1760}

◆ OnKeyDown()

void ASlider::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1802 of file ASlider.cpp.

1803{
1804 mLWSlider->OnKeyDown(event);
1805}

References mLWSlider.

◆ OnKillFocus()

void ASlider::OnKillFocus ( wxFocusEvent &  event)

Definition at line 1813 of file ASlider.cpp.

1814{
1815 mLWSlider->OnKillFocus();
1816 mSliderIsFocused = false;
1817 Refresh();
1818}

References mLWSlider, and mSliderIsFocused.

◆ OnMouseEvent()

void ASlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1782 of file ASlider.cpp.

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

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

1763{
1764 wxBufferedPaintDC dc(this);
1765
1766 bool highlighted =
1767 GetClientRect().Contains(
1768 ScreenToClient(
1769 ::wxGetMousePosition() ) );
1770 mLWSlider->OnPaint(dc, highlighted);
1771
1772 if ( mSliderIsFocused )
1773 {
1774 wxRect r( 0, 0, mLWSlider->mWidth, mLWSlider->mHeight );
1775
1776 r.Deflate( 1, 1 );
1777
1778 AColor::DrawFocus( dc, r );
1779 }
1780}
static void DrawFocus(wxDC &dc, wxRect &r)
Definition: AColor.cpp:233

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

Here is the call graph for this function:

◆ OnSetFocus()

void ASlider::OnSetFocus ( wxFocusEvent &  event)

Definition at line 1807 of file ASlider.cpp.

1808{
1809 mSliderIsFocused = true;
1810 Refresh();
1811}

References mSliderIsFocused.

◆ OnSize()

void ASlider::OnSize ( wxSizeEvent &  event)

Definition at line 1752 of file ASlider.cpp.

1753{
1754 mLWSlider->OnSize( event );
1755}

References mLWSlider.

◆ OnSlider()

void ASlider::OnSlider ( wxCommandEvent &  event)

Definition at line 1736 of file ASlider.cpp.

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

References mLWSlider.

◆ OnTimer()

void ASlider::OnTimer ( wxTimerEvent &  event)

Definition at line 1820 of file ASlider.cpp.

1821{
1822 mLWSlider->ShowTip(true);
1823}

References mLWSlider.

◆ Set()

void ASlider::Set ( float  value)

Definition at line 1845 of file ASlider.cpp.

1846{
1847 mLWSlider->Set(value);
1848}

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

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

References mLWSlider.

Referenced by MixerTrackCluster::OnPaint().

Here is the caller graph for this function:

◆ SetFocusFromKbd()

void ASlider::SetFocusFromKbd ( )
override

Definition at line 1897 of file ASlider.cpp.

1898{
1899 auto temp = TemporarilyAllowFocus();
1900 SetFocus();
1901}
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1889
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 1830 of file ASlider.cpp.

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

References mLWSlider.

◆ SetSpeed()

void ASlider::SetSpeed ( float  speed)

Definition at line 1865 of file ASlider.cpp.

1866{
1867 mLWSlider->SetSpeed(speed);
1868}

References mLWSlider.

◆ SetToolTipTemplate()

void ASlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 1835 of file ASlider.cpp.

1836{
1837 mLWSlider->SetToolTipTemplate(tip);
1838}

References mLWSlider.

◆ ShowDialog()

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

Definition at line 1860 of file ASlider.cpp.

1861{
1862 return mLWSlider->ShowDialog(pos);
1863}

References mLWSlider.

Referenced by TranscriptionToolBar::ShowPlaySpeedDialog().

Here is the caller graph for this function:

◆ TemporarilyAllowFocus()

auto ASlider::TemporarilyAllowFocus ( )
static

Definition at line 1889 of file ASlider.cpp.

1889 {
1890 s_AcceptsFocus = true;
1891 return TempAllowFocus{ &s_AcceptsFocus };
1892}
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: