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

265 :
266 wxDialogWrapper(parent,id,title,position),
268{
269 SetName();
270 mpOrigin = pSource;
271 mValue = mpOrigin->Get(false);
272
273 auto prec = 2;
274 auto trailing = NumValidatorStyle::TWO_TRAILING_ZEROES;
275 if (style == DB_SLIDER)
276 {
277 prec = 1;
278 trailing = NumValidatorStyle::ONE_TRAILING_ZERO;
279 }
280 if (style == SPEED_SLIDER)
281 {
282 prec = 3;
283 trailing = NumValidatorStyle::THREE_TRAILING_ZEROES;
284 }
285
286 ShuttleGui S(this, eIsCreating);
287
288 S.StartVerticalLay();
289 {
290 if (style == PAN_SLIDER)
291 {
292 mTextCtrl = S
293 .Validator<IntegerValidator<float>>(
294 &mValue, NumValidatorStyle::DEFAULT, -100.0, 100.0)
295 .AddTextBox({}, wxEmptyString, 15);
296 }
297 else if (style == VEL_SLIDER)
298 {
299 mTextCtrl = S
300 .Validator<IntegerValidator<float>>(
301 &mValue, NumValidatorStyle::DEFAULT, -50.0, 50.0)
302 .AddTextBox({}, wxEmptyString, 15);
303 }
304 else if(style == PERCENT_SLIDER)
305 {
306 mTextCtrl = S
307 .Validator<IntegerValidator<float>>(
308 &mValue, NumValidatorStyle::DEFAULT, 0.0, 100.0)
309 .AddTextBox({}, wxEmptyString, 15);
310 }
311 else
312 {
313 mTextCtrl = S
314 .Validator<FloatingPointValidator<float>>(
315 prec, &mValue, trailing, mpOrigin->GetMinValue(), mpOrigin->GetMaxValue())
316 .AddTextBox({}, wxEmptyString, 15);
317 }
318 mSlider = safenew ASlider(S.GetParent(),
319 wxID_ANY,
320 title,
321 wxDefaultPosition,
322 size,
324 .Style( style ).Line( line ).Page( page ).Popup( false) );
325 S.Position(wxEXPAND)
326 .AddWindow(mSlider);
327 }
328 S.EndVerticalLay();
329
330 S.AddStandardButtons(eOkButton | eCancelButton);
331
332 Fit();
333
334 mSlider->Set(value);
335}
#define VEL_SLIDER
Definition: ASlider.h:37
#define DB_SLIDER
Definition: ASlider.h:33
#define PERCENT_SLIDER
Definition: ASlider.h:39
#define SPEED_SLIDER
Definition: ASlider.h:35
#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: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:1864
float GetMinValue() const
Definition: ASlider.cpp:1670
float Get(bool convert=true)
Definition: ASlider.cpp:1569
float GetMaxValue() const
Definition: ASlider.cpp:1675
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, SPEED_SLIDER, 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 337 of file ASlider.cpp.

338{
339}

Member Function Documentation

◆ Get()

float SliderDialog::Get ( )

Definition at line 391 of file ASlider.cpp.

392{
393 return mSlider->Get(false);
394}
float Get(bool convert=true)
Definition: ASlider.cpp:1859

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

377{
379 event.Skip(false);
380}
bool TransferDataToWindow() override
Definition: ASlider.cpp:341

References TransferDataToWindow().

Here is the call graph for this function:

◆ OnTextChange()

void SliderDialog::OnTextChange ( wxCommandEvent &  event)
private

Definition at line 382 of file ASlider.cpp.

383{
384 if (mTextCtrl->GetValidator()->TransferFromWindow())
385 {
387 }
388 event.Skip(false);
389}
bool TransferDataFromWindow() override
Definition: ASlider.cpp:357

References mTextCtrl, and TransferDataFromWindow().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool SliderDialog::TransferDataFromWindow ( )
overrideprivate

Definition at line 357 of file ASlider.cpp.

358{
359 if (mTextCtrl->GetValidator()->TransferFromWindow())
360 {
361 float value = mValue;
362 if (mStyle == DB_SLIDER)
363 value = DB_TO_LINEAR(value);
364 else if (mStyle == PAN_SLIDER || mStyle == PERCENT_SLIDER)
365 value /= 100.0;
366 mSlider->Set(value);
367 if (mpOrigin) {
368 mpOrigin->Set(value);
369 mpOrigin->SendUpdate(value);
370 }
371 }
372
373 return true;
374}
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:338
void Set(float value)
Definition: ASlider.cpp:1577
void SendUpdate(float newValue)
Definition: ASlider.cpp:1428

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

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

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: