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

490{
491 Init(parent, name, pos, size, minValue, maxValue, stepValue,
492 canUseShift, style, showlabels, drawticks, drawtrack,
493 alwayshidetip, heavyweight, popup, 1.0, orientation);
494}
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:561

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

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

614{
615}

Member Function Documentation

◆ AdjustSize()

void LWSlider::AdjustSize ( const wxSize &  sz)

Definition at line 667 of file ASlider.cpp.

668{
669 mWidth = sz.GetWidth();
670 mHeight = sz.GetHeight();
671
672 if( mBitmap ){
673 mBitmap.reset();
674 }
675 mThumbWidth = 11;
676 mThumbHeight = 20;
677
678 if (mShowLabels || mDrawTicks)
679 {
680 if (mOrientation == wxHORIZONTAL)
681 {
682 mCenterY = mHeight - 9;
683 }
684 else
685 {
686 mCenterX = mWidth - 9;
687 }
688 }
689 else
690 {
691 if (mOrientation == wxHORIZONTAL)
692 {
693 mCenterY = mHeight / 2;
694 }
695 else
696 {
697 mCenterX = mWidth / 2;
698 }
699 }
700
701 if (mOrientation == wxHORIZONTAL)
702 {
704 mRightX = mWidth - mThumbWidth/2 - 1;
706 }
707 else
708 {
709 mTopY = mThumbWidth/2;
710 mBottomY = mHeight - mThumbWidth/2 - 1;
712 }
713
714 Refresh();
715}
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:1616
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 1471 of file ASlider.cpp.

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

954{
955 if(mTipPanel || mAlwaysHideTip || mParent == nullptr)
956 return;
957
959 mTipPanel->Hide();
960}
#define safenew
Definition: MemoryX.h:9
bool mAlwaysHideTip
Definition: ASlider.h:198
TranslatableStrings GetWidestTips() const
Definition: ASlider.cpp:1066
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 1593 of file ASlider.cpp.

1594{
1595 float stepValue = mStepValue;
1596
1597 if ( stepValue == 0.0 )
1598 {
1599 stepValue = ( mMaxValue - mMinValue ) / 10.0;
1600 }
1601
1602 mCurrentValue -= ( steps * stepValue );
1603
1604 if ( mCurrentValue < mMinValue )
1605 {
1607 }
1608 else if ( mCurrentValue > mMaxValue )
1609 {
1611 }
1612
1613 Refresh();
1614}
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 1124 of file ASlider.cpp.

1125{
1126 float value = mCurrentValue;
1127 bool changed = false;
1128
1129 SliderDialog dlg( NULL,
1130 wxID_ANY,
1131 mName,
1132 pos,
1133 // Bug 2087. wxMin takes care of case where
1134 // slider is vertical (tall and narrow)
1135 wxSize( mWidth, wxMin( mWidth, mHeight) ),
1136 mStyle,
1137 Get(),
1140 this);
1141 if (pos == wxPoint(-1, -1)) {
1142 dlg.Center();
1143 }
1144
1145 changed = (dlg.ShowModal() == wxID_OK);
1146 if( changed )
1147 value = dlg.Get();
1148
1149 // We now expect the pop up dialog to be
1150 // sending updates as we go.
1151 // So this code is needed to possibly restore the old
1152 // value, on a cancel.
1153 if (mCurrentValue != value) {
1154 mCurrentValue = value;
1155 SendUpdate(value);
1156 }
1157
1158 return changed;
1159}
TranslatableString mName
Definition: ASlider.h:254
float Get(bool convert=true)
Definition: ASlider.cpp:1545
int mStyle
Definition: ASlider.h:191
void SendUpdate(float newValue)
Definition: ASlider.cpp:1404
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 1515 of file ASlider.cpp.

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

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

985{
986 if (!mTipPanel)
987 {
988 return;
989 }
990
991 mTipPanel->SetLabel(GetTip(mCurrentValue));
992 mTipPanel->Refresh();
993}
TranslatableString GetTip(float value) const
Definition: ASlider.cpp:995

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

1546{
1547 if (mStyle == DB_SLIDER)
1548 return (convert ? DB_TO_LINEAR(mCurrentValue) : mCurrentValue);
1549 else
1550 return mCurrentValue;
1551}
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:337

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

1632{
1633 return mEnabled;
1634}
bool mEnabled
Definition: ASlider.h:256

References mEnabled.

◆ GetId()

wxWindowID LWSlider::GetId ( )

