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 Audio Tracks.\n \
155 * The number of buses to add.\n \
156 * A Name for the track(s).\n \
157 * An Instrument plugin (or select \"None\" to drive an external device)\n \
158 * A Group which will be assigned to the track(s).\n \
159 * Pin Connections mode. (see tooltip for details).\n \
161 The track will be added in the location specified by \"Position\".\n \
164 builtin_types.push_back (
165 std::pair<string,string>(_("VCA Masters"), _(" \
166 Use the settings, below, to create 1 or more VCA Master(s).\n \
169 * The number of buses to add.\n \
170 * A name for the new VCAs. \"%n\" will be replaced by an index number for each VCA.\n \
175 insert_at_combo.append_text (_("First"));
176 insert_at_combo.append_text (_("Before Selection"));
177 insert_at_combo.append_text (_("After Selection"));
178 insert_at_combo.append_text (_("Last"));
179 insert_at_combo.set_active (3);
181 strict_io_combo.append_text (_("Flexible-I/O"));
182 strict_io_combo.append_text (_("Strict-I/O"));
183 strict_io_combo.set_active (Config->get_strict_io () ? 1 : 0);
186 VBox* vbox = manage (new VBox);
187 get_vbox()->set_spacing (4);
188 vbox->set_spacing (18);
189 vbox->set_border_width (5);
191 //this box contains the template chooser, and the template details
192 HBox* template_hbox = manage (new HBox);
193 template_hbox->set_spacing (8);
195 //scrollbars for the template chooser and template descriptions....
196 Gtk::ScrolledWindow *template_scroller = manage (new Gtk::ScrolledWindow());
197 template_scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
198 template_scroller->add (trk_template_chooser);
200 Gtk::ScrolledWindow *desc_scroller = manage (new Gtk::ScrolledWindow());
201 desc_scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
202 desc_scroller->add (trk_template_desc);
204 //this is the outer frame that surrounds the description and the settings-table
205 trk_template_outer_frame.set_name (X_("TextHighlightFrame"));
207 //this is the "inner frame" that surrounds the description text
208 trk_template_desc_frame.set_name (X_("TextHighlightFrame"));
209 trk_template_desc_frame.add (*desc_scroller);
211 /* template_chooser is the treeview showing available templates */
212 trk_template_model = TreeStore::create (track_template_columns);
213 trk_template_chooser.set_model (trk_template_model);
214 trk_template_chooser.append_column (_("Template/Type"), track_template_columns.name);
216 trk_template_chooser.append_column (_("Created With"), track_template_columns.created_with);
218 trk_template_chooser.set_headers_visible (true);
219 trk_template_chooser.get_selection()->set_mode (SELECTION_SINGLE);
220 trk_template_chooser.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::trk_template_row_selected));
221 trk_template_chooser.set_sensitive (true);
223 /* template_desc is the textview that displays the currently selected template's description */
224 trk_template_desc.set_editable (false);
225 trk_template_desc.set_can_focus (false);
226 trk_template_desc.set_wrap_mode (Gtk::WRAP_WORD);
227 trk_template_desc.set_size_request(400,200);
228 trk_template_desc.set_name (X_("TextOnBackground"));
229 trk_template_desc.set_border_width (6);
231 Table *settings_table = manage (new Table (2, 6, false));
232 settings_table->set_row_spacings (8);
233 settings_table->set_col_spacings (4);
234 settings_table->set_col_spacing (3, 20);
235 settings_table->set_border_width (12);
237 VBox* settings_vbox = manage (new VBox);
238 settings_vbox->pack_start(trk_template_desc_frame , true, true);
239 settings_vbox->pack_start(*settings_table , true, true);
240 settings_vbox->set_border_width (4);
242 trk_template_outer_frame.add (*settings_vbox);
244 template_hbox->pack_start (*template_scroller, true, true);
245 template_hbox->pack_start (trk_template_outer_frame, true, true);
247 vbox->pack_start (*template_hbox, true, true);
250 //Now pack the "settings table" with manual controls (these controls are sensitized by the left-side selection)
254 HBox *separator_hbox = manage (new HBox);
255 separator_hbox->pack_start (manual_label, false, false);
256 separator_hbox->pack_start (*(manage (new Gtk::HSeparator)), true, true);
257 separator_hbox->set_spacing (6);
258 settings_table->attach (*separator_hbox, 0, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
263 add_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
264 settings_table->attach (add_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
265 Gtk::Alignment *align = manage (new Alignment (0, .5, 0, 0));
266 align->add (routes_spinner);
267 settings_table->attach (*align, 1, 2, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
272 name_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
273 settings_table->attach (name_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
274 settings_table->attach (name_template_entry, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
276 // Route configuration
277 configuration_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
278 settings_table->attach (configuration_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
279 settings_table->attach (channel_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
283 // instrument choice (for MIDI)
284 instrument_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
285 settings_table->attach (instrument_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
286 settings_table->attach (instrument_combo, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
289 group_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
290 settings_table->attach (group_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
291 settings_table->attach (route_group_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
295 // New Route's I/O is.. {strict/flexible}
296 if (Profile->get_mixbus ()) {
297 strict_io_combo.set_active (1);
299 strict_io_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
300 settings_table->attach (strict_io_label, 0, 1, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
301 settings_table->attach (strict_io_combo, 1, 3, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
303 ArdourWidgets::set_tooltip (strict_io_combo,
304 _("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."));
307 mode_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
308 settings_table->attach (mode_label, 4, 5, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
309 settings_table->attach (mode_combo, 5, 6, n, n + 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
314 HBox* outer_box = manage (new HBox);
315 outer_box->set_spacing (4);
317 // New route will be inserted at..
318 insert_label.set_alignment (Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
319 outer_box->pack_start (insert_label, false, false);
320 outer_box->pack_start (insert_at_combo, false, false);
322 //quick-add button (add item but don't close dialog)
323 Gtk::Button* addnoclose_button = manage (new Gtk::Button(_("Add selected items (and leave dialog open)")));
324 addnoclose_button->set_can_default ();
325 addnoclose_button->signal_clicked ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), Add));
326 outer_box->pack_end (*addnoclose_button, false, false);
328 vbox->pack_start (*outer_box, true, true);
330 get_vbox()->pack_start (*vbox, false, false);
332 name_template_entry.signal_insert_text ().connect (sigc::mem_fun (*this, &AddRouteDialog::name_template_entry_insertion));
333 name_template_entry.signal_delete_text ().connect (sigc::mem_fun (*this, &AddRouteDialog::name_template_entry_deletion));
334 channel_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::channel_combo_changed));
335 channel_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::channel_separator));
336 route_group_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::route_separator));
337 route_group_combo.signal_changed ().connect (sigc::mem_fun (*this, &AddRouteDialog::group_changed));
339 routes_spinner.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose));
340 name_template_entry.signal_activate ().connect (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose));
341 trk_template_chooser.signal_row_activated ().connect (sigc::hide (sigc::hide (sigc::bind (sigc::mem_fun (*this, &Gtk::Dialog::response), AddAndClose))));
343 show_all_children ();
345 /* track template info will be managed whenever
346 * this dialog is shown, via ::on_show()
349 add_button (_("Add and Close"), AddAndClose);
350 set_response_sensitive (AddAndClose, true);
351 set_default_response (AddAndClose);
353 refill_channel_setups ();
356 AddRouteDialog::~AddRouteDialog ()
361 AddRouteDialog::on_response (int r)
363 reset_name_edited ();
364 /* Don't call ArdourDialog::on_response() because that will
365 automatically hide the dialog.
367 Gtk::Dialog::on_response (r);
371 AddRouteDialog::trk_template_row_selected ()
373 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
377 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
380 string d = (*iter)[track_template_columns.description];
381 trk_template_desc.get_buffer ()->set_text (d);
383 const string n = (*iter)[track_template_columns.name];
384 const string p = (*iter)[track_template_columns.path];
386 if (p.substr (0, 11) == "urn:ardour:") {
387 /* lua script - meta-template */
388 const std::map<std::string, std::string> rs (ARDOUR_UI::instance()->route_setup_info (p.substr (11)));
390 trk_template_desc.set_sensitive (true);
392 add_label.set_sensitive (rs.find ("how_many") != rs.end ());
393 name_label.set_sensitive (rs.find ("name") != rs.end());
394 group_label.set_sensitive (rs.find ("group") != rs.end());
395 configuration_label.set_sensitive (rs.find ("channels") != rs.end ());
396 mode_label.set_sensitive (rs.find ("track_mode") != rs.end ());
397 instrument_label.set_sensitive (rs.find ("instrument") != rs.end ());
398 strict_io_label.set_sensitive (rs.find ("strict_io") != rs.end());
400 routes_spinner.set_sensitive (rs.find ("how_many") != rs.end ());
401 name_template_entry.set_sensitive (rs.find ("name") != rs.end ());
402 route_group_combo.set_sensitive (rs.find ("group") != rs.end());
403 channel_combo.set_sensitive (rs.find ("channels") != rs.end ());
404 mode_combo.set_sensitive (rs.find ("track_mode") != rs.end ());
405 instrument_combo.set_sensitive (rs.find ("instrument") != rs.end ());
406 strict_io_combo.set_sensitive (rs.find ("strict_io") != rs.end());
408 bool any_enabled = rs.find ("how_many") != rs.end ()
409 || rs.find ("name") != rs.end ()
410 || rs.find ("group") != rs.end()
411 || rs.find ("channels") != rs.end ()
412 || rs.find ("track_mode") != rs.end ()
413 || rs.find ("instrument") != rs.end ()
414 || rs.find ("strict_io") != rs.end();
416 manual_label.set_sensitive (any_enabled);
418 std::map<string,string>::const_iterator it;
420 if ((it = rs.find ("name")) != rs.end()) {
421 name_template_entry.set_text (it->second);
423 name_template_entry.set_text ("");
427 if ((it = rs.find ("how_many")) != rs.end()) {
428 if (atoi (it->second.c_str()) > 0) {
429 routes_adjustment.set_value (atoi (it->second.c_str()));
433 if ((it = rs.find ("track_mode")) != rs.end()) {
434 switch ((ARDOUR::TrackMode) atoi (it->second.c_str())) {
436 mode_combo.set_active_text (_("Normal"));
438 case ARDOUR::Destructive:
439 if (!ARDOUR::Profile->get_mixbus ()) {
440 mode_combo.set_active_text (_("Tape"));
443 default: // "NonLayered" enum is still present for session-format compat
448 if ((it = rs.find ("strict_io")) != rs.end()) {
449 if (it->second == X_("true")) {
450 strict_io_combo.set_active (1);
451 } else if (it->second == X_("false")) {
452 strict_io_combo.set_active (0);
456 if ((it = rs.find ("channels")) != rs.end()) {
457 uint32_t channels = atoi (it->second.c_str());
458 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
459 if ((*i).channels == channels) {
460 channel_combo.set_active_text ((*i).name);
466 } else if (!p.empty ()) {
468 trk_template_desc.set_sensitive (true);
470 manual_label.set_sensitive (true);
471 add_label.set_sensitive (true);
472 name_label.set_sensitive (true);
473 group_label.set_sensitive (false);
474 strict_io_label.set_sensitive (false);
475 configuration_label.set_sensitive (false);
476 mode_label.set_sensitive (false);
477 instrument_label.set_sensitive (false);
479 routes_spinner.set_sensitive (true);
480 name_template_entry.set_sensitive (true);
481 channel_combo.set_sensitive (false);
482 mode_combo.set_sensitive (false);
483 instrument_combo.set_sensitive (false);
484 strict_io_combo.set_sensitive (false);
485 route_group_combo.set_sensitive (false);
488 /* all manual mode */
489 trk_template_desc.set_sensitive (false);
491 manual_label.set_sensitive (true);
492 add_label.set_sensitive (true);
493 name_label.set_sensitive (true);
494 group_label.set_sensitive (true);
495 strict_io_label.set_sensitive (true);
497 routes_spinner.set_sensitive (true);
498 name_template_entry.set_sensitive (true);
499 track_type_chosen ();
505 AddRouteDialog::name_template_entry_insertion (Glib::ustring const &,int*)
507 if (name_template ().empty ()) {
508 name_edited_by_user = false;
510 name_edited_by_user = true;
515 AddRouteDialog::name_template_entry_deletion (int, int)
517 if (name_template ().empty ()) {
518 name_edited_by_user = false;
520 name_edited_by_user = true;
525 AddRouteDialog::channel_combo_changed ()
527 refill_track_modes ();
531 AddRouteDialog::get_template_path ()
535 if (trk_template_chooser.get_selection()->count_selected_rows() > 0) {
536 TreeIter iter = trk_template_chooser.get_selection()->get_selected();
539 string n = (*iter)[track_template_columns.name];
540 if ( n != _("Manual Configuration") ) {
541 p = (*iter)[track_template_columns.path];
550 AddRouteDialog::TypeWanted
551 AddRouteDialog::type_wanted()
553 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
556 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
559 const string str = (*iter)[track_template_columns.name];
560 if (str == _("Audio Busses")) {
562 } else if (str == _("MIDI Busses")){
564 } else if (str == _("MIDI Tracks")){
566 } else if (str == _("Audio+MIDI Tracks")) {
568 } else if (str == _("Audio Tracks")) {
570 } else if (str == _("VCA Masters")) {
579 AddRouteDialog::maybe_update_name_template_entry ()
581 if (name_edited_by_user) {
585 switch (type_wanted()) {
587 name_template_entry.set_text (_("Audio"));
590 name_template_entry.set_text (_("MIDI"));
593 name_template_entry.set_text (_("Audio+MIDI"));
597 name_template_entry.set_text (_("Bus"));
600 name_template_entry.set_text (VCA::default_name_template());
603 /* ignore programatic change, restore false */
604 reset_name_edited ();
608 AddRouteDialog::track_type_chosen ()
610 switch (type_wanted()) {
613 configuration_label.set_sensitive (true);
614 channel_combo.set_sensitive (true);
616 mode_label.set_sensitive (true);
617 mode_combo.set_sensitive (true);
619 instrument_label.set_sensitive (false);
620 instrument_combo.set_sensitive (false);
622 group_label.set_sensitive (true);
623 route_group_combo.set_sensitive (true);
625 strict_io_label.set_sensitive (true);
626 strict_io_combo.set_sensitive (true);
628 insert_label.set_sensitive (true);
629 insert_at_combo.set_sensitive (true);
634 configuration_label.set_sensitive (false);
635 channel_combo.set_sensitive (false);
637 mode_label.set_sensitive (false);
638 mode_combo.set_sensitive (false);
640 instrument_label.set_sensitive (true);
641 instrument_combo.set_sensitive (true);
643 group_label.set_sensitive (true);
644 route_group_combo.set_sensitive (true);
646 strict_io_label.set_sensitive (true);
647 strict_io_combo.set_sensitive (true);
649 insert_label.set_sensitive (true);
650 insert_at_combo.set_sensitive (true);
655 MessageDialog msg (_("Audio+MIDI tracks are intended for use <b>ONLY</b> with plugins that use both audio and MIDI input data\n\n"
656 "If you do not plan to use such a plugin, then use a normal audio or MIDI track instead."),
657 true, MESSAGE_INFO, BUTTONS_OK, true);
658 msg.set_position (WIN_POS_MOUSE);
662 configuration_label.set_sensitive (true);
663 channel_combo.set_sensitive (true);
665 mode_label.set_sensitive (true);
666 mode_combo.set_sensitive (true);
668 instrument_label.set_sensitive (true);
669 instrument_combo.set_sensitive (true);
671 group_label.set_sensitive (true);
672 route_group_combo.set_sensitive (true);
674 strict_io_label.set_sensitive (true);
675 strict_io_combo.set_sensitive (true);
677 insert_label.set_sensitive (true);
678 insert_at_combo.set_sensitive (true);
683 configuration_label.set_sensitive (true);
684 channel_combo.set_sensitive (true);
686 mode_label.set_sensitive (false);
687 mode_combo.set_sensitive (false);
689 instrument_label.set_sensitive (false);
690 instrument_combo.set_sensitive (false);
692 group_label.set_sensitive (true);
693 route_group_combo.set_sensitive (true);
695 strict_io_label.set_sensitive (true);
696 strict_io_combo.set_sensitive (true);
698 insert_label.set_sensitive (true);
699 insert_at_combo.set_sensitive (true);
704 configuration_label.set_sensitive (false);
705 channel_combo.set_sensitive (false);
707 mode_label.set_sensitive (false);
708 mode_combo.set_sensitive (false);
710 instrument_label.set_sensitive (false);
711 instrument_combo.set_sensitive (false);
713 group_label.set_sensitive (false);
714 route_group_combo.set_sensitive (false);
716 strict_io_label.set_sensitive (false);
717 strict_io_combo.set_sensitive (false);
719 insert_label.set_sensitive (false);
720 insert_at_combo.set_sensitive (false);
725 configuration_label.set_sensitive (false);
726 channel_combo.set_sensitive (false);
728 mode_label.set_sensitive (false);
729 mode_combo.set_sensitive (false);
731 instrument_label.set_sensitive (true);
732 instrument_combo.set_sensitive (true);
734 group_label.set_sensitive (true);
735 route_group_combo.set_sensitive (true);
737 strict_io_label.set_sensitive (true);
738 strict_io_combo.set_sensitive (true);
740 insert_label.set_sensitive (true);
741 insert_at_combo.set_sensitive (true);
746 maybe_update_name_template_entry ();
750 AddRouteDialog::name_template () const
752 return name_template_entry.get_text ();
756 AddRouteDialog::name_template_is_default () const
758 string n = name_template();
760 if (n == _("Audio") ||
762 n == _("Audio+MIDI") ||
764 n == VCA::default_name_template()) {
772 AddRouteDialog::count ()
774 return (int) floor (routes_adjustment.get_value ());
778 AddRouteDialog::refill_track_modes ()
782 s.push_back (_("Normal"));
783 if (!ARDOUR::Profile->get_mixbus ()) {
784 s.push_back (_("Tape"));
787 set_popdown_strings (mode_combo, s);
788 mode_combo.set_active_text (s.front());
792 AddRouteDialog::mode ()
794 std::string str = mode_combo.get_active_text();
795 if (str == _("Normal")) {
796 return ARDOUR::Normal;
797 } else if (str == _("Non Layered")){
798 return ARDOUR::NonLayered;
799 } else if (str == _("Tape")) {
800 return ARDOUR::Destructive;
802 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
804 abort(); /*NOTREACHED*/
807 return ARDOUR::Normal;
811 AddRouteDialog::channel_count ()
813 string str = channel_combo.get_active_text();
814 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
815 if (str == (*i).name) {
816 return (*i).channels;
823 AddRouteDialog::channels ()
826 switch (type_wanted()) {
829 ret.set (DataType::AUDIO, channel_count ());
830 ret.set (DataType::MIDI, 0);
835 ret.set (DataType::AUDIO, 0);
836 ret.set (DataType::MIDI, 1);
840 ret.set (DataType::AUDIO, channel_count ());
841 ret.set (DataType::MIDI, 1);
851 AddRouteDialog::on_show ()
853 routes_spinner.grab_focus ();
854 reset_name_edited ();
856 refill_route_groups ();
862 AddRouteDialog::refill_channel_setups ()
866 string channel_current_choice = channel_combo.get_active_text();
868 channel_combo_strings.clear ();
869 channel_setups.clear ();
871 chn.name = _("Mono");
873 channel_setups.push_back (chn);
875 chn.name = _("Stereo");
877 channel_setups.push_back (chn);
879 if (!ARDOUR::Profile->get_mixbus()) {
881 chn.name = "separator";
882 channel_setups.push_back (chn);
884 chn.name = _("3 Channel");
886 channel_setups.push_back (chn);
888 chn.name = _("4 Channel");
890 channel_setups.push_back (chn);
892 chn.name = _("5 Channel");
894 channel_setups.push_back (chn);
896 chn.name = _("6 Channel");
898 channel_setups.push_back (chn);
900 chn.name = _("8 Channel");
902 channel_setups.push_back (chn);
904 chn.name = _("12 Channel");
906 channel_setups.push_back (chn);
908 chn.name = _("Custom");
910 channel_setups.push_back (chn);
913 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
914 channel_combo_strings.push_back ((*i).name);
917 trk_template_model->clear();
918 bool selected_default = false;
920 for (std::vector<std::pair<std::string,std::string> >::const_iterator i = builtin_types.begin(); i != builtin_types.end(); ++i) {
921 TreeModel::Row row = *(trk_template_model->append ());
922 row[track_template_columns.name] = (*i).first;
923 row[track_template_columns.path] = "";
924 row[track_template_columns.description] = (*i).second;
925 row[track_template_columns.created_with] = "";
927 if (!selected_default && !Profile->get_mixbus ()) {
928 trk_template_chooser.get_selection()->select(row);
929 selected_default = true;
933 /* Add any Lua scripts (factory templates) found in the scripts folder */
934 LuaScriptList& ms (LuaScripting::instance ().scripts (LuaScriptInfo::EditorAction));
935 for (LuaScriptList::const_iterator s = ms.begin(); s != ms.end(); ++s) {
936 if (!((*s)->subtype & LuaScriptInfo::RouteSetup)) {
940 if ( (*s)->name == "Create Audio Tracks Interactively" && Profile->get_mixbus ()) {
941 // somewhat-special, Ben says: "most-used template"
942 row = *(trk_template_model->prepend ());
944 row = *(trk_template_model->append ());
946 row[track_template_columns.name] = (*s)->name;
947 row[track_template_columns.path] = "urn:ardour:" + (*s)->path;
948 row[track_template_columns.description] = (*s)->description;
949 row[track_template_columns.created_with] = _("{Factory Template}");
951 if ((*s)->name == "Create Audio Tracks Interactively" && Profile->get_mixbus ()) {
952 trk_template_chooser.get_selection()->select(row);
953 selected_default = true;
957 std::vector<ARDOUR::TemplateInfo> route_templates;
958 ARDOUR::find_route_templates (route_templates);
960 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
961 TreeModel::Row row = *(trk_template_model->append ());
963 row[track_template_columns.name] = x->name;
964 row[track_template_columns.path] = x->path;
965 row[track_template_columns.description] = x->description;
966 row[track_template_columns.created_with] = x->created_with;
969 set_popdown_strings (channel_combo, channel_combo_strings);
971 if (!channel_current_choice.empty()) {
972 channel_combo.set_active_text (channel_current_choice);
974 channel_combo.set_active_text (channel_combo_strings.front());
979 AddRouteDialog::add_route_group (RouteGroup* g)
981 route_group_combo.insert_text (3, g->name ());
985 AddRouteDialog::route_group ()
987 if (!_session || route_group_combo.get_active_row_number () == 2) {
991 return _session->route_group_by_name (route_group_combo.get_active_text());
995 AddRouteDialog::use_strict_io() {
996 return strict_io_combo.get_active_row_number () == 1;
1000 AddRouteDialog::refill_route_groups ()
1002 route_group_combo.clear ();
1003 route_group_combo.append_text (_("New Group..."));
1005 route_group_combo.append_text ("separator");
1007 route_group_combo.append_text (_("No Group"));
1010 _session->foreach_route_group (sigc::mem_fun (*this, &AddRouteDialog::add_route_group));
1013 route_group_combo.set_active (2);
1017 AddRouteDialog::group_changed ()
1019 if (_session && route_group_combo.get_active_text () == _("New Group...")) {
1020 RouteGroup* g = new RouteGroup (*_session, "");
1021 RouteGroupDialog* d = new RouteGroupDialog (g, true);
1023 d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &AddRouteDialog::new_group_dialog_finished), d));
1029 AddRouteDialog::new_group_dialog_finished (int r, RouteGroupDialog* d)
1031 if (r == RESPONSE_OK) {
1033 if (!d->name_check()) {
1038 _session->add_route_group (d->group());
1041 add_route_group (d->group());
1042 route_group_combo.set_active (3);
1045 route_group_combo.set_active (2);
1048 delete_when_idle (d);
1051 RouteDialogs::InsertAt
1052 AddRouteDialog::insert_at ()
1054 using namespace RouteDialogs;
1056 std::string str = insert_at_combo.get_active_text();
1058 if (str == _("First")) {
1060 } else if (str == _("After Selection")) {
1061 return AfterSelection;
1062 } else if (str == _("Before Selection")){
1063 return BeforeSelection;
1069 AddRouteDialog::channel_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
1071 channel_combo.set_active (i);
1073 return channel_combo.get_active_text () == "separator";
1077 AddRouteDialog::route_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
1079 route_group_combo.set_active (i);
1081 return route_group_combo.get_active_text () == "separator";
1085 AddRouteDialog::requested_instrument ()
1087 return instrument_combo.selected_instrument();