Audacity 3.2.0
ExportMixerDialog.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ExportMixerDialog.cpp
6
7 Dominic Mazzoni
8
9**********************************************************************/
10
11#include "ExportMixerDialog.h"
12#include "ExportMixerPanel.h"
13#include "ExportUtils.h"
14
15#include <wx/sizer.h>
16#include <wx/stattext.h>
17
18#include "WaveTrack.h"
19#include "MixerOptions.h"
20
21#include "ShuttleGui.h"
22#include "HelpSystem.h"
23
24enum
25{
28};
29
30BEGIN_EVENT_TABLE( ExportMixerDialog, wxDialogWrapper )
37
39
41 wxWindow *parent, wxWindowID id, const TranslatableString &title,
42 const wxPoint &position, const wxSize& size, long style )
43 : wxDialogWrapper( parent, id, title, position, size, style | wxRESIZE_BORDER )
44 , mMixerSpec(mixerSpec)
45{
46 SetName();
47
48 for (auto t : tracks)
49 {
50 const wxString sTrackName = (t->GetName()).Left(20);
51 if (IsMono(*t))
52 // No matter whether it's panned hard left or right
53 mTrackNames.push_back(sTrackName);
54 else {
55 /* i18n-hint: track name and L abbreviating Left channel */
56 mTrackNames.push_back(XO("%s - L").Format(sTrackName).Translation());
57 /* i18n-hint: track name and R abbreviating Right channel */
58 mTrackNames.push_back(XO("%s - R").Format(sTrackName).Translation());
59 }
60 }
61
62 auto label = XO("Output Channels: %2d")
63 .Format( mMixerSpec->GetNumChannels() );
64
65 ShuttleGui S{ this, eIsCreating };
66 {
67 S.SetBorder( 5 );
68
69 auto mixerPanel = safenew ExportMixerPanel(
70 S.GetParent(), ID_MIXERPANEL, mMixerSpec,
71 mTrackNames, wxDefaultPosition, wxSize(400, -1));
72 S.Prop(1)
73 .Name(XO("Mixer Panel"))
74 .Position(wxEXPAND | wxALL)
75 .AddWindow(mixerPanel);
76
77 S.StartHorizontalLay(wxALIGN_CENTER | wxALL, 0);
78 {
79 mChannelsText = S.AddVariableText(
80 label,
81 false, wxALIGN_LEFT | wxALL );
82
83 if(mMixerSpec->GetMaxNumChannels() > 1)
84 {
85 S
87 .Name(label)
88 .Size({300, -1})
89 .Style(wxSL_HORIZONTAL)
90 .Position(wxEXPAND | wxALL)
91 .AddSlider( {},
92 mMixerSpec->GetNumChannels(),
93 mMixerSpec->GetMaxNumChannels(), 1 );
94 }
95 }
96 S.EndHorizontalLay();
97
98 S.AddStandardButtons( eCancelButton | eOkButton | eHelpButton );
99 }
100
101 SetAutoLayout(true);
102 GetSizer()->Fit( this );
103 GetSizer()->SetSizeHints( this );
104
105 SetSizeHints( 640, 480, 20000, 20000 );
106
107 SetSize( 640, 480 );
108 Center();
109}
110
111
112void ExportMixerDialog::OnSize(wxSizeEvent &event)
113{
114 ExportMixerPanel *pnl = ( ( ExportMixerPanel* ) FindWindow( ID_MIXERPANEL ) );
115 pnl->Refresh( false );
116 event.Skip();
117}
118
119void ExportMixerDialog::OnSlider( wxCommandEvent & WXUNUSED(event))
120{
121 wxSlider *channels = ( wxSlider* )FindWindow( ID_SLIDER_CHANNEL );
122 ExportMixerPanel *pnl = ( ( ExportMixerPanel* ) FindWindow( ID_MIXERPANEL ) );
123 mMixerSpec->SetNumChannels( channels->GetValue() );
124 pnl->Refresh( false );
125 wxString label;
126 label.Printf( _( "Output Channels: %2d" ), mMixerSpec->GetNumChannels() );
127 mChannelsText->SetLabel( label );
128 channels->SetName( label );
129}
130
131void ExportMixerDialog::OnOk(wxCommandEvent & WXUNUSED(event))
132{
133 EndModal( wxID_OK );
134}
135
136void ExportMixerDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
137{
138 EndModal( wxID_CANCEL );
139}
140
141void ExportMixerDialog::OnMixerPanelHelp(wxCommandEvent & WXUNUSED(event))
142{
143 HelpSystem::ShowHelp(this, L"Advanced_Mixing_Options", true);
144}
END_EVENT_TABLE()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
@ ID_SLIDER_CHANNEL
@ ID_MIXERPANEL
XO("Cut/Copy/Paste")
#define _(s)
Definition: Internat.h:73
#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
@ eHelpButton
Definition: ShuttleGui.h:613
TranslatableString label
Definition: TagsEditor.cpp:165
const auto tracks
#define S(N)
Definition: ToChars.cpp:64
Dialog for advanced mixing.
void OnOk(wxCommandEvent &event)
void OnCancel(wxCommandEvent &event)
void OnSize(wxSizeEvent &event)
wxStaticText * mChannelsText
void OnMixerPanelHelp(wxCommandEvent &event)
MixerOptions::Downmix * mMixerSpec
void OnSlider(wxCommandEvent &event)
Panel that displays mixing for advanced mixing option.
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:231
bool SetNumChannels(unsigned numChannels)
unsigned GetNumChannels() const
Definition: MixerOptions.h:47
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
bool IsMono(const Channel &channel)
Whether the channel is mono.
Range between two TrackIters, usable in range-for statements, and with Visit member functions.
Definition: Track.h:682