Audacity  2.2.2
Public Member Functions | Static 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>

Public Member Functions

 LWSlider (wxWindow *parent, const wxString &name, const wxPoint &pos, const wxSize &size, float minValue, float maxValue, float stepValue, bool canUseShift, int style, bool heavyweight=false, bool popup=true, int orientation=wxHORIZONTAL)
 
 LWSlider (wxWindow *parent, const wxString &name, const wxPoint &pos, const wxSize &size, int style, bool heavyweight=false, bool popup=true, int orientation=wxHORIZONTAL)
 
void Init (wxWindow *parent, const wxString &name, const wxPoint &pos, const wxSize &size, float minValue, float maxValue, float stepValue, bool canUseShift, int style, bool heavyweight, bool popup, float speed, int orientation=wxHORIZONTAL)
 
virtual ~LWSlider ()
 
wxWindowID GetId ()
 
void SetId (wxWindowID id)
 
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 wxString &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 OnKeyEvent (wxKeyEvent &event)
 
void Refresh ()
 
bool ShowDialog ()
 
bool ShowDialog (wxPoint pos)
 
void SetEnabled (bool enabled)
 
bool GetEnabled ()
 
void SetParent (wxWindow *parent)
 

Static Public Member Functions

static void DeleteSharedTipPanel ()
 

Private Member Functions

wxString GetTip (float value) const
 
wxArrayString GetWidestTips () const
 
void FormatPopWin ()
 
void SetPopWinPosition ()
 
void CreatePopWin ()
 
void DrawToBitmap (wxDC &dc)
 
bool DoShowDialog (wxPoint pos)
 
void SendUpdate (float newValue)
 
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 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
 
std::unique_ptr< TipPanelmTipPanel
 
wxString mTipTemplate
 
bool mIsDragging
 
std::unique_ptr< wxBitmap > mBitmap
 
std::unique_ptr< wxBitmap > mThumbBitmap
 
std::unique_ptr< wxBitmap > mThumbBitmapHilited
 
wxString 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 73 of file ASlider.h.

Constructor & Destructor Documentation

LWSlider::LWSlider ( wxWindow *  parent,
const wxString &  name,
const wxPoint &  pos,
const wxSize &  size,
float  minValue,
float  maxValue,
float  stepValue,
bool  canUseShift,
int  style,
bool  heavyweight = false,
bool  popup = true,
int  orientation = wxHORIZONTAL 
)

Definition at line 351 of file ASlider.cpp.

References Init().

363 {
364  Init(parent, name, pos, size, minValue, maxValue,
365  stepValue, canUseShift, style, heavyweight, popup, 1.0, orientation);
366 }
void Init(wxWindow *parent, const wxString &name, const wxPoint &pos, const wxSize &size, float minValue, float maxValue, float stepValue, bool canUseShift, int style, bool heavyweight, bool popup, float speed, int orientation=wxHORIZONTAL)
Definition: ASlider.cpp:429
const wxChar * name
Definition: Distortion.cpp:94
LWSlider::LWSlider ( wxWindow *  parent,
const wxString &  name,
const wxPoint &  pos,
const wxSize &  size,
int  style,
bool  heavyweight = false,
bool  popup = true,
int  orientation = wxHORIZONTAL 
)

Definition at line 369 of file ASlider.cpp.

References DB_SLIDER, FRAC_SLIDER, Init(), PAN_SLIDER, SPEED_SLIDER, STEP_CONTINUOUS, VEL_MAX, VEL_MIN, and VEL_SLIDER.

377 {
378  wxString leftLabel, rightLabel;
379 
380  float minValue, maxValue, stepValue;
381  float speed = 1.0;
382 
383  switch(style)
384  {
385  case PAN_SLIDER:
386  minValue = -1.0f;
387  maxValue = +1.0f;
388  stepValue = 0.1f;
389  orientation = wxHORIZONTAL; //v Vertical PAN_SLIDER currently not handled, forced to horizontal.
390  break;
391  case DB_SLIDER:
392  minValue = -36.0f;
393  //if (orientation == wxHORIZONTAL)
394  maxValue = 36.0f;
395  //else
396  //maxValue = 36.0f; // for MixerBoard //v Previously was 6dB for MixerBoard, but identical for now.
397  stepValue = 1.0f;
398  speed = 0.5;
399  break;
400  case FRAC_SLIDER:
401  minValue = 0.0f;
402  maxValue = 1.0f;
403  stepValue = STEP_CONTINUOUS;
404  break;
405  case SPEED_SLIDER:
406  minValue = 0.01f;
407  maxValue = 3.0f;
408  stepValue = STEP_CONTINUOUS;
409  break;
410 #ifdef EXPERIMENTAL_MIDI_OUT
411  case VEL_SLIDER:
412  minValue = VEL_MIN;
413  maxValue = VEL_MAX;
414  stepValue = 1.0f;
415  speed = 0.5;
416  break;
417 #endif
418  default:
419  minValue = 0.0f;
420  maxValue = 1.0f;
421  stepValue = 0.0f;
422  wxASSERT(false); // undefined style
423  }
424 
425  Init(parent, name, pos, size, minValue, maxValue, stepValue,
426  true, style, heavyweight, popup, speed, orientation);
427 }
#define STEP_CONTINUOUS
Definition: ASlider.h:64
#define SPEED_SLIDER
Definition: ASlider.h:47
#define PAN_SLIDER
Definition: ASlider.h:46
void Init(wxWindow *parent, const wxString &name, const wxPoint &pos, const wxSize &size, float minValue, float maxValue, float stepValue, bool canUseShift, int style, bool heavyweight, bool popup, float speed, int orientation=wxHORIZONTAL)
Definition: ASlider.cpp:429
#define DB_SLIDER
Definition: ASlider.h:45
#define VEL_SLIDER
Definition: ASlider.h:49
const wxChar * name
Definition: Distortion.cpp:94
#define VEL_MIN
Definition: ASlider.h:57
#define VEL_MAX
Definition: ASlider.h:58
#define FRAC_SLIDER
Definition: ASlider.h:44
LWSlider::~LWSlider ( )
virtual

Definition at line 472 of file ASlider.cpp.

473 {
474 }

Member Function Documentation

void LWSlider::AdjustSize ( const wxSize &  sz)

Definition at line 515 of file ASlider.cpp.

References mBitmap, mBottomY, mCenterX, mCenterY, mHeight, mHeightY, mLeftX, mOrientation, mRightX, mThumbHeight, mThumbWidth, mTopY, mWidth, mWidthX, and Refresh().

Referenced by Init(), and OnSize().

516 {
517  mWidth = sz.GetWidth();
518  mHeight = sz.GetHeight();
519 
520  if( mBitmap ){
521  mBitmap.reset();
522  }
523  mThumbWidth = 11;
524  mThumbHeight = 20;
525 
526  if (mOrientation == wxHORIZONTAL)
527  {
528  mCenterY = mHeight - 9;
529  }
530  else
531  {
532  mCenterX = mWidth - 9;
533  }
534 
535  if (mOrientation == wxHORIZONTAL)
536  {
537  mLeftX = mThumbWidth/2;
538  mRightX = mWidth - mThumbWidth/2 - 1;
539  mWidthX = mRightX - mLeftX;
540  }
541  else
542  {
543  mTopY = mThumbWidth/2;
544  mBottomY = mHeight - mThumbWidth/2 - 1;
545  mHeightY = mBottomY - mTopY;
546  }
547 
548  Refresh();
549 }
std::unique_ptr< wxBitmap > mBitmap
Definition: ASlider.h:236
int mLeftX
Definition: ASlider.h:196
int mTopY
Definition: ASlider.h:203
int mWidthX
Definition: ASlider.h:198
int mCenterY
Definition: ASlider.h:194
int mRightX
Definition: ASlider.h:197
int mWidth
Definition: ASlider.h:190
int mHeight
Definition: ASlider.h:191
int mHeightY
Definition: ASlider.h:205
int mBottomY
Definition: ASlider.h:204
void Refresh()
Definition: ASlider.cpp:1384
int mThumbHeight
Definition: ASlider.h:209
int mOrientation
Definition: ASlider.h:182
int mCenterX
Definition: ASlider.h:201
int mThumbWidth
Definition: ASlider.h:208
float LWSlider::ClickPositionToValue ( int  fromPos,
bool  shiftDown 
)
private

