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 showlabels=true, bool drawticks=true, bool drawtrack=true, bool alwayshidetip=false, bool heavyweight=false, bool popup=true, int orientation=wxHORIZONTAL)
 
 LWSlider (wxWindow *parent, const TranslatableString &name, const wxPoint &pos, const wxSize &size, int style, bool showlabels=true, bool drawticks=true, bool drawtrack=true, bool alwayshidetip=false, 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 showlabels, bool drawticks, bool drawtrack, bool alwayshidetip, bool heavyweight, bool popup, float speed, int orientation=wxHORIZONTAL)
 
virtual ~LWSlider ()
 
wxWindowID GetId ()
 
void SetId (wxWindowID id)
 
void SetName (const TranslatableString &name)
 
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)
 
wxString GetStringValue () const
 
void OnKillFocus ()
 

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 mShowLabels
 
bool mDrawTicks
 
bool mDrawTrack
 
bool mAlwaysHideTip
 
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
 
wxWeakRef< 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 63 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  showlabels = true,
bool  drawticks = true,
bool  drawtrack = true,
bool  alwayshidetip = false,
bool  heavyweight = false,
bool  popup = true,
int  orientation = wxHORIZONTAL 
)

Definition at line 479 of file ASlider.cpp.

495{
496 Init(parent, name, pos, size, minValue, maxValue, stepValue,
497 canUseShift, style, showlabels, drawticks, drawtrack,
498 alwayshidetip, heavyweight, popup, 1.0, orientation);
499}
const TranslatableString name
Definition: Distortion.cpp:76
void Init(wxWindow *parent, const TranslatableString &name, const wxPoint &pos, const wxSize &size, float minValue, float maxValue, float stepValue, bool canUseShift, int style, bool showlabels, bool drawticks, bool drawtrack, bool alwayshidetip, bool heavyweight, bool popup, float speed, int orientation=wxHORIZONTAL)
Definition: ASlider.cpp:566

References Init(), name, size, and anonymous_namespace{AudacityDontAskAgainMessageDialog.cpp}::style.

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  showlabels = true,
bool  drawticks = true,
bool  drawtrack = true,
bool  alwayshidetip = false,
bool  heavyweight = false,
bool  popup = true,
int  orientation = wxHORIZONTAL 
)

Definition at line 502 of file ASlider.cpp.

514{
515 wxString leftLabel, rightLabel;
516
517 float minValue, maxValue, stepValue;
518 float speed = 1.0;
519
520 switch(style)
521 {
522 case PAN_SLIDER:
523 minValue = -1.0f;
524 maxValue = +1.0f;
525 stepValue = 0.1f;
526 orientation = wxHORIZONTAL; //v Vertical PAN_SLIDER currently not handled, forced to horizontal.
527 break;
528 case DB_SLIDER:
529 minValue = -36.0f;
530 //if (orientation == wxHORIZONTAL)
531 maxValue = 36.0f;
532 //else
533 //maxValue = 36.0f; // for MixerBoard //v Previously was 6dB for MixerBoard, but identical for now.
534 stepValue = 1.0f;
535 speed = 0.5;
536 break;
537 case FRAC_SLIDER:
538 case PERCENT_SLIDER:
539 minValue = 0.0f;
540 maxValue = 1.0f;
541 stepValue = STEP_CONTINUOUS;
542 break;
543 case SPEED_SLIDER:
544 minValue = 0.01f;
545 maxValue = 3.000f;
546 stepValue = STEP_CONTINUOUS;
547 break;
548 case VEL_SLIDER:
549 minValue = VEL_MIN;
550 maxValue = VEL_MAX;
551 stepValue = 1.0f;
552 speed = 0.5;
553 break;
554 default:
555 minValue = 0.0f;
556 maxValue = 1.0f;
557 stepValue = 0.0f;
558 wxASSERT(false); // undefined style
559 }
560
561 Init(parent, name, pos, size, minValue, maxValue, stepValue,
562 true, style, showlabels, drawticks, drawtrack, alwayshidetip,
563 heavyweight, popup, speed, orientation);
564}
#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:54
#define PERCENT_SLIDER
Definition: ASlider.h:39
#define SPEED_SLIDER
Definition: ASlider.h:35
#define PAN_SLIDER
Definition: ASlider.h:34
#define VEL_MAX
Definition: ASlider.h:48
#define VEL_MIN
Definition: ASlider.h:47

References DB_SLIDER, FRAC_SLIDER, Init(), name, PAN_SLIDER, PERCENT_SLIDER, size, SPEED_SLIDER, STEP_CONTINUOUS, anonymous_namespace{AudacityDontAskAgainMessageDialog.cpp}::style, VEL_MAX, VEL_MIN, and VEL_SLIDER.

Here is the call graph for this function:

◆ ~LWSlider()

LWSlider::~LWSlider ( )
virtual

Definition at line 618 of file ASlider.cpp.

619{
620}

Member Function Documentation

◆ AdjustSize()

void LWSlider::AdjustSize ( const wxSize &  sz)

Definition at line 672 of file ASlider.cpp.

673{
674 mWidth = sz.GetWidth();
675 mHeight = sz.GetHeight();
676
677 if( mBitmap ){
678 mBitmap.reset();
679 }
680 mThumbWidth = 11;
681 mThumbHeight = 20;
682
683 if (mShowLabels || mDrawTicks)
684 {
685 if (mOrientation == wxHORIZONTAL)
686 {
687 mCenterY = mHeight - 9;
688 }
689 else
690 {
691 mCenterX = mWidth - 9;
692 }
693 }
694 else
695 {
696 if (mOrientation == wxHORIZONTAL)
697 {
698 mCenterY = mHeight / 2;
699 }
700 else
701 {
702 mCenterX = mWidth / 2;
703 }
704 }
705
706 if (mOrientation == wxHORIZONTAL)
707 {
709 mRightX = mWidth - mThumbWidth/2 - 1;
711 }
712 else
713 {
714 mTopY = mThumbWidth/2;
715 mBottomY = mHeight - mThumbWidth/2 - 1;
717 }
718
719 Refresh();
720}
int mCenterX
Definition: ASlider.h:217
int mThumbWidth
Definition: ASlider.h:224
int mHeightY
Definition: ASlider.h:221
bool mShowLabels
Definition: ASlider.h:194
void Refresh()
Definition: ASlider.cpp:1621
int mTopY
Definition: ASlider.h:219
int mBottomY
Definition: ASlider.h:220
int mLeftX
Definition: ASlider.h:212
int mCenterY
Definition: ASlider.h:210
int mHeight
Definition: ASlider.h:207
std::unique_ptr< wxBitmap > mBitmap
Definition: ASlider.h:252
int mRightX
Definition: ASlider.h:213
int mOrientation
Definition: ASlider.h:192
bool mDrawTicks
Definition: ASlider.h:195
int mWidth
Definition: ASlider.h:206
int mWidthX
Definition: ASlider.h:214
int mThumbHeight
Definition: ASlider.h:225

