Audacity 3.2.0
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:
[legend]
Collaboration diagram for SliderDialog:
[legend]

Public Member Functions

 SliderDialog (wxWindow *parent, wxWindowID id, const TranslatableString &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 TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- 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
 
float mValue
 

Detailed Description

Pop up dialog used with an LWSlider.

Definition at line 367 of file ASlider.h.

Constructor & Destructor Documentation

◆ SliderDialog()

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

Definition at line 256 of file ASlider.cpp.

264 :
265 wxDialogWrapper(parent,id,title,position),
267{
268 SetName();
269 mpOrigin = pSource;
270 mValue = mpOrigin->Get(false);
271
272 auto prec = 2;
273 auto trailing = NumValidatorStyle::TWO_TRAILING_ZEROES;
274 if (style == DB_SLIDER)
275 {
276 prec = 1;
277 trailing = NumValidatorStyle::ONE_TRAILING_ZERO;
278 }
279
280 ShuttleGui S(this, eIsCreating);
281
282 S.StartVerticalLay();
283 {
284 if (style == PAN_SLIDER)
285 {
286 mTextCtrl = S
287 .Validator<IntegerValidator<float>>(
288 &mValue, NumValidatorStyle::DEFAULT, -100.0, 100.0)
289 .AddTextBox({}, wxEmptyString, 15);
290 }
291 else if (style == VEL_SLIDER)
292 {
293 mTextCtrl = S
294 .Validator<IntegerValidator<float>>(
295 &mValue, NumValidatorStyle::DEFAULT, -50.0, 50.0)
296 .AddTextBox({}, wxEmptyString, 15);
297 }
298 else if(style == PERCENT_SLIDER)
299 {
300 mTextCtrl = S
301 .Validator<IntegerValidator<float>>(
302 &mValue, NumValidatorStyle::DEFAULT, 0.0, 100.0)
303 .AddTextBox({}, wxEmptyString, 15);
304 }
305 else
306 {
307 mTextCtrl = S
308 .Validator<FloatingPointValidator<float>>(
309 prec, &mValue, trailing, mpOrigin->GetMinValue(), mpOrigin->GetMaxValue())
310 .AddTextBox({}, wxEmptyString, 15);
311 }
312 mSlider = safenew ASlider(S.GetParent(),
313 wxID_ANY,
314 title,
315 wxDefaultPosition,
316 size,
318 .Style( style ).Line( line ).Page( page ).Popup( false) );
319 S.Position(wxEXPAND)
320 .AddWindow(mSlider);
321 }
322 S.EndVerticalLay();
323
324 S.AddStandardButtons(eOkButton | eCancelButton);
325
326 Fit();
327
328 mSlider->Set(value);
329}
#define VEL_SLIDER
Definition: ASlider.h:37
#define DB_SLIDER
Definition: ASlider.h:33
#define PERCENT_SLIDER
Definition: ASlider.h:39
#define PAN_SLIDER
Definition: ASlider.h:34
#define safenew
Definition: MemoryX.h:9
static const auto title
@ eIsCreating
Definition: ShuttleGui.h:37
@ eOkButton
Definition: ShuttleGui.h:609
@ eCancelButton
Definition: ShuttleGui.h:610
#define S(N)
Definition: ToChars.cpp:64
ASlider is a custom slider, allowing for a slicker look and feel.
Definition: ASlider.h:260
void Set(float value)
Definition: ASlider.cpp:1848
float GetMinValue() const
Definition: ASlider.cpp:1654
float Get(bool convert=true)
Definition: ASlider.cpp:1553
float GetMaxValue() const
Definition: ASlider.cpp:1659
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
float mValue
Definition: ASlider.h:394
LWSlider * mpOrigin
Definition: ASlider.h:393
int mStyle
Definition: ASlider.h:392
wxTextCtrl * mTextCtrl
Definition: ASlider.h:391
ASlider * mSlider
Definition: ASlider.h:390
Options & Style(int s)
Definition: ASlider.h:280
Options & Page(float p)
Definition: ASlider.h:292
Options & Line(float l)
Definition: ASlider.h:291
Options & Popup(bool p)
Definition: ASlider.h:287

References DB_SLIDER, eCancelButton, eIsCreating, eOkButton, ASlider::Options::Line(), ASlider::Options::Page(), PAN_SLIDER, PERCENT_SLIDER, ASlider::Options::Popup(), S, safenew, size, anonymous_namespace{AudacityDontAskAgainMessageDialog.cpp}::style, ASlider::Options::Style(), title, and VEL_SLIDER.

Here is the call graph for this function:

◆ ~SliderDialog()

SliderDialog::~SliderDialog ( )

Definition at line 331 of file ASlider.cpp.

332{
333}

Member Function Documentation

◆ Get()

float SliderDialog::Get ( )

Definition at line 385 of file ASlider.cpp.

386{
387 return mSlider->Get(false);
388}
float Get(bool convert=true)
Definition: ASlider.cpp:1843

References ASlider::Get(), and mSlider.

Referenced by LWSlider::DoShowDialog().

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

◆ OnSlider()

void SliderDialog::OnSlider ( wxCommandEvent &  event)
private

Definition at line 370 of file ASlider.cpp.

371{
373 event.Skip(false);
374}
bool TransferDataToWindow() override
Definition: ASlider.cpp:335

References TransferDataToWindow().

Here is the call graph for this function:

◆ OnTextChange()

void SliderDialog::OnTextChange ( wxCommandEvent &  event)
private

Definition at line 376 of file ASlider.cpp.

377{
378 if (mTextCtrl->GetValidator()->TransferFromWindow())
379 {
381 }
382 event.Skip(false);
383}
bool TransferDataFromWindow() override
Definition: ASlider.cpp:351

References mTextCtrl, and TransferDataFromWindow().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool SliderDialog::TransferDataFromWindow ( )
overrideprivate

Definition at line 351 of file ASlider.cpp.

352{
353 if (mTextCtrl->GetValidator()->TransferFromWindow())
354 {
355 float value = mValue;
356 if (mStyle == DB_SLIDER)
357 value = DB_TO_LINEAR(value);
358 else if (mStyle == PAN_SLIDER || mStyle == PERCENT_SLIDER)
359 value /= 100.0;
360 mSlider->Set(value);
361 if (mpOrigin) {
362 mpOrigin->Set(value);
363 mpOrigin->SendUpdate(value);
364 }
365 }
366
367 return true;
368}
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:335
void Set(float value)
Definition: ASlider.cpp:1561
void SendUpdate(float newValue)
Definition: ASlider.cpp:1410

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

Referenced by OnTextChange().

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

◆ TransferDataToWindow()

bool SliderDialog::TransferDataToWindow ( )
overrideprivate

Definition at line 335 of file ASlider.cpp.

336{
337 float value = mSlider->Get(false);
339 ? value * 100.0
340 : value;
341 mTextCtrl->GetValidator()->TransferToWindow();
342 mTextCtrl->SetSelection(-1, -1);
343 if (mpOrigin) {
344 mpOrigin->Set(value);
345 mpOrigin->SendUpdate(value);
346 }
347
348 return true;
349}

References ASlider::Get(), mpOrigin, mSlider, mStyle, mTextCtrl, mValue, PAN_SLIDER, PERCENT_SLIDER, LWSlider::SendUpdate(), and LWSlider::Set().

Referenced by OnSlider().

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

Member Data Documentation

◆ mpOrigin

LWSlider* SliderDialog::mpOrigin
private

Definition at line 393 of file ASlider.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

◆ mSlider

ASlider* SliderDialog::mSlider
private

Definition at line 390 of file ASlider.h.

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

◆ mStyle

int SliderDialog::mStyle
private

Definition at line 392 of file ASlider.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

◆ mTextCtrl

wxTextCtrl* SliderDialog::mTextCtrl
private

Definition at line 391 of file ASlider.h.

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

◆ mValue

float SliderDialog::mValue
private

Definition at line 394 of file ASlider.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().


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