Definition at line 1239 of file ASlider.cpp.

References mBottomY, mCanUseShift, mHeightY, mLeft, mMaxValue, mMinValue, mOrientation, mStepValue, mThumbWidth, mWidthX, and STEP_CONTINUOUS.

Referenced by OnMouseEvent().

1240 {
1241  int nSpan;
1242  int pos;
1243  if (mOrientation == wxHORIZONTAL)
1244  {
1245  pos = (fromPos - mLeft - (mThumbWidth / 2));
1246  nSpan = mWidthX;
1247  }
1248  else
1249  {
1250  // wxVERTICAL => Low values at bottom.
1251  pos = mBottomY - fromPos;
1252  nSpan = mHeightY;
1253  }
1254 
1255  // MM: Special cases: If position is at the very left or the
1256  // very right (or top/bottom for wxVERTICAL), set minimum/maximum value without other checks
1257  if (pos <= 0)
1258  return mMinValue;
1259  if (pos >= nSpan)
1260  return mMaxValue;
1261 
1262  float val = (pos / (float)nSpan)
1263  * (mMaxValue - mMinValue) + mMinValue;
1264 
1265  if (val < mMinValue)
1266  val = mMinValue;
1267  if (val > mMaxValue)
1268  val = mMaxValue;
1269 
1270  if (!(mCanUseShift && shiftDown) && mStepValue != STEP_CONTINUOUS)
1271  {
1272  // MM: If shift is not down, or we don't allow usage
1273  // of shift key at all, trim value to steps of
1274  // provided size.
1275  val = (int)(val / mStepValue + 0.5 * (val>0?1.0f:-1.0f)) * mStepValue;
1276  }
1277 
1278  return val;
1279 }
float mMinValue
Definition: ASlider.h:214
#define STEP_CONTINUOUS
Definition: ASlider.h:64
float mMaxValue
Definition: ASlider.h:215
int mWidthX
Definition: ASlider.h:198
bool mCanUseShift
Definition: ASlider.h:227
int mHeightY
Definition: ASlider.h:205
int mBottomY
Definition: ASlider.h:204
int mOrientation
Definition: ASlider.h:182
float mStepValue
Definition: ASlider.h:216
int mThumbWidth
Definition: ASlider.h:208
int mLeft
Definition: ASlider.h:187
void LWSlider::CreatePopWin ( )
private

Definition at line 798 of file ASlider.cpp.

References GetWidestTips(), mParent, and mTipPanel.

Referenced by ShowTip().

799 {
800  mTipPanel = std::make_unique<TipPanel>(mParent, GetWidestTips());
801 }
wxWindow * mParent
Definition: ASlider.h:179
wxArrayString GetWidestTips() const
Definition: ASlider.cpp:898
std::unique_ptr< TipPanel > mTipPanel
Definition: ASlider.h:231
void LWSlider::Decrease ( float  steps)

Definition at line 1361 of file ASlider.cpp.

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

Referenced by OnKeyEvent(), OnMouseEvent(), AudacityProject::OnTrackGainDec(), and AudacityProject::OnTrackPanLeft().

1362 {
1363  float stepValue = mStepValue;
1364 
1365  if ( stepValue == 0.0 )
1366  {
1367  stepValue = ( mMaxValue - mMinValue ) / 10.0;
1368  }
1369 
1370  mCurrentValue -= ( steps * stepValue );
1371 
1372  if ( mCurrentValue < mMinValue )
1373  {
1375  }
1376  else if ( mCurrentValue > mMaxValue )
1377  {
1379  }
1380 
1381  Refresh();
1382 }
float mMinValue
Definition: ASlider.h:214
float mMaxValue
Definition: ASlider.h:215
float mCurrentValue
Definition: ASlider.h:222
void Refresh()
Definition: ASlider.cpp:1384
float mStepValue
Definition: ASlider.h:216
static void LWSlider::DeleteSharedTipPanel ( )
static
bool LWSlider::DoShowDialog ( wxPoint  pos)
private

Definition at line 953 of file ASlider.cpp.

References Get(), SliderDialog::Get(), mCurrentValue, mHeight, mName, mScrollLine, mScrollPage, mStyle, and mWidth.

Referenced by OnMouseEvent(), and ShowDialog().

954 {
955  float value;
956  bool changed = false;
957 
958  SliderDialog dlg( NULL,
959  wxID_ANY,
960  mName,
961  pos,
962  wxSize( mWidth, mHeight ),
963  mStyle,
964  Get(),
965  mScrollLine,
966  mScrollPage);
967  if (pos == wxPoint(-1, -1)) {
968  dlg.Center();
969  }
970 
971  if( dlg.ShowModal() == wxID_OK )
972  {
973  value = dlg.Get();
974  if( value != mCurrentValue )
975  {
976  mCurrentValue = value;
977  changed = true;
978  }
979  }
980 
981  return changed;
982 }
float mScrollPage
Definition: ASlider.h:220
int mStyle
Definition: ASlider.h:181
Pop up dialog used with an LWSlider.
Definition: ASlider.h:341
int mWidth
Definition: ASlider.h:190
float Get(bool convert=true)
Definition: ASlider.cpp:1313
int mHeight
Definition: ASlider.h:191
float mCurrentValue
Definition: ASlider.h:222
wxString mName
Definition: ASlider.h:238
float mScrollLine
Definition: ASlider.h:219
float LWSlider::DragPositionToValue ( int  fromPos,
bool  shiftDown 
)
private

Definition at line 1283 of file ASlider.cpp.

References mCanUseShift, mClickPos, mClickValue, mHeightY, mMaxValue, mMinValue, mOrientation, mSpeed, mStepValue, mWidthX, and STEP_CONTINUOUS.

Referenced by OnMouseEvent().

1284 {
1285  int delta = (fromPos - mClickPos);
1286 
1287  float speed = mSpeed;
1288  // Precision enhancement for Shift drags
1289  if (mCanUseShift && shiftDown)
1290  speed *= 0.4f;
1291 
1292  // wxVERTICAL => Low values at bottom, so throw in the minus sign here with -mHeightY.
1293  float denominator = (mOrientation == wxHORIZONTAL) ? mWidthX : -mHeightY;
1294  float val = mClickValue +
1295  speed * (delta / denominator) * (mMaxValue - mMinValue);
1296 
1297  if (val < mMinValue)
1298  val = mMinValue;
1299  if (val > mMaxValue)
1300  val = mMaxValue;
1301 
1302  if (!(mCanUseShift && shiftDown) && mStepValue != STEP_CONTINUOUS)
1303  {
1304  // MM: If shift is not down, or we don't allow usage
1305  // of shift key at all, and the slider has not continuous values,
1306  // trim value to steps of provided size.
1307  val = (int)(val / mStepValue + 0.5 * (val>0?1.0f:-1.0f)) * mStepValue;
1308  }
1309 
1310  return val;
1311 }
float mMinValue
Definition: ASlider.h:214
int mClickPos
Definition: ASlider.h:212
#define STEP_CONTINUOUS
Definition: ASlider.h:64
float mMaxValue
Definition: ASlider.h:215
int mWidthX
Definition: ASlider.h:198
float mSpeed
Definition: ASlider.h:217
bool mCanUseShift
Definition: ASlider.h:227
int mHeightY
Definition: ASlider.h:205
float mClickValue
Definition: ASlider.h:211
int mOrientation
Definition: ASlider.h:182
float mStepValue
Definition: ASlider.h:216
void LWSlider::DrawToBitmap ( wxDC &  dc)
private

