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"
31 #include "gtkmm2ext/utils.h"
33 #include "ardour/plugin_manager.h"
34 #include "ardour/profile.h"
35 #include "ardour/template_utils.h"
36 #include "ardour/route_group.h"
37 #include "ardour/session.h"
38 #include "ardour/vca.h"
41 #include "add_route_dialog.h"
42 #include "route_group_dialog.h"
47 using namespace Gtkmm2ext;
50 using namespace ARDOUR;
51 using namespace ARDOUR_UI_UTILS;
53 std::vector<std::string> AddRouteDialog::channel_combo_strings;
55 AddRouteDialog::AddRouteDialog ()
56 : ArdourDialog (_("Add Track/Bus/VCA"))
57 , routes_adjustment (1, 1, 128, 1, 4)
58 , routes_spinner (routes_adjustment)
59 , configuration_label (_("Configuration:"))
60 , mode_label (_("Record Mode:"))
61 , instrument_label (_("Instrument:"))
63 set_name ("AddRouteDialog");
65 set_skip_taskbar_hint (true);
66 set_resizable (false);
68 name_template_entry.set_name (X_("AddRouteDialogNameTemplateEntry"));
69 // routes_spinner.set_name (X_("AddRouteDialogSpinner"));
70 channel_combo.set_name (X_("ChannelCountSelector"));
71 mode_combo.set_name (X_("ChannelCountSelector"));
73 refill_channel_setups ();
74 refill_route_groups ();
75 refill_track_modes ();
77 channel_combo.set_active_text (channel_combo_strings.front());
79 track_bus_combo.append_text (_("Audio Tracks"));
80 track_bus_combo.append_text (_("MIDI Tracks"));
81 track_bus_combo.append_text (_("Audio+MIDI Tracks"));
82 track_bus_combo.append_text (_("Audio Busses"));
83 track_bus_combo.append_text (_("MIDI Busses"));
84 track_bus_combo.append_text (_("VCA Masters"));
85 track_bus_combo.set_active (0);
87 insert_at_combo.append_text (_("First"));
88 insert_at_combo.append_text (_("Before Selection"));
89 insert_at_combo.append_text (_("After Selection"));
90 insert_at_combo.append_text (_("Last"));
91 insert_at_combo.set_active (3);
93 strict_io_combo.append_text (_("Flexible-I/O"));
94 strict_io_combo.append_text (_("Strict-I/O"));
95 strict_io_combo.set_active (Config->get_strict_io () ? 1 : 0);
97 VBox* vbox = manage (new VBox);
100 get_vbox()->set_spacing (4);
102 vbox->set_spacing (18);
103 vbox->set_border_width (5);
105 HBox *type_hbox = manage (new HBox);
106 type_hbox->set_spacing (6);
108 /* track/bus choice */
110 type_hbox->pack_start (*manage (new Label (_("Add:"))));
111 type_hbox->pack_start (routes_spinner);
112 type_hbox->pack_start (track_bus_combo);
114 vbox->pack_start (*type_hbox, false, true);
116 VBox* options_box = manage (new VBox);
117 Table *table2 = manage (new Table (3, 3, false));
119 options_box->set_spacing (6);
120 table2->set_row_spacings (6);
121 table2->set_col_spacing (1, 6);
123 l = manage (new Label (_("<b>Options</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
124 l->set_use_markup ();
125 options_box->pack_start (*l, false, true);
127 l = manage (new Label ("", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
128 l->set_padding (8, 0);
129 table2->attach (*l, 0, 1, 0, 3, Gtk::FILL, Gtk::FILL, 0, 0);
133 l = manage (new Label (_("Name:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
134 table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
135 table2->attach (name_template_entry, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
138 /* Route configuration */
140 configuration_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
141 table2->attach (configuration_label, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
142 table2->attach (channel_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
145 mode_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
146 table2->attach (mode_label, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
147 table2->attach (mode_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
150 instrument_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
151 table2->attach (instrument_label, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
152 table2->attach (instrument_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
157 l = manage (new Label (_("Group:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
158 table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
159 table2->attach (route_group_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
162 /* New route will be inserted at.. */
163 l = manage (new Label (_("Insert:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
164 table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
165 table2->attach (insert_at_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
168 /* New Route's Routing is.. */
170 if (Profile->get_mixbus ()) {
171 strict_io_combo.set_active (1);
173 l = manage (new Label (_("Output Ports:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
174 table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
175 table2->attach (strict_io_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
177 ARDOUR_UI_UTILS::set_tooltip (strict_io_combo,
178 _("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."));
182 options_box->pack_start (*table2, false, true);
183 vbox->pack_start (*options_box, false, true);
185 get_vbox()->pack_start (*vbox, false, false);
187 track_bus_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::track_type_chosen));
188 channel_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::channel_combo_changed));
189 channel_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::channel_separator));
190 route_group_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::route_separator));
191 route_group_combo.signal_changed ().connect (sigc::mem_fun (*this, &AddRouteDialog::group_changed));
193 show_all_children ();
195 /* track template info will be managed whenever
196 this dialog is shown, via ::on_show()
199 add_button (Stock::CANCEL, RESPONSE_CANCEL);
200 add_button (Stock::ADD, RESPONSE_ACCEPT);
201 set_response_sensitive (RESPONSE_ACCEPT, true);
202 set_default_response (RESPONSE_ACCEPT);
204 track_type_chosen ();
207 AddRouteDialog::~AddRouteDialog ()
212 AddRouteDialog::channel_combo_changed ()
214 maybe_update_name_template_entry ();
215 refill_track_modes ();
218 AddRouteDialog::TypeWanted
219 AddRouteDialog::type_wanted() const
221 std::string str = track_bus_combo.get_active_text();
222 if (str == _("Audio Busses")) {
224 } else if (str == _("MIDI Busses")){
226 } else if (str == _("MIDI Tracks")){
228 } else if (str == _("Audio+MIDI Tracks")) {
230 } else if (str == _("Audio Tracks")) {
238 AddRouteDialog::maybe_update_name_template_entry ()
241 name_template_entry.get_text() != "" &&
242 name_template_entry.get_text() != _("VCA") &&
243 name_template_entry.get_text() != _("Audio") &&
244 name_template_entry.get_text() != _("MIDI") &&
245 name_template_entry.get_text() != _("Audio+MIDI") &&
246 name_template_entry.get_text() != _("Bus")) {
247 strict_io_combo.set_sensitive (false);
251 strict_io_combo.set_sensitive (true);
253 switch (type_wanted()) {
255 name_template_entry.set_text (_("Audio"));
258 name_template_entry.set_text (_("MIDI"));
261 name_template_entry.set_text (_("Audio+MIDI"));
265 name_template_entry.set_text (_("Bus"));
268 name_template_entry.set_text (VCA::default_name_template());
274 AddRouteDialog::track_type_chosen ()
276 switch (type_wanted()) {
278 mode_combo.set_sensitive (true);
279 channel_combo.set_sensitive (true);
280 instrument_combo.set_sensitive (false);
281 configuration_label.set_sensitive (true);
282 mode_label.set_sensitive (true);
283 instrument_label.set_sensitive (false);
284 route_group_combo.set_sensitive (true);
287 channel_combo.set_sensitive (false);
288 mode_combo.set_sensitive (false);
289 instrument_combo.set_sensitive (true);
290 configuration_label.set_sensitive (false);
291 mode_label.set_sensitive (false);
292 instrument_label.set_sensitive (true);
293 route_group_combo.set_sensitive (true);
297 MessageDialog msg (_("Audio+MIDI tracks are intended for use <b>ONLY</b> with plugins that use both audio and MIDI input data\n\n"
298 "If you do not plan to use such a plugin, then use a normal audio or MIDI track instead."),
299 true, MESSAGE_INFO, BUTTONS_OK, true);
300 msg.set_position (WIN_POS_MOUSE);
303 channel_combo.set_sensitive (true);
304 mode_combo.set_sensitive (true);
305 instrument_combo.set_sensitive (true);
306 configuration_label.set_sensitive (true);
307 mode_label.set_sensitive (true);
308 instrument_label.set_sensitive (true);
309 route_group_combo.set_sensitive (true);
312 mode_combo.set_sensitive (false);
313 channel_combo.set_sensitive (true);
314 instrument_combo.set_sensitive (false);
315 configuration_label.set_sensitive (true);
316 mode_label.set_sensitive (true);
317 instrument_label.set_sensitive (false);
318 route_group_combo.set_sensitive (true);
321 mode_combo.set_sensitive (false);
322 channel_combo.set_sensitive (false);
323 instrument_combo.set_sensitive (false);
324 configuration_label.set_sensitive (false);
325 mode_label.set_sensitive (false);
326 instrument_label.set_sensitive (false);
327 route_group_combo.set_sensitive (false);
330 mode_combo.set_sensitive (false);
331 channel_combo.set_sensitive (false);
332 instrument_combo.set_sensitive (true);
333 configuration_label.set_sensitive (false);
334 mode_label.set_sensitive (true);
335 instrument_label.set_sensitive (true);
339 maybe_update_name_template_entry ();
344 AddRouteDialog::name_template () const
346 return name_template_entry.get_text ();
350 AddRouteDialog::name_template_is_default() const
352 string n = name_template();
354 if (n == _("Audio") ||
356 n == _("Audio+MIDI") ||
366 AddRouteDialog::count ()
368 return (int) floor (routes_adjustment.get_value ());
372 AddRouteDialog::refill_track_modes ()
376 s.push_back (_("Normal"));
377 s.push_back (_("Non Layered"));
378 s.push_back (_("Tape"));
380 set_popdown_strings (mode_combo, s);
381 mode_combo.set_active_text (s.front());
385 AddRouteDialog::mode ()
387 std::string str = mode_combo.get_active_text();
388 if (str == _("Normal")) {
389 return ARDOUR::Normal;
390 } else if (str == _("Non Layered")){
391 return ARDOUR::NonLayered;
392 } else if (str == _("Tape")) {
393 return ARDOUR::Destructive;
395 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
397 abort(); /*NOTREACHED*/
400 return ARDOUR::Normal;
404 AddRouteDialog::channels ()
408 switch (type_wanted()) {
411 str = channel_combo.get_active_text();
412 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
413 if (str == (*i).name) {
414 ret.set (DataType::AUDIO, (*i).channels);
418 ret.set (DataType::MIDI, 0);
423 ret.set (DataType::AUDIO, 0);
424 ret.set (DataType::MIDI, 1);
428 str = channel_combo.get_active_text();
429 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
430 if (str == (*i).name) {
431 ret.set (DataType::AUDIO, (*i).channels);
435 ret.set (DataType::MIDI, 1);
445 AddRouteDialog::track_template ()
447 string str = channel_combo.get_active_text();
449 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
450 if (str == (*i).name) {
451 return (*i).template_path;
459 AddRouteDialog::on_show ()
461 refill_channel_setups ();
462 refill_route_groups ();
468 AddRouteDialog::refill_channel_setups ()
472 route_templates.clear ();
473 channel_combo_strings.clear ();
474 channel_setups.clear ();
476 chn.name = _("Mono");
478 channel_setups.push_back (chn);
480 chn.name = _("Stereo");
482 channel_setups.push_back (chn);
484 chn.name = "separator";
485 channel_setups.push_back (chn);
487 ARDOUR::find_route_templates (route_templates);
489 if (!route_templates.empty()) {
491 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
494 chn.template_path = x->path;
495 channel_setups.push_back (chn);
499 /* clear template path for the rest */
501 chn.template_path = "";
503 chn.name = _("3 Channel");
505 channel_setups.push_back (chn);
507 chn.name = _("4 Channel");
509 channel_setups.push_back (chn);
511 chn.name = _("5 Channel");
513 channel_setups.push_back (chn);
515 chn.name = _("6 Channel");
517 channel_setups.push_back (chn);
519 chn.name = _("8 Channel");
521 channel_setups.push_back (chn);
523 chn.name = _("12 Channel");
525 channel_setups.push_back (chn);
527 chn.name = _("Custom");
529 channel_setups.push_back (chn);
531 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
532 channel_combo_strings.push_back ((*i).name);
535 set_popdown_strings (channel_combo, channel_combo_strings);
536 channel_combo.set_active_text (channel_combo_strings.front());
540 AddRouteDialog::add_route_group (RouteGroup* g)
542 route_group_combo.insert_text (3, g->name ());
546 AddRouteDialog::route_group ()
548 if (!_session || route_group_combo.get_active_row_number () == 2) {
552 return _session->route_group_by_name (route_group_combo.get_active_text());
556 AddRouteDialog::use_strict_io() {
557 return strict_io_combo.get_active_row_number () == 1;
561 AddRouteDialog::refill_route_groups ()
563 route_group_combo.clear ();
564 route_group_combo.append_text (_("New Group..."));
566 route_group_combo.append_text ("separator");
568 route_group_combo.append_text (_("No Group"));
571 _session->foreach_route_group (sigc::mem_fun (*this, &AddRouteDialog::add_route_group));
574 route_group_combo.set_active (2);
578 AddRouteDialog::group_changed ()
580 if (_session && route_group_combo.get_active_text () == _("New Group...")) {
581 RouteGroup* g = new RouteGroup (*_session, "");
582 RouteGroupDialog d (g, true);
586 route_group_combo.set_active (2);
589 _session->add_route_group (g);
592 route_group_combo.set_active (3);
597 AddRouteDialog::InsertAt
598 AddRouteDialog::insert_at ()
600 std::string str = insert_at_combo.get_active_text();
602 if (str == _("First")) {
604 } else if (str == _("After Selection")) {
605 return AfterSelection;
606 } else if (str == _("Before Selection")){
607 return BeforeSelection;
613 AddRouteDialog::channel_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
615 channel_combo.set_active (i);
617 return channel_combo.get_active_text () == "separator";
621 AddRouteDialog::route_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
623 route_group_combo.set_active (i);
625 return route_group_combo.get_active_text () == "separator";
629 AddRouteDialog::requested_instrument ()
631 return instrument_combo.selected_instrument();