Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
LWSlider Class Reference

Lightweight version of ASlider. In other words it does not have a window permanently associated with it. More...

#include <ASlider.h>

Collaboration diagram for LWSlider:
[legend]

Public Member Functions

 LWSlider (wxWindow *parent, const TranslatableString &name, const wxPoint &pos, const wxSize &size, float minValue, float maxValue, float stepValue, bool canUseShift, int style, bool heavyweight=false, bool popup=true, int orientation=wxHORIZONTAL)
 
 LWSlider (wxWindow *parent, const TranslatableString &name, const wxPoint &pos, const wxSize &size, int style, bool heavyweight=false, bool popup=true, int orientation=wxHORIZONTAL)
 
void Init (wxWindow *parent, const TranslatableString &name, const wxPoint &pos, const wxSize &size, float minValue, float maxValue, float stepValue, bool canUseShift, int style, bool heavyweight, bool popup, float speed, int orientation=wxHORIZONTAL)
 
virtual ~LWSlider ()
 
wxWindowID GetId ()
 
void SetId (wxWindowID id)
 
void SetDefaultValue (float value)
 
void SetDefaultShortcut (bool value)
 
void GetScroll (float &line, float &page)
 
void SetScroll (float line, float page)
 
void ShowTip (bool show)
 
void SetToolTipTemplate (const TranslatableString &tip)
 
float Get (bool convert=true)
 
void Set (float value)
 
void Increase (float steps)
 
void Decrease (float steps)
 
void SetSpeed (float speed)
 
void Move (const wxPoint &newpos)
 
void AdjustSize (const wxSize &sz)
 
void OnPaint (wxDC &dc, bool highlighted)
 
