Audacity  2.2.2
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:
MixerTrackSlider

Classes

struct  Options
 
struct  Resetter
 

Public Member Functions

 ASlider (wxWindow *parent, wxWindowID id, const wxString &name, const wxPoint &pos, const wxSize &size, const Options &options=Options{})
 
virtual ~ASlider ()
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
void SetFocusFromKbd () override
 
void GetScroll (float &line, float &page)
 
void SetScroll (float line, float page)
 
void SetToolTipTemplate (const wxString &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 OnKeyEvent (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 243 of file ASlider.h.

Member Typedef Documentation

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

Definition at line 316 of file ASlider.h.

Constructor & Destructor Documentation

ASlider::ASlider ( wxWindow *  parent,
wxWindowID  id,
const wxString &  name,
const wxPoint &  pos,
const wxSize &  size,
const Options options = Options{} 
)

Definition at line 1422 of file ASlider.cpp.

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

1428 : wxPanel( parent, id, pos, size, wxWANTS_CHARS )
1429 {
1430  //wxColour Col(parent->GetBackgroundColour());
1431  //SetBackgroundColour( Col );
1432  SetBackgroundColour( theTheme.Colour( clrMedium ) );
1433  mLWSlider = std::make_unique<LWSlider>( this,
1434  name,
1435  wxPoint(0,0),
1436  size,
1437  options.style,
1438  true, // ASlider is always a heavyweight LWSlider
1439  options.popup,
1440  options.orientation);
1441  mLWSlider->mStepValue = options.stepValue;
1442  mLWSlider->SetId( id );
1443  SetName( name );
1444 
1445  mSliderIsFocused = false;
1446  mStyle = options.style;
1447 
1448  mTimer.SetOwner(this);
1449 
1450 #if wxUSE_ACCESSIBILITY
1451  SetAccessible( safenew ASliderAx( this ) );
1452 #endif
1453 
1454  mLWSlider->SetScroll( options.line, options.page );
1455 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
int mStyle
Definition: ASlider.h:327
#define safenew
Definition: Audacity.h:230
wxTimer mTimer
Definition: ASlider.h:324
friend class ASliderAx
Definition: ASlider.h:245
bool mSliderIsFocused
Definition: ASlider.h:323
const wxChar * name
Definition: Distortion.cpp:94
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
ASlider::~ASlider ( )
virtual

Definition at line 1458 of file ASlider.cpp.

1459 {
1460  if(HasCapture())
1461  ReleaseMouse();
1462 }

Member Function Documentation

bool ASlider::AcceptsFocus ( ) const
inlineoverride

Definition at line 279 of file ASlider.h.

References s_AcceptsFocus.

279 { return s_AcceptsFocus; }
static bool s_AcceptsFocus
Definition: ASlider.h:314
bool ASlider::AcceptsFocusFromKeyboard ( ) const
inlineoverride

Definition at line 280 of file ASlider.h.

280 { return true; }
void ASlider::Decrease ( float  steps)

Definition at line 1582 of file ASlider.cpp.

References mLWSlider.

Referenced by MixerToolBar::AdjustInputGain(), MixerToolBar::AdjustOutputGain(), and TranscriptionToolBar::AdjustPlaySpeed().

1583 {
1584  mLWSlider->Decrease(steps);
1585 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
bool ASlider::Enable ( bool  enable = true)
override

Definition at line 1597 of file ASlider.cpp.

References mLWSlider.

Referenced by MixerToolBar::Populate(), MixerToolBar::UpdateControls(), and MixerToolBar::UpdatePrefs().

1598 {
1599  if (mLWSlider->GetEnabled() == enable)
1600  return false;
1601 
1602  mLWSlider->SetEnabled(enable);
1603 
1604  wxWindow::Enable(enable);
1605 
1606  return true;
1607 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
float ASlider::Get ( bool  convert = true)
void ASlider::GetScroll ( float &  line,
float &  page 
)

Definition at line 1552 of file ASlider.cpp.

References mLWSlider.

1553 {
1554  mLWSlider->GetScroll(line, page);
1555 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
void ASlider::Increase ( float  steps)

Definition at line 1577 of file ASlider.cpp.

References mLWSlider.

Referenced by MixerToolBar::AdjustInputGain(), MixerToolBar::AdjustOutputGain(), and TranscriptionToolBar::AdjustPlaySpeed().

1578 {
1579  mLWSlider->Increase(steps);
1580 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
bool ASlider::IsEnabled ( ) const

Definition at line 1609 of file ASlider.cpp.

References mLWSlider.

Referenced by MixerToolBar::SetToolTips().

1610 {
1611  return mLWSlider->GetEnabled();
1612 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
void ASlider::OnCaptureLost ( wxMouseCaptureLostEvent &  event)

Definition at line 1524 of file ASlider.cpp.

References mLWSlider.

1525 {
1526  wxMouseEvent e(wxEVT_LEFT_UP);
1527  mLWSlider->OnMouseEvent(e);
1528 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
void ASlider::OnErase ( wxEraseEvent &  event)

Definition at line 1485 of file ASlider.cpp.

1486 {
1487  // Ignore it to prevent flashing
1488 }
void ASlider::OnKeyEvent ( wxKeyEvent &  event)

Definition at line 1530 of file ASlider.cpp.

References mLWSlider.

1531 {
1532  mLWSlider->OnKeyEvent(event);
1533 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
void ASlider::OnKillFocus ( wxFocusEvent &  event)

Definition at line 1541 of file ASlider.cpp.

References mSliderIsFocused.

1542 {
1543  mSliderIsFocused = false;
1544  Refresh();
1545 }
bool mSliderIsFocused
Definition: ASlider.h:323
void ASlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1510 of file ASlider.cpp.

References mLWSlider, and mTimer.

Referenced by MixerTrackSlider::OnMouseEvent().

1511 {
1512  if (event.Entering())
1513  {
1514  mTimer.StartOnce(1000);
1515  }
1516  else if (event.Leaving())
1517  {
1518  mTimer.Stop();
1519  }
1520 
1521  mLWSlider->OnMouseEvent(event);
1522 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
wxTimer mTimer
Definition: ASlider.h:324
void ASlider::OnPaint ( wxPaintEvent &  event)

Definition at line 1490 of file ASlider.cpp.

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

1491 {
1492  wxPaintDC dc(this);
1493 
1494  bool highlighted =
1495  GetClientRect().Contains(
1496  ScreenToClient(
1497  ::wxGetMousePosition() ) );
1498  mLWSlider->OnPaint(dc, highlighted);
1499 
1500  if ( mSliderIsFocused )
1501  {
1502  wxRect r( 0, 0, mLWSlider->mWidth, mLWSlider->mHeight );
1503 
1504  r.Deflate( 1, 1 );
1505 
1506  AColor::DrawFocus( dc, r );
1507  }
1508 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
static void DrawFocus(wxDC &dc, wxRect &r)
Definition: AColor.cpp:171
bool mSliderIsFocused
Definition: ASlider.h:323
void ASlider::OnSetFocus ( wxFocusEvent &  event)

Definition at line 1535 of file ASlider.cpp.

References mSliderIsFocused.

1536 {
1537  mSliderIsFocused = true;
1538  Refresh();
1539 }
bool mSliderIsFocused
Definition: ASlider.h:323
void ASlider::OnSize ( wxSizeEvent &  event)

Definition at line 1480 of file ASlider.cpp.

References mLWSlider.

1481 {
1482  mLWSlider->OnSize( event );
1483 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
void ASlider::OnSlider ( wxCommandEvent &  event)

Definition at line 1464 of file ASlider.cpp.

References mLWSlider.

1465 {
1466 
1467  if ( event.GetId() == mLWSlider->GetId() )
1468  {
1469 #if wxUSE_ACCESSIBILITY
1470  GetAccessible()->NotifyEvent( wxACC_EVENT_OBJECT_VALUECHANGE,
1471  this,
1472  wxOBJID_CLIENT,
1473  wxACC_SELF );
1474 #endif
1475  }
1476 
1477  event.Skip();
1478 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
void ASlider::OnTimer ( wxTimerEvent &  event)

Definition at line 1547 of file ASlider.cpp.

References mLWSlider.

1548 {
1549  mLWSlider->ShowTip(true);
1550 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
void ASlider::Set ( float  value)

Definition at line 1572 of file ASlider.cpp.

References mLWSlider.

Referenced by TranscriptionToolBar::Populate(), SliderDialog::TransferDataFromWindow(), MixerToolBar::UpdateControls(), MixerTrackCluster::UpdateGain(), and MixerTrackCluster::UpdatePan().

1573 {
1574  mLWSlider->Set(value);
1575 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
void ASlider::SetFocusFromKbd ( )
override

Definition at line 1624 of file ASlider.cpp.

References TemporarilyAllowFocus().

1625 {
1626  auto temp = TemporarilyAllowFocus();
1627  SetFocus();
1628 }
static TempAllowFocus TemporarilyAllowFocus()
Definition: ASlider.cpp:1616
void ASlider::SetScroll ( float  line,
float  page 
)

Definition at line 1557 of file ASlider.cpp.

References mLWSlider.

1558 {
1559  mLWSlider->SetScroll(line, page);
1560 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
void ASlider::SetSpeed ( float  speed)

Definition at line 1592 of file ASlider.cpp.

References mLWSlider.

1593 {
1594  mLWSlider->SetSpeed(speed);
1595 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
void ASlider::SetToolTipTemplate ( const wxString &  tip)

Definition at line 1562 of file ASlider.cpp.

References mLWSlider.

Referenced by MixerToolBar::SetToolTips().

1563 {
1564  mLWSlider->SetToolTipTemplate(tip);
1565 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
bool ASlider::ShowDialog ( wxPoint  pos = wxPoint(-1, -1))

Definition at line 1587 of file ASlider.cpp.

References mLWSlider.

Referenced by MixerToolBar::ShowInputGainDialog(), MixerToolBar::ShowOutputGainDialog(), and TranscriptionToolBar::ShowPlaySpeedDialog().

1588 {
1589  return mLWSlider->ShowDialog(pos);
1590 }
std::unique_ptr< LWSlider > mLWSlider
Definition: ASlider.h:322
auto ASlider::TemporarilyAllowFocus ( )
static

Definition at line 1616 of file ASlider.cpp.

Referenced by AudacityProject::NextOrPrevFrame(), ToolManager::RestoreFocus(), and SetFocusFromKbd().

1616  {
1617  s_AcceptsFocus = true;
1618  return TempAllowFocus{ &s_AcceptsFocus };
1619 }
std::unique_ptr< bool, Resetter > TempAllowFocus
Definition: ASlider.h:316
static bool s_AcceptsFocus
Definition: ASlider.h:314

Friends And Related Function Documentation

friend class ASliderAx
friend

Definition at line 245 of file ASlider.h.

Member Data Documentation

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

Definition at line 323 of file ASlider.h.

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

int ASlider::mStyle
protected

Definition at line 327 of file ASlider.h.

Referenced by MixerTrackSlider::OnMouseEvent().

wxTimer ASlider::mTimer
private

Definition at line 324 of file ASlider.h.

Referenced by OnMouseEvent().

bool ASlider::s_AcceptsFocus { false }
staticprivate

Definition at line 314 of file ASlider.h.

Referenced by AcceptsFocus().


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