Definition at line 606 of file ASlider.cpp.

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

Referenced by OnPaint().

607 {
608  // Get correctly oriented thumb.
609  if (mOrientation == wxVERTICAL){
610  mThumbBitmap = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbRotated )));
611  mThumbBitmapHilited = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbRotatedHilited )));
612  }
613  else {
614  mThumbBitmap = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumb )));
615  mThumbBitmapHilited = std::make_unique<wxBitmap>(wxBitmap( theTheme.Bitmap( bmpSliderThumbHilited )));
616  }
617 
618  // Now the background bitmap
619  mBitmap = std::make_unique<wxBitmap>();
620  mBitmap->Create(mWidth, mHeight, paintDC);
621 
622  // Set up the memory DC
623  // We draw to it, not the paintDC.
624  wxMemoryDC dc;
625  dc.SelectObject(*mBitmap);
626 
627 
628  // The backgroundColour is the expected background colour.
629  // This bitmap is masked, so the colour affects anti-aliassing
630  // at the edges.
631  wxColour backgroundColour = theTheme.Colour(clrTrackInfo);
632  if( mHW )
633  backgroundColour = mParent->GetBackgroundColour();
634  dc.SetBackground(wxBrush(backgroundColour));
635  dc.Clear();
636 
637  // Draw the line along which the thumb moves.
638  AColor::UseThemeColour(&dc, clrSliderMain );
639 
640  if (mOrientation == wxHORIZONTAL)
641  {
644  }
645  else
646  {
649  }
650 
651  // Draw +/- or L/R first. We need to draw these before the tick marks.
652  if (mStyle == PAN_SLIDER)
653  {
654  //VJ Vertical PAN_SLIDER currently not handled, forced to horizontal.
655 
656  // sliderFontSize is for the tooltip.
657  // we need something smaller here...
658  int fontSize = 7;
659  wxFont labelFont(fontSize, wxSWISS, wxNORMAL, wxNORMAL);
660  dc.SetFont(labelFont);
661 
662  // Colors
663  dc.SetTextForeground( theTheme.Colour( clrTrackPanelText ));
664  dc.SetTextBackground( backgroundColour );
665  // Used to use wxSOLID here, but wxTRANSPARENT is better for mac, and
666  // works fine on windows.
667  dc.SetBackgroundMode( wxTRANSPARENT );
668 
669  /* i18n-hint: One-letter abbreviation for Left, in the Pan slider */
670  dc.DrawText(_("L"), mLeftX, 0);
671 
672  /* i18n-hint: One-letter abbreviation for Right, in the Pan slider */
673  dc.DrawText(_("R"), mRightX-6,0);
674  }
675  else
676  {
677  // draw the '-' and the '+'
678  // These are drawn with lines, rather tha nwith a font.
679  AColor::UseThemeColour(&dc, clrTrackPanelText );
680 
681  if (mOrientation == wxHORIZONTAL)
682  {
683  AColor::Line(dc, mLeftX, mCenterY-10, mLeftX+4, mCenterY-10);
684  AColor::Line(dc, mRightX-5, mCenterY-10, mRightX-1, mCenterY-10);
685  AColor::Line(dc, mRightX-3, mCenterY-12, mRightX-3, mCenterY-8);
686  }
687  else
688  {
689  // Vertical DB_SLIDER is for gain slider in MixerBoard.
690  // We use a Ruler instead of marks & ticks.
691  // Draw '+' and '-' only for other vertical sliders.
692  if (mStyle != DB_SLIDER)
693  {
695  AColor::Line(dc, mCenterX-12, mTopY+3, mCenterX-8, mTopY+3);
696  AColor::Line(dc, mCenterX-10, mTopY, mCenterX-10, mTopY+5);
697  }
698  }
699  }
700 
701  // Use special colour to indicate no ticks.
702  wxColour TickColour = theTheme.Colour( clrSliderLight );
703  bool bTicks = TickColour != wxColour(60,60,60);
704 
705  if( bTicks ) {
706  // tick marks
707  int divs = 10;
708  double upp;
709  if (mOrientation == wxHORIZONTAL)
710  {
711  upp = divs / (double)(mWidthX-1);
712  }
713  else
714  {
715  if (mStyle == DB_SLIDER)
716  divs = mMaxValue - mMinValue + 1;
717  upp = divs / (double)(mHeightY-1);
718  }
719 #ifdef OPTIONAL_SLIDER_TICKS
720  double d = 0.0;
721  int int_d = -1;
722  const int kMax = (mOrientation == wxHORIZONTAL) ? mWidthX : mHeightY;
723  for(int p = 0; p <= kMax; p++)
724  {
725  if (((int)d) > int_d)
726  {
727  int_d = (int)d;
728  int tickLength = ((int_d == 0) || (int_d == divs)) ? 5: 3; // longer ticks at extremes
729  AColor::UseThemeColour(&dc, clrSliderLight );
730 
731  if (mOrientation == wxHORIZONTAL)
732  {
733  AColor::Line(dc, mLeftX+p, mCenterY-tickLength, mLeftX+p, mCenterY-1); // ticks above
734  }
735  else
736  {
737  AColor::Line(dc, mCenterX-tickLength, mTopY+p, mCenterX-1, mTopY+p); // ticks at left
738  }
739 
740  AColor::UseThemeColour(&dc, clrSliderDark );
741 
742  if (mOrientation == wxHORIZONTAL)
743  {
744  AColor::Line(dc, mLeftX+p+1, mCenterY-tickLength+1, mLeftX+p+1, mCenterY-1); // ticks above
745  }
746  else
747  {
748  AColor::Line(dc, mCenterX-tickLength+1, mTopY+p+1, mCenterX-1, mTopY+p+1); // ticks at left
749  }
750  }
751  d += upp;
752  }
753 #endif
754  }
755 
756  dc.SelectObject(wxNullBitmap);
757 
758  // safenew, because SetMask takes ownership
759  // We always mask. If we are HeavyWeight, the ASlider draws the
760  // background.
761  mBitmap->SetMask(safenew wxMask(*mBitmap, backgroundColour));
762 }
float mMinValue
Definition: ASlider.h:214
wxWindow * mParent
Definition: ASlider.h:179
std::unique_ptr< wxBitmap > mBitmap
Definition: ASlider.h:236
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
int mLeftX
Definition: ASlider.h:196
float mMaxValue
Definition: ASlider.h:215
int mTopY
Definition: ASlider.h:203
int mWidthX
Definition: ASlider.h:198
int mCenterY
Definition: ASlider.h:194
int mStyle
Definition: ASlider.h:181
int mRightX
Definition: ASlider.h:197
int mWidth
Definition: ASlider.h:190
bool mHW
Definition: ASlider.h:184
#define safenew
Definition: Audacity.h:230
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1244
#define PAN_SLIDER
Definition: ASlider.h:46
int mHeight
Definition: ASlider.h:191
std::unique_ptr< wxBitmap > mThumbBitmap
Definition: ASlider.h:236
int mHeightY
Definition: ASlider.h:205
int mBottomY
Definition: ASlider.h:204
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1)
Definition: AColor.cpp:289
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:122
#define DB_SLIDER
Definition: ASlider.h:45
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
std::unique_ptr< wxBitmap > mThumbBitmapHilited
Definition: ASlider.h:236
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
int mOrientation
Definition: ASlider.h:182
int mCenterX
Definition: ASlider.h:201
void LWSlider::FormatPopWin ( )
private