References mBitmap, mBottomY, mCenterX, mCenterY, mDrawTicks, mHeight, mHeightY, mLeftX, mOrientation, mRightX, mShowLabels, 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 1476 of file ASlider.cpp.

1477{
1478 int nSpan;
1479 int pos;
1480 if (mOrientation == wxHORIZONTAL)
1481 {
1482 pos = (fromPos - mLeft - (mThumbWidth / 2));
1483 nSpan = mWidthX;
1484 }
1485 else
1486 {
1487 // wxVERTICAL => Low values at bottom.
1488 pos = mBottomY - fromPos;
1489 nSpan = mHeightY;
1490 }
1491
1492 // MM: Special cases: If position is at the very left or the
1493 // very right (or top/bottom for wxVERTICAL), set minimum/maximum value without other checks
1494 if (pos <= 0)
1495 return mMinValue;
1496 if (pos >= nSpan)
1497 return mMaxValue;
1498
1499 float val = (pos / (float)nSpan)
1501
1502 if (val < mMinValue)
1503 val = mMinValue;
1504 if (val > mMaxValue)
1505 val = mMaxValue;
1506
1507 if (!(mCanUseShift && shiftDown) && mStepValue != STEP_CONTINUOUS)
1508 {
1509 // MM: If shift is not down, or we don't allow usage
1510 // of shift key at all, trim value to steps of
1511 // provided size.
1512 val = (int)(val / mStepValue + 0.5 * (val>0?1.0f:-1.0f)) * mStepValue;
1513 }
1514
1515 return val;
1516}
int mLeft
Definition: ASlider.h:203
float mMinValue
Definition: ASlider.h:230
bool mCanUseShift
Definition: ASlider.h:243
float mMaxValue
Definition: ASlider.h:231
float mStepValue
Definition: ASlider.h:232

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

959{
960 if(mTipPanel || mAlwaysHideTip || mParent == nullptr)
961 return;
962
964 mTipPanel->Hide();
965}
#define safenew
Definition: MemoryX.h:10
bool mAlwaysHideTip
Definition: ASlider.h:198
TranslatableStrings GetWidestTips() const
Definition: ASlider.cpp:1071
wxWindow * mParent
Definition: ASlider.h:189
wxWeakRef< TipWindow > mTipPanel
Definition: ASlider.h:247
A wxPopupWindow used to give the numerical value of an LWSlider or ASlider.
Definition: ASlider.cpp:147

References GetWidestTips(), mAlwaysHideTip, mParent, mTipPanel, and safenew.

Referenced by Init(), SetName(), and SetParent().

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

1599{
1600 float stepValue = mStepValue;
1601
1602 if ( stepValue == 0.0 )
1603 {
1604 stepValue = ( mMaxValue - mMinValue ) / 10.0;
1605 }
1606
1607 mCurrentValue -= ( steps * stepValue );
1608
1609 if ( mCurrentValue < mMinValue )
1610 {
1612 }
1613 else if ( mCurrentValue > mMaxValue )
1614 {
1616 }
1617
1618 Refresh();
1619}
float mCurrentValue
Definition: ASlider.h:238

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

Referenced by OnKeyDown(), OnMouseEvent(), anonymous_namespace{TrackMenus.cpp}::OnTrackGainDec(), and anonymous_namespace{TrackMenus.cpp}::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 1129 of file ASlider.cpp.

1130{
1131 float value = mCurrentValue;
1132 bool changed = false;
1133
1134 SliderDialog dlg( NULL,
1135 wxID_ANY,
1136 mName,
1137 pos,
1138 // Bug 2087. wxMin takes care of case where
1139 // slider is vertical (tall and narrow)
1140 wxSize( mWidth, wxMin( mWidth, mHeight) ),
1141 mStyle,
1142 Get(),
1145 this);
1146 if (pos == wxPoint(-1, -1)) {
1147 dlg.Center();
1148 }
1149
1150 changed = (dlg.ShowModal() == wxID_OK);
1151 if( changed )
1152 value = dlg.Get();
1153
1154 // We now expect the pop up dialog to be
1155 // sending updates as we go.
1156 // So this code is needed to possibly restore the old
1157 // value, on a cancel.
1158 if (mCurrentValue != value) {
1159 mCurrentValue = value;
1160 SendUpdate(value);
1161 }
1162
1163 return changed;
1164}
TranslatableString mName
Definition: ASlider.h:254
float Get(bool convert=true)
Definition: ASlider.cpp:1550
int mStyle
Definition: ASlider.h:191
void SendUpdate(float newValue)
Definition: ASlider.cpp:1409
float mScrollPage
Definition: ASlider.h:236
float mScrollLine
Definition: ASlider.h:235
Pop up dialog used with an LWSlider.
Definition: ASlider.h:368

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

1521{
1522 int delta = (fromPos - mClickPos);
1523
1524 float speed = mSpeed;
1525 // Precision enhancement for Shift drags
1526 if (mCanUseShift && shiftDown)
1527 speed *= 0.4f;
1528
1529 // wxVERTICAL => Low values at bottom, so throw in the minus sign here with -mHeightY.
1530 float denominator = (mOrientation == wxHORIZONTAL) ? mWidthX : -mHeightY;
1531 float val = mClickValue +
1532 speed * (delta / denominator) * (mMaxValue - mMinValue);
1533
1534 if (val < mMinValue)
1535 val = mMinValue;
1536 if (val > mMaxValue)
1537 val = mMaxValue;
1538
1539 if (!(mCanUseShift && shiftDown) && mStepValue != STEP_CONTINUOUS)
1540 {
1541 // MM: If shift is not down, or we don't allow usage
1542 // of shift key at all, and the slider has not continuous values,
1543 // trim value to steps of provided size.
1544 val = (int)(val / mStepValue + 0.5 * (val>0?1.0f:-1.0f)) * mStepValue;
1545 }
1546
1547 return val;
1548}
float mClickValue
Definition: ASlider.h:227
float mSpeed
Definition: ASlider.h:233
int mClickPos
Definition: ASlider.h:228

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

