Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ChangeClipSpeedDialog Class Referencefinal

#include <ChangeClipSpeedDialog.h>

Inheritance diagram for ChangeClipSpeedDialog:
[legend]
Collaboration diagram for ChangeClipSpeedDialog:
[legend]

Public Member Functions

 ChangeClipSpeedDialog (WaveTrack &track, WaveTrack::Interval &interval, wxWindow *parent=nullptr)
 
 ~ChangeClipSpeedDialog () override
 
- 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

void PopulateOrExchange (ShuttleGui &s)
 
void OnOk ()
 
bool SetClipSpeedFromDialog ()
 

Private Attributes

WaveTrackmTrack
 
WaveTrack::IntervalmTrackInterval
 
double mClipSpeed
 
double mOldClipSpeed
 

Detailed Description

Definition at line 18 of file ChangeClipSpeedDialog.h.

Constructor & Destructor Documentation

◆ ChangeClipSpeedDialog()

ChangeClipSpeedDialog::ChangeClipSpeedDialog ( WaveTrack track,
WaveTrack::Interval interval,
wxWindow *  parent = nullptr 
)

Definition at line 19 of file ChangeClipSpeedDialog.cpp.

22 parent, wxID_ANY, XO("Change Speed"), wxDefaultPosition, { 480, 250 },
23 wxDEFAULT_DIALOG_STYLE)
24 , mTrack { waveTrack }
25 , mTrackInterval { interval }
26 , mClipSpeed { 100.0 / interval.GetStretchRatio() }
28{
29 ShuttleGui s(this, eIsCreating);
30
31 s.StartVerticalLay();
32 {
34 }
35 s.EndVerticalLay();
36
37 // TODO: Tolerance?
38 // Stretch ratio of
39 assert(mOldClipSpeed > 0.0);
40
41 Layout();
42 Fit();
43 Centre();
44
45 Bind(
46 wxEVT_CHAR_HOOK,
47 [this](auto& evt)
48 {
49 if (!IsEscapeKey(evt))
50 {
51 evt.Skip();
52 return;
53 }
54
55 EndModal(wxID_CANCEL);
56 });
57}
XO("Cut/Copy/Paste")
@ eIsCreating
Definition: ShuttleGui.h:37
WaveTrack::Interval & mTrackInterval
void PopulateOrExchange(ShuttleGui &s)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:630
double GetStretchRatio() const
Definition: WaveTrack.cpp:430

◆ ~ChangeClipSpeedDialog()

ChangeClipSpeedDialog::~ChangeClipSpeedDialog ( )
overridedefault

Member Function Documentation

◆ OnOk()

void ChangeClipSpeedDialog::OnOk ( )
private

Definition at line 108 of file ChangeClipSpeedDialog.cpp.

109{
111 EndModal(wxID_OK);
112}

References SetClipSpeedFromDialog().

Referenced by PopulateOrExchange().

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

◆ PopulateOrExchange()

void ChangeClipSpeedDialog::PopulateOrExchange ( ShuttleGui s)
private

Definition at line 61 of file ChangeClipSpeedDialog.cpp.

62{
64 s.StartVerticalLay(wxEXPAND, 1);
65 {
66 s.SetBorder(1);
67 s.StartHorizontalLay(wxEXPAND);
68 {
69 s.AddPrompt(XO("Clip speed"));
70 s.AddSpace(0, 0, 1);
71 s.Name(XO("Clip speed"))
72 .NameSuffix(Verbatim("%"))
73 .TieNumericTextBox({}, mClipSpeed, 14, true)
74 ->Bind(wxEVT_TEXT_ENTER, [this](auto&) { OnOk(); });
75
76 s.AddFixedText(Verbatim("%"));
77 }
79 }
82
83 s.StartHorizontalLay(wxEXPAND, 0);
84 {
86 {
87 s.SetBorder(2);
88 s.StartHorizontalLay(wxEXPAND, 0);
89 {
90 s.AddSpace(0, 0, 1);
91
92 s.AddButton(XXO("&Cancel"))
93 ->Bind(wxEVT_BUTTON, [this](auto&) { EndModal(wxID_CANCEL); });
94
95 s.AddSpace(4, 0, 0);
96
97 auto okBtn = s.AddButton(XXO("&Ok"));
98 okBtn->Bind(wxEVT_BUTTON, [this](auto&) { OnOk(); });
99 okBtn->SetDefault();
100 }
102 }
104 }
106}
XXO("&Cut/Copy/Paste Toolbar")
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
void SetBorder(int Border)
Definition: ShuttleGui.h:488
wxStaticText * AddPrompt(const TranslatableString &Prompt, int wrapWidth=0)
Right aligned text string.
Definition: ShuttleGui.cpp:237
void EndMultiColumn()
void EndInvisiblePanel()
wxPanel * StartInvisiblePanel(int border=0)
void StartVerticalLay(int iProp=1)
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:361
void EndHorizontalLay()
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
wxTextCtrl * TieNumericTextBox(const TranslatableString &Prompt, int &Value, const int nChars=0, bool acceptEnter=false)
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:441
ShuttleGui & NameSuffix(const TranslatableString &suffix)
Definition: ShuttleGui.h:670
wxSizerItem * AddSpace(int width, int height, int prop=0)
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:662

References ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddFixedText(), ShuttleGuiBase::AddPrompt(), ShuttleGui::AddSpace(), ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndInvisiblePanel(), ShuttleGuiBase::EndMultiColumn(), mClipSpeed, ShuttleGui::Name(), ShuttleGui::NameSuffix(), OnOk(), ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartInvisiblePanel(), ShuttleGuiBase::StartVerticalLay(), ShuttleGuiBase::TieNumericTextBox(), Verbatim(), XO(), and XXO().

Referenced by SetClipSpeedFromDialog().

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

◆ SetClipSpeedFromDialog()

bool ChangeClipSpeedDialog::SetClipSpeedFromDialog ( )
private

Definition at line 114 of file ChangeClipSpeedDialog.cpp.

115{
116 {
119 }
120
121 if (mClipSpeed <= 0.0)
122 {
124 /* i18n-hint: Title of an error message shown, when invalid clip speed is set */
125 wxWidgetsWindowPlacement { this }, XO("Invalid clip speed"),
126 XO("Clip speed must be a positive value"), {});
127
128 return false;
129 }
130
132 const auto maxEndTime = nextClip != nullptr ?
133 nextClip->Start() :
134 std::numeric_limits<double>::infinity();
135
136 const auto start = mTrackInterval.Start();
137 const auto end = mTrackInterval.End();
138
139 const auto expectedEndTime =
140 start + (end - start) * mOldClipSpeed / mClipSpeed;
141
142 if (expectedEndTime >= maxEndTime)
143 {
145 wxWidgetsWindowPlacement { this }, XO("Invalid clip speed"),
146 XO("There is not enough space to stretch the clip to the selected speed"), {});
147
148 return false;
149 }
150
151 mTrackInterval.StretchRightTo(expectedEndTime);
153
154 {
157 }
158
159 return true;
160}
@ eIsSettingToDialog
Definition: ShuttleGui.h:39
@ eIsGettingFromDialog
Definition: ShuttleGui.h:38
#define S(N)
Definition: ToChars.cpp:64
double End() const
Definition: Channel.h:42
double Start() const
Definition: Channel.h:41
void StretchRightTo(double t)
Definition: WaveTrack.cpp:265
IntervalConstHolder GetNextInterval(const Interval &interval, PlaybackDirection searchDirection) const
Definition: WaveTrack.cpp:516
void ShowErrorDialog(const WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpPage, const ErrorDialogOptions &options={})
Show an error dialog with a link to the manual for further help.
Definition: BasicUI.h:262
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
Window placement information for wxWidgetsBasicUI can be constructed from a wxWindow pointer.

References eIsGettingFromDialog, eIsSettingToDialog, ChannelGroupInterval::End(), PackedArray::end(), forward, WaveTrack::GetNextInterval(), WaveTrack::Interval::GetStretchRatio(), mClipSpeed, mOldClipSpeed, mTrack, mTrackInterval, PopulateOrExchange(), S, BasicUI::ShowErrorDialog(), ChannelGroupInterval::Start(), WaveTrack::Interval::StretchRightTo(), and XO().

Referenced by OnOk().

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

Member Data Documentation

◆ mClipSpeed

double ChangeClipSpeedDialog::mClipSpeed
private

Definition at line 36 of file ChangeClipSpeedDialog.h.

Referenced by PopulateOrExchange(), and SetClipSpeedFromDialog().

◆ mOldClipSpeed

double ChangeClipSpeedDialog::mOldClipSpeed
private

Definition at line 37 of file ChangeClipSpeedDialog.h.

Referenced by SetClipSpeedFromDialog().

◆ mTrack

WaveTrack& ChangeClipSpeedDialog::mTrack
private

Definition at line 34 of file ChangeClipSpeedDialog.h.

Referenced by SetClipSpeedFromDialog().

◆ mTrackInterval

WaveTrack::Interval& ChangeClipSpeedDialog::mTrackInterval
private

Definition at line 35 of file ChangeClipSpeedDialog.h.

Referenced by SetClipSpeedFromDialog().


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