Definition at line 617 of file ASlider.cpp.

618{
619 return mID;
620}
wxWindowID mID
Definition: ASlider.h:245

References mID.

◆ GetMaxValue()

float LWSlider::GetMaxValue ( ) const

Definition at line 1651 of file ASlider.cpp.

1652{
1653 return mMaxValue;
1654}

References mMaxValue.

◆ GetMinValue()

float LWSlider::GetMinValue ( ) const

Definition at line 1646 of file ASlider.cpp.

1647{
1648 return mMinValue;
1649}

References mMinValue.

◆ GetScroll()

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

Definition at line 649 of file ASlider.cpp.

650{
651 line = mScrollLine;
652 page = mScrollPage;
653}

References mScrollLine, and mScrollPage.

◆ GetStringValue()

wxString LWSlider::GetStringValue ( ) const

Definition at line 1427 of file ASlider.cpp.

1428{
1429 switch(mStyle)
1430 {
1431 case FRAC_SLIDER:
1432 return wxString::Format(wxT("%.0f"), mCurrentValue * 100);
1433 case PERCENT_SLIDER:
1434 return wxString::Format(wxT("%.0f%%"), mCurrentValue * 100.0f);
1435 case DB_SLIDER:
1436 return wxString::Format(wxT("%.0f"), mCurrentValue);
1437 case PAN_SLIDER:
1438 return wxString::Format(wxT("%.0f"), mCurrentValue * 100);
1439 case SPEED_SLIDER:
1440 return wxString::Format(wxT("%.0f"), mCurrentValue * 100 );
1441 case VEL_SLIDER:
1442 return wxString::Format(wxT("%.0f"), mCurrentValue);
1443 default:
1444 return {};
1445 }
1446}
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 995 of file ASlider.cpp.

996{
998
999 if (mTipTemplate.empty())
1000 {
1002
1003 switch(mStyle)
1004 {
1005 case FRAC_SLIDER:
1006 val = Verbatim("%.2f").Format( value );
1007 break;
1008 case PERCENT_SLIDER:
1009 val = Verbatim("%.0f%%").Format(value * 100.0f);
1010 break;
1011
1012 case DB_SLIDER:
1013 /* i18n-hint dB abbreviates decibels */
1014 val = XO("%+.1f dB").Format( value );
1015 break;
1016
1017 case PAN_SLIDER:
1018 if (value == 0.0)
1019 {
1020 val = XO("Center");
1021 }
1022 else
1023 {
1024 const auto v = 100.0f * fabsf(value);
1025 if (value < 0.0)
1026 /* i18n-hint: Stereo pan setting */
1027 val = XO("%.0f%% Left").Format( v );
1028 else
1029 /* i18n-hint: Stereo pan setting */
1030 val = XO("%.0f%% Right").Format( v );
1031 }
1032 break;
1033
1034 case SPEED_SLIDER:
1035 /* i18n-hint: "x" suggests a multiplicative factor */
1036 val = XO("%.2fx").Format( value );
1037 break;
1038
1039 case VEL_SLIDER:
1040 if (value > 0.0f)
1041 // Signed
1042 val = Verbatim("%+d").Format( (int) value );
1043 else
1044 // Zero, or signed negative
1045 val = Verbatim("%d").Format( (int) value );
1046 break;
1047 }
1048
1049 if(!mName.empty())
1050 {
1051 /* i18n-hint: An item name followed by a value, with appropriate separating punctuation */
1052 label = XO("%s: %s").Format( mName, val );
1053 }
1054 else
1055 label = val;
1056 }
1057 else
1058 {
1060 label.Format( value );
1061 }
1062
1063 return label;
1064}
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 1066 of file ASlider.cpp.

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

1571{
1572 float stepValue = mStepValue;
1573
1574 if ( stepValue == 0.0 )
1575 {
1576 stepValue = ( mMaxValue - mMinValue ) / 10.0;
1577 }
1578
1579 mCurrentValue += ( steps * stepValue );
1580
1581 if ( mCurrentValue < mMinValue )
1582 {
1584 }
1585 else if ( mCurrentValue > mMaxValue )
1586 {
1588 }
1589
1590 Refresh();
1591}

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

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

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

662{
663 mLeft = newpos.x;
664 mTop = newpos.y;
665}
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 1322 of file ASlider.cpp.

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

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

1449{
1450 ShowTip(false);
1451}

References ShowTip().

Here is the call graph for this function:

◆ OnMouseEvent()

void LWSlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1161 of file ASlider.cpp.

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

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

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

764{
765 AdjustSize(event.GetSize());
766
767 Refresh();
768}

References AdjustSize(), and Refresh().

Here is the call graph for this function:

◆ Redraw()

void LWSlider::Redraw ( )

Definition at line 1622 of file ASlider.cpp.

1623{
1624 mBitmap.reset();
1625 mThumbBitmap.reset();
1626 mThumbBitmapHilited.reset();
1627
1628 Refresh();
1629}

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

Here is the call graph for this function:

◆ Refresh()

void LWSlider::Refresh ( )

Definition at line 1616 of file ASlider.cpp.

1617{
1618 if (mHW)
1619 mParent->Refresh(false);
1620}

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

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

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

1554{
1555 if (mIsDragging)
1556 return;
1557 if (mStyle == DB_SLIDER)
1558 mCurrentValue = LINEAR_TO_DB(value);
1559 else
1560 mCurrentValue = value;
1561
1566
1567 Refresh();
1568}
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:338

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

645{
646 mDefaultShortcut = value;
647}

References mDefaultShortcut.

Referenced by SetDefaultValue().

Here is the caller graph for this function:

◆ SetDefaultValue()

void LWSlider::SetDefaultValue ( float  value)

Definition at line 638 of file ASlider.cpp.

639{
640 SetDefaultShortcut(true);
641 mDefaultValue = value;
642}
void SetDefaultShortcut(bool value)
Definition: ASlider.cpp:644

References mDefaultValue, and SetDefaultShortcut().

Here is the call graph for this function:

◆ SetEnabled()

void LWSlider::SetEnabled ( bool  enabled)

Definition at line 1636 of file ASlider.cpp.

1637{
1638 mEnabled = enabled;
1639
1640 mThumbBitmap.reset();
1641 mThumbBitmapHilited.reset();
1642
1643 Refresh();
1644}

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

Here is the call graph for this function:

◆ SetId()

void LWSlider::SetId ( wxWindowID  id)

Definition at line 622 of file ASlider.cpp.

623{
624 mID = id;
625}
int id

References id, and mID.

◆ SetName()

void LWSlider::SetName ( const TranslatableString name)

Definition at line 627 of file ASlider.cpp.

628{
629 mName = name;
630 if(mTipPanel)
631 {
632 mTipPanel->Destroy();
633 mTipPanel = nullptr;
634 }
635 CreatePopWin();
636}

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

Here is the call graph for this function:

◆ SetParent()

void LWSlider::SetParent ( wxWindow *  parent)

Definition at line 1395 of file ASlider.cpp.

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

References CreatePopWin(), and mParent.

Here is the call graph for this function:

◆ SetPopWinPosition()

void LWSlider::SetPopWinPosition ( )
private

Definition at line 962 of file ASlider.cpp.

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

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

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

References mScrollLine, and mScrollPage.

◆ SetSpeed()

void LWSlider::SetSpeed ( float  speed)

Definition at line 1464 of file ASlider.cpp.

1465{
1466 mSpeed = speed;
1467}

References mSpeed.

◆ SetToolTipTemplate()

void LWSlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 933 of file ASlider.cpp.

934{
935 mTipTemplate = tip;
936}

References mTipTemplate.

◆ ShowDialog() [1/2]

bool LWSlider::ShowDialog ( )

Definition at line 1114 of file ASlider.cpp.

1115{
1116 return DoShowDialog( mParent->ClientToScreen(wxPoint( mLeft, mTop ) ) );
1117}

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

1120{
1121 return DoShowDialog( pos );
1122}

References DoShowDialog().

Here is the call graph for this function:

◆ ShowTip()

void LWSlider::ShowTip ( bool  show)

Definition at line 938 of file ASlider.cpp.

939{
940 if(!mTipPanel)
941 return;
942
943 if(show)
944 {
945 mTipPanel->SetLabel(GetTip(mCurrentValue));
947 mTipPanel->ShowWithoutActivating();
948 }
949 else
950 mTipPanel->Hide();
951}
void SetPopWinPosition()
Definition: ASlider.cpp:962

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

1455{
1456 float fRange = mMaxValue - mMinValue;
1457 if (mOrientation == wxHORIZONTAL)
1458 return (int)rint((val - mMinValue) * mWidthX / fRange);
1459 else
1460 // low values at bottom
1461 return (int)rint((mMaxValue - val) * mHeightY / fRange);
1462}
__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: