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

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

References Init(), name, and size.

Here is the call graph for this function:

◆ LWSlider() [2/2]

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

Definition at line 499 of file ASlider.cpp.

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

Here is the call graph for this function:

◆ ~LWSlider()

LWSlider::~LWSlider ( )
virtual

Definition at line 617 of file ASlider.cpp.

618{
619}

Member Function Documentation

◆ AdjustSize()

void LWSlider::AdjustSize ( const wxSize &  sz)

Definition at line 671 of file ASlider.cpp.

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

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

958{
959 if(mTipPanel || mAlwaysHideTip || mParent == nullptr)
960 return;
961
963 mTipPanel->Hide();
964}
#define safenew
Definition: MemoryX.h:10
bool mAlwaysHideTip
Definition: ASlider.h:198
TranslatableStrings GetWidestTips() const
Definition: ASlider.cpp:1072
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:149

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

1604{
1605 float stepValue = mStepValue;
1606
1607 if ( stepValue == 0.0 )
1608 {
1609 stepValue = ( mMaxValue - mMinValue ) / 10.0;
1610 }
1611
1612 mCurrentValue -= ( steps * stepValue );
1613
1614 if ( mCurrentValue < mMinValue )
1615 {
1617 }
1618 else if ( mCurrentValue > mMaxValue )
1619 {
1621 }
1622
1623 Refresh();
1624}
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 1132 of file ASlider.cpp.

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

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

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

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

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

1556{
1557 if (mStyle == DB_SLIDER)
1558 return (convert ? DB_TO_LINEAR(mCurrentValue) : mCurrentValue);
1559 else
1560 return mCurrentValue;
1561}
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:561

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

1642{
1643 return mEnabled;
1644}
bool mEnabled
Definition: ASlider.h:256

References mEnabled.

◆ GetId()

wxWindowID LWSlider::GetId ( )

Definition at line 621 of file ASlider.cpp.

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

References mID.

◆ GetMaxValue()

float LWSlider::GetMaxValue ( ) const

Definition at line 1661 of file ASlider.cpp.

1662{
1663 return mMaxValue;
1664}

References mMaxValue.

◆ GetMinValue()

float LWSlider::GetMinValue ( ) const

Definition at line 1656 of file ASlider.cpp.

1657{
1658 return mMinValue;
1659}

References mMinValue.

◆ GetScroll()

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

Definition at line 653 of file ASlider.cpp.

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

References mScrollLine, and mScrollPage.

◆ GetStringValue()

wxString LWSlider::GetStringValue ( ) const

Definition at line 1435 of file ASlider.cpp.

1436{
1437 switch(mStyle)
1438 {
1439 case FRAC_SLIDER:
1440 return wxString::Format(wxT("%.0f"), mCurrentValue * 100);
1441 case PERCENT_SLIDER:
1442 return wxString::Format(wxT("%.0f%%"), mCurrentValue * 100.0f);
1443 case DB_SLIDER:
1444 return wxString::Format(wxT("%.0f"), mCurrentValue);
1445 case PAN_SLIDER:
1446 return wxString::Format(wxT("%.0f"), mCurrentValue * 100);
1447 case SPEED_SLIDER:
1448 return wxString::Format(wxT("%.0f"), mCurrentValue * 100 );
1449#ifdef EXPERIMENTAL_MIDI_OUT
1450 case VEL_SLIDER:
1451 return wxString::Format(wxT("%.0f"), mCurrentValue);
1452#endif
1453 default:
1454 return {};
1455 }
1456}
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 999 of file ASlider.cpp.

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

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

1581{
1582 float stepValue = mStepValue;
1583
1584 if ( stepValue == 0.0 )
1585 {
1586 stepValue = ( mMaxValue - mMinValue ) / 10.0;
1587 }
1588
1589 mCurrentValue += ( steps * stepValue );
1590
1591 if ( mCurrentValue < mMinValue )
1592 {
1594 }
1595 else if ( mCurrentValue > mMaxValue )
1596 {
1598 }
1599
1600 Refresh();
1601}

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

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

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, and size.

Referenced by LWSlider().

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

◆ Move()

void LWSlider::Move ( const wxPoint &  newpos)

Definition at line 665 of file ASlider.cpp.

666{
667 mLeft = newpos.x;
668 mTop = newpos.y;
669}
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 1330 of file ASlider.cpp.

