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 258 of file ASlider.cpp.

266 :
267 wxDialogWrapper(parent,id,title,position),
268 mStyle(style)
269{
270 SetName();
271 mpOrigin = pSource;
272 mValue = mpOrigin->Get(false);
273
274 auto prec = 2;
275 auto trailing = NumValidatorStyle::TWO_TRAILING_ZEROES;
276 if (style == DB_SLIDER)
277 {
278 prec = 1;
279 trailing = NumValidatorStyle::ONE_TRAILING_ZERO;
280 }
281
282 ShuttleGui S(this, eIsCreating);
283
284 S.StartVerticalLay();
285 {
286 if (style == PAN_SLIDER)
287 {
288 mTextCtrl = S
289 .Validator<IntegerValidator<float>>(
290 &mValue, NumValidatorStyle::DEFAULT, -100.0, 100.0)
291 .AddTextBox({}, wxEmptyString, 15);
292 }
293 else if (style == VEL_SLIDER)
294 {
295 mTextCtrl = S
296 .Validator<IntegerValidator<float>>(
297 &mValue, NumValidatorStyle::DEFAULT, -50.0, 50.0)
298 .AddTextBox({}, wxEmptyString, 15);
299 }
300 else if(style == PERCENT_SLIDER)
301 {
302 mTextCtrl = S
303 .Validator<IntegerValidator<float>>(
304 &mValue, NumValidatorStyle::DEFAULT, 0.0, 100.0)
305 .AddTextBox({}, wxEmptyString, 15);
306 }
307 else
308 {
309 mTextCtrl = S
310 .Validator<FloatingPointValidator<float>>(
311 prec, &mValue, trailing, mpOrigin->GetMinValue(), mpOrigin->GetMaxValue())
312 .AddTextBox({}, wxEmptyString, 15);
313 }
314 mSlider = safenew ASlider(S.GetParent(),
315 wxID_ANY,
316 title,
317 wxDefaultPosition,
318 size,
320 .Style( style ).Line( line ).Page( page ).Popup( false) );
321 S.Position(wxEXPAND)
322 .AddWindow(mSlider);
323 }
324 S.EndVerticalLay();
325
326 S.AddStandardButtons(eOkButton | eCancelButton);
327
328 Fit();
329
330 mSlider->Set(value);
331}
#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:10
static const auto title
@ eIsCreating
Definition: ShuttleGui.h:37
@ eOkButton
Definition: ShuttleGui.h:599
@ eCancelButton
Definition: ShuttleGui.h:600
#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:1850
float GetMinValue() const
Definition: ASlider.cpp:1656
float Get(bool convert=true)
Definition: ASlider.cpp:1555
float GetMaxValue() const
Definition: ASlider.cpp:1661
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:630
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, ASlider::Options::Style(), title, and VEL_SLIDER.

Here is the call graph for this function:

◆ ~SliderDialog()

SliderDialog::~SliderDialog ( )

Definition at line 333 of file ASlider.cpp.

334{
335}

Member Function Documentation

◆ Get()

float SliderDialog::Get ( )

Definition at line 387 of file ASlider.cpp.

388{
389 return mSlider->Get(false);
390}
float Get(bool convert=true)
Definition: ASlider.cpp:1845

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 372 of file ASlider.cpp.

373{
375 event.Skip(false);
376}
bool TransferDataToWindow() override
Definition: ASlider.cpp:337

References TransferDataToWindow().

Here is the call graph for this function:

◆ OnTextChange()

void SliderDialog::OnTextChange ( wxCommandEvent &  event)
private

Definition at line 378 of file ASlider.cpp.

379{
380 if (mTextCtrl->GetValidator()->TransferFromWindow())
381 {
383 }
384 event.Skip(false);
385}
bool TransferDataFromWindow() override
Definition: ASlider.cpp:353

References mTextCtrl, and TransferDataFromWindow().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool SliderDialog::TransferDataFromWindow ( )
overrideprivate

Definition at line 353 of file ASlider.cpp.

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

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 337 of file ASlider.cpp.

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

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: