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);
67 set_position (WIN_POS_MOUSE);
69 name_template_entry.set_name (X_("AddRouteDialogNameTemplateEntry"));
70 // routes_spinner.set_name (X_("AddRouteDialogSpinner"));
71 channel_combo.set_name (X_("ChannelCountSelector"));
72 mode_combo.set_name (X_("ChannelCountSelector"));
74 refill_channel_setups ();
75 refill_route_groups ();
76 refill_track_modes ();
78 channel_combo.set_active_text (channel_combo_strings.front());
80 track_bus_combo.append_text (_("Audio Tracks"));
81 track_bus_combo.append_text (_("MIDI Tracks"));
82 track_bus_combo.append_text (_("Audio+MIDI Tracks"));
83 track_bus_combo.append_text (_("Audio Busses"));
84 track_bus_combo.append_text (_("MIDI Busses"));
85 track_bus_combo.append_text (_("VCA Masters"));
86 track_bus_combo.set_active (0);
88 insert_at_combo.append_text (_("First"));
89 insert_at_combo.append_text (_("Before Selection"));
90 insert_at_combo.append_text (_("After Selection"));
91 insert_at_combo.append_text (_("Last"));
92 insert_at_combo.set_active (3);
94 strict_io_combo.append_text (_("Flexible-I/O"));
95 strict_io_combo.append_text (_("Strict-I/O"));
96 strict_io_combo.set_active (Config->get_strict_io () ? 1 : 0);
98 VBox* vbox = manage (new VBox);
101 get_vbox()->set_spacing (4);
103 vbox->set_spacing (18);
104 vbox->set_border_width (5);
106 HBox *type_hbox = manage (new HBox);
107 type_hbox->set_spacing (6);
109 /* track/bus choice */
111 type_hbox->pack_start (*manage (new Label (_("Add:"))));
112 type_hbox->pack_start (routes_spinner);
113 type_hbox->pack_start (track_bus_combo);
115 vbox->pack_start (*type_hbox, false, true);
117 VBox* options_box = manage (new VBox);
118 Table *table2 = manage (new Table (3, 3, false));
120 options_box->set_spacing (6);
121 table2->set_row_spacings (6);
122 table2->set_col_spacing (1, 6);
124 l = manage (new Label (_("<b>Options</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
125 l->set_use_markup ();
126 options_box->pack_start (*l, false, true);
128 l = manage (new Label ("", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
129 l->set_padding (8, 0);
130 table2->attach (*l, 0, 1, 0, 3, Gtk::FILL, Gtk::FILL, 0, 0);
134 l = manage (new Label (_("Name:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
135 table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
136 table2->attach (name_template_entry, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
139 /* Route configuration */
141 configuration_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
142 table2->attach (configuration_label, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
143 table2->attach (channel_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
146 mode_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
147 table2->attach (mode_label, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
148 table2->attach (mode_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
151 instrument_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
152 table2->attach (instrument_label, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
153 table2->attach (instrument_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
158 l = manage (new Label (_("Group:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
159 table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
160 table2->attach (route_group_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
163 /* New route will be inserted at.. */
164 l = manage (new Label (_("Insert:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
165 table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
166 table2->attach (insert_at_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
169 /* New Route's Routing is.. */
171 if (Profile->get_mixbus ()) {
172 strict_io_combo.set_active (1);
174 l = manage (new Label (_("Output Ports:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
175 table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
176 table2->attach (strict_io_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
178 ARDOUR_UI_UTILS::set_tooltip (strict_io_combo,
179 _("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."));
183 options_box->pack_start (*table2, false, true);
184 vbox->pack_start (*options_box, false, true);
186 get_vbox()->pack_start (*vbox, false, false);
188 track_bus_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::track_type_chosen));
189 channel_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::channel_combo_changed));
190 channel_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::channel_separator));
191 route_group_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::route_separator));
192 route_group_combo.signal_changed ().connect (sigc::mem_fun (*this, &AddRouteDialog::group_changed));
194 show_all_children ();
196 /* track template info will be managed whenever
197 this dialog is shown, via ::on_show()
200 add_button (Stock::CANCEL, RESPONSE_CANCEL);
201 add_button (Stock::ADD, RESPONSE_ACCEPT);
202 set_response_sensitive (RESPONSE_ACCEPT, true);
203 set_default_response (RESPONSE_ACCEPT);
205 track_type_chosen ();
208 AddRouteDialog::~AddRouteDialog ()
213 AddRouteDialog::channel_combo_changed ()
215 maybe_update_name_template_entry ();
216 refill_track_modes ();
219 AddRouteDialog::TypeWanted
220 AddRouteDialog::type_wanted() const
222 std::string str = track_bus_combo.get_active_text();
223 if (str == _("Audio Busses")) {
225 } else if (str == _("MIDI Busses")){
227 } else if (str == _("MIDI Tracks")){
229 } else if (str == _("Audio+MIDI Tracks")) {
231 } else if (str == _("Audio Tracks")) {
239 AddRouteDialog::maybe_update_name_template_entry ()
242 name_template_entry.get_text() != "" &&
243 name_template_entry.get_text() != VCA::default_name_template() &&
244 name_template_entry.get_text() != _("Audio") &&
245 name_template_entry.get_text() != _("MIDI") &&
246 name_template_entry.get_text() != _("Audio+MIDI") &&
247 name_template_entry.get_text() != _("Bus")) {
248 strict_io_combo.set_sensitive (false);
252 strict_io_combo.set_sensitive (true);
254 switch (type_wanted()) {
256 name_template_entry.set_text (_("Audio"));
259 name_template_entry.set_text (_("MIDI"));
262 name_template_entry.set_text (_("Audio+MIDI"));
266 name_template_entry.set_text (_("Bus"));
269 name_template_entry.set_text (VCA::default_name_template());
275 AddRouteDialog::track_type_chosen ()
277 switch (type_wanted()) {
279 mode_combo.set_sensitive (true);
280 channel_combo.set_sensitive (true);
281 instrument_combo.set_sensitive (false);
282 configuration_label.set_sensitive (true);
283 mode_label.set_sensitive (true);
284 instrument_label.set_sensitive (false);
285 route_group_combo.set_sensitive (true);
288 channel_combo.set_sensitive (false);
289 mode_combo.set_sensitive (false);
290 instrument_combo.set_sensitive (true);
291 configuration_label.set_sensitive (false);
292 mode_label.set_sensitive (false);
293 instrument_label.set_sensitive (true);
294 route_group_combo.set_sensitive (true);
298 MessageDialog msg (_("Audio+MIDI tracks are intended for use <b>ONLY</b> with plugins that use both audio and MIDI input data\n\n"
299 "If you do not plan to use such a plugin, then use a normal audio or MIDI track instead."),
300 true, MESSAGE_INFO, BUTTONS_OK, true);
301 msg.set_position (WIN_POS_MOUSE);
304 channel_combo.set_sensitive (true);
305 mode_combo.set_sensitive (true);
306 instrument_combo.set_sensitive (true);
307 configuration_label.set_sensitive (true);
308 mode_label.set_sensitive (true);
309 instrument_label.set_sensitive (true);
310 route_group_combo.set_sensitive (true);
313 mode_combo.set_sensitive (false);
314 channel_combo.set_sensitive (true);
315 instrument_combo.set_sensitive (false);
316 configuration_label.set_sensitive (true);
317 mode_label.set_sensitive (true);
318 instrument_label.set_sensitive (false);
319 route_group_combo.set_sensitive (true);
322 mode_combo.set_sensitive (false);
323 channel_combo.set_sensitive (false);
324 instrument_combo.set_sensitive (false);
325 configuration_label.set_sensitive (false);
326 mode_label.set_sensitive (false);
327 instrument_label.set_sensitive (false);
328 route_group_combo.set_sensitive (false);
331 mode_combo.set_sensitive (false);
332 channel_combo.set_sensitive (false);
333 instrument_combo.set_sensitive (true);
334 configuration_label.set_sensitive (false);
335 mode_label.set_sensitive (true);
336 instrument_label.set_sensitive (true);
340 maybe_update_name_template_entry ();
345 AddRouteDialog::name_template () const
347 return name_template_entry.get_text ();
351 AddRouteDialog::name_template_is_default() const
353 string n = name_template();
355 if (n == _("Audio") ||
357 n == _("Audio+MIDI") ||
359 n == VCA::default_name_template()) {
367 AddRouteDialog::count ()
369 return (int) floor (routes_adjustment.get_value ());
373 AddRouteDialog::refill_track_modes ()
377 s.push_back (_("Normal"));
378 s.push_back (_("Non Layered"));
379 s.push_back (_("Tape"));
381 set_popdown_strings (mode_combo, s);
382 mode_combo.set_active_text (s.front());
386 AddRouteDialog::mode ()
388 std::string str = mode_combo.get_active_text();
389 if (str == _("Normal")) {
390 return ARDOUR::Normal;
391 } else if (str == _("Non Layered")){
392 return ARDOUR::NonLayered;
393 } else if (str == _("Tape")) {
394 return ARDOUR::Destructive;
396 fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
398 abort(); /*NOTREACHED*/
401 return ARDOUR::Normal;
405 AddRouteDialog::channels ()
409 switch (type_wanted()) {
412 str = channel_combo.get_active_text();
413 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
414 if (str == (*i).name) {
415 ret.set (DataType::AUDIO, (*i).channels);
419 ret.set (DataType::MIDI, 0);
424 ret.set (DataType::AUDIO, 0);
425 ret.set (DataType::MIDI, 1);
429 str = channel_combo.get_active_text();
430 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
431 if (str == (*i).name) {
432 ret.set (DataType::AUDIO, (*i).channels);
436 ret.set (DataType::MIDI, 1);
446 AddRouteDialog::track_template ()
448 string str = channel_combo.get_active_text();
450 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
451 if (str == (*i).name) {
452 return (*i).template_path;
460 AddRouteDialog::on_show ()
462 refill_channel_setups ();
463 refill_route_groups ();
469 AddRouteDialog::refill_channel_setups ()
473 route_templates.clear ();
474 channel_combo_strings.clear ();
475 channel_setups.clear ();
477 chn.name = _("Mono");
479 channel_setups.push_back (chn);
481 chn.name = _("Stereo");
483 channel_setups.push_back (chn);
485 chn.name = "separator";
486 channel_setups.push_back (chn);
488 ARDOUR::find_route_templates (route_templates);
490 if (!route_templates.empty()) {
492 for (vector<TemplateInfo>::iterator x = route_templates.begin(); x != route_templates.end(); ++x) {
495 chn.template_path = x->path;
496 channel_setups.push_back (chn);
500 /* clear template path for the rest */
502 chn.template_path = "";
504 chn.name = _("3 Channel");
506 channel_setups.push_back (chn);
508 chn.name = _("4 Channel");
510 channel_setups.push_back (chn);
512 chn.name = _("5 Channel");
514 channel_setups.push_back (chn);
516 chn.name = _("6 Channel");
518 channel_setups.push_back (chn);
520 chn.name = _("8 Channel");
522 channel_setups.push_back (chn);
524 chn.name = _("12 Channel");
526 channel_setups.push_back (chn);
528 chn.name = _("Custom");
530 channel_setups.push_back (chn);
532 for (ChannelSetups::iterator i = channel_setups.begin(); i != channel_setups.end(); ++i) {
533 channel_combo_strings.push_back ((*i).name);
536 set_popdown_strings (channel_combo, channel_combo_strings);
537 channel_combo.set_active_text (channel_combo_strings.front());
541 AddRouteDialog::add_route_group (RouteGroup* g)
543 route_group_combo.insert_text (3, g->name ());
547 AddRouteDialog::route_group ()
549 if (!_session || route_group_combo.get_active_row_number () == 2) {
553 return _session->route_group_by_name (route_group_combo.get_active_text());
557 AddRouteDialog::use_strict_io() {
558 return strict_io_combo.get_active_row_number () == 1;
562 AddRouteDialog::refill_route_groups ()
564 route_group_combo.clear ();
565 route_group_combo.append_text (_("New Group..."));
567 route_group_combo.append_text ("separator");
569 route_group_combo.append_text (_("No Group"));
572 _session->foreach_route_group (sigc::mem_fun (*this, &AddRouteDialog::add_route_group));
575 route_group_combo.set_active (2);
579 AddRouteDialog::group_changed ()
581 if (_session && route_group_combo.get_active_text () == _("New Group...")) {
582 RouteGroup* g = new RouteGroup (*_session, "");
583 RouteGroupDialog d (g, true);
587 route_group_combo.set_active (2);
590 _session->add_route_group (g);
593 route_group_combo.set_active (3);
598 AddRouteDialog::InsertAt
599 AddRouteDialog::insert_at ()
601 std::string str = insert_at_combo.get_active_text();
603 if (str == _("First")) {
605 } else if (str == _("After Selection")) {
606 return AfterSelection;
607 } else if (str == _("Before Selection")){
608 return BeforeSelection;
614 AddRouteDialog::channel_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
616 channel_combo.set_active (i);
618 return channel_combo.get_active_text () == "separator";
622 AddRouteDialog::route_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
624 route_group_combo.set_active (i);
626 return route_group_combo.get_active_text () == "separator";
630 AddRouteDialog::requested_instrument ()
632 return instrument_combo.selected_instrument();