ImportStreamDialog::ImportStreamDialog( ImportFileHandle *_mFile, wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style ): wxDialog( parent, id, title, position, size, style | wxRESIZE_BORDER ) { mFile = _mFile; scount = mFile->GetStreamCount(); for (wxInt32 i = 0; i < scount; i++) mFile->SetStreamUsage(i,FALSE); wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL ); wxArrayString *choices = mFile->GetStreamInfo(); StreamList = new wxListBox(this, -1, wxDefaultPosition, wxDefaultSize, *choices , wxLB_EXTENDED | wxLB_ALWAYS_SB); vertSizer->Add( StreamList, 1, wxEXPAND | wxALIGN_LEFT | wxALL, 5 ); vertSizer->Add( CreateStdButtonSizer(this, eCancelButton|eOkButton), 0, wxEXPAND ); SetAutoLayout( true ); SetSizer( vertSizer ); vertSizer->Fit( this ); SetSize( 400, 200 ); }
ImportStreamDialog::ImportStreamDialog( ImportFileHandle *_mFile, wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style ): wxDialogWrapper( parent, id, title, position, size, style | wxRESIZE_BORDER ) { SetName(GetTitle()); mFile = _mFile; scount = mFile->GetStreamCount(); for (wxInt32 i = 0; i < scount; i++) mFile->SetStreamUsage(i, FALSE); wxBoxSizer *vertSizer; { auto uVertSizer = std::make_unique<wxBoxSizer>(wxVERTICAL); vertSizer = uVertSizer.get(); auto choices = mFile->GetStreamInfo(); StreamList = safenew wxListBox(this, -1, wxDefaultPosition, wxDefaultSize, choices, wxLB_EXTENDED | wxLB_ALWAYS_SB); vertSizer->Add(StreamList, 1, wxEXPAND | wxALIGN_LEFT | wxALL, 5); vertSizer->Add(CreateStdButtonSizer(this, eCancelButton | eOkButton).release(), 0, wxEXPAND); SetAutoLayout(true); SetSizer(uVertSizer.release()); } vertSizer->Fit( this ); SetSize( 400, 200 ); }
NyquistInputDialog::NyquistInputDialog(wxWindow * parent, wxWindowID id, const wxString & title, const wxString & prompt, wxString initialCommand) : wxDialog(parent, id, title) { wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); wxControl *item; item = new wxStaticText(this, -1, prompt); mainSizer->Add(item, 0, wxALIGN_LEFT | wxLEFT | wxTOP | wxRIGHT, 10); mCommandText = new wxTextCtrl(this, -1, initialCommand, wxDefaultPosition, wxSize(400, 200), wxTE_MULTILINE); mainSizer->Add(mCommandText, 0, wxALIGN_LEFT | wxALL, 10); // Debug, OK, & Cancel buttons mainSizer->Add(CreateStdButtonSizer(this, eDebugButton|eCancelButton|eOkButton), 0, wxEXPAND); SetAutoLayout(true); SetSizer(mainSizer); mainSizer->Fit(this); mainSizer->SetSizeHints(this); mCommandText->SetFocus(); }
LevellerDialog::LevellerDialog(wxWindow *parent, wxWindowID id, const wxString &title ) : wxDialog( parent, id, title) { wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); wxStaticText *statText = new wxStaticText(this, -1, _("Leveller by Lynn Allan")); mainSizer->Add(statText, 0, wxALIGN_CENTRE | wxALL, 5); statText = new wxStaticText(this, -1, _("Equalize soft and loud sections")); mainSizer->Add(statText, 0, wxALIGN_CENTRE | wxALL, 5); wxStaticBoxSizer *group = new wxStaticBoxSizer(new wxStaticBox(this, -1, _("Degree of Leveling")), wxVERTICAL);; wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL); // wxString numPasses[] = { "None-Skip", "Light", "Moderate", "Heavy", "Heavier", "Heaviest" }; statText = new wxStaticText(this, -1, _("Degree of Leveling") + wxString(wxT(": "))); hSizer->Add(statText, 0, wxALIGN_CENTRE | wxALL, 5); mLevellerNumPassesChoice = new wxChoice(this, ID_DB_NUM_PASSES_CHOICE, wxDefaultPosition, wxDefaultSize, NUM_PASSES_CHOICES, numPasses); hSizer->Add(mLevellerNumPassesChoice, 0, wxALIGN_LEFT|wxALL, 5); group->Add(hSizer, 0, wxALIGN_CENTRE|wxALL, 5 ); mainSizer->Add(group, 0, wxALIGN_CENTRE | wxALL, 5); group = new wxStaticBoxSizer(new wxStaticBox(this, -1, _("Noise Threshold (Hiss/Hum/Ambient Noise)")), wxVERTICAL); hSizer = new wxBoxSizer(wxHORIZONTAL); statText = new wxStaticText(this, -1, _("Threshold for Noise: ")); hSizer->Add(statText, 0, wxALIGN_CENTRE | wxALL, 5); mLevellerDbSilenceThresholdChoice = new wxChoice(this, ID_DB_SILENCE_THRESHOLD_CHOICE, wxDefaultPosition, wxDefaultSize, Enums::NumDbChoices, Enums::GetDbChoices()); hSizer->Add(mLevellerDbSilenceThresholdChoice, 0, wxALIGN_CENTER | wxALL, 4); group->Add(hSizer, 0, wxALIGN_CENTRE|wxALL, 5 ); mainSizer->Add(group, 0, wxALIGN_CENTRE | wxALL, 5); // Preview, OK, & Cancel buttons mainSizer->Add(CreateStdButtonSizer(this, eCancelButton|eOkButton), 0, wxEXPAND); SetAutoLayout(true); SetSizer(mainSizer); mainSizer->Fit(this); mainSizer->SetSizeHints(this); }
VampEffectDialog::VampEffectDialog(VampEffect *effect, wxWindow *parent, Vamp::Plugin *plugin) : wxDialog(parent, -1, effect->GetEffectName(), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), mEffect(effect), mPlugin(plugin) { Vamp::Plugin::ProgramList programs = plugin->getPrograms(); mParameters = plugin->getParameterDescriptors(); #ifdef __WXMSW__ // On Windows, for some reason, wxWindows calls OnTextCtrl during creation // of the text control, and VampEffectDialog::OnTextCtrl calls HandleText, // which assumes all the fields have been initialized. // This can give us a bad pointer crash, so manipulate inSlider to // no-op HandleText during creation. inSlider = true; #else inSlider = false; #endif inText = false; int count = mParameters.size(); toggles = new wxCheckBox*[count]; sliders = new wxSlider*[count]; fields = new wxTextCtrl*[count]; labels = new wxStaticText*[count]; combos = new wxComboBox*[count]; wxControl *item; wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); item = new wxStaticText(this, 0, LAT1CTOWX(plugin->getName().c_str()) + wxString(_(" - Vamp audio analysis plugin"))); vSizer->Add(item, 0, wxALL, 5); item = new wxStaticText(this, 0, LAT1CTOWX(plugin->getDescription().c_str())); vSizer->Add(item, 0, wxALL, 5); item = new wxStaticText(this, 0, wxString(_("Author: ")) + LAT1CTOWX(plugin->getMaker().c_str())); vSizer->Add(item, 0, wxALL, 5); item = new wxStaticText(this, 0, LAT1CTOWX(plugin->getCopyright().c_str())); vSizer->Add(item, 0, wxALL, 5); wxScrolledWindow *w = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL | wxTAB_TRAVERSAL); // Try to give the window a sensible default/minimum size w->SetMinSize(wxSize( wxMax(400, parent->GetSize().GetWidth() / 2), parent->GetSize().GetHeight() / 2)); w->SetScrollRate(0, 20); vSizer->Add(w, 1, wxEXPAND|wxALL, 5); vSizer->Add(CreateStdButtonSizer(this, eCancelButton|eOkButton), 0, wxEXPAND); SetSizer(vSizer); wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, w, _("Plugin Settings")); wxFlexGridSizer *gridSizer = new wxFlexGridSizer(5, 0, 0); gridSizer->AddGrowableCol(3); programCombo = 0; if (!programs.empty()) { wxArrayString choices; wxString currentProgram = wxString(mPlugin->getCurrentProgram().c_str(), wxConvISO8859_1); for (size_t i = 0; i < programs.size(); ++i) { wxString choice = wxString(programs[i].c_str(), wxConvISO8859_1); choices.Add(choice); } gridSizer->Add(new wxStaticText(w, 0, _("Program")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); programCombo = new wxComboBox(w, 9999, currentProgram, wxDefaultPosition, wxDefaultSize, choices, wxCB_READONLY); programCombo->SetName(_("Program")); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(programCombo, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); ConnectFocus(programCombo); gridSizer->Add(1, 1, 0); } for (int p = 0; p < count; p++) { wxString labelText = LAT1CTOWX(mParameters[p].name.c_str()); item = new wxStaticText(w, 0, labelText + wxT(":")); item->SetName(labelText); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); wxString fieldText; float value = mPlugin->getParameter(mParameters[p].identifier); toggles[p] = 0; combos[p] = 0; sliders[p] = 0; fields[p] = 0; if (mParameters[p].isQuantized && mParameters[p].quantizeStep == 1.0 && mParameters[p].minValue == 0.0 && mParameters[p].maxValue == 1.0) { toggles[p] = new wxCheckBox(w, p, wxT("")); toggles[p]->SetName(labelText); toggles[p]->SetValue(value > 0.5); gridSizer->Add(toggles[p], 0, wxALL, 5); ConnectFocus(toggles[p]); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); } else if (mParameters[p].isQuantized && mParameters[p].quantizeStep == 1.0 && !mParameters[p].valueNames.empty()) { wxArrayString choices; wxString selected; for (size_t i = 0; i < mParameters[p].valueNames.size(); ++i) { wxString choice = wxString (mParameters[p].valueNames[i].c_str(), wxConvISO8859_1); if (int(value - mParameters[p].minValue + 0.5) == i) { selected = choice; } choices.Add(choice); } combos[p] = new wxComboBox(w, p, selected, wxDefaultPosition, wxDefaultSize, choices, wxCB_READONLY); combos[p]->SetName(labelText); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(combos[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); ConnectFocus(combos[p]); gridSizer->Add(1, 1, 0); } else { fieldText = Internat::ToDisplayString(value); fields[p] = new wxTextCtrl(w, p, fieldText); fields[p]->SetName(labelText); gridSizer->Add(fields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); ConnectFocus(fields[p]); wxString str = Internat::ToDisplayString(mParameters[p].minValue); item = new wxStaticText(w, 0, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); sliders[p] = new wxSlider(w, p, 0, 0, 1000, wxDefaultPosition, wxSize(100, -1)); sliders[p]->SetName(labelText); gridSizer->Add(sliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); ConnectFocus(sliders[p]); str = Internat::ToDisplayString(mParameters[p].maxValue); item = new wxStaticText(w, 0, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); } } // Set all of the sliders based on the value in the // text fields inSlider = false; // Now we're ready for HandleText to actually do something. HandleText(); paramSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5); w->SetSizer(paramSizer); Layout(); Fit(); SetSizeHints(GetSize()); }
AmplifyDialog::AmplifyDialog(EffectAmplify * effect, wxWindow * parent, wxWindowID id, const wxString & title, const wxPoint & position, const wxSize & size, long style): wxDialog(parent, id, title, position, size, style) { mLoopDetect = false; m_pEffect = effect; ratio = float(1.0); peak = float(0.0); wxStaticText * pStaticText; wxBoxSizer * pBoxSizer_Dialog = new wxBoxSizer(wxVERTICAL); pStaticText = new wxStaticText(this, -1, _("Amplify by Dominic Mazzoni"), wxDefaultPosition, wxDefaultSize, 0); pBoxSizer_Dialog->Add(pStaticText, 0, wxALIGN_CENTER | wxALL, 10); // Amplification text control wxBoxSizer *item2 = new wxBoxSizer(wxHORIZONTAL); pStaticText = new wxStaticText(this, -1, _("Amplification (dB):"), wxDefaultPosition, wxDefaultSize, 0); item2->Add(pStaticText, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); wxTextCtrl * item4 = new wxTextCtrl(this, ID_AMP_TEXT, wxT(""), wxDefaultPosition, wxSize(60, -1), 0, wxTextValidator(wxFILTER_NUMERIC)); item2->Add(item4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); pBoxSizer_Dialog->Add(item2, 0, wxALIGN_CENTER | wxALL, 5); // slider wxSlider *item5 = new wxSlider(this, ID_AMP_SLIDER, 0, AMP_MIN, AMP_MAX, wxDefaultPosition, wxSize(100, -1), wxSL_HORIZONTAL); pBoxSizer_Dialog->Add(item5, 1, wxGROW | wxALIGN_CENTER | wxALL, 5); // New Peak Amplitude text control wxBoxSizer *item6 = new wxBoxSizer(wxHORIZONTAL); pStaticText = new wxStaticText(this, -1, _("New Peak Amplitude (dB):"), wxDefaultPosition, wxDefaultSize, 0); item6->Add(pStaticText, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); wxTextCtrl *item8 = new wxTextCtrl(this, ID_PEAK_TEXT, wxT(""), wxDefaultPosition, wxSize(60, -1), 0); item6->Add(item8, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); pBoxSizer_Dialog->Add(item6, 0, wxALIGN_CENTER | wxALL, 5); // "Allow clipping" checkbox wxCheckBox *item8b = new wxCheckBox(this, ID_CLIP_CHECKBOX, _("Allow clipping"), wxDefaultPosition, wxDefaultSize, 0); pBoxSizer_Dialog->Add(item8b, 0, wxALIGN_CENTER | wxALL, 5); // Preview, OK, & Cancel buttons pBoxSizer_Dialog->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND); SetAutoLayout(TRUE); SetSizer(pBoxSizer_Dialog); pBoxSizer_Dialog->Fit(this); pBoxSizer_Dialog->SetSizeHints(this); }
LadspaEffectDialog::LadspaEffectDialog(LadspaEffect *eff, wxWindow * parent, const LADSPA_Descriptor *data, float *inputControls, int sampleRate, double length) :wxDialog(parent, -1, LAT1CTOWX(data->Name), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), effect(eff) { mLength = length; numParams = 0; this->mData = data; this->inputControls = inputControls; this->sampleRate = sampleRate; #ifdef __WXMSW__ // On Windows, for some reason, wxWindows calls OnTextCtrl during creation // of the text control, and LadspaEffectDialog::OnTextCtrl calls HandleText, // which assumes all the fields have been initialized. // This can give us a bad pointer crash, so manipulate inSlider to // no-op HandleText during creation. inSlider = true; #else inSlider = false; #endif inText = false; toggles = new wxCheckBox*[mData->PortCount]; sliders = new wxSlider*[mData->PortCount]; fields = new wxTextCtrl*[mData->PortCount]; labels = new wxStaticText*[mData->PortCount]; ports = new unsigned long [mData->PortCount]; unsigned long p; for(p=0; p<mData->PortCount; p++) { LADSPA_PortDescriptor d = mData->PortDescriptors[p]; if (LADSPA_IS_PORT_CONTROL(d) && LADSPA_IS_PORT_INPUT(d)) { ports[numParams] = p; numParams++; } } wxControl *item; wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); if (mData->Maker && mData->Maker[0] && LAT1CTOWX(mData->Maker) != wxString(_("None"))) { item = new wxStaticText(this, 0, wxString(_("Author: "))+LAT1CTOWX(mData->Maker)); vSizer->Add(item, 0, wxALL, 5); } if (mData->Copyright && mData->Copyright[0] && LAT1CTOWX(mData->Copyright) != wxString(_("None"))) { item = new wxStaticText(this, 0, LAT1CTOWX(mData->Copyright)); vSizer->Add(item, 0, wxALL, 5); } wxScrolledWindow *w = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL | wxTAB_TRAVERSAL); // Try to give the window a sensible default/minimum size w->SetMinSize(wxSize( wxMax(600, parent->GetSize().GetWidth() * 2/3), parent->GetSize().GetHeight() / 2)); w->SetScrollRate(0, 20); vSizer->Add(w, 1, wxEXPAND|wxALL, 5); // Preview, OK, & Cancel buttons vSizer->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND); SetSizer(vSizer); wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, w, _("Effect Settings")); wxFlexGridSizer *gridSizer = new wxFlexGridSizer(5, 0, 0); gridSizer->AddGrowableCol(3); for (p = 0; p < numParams; p++) { wxString labelText = LAT1CTOWX(mData->PortNames[ports[p]]); item = new wxStaticText(w, 0, labelText + wxT(":")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); wxString fieldText; LADSPA_PortRangeHint hint = mData->PortRangeHints[ports[p]]; if (LADSPA_IS_HINT_TOGGLED(hint.HintDescriptor)) { toggles[p] = new wxCheckBox(w, p, wxT("")); toggles[p]->SetName(labelText); toggles[p]->SetValue(inputControls[ports[p]] > 0); gridSizer->Add(toggles[p], 0, wxALL, 5); ConnectFocus(toggles[p]); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); } else { if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor)) fieldText.Printf(wxT("%d"), (int)(inputControls[ports[p]] + 0.5)); else fieldText = Internat::ToDisplayString(inputControls[ports[p]]); fields[p] = new wxTextCtrl(w, p, fieldText); fields[p]->SetName(labelText); gridSizer->Add(fields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); ConnectFocus(fields[p]); wxString bound; double lower = 0.0; double upper = 0.0; bool haslo = false; bool hashi = false; bool forceint = false; if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor)) { lower = hint.LowerBound; haslo = true; } if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor)) { upper = hint.UpperBound; hashi = true; } if (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor)) { lower *= sampleRate * 1000; upper *= sampleRate; forceint = true; } wxString str; if (haslo) { if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint) str.Printf(wxT("%d"), (int)(lower + 0.5)); else str = Internat::ToDisplayString(lower); item = new wxStaticText(w, 0, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); } else { gridSizer->Add(1, 1, 0); } sliders[p] = new wxSlider(w, p, 0, 0, 1000, wxDefaultPosition, wxSize(200, -1)); sliders[p]->SetName(labelText); gridSizer->Add(sliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); ConnectFocus(sliders[p]); if (hashi) { if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint) str.Printf(wxT("%d"), (int)(upper + 0.5)); else str = Internat::ToDisplayString(upper); item = new wxStaticText(w, 0, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); } else { gridSizer->Add(1, 1, 0); } } } // Now add the length control if (effect->GetEffectFlags() & INSERT_EFFECT) { item = new wxStaticText(w, 0, _("Length (seconds)")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); mSeconds = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(length)); mSeconds->SetName(_("Length (seconds)")); gridSizer->Add(mSeconds, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); ConnectFocus(mSeconds); } // Set all of the sliders based on the value in the // text fields inSlider = false; // Now we're ready for HandleText to actually do something. HandleText(); paramSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5); w->SetSizer(paramSizer); Layout(); Fit(); SetSizeHints(GetSize()); }
LV2EffectDialog::LV2EffectDialog(LV2Effect *effect, wxWindow *parent, const LilvPlugin *data, int sampleRate, double length, double WXUNUSED(noteLength), unsigned char WXUNUSED(noteVelocity), unsigned char WXUNUSED(noteKey)) : wxDialog(parent, wxID_ANY, mEffect->GetString(lilv_plugin_get_name(data)), wxDefaultPosition, wxSize(500, -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), mEffect(effect), mData(data), mControls(effect->GetControls()), mSampleRate(sampleRate), mLength(length) { #if defined(__WXMSW__) // On Windows, for some reason, wxWindows calls OnTextCtrl during creation // of the text control, and LV2EffectDialog::OnTextCtrl calls HandleText, // which assumes all the mFields have been initialized. // This can give us a bad pointer crash, so manipulate inSlider to // no-op HandleText during creation. inSlider = true; #else inSlider = false; #endif inText = false; inText = true; // Allocate memory for the user parameter controls int ctrlcnt = (int) mControls.GetCount(); mToggles = new wxCheckBox*[ctrlcnt]; mSliders = new wxSlider*[ctrlcnt]; mFields = new wxTextCtrl*[ctrlcnt]; mLabels = new wxStaticText*[ctrlcnt]; mEnums = new wxChoice*[ctrlcnt]; wxControl *item; wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); // Add information about the plugin LilvNode *tmpValue = lilv_plugin_get_author_name(data); if (tmpValue) { wxString author(_("Author: ") + mEffect->GetString(tmpValue)); item = new wxStaticText(this, wxID_ANY, author); vSizer->Add(item, 0, wxALL, 5); lilv_node_free(tmpValue); } wxScrolledWindow *w = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL | wxTAB_TRAVERSAL); // Try to give the window a sensible default/minimum size w->SetMinSize(wxSize( wxMax(600, parent->GetSize().GetWidth() * 2/3), parent->GetSize().GetHeight() / 2)); w->SetScrollRate(0, 20); vSizer->Add(w, 1, wxEXPAND|wxALL, 5); // Preview, OK, & Cancel buttons vSizer->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND); SetSizer(vSizer); wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, w, _("Effect Settings")); wxFlexGridSizer *gridSizer = new wxFlexGridSizer(5, 0, 0); gridSizer->AddGrowableCol(3); // Now add the length control if (mEffect->GetEffectFlags() & INSERT_EFFECT) { item = new wxStaticText(w, 0, _("Length (seconds)")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); mSeconds = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(length)); mSeconds->SetName(_("Length (seconds)")); gridSizer->Add(mSeconds, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); ConnectFocus(mSeconds); } // The note controls if the plugin is a synth if (mEffect->IsSynth()) { // Note length control item = new wxStaticText(w, wxID_ANY, _("Note length (seconds)")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mNoteSeconds = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(length / 2)); mNoteSeconds->SetName(_("Note length (seconds)")); gridSizer->Add(mNoteSeconds, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); ConnectFocus(mNoteSeconds); // Note velocity control item = new wxStaticText(w, wxID_ANY, _("Note velocity")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mNoteVelocity = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(64)); mNoteVelocity->SetName(_("Note velocity")); gridSizer->Add(mNoteVelocity, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); ConnectFocus(mNoteVelocity); // Note key control item = new wxStaticText(w, wxID_ANY, _("Note key")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mNoteKey = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(64)); mNoteKey->SetName(_("Note key")); gridSizer->Add(mNoteKey, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); ConnectFocus(mNoteKey); } paramSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5); // Create user parameter controls std::queue<const LV2PortGroup *> groups; groups.push(&mEffect->GetRootGroup()); while (!groups.empty()) { const LV2PortGroup* pg = groups.front(); groups.pop(); if (pg->GetName() != wxEmptyString) { wxSizer *groupSizer = new wxStaticBoxSizer(wxVERTICAL, w, pg->GetName()); paramSizer->Add(groupSizer, 0, wxEXPAND | wxALL, 5); gridSizer = new wxFlexGridSizer(5, 0, 0); gridSizer->AddGrowableCol(3); groupSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5); } const LV2PortGroupArray & subgroups = pg->GetSubGroups(); LV2PortGroupArray::const_iterator si; for (si = subgroups.begin(); si != subgroups.end(); si++) { if ((*si)->GetParameters().GetCount() != 0) { groups.push(*si); } } const wxArrayInt & params = pg->GetParameters(); for (size_t pi = 0; pi < params.GetCount(); pi++) { int p = params[pi]; if (p >= ctrlcnt) { continue; } LV2Port & port = mControls[p]; wxString labelText = port.mName; item = new wxStaticText(w, 0, labelText + wxT(":")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); wxString fieldText; if (port.mToggle) { mToggles[p] = new wxCheckBox(w, p, wxT("")); mToggles[p]->SetName(labelText); mToggles[p]->SetValue(port.mControlBuffer > 0); gridSizer->Add(mToggles[p], 0, wxALL, 5); ConnectFocus(mToggles[p]); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); } else if (port.mEnumeration) { mEnums[p] = new wxChoice(w, p); mEnums[p]->SetName(labelText); mEnums[p]->Append(port.mScaleLabels); int s; for (s = (int) port.mScaleValues.GetCount() - 1; s >= 0; s--) { if (port.mControlBuffer >= port.mScaleValues[s]) { break; } } if (s < 0) { s = 0; } mEnums[p]->SetSelection(s); gridSizer->Add(mEnums[p], 0, wxALL | wxEXPAND, 5); ConnectFocus(mEnums[p]); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); } else { if (port.mInteger) { fieldText.Printf(wxT("%d"), (int)(port.mControlBuffer + 0.5)); } else { fieldText = Internat::ToDisplayString(port.mControlBuffer); } mFields[p] = new wxTextCtrl(w, p, fieldText); mFields[p]->SetName(labelText); gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); ConnectFocus(mFields[p]); wxString bound; double lower = 0.0; double upper = 0.0; bool haslo = false; bool hashi = false; bool forceint = false; wxString loLabel; wxString hiLabel; #if 0 ScalePointMap::const_iterator iter = scalePoints.find(port.mIndex); if (!wxNaN(port.mMin)) { lower = port.mMin; haslo = true; if (iter != scalePoints.end()) { std::map<float, wxString>::const_iterator iter2 = iter->second.find(lower); if (iter2 != iter->second.end()) { loLabel = iter2->second; } } } if (!isnan(port.mMax)) { upper = port.mMax; hashi = true; if (iter != scalePoints.end()) { std::map<float, wxString>::const_iterator iter2 = iter->second.find(upper); if (iter2 != iter->second.end()) { hiLabel = iter2->second; } } } #endif if (port.mSampleRate) { lower *= mSampleRate * 1000; upper *= mSampleRate; forceint = true; } wxString str; if (haslo) { str = loLabel; if (str.IsEmpty()) { if (port.mInteger || forceint) { str.Printf(wxT("%d"), (int)(lower + 0.5)); } else { str = Internat::ToDisplayString(lower); } } item = new wxStaticText(w, wxID_ANY, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); } else { gridSizer->Add(1, 1, 0); } mSliders[p] = new wxSlider(w, p, 0, 0, 1000, wxDefaultPosition, wxSize(200, -1)); mSliders[p]->SetName(labelText); gridSizer->Add(mSliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); ConnectFocus(mSliders[p]); if (hashi) { str = hiLabel; if (str.IsEmpty()) { if (port.mInteger || forceint) { str.Printf(wxT("%d"), (int)(upper + 0.5)); } else { str = Internat::ToDisplayString(upper); } } item = new wxStaticText(w, wxID_ANY, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); } else { gridSizer->Add(1, 1, 0); } } } } // Set all of the mSliders based on the value in the // text mFields inSlider = false; // Now we're ready for HandleText to actually do something. HandleText(); w->SetSizer(paramSizer); Layout(); Fit(); SetSizeHints(GetSize()); }
void VSTEffectDialog::BuildPlain() { mNames = new wxStaticText *[mAEffect->numParams]; mSliders = new wxSlider *[mAEffect->numParams]; mDisplays = new wxStaticText *[mAEffect->numParams]; mLabels = new wxStaticText *[mAEffect->numParams]; wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); vSizer->Add(BuildProgramBar(), 0, wxALIGN_CENTER); wxScrolledWindow *sw = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL | wxTAB_TRAVERSAL); // Try to give the window a sensible default/minimum size wxSize sz = GetParent()->GetSize(); sw->SetMinSize(wxSize(wxMax(600, sz.GetWidth() * 2 / 3), sz.GetHeight() / 2)); sw->SetScrollRate(0, 20); vSizer->Add(sw, 1, wxEXPAND | wxALL, 5); // Preview, OK, & Cancel buttons vSizer->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND); SetSizer(vSizer); wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, sw, _("Effect Settings")); wxFlexGridSizer *gridSizer = new wxFlexGridSizer(4, 0, 0); gridSizer->AddGrowableCol(1); // Find the longest parameter name. int namew = 0; int w; int h; for (int i = 0; i < mAEffect->numParams; i++) { wxString text = mEffect->GetString(effGetParamName, i); if (text.Right(1) != wxT(':')) { text += wxT(':'); } GetTextExtent(text, &w, &h); if (w > namew) { namew = w; } } GetTextExtent(wxT("HHHHHHHH"), &w, &h); for (int i = 0; i < mAEffect->numParams; i++) { mNames[i] = new wxStaticText(sw, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(namew, -1), wxALIGN_RIGHT | wxST_NO_AUTORESIZE); gridSizer->Add(mNames[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mSliders[i] = new wxSlider(sw, ID_VST_SLIDERS + i, 0, 0, 1000, wxDefaultPosition, wxSize(200, -1)); gridSizer->Add(mSliders[i], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); mDisplays[i] = new wxStaticText(sw, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(w, -1), wxALIGN_RIGHT | wxST_NO_AUTORESIZE); gridSizer->Add(mDisplays[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mLabels[i] = new wxStaticText(sw, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(w, -1), wxALIGN_LEFT | wxST_NO_AUTORESIZE); gridSizer->Add(mLabels[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); } paramSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5); sw->SetSizer(paramSizer); Layout(); Fit(); SetSizeHints(GetSize()); RefreshParameters(); mSliders[0]->SetFocus(); }
void VSTEffectDialog::BuildFancy() { struct { short top, left, bottom, right; } *rect; // Some effects like to have us get their rect before opening them. mEffect->callDispatcher(effEditGetRect, 0, 0, &rect, 0.0); #if defined(__WXMAC__) HIViewRef view; WindowRef win = (WindowRef) MacGetTopLevelWindowRef(); HIViewFindByID(HIViewGetRoot(win), kHIViewWindowContentID, &view); mEffect->callDispatcher(effEditOpen, 0, 0, win, 0.0); HIViewRef subview = HIViewGetFirstSubview(view); if (subview == NULL) { mEffect->callDispatcher(effEditClose, 0, 0, win, 0.0); mGui = false; BuildPlain(); return; } #elif defined(__WXMSW__) wxWindow *w = new wxPanel(this, wxID_ANY); mEffect->callDispatcher(effEditOpen, 0, 0, w->GetHWND(), 0.0); #else #endif mEffect->callDispatcher(effEditGetRect, 0, 0, &rect, 0.0); wxBoxSizer *vs = new wxBoxSizer(wxVERTICAL); wxBoxSizer *hs = new wxBoxSizer(wxHORIZONTAL); wxSizerItem *si; vs->Add(BuildProgramBar(), 0, wxCENTER); si = hs->Add(rect->right - rect->left, rect->bottom - rect->top); vs->Add(hs, 0, wxCENTER); vs->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND); SetSizerAndFit(vs); wxPoint pos = si->GetPosition(); #if defined(__WXMAC__) HIViewPlaceInSuperviewAt(subview, pos.x, pos.y); // Some VST effects do not work unless the default handler is removed since // it captures many of the events that the plugins need. But, it must be // done last since proper window sizing will not occur otherwise. ::RemoveEventHandler((EventHandlerRef)MacGetEventHandler()); // Install a bare minimum handler so we can capture the window close event. If // it's not captured, we will crash at Audacity termination since the window // is still on the wxWidgets toplevel window lists, but it's already gone. mHandlerUPP = NewEventHandlerUPP(EventHandler); InstallWindowEventHandler(win, mHandlerUPP, GetEventTypeCount(eventList), eventList, this, &mHandlerRef); #elif defined(__WXMSW__) w->SetPosition(pos); w->SetSize(si->GetSize()); #else #endif }
LV2EffectDialog::LV2EffectDialog(LV2Effect *eff, wxWindow * parent, SLV2Plugin data, int sampleRate, double length, double noteLength, unsigned char noteVelocity, unsigned char noteKey) :wxDialog(parent, -1, LAT1CTOWX(slv2_value_as_string(slv2_plugin_get_name(data))), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), effect(eff), mControls(eff->GetControls()) { mLength = length; this->mData = data; this->sampleRate = sampleRate; #ifdef __WXMSW__ // On Windows, for some reason, wxWindows calls OnTextCtrl during creation // of the text control, and LV2EffectDialog::OnTextCtrl calls HandleText, // which assumes all the fields have been initialized. // This can give us a bad pointer crash, so manipulate inSlider to // no-op HandleText during creation. inSlider = true; #else inSlider = false; #endif inText = false; // Allocate memory for the user parameter controls toggles = new wxCheckBox*[mControls.size()]; sliders = new wxSlider*[mControls.size()]; fields = new wxTextCtrl*[mControls.size()]; labels = new wxStaticText*[mControls.size()]; wxControl *item; wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL); // Add information about the plugin SLV2Value tmpValue = slv2_plugin_get_author_name(data); if (tmpValue) { const char* author = slv2_value_as_string(tmpValue); item = new wxStaticText(this, 0, wxString(_("Author: "))+LAT1CTOWX(author)); vSizer->Add(item, 0, wxALL, 5); slv2_value_free(tmpValue); } wxScrolledWindow *w = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL | wxTAB_TRAVERSAL); // Try to give the window a sensible default/minimum size w->SetMinSize(wxSize( wxMax(600, parent->GetSize().GetWidth() * 2/3), parent->GetSize().GetHeight() / 2)); w->SetScrollRate(0, 20); vSizer->Add(w, 1, wxEXPAND|wxALL, 5); // Preview, OK, & Cancel buttons vSizer->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND); SetSizer(vSizer); wxSizer *paramSizer = new wxStaticBoxSizer(wxVERTICAL, w, _("Effect Settings")); wxFlexGridSizer *gridSizer = new wxFlexGridSizer(5, 0, 0); gridSizer->AddGrowableCol(3); const LV2PortGroup& rootGroup = eff->GetPortGroups(); const ScalePointMap& scalePoints = eff->GetScalePoints(); // Now add the length control if (effect->GetEffectFlags() & INSERT_EFFECT) { item = new wxStaticText(w, 0, _("Length (seconds)")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); mSeconds = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(length)); mSeconds->SetName(_("Length (seconds)")); gridSizer->Add(mSeconds, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); ConnectFocus(mSeconds); } // The note controls if the plugin is a synth if (effect->IsSynth()) { // Note length control item = new wxStaticText(w, 0, _("Note length (seconds)")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mNoteSeconds = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(length / 2)); mNoteSeconds->SetName(_("Note length (seconds)")); gridSizer->Add(mNoteSeconds, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); ConnectFocus(mNoteSeconds); // Note velocity control item = new wxStaticText(w, 0, _("Note velocity")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mNoteVelocity = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(64)); mNoteVelocity->SetName(_("Note velocity")); gridSizer->Add(mNoteVelocity, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); ConnectFocus(mNoteVelocity); // Note key control item = new wxStaticText(w, 0, _("Note key")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mNoteKey = new wxTextCtrl(w, LADSPA_SECONDS_ID, Internat::ToDisplayString(64)); mNoteKey->SetName(_("Note key")); gridSizer->Add(mNoteKey, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); ConnectFocus(mNoteKey); } paramSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5); // Create user parameter controls std::queue<const LV2PortGroup*> groups; groups.push(&rootGroup); while (!groups.empty()) { const LV2PortGroup* pg = groups.front(); groups.pop(); if (pg->GetName() != wxT("")) { wxSizer *groupSizer = new wxStaticBoxSizer(wxVERTICAL, w, pg->GetName()); paramSizer->Add(groupSizer, 0, wxEXPAND | wxALL, 5); gridSizer = new wxFlexGridSizer(5, 0, 0); gridSizer->AddGrowableCol(3); groupSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 5); } std::vector<LV2PortGroup>::const_iterator iter; for (iter = pg->GetSubGroups().begin(); iter != pg->GetSubGroups().end(); ++iter) { groups.push(&*iter); } const std::vector<uint32_t>& params = pg->GetParameters(); for (uint32_t k = 0; k < params.size(); ++k) { uint32_t p = params[k]; wxString labelText = mControls[p].mName; item = new wxStaticText(w, 0, labelText + wxT(":")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); wxString fieldText; if (mControls[p].mToggle) { toggles[p] = new wxCheckBox(w, p, wxT("")); toggles[p]->SetName(labelText); toggles[p]->SetValue(mControls[p].mControlBuffer > 0); gridSizer->Add(toggles[p], 0, wxALL, 5); ConnectFocus(toggles[p]); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0); } else { if (mControls[p].mInteger) fieldText.Printf(wxT("%d"), (int)(mControls[p].mControlBuffer + 0.5)); else fieldText = Internat::ToDisplayString(mControls[p].mControlBuffer); fields[p] = new wxTextCtrl(w, p, fieldText); fields[p]->SetName(labelText); gridSizer->Add(fields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); ConnectFocus(fields[p]); wxString bound; double lower = 0.0; double upper = 0.0; bool haslo = false; bool hashi = false; bool forceint = false; wxString loLabel; wxString hiLabel; ScalePointMap::const_iterator iter = scalePoints.find(mControls[p].mIndex); if (!std::isnan(mControls[p].mMin)) { lower = mControls[p].mMin; haslo = true; if (iter != scalePoints.end()) { std::map<float, wxString>::const_iterator iter2 = iter->second.find(lower); if (iter2 != iter->second.end()) { loLabel = iter2->second; } } } if (!std::isnan(mControls[p].mMax)) { upper = mControls[p].mMax; hashi = true; if (iter != scalePoints.end()) { std::map<float, wxString>::const_iterator iter2 = iter->second.find(upper); if (iter2 != iter->second.end()) hiLabel = iter2->second; } } if (mControls[p].mSampleRate) { lower *= sampleRate * 1000; upper *= sampleRate; forceint = true; } wxString str; if (haslo) { str = loLabel; if (str.IsEmpty()) { if (mControls[p].mInteger || forceint) str.Printf(wxT("%d"), (int)(lower + 0.5)); else str = Internat::ToDisplayString(lower); } item = new wxStaticText(w, 0, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); } else { gridSizer->Add(1, 1, 0); } sliders[p] = new wxSlider(w, p, 0, 0, 1000, wxDefaultPosition, wxSize(200, -1)); sliders[p]->SetName(labelText); gridSizer->Add(sliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); ConnectFocus(sliders[p]); if (hashi) { str = hiLabel; if (str.IsEmpty()) { if (mControls[p].mInteger || forceint) str.Printf(wxT("%d"), (int)(upper + 0.5)); else str = Internat::ToDisplayString(upper); } item = new wxStaticText(w, 0, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); } else { gridSizer->Add(1, 1, 0); } } } } // Set all of the sliders based on the value in the // text fields inSlider = false; // Now we're ready for HandleText to actually do something. HandleText(); w->SetSizer(paramSizer); Layout(); Fit(); SetSizeHints(GetSize()); }
LabelDialog::LabelDialog(wxWindow *parent, DirManager *dirmanager, TrackList *tracks, ViewInfo &viewinfo, double rate) : wxDialog(parent, wxID_ANY, _("Edit Labels"), wxDefaultPosition, wxSize(800, 600), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), mDirManager(dirmanager), mTracks(tracks), mViewInfo(&viewinfo), mRate(rate) { // Create the main sizer wxBoxSizer *vs = new wxBoxSizer(wxVERTICAL); // A little instruction vs->Add(new wxStaticText(this, wxID_ANY, _("Press F2 or double click to edit cell contents.")), 0, wxALIGN_LEFT | wxALL, 5); // Create the main sizer mGrid = new Grid(this, wxID_ANY); vs->Add(mGrid, 1, wxEXPAND | wxALL, 5); // Create the action buttons wxBoxSizer *hs = new wxBoxSizer(wxHORIZONTAL); hs->Add(new wxButton(this, ID_INSERTA, _("Insert &After")), 1, wxCENTER | wxALL, 5); hs->Add(new wxButton(this, ID_INSERTB, _("Insert &Before")), 1, wxCENTER | wxALL, 5); hs->Add(new wxButton(this, ID_REMOVE, _("&Remove")), 1, wxCENTER | wxALL, 5); hs->Add(new wxButton(this, ID_IMPORT, _("&Import...")), 1, wxCENTER | wxALL, 5); hs->Add(new wxButton(this, ID_EXPORT, _("&Export...")), 1, wxCENTER | wxALL, 5); vs->Add(hs, 0, wxEXPAND | wxCENTER | wxALL, 5); // Create the exit buttons vs->Add(CreateStdButtonSizer(this, eCancelButton|eOkButton), 0, wxEXPAND); // Make it so SetSizer(vs); // Build the initial (empty) grid mGrid->CreateGrid(0, Col_Max); mGrid->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER); int i; for (i = 0; i < Col_Max; i++) { mGrid->SetColLabelValue(i, headers[i]); } // Create and remember editors. No need to delete these as the wxGrid will // do it for us. mChoiceEditor = (ChoiceEditor *) mGrid->GetDefaultEditorForType(GRID_VALUE_CHOICE); mTimeEditor = (TimeEditor *) mGrid->GetDefaultEditorForType(GRID_VALUE_TIME); // Initialize and set the track name column attributes wxGridCellAttr *attr = new wxGridCellAttr(); attr->SetEditor(mChoiceEditor); mGrid->SetColAttr(Col_Track, attr); mTrackNames.Add(_("New...")); // Initialize and set the time column attributes attr = new wxGridCellAttr(); attr->SetRenderer(mGrid->GetDefaultRendererForType(GRID_VALUE_TIME)); attr->SetEditor(mTimeEditor); attr->SetAlignment(wxALIGN_CENTER, wxALIGN_CENTER); mGrid->SetColAttr(Col_Stime, attr); mGrid->SetColAttr(Col_Etime, attr->Clone()); // Seems there's a bug in wxGrid. Adding only 1 row does not // allow SetCellSize() to work properly and you will not get // the expected 1 row by 4 column cell. // // So, we set the minimum row height to 0 and basically hide // the extra row by setting its height to 0. And not allowing the // rows to be manually resized prevents the user from ever seeing // the extra row. mGrid->SetRowMinimalAcceptableHeight(0); mGrid->EnableDragRowSize(false); // Locate all labels in current track list FindAllLabels(); // Populate the grid TransferDataToWindow(); // Resize the label name column and ensure it doesn't go below an // arbitrary width. // // This should not be in TransferDataToWindow() since a user might // resize the column and we'd resize it back to the minimum. mGrid->AutoSizeColumn(Col_Label, false ); mGrid->SetColSize(Col_Label, wxMax(150, mGrid->GetColSize(Col_Label))); mGrid->SetColMinimalWidth(Col_Label, mGrid->GetColSize(Col_Label)); // Layout the works Layout(); // Resize width based on width of columns and the vertical scrollbar wxRect r = mGrid->GetGridColLabelWindow()->GetRect(); wxScrollBar sb(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL); r.width += sb.GetSize().GetWidth() + 6; SetClientSize(r.width, 300); // Make sure it doesn't go below this size r = GetRect(); SetSizeHints(r.GetWidth(), r.GetHeight()); // Center on display Center(); }
NyquistDialog::NyquistDialog(wxWindow * parent, wxWindowID id, const wxString & title, wxString info, NyqControlArray *controlArray) : wxDialog(parent, id, title) { mControls = controlArray; mInHandler = true; // prevents race condition on MSW wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); if (info.Length() > 0) { wxControl *item; item = new wxStaticText(this, -1, info); mainSizer->Add(item, 0, wxALIGN_LEFT | wxALL, 5); } wxFlexGridSizer *grid = new wxFlexGridSizer(4, 0, 0); for (size_t i = 0; i < mControls->GetCount(); i++) { wxControl *item; NyqControl *ctrl = &((*mControls)[i]); item = new wxStaticText(this, -1, ctrl->name + wxT(":")); grid->Add(item, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5); if (ctrl->type == NYQ_CTRL_STRING) { grid->Add(10, 10); item = new wxTextCtrl(this, ID_NYQ_TEXT+i, ctrl->valStr, wxDefaultPosition, wxSize(150, -1)); item->SetName(ctrl->name); grid->Add(item, 0, wxALIGN_CENTRE | wxALIGN_CENTER_VERTICAL | wxALL, 5); } else if (ctrl->type == NYQ_CTRL_CHOICE) { //str is coma separated labels for each choice wxString str = ctrl->label; wxArrayString choices; while (1) { int ci = str.Find( ',' ); //coma index if (ci == -1) { choices.Add( str ); break; } else { choices.Add(str.Left(ci)); } str = str.Right(str.length() - ci - 1); } wxChoice *choice = new wxChoice(this, ID_NYQ_CHOICE + i, wxDefaultPosition, wxSize(150, -1), choices); choice->SetName(ctrl->name); int val = (int)ctrl->val; if (val >= 0 && val < (int)choice->GetCount()) { choice->SetSelection(val); } grid->Add(10, 10); grid->Add(choice, 0, wxALIGN_CENTRE | wxALIGN_CENTER_VERTICAL | wxALL, 5); } else { // Integer or Real int val = (int)(0.5 + ctrl->ticks * (ctrl->val - ctrl->low) / (ctrl->high - ctrl->low)); item = new wxTextCtrl(this, ID_NYQ_TEXT+i, wxT(""), wxDefaultPosition, wxSize(60, -1)); item->SetName(ctrl->name); wxTextValidator vld(wxFILTER_NUMERIC); item->SetValidator(vld); grid->Add(item, 0, wxALIGN_CENTRE | wxALIGN_CENTER_VERTICAL | wxALL, 5); item = new wxSlider(this, ID_NYQ_SLIDER+i, val, 0, ctrl->ticks, wxDefaultPosition, wxSize(150, -1)); item->SetName(ctrl->name); grid->Add(item, 0, wxALIGN_CENTRE | wxALIGN_CENTER_VERTICAL | wxALL, 5); } if (ctrl->type == NYQ_CTRL_CHOICE) { grid->Add( 10, 10 ); } else { item = new wxStaticText(this, -1, ctrl->label); grid->Add(item, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5); } } mainSizer->Add(grid, 0, wxALIGN_CENTRE | wxALL, 5); mainSizer->Add(CreateStdButtonSizer(this, eDebugButton | eCancelButton | eOkButton), 0, wxEXPAND); mInHandler = false; wxCommandEvent dummy; OnSlider(dummy); SetAutoLayout(true); SetSizer(mainSizer); mainSizer->Fit(this); mainSizer->SetSizeHints(this); }
ExportMixerDialog::ExportMixerDialog( TrackList *tracks, bool selectedOnly, int maxNumChannels, wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style ) : wxDialog( parent, id, title, position, size, style | wxRESIZE_BORDER ) { int numTracks = 0; TrackListIterator iter( tracks ); for( Track *t = iter.First(); t; t = iter.Next() ) { if( t->GetKind() == Track::Wave && ( t->GetSelected() || !selectedOnly ) ) { numTracks++; if( t->GetChannel() == Track::LeftChannel ) { mTrackNames.Add( t->GetName() + _( " - Left" ) ); mTrackNames.Add( t->GetName() + _( " - Right" ) ); t = iter.Next(); numTracks++; } else mTrackNames.Add( t->GetName() ); } } // JKC: This is an attempt to fix a 'watching brief' issue, where the slider is // sometimes not slidable. My suspicion is that a mixer may incorrectly // state the number of channels - so we assume there are always at least two. // The downside is that if someone is exporting to a mono device, the dialog // will allow them to output to two channels. Hmm. We may need to revisit this. if (maxNumChannels < 2 ) maxNumChannels = 2; if (maxNumChannels > 32) maxNumChannels = 32; mMixerSpec = new MixerSpec( numTracks, maxNumChannels ); wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL ); wxWindow *mixerPanel = new ExportMixerPanel( mMixerSpec, mTrackNames, this, ID_MIXERPANEL, wxDefaultPosition, wxSize( 400, -1 ) ); vertSizer->Add( mixerPanel, 1, wxEXPAND | wxALIGN_CENTRE | wxALL, 5 ); wxBoxSizer *horSizer = new wxBoxSizer( wxHORIZONTAL ); mChannelsText = new wxStaticText( this, -1, wxString::Format( _( "Output Channels: %2d" ), mMixerSpec->GetNumChannels() ) ); horSizer->Add( mChannelsText, 0, wxALIGN_LEFT | wxALL, 5 ); wxSlider *channels = new wxSlider( this, ID_SLIDER_CHANNEL, mMixerSpec->GetNumChannels(), 1, mMixerSpec->GetMaxNumChannels(), wxDefaultPosition, wxSize( 300, -1 ) ); horSizer->Add( channels, 0, wxEXPAND | wxALL, 5 ); vertSizer->Add( horSizer, 0, wxALIGN_CENTRE | wxALL, 5 ); vertSizer->Add( CreateStdButtonSizer(this, eCancelButton|eOkButton), 0, wxEXPAND ); SetAutoLayout( true ); SetSizer( vertSizer ); vertSizer->Fit( this ); vertSizer->SetSizeHints( this ); SetSizeHints( 640, 480, 20000, 20000 ); SetSize( 640, 480 ); }
LabelDialog::LabelDialog(wxWindow *parent, TrackFactory &factory, TrackList *tracks, ViewInfo &viewinfo, double rate, const wxString & format) : wxDialog(parent, wxID_ANY, _("Edit Labels"), wxDefaultPosition, wxSize(800, 600), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), mFactory(factory), mTracks(tracks), mViewInfo(&viewinfo), mRate(rate), mFormat(format) { SetName(GetTitle()); { // Create the main sizer auto vs = std::make_unique<wxBoxSizer>(wxVERTICAL); // A little instruction wxStaticText *instruct = safenew wxStaticText(this, wxID_ANY, _("Press F2 or double click to edit cell contents.")); instruct->SetName(instruct->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) vs->Add(instruct, 0, wxALIGN_LEFT | wxALL, 5); // Create the main sizer mGrid = safenew Grid(this, wxID_ANY); vs->Add(mGrid, 1, wxEXPAND | wxALL, 5); // Create the action buttons { auto hs = std::make_unique<wxBoxSizer>(wxHORIZONTAL); hs->Add(safenew wxButton(this, ID_INSERTA, _("Insert &After")), 1, wxCENTER | wxALL, 5); hs->Add(safenew wxButton(this, ID_INSERTB, _("Insert &Before")), 1, wxCENTER | wxALL, 5); hs->Add(safenew wxButton(this, ID_REMOVE, _("&Remove")), 1, wxCENTER | wxALL, 5); hs->Add(safenew wxButton(this, ID_IMPORT, _("&Import...")), 1, wxCENTER | wxALL, 5); hs->Add(safenew wxButton(this, ID_EXPORT, _("&Export...")), 1, wxCENTER | wxALL, 5); vs->Add(hs.release(), 0, wxEXPAND | wxCENTER | wxALL, 5); } // Create the exit buttons vs->Add(CreateStdButtonSizer(this, eCancelButton | eOkButton).release(), 0, wxEXPAND); // Make it so SetSizer(vs.release()); } // Build the initial (empty) grid mGrid->CreateGrid(0, Col_Max); mGrid->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER); /* i18n-hint: (noun). A track contains waves, audio etc.*/ mGrid->SetColLabelValue(0,_("Track")); /* i18n-hint: (noun)*/ mGrid->SetColLabelValue(1,_("Label")); /* i18n-hint: (noun) of a label*/ mGrid->SetColLabelValue(2,_("Start Time")); /* i18n-hint: (noun) of a label*/ mGrid->SetColLabelValue(3,_("End Time")); // Create and remember editors. No need to DELETE these as the wxGrid will // do it for us. (The DecRef() that is needed after GetDefaultEditorForType // becomes the duty of the wxGridCellAttr objects after we set them in the grid.) mChoiceEditor = (ChoiceEditor *) mGrid->GetDefaultEditorForType(GRID_VALUE_CHOICE); mTimeEditor = (TimeEditor *) mGrid->GetDefaultEditorForType(GRID_VALUE_TIME); // Initialize and set the track name column attributes wxGridCellAttr *attr; mGrid->SetColAttr(Col_Track, (attr = safenew wxGridCellAttr)); attr->SetEditor(mChoiceEditor); mTrackNames.Add(_("New...")); // Initialize and set the time column attributes mGrid->SetColAttr(Col_Stime, (attr = safenew wxGridCellAttr)); // Don't need DecRef() after this GetDefaultRendererForType. attr->SetRenderer(mGrid->GetDefaultRendererForType(GRID_VALUE_TIME)); attr->SetEditor(mTimeEditor); attr->SetAlignment(wxALIGN_CENTER, wxALIGN_CENTER); mGrid->SetColAttr(Col_Etime, attr->Clone()); // Seems there's a bug in wxGrid. Adding only 1 row does not // allow SetCellSize() to work properly and you will not get // the expected 1 row by 4 column cell. // // So, we set the minimum row height to 0 and basically hide // the extra row by setting its height to 0. And not allowing the // rows to be manually resized prevents the user from ever seeing // the extra row. mGrid->SetRowMinimalAcceptableHeight(0); mGrid->EnableDragRowSize(false); // Locate all labels in current track list FindAllLabels(); // Populate the grid TransferDataToWindow(); // Resize the label name column and ensure it doesn't go below an // arbitrary width. // // This should not be in TransferDataToWindow() since a user might // resize the column and we'd resize it back to the minimum. mGrid->AutoSizeColumn(Col_Label, false ); mGrid->SetColSize(Col_Label, wxMax(150, mGrid->GetColSize(Col_Label))); mGrid->SetColMinimalWidth(Col_Label, mGrid->GetColSize(Col_Label)); // Layout the works Layout(); // Resize width based on width of columns and the vertical scrollbar wxRect r = mGrid->GetGridColLabelWindow()->GetRect(); wxScrollBar sb(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL); r.width += sb.GetSize().GetWidth() + 6; SetClientSize(r.width, 300); // Make sure it doesn't go below this size r = GetRect(); SetSizeHints(r.GetWidth(), r.GetHeight()); // Center on display Center(); }
ChangeSpeedDialog::ChangeSpeedDialog(EffectChangeSpeed * effect, wxWindow * parent, wxWindowID id, const wxString & title, const wxPoint & position, const wxSize & size, long style) : wxDialog(parent, id, title, position, size, style) { m_bLoopDetect = false; m_pEffect = effect; // NULL out these control members because there are some cases where the // event table handlers get called during this method, and those handlers that // can cause trouble check for NULL. m_pTextCtrl_PercentChange = NULL; m_pSlider_PercentChange = NULL; m_pChoice_FromVinyl = NULL; m_pChoice_ToVinyl = NULL; // effect parameters m_PercentChange = 0.0; m_FromVinyl = 0; m_ToVinyl = 0; // CREATE THE CONTROLS PROGRAMMATICALLY. wxStaticText * pStaticText; wxBoxSizer * pBoxSizer_Dialog = new wxBoxSizer(wxVERTICAL); // heading pStaticText = new wxStaticText(this, -1, _("Change Speed, affecting both Tempo and Pitch"), wxDefaultPosition, wxDefaultSize, 0); pBoxSizer_Dialog->Add(pStaticText, 0, wxALIGN_CENTER | wxALL, 8); pStaticText = new wxStaticText(this, -1, _("by Vaughan Johnson && Dominic Mazzoni"), wxDefaultPosition, wxDefaultSize, 0); pBoxSizer_Dialog->Add(pStaticText, 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 8); pStaticText = new wxStaticText(this, -1, _("using SampleRate, by Erik de Castro Lopo"), wxDefaultPosition, wxDefaultSize, 0); pBoxSizer_Dialog->Add(pStaticText, 0, wxALIGN_CENTER | wxBOTTOM | wxLEFT | wxRIGHT, 8); // percent change controls // Group percent controls with spacers, // rather than static box, so they don't look isolated. pBoxSizer_Dialog->Add(0, 8, 0); // spacer wxBoxSizer * pBoxSizer_PercentChange = new wxBoxSizer(wxHORIZONTAL); pStaticText = new wxStaticText(this, -1, _("Percent Change:"), wxDefaultPosition, wxDefaultSize, 0); pBoxSizer_PercentChange->Add(pStaticText, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 4); //v Override wxTextValidator to disallow negative values <= -100.0? m_pTextCtrl_PercentChange = new wxTextCtrl(this, ID_TEXT_PERCENTCHANGE, wxT("0.0"), wxDefaultPosition, wxSize(60, -1), 0, wxTextValidator(wxFILTER_NUMERIC)); pBoxSizer_PercentChange->Add(m_pTextCtrl_PercentChange, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 4); pBoxSizer_Dialog->Add(pBoxSizer_PercentChange, 0, wxALIGN_CENTER | wxALL, 4); m_pSlider_PercentChange = new wxSlider(this, ID_SLIDER_PERCENTCHANGE, 0, PERCENTCHANGE_MIN, PERCENTCHANGE_MAX, wxDefaultPosition, wxSize(100, -1), wxSL_HORIZONTAL); pBoxSizer_Dialog->Add(m_pSlider_PercentChange, 1, wxGROW | wxALIGN_CENTER | wxLEFT | wxRIGHT, 4); pBoxSizer_Dialog->Add(0, 8, 0); // spacer // from/to Vinyl controls wxBoxSizer * pBoxSizer_Vinyl = new wxBoxSizer(wxHORIZONTAL); const wxString strArray_VinylRPM[] = {wxT("33 1/3"), wxT("45"), wxT("78"), /* i18n-hint: n/a is an English abbreviation meaning "not applicable" (in other words, unimportant, not relevant). */ _("n/a")}; const int numChoices = 4; pStaticText = new wxStaticText(this, -1, _("Standard Vinyl RPM: from"), wxDefaultPosition, wxDefaultSize, 0); pBoxSizer_Vinyl->Add(pStaticText, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 4); m_pChoice_FromVinyl = new wxChoice(this, ID_CHOICE_FROMVINYL, wxDefaultPosition, wxDefaultSize, numChoices, strArray_VinylRPM); pBoxSizer_Vinyl->Add(m_pChoice_FromVinyl, 0, wxALIGN_CENTER | wxALL, 4); pStaticText = new wxStaticText(this, -1, _("to"), wxDefaultPosition, wxDefaultSize, 0); pBoxSizer_Vinyl->Add(pStaticText, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 4); m_pChoice_ToVinyl = new wxChoice(this, ID_CHOICE_TOVINYL, wxDefaultPosition, wxDefaultSize, numChoices, strArray_VinylRPM); pBoxSizer_Vinyl->Add(m_pChoice_ToVinyl, 0, wxALIGN_CENTER | wxALL, 4); pBoxSizer_Dialog->Add(pBoxSizer_Vinyl, 0, wxALIGN_CENTER | wxALL, 4); // Preview, OK, & Cancel buttons pBoxSizer_Dialog->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND); this->SetAutoLayout(true); this->SetSizer(pBoxSizer_Dialog); pBoxSizer_Dialog->Fit(this); pBoxSizer_Dialog->SetSizeHints(this); }