Definition at line 825 of file ASlider.cpp.

References GetTip(), mCurrentValue, and mTipPanel.

Referenced by SendUpdate(), and ShowTip().

826 {
827  if (!mTipPanel)
828  {
829  return;
830  }
831 
832  mTipPanel->SetLabel(GetTip(mCurrentValue));
833  mTipPanel->Refresh();
834 }
float mCurrentValue
Definition: ASlider.h:222
std::unique_ptr< TipPanel > mTipPanel
Definition: ASlider.h:231
wxString GetTip(float value) const
Definition: ASlider.cpp:836
float LWSlider::Get ( bool  convert = true)

Definition at line 1313 of file ASlider.cpp.

References DB_SLIDER, DB_TO_LINEAR(), mCurrentValue, and mStyle.

Referenced by DoShowDialog(), AudacityProject::SetTrackGain(), and AudacityProject::SetTrackPan().

1314 {
1315  if (mStyle == DB_SLIDER)
1316  return (convert ? DB_TO_LINEAR(mCurrentValue) : mCurrentValue);
1317  else
1318  return mCurrentValue;
1319 }
int mStyle
Definition: ASlider.h:181
float mCurrentValue
Definition: ASlider.h:222
#define DB_SLIDER
Definition: ASlider.h:45
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
bool LWSlider::GetEnabled ( )

Definition at line 1390 of file ASlider.cpp.

References mEnabled.

1391 {
1392  return mEnabled;
1393 }
bool mEnabled
Definition: ASlider.h:240
wxWindowID LWSlider::GetId ( )

Definition at line 476 of file ASlider.cpp.

References mID.

477 {
478  return mID;
479 }
wxWindowID mID
Definition: ASlider.h:229
void LWSlider::GetScroll ( float &  line,
float &  page 
)

Definition at line 497 of file ASlider.cpp.

References mScrollLine, and mScrollPage.

498 {
499  line = mScrollLine;
500  page = mScrollPage;
501 }
float mScrollPage
Definition: ASlider.h:220
float mScrollLine
Definition: ASlider.h:219
wxString LWSlider::GetTip ( float  value) const
private

Definition at line 836 of file ASlider.cpp.

References _(), DB_SLIDER, FRAC_SLIDER, label, mName, mStyle, mTipTemplate, PAN_SLIDER, SPEED_SLIDER, and VEL_SLIDER.

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

837 {
838  wxString label;
839 
840  if (mTipTemplate.IsEmpty())
841  {
842  wxString val;
843 
844  switch(mStyle)
845  {
846  case FRAC_SLIDER:
847  val.Printf( wxT("%.2f"), value );
848  break;
849 
850  case DB_SLIDER:
851  val.Printf( wxT("%+.1f dB"), value );
852  break;
853 
854  case PAN_SLIDER:
855  if (value == 0.0)
856  {
857  val = _("Center");
858  }
859  else
860  {
861  const auto v = 100.0f * fabsf(value);
862  if (value < 0.0)
863  /* i18n-hint: Stereo pan setting */
864  val = wxString::Format( _("%.0f%% Left"), v );
865  else
866  /* i18n-hint: Stereo pan setting */
867  val = wxString::Format( _("%.0f%% Right"), v );
868  }
869  break;
870 
871  case SPEED_SLIDER:
872  /* i18n-hint: "x" suggests a multiplicative factor */
873  val.Printf( wxT("%.2fx"), value );
874  break;
875 
876 #ifdef EXPERIMENTAL_MIDI_OUT
877  case VEL_SLIDER:
878  if (value > 0.0f)
879  // Signed
880  val.Printf( wxT("%+d"), (int) value );
881  else
882  // Zero, or signed negative
883  val.Printf( wxT("%d"), (int) value );
884  break;
885 #endif
886  }
887 
888  label.Printf(_("%s: %s"), mName, val);
889  }
890  else
891  {
892  label.Printf(mTipTemplate, value);
893  }
894 
895  return label;
896 }
wxString label
Definition: Tags.cpp:733
#define SPEED_SLIDER
Definition: ASlider.h:47
int mStyle
Definition: ASlider.h:181
#define PAN_SLIDER
Definition: ASlider.h:46
wxString mTipTemplate
Definition: ASlider.h:232
#define DB_SLIDER
Definition: ASlider.h:45
#define VEL_SLIDER
Definition: ASlider.h:49
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxString mName
Definition: ASlider.h:238
#define FRAC_SLIDER
Definition: ASlider.h:44
wxArrayString LWSlider::GetWidestTips ( ) const
private

Definition at line 898 of file ASlider.cpp.

References DB_SLIDER, FRAC_SLIDER, GetTip(), mMaxValue, mMinValue, mStyle, mTipTemplate, PAN_SLIDER, SPEED_SLIDER, and VEL_SLIDER.

Referenced by CreatePopWin().

899 {
900  wxArrayString results;
901 
902  if (mTipTemplate.IsEmpty())
903  {
904  wxString val;
905 
906  switch(mStyle)
907  {
908  case FRAC_SLIDER:
909  results.push_back( GetTip( -1.99f ) );
910  break;
911 
912  case DB_SLIDER:
913  results.push_back( GetTip( -99.9f ) );
914  break;
915 
916  case PAN_SLIDER:
917  // Don't assume we know which of "Left", "Right", or "Center"
918  // is the longest string, when localized
919  results.push_back( GetTip( 0.f ) );
920  results.push_back( GetTip( 1.f ) );
921  results.push_back( GetTip( -1.f ) );
922  break;
923 
924  case SPEED_SLIDER:
925  results.push_back( GetTip( 9.99f ) );
926  break;
927 
928 #ifdef EXPERIMENTAL_MIDI_OUT
929  case VEL_SLIDER:
930  results.push_back( GetTip( 999.f ) );
931  break;
932 #endif
933  }
934  }
935  else
936  {
937  results.push_back( GetTip( floor(mMaxValue - mMinValue) + 0.999 ) );
938  }
939 
940  return results;
941 }
float mMinValue
Definition: ASlider.h:214
float mMaxValue
Definition: ASlider.h:215
#define SPEED_SLIDER
Definition: ASlider.h:47
int mStyle
Definition: ASlider.h:181
#define PAN_SLIDER
Definition: ASlider.h:46
wxString mTipTemplate
Definition: ASlider.h:232
#define DB_SLIDER
Definition: ASlider.h:45
#define VEL_SLIDER
Definition: ASlider.h:49
wxString GetTip(float value) const
Definition: ASlider.cpp:836
#define FRAC_SLIDER
Definition: ASlider.h:44
void LWSlider::Increase ( float  steps)

Definition at line 1338 of file ASlider.cpp.

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

