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"), _( " \
93 Use the settings, below, to create 1 or more new Audio tracks.\n \
96 * The number of tracks to add.\n \
97 * A Name for the new track(s).\n \
98 * Mono, Stereo, or Multichannel operation for the new track(s).\n \
99 * A Group which the track 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 The track will be added in the location specified by \"Position\".\n \
106 builtin_types.push_back (
107 std::pair<string,string>(_("MIDI Tracks"), _(" \
108 Use the settings, below, to create 1 or more new MIDI tracks.\n \
111 * The number of tracks to add.\n \
112 * A Name for the track(s).\n \
113 * An Instrument plugin (or select \"None\" to drive an external device)\n \
114 * A Group which the track will be assigned to.\n \
115 * The Pin Connections mode. (see tooltip for details)\n \
117 The track will be added in the location specified by \"Position\".\n \
120 builtin_types.push_back (
121 std::pair<string,string>(_("Audio+MIDI Tracks"), _(" \
122 Use the settings, below, to create 1 or more new Audio+MIDI tracks.\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 will be assigned to the track(s).\n \
129 * Pin Connections mode. (see tooltip for details).\n \
130 * Normal (non-destructive) or Tape (destructive) recording mode.\n \
132 The track will be added in the location specified by \"Position\".\n \
135 builtin_types.push_back (
136 std::pair<string,string>(_("Audio Busses"), _(" \
137 Use the settings, below, to create new Audio Tracks.\n \
140 * The number of buses to add.\n \
141 * A Name for the track(s).\n \
142 * An Instrument plugin (or select \"None\" to drive an external device)\n \
143 * A Group which will be assigned to the track(s).\n \
144 * Pin Connections mode. (see tooltip for details).\n \
145 * Normal (non-destructive) or Tape (destructive) recording mode.\n \
147 The track will be added in the location specified by \"Position\".\n \
150 builtin_types.push_back (
151 std::pair<string,string>(_("MIDI Busses"), _(" \
152 Use the settings, below, to create new MIDI Busses.\n \
154 MIDI Busses can combine the output of multiple tracks. \n \
155 MIDI Buses are sometimes used to host a single \"heavy\" instrument plugin which is fed from multiple MIDI tracks. \
158 * The number of buses to add.\n \
159 * A Name for the track(s).\n \
160 * An Instrument plugin (or select \"None\" to drive an external device)\n \
161 * A Group which will be assigned to the track(s).\n \
162 * Pin Connections mode. (see tooltip for details).\n \
164 The track will be added in the location specified by \"Position\".\n \
167 builtin_types.push_back (
168 std::pair<string,string>(_("VCA Masters"), _(" \
169 Use the settings, below, to create 1 or more VCA Master(s).\n \
172 * The number of buses to add.\n \
173 * A name for the new VCAs. \"%n\" will be replaced by an index number for each VCA.\n \
178 insert_at_combo.append_text (_("First"));
179 insert_at_combo.append_text (_("Before Selection"));
180 insert_at_combo.append_text (_("After Selection"));
181 insert_at_combo.append_text (_("Last"));
182 insert_at_combo.set_active (3);
184 strict_io_combo.append_text (_("Flexible-I/O"));
185 strict_io_combo.append_text (_("Strict-I/O"));
186 strict_io_combo.set_active (Config->get_strict_io () ? 1 : 0);
189 VBox* vbox = manage (new VBox);
190 get_vbox()->set_spacing (4);
191 vbox->set_spacing (18);
192 vbox->set_border_width (5);
194 //this box contains the template chooser, and the template details
195 HBox* template_hbox = manage (new HBox);
196 template_hbox->set_spacing (8);
198 //scrollbars for the template chooser and template descriptions....
199 Gtk::ScrolledWindow *template_scroller = manage (new Gtk::ScrolledWindow());
200 template_scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
201 template_scroller->add (trk_template_chooser);
203 Gtk::ScrolledWindow *desc_scroller = manage (new Gtk::ScrolledWindow());
204 desc_scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
205 desc_scroller->add (trk_template_desc);
207 //this is the outer frame that surrounds the description and the settings-table
208 trk_template_outer_frame.set_name (X_("TextHighlightFrame"));
210 //this is the "inner frame" that surrounds the description text
211 trk_template_desc_frame.set_name (X_("TextHighlightFrame"));
212 trk_template_desc_frame.add (*desc_scroller);
214 /* template_chooser is the treeview showing available templates */
215 trk_template_model = TreeStore::create (track_template_columns);
216 trk_template_chooser.set_model (trk_template_model);
217 trk_template_chooser.append_column (_("Template/Type"), track_template_columns.name);
219 trk_template_chooser.append_column (_("Created With"), track_template_columns.created_with);
221 trk_template_chooser.set_headers_visible (true);
222 trk_template_chooser.get_selection()->set_mode (SELECTION_SINGLE);
223 trk_template_chooser.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::trk_template_row_selected));
224 trk_template_chooser.set_sensitive (true);
226 /* template_desc is the textview that displays the currently selected template's description */
227 trk_template_desc.set_editable (false);
228 trk_template_desc.set_can_focus (false);
229 trk_template_desc.set_wrap_mode (Gtk::WRAP_WORD);
230 trk_template_desc.set_size_request(400,200);
231 trk_template_desc.set_name (X_("TextOnBackground"));
232 trk_template_desc.set_border_width (6);
234 Table *settings_table = manage (new Table (2, 6, false));
235 settings_table->set_row_spacings (8);
236 settings_table->set_col_spacings (4);
237 settings_table->set_col_spacing (3, 20);
238 settings_table->set_border_width (12);
240 VBox* settings_vbox = manage (new VBox);
241 settings_vbox->pack_start(trk_template_desc_frame , true, true);
242 settings_vbox->pack_start(*settings_table , true, true);
243 settings_vbox->set_border_width (4);
245 trk_template_outer_frame.add (*settings_vbox);
247 template_hbox->pack_start (*template_scroller, true, true);
248 template_hbox->pack_start (trk_template_outer_frame, true, true);
250 vbox->pack_start (*template_hbox, true, true);
253 //Now pack the "settings table" with manual controls (these controls are sensitized by the left-side selection)
257 HBox *separator_hbox = manage (new HBox);
258 separator_hbox->pack_start (manual_label, false, false);
259 separator_hbox->pack_start (*(manage (new Gtk::HSeparator)), true, true);
260 separator_hbox->set_spacing (6);
261 settings_table->attach (*separator_hbox, 0, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
266 add_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
267 settings_table->attach (add_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
268 Gtk::Alignment *align = manage (new Alignment (0, .5, 0, 0));
269 align->add (routes_spinner);
270 settings_table->attach (*align, 1, 2, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
275 name_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
276 settings_table->attach (name_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
277 settings_table->attach (name_template_entry, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
279 // Route configuration
280 configuration_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
281 settings_table->attach (configuration_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
282 settings_table->attach (channel_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
286 // instrument choice (for MIDI)
287 instrument_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
288 settings_table->attach (instrument_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
289 settings_table->attach (instrument_combo, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
292 group_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
293 settings_table->attach (group_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
294 settings_table->attach (route_group_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
298 // New Route's I/O is.. {strict/flexible}
299 if (Profile->get_mixbus ()) {
300 strict_io_combo.set_active (1);
302 strict_io_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
303 settings_table->attach (strict_io_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
304 settings_table->attach (strict_io_combo, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
306 ArdourWidgets::set_tooltip (strict_io_combo,
307 _("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."));
310 mode_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
311 settings_table->attach (mode_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
312 settings_table->attach (mode_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
317 HBox* outer_box = manage (new HBox);
318 outer_box->set_spacing (4);
320 // New route will be inserted at..
321 insert_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
322 outer_box->pack_start (insert_label, false, false);
323 outer_box->pack_start (insert_at_combo, false, false);
325 //quick-add button (add item but don't close dialog)
326 Gtk::Button* addnoclose_button = manage (new Gtk::Button(_("Add selected items (and leave dialog open)")));
327 addnoclose_button->set_can_default ();
328 addnoclose_button->signal_clicked ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), Add));
329 outer_box->pack_end (*addnoclose_button, false, false);
331 vbox->pack_start (*outer_box, true, true);
333 get_vbox()->pack_start (*vbox, false, false);
335 name_template_entry.signal_insert_text ().connect (sigc::mem_fun (*this, &AddRouteDialog::name_template_entry_insertion));
336 name_template_entry.signal_delete_text ().connect (sigc::mem_fun (*this, &AddRouteDialog::name_template_entry_deletion));
337 channel_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::channel_combo_changed));
338 channel_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::channel_separator));
339 route_group_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::route_separator));
340 route_group_combo.signal_changed ().connect (sigc::mem_fun (*this, &AddRouteDialog::group_changed));
342 routes_spinner.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose));
343 name_template_entry.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose));
344 trk_template_chooser.signal_row_activated ().connect (sigc::hide (sigc::hide (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose))));
346 show_all_children ();
348 /* track template info will be managed whenever
349 * this dialog is shown, via ::on_show()
352 add_button (_("Add and Close"), AddAndClose);
353 set_response_sensitive (AddAndClose, true);
354 set_default_response (AddAndClose);
356 refill_channel_setups ();
359 AddRouteDialog::~AddRouteDialog ()
364 AddRouteDialog::on_response (int r)
366 reset_name_edited ();
367 /* Don't call ArdourDialog::on_response() because that will
368 automatically hide the dialog.
370 Gtk::Dialog::on_response (r);
374 AddRouteDialog::trk_template_row_selected ()
376 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
380 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
383 string d = (*iter)[track_template_columns.description];
384 trk_template_desc.get_buffer ()->set_text (d);
386 const string n = (*iter)[track_template_columns.name];
387 const string p = (*iter)[track_template_columns.path];
389 if (p.substr (0, 11) == "urn:ardour:") {
390 /* lua script - meta-template */
391 const std::map<std::string, std::string> rs (ARDOUR_UI::instance()->route_setup_info (p.substr (11)));
393 trk_template_desc.set_sensitive (true);
395 add_label.set_sensitive (rs.find ("how_many") != rs.end ());
396 name_label.set_sensitive (rs.find ("name") != rs.end());
397 group_label.set_sensitive (rs.find ("group") != rs.end());
398 configuration_label.set_sensitive (rs.find ("channels") != rs.end ());
399 mode_label.set_sensitive (rs.find ("track_mode") != rs.end ());
400 instrument_label.set_sensitive (rs.find ("instrument") != rs.end ());
401 strict_io_label.set_sensitive (rs.find ("strict_io") != rs.end());
403 routes_spinner.set_sensitive (rs.find ("how_many") != rs.end ());
404 name_template_entry.set_sensitive (rs.find ("name") != rs.end ());
405 route_group_combo.set_sensitive (rs.find ("group") != rs.end());
406 channel_combo.set_sensitive (rs.find ("channels") != rs.end ());
407 mode_combo.set_sensitive (rs.find ("track_mode") != rs.end ());
408 instrument_combo.set_sensitive (rs.find ("instrument") != rs.end ());
409 strict_io_combo.set_sensitive (rs.find ("strict_io") != rs.end());
411 bool any_enabled = rs.find ("how_many") != rs.end ()
412 || rs.find ("name") != rs.end ()
413 || rs.find ("group") != rs.end()
414 || rs.find ("channels") != rs.end ()
415 || rs.find ("track_mode") != rs.end ()
416 || rs.find ("instrument") != rs.end ()
417 || rs.find ("strict_io") != rs.end();
419 manual_label.set_sensitive (any_enabled);
421 std::map<string,string>::const_iterator it;
423 if ((it = rs.find ("name")) != rs.end()) {
424 name_template_entry.set_text (it->second);
426 name_template_entry.set_text ("");
430 if ((it = rs.find ("how_many")) != rs.end()) {
431 if (atoi (it->second.c_str()) > 0) {
432 routes_adjustment.set_value (atoi (it->second.c_str()));
436 if ((it = rs.find ("track_mode")) != rs.end()) {
437 switch ((ARDOUR::TrackMode) atoi (it->second.c_str())) {
439 mode_combo.set_active_text (_("Normal"));
441 case ARDOUR::Destructive:
442 if (!ARDOUR::Profile->get_mixbus ()) {
443 mode_combo.set_active_text (_("Tape"));
446 default: // "NonLayered" enum is still present for session-format compat
451 if ((it = rs.find ("strict_io")) != rs.end()) {
452 if (it->second == X_("true")) {
453 strict_io_combo.set_active (1);
454 } else if (it->second == X_("false")) {
455 strict_io_combo.set_active (0);
459 if ((it = rs.find ("channels")) != rs.end()) {
460 uint32_t channels = atoi (it->second.c_str());
461 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
462 if ((*i).channels == channels) {
463 channel_combo.set_active_text ((*i).name);
469 } else if (!p.empty ()) {
471 trk_template_desc.set_sensitive (true);
473 manual_label.set_sensitive (true);
474 add_label.set_sensitive (true);
475 name_label.set_sensitive (true);
476 group_label.set_sensitive (false);
477 strict_io_label.set_sensitive (false);
478 configuration_label.set_sensitive (false);
479 mode_label.set_sensitive (false);
480 instrument_label.set_sensitive (false);
482 routes_spinner.set_sensitive (true);
483 name_template_entry.set_sensitive (true);
484 channel_combo.set_sensitive (false);
485 mode_combo.set_sensitive (false);
486 instrument_combo.set_sensitive (false);
487 strict_io_combo.set_sensitive (false);
488 route_group_combo.set_sensitive (false);
491 /* all manual mode */
492 trk_template_desc.set_sensitive (false);
494 manual_label.set_sensitive (true);
495 add_label.set_sensitive (true);
496 name_label.set_sensitive (true);
497 group_label.set_sensitive (true);
498 strict_io_label.set_sensitive (true);
500 routes_spinner.set_sensitive (true);
501 name_template_entry.set_sensitive (true);
502 track_type_chosen ();
508 AddRouteDialog::name_template_entry_insertion (Glib::ustring const &,int*)
510 if (name_template ().empty ()) {
511 name_edited_by_user = false;
513 name_edited_by_user = true;
518 AddRouteDialog::name_template_entry_deletion (int, int)
520 if (name_template ().empty ()) {
521 name_edited_by_user = false;
523 name_edited_by_user = true;
528 AddRouteDialog::channel_combo_changed ()
530 refill_track_modes ();
534 AddRouteDialog::get_template_path ()
538 if (trk_template_chooser.get_selection()->count_selected_rows() > 0) {
539 TreeIter iter = trk_template_chooser.get_selection()->get_selected();
542 string n = (*iter)[track_template_columns.name];
543 if ( n != _("Manual Configuration") ) {
544 p = (*iter)[track_template_columns.path];
553 AddRouteDialog::TypeWanted
554 AddRouteDialog::type_wanted()
556 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
559 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
562 const string str = (*iter)[track_template_columns.name];
563 if (str == _("Audio Busses")) {
565 } else if (str == _("MIDI Busses")){
567 } else if (str == _("MIDI Tracks")){
569 } else if (str == _("Audio+MIDI Tracks")) {
571 } else if (str == _("Audio Tracks")) {
573 } else if (str == _("VCA Masters")) {
582 AddRouteDialog::maybe_update_name_template_entry ()
584 if (name_edited_by_user) {
588 switch (type_wanted()) {
590 name_template_entry.set_text (_("Audio"));
593 name_template_entry.set_text (_("MIDI"));
596 name_template_entry.set_text (_("Audio+MIDI"));
600 name_template_entry.set_text (_("Bus"));
603 name_template_entry.set_text (VCA::default_name_template());
606 /* ignore programatic change, restore false */
607 reset_name_edited ();
611 AddRouteDialog::track_type_chosen ()
613 switch (type_wanted()) {
616 configuration_label.set_sensitive (true);
617 channel_combo.set_sensitive (true);
619 mode_label.set_sensitive (true);
620 mode_combo.set_sensitive (true);
622 instrument_label.set_sensitive (false);
623 instrument_combo.set_sensitive (false);
625 group_label.set_sensitive (true);
626 route_group_combo.set_sensitive (true);
628 strict_io_label.set_sensitive (true);
629 strict_io_combo.set_sensitive (true);
631 insert_label.set_sensitive (true);
632 insert_at_combo.set_sensitive (true);
637 configuration_label.set_sensitive (false);
638 channel_combo.set_sensitive (false);
640 mode_label.set_sensitive (false);
641 mode_combo.set_sensitive (false);
643 instrument_label.set_sensitive (true);
644 instrument_combo.set_sensitive (true);
646 group_label.set_sensitive (true);
647 route_group_combo.set_sensitive (true);
649 strict_io_label.set_sensitive (true);
650 strict_io_combo.set_sensitive (true);
652 insert_label.set_sensitive (true);
653 insert_at_combo.set_sensitive (true);
658 MessageDialog msg (_("Audio+MIDI tracks are intended for use <b>ONLY</b> with plugins that use both audio and MIDI input data\n\n"
659 "If you do not plan to use such a plugin, then use a normal audio or MIDI track instead."),
660 true, MESSAGE_INFO, BUTTONS_OK, true);
661 msg.set_position (WIN_POS_MOUSE);
665 configuration_label.set_sensitive (true);
666 channel_combo.set_sensitive (true);
668 mode_label.set_sensitive (true);
669 mode_combo.set_sensitive (true);
671 instrument_label.set_sensitive (true);
672 instrument_combo.set_sensitive (true);
674 group_label.set_sensitive (true);
675 route_group_combo.set_sensitive (true);
677 strict_io_label.set_sensitive (true);
678 strict_io_combo.set_sensitive (true);
680 insert_label.set_sensitive (true);
681 insert_at_combo.set_sensitive (true);
686 configuration_label.set_sensitive (true);
687 channel_combo.set_sensitive (true);
689 mode_label.set_sensitive (false);
690 mode_combo.set_sensitive (false);
692 instrument_label.set_sensitive (false);
693 instrument_combo.set_sensitive (false);
695 group_label.set_sensitive (true);
696 route_group_combo.set_sensitive (true);
698 strict_io_label.set_sensitive (true);
699 strict_io_combo.set_sensitive (true);
701 insert_label.set_sensitive (true);
702 insert_at_combo.set_sensitive (true);
707 configuration_label.set_sensitive (false);
708 channel_combo.set_sensitive (false);
710 mode_label.set_sensitive (false);
711 mode_combo.set_sensitive (false);
713 instrument_label.set_sensitive (false);
714 instrument_combo.set_sensitive (false);
716 group_label.set_sensitive (false);
717 route_group_combo.set_sensitive (false);
719 strict_io_label.set_sensitive (false);
720 strict_io_combo.set_sensitive (false);
722 insert_label.set_sensitive (false);
723 insert_at_combo.set_sensitive (false);
728 configuration_label.set_sensitive (false);
729 channel_combo.set_sensitive (false);
731 mode_label.set_sensitive (false);
732 mode_combo.set_sensitive (false);
734 instrument_label.set_sensitive (true);
735 instrument_combo.set_sensitive (true);
737 group_label.set_sensitive (true);
738 route_group_combo.set_sensitive (true);
740 strict_io_label.set_sensitive (true);
741 strict_io_combo.set_sensitive (true);
743 insert_label.set_sensitive (true);
744 insert_at_combo.set_sensitive (true);
749 maybe_update_name_template_entry ();
753 AddRouteDialog::name_template () const
755 return name_template_entry.get_text ();
759 AddRouteDialog::name_template_is_default () const
761 string n = name_template();
763 if (n == _("Audio") ||
765 n == _("Audio+MIDI") ||
767 n == VCA::default_name_template()) {
775 AddRouteDialog::count ()
777 return (int) floor (routes_adjustment.get_value ());
781 AddRouteDialog::refill_track_modes ()
785 s.push_back (_("Normal"));
786 if (!ARDOUR::Profile->get_mixbus ()) {
787 s.push_back (_("Tape"));
790 set_popdown_strings (mode_combo, s);
791 mode_combo.set_active_text (s.front());
795 AddRouteDialog::mode ()
797 std::string str = mode_combo.get_active_text();
798 if (str == _("Normal")) {
799 return ARDOUR::Normal;
800 } else if (str == _("Non Layered")){
801 return ARDOUR::NonLayered;
802 } else if (str == _("Tape")) {
803 return ARDOUR::Destructive;
805 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
807 abort(); /*NOTREACHED*/
810 return ARDOUR::Normal;
814 AddRouteDialog::channel_count ()
816 string str = channel_combo.get_active_text();
817 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
818 if (str == (*i).name) {
819 return (*i).channels;
826 AddRouteDialog::channels ()
829 switch (type_wanted()) {
832 ret.set (DataType::AUDIO, channel_count ());
833 ret.set (DataType::MIDI, 0);
838 ret.set (DataType::AUDIO, 0);
839 ret.set (DataType::MIDI, 1);
843 ret.set (DataType::AUDIO, channel_count ());
844 ret.set (DataType::MIDI, 1);
854 AddRouteDialog::on_show ()
856 routes_spinner.grab_focus ();
857 reset_name_edited ();
859 refill_route_groups ();
865 AddRouteDialog::refill_channel_setups ()
869 string channel_current_choice = channel_combo.get_active_text();
871 channel_combo_strings.clear ();
872 channel_setups.clear ();
874 chn.name = _("Mono");
876 channel_setups.push_back (chn);
878 chn.name = _("Stereo");
880 channel_setups.push_back (chn);
882 if (!ARDOUR::Profile->get_mixbus()) {
884 chn.name = "separator";
885 channel_setups.push_back (chn);
887 chn.name = _("3 Channel");
889 channel_setups.push_back (chn);
891 chn.name = _("4 Channel");
893 channel_setups.push_back (chn);
895 chn.name = _("5 Channel");
897 channel_setups.push_back (chn);
899 chn.name = _("6 Channel");
901 channel_setups.push_back (chn);
903 chn.name = _("8 Channel");
905 channel_setups.push_back (chn);
907 chn.name = _("12 Channel");
909 channel_setups.push_back (chn);
911 chn.name = _("Custom");
913 channel_setups.push_back (chn);
916 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
917 channel_combo_strings.push_back ((*i).name);
920 trk_template_model->clear();
921 bool selected_default = false;
923 for (std::vector<std::pair<std::string,std::string> >::const_iterator i = builtin_types.begin(); i != builtin_types.end(); ++i) {
924 TreeModel::Row row = *(trk_template_model->append ());
925 row[track_template_columns.name] = (*i).first;
926 row[track_template_columns.path] = "";
927 row[track_template_columns.description] = (*i).second;
928 row[track_template_columns.created_with] = "";
930 if (!selected_default && !Profile->get_mixbus ()) {
931 trk_template_chooser.get_selection()->select(row);
932 selected_default = true;
936 /* Add any Lua scripts (factory templates) found in the scripts folder */
937 LuaScriptList& ms (LuaScripting::instance ().scripts (LuaScriptInfo::EditorAction));
938 for (LuaScriptList::const_iterator s = ms.begin(); s != ms.end(); ++s) {
939 if (!((*s)->subtype & LuaScriptInfo::RouteSetup)) {
943 if ( (*s)->name == "Create Audio Tracks Interactively" && Profile->get_mixbus ()) {
944 // somewhat-special, Ben says: "most-used template"
945 row = *(trk_template_model->prepend ());
947 row = *(trk_template_model->append ());
949 row[track_template_columns.name] = (*s)->name;
950 row[track_template_columns.path] = "urn:ardour:" + (*s)->path;
951 row[track_template_columns.description] = (*s)->description;
952 row[track_template_columns.created_with] = _("{Factory Template}");
954 if ((*s)->name == "Create Audio Tracks Interactively" && Profile->get_mixbus ()) {
955 trk_template_chooser.get_selection()->select(row);
956 selected_default = true;
960 std::vector<ARDOUR::TemplateInfo> route_templates;
961 ARDOUR::find_route_templates (route_templates);
963 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
964 TreeModel::Row row = *(trk_template_model->append ());
966 row[track_template_columns.name] = x->name;
967 row[track_template_columns.path] = x->path;
968 row[track_template_columns.description] = x->description;
969 row[track_template_columns.created_with] = x->created_with;
972 set_popdown_strings (channel_combo, channel_combo_strings);
974 if (!channel_current_choice.empty()) {
975 channel_combo.set_active_text (channel_current_choice);
977 channel_combo.set_active_text (channel_combo_strings.front());
982 AddRouteDialog::add_route_group (RouteGroup* g)
984 route_group_combo.insert_text (3, g->name ());
988 AddRouteDialog::route_group ()
990 if (!_session || route_group_combo.get_active_row_number () == 2) {
994 return _session->route_group_by_name (route_group_combo.get_active_text());
998 AddRouteDialog::use_strict_io() {
999 return strict_io_combo.get_active_row_number () == 1;
1003 AddRouteDialog::refill_route_groups ()
1005 route_group_combo.clear ();
1006 route_group_combo.append_text (_("New Group..."));
1008 route_group_combo.append_text ("separator");
1010 route_group_combo.append_text (_("No Group"));
1013 _session->foreach_route_group (sigc::mem_fun (*this, &AddRouteDialog::add_route_group));
1016 route_group_combo.set_active (2);
1020 AddRouteDialog::group_changed ()
1022 if (_session && route_group_combo.get_active_text () == _("New Group...")) {
1023 RouteGroup* g = new RouteGroup (*_session, "");
1024 RouteGroupDialog* d = new RouteGroupDialog (g, true);
1026 d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &AddRouteDialog::new_group_dialog_finished), d));
1032 AddRouteDialog::new_group_dialog_finished (int r, RouteGroupDialog* d)
1034 if (r == RESPONSE_OK) {
1036 if (!d->name_check()) {
1041 _session->add_route_group (d->group());
1044 add_route_group (d->group());
1045 route_group_combo.set_active (3);
1048 route_group_combo.set_active (2);
1051 delete_when_idle (d);
1054 RouteDialogs::InsertAt
1055 AddRouteDialog::insert_at ()
1057 using namespace RouteDialogs;
1059 std::string str = insert_at_combo.get_active_text();
1061 if (str == _("First")) {
1063 } else if (str == _("After Selection")) {
1064 return AfterSelection;
1065 } else if (str == _("Before Selection")){
1066 return BeforeSelection;
1072 AddRouteDialog::channel_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
1074 channel_combo.set_active (i);
1076 return channel_combo.get_active_text () == "separator";
1080 AddRouteDialog::route_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
1082 route_group_combo.set_active (i);
1084 return route_group_combo.get_active_text () == "separator";
1088 AddRouteDialog::requested_instrument ()
1090 return instrument_combo.selected_instrument();