778{
779 // Get correctly oriented thumb.
780 if (mOrientation == wxVERTICAL){
781 mThumbBitmap = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbRotated )));
782 mThumbBitmapHilited = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbRotatedHilited )));
783 }
784 else {
785 mThumbBitmap = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumb )));
786 mThumbBitmapHilited = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbHilited )));
787 }
788
789 // Now the background bitmap
790 mBitmap = std::make_unique<wxBitmap>();
791 mBitmap->Create(mWidth, mHeight, paintDC);
792
793#if defined(__WXMAC__)
794 mBitmap->UseAlpha();
795#endif
796
797 // Set up the memory DC
798 // We draw to it, not the paintDC.
799 wxMemoryDC dc;
800 dc.SelectObject(*mBitmap);
801
802 dc.SetBackground(wxBrush(mParent->GetBackgroundColour()));
803 dc.Clear();
804
805 // Draw the line along which the thumb moves.
806 AColor::UseThemeColour(&dc, clrSliderMain );
807
808 if (mDrawTrack)
809 {
810 if (mOrientation == wxHORIZONTAL)
811 {
814 }
815 else
816 {
819 }
820 }
821
822 if (mShowLabels)
823 {
824 // Draw +/- or L/R first. We need to draw these before the tick marks.
825 if (mStyle == PAN_SLIDER)
826 {
827 //VJ Vertical PAN_SLIDER currently not handled, forced to horizontal.
828
829 // sliderFontSize is for the tooltip.
830 // we need something smaller here...
831 wxFont labelFont(7, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
832 dc.SetFont(labelFont);
833
834 // Color
835 dc.SetTextForeground(theTheme.Colour(clrTrackPanelText));
836
837 /* i18n-hint: One-letter abbreviation for Left, in the Pan slider */
838 dc.DrawText(_("L"), mLeftX, 0);
839
840 /* i18n-hint: One-letter abbreviation for Right, in the Pan slider */
841 dc.DrawText(_("R"), mRightX - dc.GetTextExtent(_("R")).GetWidth(), 0);
842 }
843 else
844 {
845 // draw the '-' and the '+'
846 // These are drawn with lines, rather tha nwith a font.
847 AColor::UseThemeColour(&dc, clrTrackPanelText);
848
849 if (mOrientation == wxHORIZONTAL)
850 {
852 AColor::Line(dc, mRightX-5, mCenterY-10, mRightX-1, mCenterY-10);
854 }
855 else
856 {
857 // Vertical DB_SLIDER is for gain slider in MixerBoard.
858 // We use a Ruler instead of marks & ticks.
859 // Draw '+' and '-' only for other vertical sliders.
860 if (mStyle != DB_SLIDER)
861 {
863 AColor::Line(dc, mCenterX-12, mTopY+3, mCenterX-8, mTopY+3);
864 AColor::Line(dc, mCenterX-10, mTopY, mCenterX-10, mTopY+5);
865 }
866 }
867 }
868 }
869
870 // Use special colour to indicate no ticks.
871 wxColour TickColour = theTheme.Colour( clrSliderLight );
872 bool bTicks = TickColour != wxColour(60,60,60);
873
874 if( mDrawTicks && bTicks ) {
875 // tick marks
876 int divs = 10;
877 double upp;
878 if (mOrientation == wxHORIZONTAL)
879 {
880 // Bug #2446 - A bit of a hack, but it should suffice.
881 divs = (mWidth - 1) / 10;
882 upp = divs / (double)(mWidthX-1);
883 }
884 else
885 {
886 if (mStyle == DB_SLIDER)
887 divs = mMaxValue - mMinValue + 1;
888 upp = divs / (double)(mHeightY-1);
889 }
890#ifdef OPTIONAL_SLIDER_TICKS
891 double d = 0.0;
892 int int_d = -1;
893 const int kMax = (mOrientation == wxHORIZONTAL) ? mWidthX : mHeightY;
894 for(int p = 0; p <= kMax; p++)
895 {
896 if (((int)d) > int_d)
897 {
898 int_d = (int)d;
899 int tickLength = ((int_d == 0) || (int_d == divs)) ? 5: 3; // longer ticks at extremes
900 AColor::UseThemeColour(&dc, clrSliderLight );
901
902 if (mOrientation == wxHORIZONTAL)
903 {
904 AColor::Line(dc, mLeftX+p, mCenterY-tickLength, mLeftX+p, mCenterY-1); // ticks above
905 }
906 else
907 {
908 AColor::Line(dc, mCenterX-tickLength, mTopY+p, mCenterX-1, mTopY+p); // ticks at left
909 }
910
911 AColor::UseThemeColour(&dc, clrSliderDark );
912
913 if (mOrientation == wxHORIZONTAL)
914 {
915 AColor::Line(dc, mLeftX+p+1, mCenterY-tickLength+1, mLeftX+p+1, mCenterY-1); // ticks above
916 }
917 else
918 {
919 AColor::Line(dc, mCenterX-tickLength+1, mTopY+p+1, mCenterX-1, mTopY+p+1); // ticks at left
920 }
921 }
922 d += upp;
923 }
924#endif
925 }
926
927 dc.SelectObject(wxNullBitmap);
928
929 // safenew, because SetMask takes ownership
930 // We always mask. If we are HeavyWeight, the ASlider draws the
931 // background.
932 if( !mHW )
933 {
934 mBitmap->SetMask(safenew wxMask(*mBitmap, dc.GetBackground().GetColour()));
935 }
936}
#define _(s)
Definition: Internat.h:73
THEME_API Theme theTheme
Definition: Theme.cpp:82
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:194
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1, int alpha=255)
Definition: AColor.cpp:354
std::unique_ptr< wxBitmap > mThumbBitmap
Definition: ASlider.h:252
std::unique_ptr< wxBitmap > mThumbBitmapHilited
Definition: ASlider.h:252
bool mHW
Definition: ASlider.h:200
bool mDrawTrack
Definition: ASlider.h:196
wxColour & Colour(int iIndex)
wxBitmap & Bitmap(int iIndex)

