mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 17:30:17 +01:00
Play at speed pop-up dialog changes speed dynamically too.
In fact all the slider pop up dialogs now dynamically change their parent's value.
This commit is contained in:
@@ -191,11 +191,13 @@ SliderDialog::SliderDialog(wxWindow * parent, wxWindowID id,
|
|||||||
int style,
|
int style,
|
||||||
float value,
|
float value,
|
||||||
float line,
|
float line,
|
||||||
float page):
|
float page,
|
||||||
|
LWSlider * pSource):
|
||||||
wxDialogWrapper(parent,id,title,position),
|
wxDialogWrapper(parent,id,title,position),
|
||||||
mStyle(style)
|
mStyle(style)
|
||||||
{
|
{
|
||||||
SetName(GetTitle());
|
SetName(GetTitle());
|
||||||
|
mpOrigin = pSource;
|
||||||
ShuttleGui S(this, eIsCreating);
|
ShuttleGui S(this, eIsCreating);
|
||||||
|
|
||||||
S.StartVerticalLay();
|
S.StartVerticalLay();
|
||||||
@@ -229,8 +231,13 @@ SliderDialog::~SliderDialog()
|
|||||||
|
|
||||||
bool SliderDialog::TransferDataToWindow()
|
bool SliderDialog::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
mTextCtrl->SetValue(wxString::Format(wxT("%g"), mSlider->Get(false)));
|
float value = mSlider->Get(false);
|
||||||
|
mTextCtrl->SetValue(wxString::Format(wxT("%g"), value));
|
||||||
mTextCtrl->SetSelection(-1, -1);
|
mTextCtrl->SetSelection(-1, -1);
|
||||||
|
if (mpOrigin) {
|
||||||
|
mpOrigin->Set(value);
|
||||||
|
mpOrigin->SendUpdate(value);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -243,7 +250,10 @@ bool SliderDialog::TransferDataFromWindow()
|
|||||||
if (mStyle == DB_SLIDER)
|
if (mStyle == DB_SLIDER)
|
||||||
value = DB_TO_LINEAR(value);
|
value = DB_TO_LINEAR(value);
|
||||||
mSlider->Set(value);
|
mSlider->Set(value);
|
||||||
|
if (mpOrigin) {
|
||||||
|
mpOrigin->Set(value);
|
||||||
|
mpOrigin->SendUpdate(value);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -952,7 +962,7 @@ bool LWSlider::ShowDialog(wxPoint pos)
|
|||||||
|
|
||||||
bool LWSlider::DoShowDialog(wxPoint pos)
|
bool LWSlider::DoShowDialog(wxPoint pos)
|
||||||
{
|
{
|
||||||
float value;
|
float value = mCurrentValue;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
SliderDialog dlg( NULL,
|
SliderDialog dlg( NULL,
|
||||||
@@ -963,21 +973,27 @@ bool LWSlider::DoShowDialog(wxPoint pos)
|
|||||||
mStyle,
|
mStyle,
|
||||||
Get(),
|
Get(),
|
||||||
mScrollLine,
|
mScrollLine,
|
||||||
mScrollPage);
|
mScrollPage,
|
||||||
|
this);
|
||||||
if (pos == wxPoint(-1, -1)) {
|
if (pos == wxPoint(-1, -1)) {
|
||||||
dlg.Center();
|
dlg.Center();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_OK )
|
float initialValue = mCurrentValue;
|
||||||
{
|
|
||||||
value = dlg.Get();
|
|
||||||
if( value != mCurrentValue )
|
|
||||||
{
|
|
||||||
mCurrentValue = value;
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
changed = (dlg.ShowModal() == wxID_OK);
|
||||||
|
if( changed )
|
||||||
|
value = dlg.Get();
|
||||||
|
|
||||||
|
// We now expect the pop up dialog to be
|
||||||
|
// sending updates as we go.
|
||||||
|
// So this code is needed to possibly restore the old
|
||||||
|
// value, on a cancel.
|
||||||
|
if (mCurrentValue != value) {
|
||||||
|
mCurrentValue = value;
|
||||||
|
SendUpdate(value);
|
||||||
|
}
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ class LWSlider
|
|||||||
static void DeleteSharedTipPanel();
|
static void DeleteSharedTipPanel();
|
||||||
|
|
||||||
void SetParent(wxWindow *parent) { mParent = parent; }
|
void SetParent(wxWindow *parent) { mParent = parent; }
|
||||||
|
void SendUpdate(float newValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -170,7 +171,6 @@ class LWSlider
|
|||||||
|
|
||||||
bool DoShowDialog(wxPoint pos);
|
bool DoShowDialog(wxPoint pos);
|
||||||
|
|
||||||
void SendUpdate( float newValue );
|
|
||||||
|
|
||||||
int ValueToPosition(float val);
|
int ValueToPosition(float val);
|
||||||
float DragPositionToValue(int fromPos, bool shiftDown);
|
float DragPositionToValue(int fromPos, bool shiftDown);
|
||||||
@@ -348,7 +348,8 @@ class SliderDialog final : public wxDialogWrapper
|
|||||||
int style,
|
int style,
|
||||||
float value,
|
float value,
|
||||||
float line,
|
float line,
|
||||||
float page);
|
float page,
|
||||||
|
LWSlider * pSlider=nullptr);
|
||||||
~SliderDialog();
|
~SliderDialog();
|
||||||
|
|
||||||
float Get();
|
float Get();
|
||||||
@@ -363,6 +364,7 @@ class SliderDialog final : public wxDialogWrapper
|
|||||||
ASlider * mSlider;
|
ASlider * mSlider;
|
||||||
wxTextCtrl * mTextCtrl;
|
wxTextCtrl * mTextCtrl;
|
||||||
int mStyle;
|
int mStyle;
|
||||||
|
LWSlider * mpOrigin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|||||||
Reference in New Issue
Block a user