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

496{
497 Init(parent, name, pos, size, minValue, maxValue, stepValue,
498 canUseShift, style, showlabels, drawticks, drawtrack,
499 alwayshidetip, heavyweight, popup, 1.0, orientation);
500}
wxString name
Definition: TagsEditor.cpp:166
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:567

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

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

620{
621}

Member Function Documentation

◆ AdjustSize()

void LWSlider::AdjustSize ( const wxSize &  sz)

Definition at line 673 of file ASlider.cpp.

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

1496{
1497 int nSpan;
1498 int pos;
1499 if (mOrientation == wxHORIZONTAL)
1500 {
1501 pos = (fromPos - mLeft - (mThumbWidth / 2));
1502 nSpan = mWidthX;
1503 }
1504 else
1505 {
1506 // wxVERTICAL => Low values at bottom.
1507 pos = mBottomY - fromPos;
1508 nSpan = mHeightY;
1509 }
1510
1511 // MM: Special cases: If position is at the very left or the
1512 // very right (or top/bottom for wxVERTICAL), set minimum/maximum value without other checks
1513 if (pos <= 0)
1514 return mMinValue;
1515 if (pos >= nSpan)
1516 return mMaxValue;
1517
1518 float val = (pos / (float)nSpan)
1520
1521 if (val < mMinValue)
1522 val = mMinValue;
1523 if (val > mMaxValue)
1524 val = mMaxValue;
1525
1526 if (!(mCanUseShift && shiftDown) && mStepValue != STEP_CONTINUOUS)
1527 {
1528 // MM: If shift is not down, or we don't allow usage
1529 // of shift key at all, trim value to steps of
1530 // provided size.
1531 val = (int)(val / mStepValue + 0.5 * (val>0?1.0f:-1.0f)) * mStepValue;
1532 }
1533
1534 return val;
1535}
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 959 of file ASlider.cpp.

960{
961 if(mTipPanel || mAlwaysHideTip || mParent == nullptr)
962 return;
963
965 mTipPanel->Hide();
966}
#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:148

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

1618{
1619 float stepValue = mStepValue;
1620
1621 if ( stepValue == 0.0 )
1622 {
1623 stepValue = ( mMaxValue - mMinValue ) / 10.0;
1624 }
1625
1626 mCurrentValue -= ( steps * stepValue );
1627
1628 if ( mCurrentValue < mMinValue )
1629 {
1631 }
1632 else if ( mCurrentValue > mMaxValue )
1633 {
1635 }
1636
1637 Refresh();
1638}
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 wxRect screenRect = wxDisplay(wxDisplay::GetFromPoint(pos)).GetClientArea();
1151 int screenOffset = 8;
1152 int dlgWidth = dlg.GetSize().GetWidth();
1153 int dlgHeight = dlg.GetSize().GetHeight();
1154
1155 if (pos.x + dlgWidth > screenRect.GetRight()) {
1156 pos.x = screenRect.GetRight() - dlgWidth - screenOffset;
1157 }
1158 if (pos.x < screenRect.GetLeft()) {
1159 pos.x = screenRect.GetLeft() + screenOffset;
1160 }
1161 if (pos.y + dlgHeight > screenRect.GetBottom()) {
1162 pos.y = screenRect.GetBottom() - dlgHeight - screenOffset;
1163 }
1164 if (pos.y < screenRect.GetTop()) {
1165 pos.y = screenRect.GetTop() + screenOffset;
1166 }
1167 dlg.SetPosition(pos);
1168
1169 changed = (dlg.ShowModal() == wxID_OK);
1170 if( changed )
1171 value = dlg.Get();
1172
1173 // We now expect the pop up dialog to be
1174 // sending updates as we go.
1175 // So this code is needed to possibly restore the old
1176 // value, on a cancel.
1177 if (mCurrentValue != value) {
1178 mCurrentValue = value;
1179 SendUpdate(value);
1180 }
1181
1182 return changed;
1183}
TranslatableString mName
Definition: ASlider.h:254
float Get(bool convert=true)
Definition: ASlider.cpp:1569
int mStyle
Definition: ASlider.h:191
void SendUpdate(float newValue)
Definition: ASlider.cpp:1428
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 1539 of file ASlider.cpp.