void OnSize (wxSizeEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 
void Refresh ()
 
void Redraw ()
 
bool ShowDialog ()
 
bool ShowDialog (wxPoint pos)
 
void SetEnabled (bool enabled)
 
bool GetEnabled () const
 
float GetMinValue () const
 
float GetMaxValue () const
 
void SetParent (wxWindow *parent)
 
void SendUpdate (float newValue)
 

Private Member Functions

TranslatableString GetTip (float value) const
 
TranslatableStrings GetWidestTips () const
 
void FormatPopWin ()
 
void SetPopWinPosition ()
 
void CreatePopWin ()
 
void DrawToBitmap (wxDC &dc)
 
bool DoShowDialog (wxPoint pos)
 
int ValueToPosition (float val)
 
float DragPositionToValue (int fromPos, bool shiftDown)
 
float ClickPositionToValue (int fromPos, bool shiftDown)
 

Private Attributes

wxWindow * mParent
 
int mStyle
 
int mOrientation
 
bool mHW
 
bool mPopup
 
int mLeft
 
int mTop
 
int mWidth
 
int mHeight
 
int mCenterY
 
int mLeftX
 
int mRightX
 
int mWidthX
 
int mCenterX
 
int mTopY
 
int mBottomY
 
int mHeightY
 
int mThumbWidth
 
int mThumbHeight
 
float mClickValue
 
int mClickPos
 
float mMinValue
 
float mMaxValue
 
float mStepValue
 
float mSpeed
 
float mScrollLine
 
float mScrollPage
 
float mCurrentValue
 
bool mDefaultShortcut
 
float mDefaultValue
 
bool mCanUseShift
 
wxWindowID mID
 
std::unique_ptr< TipWindowmTipPanel
 
TranslatableString mTipTemplate
 
bool mIsDragging
 
std::unique_ptr< wxBitmap > mBitmap
 
std::unique_ptr< wxBitmap > mThumbBitmap
 
std::unique_ptr< wxBitmap > mThumbBitmapHilited
 
TranslatableString mName
 
bool mEnabled
 

Friends

class ASlider
 
class ASliderAx
 

Detailed Description

Lightweight version of ASlider. In other words it does not have a window permanently associated with it.

Definition at line 61 of file ASlider.h.

Constructor & Destructor Documentation

◆ LWSlider() [1/2]

LWSlider::LWSlider ( wxWindow *  parent,
const TranslatableString name,
const wxPoint &  pos,
const wxSize &  size,
float  minValue,
float  maxValue,
float  stepValue,
bool  canUseShift,
int  style,
bool  heavyweight = false,
bool  popup = true,
int  orientation = wxHORIZONTAL 
)

Definition at line 474 of file ASlider.cpp.

486{
487 Init(parent, name, pos, size, minValue, maxValue,
488 stepValue, canUseShift, style, heavyweight, popup, 1.0, orientation);
489}
const TranslatableString name
Definition: Distortion.cpp:82
void Init(wxWindow *parent, const TranslatableString &name, const wxPoint &pos, const wxSize &size, float minValue, float maxValue, float stepValue, bool canUseShift, int style, bool heavyweight, bool popup, float speed, int orientation=wxHORIZONTAL)
Definition: ASlider.cpp:552

References Init(), name, and size.

Here is the call graph for this function:

◆ LWSlider() [2/2]

LWSlider::LWSlider ( wxWindow *  parent,
const TranslatableString name,
const wxPoint &  pos,
const wxSize &  size,
int  style,
bool  heavyweight = false,
bool  popup = true,
int  orientation = wxHORIZONTAL 
)

Definition at line 492 of file ASlider.cpp.

500{
501 wxString leftLabel, rightLabel;
502
503 float minValue, maxValue, stepValue;
504 float speed = 1.0;
505
506 switch(style)
507 {
508 case PAN_SLIDER:
509 minValue = -1.0f;
510 maxValue = +1.0f;
511 stepValue = 0.1f;
512 orientation = wxHORIZONTAL; //v Vertical PAN_SLIDER currently not handled, forced to horizontal.
513 break;
514 case DB_SLIDER:
515 minValue = -36.0f;
516 //if (orientation == wxHORIZONTAL)
517 maxValue = 36.0f;
518 //else
519 //maxValue = 36.0f; // for MixerBoard //v Previously was 6dB for MixerBoard, but identical for now.
520 stepValue = 1.0f;
521 speed = 0.5;
522 break;
523 case FRAC_SLIDER:
524 minValue = 0.0f;
525 maxValue = 1.0f;
526 stepValue = STEP_CONTINUOUS;
527 break;
528 case SPEED_SLIDER:
529 minValue = 0.01f;
530 maxValue = 3.0f;
531 stepValue = STEP_CONTINUOUS;
532 break;
533#ifdef EXPERIMENTAL_MIDI_OUT
534 case VEL_SLIDER:
535 minValue = VEL_MIN;
536 maxValue = VEL_MAX;
537 stepValue = 1.0f;
538 speed = 0.5;
539 break;
540#endif
541 default:
542 minValue = 0.0f;
543 maxValue = 1.0f;
544 stepValue = 0.0f;
545 wxASSERT(false); // undefined style
546 }
547
548 Init(parent, name, pos, size, minValue, maxValue, stepValue,
549 true, style, heavyweight, popup, speed, orientation);
550}
#define VEL_SLIDER
Definition: ASlider.h:37
#define DB_SLIDER
Definition: ASlider.h:33
#define FRAC_SLIDER
Definition: ASlider.h:32
#define STEP_CONTINUOUS
Definition: ASlider.h:52
#define SPEED_SLIDER
Definition: ASlider.h:35
#define PAN_SLIDER
Definition: ASlider.h:34
#define VEL_MAX
Definition: ASlider.h:46
#define VEL_MIN
Definition: ASlider.h:45

References DB_SLIDER, FRAC_SLIDER, Init(), name, PAN_SLIDER, size, SPEED_SLIDER, STEP_CONTINUOUS, VEL_MAX, VEL_MIN, and VEL_SLIDER.

Here is the call graph for this function:

◆ ~LWSlider()

LWSlider::~LWSlider ( )
virtual

Definition at line 595 of file ASlider.cpp.

596{
597}

Member Function Documentation

◆ AdjustSize()

void LWSlider::AdjustSize ( const wxSize &  sz)

Definition at line 638 of file ASlider.cpp.

639{
640 mWidth = sz.GetWidth();
641 mHeight = sz.GetHeight();
642
643 if( mBitmap ){
644 mBitmap.reset();
645 }
646 mThumbWidth = 11;
647 mThumbHeight = 20;
648
649 if (mOrientation == wxHORIZONTAL)
650 {
651 mCenterY = mHeight - 9;
652 }
653 else
654 {
655 mCenterX = mWidth - 9;
656 }
657
658 if (mOrientation == wxHORIZONTAL)
659 {
661 mRightX = mWidth - mThumbWidth/2 - 1;
663 }
664 else
665 {
666 mTopY = mThumbWidth/2;
667 mBottomY = mHeight - mThumbWidth/2 - 1;
669 }
670
671 Refresh();
672}
int mCenterX
Definition: ASlider.h:191
int mThumbWidth
Definition: ASlider.h:198
int mHeightY
Definition: ASlider.h:195
void Refresh()
Definition: ASlider.cpp:1528
int mTopY
Definition: ASlider.h:193
int mBottomY
Definition: ASlider.h:194
int mLeftX
Definition: ASlider.h:186
int mCenterY
Definition: ASlider.h:184
int mHeight
Definition: ASlider.h:181
std::unique_ptr< wxBitmap > mBitmap
Definition: ASlider.h:226
int mRightX
Definition: ASlider.h:187
int mOrientation
Definition: ASlider.h:172
int mWidth
Definition: ASlider.h:180
int mWidthX
Definition: ASlider.h:188
int mThumbHeight
Definition: ASlider.h:199

References mBitmap, mBottomY, mCenterX, mCenterY, mHeight, mHeightY, mLeftX, mOrientation, mRightX, mThumbHeight, mThumbWidth, mTopY, mWidth, mWidthX, and Refresh().

Referenced by Init(), and OnSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClickPositionToValue()

float LWSlider::ClickPositionToValue ( int  fromPos,
bool  shiftDown 
)
private

Definition at line 1383 of file ASlider.cpp.

1384{
1385 int nSpan;
1386 int pos;
1387 if (mOrientation == wxHORIZONTAL)
1388 {
1389 pos = (fromPos - mLeft - (mThumbWidth / 2));
1390 nSpan = mWidthX;
1391 }
1392 else
1393 {
1394 // wxVERTICAL => Low values at bottom.
1395 pos = mBottomY - fromPos;
1396 nSpan = mHeightY;
1397 }
1398
1399 // MM: Special cases: If position is at the very left or the
1400 // very right (or top/bottom for wxVERTICAL), set minimum/maximum value without other checks
1401 if (pos <= 0)
1402 return mMinValue;
1403 if (pos >= nSpan)
1404 return mMaxValue;
1405
1406 float val = (pos / (float)nSpan)
1408
1409 if (val < mMinValue)
1410 val = mMinValue;
1411 if (val > mMaxValue)
1412 val = mMaxValue;
1413
1414 if (!(mCanUseShift && shiftDown) && mStepValue != STEP_CONTINUOUS)
1415 {
1416 // MM: If shift is not down, or we don't allow usage
1417 // of shift key at all, trim value to steps of
1418 // provided size.
1419 val = (int)(val / mStepValue + 0.5 * (val>0?1.0f:-1.0f)) * mStepValue;
1420 }
1421
1422 return val;
1423}
int mLeft
Definition: ASlider.h:177
float mMinValue
Definition: ASlider.h:204
bool mCanUseShift
Definition: ASlider.h:217
float mMaxValue
Definition: ASlider.h:205
float mStepValue
Definition: ASlider.h:206

References mBottomY, mCanUseShift, mHeightY, mLeft, mMaxValue, mMinValue, mOrientation, mStepValue, mThumbWidth, mWidthX, and STEP_CONTINUOUS.

Referenced by OnMouseEvent().

Here is the caller graph for this function:

◆ CreatePopWin()

void LWSlider::CreatePopWin ( )
private

Definition at line 918 of file ASlider.cpp.

919{
920 mTipPanel = std::make_unique<TipWindow>(mParent, GetWidestTips());
921}
std::unique_ptr< TipWindow > mTipPanel
Definition: ASlider.h:221
TranslatableStrings GetWidestTips() const
Definition: ASlider.cpp:1021
wxWindow * mParent
Definition: ASlider.h:169

References GetWidestTips(), mParent, and mTipPanel.

Referenced by ShowTip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Decrease()

void LWSlider::Decrease ( float  steps)

Definition at line 1505 of file ASlider.cpp.

1506{
1507 float stepValue = mStepValue;
1508
1509 if ( stepValue == 0.0 )
1510 {
1511 stepValue = ( mMaxValue - mMinValue ) / 10.0;
1512 }
1513
1514 mCurrentValue -= ( steps * stepValue );
1515
1516 if ( mCurrentValue < mMinValue )
1517 {
1519 }
1520 else if ( mCurrentValue > mMaxValue )
1521 {
1523 }
1524
1525 Refresh();
1526}
float mCurrentValue
Definition: ASlider.h:212

References mCurrentValue, mMaxValue, mMinValue, mStepValue, and Refresh().

Referenced by OnKeyDown(), OnMouseEvent(), TrackActions::Handler::OnTrackGainDec(), and TrackActions::Handler::OnTrackPanLeft().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoShowDialog()

bool LWSlider::DoShowDialog ( wxPoint  pos)
private

Definition at line 1078 of file ASlider.cpp.

1079{
1080 float value = mCurrentValue;
1081 bool changed = false;
1082
1083 SliderDialog dlg( NULL,
1084 wxID_ANY,
1085 mName,
1086 pos,
1087 // Bug 2087. wxMin takes care of case where
1088 // slider is vertical (tall and narrow)
1089 wxSize( mWidth, wxMin( mWidth, mHeight) ),
1090 mStyle,
1091 Get(),
1094 this);
1095 if (pos == wxPoint(-1, -1)) {
1096 dlg.Center();
1097 }
1098
1099 changed = (dlg.ShowModal() == wxID_OK);
1100 if( changed )
1101 value = dlg.Get();
1102
1103 // We now expect the pop up dialog to be
1104 // sending updates as we go.
1105 // So this code is needed to possibly restore the old
1106 // value, on a cancel.
1107 if (mCurrentValue != value) {
1108 mCurrentValue = value;
1109 SendUpdate(value);
1110 }
1111
1112 return changed;
1113}
TranslatableString mName
Definition: ASlider.h:228
float Get(bool convert=true)
Definition: ASlider.cpp:1457
int mStyle
Definition: ASlider.h:171
void SendUpdate(float newValue)
Definition: ASlider.cpp:1343
float mScrollPage
Definition: ASlider.h:210
float mScrollLine
Definition: ASlider.h:209
Pop up dialog used with an LWSlider.
Definition: ASlider.h:334

References SliderDialog::Get(), Get(), mCurrentValue, mHeight, mName, mScrollLine, mScrollPage, mStyle, mWidth, and SendUpdate().

Referenced by OnMouseEvent(), and ShowDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DragPositionToValue()

float LWSlider::DragPositionToValue ( int  fromPos,
bool  shiftDown 
)
private

Definition at line 1427 of file ASlider.cpp.

1428{
1429 int delta = (fromPos - mClickPos);
1430
1431 float speed = mSpeed;
1432 // Precision enhancement for Shift drags
1433 if (mCanUseShift && shiftDown)
1434 speed *= 0.4f;
1435
1436 // wxVERTICAL => Low values at bottom, so throw in the minus sign here with -mHeightY.
1437 float denominator = (mOrientation == wxHORIZONTAL) ? mWidthX : -mHeightY;
1438 float val = mClickValue +
1439 speed * (delta / denominator) * (mMaxValue - mMinValue);
1440
1441 if (val < mMinValue)
1442 val = mMinValue;
1443 if (val > mMaxValue)
1444 val = mMaxValue;
1445
1446 if (!(mCanUseShift && shiftDown) && mStepValue != STEP_CONTINUOUS)
1447 {
1448 // MM: If shift is not down, or we don't allow usage
1449 // of shift key at all, and the slider has not continuous values,
1450 // trim value to steps of provided size.
1451 val = (int)(val / mStepValue + 0.5 * (val>0?1.0f:-1.0f)) * mStepValue;
1452 }
1453
1454 return val;
1455}
float mClickValue
Definition: ASlider.h:201
float mSpeed
Definition: ASlider.h:207
int mClickPos
Definition: ASlider.h:202

References mCanUseShift, mClickPos, mClickValue, mHeightY, mMaxValue, mMinValue, mOrientation, mSpeed, mStepValue, mWidthX, and STEP_CONTINUOUS.

Referenced by OnMouseEvent().

Here is the caller graph for this function:

◆ DrawToBitmap()

void LWSlider::DrawToBitmap ( wxDC &  dc)
private

Definition at line 729 of file ASlider.cpp.

730{
731 // Get correctly oriented thumb.
732 if (mOrientation == wxVERTICAL){
733 mThumbBitmap = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbRotated )));
734 mThumbBitmapHilited = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbRotatedHilited )));
735 }
736 else {
737 mThumbBitmap = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumb )));
738 mThumbBitmapHilited = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbHilited )));
739 }
740
741 // Now the background bitmap
742 mBitmap = std::make_unique<wxBitmap>();
743 mBitmap->Create(mWidth, mHeight, paintDC);
744
745#if defined(__WXMAC__)
746 mBitmap->UseAlpha();
747#endif
748
749 // Set up the memory DC
750 // We draw to it, not the paintDC.
751 wxMemoryDC dc;
752 dc.SelectObject(*mBitmap);
753
754 dc.SetBackground(wxBrush(mParent->GetBackgroundColour()));
755 dc.Clear();
756
757 // Draw the line along which the thumb moves.
758 AColor::UseThemeColour(&dc, clrSliderMain );
759
760 if (mOrientation == wxHORIZONTAL)
761 {
764 }
765 else
766 {
769 }
770
771 // Draw +/- or L/R first. We need to draw these before the tick marks.
772 if (mStyle == PAN_SLIDER)
773 {
774 //VJ Vertical PAN_SLIDER currently not handled, forced to horizontal.
775
776 // sliderFontSize is for the tooltip.
777 // we need something smaller here...
778 wxFont labelFont(7, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
779 dc.SetFont(labelFont);
780
781 // Color
782 dc.SetTextForeground( theTheme.Colour( clrTrackPanelText ));
783
784 /* i18n-hint: One-letter abbreviation for Left, in the Pan slider */
785 dc.DrawText(_("L"), mLeftX, 0);
786
787 /* i18n-hint: One-letter abbreviation for Right, in the Pan slider */
788 dc.DrawText(_("R"), mRightX - dc.GetTextExtent(_("R")).GetWidth(), 0);
789 }
790 else
791 {
792 // draw the '-' and the '+'
793 // These are drawn with lines, rather tha nwith a font.
794 AColor::UseThemeColour(&dc, clrTrackPanelText );
795
796 if (mOrientation == wxHORIZONTAL)
797 {
799 AColor::Line(dc, mRightX-5, mCenterY-10, mRightX-1, mCenterY-10);
801 }
802 else
803 {
804 // Vertical DB_SLIDER is for gain slider in MixerBoard.
805 // We use a Ruler instead of marks & ticks.
806 // Draw '+' and '-' only for other vertical sliders.
807 if (mStyle != DB_SLIDER)
808 {
810 AColor::Line(dc, mCenterX-12, mTopY+3, mCenterX-8, mTopY+3);
811 AColor::Line(dc, mCenterX-10, mTopY, mCenterX-10, mTopY+5);
812 }
813 }
814 }
815
816 // Use special colour to indicate no ticks.
817 wxColour TickColour = theTheme.Colour( clrSliderLight );
818 bool bTicks = TickColour != wxColour(60,60,60);
819
820 if( bTicks ) {
821 // tick marks
822 int divs = 10;
823 double upp;
824 if (mOrientation == wxHORIZONTAL)
825 {
826 // Bug #2446 - A bit of a hack, but it should suffice.
827 divs = (mWidth - 1) / 10;
828 upp = divs / (double)(mWidthX-1);
829 }
830 else
831 {
832 if (mStyle == DB_SLIDER)
833 divs = mMaxValue - mMinValue + 1;
834 upp = divs / (double)(mHeightY-1);
835 }
836#ifdef OPTIONAL_SLIDER_TICKS
837 double d = 0.0;
838 int int_d = -1;
839 const int kMax = (mOrientation == wxHORIZONTAL) ? mWidthX : mHeightY;
840 for(int p = 0; p <= kMax; p++)
841 {
842 if (((int)d) > int_d)
843 {
844 int_d = (int)d;
845 int tickLength = ((int_d == 0) || (int_d == divs)) ? 5: 3; // longer ticks at extremes
846 AColor::UseThemeColour(&dc, clrSliderLight );
847
848 if (mOrientation == wxHORIZONTAL)
849 {
850 AColor::Line(dc, mLeftX+p, mCenterY-tickLength, mLeftX+p, mCenterY-1); // ticks above
851 }
852 else
853 {
854 AColor::Line(dc, mCenterX-tickLength, mTopY+p, mCenterX-1, mTopY+p); // ticks at left
855 }
856
857 AColor::UseThemeColour(&dc, clrSliderDark );
858
859 if (mOrientation == wxHORIZONTAL)
860 {
861 AColor::Line(dc, mLeftX+p+1, mCenterY-tickLength+1, mLeftX+p+1, mCenterY-1); // ticks above
862 }
863 else
864 {
865 AColor::Line(dc, mCenterX-tickLength+1, mTopY+p+1, mCenterX-1, mTopY+p+1); // ticks at left
866 }
867 }
868 d += upp;
869 }
870#endif
871 }
872
873 dc.SelectObject(wxNullBitmap);
874
875 // safenew, because SetMask takes ownership
876 // We always mask. If we are HeavyWeight, the ASlider draws the
877 // background.
878 if( !mHW )
879 {
880 mBitmap->SetMask(safenew wxMask(*mBitmap, dc.GetBackground().GetColour()));
881 }
882}
#define _(s)
Definition: Internat.h:75
#define safenew
Definition: MemoryX.h:10
THEME_API Theme theTheme
Definition: Theme.cpp:82
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1, int alpha=255)
Definition: AColor.cpp:349
std::unique_ptr< wxBitmap > mThumbBitmap
Definition: ASlider.h:226
std::unique_ptr< wxBitmap > mThumbBitmapHilited
Definition: ASlider.h:226
bool mHW
Definition: ASlider.h:174
wxColour & Colour(int iIndex)
wxBitmap & Bitmap(int iIndex)

References _, ThemeBase::Bitmap(), ThemeBase::Colour(), DB_SLIDER, AColor::Line(), mBitmap, mBottomY, mCenterX, mCenterY, mHeight, mHeightY, mHW, mLeftX, mMaxValue, mMinValue, mOrientation, mParent, mRightX, mStyle, mThumbBitmap, mThumbBitmapHilited, mTopY, mWidth, mWidthX, PAN_SLIDER, safenew, theTheme, and AColor::UseThemeColour().

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FormatPopWin()

void LWSlider::FormatPopWin ( )
private

Definition at line 945 of file ASlider.cpp.

946{
947 if (!mTipPanel)
948 {
949 return;
950 }
951
952 mTipPanel->SetLabel(GetTip(mCurrentValue));
953 mTipPanel->Refresh();
954}
TranslatableString GetTip(float value) const
Definition: ASlider.cpp:956

References GetTip(), mCurrentValue, and mTipPanel.

Referenced by SendUpdate(), and ShowTip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get()

float LWSlider::Get ( bool  convert = true)

Definition at line 1457 of file ASlider.cpp.

1458{
1459 if (mStyle == DB_SLIDER)
1460 return (convert ? DB_TO_LINEAR(mCurrentValue) : mCurrentValue);
1461 else
1462 return mCurrentValue;
1463}
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:535