Referenced by OnKeyEvent(), OnMouseEvent(), AudacityProject::OnTrackGainInc(), and AudacityProject::OnTrackPanRight().

1339 {
1340  float stepValue = mStepValue;
1341 
1342  if ( stepValue == 0.0 )
1343  {
1344  stepValue = ( mMaxValue - mMinValue ) / 10.0;
1345  }
1346 
1347  mCurrentValue += ( steps * stepValue );
1348 
1349  if ( mCurrentValue < mMinValue )
1350  {
1352  }
1353  else if ( mCurrentValue > mMaxValue )
1354  {
1356  }
1357 
1358  Refresh();
1359 }
float mMinValue
Definition: ASlider.h:214
float mMaxValue
Definition: ASlider.h:215
float mCurrentValue
Definition: ASlider.h:222
void Refresh()
Definition: ASlider.cpp:1384
float mStepValue
Definition: ASlider.h:216
void LWSlider::Init ( wxWindow *  parent,
const wxString &  name,
const wxPoint &  pos,
const wxSize &  size,
float  minValue,
float  maxValue,
float  stepValue,
bool  canUseShift,
int  style,
bool  heavyweight,
bool  popup,
float  speed,
int  orientation = wxHORIZONTAL 
)

Definition at line 429 of file ASlider.cpp.

References AdjustSize(), mBitmap, mCanUseShift, mCurrentValue, mDefaultShortcut, mDefaultValue, mEnabled, mHW, mID, mIsDragging, mMaxValue, mMinValue, mName, mOrientation, Move(), mParent, mPopup, mScrollLine, mScrollPage, mSpeed, mStepValue, mStyle, mThumbBitmap, mThumbBitmapHilited, mTipPanel, and name.

Referenced by LWSlider().

442 {
443  mEnabled = true;
444  mName = name;
445  mStyle = style;
446  mOrientation = orientation;
447  mIsDragging = false;
448  mParent = parent;
449  mHW = heavyweight;
450  mPopup = popup;
451  mSpeed = speed;
452  mID = wxID_ANY;
453  mMinValue = minValue;
454  mMaxValue = maxValue;
455  mStepValue = stepValue;
456  mCanUseShift = canUseShift;
457  mCurrentValue = 0.0f;
458  mDefaultValue = 0.0f;
459  mDefaultShortcut = false;
460  mBitmap = nullptr;
461  mThumbBitmap = nullptr;
462  mThumbBitmapHilited = nullptr;
463  mScrollLine = 1.0f;
464  mScrollPage = 5.0f;
465  mTipPanel = NULL;
466 
467  AdjustSize(size);
468 
469  Move(pos);
470 }
float mMinValue
Definition: ASlider.h:214
wxWindow * mParent
Definition: ASlider.h:179
std::unique_ptr< wxBitmap > mBitmap
Definition: ASlider.h:236
float mMaxValue
Definition: ASlider.h:215
float mScrollPage
Definition: ASlider.h:220
bool mDefaultShortcut
Definition: ASlider.h:224
wxWindowID mID
Definition: ASlider.h:229
float mSpeed
Definition: ASlider.h:217
int mStyle
Definition: ASlider.h:181
void Move(const wxPoint &newpos)
Definition: ASlider.cpp:509
bool mHW
Definition: ASlider.h:184
bool mCanUseShift
Definition: ASlider.h:227
std::unique_ptr< wxBitmap > mThumbBitmap
Definition: ASlider.h:236
float mCurrentValue
Definition: ASlider.h:222
std::unique_ptr< TipPanel > mTipPanel
Definition: ASlider.h:231
bool mEnabled
Definition: ASlider.h:240
float mDefaultValue
Definition: ASlider.h:225
std::unique_ptr< wxBitmap > mThumbBitmapHilited
Definition: ASlider.h:236
const wxChar * name
Definition: Distortion.cpp:94
bool mIsDragging
Definition: ASlider.h:234
wxString mName
Definition: ASlider.h:238
bool mPopup
Definition: ASlider.h:185
float mScrollLine
Definition: ASlider.h:219
void AdjustSize(const wxSize &sz)
Definition: ASlider.cpp:515
int mOrientation
Definition: ASlider.h:182
float mStepValue
Definition: ASlider.h:216
void LWSlider::Move ( const wxPoint &  newpos)

Definition at line 509 of file ASlider.cpp.

References mLeft, and mTop.

Referenced by Init().

510 {
511  mLeft = newpos.x;
512  mTop = newpos.y;
513 }
int mTop
Definition: ASlider.h:188
int mLeft
Definition: ASlider.h:187
void LWSlider::OnKeyEvent ( wxKeyEvent &  event)

Definition at line 1141 of file ASlider.cpp.

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

1142 {
1143  if (mEnabled)
1144  {
1145  switch( event.GetKeyCode() )
1146  {
1147  case WXK_TAB:
1148  mParent->Navigate(event.ShiftDown()
1149  ? wxNavigationKeyEvent::IsBackward
1150  : wxNavigationKeyEvent::IsForward);
1151  break;
1152 
1153  case WXK_RIGHT:
1154  case WXK_UP:
1155  Increase( mScrollLine );
1157  break;
1158 
1159  case WXK_LEFT:
1160  case WXK_DOWN:
1161  Decrease( mScrollLine );
1163  break;
1164 
1165  case WXK_PAGEUP:
1166  Increase( mScrollPage );
1168  break;
1169 
1170  case WXK_PAGEDOWN:
1171  Decrease( mScrollPage );
1173  break;
1174 
1175  case WXK_HOME:
1176  SendUpdate( mMinValue );
1177  break;
1178 
1179  case WXK_END:
1180  SendUpdate( mMaxValue );
1181  break;
1182 
1183  case WXK_RETURN:
1184  case WXK_NUMPAD_ENTER:
1185  {
1186  wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(mParent), wxTopLevelWindow);
1187  wxWindow *def = tlw->GetDefaultItem();
1188  if (def && def->IsEnabled()) {
1189  wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
1190  def->GetId());
1191  mParent->GetEventHandler()->ProcessEvent(cevent);
1192  }
1193  }
1194 
1195  default:
1196  // Allow it to propagate
1197  event.Skip();
1198  break;
1199  }
1200  }
1201  else
1202  {
1203  event.Skip();
1204  }
1205 }
float mMinValue
Definition: ASlider.h:214
wxWindow * mParent
Definition: ASlider.h:179
void Decrease(float steps)
Definition: ASlider.cpp:1361
void Increase(float steps)
Definition: ASlider.cpp:1338
float mMaxValue
Definition: ASlider.h:215
float mScrollPage
Definition: ASlider.h:220
void SendUpdate(float newValue)
Definition: ASlider.cpp:1207
float mCurrentValue
Definition: ASlider.h:222
bool mEnabled
Definition: ASlider.h:240
float mScrollLine
Definition: ASlider.h:219
void LWSlider::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 984 of file ASlider.cpp.

References ClickPositionToValue(), Decrease(), DoShowDialog(), DragPositionToValue(), GetActiveProject(), GetTip(), Increase(), mCenterX, mCenterY, mClickPos, mClickValue, mCurrentValue, mDefaultShortcut, mDefaultValue, mEnabled, mIsDragging, mLeft, mOrientation, mParent, mPopup, mThumbHeight, mThumbWidth, mTop, Refresh(), SendUpdate(), ShowTip(), AudacityProject::TP_DisplayStatusMessage(), and ValueToPosition().

Referenced by SliderHandle::Cancel().