1331{
1332 if (mEnabled)
1333 {
1334 switch( event.GetKeyCode() )
1335 {
1336 case WXK_TAB:
1337 mParent->Navigate(event.ShiftDown()
1338 ? wxNavigationKeyEvent::IsBackward
1339 : wxNavigationKeyEvent::IsForward);
1340 break;
1341
1342 case WXK_RIGHT:
1343 case WXK_UP:
1346 ShowTip(true);
1347 break;
1348
1349 case WXK_LEFT:
1350 case WXK_DOWN:
1353 ShowTip(true);
1354 break;
1355
1356 case WXK_PAGEUP:
1359 ShowTip(true);
1360 break;
1361
1362 case WXK_PAGEDOWN:
1365 ShowTip(true);
1366 break;
1367
1368 case WXK_HOME:
1370 ShowTip(true);
1371 break;
1372
1373 case WXK_END:
1375 ShowTip(true);
1376 break;
1377
1378 case WXK_RETURN:
1379 case WXK_NUMPAD_ENTER:
1380 {
1381 wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(mParent), wxTopLevelWindow);
1382 wxWindow *def = tlw->GetDefaultItem();
1383 if (def && def->IsEnabled()) {
1384 wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
1385 def->GetId());
1386 cevent.SetEventObject( def );
1387 mParent->GetEventHandler()->ProcessEvent(cevent);
1388 }
1389 }
1390
1391 default:
1392 // Allow it to propagate
1393 event.Skip();
1394 break;
1395 }
1396 }
1397 else
1398 {
1399 event.Skip();
1400 }
1401}
wxEVT_COMMAND_BUTTON_CLICKED
void ShowTip(bool show)
Definition: ASlider.cpp:942
void Decrease(float steps)
Definition: ASlider.cpp:1603
void Increase(float steps)
Definition: ASlider.cpp:1580

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

1459{
1460 ShowTip(false);
1461}

References ShowTip().

Here is the call graph for this function:

◆ OnMouseEvent()

void LWSlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1169 of file ASlider.cpp.

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

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

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

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

References AdjustSize(), and Refresh().

Here is the call graph for this function:

◆ Redraw()

void LWSlider::Redraw ( )

Definition at line 1632 of file ASlider.cpp.

1633{
1634 mBitmap.reset();
1635 mThumbBitmap.reset();
1636 mThumbBitmapHilited.reset();
1637
1638 Refresh();
1639}

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

Here is the call graph for this function:

◆ Refresh()

void LWSlider::Refresh ( )

Definition at line 1626 of file ASlider.cpp.

1627{
1628 if (mHW)
1629 mParent->Refresh(false);
1630}

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

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

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

1564{
1565 if (mIsDragging)
1566 return;
1567 if (mStyle == DB_SLIDER)
1568 mCurrentValue = LINEAR_TO_DB(value);
1569 else
1570 mCurrentValue = value;
1571
1576
1577 Refresh();
1578}
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:562

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

649{
650 mDefaultShortcut = value;
651}

References mDefaultShortcut.

Referenced by SetDefaultValue().

Here is the caller graph for this function:

◆ SetDefaultValue()

void LWSlider::SetDefaultValue ( float  value)

Definition at line 642 of file ASlider.cpp.

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

References mDefaultValue, and SetDefaultShortcut().

Here is the call graph for this function:

◆ SetEnabled()

void LWSlider::SetEnabled ( bool  enabled)

Definition at line 1646 of file ASlider.cpp.

1647{
1648 mEnabled = enabled;
1649
1650 mThumbBitmap.reset();
1651 mThumbBitmapHilited.reset();
1652
1653 Refresh();
1654}

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

Here is the call graph for this function:

◆ SetId()

void LWSlider::SetId ( wxWindowID  id)

Definition at line 626 of file ASlider.cpp.

627{
628 mID = id;
629}
int id

References id, and mID.

◆ SetName()

void LWSlider::SetName ( const TranslatableString name)

Definition at line 631 of file ASlider.cpp.

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

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

Here is the call graph for this function:

◆ SetParent()

void LWSlider::SetParent ( wxWindow *  parent)

Definition at line 1403 of file ASlider.cpp.

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

References CreatePopWin(), and mParent.

Here is the call graph for this function:

◆ SetPopWinPosition()

void LWSlider::SetPopWinPosition ( )
private

Definition at line 966 of file ASlider.cpp.

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

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

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

References mScrollLine, and mScrollPage.

◆ SetSpeed()

void LWSlider::SetSpeed ( float  speed)

Definition at line 1474 of file ASlider.cpp.

1475{
1476 mSpeed = speed;
1477}

References mSpeed.

◆ SetToolTipTemplate()

void LWSlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 937 of file ASlider.cpp.

938{
939 mTipTemplate = tip;
940}

References mTipTemplate.

◆ ShowDialog() [1/2]

bool LWSlider::ShowDialog ( )

Definition at line 1122 of file ASlider.cpp.

1123{
1124 return DoShowDialog( mParent->ClientToScreen(wxPoint( mLeft, mTop ) ) );
1125}

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

1128{
1129 return DoShowDialog( pos );
1130}

References DoShowDialog().

Here is the call graph for this function:

◆ ShowTip()

void LWSlider::ShowTip ( bool  show)

Definition at line 942 of file ASlider.cpp.

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

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

1465{
1466 float fRange = mMaxValue - mMinValue;
1467 if (mOrientation == wxHORIZONTAL)
1468 return (int)rint((val - mMinValue) * mWidthX / fRange);
1469 else
1470 // low values at bottom
1471 return (int)rint((mMaxValue - val) * mHeightY / fRange);
1472}
__finl float_x4 __vecc rint(const float_x4 &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: