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 if (style == SPEED_SLIDER)
280 {
281 prec = 3;
282 trailing = NumValidatorStyle::THREE_TRAILING_ZEROES;
283 }
284
285 ShuttleGui S(this, eIsCreating);
286
287 S.StartVerticalLay();
288 {
289 if (style == PAN_SLIDER)
290 {
291 mTextCtrl = S
292 .Validator<IntegerValidator<float>>(
293 &mValue, NumValidatorStyle::DEFAULT, -100.0, 100.0)
294 .AddTextBox({}, wxEmptyString, 15);
295 }
296 else if (style == VEL_SLIDER)
297 {
298 mTextCtrl = S
299 .Validator<IntegerValidator<float>>(
300 &mValue, NumValidatorStyle::DEFAULT, -50.0, 50.0)
301 .AddTextBox({}, wxEmptyString, 15);
302 }
303 else if(style == PERCENT_SLIDER)
304 {
305 mTextCtrl = S
306 .Validator<IntegerValidator<float>>(
307 &mValue, NumValidatorStyle::DEFAULT, 0.0, 100.0)
308 .AddTextBox({}, wxEmptyString, 15);
309 }
310 else
311 {
312 mTextCtrl = S
313 .Validator<FloatingPointValidator<float>>(
314 prec, &mValue, trailing, mpOrigin->GetMinValue(), mpOrigin->GetMaxValue())
315 .AddTextBox({}, wxEmptyString, 15);
316 }
317 mSlider = safenew ASlider(S.GetParent(),
318 wxID_ANY,
319 title,
320 wxDefaultPosition,
321 size,
323 .Style( style ).Line( line ).Page( page ).Popup( false) );
324 S.Position(wxEXPAND)
325 .AddWindow(mSlider);
326 }
327 S.EndVerticalLay();
328
329 S.AddStandardButtons(eOkButton | eCancelButton);
330
331 Fit();
332
333 mSlider->Set(value);
334}
#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:1845
float GetMinValue() const
Definition: ASlider.cpp:1651
float Get(bool convert=true)
Definition: ASlider.cpp:1550
float GetMaxValue() const
Definition: ASlider.cpp:1656
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 336 of file ASlider.cpp.

337{
338}

Member Function Documentation

◆ Get()

float SliderDialog::Get ( )

Definition at line 390 of file ASlider.cpp.

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

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

376{
378 event.Skip(false);
379}
bool TransferDataToWindow() override
Definition: ASlider.cpp:340

References TransferDataToWindow().

Here is the call graph for this function:

◆ OnTextChange()

void SliderDialog::OnTextChange ( wxCommandEvent &  event)
private

Definition at line 381 of file ASlider.cpp.

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

References mTextCtrl, and TransferDataFromWindow().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool SliderDialog::TransferDataFromWindow ( )
overrideprivate

Definition at line 356 of file ASlider.cpp.

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

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

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

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: