18#include <wx/spinctrl.h>
20#include <wx/checkbox.h>
21#include <wx/textctrl.h>
22#include <wx/stattext.h>
23#include <wx/wupdlock.h>
25#ifdef wxUSE_ACCESSIBILITY
42 uiServices->PopulateUI(
S);
56 if(!uiServices->TransferDataFromWindow())
75 for(
const auto& p : parameters)
76 mEditor->SetValue(std::get<0>(p), std::get<1>(p));
83 return mEditor->GetSampleRateList();
89 S.StartHorizontalLay(wxCENTER);
91 S.StartHorizontalLay(wxCENTER, 0);
93 S.Prop(1).AddTitle(
XO(
"No format specific options"));
103 S.StartMultiColumn(2, wxALIGN_LEFT);
105 for(
int i = 0; i <
mEditor->GetOptionsCount(); ++i)
108 if(!
mEditor->GetOption(i, option))
115 wxControl* control {
nullptr };
117 auto prompt =
S.AddPrompt(option.
title);
118 prompt->SetMinSize({140, -1});
126 std::unordered_map<int, ExportValue> indexValueMap;
127 indexValueMap.reserve(option.
values.size());
128 for(
auto& e : option.
values)
130 list.push_back(option.
names[index]);
133 indexValueMap[index] = e;
136 control =
S.AddChoice({}, list, selected);
137 control->Bind(wxEVT_CHOICE, [
this,
id = option.
id, indexValueMap](
const wxCommandEvent& evt)
139 const auto it = indexValueMap.find(evt.GetInt());
140 if(it != indexValueMap.end())
141 mEditor->SetValue(id, it->second);
144 else if(
auto selected = std::get_if<bool>(&value))
146 control =
S.Name(option.
title).
147 AddCheckBox({}, *selected);
148#if wxUSE_ACCESSIBILITY
151 control->Bind(wxEVT_CHECKBOX, [
this,
id = option.
id](
const wxCommandEvent& evt)
153 const auto checked = evt.GetInt() != 0;
154 mEditor->SetValue(id, checked);
157 else if(
auto num = std::get_if<int>(&value))
161 const int min = *std::get_if<int>(&option.
values[0]);
162 const int max = *std::get_if<int>(&option.
values[1]);
165 control =
S.Name(option.
title)
166 .AddSlider({}, *num, max,
min);
167 control->Bind(wxEVT_SLIDER, [
this,
id = option.
id](
const wxCommandEvent& evt)
169 mEditor->SetValue(id, evt.GetInt());
171 control->SetMinSize({180, -1});
175 control =
S.AddSpinCtrl({}, *num, max,
min);
176 control->Bind(wxEVT_SPINCTRL, [
this,
id = option.
id](
const wxSpinEvent& evt)
178 mEditor->SetValue(id, evt.GetInt());
184 control =
S.AddNumericTextBox({}, wxString::Format(
"%d", *num), 0);
185 control->Bind(wxEVT_TEXT, [
this,
id = option.
id](
const wxCommandEvent& evt)
188 if(evt.GetString().ToLong(&num))
189 mEditor->SetValue(
id,
static_cast<int>(num));
193 else if(
auto str = std::get_if<std::string>(&value))
195 control =
S.AddTextBox({}, wxString::FromUTF8(*
str), 0);
196 control->Bind(wxEVT_TEXT, [
this,
id = option.
id](
const wxCommandEvent& evt)
198 mEditor->SetValue(
id, evt.GetString().ToStdString());
202 mRows.emplace_back(prompt, control);
234 const auto index = it->second;
235 const auto [prompt, control] =
mRows[index];
239 prompt->Show(visible);
240 control->Show(visible);
243 control->Enable(enabled);
wxDEFINE_EVENT(AUDACITY_FILE_SUFFIX_EVENT, wxCommandEvent)
std::variant< bool, int, double, std::string > ExportValue
A type of option values (parameters) used by exporting plugins.
audacity::BasicSettings * gPrefs
std::vector< TranslatableString > TranslatableStrings
std::vector< int > SampleRateList
ExportOptionsHandler(ShuttleGui &S, const ExportPlugin &plugin, int format)
void PopulateOptions(ShuttleGui &S)
void OnExportOptionChange(const ExportOption &option) override
Called when option change.
std::unordered_map< int, int > mIDRowIndexMap
void PopulateEmpty(ShuttleGui &S)
void OnExportOptionChangeBegin() override
Called before OnExportOptionChange
ExportOptionsEditor::SampleRateList GetSampleRateList() const
void OnSampleRateListChange() override
std::vector< std::tuple< wxStaticText *, wxControl * > > mRows
void OnExportOptionChangeEnd() override
Called after OnExportOptionChange
void OnFormatInfoChange() override
Called when format extension change (usually in response parameter change)
void SetParameters(const ExportProcessor::Parameters ¶meters)
bool TransferDataFromEditor()
std::unique_ptr< wxWindowUpdateLocker > mUpdateLocker
std::unique_ptr< ExportOptionsEditor > mEditor
ExportProcessor::Parameters GetParameters() const
virtual std::unique_ptr< ExportOptionsEditor > CreateOptionsEditor(int formatIndex, ExportOptionsEditor::Listener *listener) const =0
Creates format-dependent options editor, that is used to create a valid set of parameters to be used ...
std::vector< std::tuple< ExportOptionID, ExportValue > > Parameters
static ExportProcessor::Parameters ParametersFromEditor(const ExportOptionsEditor &editor)
CallbackReturn Publish(const ExportOptionsHandlerEvent &message)
Send a message to connected callbacks.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
A type that provides a description of an exporting option. Isn't allowed to change except non-type re...
ExportOptionID id
Internal option id.
@ TypeMask
Mask for bits that hold option type.
@ TypeEnum
List/enum option. values holds items, and names text to be displayed.
@ ReadOnly
Parameter is read-only, client should not attempt to change it's value.
@ TypeRange
Range option. values holds [min, max].
@ Hidden
Option is not used and may be hidden from the user.
int flags
A set of flag that desc.
std::vector< ExportValue > values
Interpretation depends on type.
TranslatableString title
Name of an option in a human-readable form.
TranslatableStrings names
Interpretation depends on type.