1540{
1541 int delta = (fromPos - mClickPos);
1542
1543 float speed = mSpeed;
1544 // Precision enhancement for Shift drags
1545 if (mCanUseShift && shiftDown)
1546 speed *= 0.4f;
1547
1548 // wxVERTICAL => Low values at bottom, so throw in the minus sign here with -mHeightY.
1549 float denominator = (mOrientation == wxHORIZONTAL) ? mWidthX : -mHeightY;
1550 float val = mClickValue +
1551 speed * (delta / denominator) * (mMaxValue - mMinValue);
1552
1553 if (val < mMinValue)
1554 val = mMinValue;
1555 if (val > mMaxValue)
1556 val = mMaxValue;
1557
1558 if (!(mCanUseShift && shiftDown) && mStepValue != STEP_CONTINUOUS)
1559 {
1560 // MM: If shift is not down, or we don't allow usage
1561 // of shift key at all, and the slider has not continuous values,
1562 // trim value to steps of provided size.
1563 val = (int)(val / mStepValue + 0.5 * (val>0?1.0f:-1.0f)) * mStepValue;
1564 }
1565
1566 return val;
1567}
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 778 of file ASlider.cpp.

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

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

Referenced by OnPaint().

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

◆ FormatPopWin()

void LWSlider::FormatPopWin ( )
private

Definition at line 990 of file ASlider.cpp.

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

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

1570{
1571 if (mStyle == DB_SLIDER)
1572 return (convert ? DB_TO_LINEAR(mCurrentValue) : mCurrentValue);
1573 else
1574 return mCurrentValue;
1575}
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:338

References DB_SLIDER, DB_TO_LINEAR, mCurrentValue, and mStyle.

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

Here is the caller graph for this function:

◆ GetEnabled()

bool LWSlider::GetEnabled ( ) const

Definition at line 1655 of file ASlider.cpp.

1656{
1657 return mEnabled;
1658}
bool mEnabled
Definition: ASlider.h:256

References mEnabled.

◆ GetId()

wxWindowID LWSlider::GetId ( )

Definition at line 623 of file ASlider.cpp.

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

References mID.

◆ GetMaxValue()

float LWSlider::GetMaxValue ( ) const

Definition at line 1675 of file ASlider.cpp.

1676{
1677 return mMaxValue;
1678}

References mMaxValue.

◆ GetMinValue()

float LWSlider::GetMinValue ( ) const

Definition at line 1670 of file ASlider.cpp.

1671{
1672 return mMinValue;
1673}

References mMinValue.

◆ GetScroll()

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

Definition at line 655 of file ASlider.cpp.

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

References mScrollLine, and mScrollPage.

◆ GetStringValue()

wxString LWSlider::GetStringValue ( ) const

Definition at line 1451 of file ASlider.cpp.

1452{
1453 switch(mStyle)
1454 {
1455 case FRAC_SLIDER:
1456 return wxString::Format(wxT("%.0f"), mCurrentValue * 100);
1457 case PERCENT_SLIDER:
1458 return wxString::Format(wxT("%.0f%%"), mCurrentValue * 100.0f);
1459 case DB_SLIDER:
1460 return wxString::Format(wxT("%.0f"), mCurrentValue);
1461 case PAN_SLIDER:
1462 return wxString::Format(wxT("%.0f"), mCurrentValue * 100);
1463 case SPEED_SLIDER:
1464 return wxString::Format(wxT("%.0f"), mCurrentValue * 100 );
1465 case VEL_SLIDER:
1466 return wxString::Format(wxT("%.0f"), mCurrentValue);
1467 default:
1468 return {};
1469 }
1470}
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 1001 of file ASlider.cpp.