References _, ThemeBase::Bitmap(), ThemeBase::Colour(), DB_SLIDER, AColor::Line(), mBitmap, mBottomY, mCenterX, mCenterY, mDrawTicks, mDrawTrack, mHeight, mHeightY, mHW, mLeftX, mMaxValue, mMinValue, mOrientation, mParent, mRightX, mShowLabels, 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 989 of file ASlider.cpp.

990{
991 if (!mTipPanel)
992 {
993 return;
994 }
995
996 mTipPanel->SetLabel(GetTip(mCurrentValue));
997 mTipPanel->Refresh();
998}
TranslatableString GetTip(float value) const
Definition: ASlider.cpp:1000

References GetTip(), mCurrentValue, and mTipPanel.

Referenced by SendUpdate().

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

1551{
1552 if (mStyle == DB_SLIDER)
1553 return (convert ? DB_TO_LINEAR(mCurrentValue) : mCurrentValue);
1554 else
1555 return mCurrentValue;
1556}
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:338

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

1637{
1638 return mEnabled;
1639}
bool mEnabled
Definition: ASlider.h:256

References mEnabled.

◆ GetId()

wxWindowID LWSlider::GetId ( )

Definition at line 622 of file ASlider.cpp.

623{
624 return mID;
625}
wxWindowID mID
Definition: ASlider.h:245

References mID.

◆ GetMaxValue()

float LWSlider::GetMaxValue ( ) const

Definition at line 1656 of file ASlider.cpp.

1657{
1658 return mMaxValue;
1659}

References mMaxValue.

◆ GetMinValue()

float LWSlider::GetMinValue ( ) const

Definition at line 1651 of file ASlider.cpp.

1652{
1653 return mMinValue;
1654}

References mMinValue.

◆ GetScroll()

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

Definition at line 654 of file ASlider.cpp.

655{
656 line = mScrollLine;
657 page = mScrollPage;
658}

References mScrollLine, and mScrollPage.

◆ GetStringValue()

wxString LWSlider::GetStringValue ( ) const

Definition at line 1432 of file ASlider.cpp.

1433{
1434 switch(mStyle)
1435 {
1436 case FRAC_SLIDER:
1437 return wxString::Format(wxT("%.0f"), mCurrentValue * 100);
1438 case PERCENT_SLIDER:
1439 return wxString::Format(wxT("%.0f%%"), mCurrentValue * 100.0f);
1440 case DB_SLIDER:
1441 return wxString::Format(wxT("%.0f"), mCurrentValue);
1442 case PAN_SLIDER:
1443 return wxString::Format(wxT("%.0f"), mCurrentValue * 100);
1444 case SPEED_SLIDER:
1445 return wxString::Format(wxT("%.0f"), mCurrentValue * 100 );
1446 case VEL_SLIDER:
1447 return wxString::Format(wxT("%.0f"), mCurrentValue);
1448 default:
1449 return {};
1450 }
1451}
wxT("CloseDown"))

References DB_SLIDER, FRAC_SLIDER, mCurrentValue, mStyle, PAN_SLIDER, PERCENT_SLIDER, SPEED_SLIDER, VEL_SLIDER, and wxT().

Here is the call graph for this function:

◆ GetTip()

TranslatableString LWSlider::GetTip ( float  value) const
private

Definition at line 1000 of file ASlider.cpp.