References DB_SLIDER, DB_TO_LINEAR, mCurrentValue, and mStyle.

Referenced by DoShowDialog(), SliderHandle::Drag(), SliderHandle::Release(), anonymous_namespace{TrackMenus.cpp}::SetTrackGain(), and anonymous_namespace{TrackMenus.cpp}::SetTrackPan().

Here is the caller graph for this function:

◆ GetEnabled()

bool LWSlider::GetEnabled ( ) const

Definition at line 1543 of file ASlider.cpp.

1544{
1545 return mEnabled;
1546}
bool mEnabled
Definition: ASlider.h:230

References mEnabled.

◆ GetId()

wxWindowID LWSlider::GetId ( )

Definition at line 599 of file ASlider.cpp.

600{
601 return mID;
602}
wxWindowID mID
Definition: ASlider.h:219

References mID.

◆ GetMaxValue()

float LWSlider::GetMaxValue ( ) const

Definition at line 1563 of file ASlider.cpp.

1564{
1565 return mMaxValue;
1566}

References mMaxValue.

◆ GetMinValue()

float LWSlider::GetMinValue ( ) const

Definition at line 1558 of file ASlider.cpp.

1559{
1560 return mMinValue;
1561}

References mMinValue.

◆ GetScroll()

void LWSlider::GetScroll ( float &  line,
float &  page 
)

Definition at line 620 of file ASlider.cpp.

621{
622 line = mScrollLine;
623 page = mScrollPage;
624}

References mScrollLine, and mScrollPage.

◆ GetTip()

TranslatableString LWSlider::GetTip ( float  value) const
private

Definition at line 956 of file ASlider.cpp.

