2 Copyright (C) 2003 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <sigc++/bind.h>
24 #include <gtkmm/stock.h>
25 #include <gtkmm/messagedialog.h>
26 #include <gtkmm/separator.h>
27 #include <gtkmm/table.h>
29 #include "pbd/error.h"
30 #include "pbd/convert.h"
32 #include "gtkmm2ext/utils.h"
33 #include "gtkmm2ext/doi.h"
35 #include "widgets/tooltips.h"
37 #include "ardour/plugin_manager.h"
38 #include "ardour/profile.h"
39 #include "ardour/template_utils.h"
40 #include "ardour/route_group.h"
41 #include "ardour/session.h"
42 #include "ardour/vca.h"
44 #include "LuaBridge/LuaBridge.h"
46 #include "add_route_dialog.h"
47 #include "ardour_ui.h"
48 #include "route_group_dialog.h"
54 using namespace Gtkmm2ext;
57 using namespace ARDOUR;
58 using namespace ARDOUR_UI_UTILS;
60 std::vector<std::string> AddRouteDialog::channel_combo_strings;
61 std::vector<std::pair<std::string,std::string> > AddRouteDialog::builtin_types;
63 AddRouteDialog::AddRouteDialog ()
64 : ArdourDialog (_("Add Track/Bus/VCA"))
65 , routes_adjustment (1, 1, 128, 1, 4)
66 , routes_spinner (routes_adjustment)
67 , configuration_label (_("Configuration:"))
68 , manual_label (_("Configuration:"))
69 , add_label (_("Add:"))
70 , name_label (_("Name:"))
71 , group_label (_("Group:"))
72 , insert_label (_("Position:"))
73 , strict_io_label (_("Pin Mode:"))
74 , mode_label (_("Record Mode:"))
75 , instrument_label (_("Instrument:"))
76 , name_edited_by_user (false)
78 set_name ("AddRouteDialog");
79 set_skip_taskbar_hint (true);
80 set_resizable (false);
81 set_position (WIN_POS_MOUSE);
83 name_template_entry.set_name (X_("AddRouteDialogNameTemplateEntry"));
84 // routes_spinner.set_name (X_("AddRouteDialogSpinner"));
85 channel_combo.set_name (X_("ChannelCountSelector"));
86 mode_combo.set_name (X_("ChannelCountSelector"));
88 refill_track_modes ();
90 if (builtin_types.empty()) {
91 builtin_types.push_back (
92 std::pair<string,string> (_("Audio Tracks"), std::string () +
93 _("Use these settings to create one or more audio tracks.") + "\n\n" +
94 _("You may select:") + "\n" +
95 "* " + _("The number of tracks to add") + "\n" +
96 "* " + _("A name for the track(s)") + "\n" +
97 "* " + _("Mono, stereo, or multi-channel operation for the track(s)") + "\n" +
98 "* " + _("A group which the track(s) will be assigned to") + "\n" +
100 "* " + _("The pin connections mode (see tooltip for details)") + "\n" +
101 "* " + _("Normal (non-destructive) or tape (destructive) recording mode") + "\n" +
103 "\n" + _("The track(s) will be added at the location specified by \"Position\"")
106 builtin_types.push_back (
107 std::pair<string,string> (_("MIDI Tracks"), std::string () +
108 _(" Use these settings to create one or more MIDI tracks.") + "\n\n" +
109 _("You may select:") + "\n" +
110 "* " + _("The number of tracks to add") + "\n" +
111 "* " + _("A name for the track(s)") + "\n" +
112 "* " + _("An instrument plugin (or select \"None\" to drive an external device)") + "\n" +
113 "* " + _("A group which the track(s) will be assigned to") + "\n" +
115 "* " + _("The pin connections mode (see tooltip for details)") + "\n" +
117 "\n" + _("The track(s) will be added at the location specified by \"Position\"")
121 builtin_types.push_back (
122 std::pair<string,string> (_("Audio+MIDI Tracks"), std::string () +
123 _("Use these settings to create one or more Audio+MIDI tracks.") + "\n\n" +
124 _("You may select:") + "\n" +
125 "* " + _("The number of tracks to add") + "\n" +
126 "* " + _("A name for the track(s)") + "\n" +
127 "* " + _("An instrument plugin (or select \"None\" to drive an external device)") + "\n" +
128 "* " + _("A group which the track(s) will be assigned to") + "\n" +
130 "* " + _("The pin connections mode (see tooltip for details)") + "\n" +
131 "* " + _("Normal (non-destructive) or tape (destructive) recording mode") + "\n" +
133 "\n" + _("The track(s) will be added at the location specified by \"Position\"")
137 builtin_types.push_back (
138 std::pair<string,string> (_("Audio Busses"), std::string () +
139 _("Use these settings to create one or more audio busses.") + "\n\n" +
140 _("You may select:") + "\n" +
141 "* " + _("The number of busses to add") + "\n" +
142 "* " + _("A name for the buss(es)") + "\n" +
143 "* " + _("A group which the buss(es) will be assigned to") + "\n" +
145 "* " + _("The pin connections mode (see tooltip for details)") + "\n" +
147 "\n" + _("The buss(es) will be added at the location specified by \"Position\"")
150 builtin_types.push_back (
151 std::pair<string,string> (_("MIDI Busses"), std::string () +
152 _("Use these settings to create one or more MIDI busses.") + "\n\n" +
153 _("MIDI busses can combine the output of multiple tracks. They are sometimes used\nto host a single \"heavy\" instrument plugin which is fed from multiple MIDI tracks.") + "\n\n" +
154 _("You may select:") + "\n" +
155 "* " + _("The number of busses to add") + "\n" +
156 "* " + _("A name for the buss(es)") + "\n" +
157 "* " + _("An instrument plugin (or select \"None\" to drive an external device)") + "\n" +
158 "* " + _("A group which the buss(es) will be assigned to") + "\n" +
160 "* " + _("The pin connections mode (see tooltip for details)") + "\n" +
162 "\n" + _("The buss(es) will be added at the location specified by \"Position\"")
165 builtin_types.push_back (
166 std::pair<string,string> (_("VCA Masters"), std::string () +
167 _("Use these settings to create one or more VCA masters.") + "\n\n" +
168 _("You may select:") + "\n" +
169 "* " + _("The number of VCAs to add") + "\n" +
170 "* " + _("A name for the VCA(s). \"%n\" will be replaced by an index number for each VCA")
173 builtin_types.push_back (
174 std::pair<string,string> (_("Foldback Busses"), std::string () +
175 _("Use these settings to create one or more foldback busses.") + "\n\n" +
176 _("Foldback busses are used as master outputs for monitor channels and are fed by\nhidden monitor sends.") + "\n\n" +
177 _("You may select:") + "\n" +
178 "* " + _("The number of busses to add") + "\n" +
179 "* " + _("A name for the buss(es)")
183 insert_at_combo.append_text (_("First"));
184 insert_at_combo.append_text (_("Before Selection"));
185 insert_at_combo.append_text (_("After Selection"));
186 insert_at_combo.append_text (_("Last"));
187 insert_at_combo.set_active (3);
189 strict_io_combo.append_text (_("Flexible-I/O"));
190 strict_io_combo.append_text (_("Strict-I/O"));
191 strict_io_combo.set_active (Config->get_strict_io () ? 1 : 0);
194 VBox* vbox = manage (new VBox);
195 get_vbox()->set_spacing (4);
196 vbox->set_spacing (18);
197 vbox->set_border_width (5);
199 /* this box contains the template chooser, and the template details */
200 HBox* template_hbox = manage (new HBox);
201 template_hbox->set_spacing (8);
203 /* scrollbars for the template chooser and template descriptions.... */
204 Gtk::ScrolledWindow *template_scroller = manage (new Gtk::ScrolledWindow());
205 template_scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
206 template_scroller->add (trk_template_chooser);
208 Gtk::ScrolledWindow *desc_scroller = manage (new Gtk::ScrolledWindow());
209 desc_scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
210 desc_scroller->add (trk_template_desc);
212 /* this is the outer sample that surrounds the description and the settings-table */
213 trk_template_outer_frame.set_name (X_("TextHighlightFrame"));
215 /* this is the "inner frame" that surrounds the description text */
216 trk_template_desc_frame.set_name (X_("TextHighlightFrame"));
217 trk_template_desc_frame.add (*desc_scroller);
219 /* template_chooser is the treeview showing available templates */
220 trk_template_model = TreeStore::create (track_template_columns);
221 trk_template_chooser.set_model (trk_template_model);
222 trk_template_chooser.append_column (_("Template/Type"), track_template_columns.name);
224 trk_template_chooser.append_column (_("Modified With"), track_template_columns.modified_with);
226 trk_template_chooser.set_headers_visible (true);
227 trk_template_chooser.get_selection()->set_mode (SELECTION_SINGLE);
228 trk_template_chooser.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::trk_template_row_selected));
229 trk_template_chooser.set_sensitive (true);
231 /* template_desc is the textview that displays the currently selected template's description */
232 trk_template_desc.set_editable (false);
233 trk_template_desc.set_can_focus (false);
234 trk_template_desc.set_wrap_mode (Gtk::WRAP_WORD);
235 trk_template_desc.set_size_request(400,200);
236 trk_template_desc.set_name (X_("TextOnBackground"));
237 trk_template_desc.set_border_width (6);
239 Table *settings_table = manage (new Table (2, 6, false));
240 settings_table->set_row_spacings (8);
241 settings_table->set_col_spacings (4);
242 settings_table->set_col_spacing (3, 20);
243 settings_table->set_border_width (12);
245 VBox* settings_vbox = manage (new VBox);
246 settings_vbox->pack_start(trk_template_desc_frame , true, true);
247 settings_vbox->pack_start(*settings_table , true, true);
248 settings_vbox->set_border_width (4);
250 trk_template_outer_frame.add (*settings_vbox);
252 template_hbox->pack_start (*template_scroller, true, true);
253 template_hbox->pack_start (trk_template_outer_frame, true, true);
255 vbox->pack_start (*template_hbox, true, true);
258 /* Now pack the "settings table" with manual controls (these controls are sensitized by the left-side selection) */
262 HBox *separator_hbox = manage (new HBox);
263 separator_hbox->pack_start (manual_label, false, false);
264 separator_hbox->pack_start (*(manage (new Gtk::HSeparator)), true, true);
265 separator_hbox->set_spacing (6);
266 settings_table->attach (*separator_hbox, 0, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
271 add_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
272 settings_table->attach (add_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
273 Gtk::Alignment *align = manage (new Alignment (0, .5, 0, 0));
274 align->add (routes_spinner);
275 settings_table->attach (*align, 1, 2, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
280 name_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
281 settings_table->attach (name_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
282 settings_table->attach (name_template_entry, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
284 /* Route configuration */
285 configuration_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
286 settings_table->attach (configuration_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
287 settings_table->attach (channel_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
291 /* instrument choice (for MIDI) */
292 instrument_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
293 settings_table->attach (instrument_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
294 settings_table->attach (instrument_combo, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
297 group_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
298 settings_table->attach (group_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
299 settings_table->attach (route_group_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
303 /* New Route's I/O is.. {strict/flexible} */
304 if (Profile->get_mixbus ()) {
305 strict_io_combo.set_active (1);
307 strict_io_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
308 settings_table->attach (strict_io_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
309 settings_table->attach (strict_io_combo, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
311 ArdourWidgets::set_tooltip (strict_io_combo,
312 _("With strict-i/o enabled, Effect Processors will not modify the number of channels on a track. The number of output channels will always match the number of input channels."));
315 mode_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
316 settings_table->attach (mode_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
317 settings_table->attach (mode_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
322 HBox* outer_box = manage (new HBox);
323 outer_box->set_spacing (4);
325 /* New route will be inserted at.. */
326 insert_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
327 outer_box->pack_start (insert_label, false, false);
328 outer_box->pack_start (insert_at_combo, false, false);
330 /* quick-add button (add item but don't close dialog) */
331 Gtk::Button* addnoclose_button = manage (new Gtk::Button(_("Add selected items (and leave dialog open)")));
332 addnoclose_button->set_can_default ();
333 addnoclose_button->signal_clicked ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), Add));
334 outer_box->pack_end (*addnoclose_button, false, false);
336 vbox->pack_start (*outer_box, true, true);
338 get_vbox()->pack_start (*vbox, false, false);
340 name_template_entry.signal_insert_text ().connect (sigc::mem_fun (*this, &AddRouteDialog::name_template_entry_insertion));
341 name_template_entry.signal_delete_text ().connect (sigc::mem_fun (*this, &AddRouteDialog::name_template_entry_deletion));
342 channel_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::channel_combo_changed));
343 channel_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::channel_separator));
344 route_group_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::route_separator));
345 route_group_combo.signal_changed ().connect (sigc::mem_fun (*this, &AddRouteDialog::group_changed));
347 routes_spinner.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose));
348 name_template_entry.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose));
349 trk_template_chooser.signal_row_activated ().connect (sigc::hide (sigc::hide (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose))));
351 show_all_children ();
353 /* track template info will be managed whenever
354 * this dialog is shown, via ::on_show()
357 add_button (_("Add and Close"), AddAndClose);
358 set_response_sensitive (AddAndClose, true);
359 set_default_response (AddAndClose);
361 refill_channel_setups ();
364 AddRouteDialog::~AddRouteDialog ()
369 AddRouteDialog::on_response (int r)
371 reset_name_edited ();
372 /* Don't call ArdourDialog::on_response() because that will
373 automatically hide the dialog.
375 Gtk::Dialog::on_response (r);
379 AddRouteDialog::trk_template_row_selected ()
381 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
385 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
388 string d = (*iter)[track_template_columns.description];
389 trk_template_desc.get_buffer ()->set_text (d);
391 const string n = (*iter)[track_template_columns.name];
392 const string p = (*iter)[track_template_columns.path];
394 if (p.substr (0, 11) == "urn:ardour:") {
395 /* lua script - meta-template */
396 const std::map<std::string, std::string> rs (ARDOUR_UI::instance()->route_setup_info (p.substr (11)));
398 trk_template_desc.set_sensitive (true);
400 add_label.set_sensitive (rs.find ("how_many") != rs.end ());
401 name_label.set_sensitive (rs.find ("name") != rs.end());
402 group_label.set_sensitive (rs.find ("group") != rs.end());
403 configuration_label.set_sensitive (rs.find ("channels") != rs.end ());
404 mode_label.set_sensitive (rs.find ("track_mode") != rs.end ());
405 instrument_label.set_sensitive (rs.find ("instrument") != rs.end ());
406 strict_io_label.set_sensitive (rs.find ("strict_io") != rs.end());
408 routes_spinner.set_sensitive (rs.find ("how_many") != rs.end ());
409 name_template_entry.set_sensitive (rs.find ("name") != rs.end ());
410 route_group_combo.set_sensitive (rs.find ("group") != rs.end());
411 channel_combo.set_sensitive (rs.find ("channels") != rs.end ());
412 mode_combo.set_sensitive (rs.find ("track_mode") != rs.end ());
413 instrument_combo.set_sensitive (rs.find ("instrument") != rs.end ());
414 strict_io_combo.set_sensitive (rs.find ("strict_io") != rs.end());
416 bool any_enabled = rs.find ("how_many") != rs.end ()
417 || rs.find ("name") != rs.end ()
418 || rs.find ("group") != rs.end()
419 || rs.find ("channels") != rs.end ()
420 || rs.find ("track_mode") != rs.end ()
421 || rs.find ("instrument") != rs.end ()
422 || rs.find ("strict_io") != rs.end();
424 manual_label.set_sensitive (any_enabled);
426 std::map<string,string>::const_iterator it;
428 if ((it = rs.find ("name")) != rs.end()) {
429 name_template_entry.set_text (it->second);
431 name_template_entry.set_text ("");
434 if ((it = rs.find ("how_many")) != rs.end()) {
435 if (atoi (it->second.c_str()) > 0) {
436 routes_adjustment.set_value (atoi (it->second.c_str()));
440 if ((it = rs.find ("track_mode")) != rs.end()) {
441 switch ((ARDOUR::TrackMode) atoi (it->second.c_str())) {
443 mode_combo.set_active_text (_("Normal"));
445 case ARDOUR::Destructive:
446 if (!ARDOUR::Profile->get_mixbus ()) {
447 mode_combo.set_active_text (_("Tape"));
450 default: // "NonLayered" enum is still present for session-format compat
455 if ((it = rs.find ("strict_io")) != rs.end()) {
456 if (it->second == X_("true")) {
457 strict_io_combo.set_active (1);
458 } else if (it->second == X_("false")) {
459 strict_io_combo.set_active (0);
463 if ((it = rs.find ("channels")) != rs.end()) {
464 uint32_t channels = atoi (it->second.c_str());
465 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
466 if ((*i).channels == channels) {
467 channel_combo.set_active_text ((*i).name);
473 } else if (!p.empty ()) {
475 trk_template_desc.set_sensitive (true);
477 manual_label.set_sensitive (true);
478 add_label.set_sensitive (true);
479 name_label.set_sensitive (true);
480 group_label.set_sensitive (false);
481 strict_io_label.set_sensitive (false);
482 configuration_label.set_sensitive (false);
483 mode_label.set_sensitive (false);
484 instrument_label.set_sensitive (false);
486 routes_spinner.set_sensitive (true);
487 name_template_entry.set_sensitive (true);
488 channel_combo.set_sensitive (false);
489 mode_combo.set_sensitive (false);
490 instrument_combo.set_sensitive (false);
491 strict_io_combo.set_sensitive (false);
492 route_group_combo.set_sensitive (false);
495 /* all manual mode */
496 trk_template_desc.set_sensitive (false);
498 manual_label.set_sensitive (true);
499 add_label.set_sensitive (true);
500 name_label.set_sensitive (true);
501 group_label.set_sensitive (true);
502 strict_io_label.set_sensitive (true);
504 routes_spinner.set_sensitive (true);
505 name_template_entry.set_sensitive (true);
506 track_type_chosen ();
512 AddRouteDialog::name_template_entry_insertion (Glib::ustring const &,int*)
514 if (name_template ().empty ()) {
515 name_edited_by_user = false;
517 name_edited_by_user = true;
522 AddRouteDialog::name_template_entry_deletion (int, int)
524 if (name_template ().empty ()) {
525 name_edited_by_user = false;
527 name_edited_by_user = true;
532 AddRouteDialog::channel_combo_changed ()
534 refill_track_modes ();
538 AddRouteDialog::get_template_path ()
542 if (trk_template_chooser.get_selection()->count_selected_rows() > 0) {
543 TreeIter iter = trk_template_chooser.get_selection()->get_selected();
546 string n = (*iter)[track_template_columns.name];
547 if (n != _("Manual Configuration")) {
548 p = (*iter)[track_template_columns.path];
557 AddRouteDialog::TypeWanted
558 AddRouteDialog::type_wanted()
560 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
563 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
566 const string str = (*iter)[track_template_columns.name];
567 if (str == _("Audio Busses")) {
569 } else if (str == _("MIDI Busses")){
571 } else if (str == _("MIDI Tracks")){
573 } else if (str == _("Audio+MIDI Tracks")) {
575 } else if (str == _("Audio Tracks")) {
577 } else if (str == _("VCA Masters")) {
579 } else if (str == _("Foldback Busses")) {
588 AddRouteDialog::maybe_update_name_template_entry ()
590 if (name_edited_by_user) {
594 switch (type_wanted()) {
596 name_template_entry.set_text (_("Audio"));
599 name_template_entry.set_text (_("MIDI"));
602 name_template_entry.set_text (_("Audio+MIDI"));
606 name_template_entry.set_text (_("Bus"));
609 name_template_entry.set_text (_("Foldback"));
612 name_template_entry.set_text (VCA::default_name_template());
615 /* ignore programatic change, restore false */
616 reset_name_edited ();
620 AddRouteDialog::track_type_chosen ()
622 switch (type_wanted()) {
625 configuration_label.set_sensitive (true);
626 channel_combo.set_sensitive (true);
628 mode_label.set_sensitive (true);
629 mode_combo.set_sensitive (true);
631 instrument_label.set_sensitive (false);
632 instrument_combo.set_sensitive (false);
634 group_label.set_sensitive (true);
635 route_group_combo.set_sensitive (true);
637 strict_io_label.set_sensitive (true);
638 strict_io_combo.set_sensitive (true);
640 insert_label.set_sensitive (true);
641 insert_at_combo.set_sensitive (true);
646 configuration_label.set_sensitive (false);
647 channel_combo.set_sensitive (false);
649 mode_label.set_sensitive (false);
650 mode_combo.set_sensitive (false);
652 instrument_label.set_sensitive (true);
653 instrument_combo.set_sensitive (true);
655 group_label.set_sensitive (true);
656 route_group_combo.set_sensitive (true);
658 strict_io_label.set_sensitive (true);
659 strict_io_combo.set_sensitive (true);
661 insert_label.set_sensitive (true);
662 insert_at_combo.set_sensitive (true);
667 MessageDialog msg (_("Audio+MIDI tracks are intended for use <b>ONLY</b> with plugins that use both audio and MIDI input data.\n\n"
668 "Use a normal audio or MIDI track if you do not plan to use such a plugin."),
669 true, MESSAGE_INFO, BUTTONS_OK, true);
670 msg.set_position (WIN_POS_MOUSE);
674 configuration_label.set_sensitive (true);
675 channel_combo.set_sensitive (true);
677 mode_label.set_sensitive (true);
678 mode_combo.set_sensitive (true);
680 instrument_label.set_sensitive (true);
681 instrument_combo.set_sensitive (true);
683 group_label.set_sensitive (true);
684 route_group_combo.set_sensitive (true);
686 strict_io_label.set_sensitive (true);
687 strict_io_combo.set_sensitive (true);
689 insert_label.set_sensitive (true);
690 insert_at_combo.set_sensitive (true);
695 configuration_label.set_sensitive (true);
696 channel_combo.set_sensitive (true);
698 mode_label.set_sensitive (false);
699 mode_combo.set_sensitive (false);
701 instrument_label.set_sensitive (false);
702 instrument_combo.set_sensitive (false);
704 group_label.set_sensitive (true);
705 route_group_combo.set_sensitive (true);
707 strict_io_label.set_sensitive (true);
708 strict_io_combo.set_sensitive (true);
710 insert_label.set_sensitive (true);
711 insert_at_combo.set_sensitive (true);
716 configuration_label.set_sensitive (false);
717 channel_combo.set_sensitive (false);
719 mode_label.set_sensitive (false);
720 mode_combo.set_sensitive (false);
722 instrument_label.set_sensitive (false);
723 instrument_combo.set_sensitive (false);
725 group_label.set_sensitive (false);
726 route_group_combo.set_sensitive (false);
728 strict_io_label.set_sensitive (false);
729 strict_io_combo.set_sensitive (false);
731 insert_label.set_sensitive (false);
732 insert_at_combo.set_sensitive (false);
737 configuration_label.set_sensitive (false);
738 channel_combo.set_sensitive (false);
740 mode_label.set_sensitive (false);
741 mode_combo.set_sensitive (false);
743 instrument_label.set_sensitive (true);
744 instrument_combo.set_sensitive (true);
746 group_label.set_sensitive (true);
747 route_group_combo.set_sensitive (true);
749 strict_io_label.set_sensitive (true);
750 strict_io_combo.set_sensitive (true);
752 insert_label.set_sensitive (true);
753 insert_at_combo.set_sensitive (true);
758 configuration_label.set_sensitive (false);
759 channel_combo.set_sensitive (false);
761 mode_label.set_sensitive (false);
762 mode_combo.set_sensitive (false);
764 instrument_label.set_sensitive (false);
765 instrument_combo.set_sensitive (false);
767 group_label.set_sensitive (false);
768 route_group_combo.set_sensitive (false);
770 strict_io_label.set_sensitive (false);
771 strict_io_combo.set_sensitive (false);
773 insert_label.set_sensitive (false);
774 insert_at_combo.set_sensitive (false);
779 maybe_update_name_template_entry ();
783 AddRouteDialog::name_template () const
785 return name_template_entry.get_text ();
789 AddRouteDialog::name_template_is_default () const
791 string n = name_template();
793 if (n == _("Audio") ||
795 n == _("Audio+MIDI") ||
797 n == VCA::default_name_template()) {
805 AddRouteDialog::count ()
807 return (int) floor (routes_adjustment.get_value ());
811 AddRouteDialog::refill_track_modes ()
815 s.push_back (_("Normal"));
816 if (!ARDOUR::Profile->get_mixbus ()) {
817 s.push_back (_("Tape"));
820 set_popdown_strings (mode_combo, s);
821 mode_combo.set_active_text (s.front());
825 AddRouteDialog::mode ()
827 std::string str = mode_combo.get_active_text();
828 if (str == _("Normal")) {
829 return ARDOUR::Normal;
830 } else if (str == _("Non Layered")){
831 return ARDOUR::NonLayered;
832 } else if (str == _("Tape")) {
833 return ARDOUR::Destructive;
835 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
837 abort(); /*NOTREACHED*/
840 return ARDOUR::Normal;
844 AddRouteDialog::channel_count ()
846 string str = channel_combo.get_active_text();
847 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
848 if (str == (*i).name) {
849 return (*i).channels;
856 AddRouteDialog::channels ()
859 switch (type_wanted()) {
862 ret.set (DataType::AUDIO, channel_count ());
863 ret.set (DataType::MIDI, 0);
868 ret.set (DataType::AUDIO, 0);
869 ret.set (DataType::MIDI, 1);
873 ret.set (DataType::AUDIO, channel_count ());
874 ret.set (DataType::MIDI, 1);
878 ret.set (DataType::AUDIO, 2);
879 ret.set (DataType::MIDI, 0);
890 AddRouteDialog::on_show ()
892 routes_spinner.grab_focus ();
893 reset_name_edited ();
895 refill_route_groups ();
896 refill_channel_setups ();
902 AddRouteDialog::refill_channel_setups ()
906 string channel_current_choice = channel_combo.get_active_text();
908 channel_combo_strings.clear ();
909 channel_setups.clear ();
911 chn.name = _("Mono");
913 channel_setups.push_back (chn);
915 chn.name = _("Stereo");
917 channel_setups.push_back (chn);
919 if (!ARDOUR::Profile->get_mixbus()) {
921 chn.name = "separator";
922 channel_setups.push_back (chn);
924 chn.name = _("3 Channel");
926 channel_setups.push_back (chn);
928 chn.name = _("4 Channel");
930 channel_setups.push_back (chn);
932 chn.name = _("5 Channel");
934 channel_setups.push_back (chn);
936 chn.name = _("6 Channel");
938 channel_setups.push_back (chn);
940 chn.name = _("8 Channel");
942 channel_setups.push_back (chn);
944 chn.name = _("12 Channel");
946 channel_setups.push_back (chn);
948 chn.name = _("Custom");
950 channel_setups.push_back (chn);
953 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
954 channel_combo_strings.push_back ((*i).name);
957 trk_template_model->clear();
958 bool selected_default = false;
960 for (std::vector<std::pair<std::string,std::string> >::const_iterator i = builtin_types.begin(); i != builtin_types.end(); ++i) {
961 TreeModel::Row row = *(trk_template_model->append ());
962 row[track_template_columns.name] = (*i).first;
963 row[track_template_columns.path] = "";
964 row[track_template_columns.description] = (*i).second;
965 row[track_template_columns.modified_with] = "";
967 if (!selected_default && !Profile->get_mixbus ()) {
968 trk_template_chooser.get_selection()->select(row);
969 selected_default = true;
973 /* Add any Lua scripts (factory templates) found in the scripts folder */
974 LuaScriptList& ms (LuaScripting::instance ().scripts (LuaScriptInfo::EditorAction));
975 for (LuaScriptList::const_iterator s = ms.begin(); s != ms.end(); ++s) {
976 if (!((*s)->subtype & LuaScriptInfo::RouteSetup)) {
980 if ((*s)->name == "Create Audio Tracks Interactively" && Profile->get_mixbus ()) {
981 /* somewhat-special, Ben says: "most-used template" */
982 row = *(trk_template_model->prepend ());
984 row = *(trk_template_model->append ());
986 row[track_template_columns.name] = (*s)->name;
987 row[track_template_columns.path] = "urn:ardour:" + (*s)->path;
988 row[track_template_columns.description] = (*s)->description;
989 row[track_template_columns.modified_with] = _("{Factory Template}");
991 if ((*s)->name == "Create Audio Tracks Interactively" && Profile->get_mixbus ()) {
992 trk_template_chooser.get_selection()->select(row);
993 selected_default = true;
997 if (!selected_default && !trk_template_model->children().empty()) {
998 TreeModel::Children rows = trk_template_model->children();
999 trk_template_chooser.get_selection()->select(rows[0]);
1002 std::vector<ARDOUR::TemplateInfo> route_templates;
1003 ARDOUR::find_route_templates (route_templates);
1005 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
1006 TreeModel::Row row = *(trk_template_model->append ());
1008 row[track_template_columns.name] = x->name;
1009 row[track_template_columns.path] = x->path;
1010 row[track_template_columns.description] = x->description;
1011 row[track_template_columns.modified_with] = x->modified_with;
1014 set_popdown_strings (channel_combo, channel_combo_strings);
1016 if (!channel_current_choice.empty()) {
1017 channel_combo.set_active_text (channel_current_choice);
1019 channel_combo.set_active_text (channel_combo_strings.front());
1024 AddRouteDialog::add_route_group (RouteGroup* g)
1026 route_group_combo.insert_text (3, g->name ());
1030 AddRouteDialog::route_group ()
1032 if (!_session || route_group_combo.get_active_row_number () == 2) {
1036 return _session->route_group_by_name (route_group_combo.get_active_text());
1040 AddRouteDialog::use_strict_io() {
1041 return strict_io_combo.get_active_row_number () == 1;
1045 AddRouteDialog::refill_route_groups ()
1047 route_group_combo.clear ();
1048 route_group_combo.append_text (_("New Group..."));
1050 route_group_combo.append_text ("separator");
1052 route_group_combo.append_text (_("No Group"));
1055 _session->foreach_route_group (sigc::mem_fun (*this, &AddRouteDialog::add_route_group));
1058 route_group_combo.set_active (2);
1062 AddRouteDialog::group_changed ()
1064 if (_session && route_group_combo.get_active_text () == _("New Group...")) {
1065 RouteGroup* g = new RouteGroup (*_session, "");
1066 RouteGroupDialog* d = new RouteGroupDialog (g, true);
1068 d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &AddRouteDialog::new_group_dialog_finished), d));
1074 AddRouteDialog::new_group_dialog_finished (int r, RouteGroupDialog* d)
1076 if (r == RESPONSE_OK) {
1078 if (!d->name_check()) {
1083 _session->add_route_group (d->group());
1086 add_route_group (d->group());
1087 route_group_combo.set_active (3);
1090 route_group_combo.set_active (2);
1093 delete_when_idle (d);
1096 RouteDialogs::InsertAt
1097 AddRouteDialog::insert_at ()
1099 using namespace RouteDialogs;
1101 std::string str = insert_at_combo.get_active_text();
1103 if (str == _("First")) {
1105 } else if (str == _("After Selection")) {
1106 return AfterSelection;
1107 } else if (str == _("Before Selection")){
1108 return BeforeSelection;
1114 AddRouteDialog::channel_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
1116 channel_combo.set_active (i);
1118 return channel_combo.get_active_text () == "separator";
1122 AddRouteDialog::route_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
1124 route_group_combo.set_active (i);
1126 return route_group_combo.get_active_text () == "separator";
1130 AddRouteDialog::requested_instrument ()
1132 return instrument_combo.selected_instrument();