Audacity  2.3.1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SliderDialog Class Referencefinal

Pop up dialog used with an LWSlider. More...

#include <ASlider.h>

Inheritance diagram for SliderDialog:
wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 SliderDialog (wxWindow *parent, wxWindowID id, const wxString &title, wxPoint position, wxSize size, int style, float value, float line, float page, LWSlider *pSlider=nullptr)
 
 ~SliderDialog ()
 
float Get ()
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
void OnSlider (wxCommandEvent &event)
 
void OnTextChange (wxCommandEvent &event)
 

Private Attributes

ASlidermSlider
 
wxTextCtrl * mTextCtrl
 
int mStyle
 
LWSlidermpOrigin
 

Detailed Description

Pop up dialog used with an LWSlider.

Definition at line 341 of file ASlider.h.

Constructor & Destructor Documentation

SliderDialog::SliderDialog ( wxWindow *  parent,
wxWindowID  id,
const wxString &  title,
wxPoint  position,
wxSize  size,
int  style,
float  value,
float  line,
float  page,
LWSlider pSlider = nullptr 
)

Definition at line 187 of file ASlider.cpp.

References ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddTextBox(), ShuttleGuiBase::AddWindow(), eCancelButton, eIsCreating, ShuttleGuiBase::EndVerticalLay(), eOkButton, ASlider::Options::Line(), ASlider::Options::Page(), safenew, ShuttleGuiBase::StartVerticalLay(), and ASlider::Options::Style().

195  :
196  wxDialogWrapper(parent,id,title,position),
197  mStyle(style)
198 {
199  SetName(GetTitle());
200  mpOrigin = pSource;
201  ShuttleGui S(this, eIsCreating);
202 
203  S.StartVerticalLay();
204  {
205  mTextCtrl = S.AddTextBox( {},
206  wxEmptyString,
207  15);
208  mTextCtrl->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
209 
210  mSlider = safenew ASlider(this,
211  wxID_ANY,
212  title,
213  wxDefaultPosition,
214  size,
216  .Style( style ).Line( line ).Page( page ) );
217  S.AddWindow(mSlider, wxEXPAND);
218  }
219  S.EndVerticalLay();
220 
221  S.AddStandardButtons(eOkButton | eCancelButton);
222 
223  Fit();
224 
225  mSlider->Set(value);
226 }
ASlider * mSlider
Definition: ASlider.h:364
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
int mStyle
Definition: ASlider.h:366
#define safenew
Definition: Audacity.h:230
Options & Page(float p)
Definition: ASlider.h:268
void Set(float value)
Definition: ASlider.cpp:1596
Options & Line(float l)
Definition: ASlider.h:267
wxTextCtrl * mTextCtrl
Definition: ASlider.h:365
LWSlider * mpOrigin
Definition: ASlider.h:367
ASlider is a custom slider, allowing for a slicker look and feel.
Definition: ASlider.h:243
Options & Style(int s)
Definition: ASlider.h:260
SliderDialog::~SliderDialog ( )

Definition at line 228 of file ASlider.cpp.

229 {
230 }

Member Function Documentation

float SliderDialog::Get ( )

Definition at line 272 of file ASlider.cpp.

References ASlider::Get(), and mSlider.

Referenced by LWSlider::DoShowDialog().

273 {
274  return mSlider->Get(false);
275 }
ASlider * mSlider
Definition: ASlider.h:364
float Get(bool convert=true)
Definition: ASlider.cpp:1591
void SliderDialog::OnSlider ( wxCommandEvent &  event)
private

Definition at line 260 of file ASlider.cpp.

References TransferDataToWindow().

261 {
263  event.Skip(false);
264 }
bool TransferDataToWindow() override
Definition: ASlider.cpp:232
void SliderDialog::OnTextChange ( wxCommandEvent &  event)
private

Definition at line 266 of file ASlider.cpp.

References TransferDataFromWindow().

267 {
269  event.Skip(false);
270 }
bool TransferDataFromWindow() override
Definition: ASlider.cpp:245
bool SliderDialog::TransferDataFromWindow ( )
overrideprivate

Definition at line 245 of file ASlider.cpp.

References DB_SLIDER, DB_TO_LINEAR(), mpOrigin, mSlider, mStyle, mTextCtrl, LWSlider::SendUpdate(), LWSlider::Set(), and ASlider::Set().

Referenced by OnTextChange().

246 {
247  double value;
248 
249  mTextCtrl->GetValue().ToDouble(&value);
250  if (mStyle == DB_SLIDER)
251  value = DB_TO_LINEAR(value);
252  mSlider->Set(value);
253  if (mpOrigin) {
254  mpOrigin->Set(value);
255  mpOrigin->SendUpdate(value);
256  }
257  return true;
258 }
ASlider * mSlider
Definition: ASlider.h:364
int mStyle
Definition: ASlider.h:366
void SendUpdate(float newValue)
Definition: ASlider.cpp:1231
void Set(float value)
Definition: ASlider.cpp:1345
void Set(float value)
Definition: ASlider.cpp:1596
wxTextCtrl * mTextCtrl
Definition: ASlider.h:365
#define DB_SLIDER
Definition: ASlider.h:45
LWSlider * mpOrigin
Definition: ASlider.h:367
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
bool SliderDialog::TransferDataToWindow ( )
overrideprivate

Definition at line 232 of file ASlider.cpp.

References ASlider::Get(), mpOrigin, mSlider, mTextCtrl, LWSlider::SendUpdate(), and LWSlider::Set().

Referenced by OnSlider().

233 {
234  float value = mSlider->Get(false);
235  mTextCtrl->SetValue(wxString::Format(wxT("%g"), value));
236  mTextCtrl->SetSelection(-1, -1);
237  if (mpOrigin) {
238  mpOrigin->Set(value);
239  mpOrigin->SendUpdate(value);
240  }
241 
242  return true;
243 }
ASlider * mSlider
Definition: ASlider.h:364
float Get(bool convert=true)
Definition: ASlider.cpp:1591
void SendUpdate(float newValue)
Definition: ASlider.cpp:1231
void Set(float value)
Definition: ASlider.cpp:1345
wxTextCtrl * mTextCtrl
Definition: ASlider.h:365
LWSlider * mpOrigin
Definition: ASlider.h:367

Member Data Documentation

LWSlider* SliderDialog::mpOrigin
private

Definition at line 367 of file ASlider.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

ASlider* SliderDialog::mSlider
private

Definition at line 364 of file ASlider.h.

Referenced by Get(), TransferDataFromWindow(), and TransferDataToWindow().

int SliderDialog::mStyle
private

Definition at line 366 of file ASlider.h.

Referenced by TransferDataFromWindow().

wxTextCtrl* SliderDialog::mTextCtrl
private

Definition at line 365 of file ASlider.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().


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