mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-09 06:07:06 +01:00
Options for constructing ASlider, and can specify scroll increments
This commit is contained in:
@@ -62,13 +62,8 @@ MixerTrackSlider::MixerTrackSlider(wxWindow * parent,
|
|||||||
const wxString &name,
|
const wxString &name,
|
||||||
const wxPoint & pos,
|
const wxPoint & pos,
|
||||||
const wxSize & size,
|
const wxSize & size,
|
||||||
int style /*= FRAC_SLIDER*/,
|
const ASlider::Options &options)
|
||||||
bool popup /*= true*/,
|
: ASlider(parent, id, name, pos, size, options)
|
||||||
bool canUseShift /*= true*/,
|
|
||||||
float stepValue /*= STEP_CONTINUOUS*/,
|
|
||||||
int orientation /*= wxHORIZONTAL*/)
|
|
||||||
: ASlider(parent, id, name, pos, size,
|
|
||||||
style, popup, canUseShift, stepValue, orientation)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,8 +204,10 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
|
|||||||
this, ID_SLIDER_GAIN,
|
this, ID_SLIDER_GAIN,
|
||||||
/* i18n-hint: title of the Gain slider, used to adjust the volume */
|
/* i18n-hint: title of the Gain slider, used to adjust the volume */
|
||||||
_("Gain"),
|
_("Gain"),
|
||||||
ctrlPos, ctrlSize, DB_SLIDER, true,
|
ctrlPos, ctrlSize,
|
||||||
true, 0.0, wxVERTICAL);
|
ASlider::Options{}
|
||||||
|
.Style( DB_SLIDER )
|
||||||
|
.Orientation( wxVERTICAL ));
|
||||||
mSlider_Gain->SetName(_("Gain"));
|
mSlider_Gain->SetName(_("Gain"));
|
||||||
this->UpdateGain();
|
this->UpdateGain();
|
||||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||||
@@ -219,8 +216,10 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
|
|||||||
this, ID_SLIDER_VELOCITY,
|
this, ID_SLIDER_VELOCITY,
|
||||||
/* i18n-hint: title of the MIDI Velocity slider */
|
/* i18n-hint: title of the MIDI Velocity slider */
|
||||||
_("Velocity"),
|
_("Velocity"),
|
||||||
ctrlPos, ctrlSize, VEL_SLIDER, true,
|
ctrlPos, ctrlSize,
|
||||||
true, 0.0, wxVERTICAL);
|
ASlider::Options{}
|
||||||
|
.Style( VEL_SLIDER )
|
||||||
|
.Orientation( wxVERTICAL ));
|
||||||
mSlider_Velocity->SetName(_("Velocity"));
|
mSlider_Velocity->SetName(_("Velocity"));
|
||||||
this->UpdateVelocity();
|
this->UpdateVelocity();
|
||||||
#endif
|
#endif
|
||||||
@@ -254,7 +253,8 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
|
|||||||
this, ID_SLIDER_PAN,
|
this, ID_SLIDER_PAN,
|
||||||
/* i18n-hint: Title of the Pan slider, used to move the sound left or right */
|
/* i18n-hint: Title of the Pan slider, used to move the sound left or right */
|
||||||
_("Pan"),
|
_("Pan"),
|
||||||
ctrlPos, ctrlSize, PAN_SLIDER, true);
|
ctrlPos, ctrlSize,
|
||||||
|
ASlider::Options{}.Style( PAN_SLIDER ));
|
||||||
mSlider_Pan->SetName(_("Pan"));
|
mSlider_Pan->SetName(_("Pan"));
|
||||||
|
|
||||||
this->UpdatePan();
|
this->UpdatePan();
|
||||||
|
|||||||
@@ -39,11 +39,7 @@ public:
|
|||||||
const wxString &name,
|
const wxString &name,
|
||||||
const wxPoint & pos,
|
const wxPoint & pos,
|
||||||
const wxSize & size,
|
const wxSize & size,
|
||||||
int style = FRAC_SLIDER,
|
const ASlider::Options &options = ASlider::Options{});
|
||||||
bool popup = true,
|
|
||||||
bool canUseShift = true,
|
|
||||||
float stepValue = STEP_CONTINUOUS,
|
|
||||||
int orientation = wxHORIZONTAL);
|
|
||||||
virtual ~MixerTrackSlider() {}
|
virtual ~MixerTrackSlider() {}
|
||||||
|
|
||||||
void OnMouseEvent(wxMouseEvent & event);
|
void OnMouseEvent(wxMouseEvent & event);
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ void MixerToolBar::Populate()
|
|||||||
wxID_ANY,
|
wxID_ANY,
|
||||||
theTheme.Bitmap(bmpMic)), 0, wxALIGN_CENTER);
|
theTheme.Bitmap(bmpMic)), 0, wxALIGN_CENTER);
|
||||||
mInputSlider = safenew ASlider(this, wxID_ANY, _("Recording Volume"),
|
mInputSlider = safenew ASlider(this, wxID_ANY, _("Recording Volume"),
|
||||||
wxDefaultPosition, wxSize(130, 25));
|
wxDefaultPosition, wxSize(130, 25),
|
||||||
mInputSlider->SetScroll(0.1f, 2.0f);
|
ASlider::Options{}.Line( 0.1f ).Page( 2.0f ));
|
||||||
mInputSlider->SetName(_("Slider Recording"));
|
mInputSlider->SetName(_("Slider Recording"));
|
||||||
Add(mInputSlider, 0, wxALIGN_CENTER);
|
Add(mInputSlider, 0, wxALIGN_CENTER);
|
||||||
|
|
||||||
@@ -88,8 +88,8 @@ void MixerToolBar::Populate()
|
|||||||
wxID_ANY,
|
wxID_ANY,
|
||||||
theTheme.Bitmap(bmpSpeaker)), 0, wxALIGN_CENTER);
|
theTheme.Bitmap(bmpSpeaker)), 0, wxALIGN_CENTER);
|
||||||
mOutputSlider = safenew ASlider(this, wxID_ANY, _("Playback Volume"),
|
mOutputSlider = safenew ASlider(this, wxID_ANY, _("Playback Volume"),
|
||||||
wxDefaultPosition, wxSize(130, 25));
|
wxDefaultPosition, wxSize(130, 25),
|
||||||
mOutputSlider->SetScroll(0.1f, 2.0f);
|
ASlider::Options{}.Line( 0.1f ).Page( 2.0f ));
|
||||||
mOutputSlider->SetName(_("Slider Playback"));
|
mOutputSlider->SetName(_("Slider Playback"));
|
||||||
Add(mOutputSlider, 0, wxALIGN_CENTER);
|
Add(mOutputSlider, 0, wxALIGN_CENTER);
|
||||||
|
|
||||||
|
|||||||
@@ -186,15 +186,18 @@ void TranscriptionToolBar::Populate()
|
|||||||
//Add a slider that controls the speed of playback.
|
//Add a slider that controls the speed of playback.
|
||||||
const int SliderWidth=100;
|
const int SliderWidth=100;
|
||||||
mPlaySpeedSlider = safenew ASlider(this,
|
mPlaySpeedSlider = safenew ASlider(this,
|
||||||
TTB_PlaySpeedSlider,
|
TTB_PlaySpeedSlider,
|
||||||
_("Playback Speed"),
|
_("Playback Speed"),
|
||||||
wxDefaultPosition,
|
wxDefaultPosition,
|
||||||
wxSize(SliderWidth,25),
|
wxSize(SliderWidth,25),
|
||||||
SPEED_SLIDER);
|
ASlider::Options{}
|
||||||
|
.Style( SPEED_SLIDER )
|
||||||
|
// 6 steps using page up/down, and 60 using arrow keys
|
||||||
|
.Line( 0.16667f )
|
||||||
|
.Page( 0.16667f )
|
||||||
|
);
|
||||||
mPlaySpeedSlider->Set(mPlaySpeed / 100.0);
|
mPlaySpeedSlider->Set(mPlaySpeed / 100.0);
|
||||||
mPlaySpeedSlider->SetLabel(_("Playback Speed"));
|
mPlaySpeedSlider->SetLabel(_("Playback Speed"));
|
||||||
// 6 steps using page up/down, and 60 using arrow keys
|
|
||||||
mPlaySpeedSlider->SetScroll(0.16667f, 1.6667f);
|
|
||||||
Add( mPlaySpeedSlider, 0, wxALIGN_CENTER );
|
Add( mPlaySpeedSlider, 0, wxALIGN_CENTER );
|
||||||
mPlaySpeedSlider->Connect(wxEVT_SET_FOCUS,
|
mPlaySpeedSlider->Connect(wxEVT_SET_FOCUS,
|
||||||
wxFocusEventHandler(TranscriptionToolBar::OnFocus),
|
wxFocusEventHandler(TranscriptionToolBar::OnFocus),
|
||||||
|
|||||||
@@ -215,9 +215,8 @@ SliderDialog::SliderDialog(wxWindow * parent, wxWindowID id,
|
|||||||
title,
|
title,
|
||||||
wxDefaultPosition,
|
wxDefaultPosition,
|
||||||
size,
|
size,
|
||||||
style,
|
ASlider::Options{}
|
||||||
false);
|
.Style( style ).Line( line ).Page( page ) );
|
||||||
mSlider->SetScroll(line, page);
|
|
||||||
S.AddWindow(mSlider, wxEXPAND);
|
S.AddWindow(mSlider, wxEXPAND);
|
||||||
}
|
}
|
||||||
S.EndVerticalLay();
|
S.EndVerticalLay();
|
||||||
@@ -1557,11 +1556,7 @@ ASlider::ASlider( wxWindow * parent,
|
|||||||
const wxString &name,
|
const wxString &name,
|
||||||
const wxPoint & pos,
|
const wxPoint & pos,
|
||||||
const wxSize & size,
|
const wxSize & size,
|
||||||
int style,
|
const Options &options)
|
||||||
bool popup,
|
|
||||||
bool canUseShift,
|
|
||||||
float stepValue,
|
|
||||||
int orientation /*= wxHORIZONTAL*/)
|
|
||||||
: wxPanel( parent, id, pos, size, wxWANTS_CHARS )
|
: wxPanel( parent, id, pos, size, wxWANTS_CHARS )
|
||||||
{
|
{
|
||||||
//wxColour Col(parent->GetBackgroundColour());
|
//wxColour Col(parent->GetBackgroundColour());
|
||||||
@@ -1571,23 +1566,25 @@ ASlider::ASlider( wxWindow * parent,
|
|||||||
name,
|
name,
|
||||||
wxPoint(0,0),
|
wxPoint(0,0),
|
||||||
size,
|
size,
|
||||||
style,
|
options.style,
|
||||||
canUseShift,
|
options.canUseShift,
|
||||||
popup,
|
options.popup,
|
||||||
orientation);
|
options.orientation);
|
||||||
mLWSlider->mStepValue = stepValue;
|
mLWSlider->mStepValue = options.stepValue;
|
||||||
mLWSlider->SetId( id );
|
mLWSlider->SetId( id );
|
||||||
SetName( name );
|
SetName( name );
|
||||||
|
|
||||||
mSliderIsFocused = false;
|
mSliderIsFocused = false;
|
||||||
|
|
||||||
mStyle = style;
|
mStyle = options.style;
|
||||||
|
|
||||||
mTimer.SetOwner(this);
|
mTimer.SetOwner(this);
|
||||||
|
|
||||||
#if wxUSE_ACCESSIBILITY
|
#if wxUSE_ACCESSIBILITY
|
||||||
SetAccessible( safenew ASliderAx( this ) );
|
SetAccessible( safenew ASliderAx( this ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
mLWSlider->SetScroll( options.line, options.page );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -244,16 +244,35 @@ class ASlider /* not final */ : public wxPanel
|
|||||||
friend class ASliderAx;
|
friend class ASliderAx;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
struct Options {
|
||||||
|
Options() {}
|
||||||
|
|
||||||
|
int style{ FRAC_SLIDER };
|
||||||
|
wxOrientation orientation{ wxHORIZONTAL };
|
||||||
|
bool popup{ true };
|
||||||
|
bool canUseShift{ true };
|
||||||
|
float stepValue{ STEP_CONTINUOUS };
|
||||||
|
|
||||||
|
float line{ 1.0 };
|
||||||
|
float page{ 5.0 };
|
||||||
|
|
||||||
|
Options& Style( int s ) { style = s; return *this; }
|
||||||
|
Options& Orientation( wxOrientation o )
|
||||||
|
{ orientation = o; return *this; }
|
||||||
|
Options& Popup( bool p ) { popup = p; return *this; }
|
||||||
|
Options& CanUseShift( bool c ) { canUseShift = c; return *this; }
|
||||||
|
Options& StepValue( float v ) { stepValue = v; return *this; }
|
||||||
|
|
||||||
|
Options& Line( float l ) { line = l; return *this; }
|
||||||
|
Options& Page( float p ) { page = p; return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
ASlider( wxWindow * parent,
|
ASlider( wxWindow * parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxString &name,
|
const wxString &name,
|
||||||
const wxPoint & pos,
|
const wxPoint & pos,
|
||||||
const wxSize & size,
|
const wxSize & size,
|
||||||
int style = FRAC_SLIDER,
|
const Options &options = Options{});
|
||||||
bool popup = true,
|
|
||||||
bool canUseShift = true,
|
|
||||||
float stepValue = STEP_CONTINUOUS,
|
|
||||||
int orientation = wxHORIZONTAL);
|
|
||||||
virtual ~ASlider();
|
virtual ~ASlider();
|
||||||
|
|
||||||
bool AcceptsFocus() const override { return s_AcceptsFocus; }
|
bool AcceptsFocus() const override { return s_AcceptsFocus; }
|
||||||
|
|||||||
Reference in New Issue
Block a user