1001{
1003
1004 if (mTipTemplate.empty())
1005 {
1007
1008 switch(mStyle)
1009 {
1010 case FRAC_SLIDER:
1011 val = Verbatim("%.2f").Format( value );
1012 break;
1013 case PERCENT_SLIDER:
1014 val = Verbatim("%.0f%%").Format(value * 100.0f);
1015 break;
1016
1017 case DB_SLIDER:
1018 /* i18n-hint dB abbreviates decibels */
1019 val = XO("%+.1f dB").Format( value );
1020 break;
1021
1022 case PAN_SLIDER:
1023 if (value == 0.0)
1024 {
1025 val = XO("Center");
1026 }
1027 else
1028 {
1029 const auto v = 100.0f * fabsf(value);
1030 if (value < 0.0)
1031 /* i18n-hint: Stereo pan setting */
1032 val = XO("%.0f%% Left").Format( v );
1033 else
1034 /* i18n-hint: Stereo pan setting */
1035 val = XO("%.0f%% Right").Format( v );
1036 }
1037 break;
1038
1039 case SPEED_SLIDER:
1040 /* i18n-hint: "x" suggests a multiplicative factor */
1041 val = XO("%.3fx").Format( value );
1042 break;
1043
1044 case VEL_SLIDER:
1045 if (value > 0.0f)
1046 // Signed
1047 val = Verbatim("%+d").Format( (int) value );
1048 else
1049 // Zero, or signed negative
1050 val = Verbatim("%d").Format( (int) value );
1051 break;
1052 }
1053
1054 if(!mName.empty())
1055 {
1056 /* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
1057 label = XO("%s: %s").Format( mName, val );
1058 }
1059 else
1060 label = val;
1061 }
1062 else
1063 {
1065 label.Format( value );
1066 }
1067
1068 return label;
1069}
XO("Cut/Copy/Paste")
TranslatableString label
Definition: TagsEditor.cpp:165
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
TranslatableString mTipTemplate
Definition: ASlider.h:248
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, PERCENT_SLIDER, SPEED_SLIDER, VEL_SLIDER, Verbatim(), and XO().

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

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

1072{
1073 TranslatableStrings results;
1074
1075 if (mTipTemplate.empty())
1076 {
1077 wxString val;
1078
1079 switch(mStyle)
1080 {
1081 case FRAC_SLIDER:
1082 results.push_back( GetTip( -1.99f ) );
1083 results.push_back( GetTip( +1.99f ) );
1084 break;
1085
1086 case PERCENT_SLIDER:
1087 results.push_back(GetTip(1.0f));
1088
1089 case DB_SLIDER:
1090 results.push_back( GetTip( -99.9f ) );
1091 results.push_back( GetTip( +99.9f ) );
1092 break;
1093
1094 case PAN_SLIDER:
1095 // Don't assume we know which of "Left", "Right", or "Center"
1096 // is the longest string, when localized
1097 results.push_back( GetTip( 0.f ) );
1098 results.push_back( GetTip( +1.f ) );
1099 results.push_back( GetTip( -1.f ) );
1100 break;
1101
1102 case SPEED_SLIDER:
1103 results.push_back( GetTip( 9.99f ) );
1104 break;
1105
1106 case VEL_SLIDER:
1107 results.push_back( GetTip( 999.f ) );
1108 break;
1109 }
1110 }
1111 else
1112 {
1113 results.push_back( GetTip( floor(mMaxValue - mMinValue) + 0.999 ) );
1114 }
1115
1116 return results;
1117}
std::vector< TranslatableString > TranslatableStrings

References DB_SLIDER, TranslatableString::empty(), FRAC_SLIDER, GetTip(), mMaxValue, mMinValue, mStyle, mTipTemplate, PAN_SLIDER, PERCENT_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 1575 of file ASlider.cpp.

1576{
1577 float stepValue = mStepValue;
1578
1579 if ( stepValue == 0.0 )
1580 {
1581 stepValue = ( mMaxValue - mMinValue ) / 10.0;
1582 }
1583
1584 mCurrentValue += ( steps * stepValue );
1585
1586 if ( mCurrentValue < mMinValue )
1587 {
1589 }
1590 else if ( mCurrentValue > mMaxValue )
1591 {
1593 }
1594
1595 Refresh();
1596}

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

Referenced by OnKeyDown(), OnMouseEvent(), anonymous_namespace{TrackMenus.cpp}::OnTrackGainInc(), and anonymous_namespace{TrackMenus.cpp}::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  showlabels,
bool  drawticks,
bool  drawtrack,
bool  alwayshidetip,
bool  heavyweight,
bool  popup,
float  speed,
int  orientation = wxHORIZONTAL 
)

Definition at line 566 of file ASlider.cpp.

583{
584 mEnabled = true;
585 mName = name;
586 mStyle = style;
587 mOrientation = orientation;
588 mIsDragging = false;
589 mParent = parent;
590 mShowLabels = showlabels;
591 mDrawTicks = drawticks;
592 mDrawTrack = drawtrack;
593 mAlwaysHideTip = alwayshidetip;
594 mHW = heavyweight;
595 mPopup = popup;
596 mSpeed = speed;
597 mID = wxID_ANY;
598 mMinValue = minValue;
599 mMaxValue = maxValue;
600 mStepValue = stepValue;
601 mCanUseShift = canUseShift;
602 mCurrentValue = 0.0f;
603 mDefaultValue = 0.0f;
604 mDefaultShortcut = false;
605 mBitmap = nullptr;
606 mThumbBitmap = nullptr;
607 mThumbBitmapHilited = nullptr;
608 mScrollLine = 1.0f;
609 mScrollPage = 5.0f;
610
612
613 Move(pos);
614
615 CreatePopWin();
616}
float mDefaultValue
Definition: ASlider.h:241
bool mPopup
Definition: ASlider.h:201
void CreatePopWin()
Definition: ASlider.cpp:958
void AdjustSize(const wxSize &sz)
Definition: ASlider.cpp:672
bool mIsDragging
Definition: ASlider.h:250
bool mDefaultShortcut
Definition: ASlider.h:240
void Move(const wxPoint &newpos)
Definition: ASlider.cpp:666

References AdjustSize(), CreatePopWin(), mAlwaysHideTip, mBitmap, mCanUseShift, mCurrentValue, mDefaultShortcut, mDefaultValue, mDrawTicks, mDrawTrack, mEnabled, mHW, mID, mIsDragging, mMaxValue, mMinValue, mName, mOrientation, Move(), mParent, mPopup, mScrollLine, mScrollPage, mShowLabels, mSpeed, mStepValue, mStyle, mThumbBitmap, mThumbBitmapHilited, name, size, and anonymous_namespace{AudacityDontAskAgainMessageDialog.cpp}::style.

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

667{
668 mLeft = newpos.x;
669 mTop = newpos.y;
670}
int mTop
Definition: ASlider.h:204

References mLeft, and mTop.

Referenced by Init().

Here is the caller graph for this function:

◆ OnKeyDown()

void LWSlider::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1327 of file ASlider.cpp.

1328{
1329 if (mEnabled)
1330 {
1331 switch( event.GetKeyCode() )
1332 {
1333 case WXK_TAB:
1334 mParent->Navigate(event.ShiftDown()
1335 ? wxNavigationKeyEvent::IsBackward
1336 : wxNavigationKeyEvent::IsForward);
1337 break;
1338
1339 case WXK_RIGHT:
1340 case WXK_UP:
1343 ShowTip(true);
1344 break;
1345
1346 case WXK_LEFT:
1347 case WXK_DOWN:
1350 ShowTip(true);
1351 break;
1352
1353 case WXK_PAGEUP:
1356 ShowTip(true);
1357 break;
1358
1359 case WXK_PAGEDOWN:
1362 ShowTip(true);
1363 break;
1364
1365 case WXK_HOME:
1367 ShowTip(true);
1368 break;
1369
1370 case WXK_END:
1372 ShowTip(true);
1373 break;
1374
1375 case WXK_RETURN:
1376 case WXK_NUMPAD_ENTER:
1377 {
1378 wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(mParent), wxTopLevelWindow);
1379 wxWindow *def = tlw->GetDefaultItem();
1380 if (def && def->IsEnabled()) {
1381 wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
1382 def->GetId());
1383 cevent.SetEventObject( def );
1384 mParent->GetEventHandler()->ProcessEvent(cevent);
1385 }
1386 }
1387
1388 default:
1389 // Allow it to propagate
1390 event.Skip();
1391 break;
1392 }
1393 }
1394 else
1395 {
1396 event.Skip();
1397 }
1398}
wxEVT_COMMAND_BUTTON_CLICKED
void ShowTip(bool show)
Definition: ASlider.cpp:943
void Decrease(float steps)
Definition: ASlider.cpp:1598
void Increase(float steps)
Definition: ASlider.cpp:1575

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

Here is the call graph for this function:

◆ OnKillFocus()

void LWSlider::OnKillFocus ( )

Definition at line 1453 of file ASlider.cpp.

1454{
1455 ShowTip(false);
1456}

References ShowTip().

Here is the call graph for this function:

◆ OnMouseEvent()

void LWSlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1166 of file ASlider.cpp.

1167{
1168 if (event.Entering())
1169 {
1170 // Display the tooltip in the status bar
1171 auto tip = GetTip(mCurrentValue);
1172 auto pProject = FindProjectFromWindow( mParent );
1173 if (pProject)
1174 ProjectStatus::Get( *pProject ).Set( tip );
1175 Refresh();
1176 }
1177 else if (event.Leaving())
1178 {
1179 if (!mIsDragging)
1180 {
1181 ShowTip(false);
1182 }
1183 auto pProject = FindProjectFromWindow( mParent );
1184 if (pProject)
1185 ProjectStatus::Get( *pProject ).Set({});
1186 Refresh();
1187 }
1188
1189 // Events other than mouse-overs are ignored when we are disabled
1190 if (!mEnabled)
1191 return;
1192
1193 // Windows sends a right button mouse event when you press the context menu
1194 // key, so ignore it.
1195 if ((event.RightDown() && !event.RightIsDown()) ||
1196 (event.RightUp() && event.GetPosition() == wxPoint(-1, -1)))
1197 {
1198 event.Skip(false);
1199 return;
1200 }
1201
1202 float prevValue = mCurrentValue;
1203
1204 // Figure out the thumb position
1205 wxRect r;
1206 if (mOrientation == wxHORIZONTAL)
1207 {
1209 r.y = mTop + (mCenterY - (mThumbHeight / 2));
1210 }
1211 else
1212 {
1213 r.x = mLeft + (mCenterX - (mThumbWidth / 2));
1215 }
1216 r.width = mThumbWidth;
1217 r.height = mThumbHeight;
1218
1219 wxRect tolerantThumbRect = r;
1220 tolerantThumbRect.Inflate(3, 3);
1221
1222 // Should probably use a right click instead/also
1223 if( event.ButtonDClick() && mPopup )
1224 {
1225 //On a double-click, we should pop up a dialog.
1226 DoShowDialog(mParent->ClientToScreen(wxPoint(event.m_x,event.m_y)));
1227 }
1228 else if( event.ButtonDown() )
1229 {
1230 if( mDefaultShortcut && event.ControlDown() )
1231 {
1233 }
1234
1235 if( event.RightDown() ) {
1236 mParent->SetFocus();
1237 }
1238
1239 // Thumb clicked?
1240 //
1241 // Do not change position until first drag. This helps
1242 // with unintended value changes.
1243 if( tolerantThumbRect.Contains( event.GetPosition() ) )
1244 {
1245 // Remember mouse position and current value
1246 mClickPos = (mOrientation == wxHORIZONTAL) ? event.m_x : event.m_y;
1248
1249 mIsDragging = true;
1250 }
1251 // Clicked to set location?
1252 else
1253 {
1256 (mOrientation == wxHORIZONTAL) ? event.m_x : event.m_y,
1257 event.ShiftDown());
1258 }
1259
1260 if (!mParent->HasCapture()) {
1261 mParent->CaptureMouse();
1262 }
1263
1264 ShowTip(true);
1265 }
1266 else if( event.ButtonUp() )
1267 {
1268 mIsDragging = false;
1269 if (mParent->HasCapture())
1270 mParent->ReleaseMouse();
1271
1272 ShowTip(false);
1273 }
1274 else if (event.Dragging() && mIsDragging)
1275 {
1276 if (mOrientation == wxHORIZONTAL)
1277 {
1278 if (event.m_y < (r.y - 2 * r.height) ||
1279 event.m_y > (r.y + 3 * r.height)) {
1280 // If the mouse y coordinate is relatively far from the slider,
1281 // snap back to the original position
1283 }
1284 else {
1285 // Otherwise, move the slider to the right position based
1286 // on the mouse position
1287 mCurrentValue = DragPositionToValue(event.m_x, event.ShiftDown());
1288 }
1289 }
1290 else // (mOrientation == wxVERTICAL)
1291 {
1292 if (event.m_x < (r.x - 2 * r.width) ||
1293 event.m_x > (r.x + 3 * r.width)) {
1294 // If the mouse x coordinate is relatively far from the slider,
1295 // snap back to the original position
1297 }
1298 else {
1299 // Otherwise, move the slider to the right position based
1300 // on the mouse position
1301 mCurrentValue = DragPositionToValue(event.m_y, event.ShiftDown());
1302 }
1303 }
1304 }
1305 else if( event.m_wheelRotation != 0 )
1306 {
1307 //Calculate the number of steps in a given direction this event
1308 //represents (allows for two or more clicks on a single event.)
1309 double steps = event.m_wheelRotation /
1310 (event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);
1311
1312 if( steps < 0.0 )
1313 {
1314 Decrease( (float)-steps );
1315 }
1316 else
1317 {
1318 Increase( (float)steps );
1319 }
1321 }
1322
1323 if( prevValue != mCurrentValue )
1325}
AudacityProject * FindProjectFromWindow(wxWindow *pWindow)
int ValueToPosition(float val)
Definition: ASlider.cpp:1459
float DragPositionToValue(int fromPos, bool shiftDown)
Definition: ASlider.cpp:1520
bool DoShowDialog(wxPoint pos)
Definition: ASlider.cpp:1129
float ClickPositionToValue(int fromPos, bool shiftDown)
Definition: ASlider.cpp:1476
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 722 of file ASlider.cpp.

723{
724 // The dc will be a paint DC
726 {
727 DrawToBitmap(dc);
728 }
729
730 //thumbPos should be in pixels
731 int thumbPos = ValueToPosition(mCurrentValue);
732 int thumbOrtho; // position in axis orthogonal to mOrientation
733 if (mOrientation == wxHORIZONTAL){
734 thumbOrtho = mCenterY - (mThumbHeight/2);
735 thumbPos += 1-mThumbWidth/2;
736 }
737 else{
738 thumbOrtho = mCenterX - (mThumbWidth/2);
739 thumbPos += 8-mThumbHeight/2;
740 }
741
742 // Draw the background.
743 // If we are lightweight, this has already been done for us.
744 if( mHW ){
745 dc.SetBackground( *wxTRANSPARENT_BRUSH );
746 dc.Clear();
747 }
748
749 dc.DrawBitmap(*mBitmap, mLeft, mTop, true);
750 const auto &thumbBitmap =
751 highlight ? *mThumbBitmapHilited : *mThumbBitmap;
752 if (mOrientation == wxHORIZONTAL)
753 {
754 dc.DrawBitmap(thumbBitmap, mLeft+thumbPos, mTop+thumbOrtho, true);
755 }
756 else
757 {
758 // TODO: Don't use pixel-count hack in positioning.
759 dc.DrawBitmap(thumbBitmap, mLeft+thumbOrtho-5, mTop+thumbPos, true);
760 }
761
762 if (mTipPanel)
763 {
764 mTipPanel->Update();
765 }
766}
void DrawToBitmap(wxDC &dc)
Definition: ASlider.cpp:777

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

769{
770 AdjustSize(event.GetSize());
771
772 Refresh();
773}

References AdjustSize(), and Refresh().

Here is the call graph for this function:

◆ Redraw()

void LWSlider::Redraw ( )

Definition at line 1627 of file ASlider.cpp.

1628{
1629 mBitmap.reset();
1630 mThumbBitmap.reset();
1631 mThumbBitmapHilited.reset();
1632
1633 Refresh();
1634}

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

Here is the call graph for this function:

◆ Refresh()

void LWSlider::Refresh ( )

Definition at line 1621 of file ASlider.cpp.

1622{
1623 if (mHW)
1624 mParent->Refresh(false);
1625}

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

1410{
1411 mCurrentValue = newValue;
1412
1413 FormatPopWin();
1414
1415 Refresh();
1416
1417 // Update the project's status bar as well
1418 if (mTipPanel) {
1419 auto tip = GetTip(mCurrentValue);
1420 auto pProject = FindProjectFromWindow( mParent );
1421 if (pProject)
1422 ProjectStatus::Get( *pProject ).Set( tip );
1423 }
1424
1425 wxCommandEvent e( wxEVT_COMMAND_SLIDER_UPDATED, mID );
1426 int intValue = (int)( ( mCurrentValue - mMinValue ) * 1000.0f /
1427 ( mMaxValue - mMinValue ) );
1428 e.SetInt( intValue );
1429 mParent->GetEventHandler()->ProcessEvent(e);
1430}
void FormatPopWin()
Definition: ASlider.cpp:989

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

1559{
1560 if (mIsDragging)
1561 return;
1562 if (mStyle == DB_SLIDER)
1563 mCurrentValue = LINEAR_TO_DB(value);
1564 else
1565 mCurrentValue = value;
1566
1571
1572 Refresh();
1573}
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:339

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

650{
651 mDefaultShortcut = value;
652}

References mDefaultShortcut.

Referenced by SetDefaultValue().

Here is the caller graph for this function:

◆ SetDefaultValue()

void LWSlider::SetDefaultValue ( float  value)

Definition at line 643 of file ASlider.cpp.

644{
645 SetDefaultShortcut(true);
646 mDefaultValue = value;
647}
void SetDefaultShortcut(bool value)
Definition: ASlider.cpp:649

References mDefaultValue, and SetDefaultShortcut().

Here is the call graph for this function:

◆ SetEnabled()

void LWSlider::SetEnabled ( bool  enabled)

Definition at line 1641 of file ASlider.cpp.

1642{
1643 mEnabled = enabled;
1644
1645 mThumbBitmap.reset();
1646 mThumbBitmapHilited.reset();
1647
1648 Refresh();
1649}

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

Here is the call graph for this function:

◆ SetId()

void LWSlider::SetId ( wxWindowID  id)

Definition at line 627 of file ASlider.cpp.

628{
629 mID = id;
630}
int id

References id, and mID.

◆ SetName()

void LWSlider::SetName ( const TranslatableString name)

Definition at line 632 of file ASlider.cpp.

633{
634 mName = name;
635 if(mTipPanel)
636 {
637 mTipPanel->Destroy();
638 mTipPanel = nullptr;
639 }
640 CreatePopWin();
641}

References CreatePopWin(), mName, mTipPanel, and name.

Here is the call graph for this function:

◆ SetParent()

void LWSlider::SetParent ( wxWindow *  parent)

Definition at line 1400 of file ASlider.cpp.

1401{
1402 mParent = parent;
1403 //VS: create pop win if there is no one, don't re-parent
1404 //as it seem to be a workaround for DC drawing purposes
1405 //(see `WaveTrackControls::GainSlider`)
1406 CreatePopWin();
1407}

References CreatePopWin(), and mParent.

Here is the call graph for this function:

◆ SetPopWinPosition()

void LWSlider::SetPopWinPosition ( )
private

Definition at line 967 of file ASlider.cpp.

968{
969 if (mTipPanel)
970 {
971 wxSize sz = mTipPanel->GetSize();
972 wxPoint pt;
973
974 if (mOrientation == wxHORIZONTAL)
975 {
976 pt.x = mLeft + ((mWidth - sz.x) / 2);
977 pt.y = mTop + mHeight + 1;
978 }
979 else
980 {
981 pt.x = mLeft + mWidth + 1;
982 pt.y = mTop + ((mHeight - sz.y) / 2);
983 }
984
985 mTipPanel->SetPos(mParent->ClientToScreen(pt));
986 }
987}

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

661{
662 mScrollLine = line;
663 mScrollPage = page;
664}

References mScrollLine, and mScrollPage.

◆ SetSpeed()

void LWSlider::SetSpeed ( float  speed)

Definition at line 1469 of file ASlider.cpp.

1470{
1471 mSpeed = speed;
1472}

References mSpeed.

◆ SetToolTipTemplate()

void LWSlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 938 of file ASlider.cpp.

939{
940 mTipTemplate = tip;
941}

References mTipTemplate.

◆ ShowDialog() [1/2]

bool LWSlider::ShowDialog ( )

Definition at line 1119 of file ASlider.cpp.

1120{
1121 return DoShowDialog( mParent->ClientToScreen(wxPoint( mLeft, mTop ) ) );
1122}

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

Referenced by anonymous_namespace{TrackMenus.cpp}::OnTrackGain(), and anonymous_namespace{TrackMenus.cpp}::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 1124 of file ASlider.cpp.

1125{
1126 return DoShowDialog( pos );
1127}

References DoShowDialog().

Here is the call graph for this function:

◆ ShowTip()

void LWSlider::ShowTip ( bool  show)

Definition at line 943 of file ASlider.cpp.

944{
945 if(!mTipPanel)
946 return;
947
948 if(show)
949 {
950 mTipPanel->SetLabel(GetTip(mCurrentValue));
952 mTipPanel->ShowWithoutActivating();
953 }
954 else
955 mTipPanel->Hide();
956}
void SetPopWinPosition()
Definition: ASlider.cpp:967

References GetTip(), mCurrentValue, mTipPanel, and SetPopWinPosition().

Referenced by OnKeyDown(), OnKillFocus(), and 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 1459 of file ASlider.cpp.

1460{
1461 float fRange = mMaxValue - mMinValue;
1462 if (mOrientation == wxHORIZONTAL)
1463 return (int)rint((val - mMinValue) * mWidthX / fRange);
1464 else
1465 // low values at bottom
1466 return (int)rint((mMaxValue - val) * mHeightY / fRange);
1467}
__finl float __vecc rint(float a)

References mHeightY, mMaxValue, mMinValue, mOrientation, mWidthX, and staffpad::audio::simd::rint().

Referenced by OnMouseEvent(), and OnPaint().

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

Friends And Related Function Documentation

◆ ASlider

friend class ASlider
friend

Definition at line 65 of file ASlider.h.

◆ ASliderAx

friend class ASliderAx
friend

Definition at line 66 of file ASlider.h.

Member Data Documentation

◆ mAlwaysHideTip

bool LWSlider::mAlwaysHideTip
private

Definition at line 198 of file ASlider.h.

Referenced by CreatePopWin(), and Init().

◆ mBitmap

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

Definition at line 252 of file ASlider.h.

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

◆ mBottomY

int LWSlider::mBottomY
private

Definition at line 220 of file ASlider.h.

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

◆ mCanUseShift

bool LWSlider::mCanUseShift
private

Definition at line 243 of file ASlider.h.

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

◆ mCenterX

int LWSlider::mCenterX
private

Definition at line 217 of file ASlider.h.

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

◆ mCenterY

int LWSlider::mCenterY
private

Definition at line 210 of file ASlider.h.

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

◆ mClickPos

int LWSlider::mClickPos
private

Definition at line 228 of file ASlider.h.

Referenced by DragPositionToValue(), and OnMouseEvent().

◆ mClickValue

float LWSlider::mClickValue
private

Definition at line 227 of file ASlider.h.

Referenced by DragPositionToValue(), and OnMouseEvent().

◆ mCurrentValue

float LWSlider::mCurrentValue
private

◆ mDefaultShortcut

bool LWSlider::mDefaultShortcut
private

Definition at line 240 of file ASlider.h.

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

◆ mDefaultValue

float LWSlider::mDefaultValue
private

Definition at line 241 of file ASlider.h.

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

◆ mDrawTicks

bool LWSlider::mDrawTicks
private

Definition at line 195 of file ASlider.h.

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

◆ mDrawTrack

bool LWSlider::mDrawTrack
private

Definition at line 196 of file ASlider.h.

Referenced by DrawToBitmap(), and Init().

◆ mEnabled

bool LWSlider::mEnabled
private

Definition at line 256 of file ASlider.h.

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

◆ mHeight

int LWSlider::mHeight
private

Definition at line 207 of file ASlider.h.

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

◆ mHeightY

int LWSlider::mHeightY
private

◆ mHW

bool LWSlider::mHW
private

Definition at line 200 of file ASlider.h.

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

◆ mID

wxWindowID LWSlider::mID
private

Definition at line 245 of file ASlider.h.

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

◆ mIsDragging

bool LWSlider::mIsDragging
private

Definition at line 250 of file ASlider.h.

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

◆ mLeft

int LWSlider::mLeft
private

◆ mLeftX

int LWSlider::mLeftX
private

Definition at line 212 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 254 of file ASlider.h.

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

◆ mOrientation

int LWSlider::mOrientation
private

◆ mParent

wxWindow* LWSlider::mParent
private

◆ mPopup

bool LWSlider::mPopup
private

Definition at line 201 of file ASlider.h.

Referenced by Init(), and OnMouseEvent().

◆ mRightX

int LWSlider::mRightX
private

Definition at line 213 of file ASlider.h.

Referenced by AdjustSize(), and DrawToBitmap().

◆ mScrollLine

float LWSlider::mScrollLine
private

Definition at line 235 of file ASlider.h.

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

◆ mScrollPage

float LWSlider::mScrollPage
private

Definition at line 236 of file ASlider.h.

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

◆ mShowLabels

bool LWSlider::mShowLabels
private

Definition at line 194 of file ASlider.h.

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

◆ mSpeed

float LWSlider::mSpeed
private

Definition at line 233 of file ASlider.h.

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

◆ mStepValue

float LWSlider::mStepValue
private

Definition at line 232 of file ASlider.h.

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

◆ mStyle

int LWSlider::mStyle
private

Definition at line 191 of file ASlider.h.

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

◆ mThumbBitmap

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

Definition at line 252 of file ASlider.h.

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

◆ mThumbBitmapHilited

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

Definition at line 252 of file ASlider.h.

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

◆ mThumbHeight

int LWSlider::mThumbHeight
private

Definition at line 225 of file ASlider.h.

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

◆ mThumbWidth

int LWSlider::mThumbWidth
private

Definition at line 224 of file ASlider.h.

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

◆ mTipPanel

wxWeakRef<TipWindow> LWSlider::mTipPanel
private

◆ mTipTemplate

TranslatableString LWSlider::mTipTemplate
private

Definition at line 248 of file ASlider.h.

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

◆ mTop

int LWSlider::mTop
private

Definition at line 204 of file ASlider.h.

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

◆ mTopY

int LWSlider::mTopY
private

Definition at line 219 of file ASlider.h.

Referenced by AdjustSize(), and DrawToBitmap().

◆ mWidth

int LWSlider::mWidth
private

Definition at line 206 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: