Audacity  3.0.3
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 333 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 263 of file ASlider.cpp.

271  :
272  wxDialogWrapper(parent,id,title,position),
273  mStyle(style)
274 {
275  SetName();
276  mpOrigin = pSource;
277  mValue = mpOrigin->Get(false);
278 
279  auto prec = 2;
280  auto trailing = NumValidatorStyle::TWO_TRAILING_ZEROES;
281  if (style == DB_SLIDER)
282  {
283  prec = 1;
284  trailing = NumValidatorStyle::ONE_TRAILING_ZERO;
285  }
286 
287  ShuttleGui S(this, eIsCreating);
288 
289  S.StartVerticalLay();
290  {
291  if (style == PAN_SLIDER)
292  {
293  mTextCtrl = S
294  .Validator<IntegerValidator<float>>(
295  &mValue, NumValidatorStyle::DEFAULT, -100.0, 100.0)
296  .AddTextBox({}, wxEmptyString, 15);
297  }
298  else if (style == VEL_SLIDER)
299  {
300  mTextCtrl = S
301  .Validator<IntegerValidator<float>>(
302  &mValue, NumValidatorStyle::DEFAULT, -50.0, 50.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 }

References ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddWindow(), DB_SLIDER, eCancelButton, eIsCreating, ShuttleGuiBase::EndVerticalLay(), eOkButton, ShuttleGuiBase::GetParent(), ASlider::Options::Line(), ASlider::Options::Page(), PAN_SLIDER, ASlider::Options::Popup(), ShuttleGui::Position(), safenew, ShuttleGuiBase::StartVerticalLay(), ASlider::Options::Style(), title, ShuttleGui::Validator(), 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 }

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 }

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 }

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)
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 }

References DB_SLIDER, DB_TO_LINEAR(), mpOrigin, mSlider, mStyle, mTextCtrl, mValue, PAN_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, 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 359 of file ASlider.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

◆ mSlider

ASlider* SliderDialog::mSlider
private

Definition at line 356 of file ASlider.h.

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

◆ mStyle

int SliderDialog::mStyle
private

Definition at line 358 of file ASlider.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

◆ mTextCtrl

wxTextCtrl* SliderDialog::mTextCtrl
private

Definition at line 357 of file ASlider.h.

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

◆ mValue

float SliderDialog::mValue
private

Definition at line 360 of file ASlider.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().


The documentation for this class was generated from the following files:
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
ASlider::Get
float Get(bool convert=true)
Definition: ASlider.cpp:1742
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
SliderDialog::mTextCtrl
wxTextCtrl * mTextCtrl
Definition: ASlider.h:357
ASlider::Set
void Set(float value)
Definition: ASlider.cpp:1747
VEL_SLIDER
#define VEL_SLIDER
Definition: ASlider.h:37
LWSlider::Set
void Set(float value)
Definition: ASlider.cpp:1465
LWSlider::SendUpdate
void SendUpdate(float newValue)
Definition: ASlider.cpp:1343
SliderDialog::mValue
float mValue
Definition: ASlider.h:360
ASlider::Options
Definition: ASlider.h:238
PAN_SLIDER
#define PAN_SLIDER
Definition: ASlider.h:34
LWSlider::GetMinValue
float GetMinValue() const
Definition: ASlider.cpp:1558
LWSlider::Get
float Get(bool convert=true)
Definition: ASlider.cpp:1457
eCancelButton
@ eCancelButton
Definition: ShuttleGui.h:601
SliderDialog::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: ASlider.cpp:351
ASlider::Options::Popup
Options & Popup(bool p)
Definition: ASlider.h:253
SliderDialog::mStyle
int mStyle
Definition: ASlider.h:358
ASlider::Options::Page
Options & Page(float p)
Definition: ASlider.h:258
DB_SLIDER
#define DB_SLIDER
Definition: ASlider.h:33
title
static const auto title
Definition: UpdateNoticeDialog.cpp:23
ASlider
ASlider is a custom slider, allowing for a slicker look and feel.
Definition: ASlider.h:234
eOkButton
@ eOkButton
Definition: ShuttleGui.h:600
SliderDialog::TransferDataToWindow
bool TransferDataToWindow() override
Definition: ASlider.cpp:335
ASlider::Options::Line
Options & Line(float l)
Definition: ASlider.h:257
LWSlider::GetMaxValue
float GetMaxValue() const
Definition: ASlider.cpp:1563
wxDialogWrapper::wxDialogWrapper
wxDialogWrapper()
Definition: wxPanelWrapper.h:84
SliderDialog::mpOrigin
LWSlider * mpOrigin
Definition: ASlider.h:359
SliderDialog::mSlider
ASlider * mSlider
Definition: ASlider.h:356
wxDialogWrapper::SetName
void SetName()
Definition: wxPanelWrapper.cpp:81
safenew
#define safenew
Definition: MemoryX.h:10
ASlider::Options::Style
Options & Style(int s)
Definition: ASlider.h:250
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631