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 sample 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 (_("Modified With"), track_template_columns.modified_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 ("");
429 if ((it = rs.find ("how_many")) != rs.end()) {
430 if (atoi (it->second.c_str()) > 0) {
431 routes_adjustment.set_value (atoi (it->second.c_str()));
435 if ((it = rs.find ("track_mode")) != rs.end()) {
436 switch ((ARDOUR::TrackMode) atoi (it->second.c_str())) {
438 mode_combo.set_active_text (_("Normal"));
440 case ARDOUR::Destructive:
441 if (!ARDOUR::Profile->get_mixbus ()) {
442 mode_combo.set_active_text (_("Tape"));
445 default: // "NonLayered" enum is still present for session-format compat
450 if ((it = rs.find ("strict_io")) != rs.end()) {
451 if (it->second == X_("true")) {
452 strict_io_combo.set_active (1);
453 } else if (it->second == X_("false")) {
454 strict_io_combo.set_active (0);
458 if ((it = rs.find ("channels")) != rs.end()) {
459 uint32_t channels = atoi (it->second.c_str());
460 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
461 if ((*i).channels == channels) {
462 channel_combo.set_active_text ((*i).name);
468 } else if (!p.empty ()) {
470 trk_template_desc.set_sensitive (true);
472 manual_label.set_sensitive (true);
473 add_label.set_sensitive (true);
474 name_label.set_sensitive (true);
475 group_label.set_sensitive (false);
476 strict_io_label.set_sensitive (false);
477 configuration_label.set_sensitive (false);
478 mode_label.set_sensitive (false);
479 instrument_label.set_sensitive (false);
481 routes_spinner.set_sensitive (true);
482 name_template_entry.set_sensitive (true);
483 channel_combo.set_sensitive (false);
484 mode_combo.set_sensitive (false);
485 instrument_combo.set_sensitive (false);
486 strict_io_combo.set_sensitive (false);
487 route_group_combo.set_sensitive (false);
490 /* all manual mode */
491 trk_template_desc.set_sensitive (false);
493 manual_label.set_sensitive (true);
494 add_label.set_sensitive (true);
495 name_label.set_sensitive (true);
496 group_label.set_sensitive (true);
497 strict_io_label.set_sensitive (true);
499 routes_spinner.set_sensitive (true);
500 name_template_entry.set_sensitive (true);
501 track_type_chosen ();
507 AddRouteDialog::name_template_entry_insertion (Glib::ustring const &,int*)
509 if (name_template ().empty ()) {
510 name_edited_by_user = false;
512 name_edited_by_user = true;
517 AddRouteDialog::name_template_entry_deletion (int, int)
519 if (name_template ().empty ()) {
520 name_edited_by_user = false;
522 name_edited_by_user = true;
527 AddRouteDialog::channel_combo_changed ()
529 refill_track_modes ();
533 AddRouteDialog::get_template_path ()
537 if (trk_template_chooser.get_selection()->count_selected_rows() > 0) {
538 TreeIter iter = trk_template_chooser.get_selection()->get_selected();
541 string n = (*iter)[track_template_columns.name];
542 if (n != _("Manual Configuration")) {
543 p = (*iter)[track_template_columns.path];
552 AddRouteDialog::TypeWanted
553 AddRouteDialog::type_wanted()
555 if (trk_template_chooser.get_selection()->count_selected_rows() != 1) {
558 TreeIter iter = trk_template_chooser.get_selection ()->get_selected ();
561 const string str = (*iter)[track_template_columns.name];
562 if (str == _("Audio Busses")) {
564 } else if (str == _("MIDI Busses")){
566 } else if (str == _("MIDI Tracks")){
568 } else if (str == _("Audio+MIDI Tracks")) {
570 } else if (str == _("Audio Tracks")) {
572 } else if (str == _("VCA Masters")) {
581 AddRouteDialog::maybe_update_name_template_entry ()
583 if (name_edited_by_user) {
587 switch (type_wanted()) {
589 name_template_entry.set_text (_("Audio"));
592 name_template_entry.set_text (_("MIDI"));
595 name_template_entry.set_text (_("Audio+MIDI"));
599 name_template_entry.set_text (_("Bus"));
602 name_template_entry.set_text (VCA::default_name_template());
605 /* ignore programatic change, restore false */
606 reset_name_edited ();
610 AddRouteDialog::track_type_chosen ()
612 switch (type_wanted()) {
615 configuration_label.set_sensitive (true);
616 channel_combo.set_sensitive (true);
618 mode_label.set_sensitive (true);
619 mode_combo.set_sensitive (true);
621 instrument_label.set_sensitive (false);
622 instrument_combo.set_sensitive (false);
624 group_label.set_sensitive (true);
625 route_group_combo.set_sensitive (true);
627 strict_io_label.set_sensitive (true);
628 strict_io_combo.set_sensitive (true);
630 insert_label.set_sensitive (true);
631 insert_at_combo.set_sensitive (true);
636 configuration_label.set_sensitive (false);
637 channel_combo.set_sensitive (false);
639 mode_label.set_sensitive (false);
640 mode_combo.set_sensitive (false);
642 instrument_label.set_sensitive (true);
643 instrument_combo.set_sensitive (true);
645 group_label.set_sensitive (true);
646 route_group_combo.set_sensitive (true);
648 strict_io_label.set_sensitive (true);
649 strict_io_combo.set_sensitive (true);
651 insert_label.set_sensitive (true);
652 insert_at_combo.set_sensitive (true);
657 MessageDialog msg (_("Audio+MIDI tracks are intended for use <b>ONLY</b> with plugins that use both audio and MIDI input data\n\n"
658 "If you do not plan to use such a plugin, then use a normal audio or MIDI track instead."),
659 true, MESSAGE_INFO, BUTTONS_OK, true);
660 msg.set_position (WIN_POS_MOUSE);
664 configuration_label.set_sensitive (true);
665 channel_combo.set_sensitive (true);
667 mode_label.set_sensitive (true);
668 mode_combo.set_sensitive (true);
670 instrument_label.set_sensitive (true);
671 instrument_combo.set_sensitive (true);
673 group_label.set_sensitive (true);
674 route_group_combo.set_sensitive (true);
676 strict_io_label.set_sensitive (true);
677 strict_io_combo.set_sensitive (true);
679 insert_label.set_sensitive (true);
680 insert_at_combo.set_sensitive (true);
685 configuration_label.set_sensitive (true);
686 channel_combo.set_sensitive (true);
688 mode_label.set_sensitive (false);
689 mode_combo.set_sensitive (false);
691 instrument_label.set_sensitive (false);
692 instrument_combo.set_sensitive (false);
694 group_label.set_sensitive (true);
695 route_group_combo.set_sensitive (true);
697 strict_io_label.set_sensitive (true);
698 strict_io_combo.set_sensitive (true);
700 insert_label.set_sensitive (true);
701 insert_at_combo.set_sensitive (true);
706 configuration_label.set_sensitive (false);
707 channel_combo.set_sensitive (false);
709 mode_label.set_sensitive (false);
710 mode_combo.set_sensitive (false);
712 instrument_label.set_sensitive (false);
713 instrument_combo.set_sensitive (false);
715 group_label.set_sensitive (false);
716 route_group_combo.set_sensitive (false);
718 strict_io_label.set_sensitive (false);
719 strict_io_combo.set_sensitive (false);
721 insert_label.set_sensitive (false);
722 insert_at_combo.set_sensitive (false);
727 configuration_label.set_sensitive (false);
728 channel_combo.set_sensitive (false);
730 mode_label.set_sensitive (false);
731 mode_combo.set_sensitive (false);
733 instrument_label.set_sensitive (true);
734 instrument_combo.set_sensitive (true);
736 group_label.set_sensitive (true);
737 route_group_combo.set_sensitive (true);
739 strict_io_label.set_sensitive (true);
740 strict_io_combo.set_sensitive (true);
742 insert_label.set_sensitive (true);
743 insert_at_combo.set_sensitive (true);
748 maybe_update_name_template_entry ();
752 AddRouteDialog::name_template () const
754 return name_template_entry.get_text ();
758 AddRouteDialog::name_template_is_default () const
760 string n = name_template();
762 if (n == _("Audio") ||
764 n == _("Audio+MIDI") ||
766 n == VCA::default_name_template()) {
774 AddRouteDialog::count ()
776 return (int) floor (routes_adjustment.get_value ());
780 AddRouteDialog::refill_track_modes ()
784 s.push_back (_("Normal"));
785 if (!ARDOUR::Profile->get_mixbus ()) {
786 s.push_back (_("Tape"));
789 set_popdown_strings (mode_combo, s);
790 mode_combo.set_active_text (s.front());
794 AddRouteDialog::mode ()
796 std::string str = mode_combo.get_active_text();
797 if (str == _("Normal")) {
798 return ARDOUR::Normal;
799 } else if (str == _("Non Layered")){
800 return ARDOUR::NonLayered;
801 } else if (str == _("Tape")) {
802 return ARDOUR::Destructive;
804 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
806 abort(); /*NOTREACHED*/
809 return ARDOUR::Normal;
813 AddRouteDialog::channel_count ()
815 string str = channel_combo.get_active_text();
816 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
817 if (str == (*i).name) {
818 return (*i).channels;
825 AddRouteDialog::channels ()
828 switch (type_wanted()) {
831 ret.set (DataType::AUDIO, channel_count ());
832 ret.set (DataType::MIDI, 0);
837 ret.set (DataType::AUDIO, 0);
838 ret.set (DataType::MIDI, 1);
842 ret.set (DataType::AUDIO, channel_count ());
843 ret.set (DataType::MIDI, 1);
853 AddRouteDialog::on_show ()
855 routes_spinner.grab_focus ();
856 reset_name_edited ();
858 refill_route_groups ();
859 refill_channel_setups ();
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.modified_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.modified_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 if (!selected_default && !trk_template_model->children().empty()) {
961 TreeModel::Children rows = trk_template_model->children();
962 trk_template_chooser.get_selection()->select(rows[0]);
965 std::vector<ARDOUR::TemplateInfo> route_templates;
966 ARDOUR::find_route_templates (route_templates);
968 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
969 TreeModel::Row row = *(trk_template_model->append ());
971 row[track_template_columns.name] = x->name;
972 row[track_template_columns.path] = x->path;
973 row[track_template_columns.description] = x->description;
974 row[track_template_columns.modified_with] = x->modified_with;
977 set_popdown_strings (channel_combo, channel_combo_strings);
979 if (!channel_current_choice.empty()) {
980 channel_combo.set_active_text (channel_current_choice);
982 channel_combo.set_active_text (channel_combo_strings.front());
987 AddRouteDialog::add_route_group (RouteGroup* g)
989 route_group_combo.insert_text (3, g->name ());
993 AddRouteDialog::route_group ()
995 if (!_session || route_group_combo.get_active_row_number () == 2) {
999 return _session->route_group_by_name (route_group_combo.get_active_text());
1003 AddRouteDialog::use_strict_io() {
1004 return strict_io_combo.get_active_row_number () == 1;
1008 AddRouteDialog::refill_route_groups ()
1010 route_group_combo.clear ();
1011 route_group_combo.append_text (_("New Group..."));
1013 route_group_combo.append_text ("separator");
1015 route_group_combo.append_text (_("No Group"));
1018 _session->foreach_route_group (sigc::mem_fun (*this, &AddRouteDialog::add_route_group));
1021 route_group_combo.set_active (2);
1025 AddRouteDialog::group_changed ()
1027 if (_session && route_group_combo.get_active_text () == _("New Group...")) {
1028 RouteGroup* g = new RouteGroup (*_session, "");
1029 RouteGroupDialog* d = new RouteGroupDialog (g, true);
1031 d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &AddRouteDialog::new_group_dialog_finished), d));
1037 AddRouteDialog::new_group_dialog_finished (int r, RouteGroupDialog* d)
1039 if (r == RESPONSE_OK) {
1041 if (!d->name_check()) {
1046 _session->add_route_group (d->group());
1049 add_route_group (d->group());
1050 route_group_combo.set_active (3);
1053 route_group_combo.set_active (2);
1056 delete_when_idle (d);
1059 RouteDialogs::InsertAt
1060 AddRouteDialog::insert_at ()
1062 using namespace RouteDialogs;
1064 std::string str = insert_at_combo.get_active_text();
1066 if (str == _("First")) {
1068 } else if (str == _("After Selection")) {
1069 return AfterSelection;
1070 } else if (str == _("Before Selection")){
1071 return BeforeSelection;
1077 AddRouteDialog::channel_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
1079 channel_combo.set_active (i);
1081 return channel_combo.get_active_text () == "separator";
1085 AddRouteDialog::route_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
1087 route_group_combo.set_active (i);
1089 return route_group_combo.get_active_text () == "separator";
1093 AddRouteDialog::requested_instrument ()
1095 return instrument_combo.selected_instrument();