1002{
1004
1005 if (mTipTemplate.empty())
1006 {
1008
1009 switch(mStyle)
1010 {
1011 case FRAC_SLIDER:
1012 val = Verbatim("%.2f").Format( value );
1013 break;
1014 case PERCENT_SLIDER:
1015 val = Verbatim("%.0f%%").Format(value * 100.0f);
1016 break;
1017
1018 case DB_SLIDER:
1019 /* i18n-hint dB abbreviates decibels */
1020 val = XO("%+.1f dB").Format( value );
1021 break;
1022
1023 case PAN_SLIDER:
1024 if (value == 0.0)
1025 {
1026 val = XO("Center");
1027 }
1028 else
1029 {
1030 const auto v = 100.0f * fabsf(value);
1031 if (value < 0.0)
1032 /* i18n-hint: Stereo pan setting */
1033 val = XO("%.0f%% Left").Format( v );
1034 else
1035 /* i18n-hint: Stereo pan setting */
1036 val = XO("%.0f%% Right").Format( v );
1037 }
1038 break;
1039
1040 case SPEED_SLIDER:
1041 /* i18n-hint: "x" suggests a multiplicative factor */
1042 val = XO("%.3fx").Format( value );
1043 break;
1044
1045 case VEL_SLIDER:
1046 if (value > 0.0f)
1047 // Signed
1048 val = Verbatim("%+d").Format( (int) value );
1049 else
1050 // Zero, or signed negative
1051 val = Verbatim("%d").Format( (int) value );
1052 break;
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 case VEL_SLIDER:
1108 results.push_back( GetTip( 999.f ) );
1109 break;
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 1594 of file ASlider.cpp.

1595{
1596 float stepValue = mStepValue;
1597
1598 if ( stepValue == 0.0 )
1599 {
1600 stepValue = ( mMaxValue - mMinValue ) / 10.0;
1601 }
1602
1603 mCurrentValue += ( steps * stepValue );
1604
1605 if ( mCurrentValue < mMinValue )
1606 {
1608 }
1609 else if ( mCurrentValue > mMaxValue )
1610 {
1612 }
1613
1614 Refresh();
1615}

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

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

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

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

1347{
1348 if (mEnabled)
1349 {
1350 switch( event.GetKeyCode() )
1351 {
1352 case WXK_TAB:
1353 mParent->Navigate(event.ShiftDown()
1354 ? wxNavigationKeyEvent::IsBackward
1355 : wxNavigationKeyEvent::IsForward);
1356 break;
1357
1358 case WXK_RIGHT:
1359 case WXK_UP:
1362 ShowTip(true);
1363 break;
1364
1365 case WXK_LEFT:
1366 case WXK_DOWN:
1369 ShowTip(true);
1370 break;
1371
1372 case WXK_PAGEUP:
1375 ShowTip(true);
1376 break;
1377
1378 case WXK_PAGEDOWN:
1381 ShowTip(true);
1382 break;
1383
1384 case WXK_HOME:
1386 ShowTip(true);
1387 break;
1388
1389 case WXK_END:
1391 ShowTip(true);
1392 break;
1393
1394 case WXK_RETURN:
1395 case WXK_NUMPAD_ENTER:
1396 {
1397 wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(mParent), wxTopLevelWindow);
1398 wxWindow *def = tlw->GetDefaultItem();
1399 if (def && def->IsEnabled()) {
1400 wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
1401 def->GetId());
1402 cevent.SetEventObject( def );
1403 mParent->GetEventHandler()->ProcessEvent(cevent);
1404 }
1405 }
1406
1407 default:
1408 // Allow it to propagate
1409 event.Skip();
1410 break;
1411 }
1412 }
1413 else
1414 {
1415 event.Skip();
1416 }
1417}
wxEVT_COMMAND_BUTTON_CLICKED
void ShowTip(bool show)
Definition: ASlider.cpp:944
void Decrease(float steps)
Definition: ASlider.cpp:1617
void Increase(float steps)
Definition: ASlider.cpp:1594

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

1473{
1474 ShowTip(false);
1475}

References ShowTip().

Here is the call graph for this function:

◆ OnMouseEvent()

void LWSlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1185 of file ASlider.cpp.

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

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

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

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

References AdjustSize(), and Refresh().

Here is the call graph for this function:

◆ Redraw()

void LWSlider::Redraw ( )

Definition at line 1646 of file ASlider.cpp.

1647{
1648 mBitmap.reset();
1649 mThumbBitmap.reset();
1650 mThumbBitmapHilited.reset();
1651
1652 Refresh();
1653}

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

Here is the call graph for this function:

◆ Refresh()

void LWSlider::Refresh ( )

Definition at line 1640 of file ASlider.cpp.

1641{
1642 if (mHW)
1643 mParent->Refresh(false);
1644}

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

1429{
1430 mCurrentValue = newValue;
1431
1432 FormatPopWin();
1433
1434 Refresh();
1435
1436 // Update the project's status bar as well
1437 if (mTipPanel) {
1438 auto tip = GetTip(mCurrentValue);
1439 auto pProject = FindProjectFromWindow( mParent );
1440 if (pProject)
1441 ProjectStatus::Get( *pProject ).Set( tip );
1442 }
1443
1444 wxCommandEvent e( wxEVT_COMMAND_SLIDER_UPDATED, mID );
1445 int intValue = (int)( ( mCurrentValue - mMinValue ) * 1000.0f /
1446 ( mMaxValue - mMinValue ) );
1447 e.SetInt( intValue );
1448 mParent->GetEventHandler()->ProcessEvent(e);
1449}
void FormatPopWin()
Definition: ASlider.cpp:990

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

1578{
1579 if (mIsDragging)
1580 return;
1581 if (mStyle == DB_SLIDER)
1582 mCurrentValue = LINEAR_TO_DB(value);
1583 else
1584 mCurrentValue = value;
1585
1590
1591 Refresh();
1592}
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:339

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

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

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

◆ SetDefaultShortcut()

void LWSlider::SetDefaultShortcut ( bool  value)

Definition at line 650 of file ASlider.cpp.

651{
652 mDefaultShortcut = value;
653}

References mDefaultShortcut.

Referenced by SetDefaultValue().

Here is the caller graph for this function:

◆ SetDefaultValue()

void LWSlider::SetDefaultValue ( float  value)

Definition at line 644 of file ASlider.cpp.

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

References mDefaultValue, and SetDefaultShortcut().

Here is the call graph for this function:

◆ SetEnabled()

void LWSlider::SetEnabled ( bool  enabled)

Definition at line 1660 of file ASlider.cpp.

1661{
1662 mEnabled = enabled;
1663
1664 mThumbBitmap.reset();
1665 mThumbBitmapHilited.reset();
1666
1667 Refresh();
1668}

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

Here is the call graph for this function:

◆ SetId()

void LWSlider::SetId ( wxWindowID  id)

Definition at line 628 of file ASlider.cpp.

629{
630 mID = id;
631}
int id

References id, and mID.

◆ SetName()

void LWSlider::SetName ( const TranslatableString name)

Definition at line 633 of file ASlider.cpp.

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

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

Here is the call graph for this function:

◆ SetParent()

void LWSlider::SetParent ( wxWindow *  parent)

Definition at line 1419 of file ASlider.cpp.

1420{
1421 mParent = parent;
1422 //VS: create pop win if there is no one, don't re-parent
1423 //as it seem to be a workaround for DC drawing purposes
1424 //(see `WaveTrackControls::GainSlider`)
1425 CreatePopWin();
1426}

References CreatePopWin(), and mParent.

Here is the call graph for this function:

◆ SetPopWinPosition()

void LWSlider::SetPopWinPosition ( )
private

Definition at line 968 of file ASlider.cpp.

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

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

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

References mScrollLine, and mScrollPage.

◆ SetSpeed()

void LWSlider::SetSpeed ( float  speed)

Definition at line 1488 of file ASlider.cpp.

1489{
1490 mSpeed = speed;
1491}

References mSpeed.

◆ SetToolTipTemplate()

void LWSlider::SetToolTipTemplate ( const TranslatableString tip)

Definition at line 939 of file ASlider.cpp.

940{
941 mTipTemplate = tip;
942}

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

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

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

1479{
1480 float fRange = mMaxValue - mMinValue;
1481 if (mOrientation == wxHORIZONTAL)
1482 return (int)rint((val - mMinValue) * mWidthX / fRange);
1483 else
1484 // low values at bottom
1485 return (int)rint((mMaxValue - val) * mHeightY / fRange);
1486}
__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: