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:563

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#ifdef EXPERIMENTAL_MIDI_OUT
544 case VEL_SLIDER:
545 minValue = VEL_MIN;
546 maxValue = VEL_MAX;
547 stepValue = 1.0f;
548 speed = 0.5;
549 break;
550#endif
551 default:
552 minValue = 0.0f;
553 maxValue = 1.0f;
554 stepValue = 0.0f;
555 wxASSERT(false); // undefined style
556 }
557
558 Init(parent, name, pos, size, minValue, maxValue, stepValue,
559 true, style, showlabels, drawticks, drawtrack, alwayshidetip,
560 heavyweight, popup, speed, orientation);
561}
#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 615 of file ASlider.cpp.

616{
617}

Member Function Documentation

◆ AdjustSize()

void LWSlider::AdjustSize ( const wxSize &  sz)

Definition at line 669 of file ASlider.cpp.

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

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

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

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

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

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

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

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

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

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

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

1640{
1641 return mEnabled;
1642}
bool mEnabled
Definition: ASlider.h:256

References mEnabled.

◆ GetId()

wxWindowID LWSlider::GetId ( )

Definition at line 619 of file ASlider.cpp.

620{
621 return mID;
622}
wxWindowID mID
Definition: ASlider.h:245

References mID.

◆ GetMaxValue()

float LWSlider::GetMaxValue ( ) const

Definition at line 1659 of file ASlider.cpp.

1660{
1661 return mMaxValue;
1662}

References mMaxValue.

◆ GetMinValue()

float LWSlider::GetMinValue ( ) const

Definition at line 1654 of file ASlider.cpp.

1655{
1656 return mMinValue;
1657}

References mMinValue.

◆ GetScroll()

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

Definition at line 651 of file ASlider.cpp.

652{
653 line = mScrollLine;
654 page = mScrollPage;
655}

References mScrollLine, and mScrollPage.

◆ GetStringValue()

wxString LWSlider::GetStringValue ( ) const

Definition at line 1433 of file ASlider.cpp.

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

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

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

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

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

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

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

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

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

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

1457{
1458 ShowTip(false);
1459}

References ShowTip().

Here is the call graph for this function:

◆ OnMouseEvent()

void LWSlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1167 of file ASlider.cpp.

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

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

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

766{
767 AdjustSize(event.GetSize());
768
769 Refresh();
770}

References AdjustSize(), and Refresh().

Here is the call graph for this function:

◆ Redraw()

void LWSlider::Redraw ( )

Definition at line 1630 of file ASlider.cpp.

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

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

Here is the call graph for this function:

◆ Refresh()

void LWSlider::Refresh ( )

Definition at line 1624 of file ASlider.cpp.

1625{
1626 if (mHW)
1627 mParent->Refresh(false);
1628}

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

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

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

1562{
1563 if (mIsDragging)
1564 return;
1565 if (mStyle == DB_SLIDER)
1566 mCurrentValue = LINEAR_TO_DB(value);
1567 else
1568 mCurrentValue = value;
1569
1574
1575 Refresh();
1576}
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:336

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

647{
648 mDefaultShortcut = value;
649}

References mDefaultShortcut.

Referenced by SetDefaultValue().

Here is the caller graph for this function:

◆ SetDefaultValue()

void LWSlider::SetDefaultValue ( float  value)

Definition at line 640 of file ASlider.cpp.

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

References mDefaultValue, and SetDefaultShortcut().

Here is the call graph for this function:

◆ SetEnabled()

void LWSlider::SetEnabled ( bool  enabled)

Definition at line 1644 of file ASlider.cpp.

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

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

Here is the call graph for this function:

◆ SetId()

void LWSlider::SetId ( wxWindowID  id)

Definition at line 624 of file ASlider.cpp.

625{
626 mID = id;
627}
int id

References id, and mID.

◆ SetName()

void LWSlider::SetName ( const TranslatableString name)

Definition at line 629 of file ASlider.cpp.

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

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

Here is the call graph for this function:

◆ SetParent()

void LWSlider::SetParent ( wxWindow *  parent)

Definition at line 1401 of file ASlider.cpp.

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

References CreatePopWin(), and mParent.

Here is the call graph for this function:

◆ SetPopWinPosition()

void LWSlider::SetPopWinPosition ( )
private

Definition at line 964 of file ASlider.cpp.

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

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

658{
659 mScrollLine = line;
660 mScrollPage = page;
661}

References mScrollLine, and mScrollPage.

◆ SetSpeed()

void LWSlider::SetSpeed ( float  speed)

Definition at line 1472 of file ASlider.cpp.

1473{
1474 mSpeed = speed;
1475}

References mSpeed.

◆ SetToolTipTemplate()

void LWSlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 935 of file ASlider.cpp.

936{
937 mTipTemplate = tip;
938}

References mTipTemplate.

◆ ShowDialog() [1/2]

bool LWSlider::ShowDialog ( )

Definition at line 1120 of file ASlider.cpp.

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

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

1126{
1127 return DoShowDialog( pos );
1128}

References DoShowDialog().

Here is the call graph for this function:

◆ ShowTip()

void LWSlider::ShowTip ( bool  show)

Definition at line 940 of file ASlider.cpp.

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

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

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