allow zero-input (i.e. tone generator) processors to be added
[ardour2.git] / gtk2_ardour / route_time_axis.cc
blob1730725fe74f38c8975bf18f6146d22ea6a28b56
1 /*
2 Copyright (C) 2006 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.
19 #include <cstdlib>
20 #include <cmath>
21 #include <cassert>
23 #include <algorithm>
24 #include <string>
25 #include <vector>
26 #include <map>
27 #include <utility>
29 #include <sigc++/bind.h>
31 #include "pbd/error.h"
32 #include "pbd/stl_delete.h"
33 #include "pbd/whitespace.h"
34 #include "pbd/memento_command.h"
35 #include "pbd/enumwriter.h"
36 #include "pbd/stateful_diff_command.h"
38 #include <gtkmm/menu.h>
39 #include <gtkmm/menuitem.h>
40 #include <gtkmm2ext/gtk_ui.h>
41 #include <gtkmm2ext/selector.h>
42 #include <gtkmm2ext/bindable_button.h>
43 #include <gtkmm2ext/utils.h>
45 #include "ardour/amp.h"
46 #include "ardour/audioplaylist.h"
47 #include "ardour/diskstream.h"
48 #include "ardour/event_type_map.h"
49 #include "ardour/ladspa_plugin.h"
50 #include "ardour/location.h"
51 #include "ardour/panner.h"
52 #include "ardour/playlist.h"
53 #include "ardour/playlist.h"
54 #include "ardour/processor.h"
55 #include "ardour/profile.h"
56 #include "ardour/route_group.h"
57 #include "ardour/session.h"
58 #include "ardour/session_playlist.h"
59 #include "ardour/debug.h"
60 #include "ardour/utils.h"
61 #include "evoral/Parameter.hpp"
63 #include "ardour_ui.h"
64 #include "debug.h"
65 #include "global_signals.h"
66 #include "route_time_axis.h"
67 #include "automation_time_axis.h"
68 #include "canvas_impl.h"
69 #include "crossfade_view.h"
70 #include "enums.h"
71 #include "gui_thread.h"
72 #include "keyboard.h"
73 #include "playlist_selector.h"
74 #include "point_selection.h"
75 #include "prompter.h"
76 #include "public_editor.h"
77 #include "region_view.h"
78 #include "rgb_macros.h"
79 #include "selection.h"
80 #include "simplerect.h"
81 #include "streamview.h"
82 #include "utils.h"
83 #include "route_group_menu.h"
85 #include "ardour/track.h"
87 #include "i18n.h"
89 using namespace ARDOUR;
90 using namespace PBD;
91 using namespace Gtkmm2ext;
92 using namespace Gtk;
93 using namespace Editing;
94 using namespace std;
96 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
98 void
99 RouteTimeAxisView::setup_slider_pix ()
101 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
102 throw failed_constructor ();
106 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, boost::shared_ptr<Route> rt, Canvas& canvas)
107 : AxisView(sess)
108 , RouteUI(rt, sess)
109 , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
110 , parent_canvas (canvas)
111 , button_table (3, 3)
112 , route_group_button (_("g"))
113 , playlist_button (_("p"))
114 , automation_button (_("a"))
115 , gm (sess, slider, true, 115)
116 , _ignore_track_mode_change (false)
118 gm.set_controls (_route, _route->shared_peak_meter(), _route->amp());
119 gm.get_level_meter().set_no_show_all();
120 gm.get_level_meter().setup_meters(50);
122 _has_state = true;
123 playlist_action_menu = 0;
124 automation_action_menu = 0;
125 plugins_submenu_item = 0;
126 mode_menu = 0;
127 _view = 0;
129 if (!_route->is_hidden()) {
130 _marked_for_display = true;
133 mute_changed (0);
134 update_solo_display ();
136 timestretch_rect = 0;
137 no_redraw = false;
138 destructive_track_mode_item = 0;
139 normal_track_mode_item = 0;
140 non_layered_track_mode_item = 0;
142 ignore_toggle = false;
144 route_group_button.set_name ("TrackGroupButton");
145 playlist_button.set_name ("TrackPlaylistButton");
146 automation_button.set_name ("TrackAutomationButton");
148 route_group_button.unset_flags (Gtk::CAN_FOCUS);
149 playlist_button.unset_flags (Gtk::CAN_FOCUS);
150 automation_button.unset_flags (Gtk::CAN_FOCUS);
152 route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::route_group_click), false);
153 playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
154 automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
156 if (is_track()) {
158 /* use icon */
160 rec_enable_button->remove ();
162 switch (track()->mode()) {
163 case ARDOUR::Normal:
164 case ARDOUR::NonLayered:
165 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
166 break;
167 case ARDOUR::Destructive:
168 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
169 break;
171 rec_enable_button->show_all ();
173 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
175 if (is_midi_track()) {
176 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record (Right-click for Step Edit)"));
177 } else {
178 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record"));
181 rec_enable_button->set_sensitive (_session->writable());
184 controls_hbox.pack_start(gm.get_level_meter(), false, false);
185 _route->meter_change.connect (*this, invalidator (*this), bind (&RouteTimeAxisView::meter_changed, this), gui_context());
186 _route->input()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
187 _route->output()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
189 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
191 if (!_route->is_master()) {
192 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
195 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
196 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
198 ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
199 ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
200 ARDOUR_UI::instance()->set_tip(route_group_button, _("Route Group"));
201 ARDOUR_UI::instance()->set_tip(playlist_button,_("Playlist"));
202 ARDOUR_UI::instance()->set_tip(automation_button, _("Automation"));
204 label_view ();
206 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
208 if (is_track() && track()->mode() == ARDOUR::Normal) {
209 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
212 _y_position = -1;
214 _route->processors_changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
215 _route->PropertyChanged.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::route_property_changed, this, _1), gui_context());
217 if (is_track()) {
219 track()->TrackModeChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
220 track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
221 track()->SpeedChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
223 /* pick up the correct freeze state */
224 map_frozen ();
228 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
229 _editor.HorizontalPositionChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::horizontal_position_changed));
230 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
232 PropertyList* plist = new PropertyList();
234 plist->add (ARDOUR::Properties::edit, true);
235 plist->add (ARDOUR::Properties::mute, true);
236 plist->add (ARDOUR::Properties::solo, true);
238 route_group_menu = new RouteGroupMenu (_session, plist);
239 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
241 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
242 gm.get_gain_slider().set_name ("TrackGainFader");
245 RouteTimeAxisView::~RouteTimeAxisView ()
247 CatchDeletion (this);
249 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
250 delete *i;
253 delete playlist_action_menu;
254 playlist_action_menu = 0;
256 delete _view;
257 _view = 0;
259 _automation_tracks.clear ();
261 delete route_group_menu;
264 void
265 RouteTimeAxisView::post_construct ()
267 /* map current state of the route */
269 update_diskstream_display ();
271 _subplugin_menu_map.clear ();
272 subplugin_menu.items().clear ();
273 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
274 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
275 reset_processor_automation_curves ();
278 gint
279 RouteTimeAxisView::route_group_click (GdkEventButton *ev)
281 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
282 if (_route->route_group()) {
283 _route->route_group()->remove (_route);
285 return false;
288 route_group_menu->build (_route->route_group ());
289 route_group_menu->menu()->popup (ev->button, ev->time);
291 return false;
294 void
295 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
297 if (eg) {
298 eg->add (_route);
299 } else {
300 if (_route->route_group()) {
301 _route->route_group()->remove (_route);
306 void
307 RouteTimeAxisView::playlist_changed ()
309 label_view ();
312 void
313 RouteTimeAxisView::label_view ()
315 string x = _route->name();
317 if (x != name_entry.get_text()) {
318 name_entry.set_text (x);
321 if (x != name_label.get_text()) {
322 name_label.set_text (x);
325 ARDOUR_UI::instance()->set_tip (name_entry, x);
328 void
329 RouteTimeAxisView::route_property_changed (const PropertyChange& what_changed)
331 if (what_changed.contains (ARDOUR::Properties::name)) {
332 label_view ();
336 void
337 RouteTimeAxisView::take_name_changed (void *src)
339 if (src != this) {
340 label_view ();
344 void
345 RouteTimeAxisView::playlist_click ()
347 build_playlist_menu ();
348 conditionally_add_to_selection ();
349 playlist_action_menu->popup (1, gtk_get_current_event_time());
352 void
353 RouteTimeAxisView::automation_click ()
355 conditionally_add_to_selection ();
356 build_automation_action_menu ();
357 automation_action_menu->popup (1, gtk_get_current_event_time());
361 RouteTimeAxisView::set_state (const XMLNode& node, int version)
363 TimeAxisView::set_state (node, version);
365 XMLNodeList kids = node.children();
366 XMLNodeConstIterator iter;
367 const XMLProperty* prop;
369 if (_view && (prop = node.property ("layer-display"))) {
370 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
373 for (iter = kids.begin(); iter != kids.end(); ++iter) {
374 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
375 if ((prop = (*iter)->property ("automation-id")) != 0) {
377 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
378 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
379 create_automation_child(param, show);
380 } else {
381 warning << "Automation child has no ID" << endmsg;
386 return 0;
389 void
390 RouteTimeAxisView::build_automation_action_menu ()
392 using namespace Menu_Helpers;
394 /* detach subplugin_menu from automation_action_menu before we delete automation_action_menu,
395 otherwise bad things happen (see comment for similar case in MidiTimeAxisView::build_automation_action_menu)
398 detach_menu (subplugin_menu);
400 _main_automation_menu_map.clear ();
401 delete automation_action_menu;
402 automation_action_menu = new Menu;
404 MenuList& items = automation_action_menu->items();
406 automation_action_menu->set_name ("ArdourContextMenu");
408 items.push_back (MenuElem (_("Show All Automation"),
409 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
411 items.push_back (MenuElem (_("Show Existing Automation"),
412 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
414 items.push_back (MenuElem (_("Hide All Automation"),
415 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
417 items.push_back (SeparatorElem ());
419 /* Attach the plugin submenu. It may have previously been used elsewhere,
420 so it was detached above */
422 items.push_back (MenuElem (_("Plugins"), subplugin_menu));
423 items.back().set_sensitive (!subplugin_menu.items().empty());
426 void
427 RouteTimeAxisView::build_display_menu ()
429 using namespace Menu_Helpers;
431 /* prepare it */
433 TimeAxisView::build_display_menu ();
435 /* now fill it with our stuff */
437 MenuList& items = display_menu->items();
438 display_menu->set_name ("ArdourContextMenu");
440 items.push_back (MenuElem (_("Color..."), sigc::mem_fun (*this, &RouteUI::choose_color)));
442 if (_size_menu) {
443 detach_menu (*_size_menu);
445 build_size_menu ();
446 items.push_back (MenuElem (_("Height"), *_size_menu));
448 items.push_back (SeparatorElem());
450 if (!Profile->get_sae()) {
451 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
452 items.back().set_sensitive (_editor.get_selection().tracks.size() <= 1);
453 items.push_back (SeparatorElem());
456 // Hook for derived classes to add type specific stuff
457 append_extra_display_menu_items ();
459 if (is_track()) {
461 Menu* layers_menu = manage (new Menu);
462 MenuList &layers_items = layers_menu->items();
463 layers_menu->set_name("ArdourContextMenu");
465 RadioMenuItem::Group layers_group;
467 /* Find out how many overlaid/stacked tracks we have in the selection */
469 int overlaid = 0;
470 int stacked = 0;
471 TrackSelection const & s = _editor.get_selection().tracks;
472 for (TrackSelection::const_iterator i = s.begin(); i != s.end(); ++i) {
473 StreamView* v = (*i)->view ();
474 if (!v) {
475 continue;
478 switch (v->layer_display ()) {
479 case Overlaid:
480 ++overlaid;
481 break;
482 case Stacked:
483 ++stacked;
484 break;
488 /* We're not connecting to signal_toggled() here; in the case where these two items are
489 set to be in the `inconsistent' state, it seems that one or other will end up active
490 as well as inconsistent (presumably due to the RadioMenuItem::Group). Then when you
491 select the active one, no toggled signal is emitted so nothing happens.
494 layers_items.push_back (RadioMenuElem (layers_group, _("Overlaid")));
495 RadioMenuItem* i = dynamic_cast<RadioMenuItem*> (&layers_items.back ());
496 i->set_active (overlaid != 0 && stacked == 0);
497 i->set_inconsistent (overlaid != 0 && stacked != 0);
498 i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid, true));
500 layers_items.push_back (
501 RadioMenuElem (layers_group, _("Stacked"),
502 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked, true))
505 i = dynamic_cast<RadioMenuItem*> (&layers_items.back ());
506 i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked, true));
507 i->set_active (overlaid == 0 && stacked != 0);
508 i->set_inconsistent (overlaid != 0 && stacked != 0);
510 items.push_back (MenuElem (_("Layers"), *layers_menu));
512 if (!Profile->get_sae()) {
514 Menu* alignment_menu = manage (new Menu);
515 MenuList& alignment_items = alignment_menu->items();
516 alignment_menu->set_name ("ArdourContextMenu");
518 RadioMenuItem::Group align_group;
520 /* Same verbose hacks as for the layering options above */
522 int existing = 0;
523 int capture = 0;
524 TrackSelection const & s = _editor.get_selection().tracks;
525 for (TrackSelection::const_iterator i = s.begin(); i != s.end(); ++i) {
526 RouteTimeAxisView* r = dynamic_cast<RouteTimeAxisView*> (*i);
527 if (!r || !r->is_track ()) {
528 continue;
531 switch (r->track()->alignment_style()) {
532 case ExistingMaterial:
533 ++existing;
534 break;
535 case CaptureTime:
536 ++capture;
537 break;
541 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material")));
542 RadioMenuItem* i = dynamic_cast<RadioMenuItem*> (&alignment_items.back());
543 i->signal_activate().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial, true));
544 i->set_active (existing != 0 && capture == 0);
545 i->set_inconsistent (existing != 0 && capture != 0);
547 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time")));
548 i = dynamic_cast<RadioMenuItem*> (&alignment_items.back());
549 i->signal_activate().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime, true));
550 i->set_active (existing == 0 && capture != 0);
551 i->set_inconsistent (existing != 0 && capture != 0);
553 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
555 Menu* mode_menu = manage (new Menu);
556 MenuList& mode_items = mode_menu->items ();
557 mode_menu->set_name ("ArdourContextMenu");
559 RadioMenuItem::Group mode_group;
561 mode_items.push_back (RadioMenuElem (mode_group, _("Normal Mode"), sigc::bind (
562 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
563 ARDOUR::Normal)));
564 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&mode_items.back());
566 mode_items.push_back (RadioMenuElem (mode_group, _("Tape Mode"), sigc::bind (
567 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
568 ARDOUR::Destructive)));
569 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&mode_items.back());
571 mode_items.push_back (RadioMenuElem (mode_group, _("Non-Layered Mode"),
572 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
573 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&mode_items.back());
576 _ignore_track_mode_change = true;
578 switch (track()->mode()) {
579 case ARDOUR::Destructive:
580 destructive_track_mode_item->set_active ();
581 break;
582 case ARDOUR::Normal:
583 normal_track_mode_item->set_active ();
584 break;
585 case ARDOUR::NonLayered:
586 non_layered_track_mode_item->set_active ();
587 break;
590 _ignore_track_mode_change = false;
592 items.push_back (MenuElem (_("Mode"), *mode_menu));
595 color_mode_menu = build_color_mode_menu();
596 if (color_mode_menu) {
597 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
600 items.push_back (SeparatorElem());
602 build_playlist_menu ();
603 items.push_back (MenuElem (_("Playlist"), *playlist_action_menu));
605 route_group_menu->detach ();
606 route_group_menu->build (_route->route_group ());
607 items.push_back (MenuElem (_("Route Group"), *route_group_menu->menu ()));
609 build_automation_action_menu ();
610 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
612 items.push_back (SeparatorElem());
615 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
616 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
617 route_active_menu_item->set_active (_route->active());
619 items.push_back (SeparatorElem());
620 items.push_back (MenuElem (_("Hide"), sigc::bind (sigc::mem_fun(_editor, &PublicEditor::hide_track_in_display), this, false)));
621 if (!Profile->get_sae()) {
622 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
623 } else {
624 items.push_front (SeparatorElem());
625 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
629 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
631 item->set_active ();
632 item_2->set_active ();
633 return false;
636 void
637 RouteTimeAxisView::set_track_mode (TrackMode mode)
639 if (_ignore_track_mode_change) {
640 return;
643 RadioMenuItem* item;
644 RadioMenuItem* other_item;
645 RadioMenuItem* other_item_2;
647 switch (mode) {
648 case ARDOUR::Normal:
649 item = normal_track_mode_item;
650 other_item = non_layered_track_mode_item;
651 other_item_2 = destructive_track_mode_item;
652 break;
653 case ARDOUR::NonLayered:
654 item = non_layered_track_mode_item;
655 other_item = normal_track_mode_item;
656 other_item_2 = destructive_track_mode_item;
657 break;
658 case ARDOUR::Destructive:
659 item = destructive_track_mode_item;
660 other_item = normal_track_mode_item;
661 other_item_2 = non_layered_track_mode_item;
662 break;
663 default:
664 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
665 /*NOTREACHED*/
666 return;
669 if (item && other_item && other_item_2 && track()->mode() != mode) {
670 _set_track_mode (track().get(), mode, other_item, other_item_2);
674 void
675 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
677 bool needs_bounce;
679 if (!track->can_use_mode (mode, needs_bounce)) {
681 if (!needs_bounce) {
682 /* cannot be done */
683 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
684 return;
685 } else {
686 cerr << "would bounce this one\n";
687 /* XXX: radio menu item becomes inconsistent with track state in this case */
688 return;
692 track->set_mode (mode);
694 rec_enable_button->remove ();
696 switch (mode) {
697 case ARDOUR::NonLayered:
698 case ARDOUR::Normal:
699 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
700 break;
701 case ARDOUR::Destructive:
702 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
703 break;
706 rec_enable_button->show_all ();
709 void
710 RouteTimeAxisView::track_mode_changed ()
712 RadioMenuItem* item;
714 switch (track()->mode()) {
715 case ARDOUR::Normal:
716 item = normal_track_mode_item;
717 break;
718 case ARDOUR::NonLayered:
719 item = non_layered_track_mode_item;
720 break;
721 case ARDOUR::Destructive:
722 item = destructive_track_mode_item;
723 break;
724 default:
725 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
726 /*NOTREACHED*/
727 return;
730 item->set_active ();
733 void
734 RouteTimeAxisView::show_timestretch (framepos_t start, framepos_t end)
736 double x1;
737 double x2;
738 double y2;
740 TimeAxisView::show_timestretch (start, end);
742 hide_timestretch ();
744 #if 0
745 if (ts.empty()) {
746 return;
750 /* check that the time selection was made in our route, or our route group.
751 remember that route_group() == 0 implies the route is *not* in a edit group.
754 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
755 /* this doesn't apply to us */
756 return;
759 /* ignore it if our edit group is not active */
761 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
762 return;
764 #endif
766 if (timestretch_rect == 0) {
767 timestretch_rect = new SimpleRect (*canvas_display ());
768 timestretch_rect->property_x1() = 0.0;
769 timestretch_rect->property_y1() = 0.0;
770 timestretch_rect->property_x2() = 0.0;
771 timestretch_rect->property_y2() = 0.0;
772 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
773 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
776 timestretch_rect->show ();
777 timestretch_rect->raise_to_top ();
779 x1 = start / _editor.get_current_zoom();
780 x2 = (end - 1) / _editor.get_current_zoom();
781 y2 = current_height() - 2;
783 timestretch_rect->property_x1() = x1;
784 timestretch_rect->property_y1() = 1.0;
785 timestretch_rect->property_x2() = x2;
786 timestretch_rect->property_y2() = y2;
789 void
790 RouteTimeAxisView::hide_timestretch ()
792 TimeAxisView::hide_timestretch ();
794 if (timestretch_rect) {
795 timestretch_rect->hide ();
799 void
800 RouteTimeAxisView::show_selection (TimeSelection& ts)
803 #if 0
804 /* ignore it if our edit group is not active or if the selection was started
805 in some other track or route group (remember that route_group() == 0 means
806 that the track is not in an route group).
809 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
810 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
811 hide_selection ();
812 return;
814 #endif
816 TimeAxisView::show_selection (ts);
819 void
820 RouteTimeAxisView::set_height (uint32_t h)
822 int gmlen = h - 5;
823 bool height_changed = (height == 0) || (h != height);
824 gm.get_level_meter().setup_meters (gmlen);
826 TimeAxisView::set_height (h);
828 ensure_xml_node ();
830 if (_view) {
831 _view->set_height ((double) current_height());
834 char buf[32];
835 snprintf (buf, sizeof (buf), "%u", height);
836 xml_node->add_property ("height", buf);
838 if (height >= preset_height (HeightNormal)) {
839 reset_meter();
840 show_name_entry ();
841 hide_name_label ();
843 gm.get_gain_slider().show();
844 mute_button->show();
845 if (!_route || _route->is_monitor()) {
846 solo_button->hide();
847 } else {
848 solo_button->show();
850 if (rec_enable_button)
851 rec_enable_button->show();
853 route_group_button.show();
854 automation_button.show();
856 if (is_track() && track()->mode() == ARDOUR::Normal) {
857 playlist_button.show();
860 } else if (height >= preset_height (HeightSmaller)) {
862 reset_meter();
863 show_name_entry ();
864 hide_name_label ();
866 gm.get_gain_slider().hide();
867 mute_button->show();
868 if (!_route || _route->is_monitor()) {
869 solo_button->hide();
870 } else {
871 solo_button->show();
873 if (rec_enable_button)
874 rec_enable_button->show();
876 route_group_button.hide ();
877 automation_button.hide ();
879 if (is_track() && track()->mode() == ARDOUR::Normal) {
880 playlist_button.hide ();
883 } else {
886 /* don't allow name_entry to be hidden while
887 it has focus, otherwise the GUI becomes unusable.
890 if (name_entry.has_focus()) {
891 if (name_entry.get_text() != _route->name()) {
892 name_entry_changed ();
894 controls_ebox.grab_focus ();
897 hide_name_entry ();
898 show_name_label ();
900 gm.get_gain_slider().hide();
901 mute_button->hide();
902 solo_button->hide();
903 if (rec_enable_button)
904 rec_enable_button->hide();
906 route_group_button.hide ();
907 automation_button.hide ();
908 playlist_button.hide ();
909 name_label.set_text (_route->name());
912 if (height_changed && !no_redraw) {
913 /* only emit the signal if the height really changed */
914 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
918 void
919 RouteTimeAxisView::set_color (Gdk::Color const & c)
921 RouteUI::set_color (c);
923 if (_view) {
924 _view->apply_color (_color, StreamView::RegionColor);
928 void
929 RouteTimeAxisView::reset_samples_per_unit ()
931 set_samples_per_unit (_editor.get_current_zoom());
934 void
935 RouteTimeAxisView::horizontal_position_changed ()
937 if (_view) {
938 _view->horizontal_position_changed ();
942 void
943 RouteTimeAxisView::set_samples_per_unit (double spu)
945 double speed = 1.0;
947 if (track()) {
948 speed = track()->speed();
951 if (_view) {
952 _view->set_samples_per_unit (spu * speed);
955 TimeAxisView::set_samples_per_unit (spu * speed);
958 void
959 RouteTimeAxisView::set_align_style (AlignStyle style, bool apply_to_selection)
961 if (apply_to_selection) {
962 _editor.get_selection().tracks.foreach_route_time_axis (boost::bind (&RouteTimeAxisView::set_align_style, _1, style, false));
963 } else {
964 if (track ()) {
965 track()->set_align_style (style);
970 void
971 RouteTimeAxisView::rename_current_playlist ()
973 ArdourPrompter prompter (true);
974 string name;
976 boost::shared_ptr<Track> tr = track();
977 if (!tr || tr->destructive()) {
978 return;
981 boost::shared_ptr<Playlist> pl = tr->playlist();
982 if (!pl) {
983 return;
986 prompter.set_title (_("Rename Playlist"));
987 prompter.set_prompt (_("New name for playlist:"));
988 prompter.set_initial_text (pl->name());
989 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
990 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
992 switch (prompter.run ()) {
993 case Gtk::RESPONSE_ACCEPT:
994 prompter.get_result (name);
995 if (name.length()) {
996 pl->set_name (name);
998 break;
1000 default:
1001 break;
1005 std::string
1006 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
1008 std::string ret (basename);
1010 std::string const group_string = "." + route_group()->name() + ".";
1012 // iterate through all playlists
1013 int maxnumber = 0;
1014 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
1015 std::string tmp = (*i)->name();
1017 std::string::size_type idx = tmp.find(group_string);
1018 // find those which belong to this group
1019 if (idx != string::npos) {
1020 tmp = tmp.substr(idx + group_string.length());
1022 // and find the largest current number
1023 int x = atoi(tmp.c_str());
1024 if (x > maxnumber) {
1025 maxnumber = x;
1030 maxnumber++;
1032 char buf[32];
1033 snprintf (buf, sizeof(buf), "%d", maxnumber);
1035 ret = this->name() + "." + route_group()->name () + "." + buf;
1037 return ret;
1040 void
1041 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1043 string name;
1045 boost::shared_ptr<Track> tr = track ();
1046 if (!tr || tr->destructive()) {
1047 return;
1050 boost::shared_ptr<const Playlist> pl = tr->playlist();
1051 if (!pl) {
1052 return;
1055 name = pl->name();
1057 if (route_group() && route_group()->is_active()) {
1058 name = resolve_new_group_playlist_name(name, playlists_before_op);
1061 while (_session->playlists->by_name(name)) {
1062 name = Playlist::bump_name (name, *_session);
1065 // TODO: The prompter "new" button should be de-activated if the user
1066 // specifies a playlist name which already exists in the session.
1068 if (prompt) {
1070 ArdourPrompter prompter (true);
1072 prompter.set_title (_("New Copy Playlist"));
1073 prompter.set_prompt (_("Name for new playlist:"));
1074 prompter.set_initial_text (name);
1075 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1076 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1077 prompter.show_all ();
1079 switch (prompter.run ()) {
1080 case Gtk::RESPONSE_ACCEPT:
1081 prompter.get_result (name);
1082 break;
1084 default:
1085 return;
1089 if (name.length()) {
1090 tr->use_copy_playlist ();
1091 tr->playlist()->set_name (name);
1095 void
1096 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1098 string name;
1100 boost::shared_ptr<Track> tr = track ();
1101 if (!tr || tr->destructive()) {
1102 return;
1105 boost::shared_ptr<const Playlist> pl = tr->playlist();
1106 if (!pl) {
1107 return;
1110 name = pl->name();
1112 if (route_group() && route_group()->is_active()) {
1113 name = resolve_new_group_playlist_name(name,playlists_before_op);
1116 while (_session->playlists->by_name(name)) {
1117 name = Playlist::bump_name (name, *_session);
1121 if (prompt) {
1123 ArdourPrompter prompter (true);
1125 prompter.set_title (_("New Playlist"));
1126 prompter.set_prompt (_("Name for new playlist:"));
1127 prompter.set_initial_text (name);
1128 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1129 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1131 switch (prompter.run ()) {
1132 case Gtk::RESPONSE_ACCEPT:
1133 prompter.get_result (name);
1134 break;
1136 default:
1137 return;
1141 if (name.length()) {
1142 tr->use_new_playlist ();
1143 tr->playlist()->set_name (name);
1147 void
1148 RouteTimeAxisView::clear_playlist ()
1150 boost::shared_ptr<Track> tr = track ();
1151 if (!tr || tr->destructive()) {
1152 return;
1155 boost::shared_ptr<Playlist> pl = tr->playlist();
1156 if (!pl) {
1157 return;
1160 _editor.clear_playlist (pl);
1163 void
1164 RouteTimeAxisView::speed_changed ()
1166 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1169 void
1170 RouteTimeAxisView::update_diskstream_display ()
1172 if (!track()) {
1173 return;
1176 map_frozen ();
1179 void
1180 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1182 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1184 /* special case: select/deselect all tracks */
1185 if (_editor.get_selection().selected (this)) {
1186 _editor.get_selection().clear_tracks ();
1187 } else {
1188 _editor.select_all_tracks ();
1191 return;
1194 switch (ArdourKeyboard::selection_type (ev->state)) {
1195 case Selection::Toggle:
1196 _editor.get_selection().toggle (this);
1197 break;
1199 case Selection::Set:
1200 _editor.get_selection().set (this);
1201 break;
1203 case Selection::Extend:
1204 _editor.extend_selection_to_track (*this);
1205 break;
1207 case Selection::Add:
1208 _editor.get_selection().add (this);
1209 break;
1213 void
1214 RouteTimeAxisView::set_selected_points (PointSelection& points)
1216 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1217 (*i)->set_selected_points (points);
1221 void
1222 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1224 if (_view) {
1225 _view->set_selected_regionviews (regions);
1229 /** Add the selectable things that we have to a list.
1230 * @param results List to add things to.
1232 void
1233 RouteTimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list<Selectable*>& results)
1235 double speed = 1.0;
1237 if (track() != 0) {
1238 speed = track()->speed();
1241 framepos_t const start_adjusted = session_frame_to_track_frame(start, speed);
1242 framepos_t const end_adjusted = session_frame_to_track_frame(end, speed);
1244 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1245 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1248 /* pick up visible automation tracks */
1250 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1251 if (!(*i)->hidden()) {
1252 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1257 void
1258 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1260 if (_view) {
1261 _view->get_inverted_selectables (sel, results);
1264 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1265 if (!(*i)->hidden()) {
1266 (*i)->get_inverted_selectables (sel, results);
1270 return;
1273 RouteGroup*
1274 RouteTimeAxisView::route_group () const
1276 return _route->route_group();
1279 string
1280 RouteTimeAxisView::name() const
1282 return _route->name();
1285 boost::shared_ptr<Playlist>
1286 RouteTimeAxisView::playlist () const
1288 boost::shared_ptr<Track> tr;
1290 if ((tr = track()) != 0) {
1291 return tr->playlist();
1292 } else {
1293 return boost::shared_ptr<Playlist> ();
1297 void
1298 RouteTimeAxisView::name_entry_changed ()
1300 string x;
1302 x = name_entry.get_text ();
1304 if (x == _route->name()) {
1305 return;
1308 strip_whitespace_edges(x);
1310 if (x.length() == 0) {
1311 name_entry.set_text (_route->name());
1312 return;
1315 if (!_session->route_name_unique (x)) {
1316 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1317 name_entry.set_text (_route->name());
1318 } else if (_session->route_name_internal (x)) {
1319 ARDOUR_UI::instance()->popup_error (string_compose (_("You cannot create a track with that name as it is reserved for %1"),
1320 PROGRAM_NAME));
1321 name_entry.set_text (_route->name());
1322 } else {
1323 _route->set_name (x);
1327 boost::shared_ptr<Region>
1328 RouteTimeAxisView::find_next_region (framepos_t pos, RegionPoint point, int32_t dir)
1330 boost::shared_ptr<Playlist> pl = playlist ();
1332 if (pl) {
1333 return pl->find_next_region (pos, point, dir);
1336 return boost::shared_ptr<Region> ();
1339 framepos_t
1340 RouteTimeAxisView::find_next_region_boundary (framepos_t pos, int32_t dir)
1342 boost::shared_ptr<Playlist> pl = playlist ();
1344 if (pl) {
1345 return pl->find_next_region_boundary (pos, dir);
1348 return -1;
1351 void
1352 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1354 boost::shared_ptr<Playlist> what_we_got;
1355 boost::shared_ptr<Track> tr = track ();
1356 boost::shared_ptr<Playlist> playlist;
1358 if (tr == 0) {
1359 /* route is a bus, not a track */
1360 return;
1363 playlist = tr->playlist();
1365 TimeSelection time (selection.time);
1366 float const speed = tr->speed();
1367 if (speed != 1.0f) {
1368 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1369 (*i).start = session_frame_to_track_frame((*i).start, speed);
1370 (*i).end = session_frame_to_track_frame((*i).end, speed);
1374 playlist->clear_changes ();
1375 playlist->clear_owned_changes ();
1377 switch (op) {
1378 case Cut:
1379 if ((what_we_got = playlist->cut (time)) != 0) {
1380 _editor.get_cut_buffer().add (what_we_got);
1382 vector<Command*> cmds;
1383 playlist->rdiff (cmds);
1384 _session->add_commands (cmds);
1386 _session->add_command (new StatefulDiffCommand (playlist));
1388 break;
1389 case Copy:
1390 if ((what_we_got = playlist->copy (time)) != 0) {
1391 _editor.get_cut_buffer().add (what_we_got);
1393 break;
1395 case Clear:
1396 if ((what_we_got = playlist->cut (time)) != 0) {
1398 vector<Command*> cmds;
1399 playlist->rdiff (cmds);
1400 _session->add_commands (cmds);
1401 _session->add_command (new StatefulDiffCommand (playlist));
1402 what_we_got->release ();
1404 break;
1408 bool
1409 RouteTimeAxisView::paste (framepos_t pos, float times, Selection& selection, size_t nth)
1411 if (!is_track()) {
1412 return false;
1415 boost::shared_ptr<Playlist> pl = playlist ();
1416 PlaylistSelection::iterator p;
1418 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1420 if (p == selection.playlists.end()) {
1421 return false;
1424 DEBUG_TRACE (DEBUG::CutNPaste, string_compose ("paste to %1\n", pos));
1426 if (track()->speed() != 1.0f) {
1427 pos = session_frame_to_track_frame (pos, track()->speed());
1428 DEBUG_TRACE (DEBUG::CutNPaste, string_compose ("modified paste to %1\n", pos));
1431 pl->clear_changes ();
1432 pl->paste (*p, pos, times);
1433 _session->add_command (new StatefulDiffCommand (pl));
1435 return true;
1439 struct PlaylistSorter {
1440 bool operator() (boost::shared_ptr<Playlist> a, boost::shared_ptr<Playlist> b) const {
1441 return a->sort_id() < b->sort_id();
1445 void
1446 RouteTimeAxisView::build_playlist_menu ()
1448 using namespace Menu_Helpers;
1450 if (!is_track()) {
1451 return;
1454 delete playlist_action_menu;
1455 playlist_action_menu = new Menu;
1456 playlist_action_menu->set_name ("ArdourContextMenu");
1458 MenuList& playlist_items = playlist_action_menu->items();
1459 playlist_action_menu->set_name ("ArdourContextMenu");
1460 playlist_items.clear();
1462 vector<boost::shared_ptr<Playlist> > playlists, playlists_tr;
1463 boost::shared_ptr<Track> tr = track();
1464 RadioMenuItem::Group playlist_group;
1466 _session->playlists->get (playlists);
1468 /* find the playlists for this diskstream */
1469 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1470 if (((*i)->get_orig_diskstream_id() == tr->diskstream_id()) || (tr->playlist()->id() == (*i)->id())) {
1471 playlists_tr.push_back(*i);
1475 /* sort the playlists */
1476 PlaylistSorter cmp;
1477 sort (playlists_tr.begin(), playlists_tr.end(), cmp);
1479 /* add the playlists to the menu */
1480 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_tr.begin(); i != playlists_tr.end(); ++i) {
1481 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name()));
1482 RadioMenuItem *item = static_cast<RadioMenuItem*>(&playlist_items.back());
1483 item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr<Playlist> (*i)));
1485 if (tr->playlist()->id() == (*i)->id()) {
1486 item->set_active();
1491 playlist_items.push_back (SeparatorElem());
1492 playlist_items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1493 playlist_items.push_back (SeparatorElem());
1495 if (!route_group() || !route_group()->is_active()) {
1496 playlist_items.push_back (MenuElem (_("New..."), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1497 playlist_items.push_back (MenuElem (_("New Copy..."), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1499 } else {
1500 // Use a label which tells the user what is happening
1501 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1502 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1506 playlist_items.push_back (SeparatorElem());
1507 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1508 playlist_items.push_back (SeparatorElem());
1510 playlist_items.push_back (MenuElem(_("Select from all..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1513 void
1514 RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr<Playlist> wpl)
1516 assert (is_track());
1518 // exit if we were triggered by deactivating the old playlist
1519 if (!item->get_active()) {
1520 return;
1523 boost::shared_ptr<Playlist> pl (wpl.lock());
1525 if (!pl) {
1526 return;
1529 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1531 if (apl) {
1532 if (track()->playlist() == apl) {
1533 // exit when use_playlist is called by the creation of the playlist menu
1534 // or the playlist choice is unchanged
1535 return;
1537 track()->use_playlist (apl);
1539 if (route_group() && route_group()->is_active()) {
1540 std::string group_string = "."+route_group()->name()+".";
1542 std::string take_name = apl->name();
1543 std::string::size_type idx = take_name.find(group_string);
1545 if (idx == std::string::npos)
1546 return;
1548 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1550 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1552 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1553 if ( (*i) == this->route()) {
1554 continue;
1557 std::string playlist_name = (*i)->name()+group_string+take_name;
1559 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1560 if (!track) {
1561 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1562 continue;
1565 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1566 if (!ipl) {
1567 // No playlist for this track for this take yet, make it
1568 track->use_new_playlist();
1569 track->playlist()->set_name(playlist_name);
1570 } else {
1571 track->use_playlist(ipl);
1578 void
1579 RouteTimeAxisView::show_playlist_selector ()
1581 _editor.playlist_selector().show_for (this);
1584 void
1585 RouteTimeAxisView::map_frozen ()
1587 if (!is_track()) {
1588 return;
1591 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1593 switch (track()->freeze_state()) {
1594 case Track::Frozen:
1595 playlist_button.set_sensitive (false);
1596 rec_enable_button->set_sensitive (false);
1597 break;
1598 default:
1599 playlist_button.set_sensitive (true);
1600 rec_enable_button->set_sensitive (true);
1601 break;
1605 void
1606 RouteTimeAxisView::color_handler ()
1608 //case cTimeStretchOutline:
1609 if (timestretch_rect) {
1610 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1612 //case cTimeStretchFill:
1613 if (timestretch_rect) {
1614 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1617 reset_meter();
1620 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1621 * Will add track if necessary.
1623 void
1624 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1626 boost::shared_ptr<AutomationTimeAxisView> track = automation_child (param);
1627 Gtk::CheckMenuItem* menu = automation_child_menu_item (param);
1629 if (!track) {
1630 /* it doesn't exist yet, so we don't care about the button state: just add it */
1631 create_automation_child (param, true);
1632 } else {
1633 assert (menu);
1634 bool yn = menu->get_active();
1635 if (track->set_visibility (menu->get_active()) && yn) {
1637 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1638 will have done that for us.
1641 if (!no_redraw) {
1642 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1648 void
1649 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1651 boost::shared_ptr<AutomationTimeAxisView> track = automation_child (param);
1653 if (!track) {
1654 return;
1657 Gtk::CheckMenuItem* menu = automation_child_menu_item (param);
1659 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1660 track->get_state_node()->add_property (X_("shown"), X_("no"));
1662 if (menu && !_hidden) {
1663 ignore_toggle = true;
1664 menu->set_active (false);
1665 ignore_toggle = false;
1668 if (_route && !no_redraw) {
1669 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1674 void
1675 RouteTimeAxisView::show_all_automation ()
1677 no_redraw = true;
1679 /* Show our automation */
1681 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1682 i->second->set_marked_for_display (true);
1683 i->second->canvas_display()->show();
1684 i->second->get_state_node()->add_property ("shown", X_("yes"));
1686 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1688 if (menu) {
1689 menu->set_active(true);
1694 /* Show processor automation */
1696 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1697 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1698 if ((*ii)->view == 0) {
1699 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1702 (*ii)->menu_item->set_active (true);
1706 no_redraw = false;
1708 /* Redraw */
1710 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1713 void
1714 RouteTimeAxisView::show_existing_automation ()
1716 no_redraw = true;
1718 /* Show our automation */
1720 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1721 if (i->second->has_automation()) {
1722 i->second->set_marked_for_display (true);
1723 i->second->canvas_display()->show();
1724 i->second->get_state_node()->add_property ("shown", X_("yes"));
1726 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1727 if (menu) {
1728 menu->set_active(true);
1734 /* Show processor automation */
1736 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1737 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1738 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1739 (*ii)->menu_item->set_active (true);
1744 no_redraw = false;
1746 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1749 void
1750 RouteTimeAxisView::hide_all_automation ()
1752 no_redraw = true;
1754 /* Hide our automation */
1756 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1757 i->second->set_marked_for_display (false);
1758 i->second->hide ();
1759 i->second->get_state_node()->add_property ("shown", X_("no"));
1761 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1763 if (menu) {
1764 menu->set_active (false);
1768 /* Hide processor automation */
1770 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1771 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1772 (*ii)->menu_item->set_active (false);
1776 no_redraw = false;
1777 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1781 void
1782 RouteTimeAxisView::region_view_added (RegionView* rv)
1784 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1785 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1786 boost::shared_ptr<AutomationTimeAxisView> atv;
1788 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1789 atv->add_ghost(rv);
1793 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1794 (*i)->add_ghost(rv);
1798 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1800 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1801 delete *i;
1806 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1808 parent.remove_processor_automation_node (this);
1811 void
1812 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1814 if (pan->view) {
1815 remove_child (pan->view);
1819 RouteTimeAxisView::ProcessorAutomationNode*
1820 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1822 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1824 if ((*i)->processor == processor) {
1826 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1827 if ((*ii)->what == what) {
1828 return *ii;
1834 return 0;
1837 static string
1838 legalize_for_xml_node (string str)
1840 string::size_type pos;
1841 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1842 string legal;
1844 legal = str;
1845 pos = 0;
1847 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1848 legal.replace (pos, 1, "_");
1849 pos += 1;
1852 return legal;
1856 void
1857 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1859 string name;
1860 ProcessorAutomationNode* pan;
1862 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1863 /* session state may never have been saved with new plugin */
1864 error << _("programming error: ")
1865 << string_compose (X_("processor automation curve for %1:%2/%3/%4 not registered with track!"),
1866 processor->name(), what.type(), (int) what.channel(), what.id() )
1867 << endmsg;
1868 /*NOTREACHED*/
1869 return;
1872 if (pan->view) {
1873 return;
1876 name = processor->describe_parameter (what);
1878 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1880 /* FIXME: ew */
1882 char state_name[256];
1883 snprintf (state_name, sizeof (state_name), "%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1885 boost::shared_ptr<AutomationControl> control
1886 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1888 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1889 new AutomationTimeAxisView (_session, _route, processor, control, control->parameter (),
1890 _editor, *this, false, parent_canvas, name, state_name));
1892 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1894 if (!pan->view->marked_for_display()) {
1895 pan->view->hide ();
1896 } else {
1897 pan->menu_item->set_active (true);
1900 add_child (pan->view);
1902 if (_view) {
1903 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1906 processor->mark_automation_visible (what, true);
1909 void
1910 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1912 if (!_hidden) {
1913 pan->menu_item->set_active (false);
1916 i->mark_automation_visible (pan->what, false);
1918 if (!no_redraw) {
1919 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1923 void
1924 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1926 boost::shared_ptr<Processor> processor (p.lock ());
1927 if (!processor) {
1928 return;
1931 set<Evoral::Parameter> s;
1932 boost::shared_ptr<AutomationLine> al;
1934 processor->what_has_visible_data (s);
1936 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1938 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1939 al->queue_reset ();
1940 } else {
1941 add_processor_automation_curve (processor, (*i));
1946 void
1947 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1949 using namespace Menu_Helpers;
1951 XMLProperty* prop;
1952 XMLNode* node;
1954 add_child (track);
1956 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1958 bool hideit = (!show);
1960 if ((node = track->get_state_node()) != 0) {
1961 if ((prop = node->property ("shown")) != 0) {
1962 if (string_is_affirmative (prop->value())) {
1963 hideit = false;
1968 _automation_tracks[param] = track;
1970 track->set_visibility (!hideit);
1972 if (!no_redraw) {
1973 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1976 if (!EventTypeMap::instance().is_midi_parameter(param)) {
1977 /* MIDI-related parameters are always in the menu, there's no
1978 reason to rebuild the menu just because we added a automation
1979 lane for one of them. But if we add a non-MIDI automation
1980 lane, then we need to invalidate the display menu.
1982 delete display_menu;
1983 display_menu = 0;
1987 void
1988 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1990 boost::shared_ptr<Processor> processor (p.lock ());
1992 if (!processor || !processor->display_to_user ()) {
1993 return;
1996 using namespace Menu_Helpers;
1997 ProcessorAutomationInfo *rai;
1998 list<ProcessorAutomationInfo*>::iterator x;
2000 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2001 std::set<Evoral::Parameter> has_visible_automation;
2003 processor->what_has_visible_data(has_visible_automation);
2005 if (automatable.empty()) {
2006 return;
2009 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2010 if ((*x)->processor == processor) {
2011 break;
2015 if (x == processor_automation.end()) {
2017 rai = new ProcessorAutomationInfo (processor);
2018 processor_automation.push_back (rai);
2020 } else {
2022 rai = *x;
2026 /* any older menu was deleted at the top of processors_changed()
2027 when we cleared the subplugin menu.
2030 rai->menu = manage (new Menu);
2031 MenuList& items = rai->menu->items();
2032 rai->menu->set_name ("ArdourContextMenu");
2034 items.clear ();
2036 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2038 ProcessorAutomationNode* pan;
2039 CheckMenuItem* mitem;
2041 string name = processor->describe_parameter (*i);
2043 items.push_back (CheckMenuElem (name));
2044 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2046 _subplugin_menu_map[*i] = mitem;
2048 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2049 mitem->set_active(true);
2052 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2054 /* new item */
2056 pan = new ProcessorAutomationNode (*i, mitem, *this);
2058 rai->lines.push_back (pan);
2060 } else {
2062 pan->menu_item = mitem;
2066 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2069 /* add the menu for this processor, because the subplugin
2070 menu is always cleared at the top of processors_changed().
2071 this is the result of some poor design in gtkmm and/or
2072 GTK+.
2075 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2076 rai->valid = true;
2079 void
2080 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2081 RouteTimeAxisView::ProcessorAutomationNode* pan)
2083 bool showit = pan->menu_item->get_active();
2084 bool redraw = false;
2086 if (pan->view == 0 && showit) {
2087 add_processor_automation_curve (rai->processor, pan->what);
2088 redraw = true;
2091 if (pan->view && showit != pan->view->marked_for_display()) {
2093 if (showit) {
2094 pan->view->set_marked_for_display (true);
2095 pan->view->canvas_display()->show();
2096 pan->view->canvas_background()->show();
2097 } else {
2098 rai->processor->mark_automation_visible (pan->what, true);
2099 pan->view->set_marked_for_display (false);
2100 pan->view->hide ();
2103 redraw = true;
2107 if (redraw && !no_redraw) {
2108 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2113 void
2114 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2116 if (c.type == RouteProcessorChange::MeterPointChange) {
2117 /* nothing to do if only the meter point has changed */
2118 return;
2121 using namespace Menu_Helpers;
2123 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2124 (*i)->valid = false;
2127 _subplugin_menu_map.clear ();
2128 subplugin_menu.items().clear ();
2130 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2131 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2133 bool deleted_processor_automation = false;
2135 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2137 list<ProcessorAutomationInfo*>::iterator tmp;
2139 tmp = i;
2140 ++tmp;
2142 if (!(*i)->valid) {
2144 delete *i;
2145 processor_automation.erase (i);
2146 deleted_processor_automation = true;
2150 i = tmp;
2153 if (deleted_processor_automation && !no_redraw) {
2154 _route->gui_changed ("track_height", this);
2158 boost::shared_ptr<AutomationLine>
2159 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2161 ProcessorAutomationNode* pan;
2163 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2164 if (pan->view) {
2165 pan->view->line();
2169 return boost::shared_ptr<AutomationLine>();
2172 void
2173 RouteTimeAxisView::reset_processor_automation_curves ()
2175 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2176 (*i)->reset();
2180 void
2181 RouteTimeAxisView::update_rec_display ()
2183 RouteUI::update_rec_display ();
2184 name_entry.set_sensitive (!_route->record_enabled());
2187 void
2188 RouteTimeAxisView::set_layer_display (LayerDisplay d, bool apply_to_selection)
2190 if (apply_to_selection) {
2191 _editor.get_selection().tracks.foreach_route_time_axis (boost::bind (&RouteTimeAxisView::set_layer_display, _1, d, false));
2192 } else {
2194 if (_view) {
2195 _view->set_layer_display (d);
2198 ensure_xml_node ();
2199 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2203 LayerDisplay
2204 RouteTimeAxisView::layer_display () const
2206 if (_view) {
2207 return _view->layer_display ();
2210 /* we don't know, since we don't have a _view, so just return something */
2211 return Overlaid;
2216 boost::shared_ptr<AutomationTimeAxisView>
2217 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2219 AutomationTracks::iterator i = _automation_tracks.find(param);
2220 if (i != _automation_tracks.end()) {
2221 return i->second;
2222 } else {
2223 return boost::shared_ptr<AutomationTimeAxisView>();
2227 void
2228 RouteTimeAxisView::fast_update ()
2230 gm.get_level_meter().update_meters ();
2233 void
2234 RouteTimeAxisView::hide_meter ()
2236 clear_meter ();
2237 gm.get_level_meter().hide_meters ();
2240 void
2241 RouteTimeAxisView::show_meter ()
2243 reset_meter ();
2246 void
2247 RouteTimeAxisView::reset_meter ()
2249 if (Config->get_show_track_meters()) {
2250 gm.get_level_meter().setup_meters (height-5);
2251 } else {
2252 hide_meter ();
2256 void
2257 RouteTimeAxisView::clear_meter ()
2259 gm.get_level_meter().clear_meters ();
2262 void
2263 RouteTimeAxisView::meter_changed ()
2265 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed)
2266 reset_meter();
2269 void
2270 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2272 reset_meter ();
2275 void
2276 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2278 using namespace Menu_Helpers;
2280 if (!_underlay_streams.empty()) {
2281 MenuList& parent_items = parent_menu->items();
2282 Menu* gs_menu = manage (new Menu);
2283 gs_menu->set_name ("ArdourContextMenu");
2284 MenuList& gs_items = gs_menu->items();
2286 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2288 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2289 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2290 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2295 bool
2296 RouteTimeAxisView::set_underlay_state()
2298 if (!underlay_xml_node) {
2299 return false;
2302 XMLNodeList nlist = underlay_xml_node->children();
2303 XMLNodeConstIterator niter;
2304 XMLNode *child_node;
2306 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2307 child_node = *niter;
2309 if (child_node->name() != "Underlay") {
2310 continue;
2313 XMLProperty* prop = child_node->property ("id");
2314 if (prop) {
2315 PBD::ID id (prop->value());
2317 RouteTimeAxisView* v = _editor.get_route_view_by_route_id (id);
2319 if (v) {
2320 add_underlay(v->view(), false);
2325 return false;
2328 void
2329 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2331 if (!v) {
2332 return;
2335 RouteTimeAxisView& other = v->trackview();
2337 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2338 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2339 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2340 /*NOTREACHED*/
2343 _underlay_streams.push_back(v);
2344 other._underlay_mirrors.push_back(this);
2346 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2348 if (update_xml) {
2349 if (!underlay_xml_node) {
2350 ensure_xml_node();
2351 underlay_xml_node = xml_node->add_child("Underlays");
2354 XMLNode* node = underlay_xml_node->add_child("Underlay");
2355 XMLProperty* prop = node->add_property("id");
2356 prop->set_value(v->trackview().route()->id().to_s());
2361 void
2362 RouteTimeAxisView::remove_underlay (StreamView* v)
2364 if (!v) {
2365 return;
2368 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2369 RouteTimeAxisView& other = v->trackview();
2371 if (it != _underlay_streams.end()) {
2372 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2374 if (gm == other._underlay_mirrors.end()) {
2375 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2376 /*NOTREACHED*/
2379 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2381 _underlay_streams.erase(it);
2382 other._underlay_mirrors.erase(gm);
2384 if (underlay_xml_node) {
2385 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2390 void
2391 RouteTimeAxisView::set_button_names ()
2393 rec_enable_button_label.set_text (_("r"));
2395 if (_route && _route->solo_safe()) {
2396 solo_button_label.set_text (X_("!"));
2397 } else {
2398 if (Config->get_solo_control_is_listen_control()) {
2399 switch (Config->get_listen_position()) {
2400 case AfterFaderListen:
2401 solo_button_label.set_text (_("A"));
2402 break;
2403 case PreFaderListen:
2404 solo_button_label.set_text (_("P"));
2405 break;
2407 } else {
2408 solo_button_label.set_text (_("s"));
2411 mute_button_label.set_text (_("m"));
2414 Gtk::CheckMenuItem*
2415 RouteTimeAxisView::automation_child_menu_item (Evoral::Parameter param)
2417 ParameterMenuMap::iterator i = _main_automation_menu_map.find (param);
2418 if (i != _main_automation_menu_map.end()) {
2419 return i->second;
2422 i = _subplugin_menu_map.find (param);
2423 if (i != _subplugin_menu_map.end()) {
2424 return i->second;
2427 return 0;
2430 void
2431 RouteTimeAxisView::create_gain_automation_child (const Evoral::Parameter& param, bool show)
2433 boost::shared_ptr<AutomationControl> c = _route->gain_control();
2434 if (!c) {
2435 error << "Route has no gain automation, unable to add automation track view." << endmsg;
2436 return;
2439 gain_track.reset (new AutomationTimeAxisView (_session,
2440 _route, _route->amp(), c, param,
2441 _editor,
2442 *this,
2443 false,
2444 parent_canvas,
2445 _route->amp()->describe_parameter(param)));
2447 add_automation_child (Evoral::Parameter(GainAutomation), gain_track, show);