985 {
986  if (event.Entering())
987  {
988  // Display the tooltip in the status bar
989  wxString tip = GetTip(mCurrentValue);
991  Refresh();
992  }
993  else if (event.Leaving())
994  {
995  if (!mIsDragging)
996  {
997  ShowTip(false);
998  }
1000  Refresh();
1001  }
1002 
1003  // Events other than mouse-overs are ignored when we are disabled
1004  if (!mEnabled)
1005  return;
1006 
1007  // Windows sends a right button mouse event when you press the context menu
1008  // key, so ignore it.
1009  if ((event.RightDown() && !event.RightIsDown()) ||
1010  (event.RightUp() && event.GetPosition() == wxPoint(-1, -1)))
1011  {
1012  event.Skip(false);
1013  return;
1014  }
1015 
1016  float prevValue = mCurrentValue;
1017 
1018  // Figure out the thumb position
1019  wxRect r;
1020  if (mOrientation == wxHORIZONTAL)
1021  {
1023  r.y = mTop + (mCenterY - (mThumbHeight / 2));
1024  }
1025  else
1026  {
1027  r.x = mLeft + (mCenterX - (mThumbWidth / 2));
1029  }
1030  r.width = mThumbWidth;
1031  r.height = mThumbHeight;
1032 
1033  wxRect tolerantThumbRect = r;
1034  tolerantThumbRect.Inflate(3, 3);
1035 
1036  // Should probably use a right click instead/also
1037  if( event.ButtonDClick() && mPopup )
1038  {
1039  //On a double-click, we should pop up a dialog.
1040  DoShowDialog(mParent->ClientToScreen(wxPoint(event.m_x,event.m_y)));
1041  }
1042  else if( event.ButtonDown() )
1043  {
1044  if( mDefaultShortcut && event.ControlDown() )
1045  {
1047  }
1048 
1049  if( event.RightDown() ) {
1050  mParent->SetFocus();
1051  }
1052 
1053  // Thumb clicked?
1054  //
1055  // Do not change position until first drag. This helps
1056  // with unintended value changes.
1057  if( tolerantThumbRect.Contains( event.GetPosition() ) )
1058  {
1059  // Remember mouse position and current value
1060  mClickPos = (mOrientation == wxHORIZONTAL) ? event.m_x : event.m_y;
1062 
1063  mIsDragging = true;
1064  }
1065  // Clicked to set location?
1066  else
1067  {
1068  mCurrentValue =
1070  (mOrientation == wxHORIZONTAL) ? event.m_x : event.m_y,
1071  event.ShiftDown());
1072  }
1073 
1074  if (!mParent->HasCapture()) {
1075  mParent->CaptureMouse();
1076  }
1077 
1078  ShowTip(true);
1079  }
1080  else if( event.ButtonUp() )
1081  {
1082  mIsDragging = false;
1083  if (mParent->HasCapture())
1084  mParent->ReleaseMouse();
1085 
1086  ShowTip(false);
1087  }
1088  else if (event.Dragging() && mIsDragging)
1089  {
1090  if (mOrientation == wxHORIZONTAL)
1091  {
1092  if (event.m_y < (r.y - 2 * r.height) ||
1093  event.m_y > (r.y + 3 * r.height)) {
1094  // If the mouse y coordinate is relatively far from the slider,
1095  // snap back to the original position
1097  }
1098  else {
1099  // Otherwise, move the slider to the right position based
1100  // on the mouse position
1101  mCurrentValue = DragPositionToValue(event.m_x, event.ShiftDown());
1102  }
1103  }
1104  else // (mOrientation == wxVERTICAL)
1105  {
1106  if (event.m_x < (r.x - 2 * r.width) ||
1107  event.m_x > (r.x + 3 * r.width)) {
1108  // If the mouse x coordinate is relatively far from the slider,
1109  // snap back to the original position
1111  }
1112  else {
1113  // Otherwise, move the slider to the right position based
1114  // on the mouse position
1115  mCurrentValue = DragPositionToValue(event.m_y, event.ShiftDown());
1116  }
1117  }
1118  }
1119  else if( event.m_wheelRotation != 0 )
1120  {
1121  //Calculate the number of steps in a given direction this event
1122  //represents (allows for two or more clicks on a single event.)
1123  double steps = event.m_wheelRotation /
1124  (event.m_wheelDelta > 0 ? (double)event.m_wheelDelta : 120.0);
1125 
1126  if( steps < 0.0 )
1127  {
1128  Decrease( (float)-steps );
1129  }
1130  else
1131  {
1132  Increase( (float)steps );
1133  }
1135  }
1136 
1137  if( prevValue != mCurrentValue )
1139 }
wxWindow * mParent
Definition: ASlider.h:179
void Decrease(float steps)
Definition: ASlider.cpp:1361
int mClickPos
Definition: ASlider.h:212
void Increase(float steps)
Definition: ASlider.cpp:1338
void ShowTip(bool show)
Definition: ASlider.cpp:769
bool mDefaultShortcut
Definition: ASlider.h:224
void SendUpdate(float newValue)
Definition: ASlider.cpp:1207
float DragPositionToValue(int fromPos, bool shiftDown)
Definition: ASlider.cpp:1283
int mCenterY
Definition: ASlider.h:194
float mCurrentValue
Definition: ASlider.h:222
int ValueToPosition(float val)
Definition: ASlider.cpp:1222
bool mEnabled
Definition: ASlider.h:240
void Refresh()
Definition: ASlider.cpp:1384
float mDefaultValue
Definition: ASlider.h:225
void TP_DisplayStatusMessage(const wxString &msg) override
Definition: Project.cpp:5356
float mClickValue
Definition: ASlider.h:211
int mThumbHeight
Definition: ASlider.h:209
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
bool mIsDragging
Definition: ASlider.h:234
bool mPopup
Definition: ASlider.h:185
float ClickPositionToValue(int fromPos, bool shiftDown)
Definition: ASlider.cpp:1239
int mOrientation
Definition: ASlider.h:182
wxString GetTip(float value) const
Definition: ASlider.cpp:836
int mCenterX
Definition: ASlider.h:201
int mTop
Definition: ASlider.h:188
bool DoShowDialog(wxPoint pos)
Definition: ASlider.cpp:953
int mThumbWidth
Definition: ASlider.h:208
int mLeft
Definition: ASlider.h:187
void LWSlider::OnPaint ( wxDC &  dc,
bool  highlighted 
)

Definition at line 551 of file ASlider.cpp.

References DrawToBitmap(), mBitmap, mCenterX, mCenterY, mCurrentValue, mHW, mLeft, mOrientation, mParent, mThumbBitmap, mThumbBitmapHilited, mThumbHeight, mThumbWidth, mTipPanel, mTop, and ValueToPosition().