957{
959
960 if (mTipTemplate.empty())
961 {
963
964 switch(mStyle)
965 {
966 case FRAC_SLIDER:
967 val = Verbatim("%.2f").Format( value );
968 break;
969
970 case DB_SLIDER:
971 /* i18n-hint dB abbreviates decibels */
972 val = XO("%+.1f dB").Format( value );
973 break;
974
975 case PAN_SLIDER:
976 if (value == 0.0)
977 {
978 val = XO("Center");
979 }
980 else
981 {
982 const auto v = 100.0f * fabsf(value);
983 if (value < 0.0)
984 /* i18n-hint: Stereo pan setting */
985 val = XO("%.0f%% Left").Format( v );
986 else
987 /* i18n-hint: Stereo pan setting */
988 val = XO("%.0f%% Right").Format( v );
989 }
990 break;
991
992 case SPEED_SLIDER:
993 /* i18n-hint: "x" suggests a multiplicative factor */
994 val = XO("%.2fx").Format( value );
995 break;
996
997#ifdef EXPERIMENTAL_MIDI_OUT
998 case VEL_SLIDER:
999 if (value > 0.0f)
1000 // Signed
1001 val = Verbatim("%+d").Format( (int) value );
1002 else
1003 // Zero, or signed negative
1004 val = Verbatim("%d").Format( (int) value );
1005 break;
1006#endif
1007 }
1008
1009 /* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
1010 label = XO("%s: %s").Format( mName, val );
1011 }
1012 else
1013 {
1015 label.Format( value );
1016 }
1017
1018 return label;
1019}
#define XO(s)
Definition: Internat.h:31
TranslatableString label
Definition: TagsEditor.cpp:163
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
TranslatableString mTipTemplate
Definition: ASlider.h:222
Holds a msgid for the translation catalog; may also bind format arguments.
TranslatableString & Format(Args &&...args) &
Capture variadic format arguments (by copy) when there is no plural.

References DB_SLIDER, TranslatableString::empty(), TranslatableString::Format(), FRAC_SLIDER, label, mName, mStyle, mTipTemplate, PAN_SLIDER, SPEED_SLIDER, VEL_SLIDER, Verbatim(), and XO.

Referenced by FormatPopWin(), GetWidestTips(), OnMouseEvent(), and SendUpdate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetWidestTips()

TranslatableStrings LWSlider::GetWidestTips ( ) const
private

Definition at line 1021 of file ASlider.cpp.

1022{
1023 TranslatableStrings results;
1024
1025 if (mTipTemplate.empty())
1026 {
1027 wxString val;
1028
1029 switch(mStyle)
1030 {
1031 case FRAC_SLIDER:
1032 results.push_back( GetTip( -1.99f ) );
1033 results.push_back( GetTip( +1.99f ) );
1034 break;
1035
1036 case DB_SLIDER:
1037 results.push_back( GetTip( -99.9f ) );
1038 results.push_back( GetTip( +99.9f ) );
1039 break;
1040
1041 case PAN_SLIDER:
1042 // Don't assume we know which of "Left", "Right", or "Center"
1043 // is the longest string, when localized
1044 results.push_back( GetTip( 0.f ) );
1045 results.push_back( GetTip( +1.f ) );
1046 results.push_back( GetTip( -1.f ) );
1047 break;
1048
1049 case SPEED_SLIDER:
1050 results.push_back( GetTip( 9.99f ) );
1051 break;
1052
1053#ifdef EXPERIMENTAL_MIDI_OUT
1054 case VEL_SLIDER:
1055 results.push_back( GetTip( 999.f ) );
1056 break;
1057#endif
1058 }
1059 }
1060 else
1061 {
1062 results.push_back( GetTip( floor(mMaxValue - mMinValue) + 0.999 ) );
1063 }
1064
1065 return results;
1066}
std::vector< TranslatableString > TranslatableStrings

References DB_SLIDER, TranslatableString::empty(), FRAC_SLIDER, GetTip(), mMaxValue, mMinValue, mStyle, mTipTemplate, PAN_SLIDER, SPEED_SLIDER, and VEL_SLIDER.

Referenced by CreatePopWin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Increase()

void LWSlider::Increase ( float  steps)

Definition at line 1482 of file ASlider.cpp.

1483{
1484 float stepValue = mStepValue;
1485
1486 if ( stepValue == 0.0 )
1487 {
1488 stepValue = ( mMaxValue - mMinValue ) / 10.0;
1489 }
1490
1491 mCurrentValue += ( steps * stepValue );
1492
1493 if ( mCurrentValue < mMinValue )
1494 {
1496 }
1497 else if ( mCurrentValue > mMaxValue )
1498 {
1500 }
1501
1502 Refresh();
1503}

References mCurrentValue, mMaxValue, mMinValue, mStepValue, and Refresh().

Referenced by OnKeyDown(), OnMouseEvent(), TrackActions::Handler::OnTrackGainInc(), and TrackActions::Handler::OnTrackPanRight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init()

void LWSlider::Init ( wxWindow *  parent,
const TranslatableString name,
const wxPoint &  pos,
const wxSize &  size,
float  minValue,
float  maxValue,
float  stepValue,
bool  canUseShift,
int  style,
bool  heavyweight,
bool  popup,
float  speed,
int  orientation = wxHORIZONTAL 
)

Definition at line 552 of file ASlider.cpp.

565{
566 mEnabled = true;
567 mName = name;
568 mStyle = style;
569 mOrientation = orientation;
570 mIsDragging = false;
571 mParent = parent;
572 mHW = heavyweight;
573 mPopup = popup;
574 mSpeed = speed;
575 mID = wxID_ANY;
576 mMinValue = minValue;
577 mMaxValue = maxValue;
578 mStepValue = stepValue;
579 mCanUseShift = canUseShift;
580 mCurrentValue = 0.0f;
581 mDefaultValue = 0.0f;
582 mDefaultShortcut = false;
583 mBitmap = nullptr;
584 mThumbBitmap = nullptr;
585 mThumbBitmapHilited = nullptr;
586 mScrollLine = 1.0f;
587 mScrollPage = 5.0f;
588 mTipPanel = NULL;
589
591
592 Move(pos);
593}
float mDefaultValue
Definition: ASlider.h:215
bool mPopup
Definition: ASlider.h:175
void AdjustSize(const wxSize &sz)
Definition: ASlider.cpp:638
bool mIsDragging
Definition: ASlider.h:224
bool mDefaultShortcut
Definition: ASlider.h:214
void Move(const wxPoint &newpos)
Definition: ASlider.cpp:632

References AdjustSize(), mBitmap, mCanUseShift, mCurrentValue, mDefaultShortcut, mDefaultValue, mEnabled, mHW, mID, mIsDragging, mMaxValue, mMinValue, mName, mOrientation, Move(), mParent, mPopup, mScrollLine, mScrollPage, mSpeed, mStepValue, mStyle, mThumbBitmap, mThumbBitmapHilited, mTipPanel, name, and size.

Referenced by LWSlider().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Move()

void LWSlider::Move ( const wxPoint &  newpos)

Definition at line 632 of file ASlider.cpp.

633{
634 mLeft = newpos.x;
635 mTop = newpos.y;
636}
int mTop
Definition: ASlider.h:178

References mLeft, and mTop.

Referenced by Init().

Here is the caller graph for this function:

◆ OnKeyDown()

void LWSlider::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1276 of file ASlider.cpp.

1277{
1278 if (mEnabled)
1279 {
1280 switch( event.GetKeyCode() )
1281 {
1282 case WXK_TAB:
1283 mParent->Navigate(event.ShiftDown()
1284 ? wxNavigationKeyEvent::IsBackward
1285 : wxNavigationKeyEvent::IsForward);
1286 break;
1287
1288 case WXK_RIGHT:
1289 case WXK_UP:
1292 break;
1293
1294 case WXK_LEFT:
1295 case WXK_DOWN:
1298 break;
1299
1300 case WXK_PAGEUP:
1303 break;
1304
1305 case WXK_PAGEDOWN:
1308 break;
1309
1310 case WXK_HOME:
1312 break;
1313
1314 case WXK_END:
1316 break;
1317
1318 case WXK_RETURN:
1319 case WXK_NUMPAD_ENTER:
1320 {
1321 wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(mParent), wxTopLevelWindow);
1322 wxWindow *def = tlw->GetDefaultItem();
1323 if (def && def->IsEnabled()) {
1324 wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
1325 def->GetId());
1326 cevent.SetEventObject( def );
1327 mParent->GetEventHandler()->ProcessEvent(cevent);
1328 }
1329 }
1330
1331 default:
1332 // Allow it to propagate
1333 event.Skip();
1334 break;
1335 }
1336 }
1337 else
1338 {
1339 event.Skip();
1340 }
1341}
wxEVT_COMMAND_BUTTON_CLICKED
void Decrease(float steps)
Definition: ASlider.cpp:1505
void Increase(float steps)
Definition: ASlider.cpp:1482

References Decrease(), Increase(), mCurrentValue, mEnabled, mMaxValue, mMinValue, mParent, mScrollLine, mScrollPage, SendUpdate(), and wxEVT_COMMAND_BUTTON_CLICKED.

Here is the call graph for this function:

◆ OnMouseEvent()

void LWSlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1115 of file ASlider.cpp.

1116{
1117 if (event.Entering())
1118 {
1119 // Display the tooltip in the status bar
1120 auto tip = GetTip(mCurrentValue);
1121 auto pProject = FindProjectFromWindow( mParent );
1122 if (pProject)
1123 ProjectStatus::Get( *pProject ).Set( tip );
1124 Refresh();
1125 }
1126 else if (event.Leaving())
1127 {
1128 if (!mIsDragging)
1129 {
1130 ShowTip(false);
1131 }
1132 auto pProject = FindProjectFromWindow( mParent );
1133 if (pProject)
1134 ProjectStatus::Get( *pProject ).Set({});
1135 Refresh();
1136 }
1137
1138 // Events other than mouse-overs are ignored when we are disabled
1139 if (!mEnabled)
1140 return;
1141
1142 // Windows sends a right button mouse event when you press the context menu
1143 // key, so ignore it.
1144 if ((event.RightDown() && !event.RightIsDown()) ||
1145 (event.RightUp() && event.GetPosition() == wxPoint(-1, -1)))
1146 {
1147 event.Skip(false);
1148 return;
1149 }
1150
1151 float prevValue = mCurrentValue;
1152
1153 // Figure out the thumb position
1154 wxRect r;
1155 if (mOrientation == wxHORIZONTAL)
1156 {
1158 r.y = mTop + (mCenterY - (mThumbHeight / 2));
1159 }
1160 else
1161 {
1162 r.x = mLeft + (mCenterX - (mThumbWidth / 2));
1164 }
1165 r.width = mThumbWidth;
1166 r.height = mThumbHeight;
1167
1168 wxRect tolerantThumbRect = r;
1169 tolerantThumbRect.Inflate(3, 3);
1170
1171 // Should probably use a right click instead/also
1172 if( event.ButtonDClick() && mPopup )
1173 {
1174 //On a double-click, we should pop up a dialog.
1175 DoShowDialog(mParent->ClientToScreen(wxPoint(event.m_x,event.m_y)));
1176 }
1177 else if( event.ButtonDown() )
1178 {
1179 if( mDefaultShortcut && event.ControlDown() )
1180 {
1182 }
1183
1184 if( event.RightDown() ) {
1185 mParent->SetFocus();
1186 }
1187
1188 // Thumb clicked?
1189 //
1190 // Do not change position until first drag. This helps
1191 // with unintended value changes.
1192 if( tolerantThumbRect.Contains( event.GetPosition() ) )
1193 {
1194 // Remember mouse position and current value
1195 mClickPos = (mOrientation == wxHORIZONTAL) ? event.m_x : event.m_y;
1197
1198 mIsDragging = true;
1199 }
1200 // Clicked to set location?
1201 else
1202 {
1205 (mOrientation == wxHORIZONTAL) ? event.m_x : event.m_y,
1206 event.ShiftDown());
1207 }
1208
1209 if (!mParent->HasCapture()) {
1210 mParent->CaptureMouse();
1211 }
1212
1213 ShowTip(true);
1214 }
1215 else if( event.ButtonUp() )
1216 {
1217 mIsDragging = false;
1218 if (mParent->HasCapture())
1219 mParent->ReleaseMouse();
1220
1221 ShowTip(false);
1222 }
1223 else if (event.Dragging() && mIsDragging)
1224 {
1225 if (mOrientation == wxHORIZONTAL)
1226 {
1227 if (event.m_y < (r.y - 2 * r.height) ||
1228 event.m_y > (r.y + 3 * r.height)) {
1229 // If the mouse y coordinate is relatively far from the slider,
1230 // snap back to the original position
1232 }
1233 else {
1234 // Otherwise, move the slider to the right position based
1235 // on the mouse position
1236 mCurrentValue = DragPositionToValue(event.m_x, event.ShiftDown());
1237 }
1238 }
1239 else // (mOrientation == wxVERTICAL)
1240 {
1241 if (event.m_x < (r.x - 2 * r.width) ||
1242 event.m_x > (r.x + 3 * r.width)) {
1243 // If the mouse x coordinate is relatively far from the slider,
1244 // snap back to the original position
1246 }
1247 else {
1248 // Otherwise, move the slider to the right position based
1249 // on the mouse position
1250 mCurrentValue = DragPositionToValue(event.m_y, event.ShiftDown());
1251 }
1252 }
1253 }
1254 else if( event.m_wheelRotation != 0 )
1255 {
1256 //Calculate the number of steps in a given direction this event
1257 //represents (allows for two or more clicks on a single event.)
1258 double steps = event.m_wheelRotation /
1259 (event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);
1260
1261 if( steps < 0.0 )
1262 {
1263 Decrease( (float)-steps );
1264 }
1265 else
1266 {
1267 Increase( (float)steps );
1268 }
1270 }
1271
1272 if( prevValue != mCurrentValue )
1274}
AudacityProject * FindProjectFromWindow(wxWindow *pWindow)
void ShowTip(bool show)
Definition: ASlider.cpp:889
int ValueToPosition(float val)
Definition: ASlider.cpp:1366
float DragPositionToValue(int fromPos, bool shiftDown)
Definition: ASlider.cpp:1427
bool DoShowDialog(wxPoint pos)
Definition: ASlider.cpp:1078
float ClickPositionToValue(int fromPos, bool shiftDown)
Definition: ASlider.cpp:1383
static ProjectStatus & Get(AudacityProject &project)
void Set(const TranslatableString &msg, StatusBarField field=mainStatusBarField)

References ClickPositionToValue(), Decrease(), DoShowDialog(), DragPositionToValue(), FindProjectFromWindow(), ProjectStatus::Get(), GetTip(), Increase(), mCenterX, mCenterY, mClickPos, mClickValue, mCurrentValue, mDefaultShortcut, mDefaultValue, mEnabled, mIsDragging, mLeft, mOrientation, mParent, mPopup, mThumbHeight, mThumbWidth, mTop, Refresh(), SendUpdate(), ProjectStatus::Set(), ShowTip(), and ValueToPosition().

Referenced by SliderHandle::Cancel(), SliderHandle::Drag(), and SliderHandle::Release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnPaint()

void LWSlider::OnPaint ( wxDC &  dc,
bool  highlighted 
)

Definition at line 674 of file ASlider.cpp.

675{
676 // The dc will be a paint DC
678 {
679 DrawToBitmap(dc);
680 }
681
682 //thumbPos should be in pixels
683 int thumbPos = ValueToPosition(mCurrentValue);
684 int thumbOrtho; // position in axis orthogonal to mOrientation
685 if (mOrientation == wxHORIZONTAL){
686 thumbOrtho = mCenterY - (mThumbHeight/2);
687 thumbPos += 1-mThumbWidth/2;
688 }
689 else{
690 thumbOrtho = mCenterX - (mThumbWidth/2);
691 thumbPos += 8-mThumbHeight/2;
692 }
693
694 // Draw the background.
695 // If we are lightweight, this has already been done for us.
696 if( mHW ){
697 dc.SetBackground( *wxTRANSPARENT_BRUSH );
698 dc.Clear();
699 }
700
701 dc.DrawBitmap(*mBitmap, mLeft, mTop, true);
702 const auto &thumbBitmap =
703 highlight ? *mThumbBitmapHilited : *mThumbBitmap;
704 if (mOrientation == wxHORIZONTAL)
705 {
706 dc.DrawBitmap(thumbBitmap, mLeft+thumbPos, mTop+thumbOrtho, true);
707 }
708 else
709 {
710 // TODO: Don't use pixel-count hack in positioning.
711 dc.DrawBitmap(thumbBitmap, mLeft+thumbOrtho-5, mTop+thumbPos, true);
712 }
713
714 if (mTipPanel)
715 {
716 mTipPanel->Update();
717 }
718}
void DrawToBitmap(wxDC &dc)
Definition: ASlider.cpp:729

References DrawToBitmap(), mBitmap, mCenterX, mCenterY, mCurrentValue, mHW, mLeft, mOrientation, mThumbBitmap, mThumbBitmapHilited, mThumbHeight, mThumbWidth, mTipPanel, mTop, and ValueToPosition().

Here is the call graph for this function:

◆ OnSize()

void LWSlider::OnSize ( wxSizeEvent &  event)

Definition at line 720 of file ASlider.cpp.

721{
722 AdjustSize(event.GetSize());
723
724 Refresh();
725}

References AdjustSize(), and Refresh().

Here is the call graph for this function:

◆ Redraw()

void LWSlider::Redraw ( )

Definition at line 1534 of file ASlider.cpp.

1535{
1536 mBitmap.reset();
1537 mThumbBitmap.reset();
1538 mThumbBitmapHilited.reset();
1539
1540 Refresh();
1541}

References mBitmap, mThumbBitmap, mThumbBitmapHilited, and Refresh().

Here is the call graph for this function:

◆ Refresh()

void LWSlider::Refresh ( )

Definition at line 1528 of file ASlider.cpp.

1529{
1530 if (mHW)
1531 mParent->Refresh(false);
1532}

References mHW, and mParent.

Referenced by AdjustSize(), Decrease(), Increase(), OnMouseEvent(), OnSize(), Redraw(), SendUpdate(), Set(), and SetEnabled().

Here is the caller graph for this function:

◆ SendUpdate()

void LWSlider::SendUpdate ( float  newValue)

Definition at line 1343 of file ASlider.cpp.

1344{
1345 mCurrentValue = newValue;
1346
1347 FormatPopWin();
1348
1349 Refresh();
1350
1351 // Update the project's status bar as well
1352 if (mTipPanel) {
1353 auto tip = GetTip(mCurrentValue);
1354 auto pProject = FindProjectFromWindow( mParent );
1355 if (pProject)
1356 ProjectStatus::Get( *pProject ).Set( tip );
1357 }
1358
1359 wxCommandEvent e( wxEVT_COMMAND_SLIDER_UPDATED, mID );
1360 int intValue = (int)( ( mCurrentValue - mMinValue ) * 1000.0f /
1361 ( mMaxValue - mMinValue ) );
1362 e.SetInt( intValue );
1363 mParent->GetEventHandler()->ProcessEvent(e);
1364}
void FormatPopWin()
Definition: ASlider.cpp:945

References FindProjectFromWindow(), FormatPopWin(), ProjectStatus::Get(), GetTip(), mCurrentValue, mID, mMaxValue, mMinValue, mParent, mTipPanel, Refresh(), and ProjectStatus::Set().

Referenced by DoShowDialog(), OnKeyDown(), OnMouseEvent(), SliderDialog::TransferDataFromWindow(), and SliderDialog::TransferDataToWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Set()

void LWSlider::Set ( float  value)

Definition at line 1465 of file ASlider.cpp.

1466{
1467 if (mIsDragging)
1468 return;
1469 if (mStyle == DB_SLIDER)
1470 mCurrentValue = LINEAR_TO_DB(value);
1471 else
1472 mCurrentValue = value;
1473
1478
1479 Refresh();
1480}
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:536

References DB_SLIDER, LINEAR_TO_DB, mCurrentValue, mIsDragging, mMaxValue, mMinValue, mStyle, and Refresh().

Referenced by SliderDialog::TransferDataFromWindow(), and SliderDialog::TransferDataToWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDefaultShortcut()

void LWSlider::SetDefaultShortcut ( bool  value)

Definition at line 615 of file ASlider.cpp.

616{
617 mDefaultShortcut = value;
618}

References mDefaultShortcut.

Referenced by SetDefaultValue().

Here is the caller graph for this function:

◆ SetDefaultValue()

void LWSlider::SetDefaultValue ( float  value)

Definition at line 609 of file ASlider.cpp.

610{
611 SetDefaultShortcut(true);
612 mDefaultValue = value;
613}
void SetDefaultShortcut(bool value)
Definition: ASlider.cpp:615

References mDefaultValue, and SetDefaultShortcut().

Here is the call graph for this function:

◆ SetEnabled()

void LWSlider::SetEnabled ( bool  enabled)

Definition at line 1548 of file ASlider.cpp.

1549{
1550 mEnabled = enabled;
1551
1552 mThumbBitmap.reset();
1553 mThumbBitmapHilited.reset();
1554
1555 Refresh();
1556}

References mEnabled, mThumbBitmap, mThumbBitmapHilited, and Refresh().

Here is the call graph for this function:

◆ SetId()

void LWSlider::SetId ( wxWindowID  id)

Definition at line 604 of file ASlider.cpp.

605{
606 mID = id;
607}
int id

References id, and mID.

◆ SetParent()

void LWSlider::SetParent ( wxWindow *  parent)
inline

Definition at line 150 of file ASlider.h.

150{ mParent = parent; }

◆ SetPopWinPosition()

void LWSlider::SetPopWinPosition ( )
private

Definition at line 923 of file ASlider.cpp.

924{
925 if (mTipPanel)
926 {
927 wxSize sz = mTipPanel->GetSize();
928 wxPoint pt;
929
930 if (mOrientation == wxHORIZONTAL)
931 {
932 pt.x = mLeft + ((mWidth - sz.x) / 2);
933 pt.y = mTop + mHeight + 1;
934 }
935 else
936 {
937 pt.x = mLeft + mWidth + 1;
938 pt.y = mTop + ((mHeight - sz.y) / 2);
939 }
940
941 mTipPanel->SetPos(mParent->ClientToScreen(pt));
942 }
943}

References mHeight, mLeft, mOrientation, mParent, mTipPanel, mTop, and mWidth.

Referenced by ShowTip().

Here is the caller graph for this function:

◆ SetScroll()

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

Definition at line 626 of file ASlider.cpp.

627{
628 mScrollLine = line;
629 mScrollPage = page;
630}

References mScrollLine, and mScrollPage.

◆ SetSpeed()

void LWSlider::SetSpeed ( float  speed)

Definition at line 1376 of file ASlider.cpp.

1377{
1378 mSpeed = speed;
1379}

References mSpeed.

◆ SetToolTipTemplate()

void LWSlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 884 of file ASlider.cpp.

885{
886 mTipTemplate = tip;
887}

References mTipTemplate.

◆ ShowDialog() [1/2]

bool LWSlider::ShowDialog ( )

Definition at line 1068 of file ASlider.cpp.

1069{
1070 return DoShowDialog( mParent->ClientToScreen(wxPoint( mLeft, mTop ) ) );
1071}

References DoShowDialog(), mLeft, mParent, and mTop.

Referenced by TrackActions::Handler::OnTrackGain(), and TrackActions::Handler::OnTrackPan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowDialog() [2/2]

bool LWSlider::ShowDialog ( wxPoint  pos)

Definition at line 1073 of file ASlider.cpp.

1074{
1075 return DoShowDialog( pos );
1076}

References DoShowDialog().

Here is the call graph for this function:

◆ ShowTip()

void LWSlider::ShowTip ( bool  show)

Definition at line 889 of file ASlider.cpp.

890{
891 if (show)
892 {
893 if (mTipPanel)
894 {
895 if (mTipPanel->IsShownOnScreen())
896 {
897 return;
898 }
899
900 mTipPanel.reset();
901 }
902
903 CreatePopWin();
904 FormatPopWin();
906 mTipPanel->ShowWithoutActivating();
907 }
908 else
909 {
910 if (mTipPanel)
911 {
912 mTipPanel->Hide();
913 mTipPanel.reset();
914 }
915 }
916}
void CreatePopWin()
Definition: ASlider.cpp:918
void SetPopWinPosition()
Definition: ASlider.cpp:923

References CreatePopWin(), FormatPopWin(), mTipPanel, and SetPopWinPosition().

Referenced by OnMouseEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ValueToPosition()

int LWSlider::ValueToPosition ( float  val)
private

Definition at line 1366 of file ASlider.cpp.

1367{
1368 float fRange = mMaxValue - mMinValue;
1369 if (mOrientation == wxHORIZONTAL)
1370 return (int)rint((val - mMinValue) * mWidthX / fRange);
1371 else
1372 // low values at bottom
1373 return (int)rint((mMaxValue - val) * mHeightY / fRange);
1374}

References mHeightY, mMaxValue, mMinValue, mOrientation, and mWidthX.

Referenced by OnMouseEvent(), and OnPaint().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ASlider

friend class ASlider
friend

Definition at line 63 of file ASlider.h.

◆ ASliderAx

friend class ASliderAx
friend

Definition at line 64 of file ASlider.h.

Member Data Documentation

◆ mBitmap

std::unique_ptr<wxBitmap> LWSlider::mBitmap
private

Definition at line 226 of file ASlider.h.

Referenced by AdjustSize(), DrawToBitmap(), Init(), OnPaint(), and Redraw().

◆ mBottomY

int LWSlider::mBottomY
private

Definition at line 194 of file ASlider.h.

Referenced by AdjustSize(), ClickPositionToValue(), and DrawToBitmap().

◆ mCanUseShift

bool LWSlider::mCanUseShift
private

Definition at line 217 of file ASlider.h.

Referenced by ClickPositionToValue(), DragPositionToValue(), and Init().

◆ mCenterX

int LWSlider::mCenterX
private

Definition at line 191 of file ASlider.h.

Referenced by AdjustSize(), DrawToBitmap(), OnMouseEvent(), and OnPaint().

◆ mCenterY

int LWSlider::mCenterY
private

Definition at line 184 of file ASlider.h.

Referenced by AdjustSize(), DrawToBitmap(), OnMouseEvent(), and OnPaint().

◆ mClickPos

int LWSlider::mClickPos
private

Definition at line 202 of file ASlider.h.

Referenced by DragPositionToValue(), and OnMouseEvent().

◆ mClickValue

float LWSlider::mClickValue
private

Definition at line 201 of file ASlider.h.

Referenced by DragPositionToValue(), and OnMouseEvent().

◆ mCurrentValue

float LWSlider::mCurrentValue
private

◆ mDefaultShortcut

bool LWSlider::mDefaultShortcut
private

Definition at line 214 of file ASlider.h.

Referenced by Init(), OnMouseEvent(), and SetDefaultShortcut().

◆ mDefaultValue

float LWSlider::mDefaultValue
private

Definition at line 215 of file ASlider.h.

Referenced by Init(), OnMouseEvent(), and SetDefaultValue().

◆ mEnabled

bool LWSlider::mEnabled
private

Definition at line 230 of file ASlider.h.

Referenced by GetEnabled(), Init(), OnKeyDown(), OnMouseEvent(), and SetEnabled().

◆ mHeight

int LWSlider::mHeight
private

Definition at line 181 of file ASlider.h.

Referenced by AdjustSize(), DoShowDialog(), DrawToBitmap(), and SetPopWinPosition().

◆ mHeightY

int LWSlider::mHeightY
private

◆ mHW

bool LWSlider::mHW
private

Definition at line 174 of file ASlider.h.

Referenced by DrawToBitmap(), Init(), OnPaint(), and Refresh().

◆ mID

wxWindowID LWSlider::mID
private

Definition at line 219 of file ASlider.h.

Referenced by GetId(), Init(), SendUpdate(), and SetId().

◆ mIsDragging

bool LWSlider::mIsDragging
private

Definition at line 224 of file ASlider.h.

Referenced by Init(), OnMouseEvent(), and Set().

◆ mLeft

int LWSlider::mLeft
private

◆ mLeftX

int LWSlider::mLeftX
private

Definition at line 186 of file ASlider.h.

Referenced by AdjustSize(), and DrawToBitmap().

◆ mMaxValue

float LWSlider::mMaxValue
private

◆ mMinValue

float LWSlider::mMinValue
private

◆ mName

TranslatableString LWSlider::mName
private

Definition at line 228 of file ASlider.h.

Referenced by DoShowDialog(), GetTip(), and Init().

◆ mOrientation

int LWSlider::mOrientation
private

◆ mParent

wxWindow* LWSlider::mParent
private

◆ mPopup

bool LWSlider::mPopup
private

Definition at line 175 of file ASlider.h.

Referenced by Init(), and OnMouseEvent().

◆ mRightX

int LWSlider::mRightX
private

Definition at line 187 of file ASlider.h.

Referenced by AdjustSize(), and DrawToBitmap().

◆ mScrollLine

float LWSlider::mScrollLine
private

Definition at line 209 of file ASlider.h.

Referenced by DoShowDialog(), GetScroll(), Init(), OnKeyDown(), and SetScroll().

◆ mScrollPage

float LWSlider::mScrollPage
private

Definition at line 210 of file ASlider.h.

Referenced by DoShowDialog(), GetScroll(), Init(), OnKeyDown(), and SetScroll().

◆ mSpeed

float LWSlider::mSpeed
private

Definition at line 207 of file ASlider.h.

Referenced by DragPositionToValue(), Init(), and SetSpeed().

◆ mStepValue

float LWSlider::mStepValue
private

Definition at line 206 of file ASlider.h.

Referenced by ClickPositionToValue(), Decrease(), DragPositionToValue(), Increase(), and Init().

◆ mStyle

int LWSlider::mStyle
private

Definition at line 171 of file ASlider.h.

Referenced by DoShowDialog(), DrawToBitmap(), Get(), GetTip(), GetWidestTips(), Init(), and Set().

◆ mThumbBitmap

std::unique_ptr<wxBitmap> LWSlider::mThumbBitmap
private

Definition at line 226 of file ASlider.h.

Referenced by DrawToBitmap(), Init(), OnPaint(), Redraw(), and SetEnabled().

◆ mThumbBitmapHilited

std::unique_ptr<wxBitmap> LWSlider::mThumbBitmapHilited
private

Definition at line 226 of file ASlider.h.

Referenced by DrawToBitmap(), Init(), OnPaint(), Redraw(), and SetEnabled().

◆ mThumbHeight

int LWSlider::mThumbHeight
private

Definition at line 199 of file ASlider.h.

Referenced by AdjustSize(), OnMouseEvent(), and OnPaint().

◆ mThumbWidth

int LWSlider::mThumbWidth
private

Definition at line 198 of file ASlider.h.

Referenced by AdjustSize(), ClickPositionToValue(), OnMouseEvent(), and OnPaint().

◆ mTipPanel

std::unique_ptr<TipWindow> LWSlider::mTipPanel
private

◆ mTipTemplate

TranslatableString LWSlider::mTipTemplate
private

Definition at line 222 of file ASlider.h.

Referenced by GetTip(), GetWidestTips(), and SetToolTipTemplate().

◆ mTop

int LWSlider::mTop
private

Definition at line 178 of file ASlider.h.

Referenced by Move(), OnMouseEvent(), OnPaint(), SetPopWinPosition(), and ShowDialog().

◆ mTopY

int LWSlider::mTopY
private

Definition at line 193 of file ASlider.h.

Referenced by AdjustSize(), and DrawToBitmap().

◆ mWidth

int LWSlider::mWidth
private

Definition at line 180 of file ASlider.h.

Referenced by AdjustSize(), DoShowDialog(), DrawToBitmap(), and SetPopWinPosition().

◆ mWidthX

int LWSlider::mWidthX
private

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