552 {
553  // The dc will be a paint DC
555  {
556  DrawToBitmap(dc);
557  }
558 
559  //thumbPos should be in pixels
560  int thumbPos = ValueToPosition(mCurrentValue);
561  int thumbOrtho; // position in axis orthogonal to mOrientation
562  if (mOrientation == wxHORIZONTAL){
563  thumbOrtho = mCenterY - (mThumbHeight/2);
564  thumbPos += 1-mThumbWidth/2;
565  }
566  else{
567  thumbOrtho = mCenterX - (mThumbWidth/2);
568  thumbPos += 8-mThumbHeight/2;
569  }
570 
571  // Draw the background.
572  // If we are lightweight, this has already been done for us.
573  if( mHW ){
574  dc.SetBackground( wxBrush(mParent->GetBackgroundColour()) );
575  dc.Clear();
576  }
577 
578  dc.DrawBitmap(*mBitmap, mLeft, mTop, true);
579  const auto &thumbBitmap =
580  highlight ? *mThumbBitmapHilited : *mThumbBitmap;
581  if (mOrientation == wxHORIZONTAL)
582  {
583  dc.DrawBitmap(thumbBitmap, mLeft+thumbPos, mTop+thumbOrtho, true);
584  }
585  else
586  {
587  // TODO: Don't use pixel-count hack in positioning.
588  dc.DrawBitmap(thumbBitmap, mLeft+thumbOrtho-5, mTop+thumbPos, true);
589  }
590 
591  if (mTipPanel)
592  {
593  mTipPanel->Update();
594  }
595 }
wxWindow * mParent
Definition: ASlider.h:179
std::unique_ptr< wxBitmap > mBitmap
Definition: ASlider.h:236
void DrawToBitmap(wxDC &dc)
Definition: ASlider.cpp:606
int mCenterY
Definition: ASlider.h:194
bool mHW
Definition: ASlider.h:184
std::unique_ptr< wxBitmap > mThumbBitmap
Definition: ASlider.h:236
float mCurrentValue
Definition: ASlider.h:222
std::unique_ptr< TipPanel > mTipPanel
Definition: ASlider.h:231
int ValueToPosition(float val)
Definition: ASlider.cpp:1222
std::unique_ptr< wxBitmap > mThumbBitmapHilited
Definition: ASlider.h:236
int mThumbHeight
Definition: ASlider.h:209
int mOrientation
Definition: ASlider.h:182
int mCenterX
Definition: ASlider.h:201
int mTop
Definition: ASlider.h:188
int mThumbWidth
Definition: ASlider.h:208
int mLeft
Definition: ASlider.h:187
void LWSlider::OnSize ( wxSizeEvent &  event)

Definition at line 597 of file ASlider.cpp.

References AdjustSize(), and Refresh().

598 {
599  AdjustSize(event.GetSize());
600 
601  Refresh();
602 }
void Refresh()
Definition: ASlider.cpp:1384
void AdjustSize(const wxSize &sz)
Definition: ASlider.cpp:515
void LWSlider::Refresh ( )

Definition at line 1384 of file ASlider.cpp.

References mHW, and mParent.

Referenced by AdjustSize(), Decrease(), Increase(), OnMouseEvent(), OnSize(), SendUpdate(), Set(), and SetEnabled().

1385 {
1386  if (mHW)
1387  mParent->Refresh(false);
1388 }
wxWindow * mParent
Definition: ASlider.h:179
bool mHW
Definition: ASlider.h:184
void LWSlider::SendUpdate ( float  newValue)
private

Definition at line 1207 of file ASlider.cpp.

References FormatPopWin(), mCurrentValue, mID, mMaxValue, mMinValue, mParent, and Refresh().

Referenced by OnKeyEvent(), and OnMouseEvent().

1208 {
1209  mCurrentValue = newValue;
1210 
1211  FormatPopWin();
1212 
1213  Refresh();
1214 
1215  wxCommandEvent e( wxEVT_COMMAND_SLIDER_UPDATED, mID );
1216  int intValue = (int)( ( mCurrentValue - mMinValue ) * 1000.0f /
1217  ( mMaxValue - mMinValue ) );
1218  e.SetInt( intValue );
1219  mParent->GetEventHandler()->ProcessEvent(e);
1220 }
wxWindow * mParent
Definition: ASlider.h:179
float mMinValue
Definition: ASlider.h:214
float mMaxValue
Definition: ASlider.h:215
void FormatPopWin()
Definition: ASlider.cpp:825
wxWindowID mID
Definition: ASlider.h:229
float mCurrentValue
Definition: ASlider.h:222
void Refresh()
Definition: ASlider.cpp:1384
void LWSlider::Set ( float  value)

Definition at line 1321 of file ASlider.cpp.

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

1322 {
1323  if (mIsDragging)
1324  return;
1325  if (mStyle == DB_SLIDER)
1326  mCurrentValue = LINEAR_TO_DB(value);
1327  else
1328  mCurrentValue = value;
1329 
1330  if (mCurrentValue < mMinValue)
1332  if (mCurrentValue > mMaxValue)
1334 
1335  Refresh();
1336 }
float mMinValue
Definition: ASlider.h:214
float mMaxValue
Definition: ASlider.h:215
int mStyle
Definition: ASlider.h:181
float mCurrentValue
Definition: ASlider.h:222
void Refresh()
Definition: ASlider.cpp:1384
#define DB_SLIDER
Definition: ASlider.h:45
#define LINEAR_TO_DB(x)
Definition: Audacity.h:217
bool mIsDragging
Definition: ASlider.h:234
void LWSlider::SetDefaultShortcut ( bool  value)

Definition at line 492 of file ASlider.cpp.

References mDefaultShortcut.

Referenced by SetDefaultValue().

493 {
494  mDefaultShortcut = value;
495 }
bool mDefaultShortcut
Definition: ASlider.h:224
void LWSlider::SetDefaultValue ( float  value)

Definition at line 486 of file ASlider.cpp.

References mDefaultValue, and SetDefaultShortcut().

487 {
488  SetDefaultShortcut(true);
489  mDefaultValue = value;
490 }
float mDefaultValue
Definition: ASlider.h:225
void SetDefaultShortcut(bool value)
Definition: ASlider.cpp:492
void LWSlider::SetEnabled ( bool  enabled)

Definition at line 1395 of file ASlider.cpp.

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

1396 {
1397  mEnabled = enabled;
1398 
1399  mThumbBitmap.reset();
1400  mThumbBitmapHilited.reset();
1401 
1402  Refresh();
1403 }
std::unique_ptr< wxBitmap > mThumbBitmap
Definition: ASlider.h:236
bool mEnabled
Definition: ASlider.h:240
void Refresh()
Definition: ASlider.cpp:1384
std::unique_ptr< wxBitmap > mThumbBitmapHilited
Definition: ASlider.h:236
void LWSlider::SetId ( wxWindowID  id)

Definition at line 481 of file ASlider.cpp.

References mID.

482 {
483  mID = id;
484 }
wxWindowID mID
Definition: ASlider.h:229
void LWSlider::SetParent ( wxWindow *  parent)
inline

Definition at line 160 of file ASlider.h.

References mParent.

160 { mParent = parent; }
wxWindow * mParent
Definition: ASlider.h:179
void LWSlider::SetPopWinPosition ( )
private

Definition at line 803 of file ASlider.cpp.

References mHeight, mLeft, mOrientation, mParent, mTipPanel, mTop, and mWidth.

Referenced by ShowTip().

804 {
805  if (mTipPanel)
806  {
807  wxSize sz = mTipPanel->GetSize();
808  wxPoint pt;
809 
810  if (mOrientation == wxHORIZONTAL)
811  {
812  pt.x = mLeft + ((mWidth - sz.x) / 2);
813  pt.y = mTop + mHeight + 1;
814  }
815  else
816  {
817  pt.x = mLeft + mWidth + 1;
818  pt.y = mTop + ((mHeight - sz.y) / 2);
819  }
820 
821  mTipPanel->SetPos(mParent->ClientToScreen(pt));
822  }
823 }
wxWindow * mParent
Definition: ASlider.h:179
int mWidth
Definition: ASlider.h:190
int mHeight
Definition: ASlider.h:191
std::unique_ptr< TipPanel > mTipPanel
Definition: ASlider.h:231
int mOrientation
Definition: ASlider.h:182
int mTop
Definition: ASlider.h:188
int mLeft
Definition: ASlider.h:187
void LWSlider::SetScroll ( float  line,
float  page 
)

Definition at line 503 of file ASlider.cpp.

References mScrollLine, and mScrollPage.

504 {
505  mScrollLine = line;
506  mScrollPage = page;
507 }
float mScrollPage
Definition: ASlider.h:220
float mScrollLine
Definition: ASlider.h:219
void LWSlider::SetSpeed ( float  speed)

Definition at line 1232 of file ASlider.cpp.

References mSpeed.

1233 {
1234  mSpeed = speed;
1235 }
float mSpeed
Definition: ASlider.h:217
void LWSlider::SetToolTipTemplate ( const wxString &  tip)

Definition at line 764 of file ASlider.cpp.

References mTipTemplate.

765 {
766  mTipTemplate = tip;
767 }
wxString mTipTemplate
Definition: ASlider.h:232
bool LWSlider::ShowDialog ( )

Definition at line 943 of file ASlider.cpp.

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

Referenced by AudacityProject::OnTrackGain(), and AudacityProject::OnTrackPan().

944 {
945  return DoShowDialog( mParent->ClientToScreen(wxPoint( mLeft, mTop ) ) );
946 }
wxWindow * mParent
Definition: ASlider.h:179
int mTop
Definition: ASlider.h:188
bool DoShowDialog(wxPoint pos)
Definition: ASlider.cpp:953
int mLeft
Definition: ASlider.h:187
bool LWSlider::ShowDialog ( wxPoint  pos)

Definition at line 948 of file ASlider.cpp.

References DoShowDialog().

949 {
950  return DoShowDialog( pos );
951 }
bool DoShowDialog(wxPoint pos)
Definition: ASlider.cpp:953
void LWSlider::ShowTip ( bool  show)

Definition at line 769 of file ASlider.cpp.

References CreatePopWin(), FormatPopWin(), mTipPanel, and SetPopWinPosition().

Referenced by OnMouseEvent().

770 {
771  if (show)
772  {
773  if (mTipPanel)
774  {
775  if (mTipPanel->IsShownOnScreen())
776  {
777  return;
778  }
779 
780  mTipPanel.reset();
781  }
782 
783  CreatePopWin();
784  FormatPopWin();
786  mTipPanel->ShowWithoutActivating();
787  }
788  else
789  {
790  if (mTipPanel)
791  {
792  mTipPanel->Hide();
793  mTipPanel.reset();
794  }
795  }
796 }
void FormatPopWin()
Definition: ASlider.cpp:825
void SetPopWinPosition()
Definition: ASlider.cpp:803
std::unique_ptr< TipPanel > mTipPanel
Definition: ASlider.h:231
void CreatePopWin()
Definition: ASlider.cpp:798
int LWSlider::ValueToPosition ( float  val)
private

Definition at line 1222 of file ASlider.cpp.

References mHeightY, mMaxValue, mMinValue, mOrientation, and mWidthX.

Referenced by OnMouseEvent(), and OnPaint().

1223 {
1224  float fRange = mMaxValue - mMinValue;
1225  if (mOrientation == wxHORIZONTAL)
1226  return (int)rint((val - mMinValue) * mWidthX / fRange);
1227  else
1228  // low values at bottom
1229  return (int)rint((mMaxValue - val) * mHeightY / fRange);
1230 }
float mMinValue
Definition: ASlider.h:214
float mMaxValue
Definition: ASlider.h:215
int mWidthX
Definition: ASlider.h:198
int mHeightY
Definition: ASlider.h:205
int mOrientation
Definition: ASlider.h:182

Friends And Related Function Documentation

friend class ASlider
friend

Definition at line 75 of file ASlider.h.

friend class ASliderAx
friend

Definition at line 76 of file ASlider.h.

Member Data Documentation

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

Definition at line 236 of file ASlider.h.

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

int LWSlider::mBottomY
private

Definition at line 204 of file ASlider.h.

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

bool LWSlider::mCanUseShift
private

Definition at line 227 of file ASlider.h.

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

int LWSlider::mCenterX
private

Definition at line 201 of file ASlider.h.

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

int LWSlider::mCenterY
private

Definition at line 194 of file ASlider.h.

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

int LWSlider::mClickPos
private

Definition at line 212 of file ASlider.h.

Referenced by DragPositionToValue(), and OnMouseEvent().

float LWSlider::mClickValue
private

Definition at line 211 of file ASlider.h.

Referenced by DragPositionToValue(), and OnMouseEvent().

float LWSlider::mCurrentValue
private
bool LWSlider::mDefaultShortcut
private

Definition at line 224 of file ASlider.h.

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

float LWSlider::mDefaultValue
private

Definition at line 225 of file ASlider.h.

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

bool LWSlider::mEnabled
private

Definition at line 240 of file ASlider.h.

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

int LWSlider::mHeight
private

Definition at line 191 of file ASlider.h.

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

int LWSlider::mHeightY
private
bool LWSlider::mHW
private

Definition at line 184 of file ASlider.h.

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

wxWindowID LWSlider::mID
private

Definition at line 229 of file ASlider.h.

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

bool LWSlider::mIsDragging
private

Definition at line 234 of file ASlider.h.

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

int LWSlider::mLeft
private
int LWSlider::mLeftX
private

Definition at line 196 of file ASlider.h.

Referenced by AdjustSize(), and DrawToBitmap().

float LWSlider::mMaxValue
private
float LWSlider::mMinValue
private
wxString LWSlider::mName
private

Definition at line 238 of file ASlider.h.

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

int LWSlider::mOrientation
private
wxWindow* LWSlider::mParent
private
bool LWSlider::mPopup
private

Definition at line 185 of file ASlider.h.

Referenced by Init(), and OnMouseEvent().

int LWSlider::mRightX
private

Definition at line 197 of file ASlider.h.

Referenced by AdjustSize(), and DrawToBitmap().

float LWSlider::mScrollLine
private

Definition at line 219 of file ASlider.h.

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

float LWSlider::mScrollPage
private

Definition at line 220 of file ASlider.h.

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

float LWSlider::mSpeed
private

Definition at line 217 of file ASlider.h.

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

float LWSlider::mStepValue
private

Definition at line 216 of file ASlider.h.

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

int LWSlider::mStyle
private

Definition at line 181 of file ASlider.h.

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

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

Definition at line 236 of file ASlider.h.

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

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

Definition at line 236 of file ASlider.h.

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

int LWSlider::mThumbHeight
private

Definition at line 209 of file ASlider.h.

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

int LWSlider::mThumbWidth
private

Definition at line 208 of file ASlider.h.

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

std::unique_ptr<TipPanel> LWSlider::mTipPanel
private

Definition at line 231 of file ASlider.h.

Referenced by CreatePopWin(), FormatPopWin(), Init(), OnPaint(), SetPopWinPosition(), and ShowTip().

wxString LWSlider::mTipTemplate
private

Definition at line 232 of file ASlider.h.

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

int LWSlider::mTop
private

Definition at line 188 of file ASlider.h.

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

int LWSlider::mTopY
private

Definition at line 203 of file ASlider.h.

Referenced by AdjustSize(), and DrawToBitmap().

int LWSlider::mWidth
private

Definition at line 190 of file ASlider.h.

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

int LWSlider::mWidthX
private

The documentation for this class was generated from the following files: