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.
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 "route_time_axis.h"
65 #include "automation_time_axis.h"
66 #include "canvas_impl.h"
67 #include "crossfade_view.h"
69 #include "gui_thread.h"
71 #include "playlist_selector.h"
72 #include "point_selection.h"
74 #include "public_editor.h"
75 #include "region_view.h"
76 #include "rgb_macros.h"
77 #include "selection.h"
78 #include "simplerect.h"
79 #include "streamview.h"
81 #include "route_group_menu.h"
83 #include "ardour/track.h"
87 using namespace ARDOUR;
89 using namespace Gtkmm2ext;
91 using namespace Editing;
94 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
97 RouteTimeAxisView::setup_slider_pix ()
99 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
100 throw failed_constructor ();
104 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, boost::shared_ptr<Route> rt, Canvas& canvas)
107 , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
108 , parent_canvas (canvas)
109 , button_table (3, 3)
110 , route_group_button (_("g"))
111 , playlist_button (_("p"))
112 , automation_button (_("a"))
113 , gm (sess, slider, true, 115)
114 , _ignore_track_mode_change (false)
116 gm.set_controls (_route, _route->shared_peak_meter(), _route->amp());
117 gm.get_level_meter().set_no_show_all();
118 gm.get_level_meter().setup_meters(50);
122 playlist_action_menu = 0;
123 automation_action_menu = 0;
124 plugins_submenu_item = 0;
128 if (!_route->is_hidden()) {
129 _marked_for_display = true;
133 update_solo_display ();
135 timestretch_rect = 0;
137 destructive_track_mode_item = 0;
138 normal_track_mode_item = 0;
139 non_layered_track_mode_item = 0;
141 ignore_toggle = false;
143 route_group_button.set_name ("TrackGroupButton");
144 playlist_button.set_name ("TrackPlaylistButton");
145 automation_button.set_name ("TrackAutomationButton");
147 route_group_button.unset_flags (Gtk::CAN_FOCUS);
148 playlist_button.unset_flags (Gtk::CAN_FOCUS);
149 automation_button.unset_flags (Gtk::CAN_FOCUS);
151 route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::edit_click), false);
152 playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
153 automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
159 rec_enable_button->remove ();
161 switch (track()->mode()) {
163 case ARDOUR::NonLayered:
164 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
166 case ARDOUR::Destructive:
167 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
170 rec_enable_button->show_all ();
172 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
173 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record"));
175 rec_enable_button->set_sensitive (_session->writable());
178 controls_hbox.pack_start(gm.get_level_meter(), false, false);
179 _route->meter_change.connect (*this, invalidator (*this), bind (&RouteTimeAxisView::meter_changed, this), gui_context());
180 _route->input()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
181 _route->output()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
183 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
185 if (!_route->is_master()) {
186 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
189 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
190 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
192 ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
193 ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
194 ARDOUR_UI::instance()->set_tip(route_group_button, _("Route Group"));
195 ARDOUR_UI::instance()->set_tip(playlist_button,_("Playlist"));
196 ARDOUR_UI::instance()->set_tip(automation_button, _("Automation"));
200 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
202 if (is_track() && track()->mode() == ARDOUR::Normal) {
203 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
208 _route->processors_changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
209 _route->PropertyChanged.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::route_property_changed, this, _1), gui_context());
213 track()->TrackModeChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
214 track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
215 track()->SpeedChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
217 /* pick up the correct freeze state */
222 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
223 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
225 PropertyList* plist = new PropertyList();
227 plist->add (ARDOUR::Properties::edit, true);
228 plist->add (ARDOUR::Properties::mute, true);
229 plist->add (ARDOUR::Properties::solo, true);
231 route_group_menu = new RouteGroupMenu (_session, plist);
232 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
234 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
235 gm.get_gain_slider().set_name ("TrackGainFader");
238 RouteTimeAxisView::~RouteTimeAxisView ()
240 CatchDeletion (this);
242 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
246 delete playlist_menu;
249 delete playlist_action_menu;
250 playlist_action_menu = 0;
255 _automation_tracks.clear ();
257 delete route_group_menu;
261 RouteTimeAxisView::post_construct ()
263 /* map current state of the route */
265 update_diskstream_display ();
267 subplugin_menu.items().clear ();
268 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
269 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
270 reset_processor_automation_curves ();
274 RouteTimeAxisView::edit_click (GdkEventButton *ev)
276 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
277 if (_route->route_group()) {
278 _route->route_group()->remove (_route);
283 route_group_menu->rebuild (_route->route_group ());
284 route_group_menu->popup (ev->button, ev->time);
290 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
295 if (_route->route_group()) {
296 _route->route_group()->remove (_route);
302 RouteTimeAxisView::playlist_changed ()
308 RouteTimeAxisView::label_view ()
310 string x = _route->name();
312 if (x != name_entry.get_text()) {
313 name_entry.set_text (x);
316 ARDOUR_UI::instance()->set_tip (name_entry, x);
320 RouteTimeAxisView::route_property_changed (const PropertyChange& what_changed)
322 if (what_changed.contains (ARDOUR::Properties::name)) {
328 RouteTimeAxisView::take_name_changed (void *src)
337 RouteTimeAxisView::playlist_click ()
339 // always build a new action menu
341 delete playlist_action_menu;
343 playlist_action_menu = new Menu;
344 playlist_action_menu->set_name ("ArdourContextMenu");
346 build_playlist_menu (playlist_action_menu);
348 conditionally_add_to_selection ();
349 playlist_action_menu->popup (1, gtk_get_current_event_time());
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);
381 warning << "Automation child has no ID" << endmsg;
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 delete automation_action_menu;
401 automation_action_menu = new Menu;
403 MenuList& items = automation_action_menu->items();
405 automation_action_menu->set_name ("ArdourContextMenu");
407 items.push_back (MenuElem (_("Show All Automation"),
408 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
410 items.push_back (MenuElem (_("Show Existing Automation"),
411 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
413 items.push_back (MenuElem (_("Hide All Automation"),
414 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
416 items.push_back (SeparatorElem ());
418 /* Attach the plugin submenu. It may have previously been used elsewhere,
419 so it was detached above */
421 items.push_back (MenuElem (_("Plugins"), subplugin_menu));
422 items.back().set_sensitive (!subplugin_menu.items().empty());
426 RouteTimeAxisView::build_display_menu ()
428 using namespace Menu_Helpers;
432 TimeAxisView::build_display_menu ();
434 /* now fill it with our stuff */
436 MenuList& items = display_menu->items();
437 display_menu->set_name ("ArdourContextMenu");
439 items.push_back (MenuElem (_("Color..."), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
441 items.push_back (SeparatorElem());
443 if (!Profile->get_sae()) {
444 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
445 /* rebuild this every time */
446 build_automation_action_menu ();
447 detach_menu (*automation_action_menu);
448 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
449 items.push_back (SeparatorElem());
452 // Hook for derived classes to add type specific stuff
453 append_extra_display_menu_items ();
454 items.push_back (SeparatorElem());
458 Menu *layers_menu = manage(new Menu);
459 MenuList &layers_items = layers_menu->items();
460 layers_menu->set_name("ArdourContextMenu");
462 RadioMenuItem::Group layers_group;
464 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
465 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
466 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
467 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
469 items.push_back (MenuElem (_("Layers"), *layers_menu));
471 Menu* alignment_menu = manage (new Menu);
472 MenuList& alignment_items = alignment_menu->items();
473 alignment_menu->set_name ("ArdourContextMenu");
475 RadioMenuItem::Group align_group;
477 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material"),
478 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
479 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
480 if (track()->alignment_style() == ExistingMaterial) {
481 align_existing_item->set_active();
484 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time"),
485 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
486 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
487 if (track()->alignment_style() == CaptureTime) {
488 align_capture_item->set_active();
491 if (!Profile->get_sae()) {
493 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
494 track()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
496 RadioMenuItem::Group mode_group;
497 items.push_back (RadioMenuElem (mode_group, _("Normal Mode"), sigc::bind (
498 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
500 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
502 items.push_back (RadioMenuElem (mode_group, _("Tape Mode"), sigc::bind (
503 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
504 ARDOUR::Destructive)));
505 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
507 items.push_back (RadioMenuElem (mode_group, _("Non-Layered Mode"),
508 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
509 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
512 _ignore_track_mode_change = true;
514 switch (track()->mode()) {
515 case ARDOUR::Destructive:
516 destructive_track_mode_item->set_active ();
519 normal_track_mode_item->set_active ();
521 case ARDOUR::NonLayered:
522 non_layered_track_mode_item->set_active ();
526 _ignore_track_mode_change = false;
529 track()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
531 color_mode_menu = build_color_mode_menu();
532 if (color_mode_menu) {
533 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
536 items.push_back (SeparatorElem());
539 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
540 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
541 route_active_menu_item->set_active (_route->active());
543 items.push_back (SeparatorElem());
544 items.push_back (MenuElem (_("Hide"), sigc::bind (sigc::mem_fun(_editor, &PublicEditor::hide_track_in_display), this, false)));
545 if (!Profile->get_sae()) {
546 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
548 items.push_front (SeparatorElem());
549 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
553 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
556 item_2->set_active ();
561 RouteTimeAxisView::set_track_mode (TrackMode mode)
563 if (_ignore_track_mode_change) {
568 RadioMenuItem* other_item;
569 RadioMenuItem* other_item_2;
573 item = normal_track_mode_item;
574 other_item = non_layered_track_mode_item;
575 other_item_2 = destructive_track_mode_item;
577 case ARDOUR::NonLayered:
578 item = non_layered_track_mode_item;
579 other_item = normal_track_mode_item;
580 other_item_2 = destructive_track_mode_item;
582 case ARDOUR::Destructive:
583 item = destructive_track_mode_item;
584 other_item = normal_track_mode_item;
585 other_item_2 = non_layered_track_mode_item;
588 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
593 if (item && other_item && other_item_2 && track()->mode() != mode) {
594 _set_track_mode (track().get(), mode, other_item, other_item_2);
599 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
603 if (!track->can_use_mode (mode, needs_bounce)) {
607 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
610 cerr << "would bounce this one\n";
611 /* XXX: radio menu item becomes inconsistent with track state in this case */
616 track->set_mode (mode);
618 rec_enable_button->remove ();
621 case ARDOUR::NonLayered:
623 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
625 case ARDOUR::Destructive:
626 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
630 rec_enable_button->show_all ();
634 RouteTimeAxisView::track_mode_changed ()
638 switch (track()->mode()) {
640 item = normal_track_mode_item;
642 case ARDOUR::NonLayered:
643 item = non_layered_track_mode_item;
645 case ARDOUR::Destructive:
646 item = destructive_track_mode_item;
649 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
658 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
664 TimeAxisView::show_timestretch (start, end);
674 /* check that the time selection was made in our route, or our route group.
675 remember that route_group() == 0 implies the route is *not* in a edit group.
678 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
679 /* this doesn't apply to us */
683 /* ignore it if our edit group is not active */
685 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
690 if (timestretch_rect == 0) {
691 timestretch_rect = new SimpleRect (*canvas_display ());
692 timestretch_rect->property_x1() = 0.0;
693 timestretch_rect->property_y1() = 0.0;
694 timestretch_rect->property_x2() = 0.0;
695 timestretch_rect->property_y2() = 0.0;
696 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
697 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
700 timestretch_rect->show ();
701 timestretch_rect->raise_to_top ();
703 x1 = start / _editor.get_current_zoom();
704 x2 = (end - 1) / _editor.get_current_zoom();
705 y2 = current_height() - 2;
707 timestretch_rect->property_x1() = x1;
708 timestretch_rect->property_y1() = 1.0;
709 timestretch_rect->property_x2() = x2;
710 timestretch_rect->property_y2() = y2;
714 RouteTimeAxisView::hide_timestretch ()
716 TimeAxisView::hide_timestretch ();
718 if (timestretch_rect) {
719 timestretch_rect->hide ();
724 RouteTimeAxisView::show_selection (TimeSelection& ts)
728 /* ignore it if our edit group is not active or if the selection was started
729 in some other track or route group (remember that route_group() == 0 means
730 that the track is not in an route group).
733 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
734 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
740 TimeAxisView::show_selection (ts);
744 RouteTimeAxisView::set_height (uint32_t h)
747 bool height_changed = (height == 0) || (h != height);
748 gm.get_level_meter().setup_meters (gmlen);
750 TimeAxisView::set_height (h);
755 _view->set_height ((double) current_height());
759 snprintf (buf, sizeof (buf), "%u", height);
760 xml_node->add_property ("height", buf);
762 if (height >= preset_height (HeightNormal)) {
767 gm.get_gain_slider().show();
769 if (!_route || _route->is_monitor()) {
774 if (rec_enable_button)
775 rec_enable_button->show();
777 route_group_button.show();
778 automation_button.show();
780 if (is_track() && track()->mode() == ARDOUR::Normal) {
781 playlist_button.show();
784 } else if (height >= preset_height (HeightSmaller)) {
790 gm.get_gain_slider().hide();
792 if (!_route || _route->is_monitor()) {
797 if (rec_enable_button)
798 rec_enable_button->show();
800 route_group_button.hide ();
801 automation_button.hide ();
803 if (is_track() && track()->mode() == ARDOUR::Normal) {
804 playlist_button.hide ();
810 /* don't allow name_entry to be hidden while
811 it has focus, otherwise the GUI becomes unusable.
814 if (name_entry.has_focus()) {
815 if (name_entry.get_text() != _route->name()) {
816 name_entry_changed ();
818 controls_ebox.grab_focus ();
824 gm.get_gain_slider().hide();
827 if (rec_enable_button)
828 rec_enable_button->hide();
830 route_group_button.hide ();
831 automation_button.hide ();
832 playlist_button.hide ();
833 name_label.set_text (_route->name());
836 if (height_changed && !no_redraw) {
837 /* only emit the signal if the height really changed */
838 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
843 RouteTimeAxisView::select_track_color ()
845 if (RouteUI::choose_color ()) {
848 _view->apply_color (_color, StreamView::RegionColor);
854 RouteTimeAxisView::reset_samples_per_unit ()
856 set_samples_per_unit (_editor.get_current_zoom());
860 RouteTimeAxisView::set_samples_per_unit (double spu)
865 speed = track()->speed();
869 _view->set_samples_per_unit (spu * speed);
872 TimeAxisView::set_samples_per_unit (spu * speed);
876 RouteTimeAxisView::align_style_changed ()
878 switch (track()->alignment_style()) {
879 case ExistingMaterial:
880 if (!align_existing_item->get_active()) {
881 align_existing_item->set_active();
885 if (!align_capture_item->get_active()) {
886 align_capture_item->set_active();
893 RouteTimeAxisView::set_align_style (AlignStyle style)
898 case ExistingMaterial:
899 item = align_existing_item;
902 item = align_capture_item;
905 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
910 if (item->get_active()) {
911 track()->set_align_style (style);
916 RouteTimeAxisView::rename_current_playlist ()
918 ArdourPrompter prompter (true);
921 boost::shared_ptr<Track> tr = track();
922 if (!tr || tr->destructive()) {
926 boost::shared_ptr<Playlist> pl = tr->playlist();
931 prompter.set_title (_("Rename Playlist"));
932 prompter.set_prompt (_("New name for playlist:"));
933 prompter.set_initial_text (pl->name());
934 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
935 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
937 switch (prompter.run ()) {
938 case Gtk::RESPONSE_ACCEPT:
939 prompter.get_result (name);
951 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
953 std::string ret (basename);
955 std::string const group_string = "." + route_group()->name() + ".";
957 // iterate through all playlists
959 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
960 std::string tmp = (*i)->name();
962 std::string::size_type idx = tmp.find(group_string);
963 // find those which belong to this group
964 if (idx != string::npos) {
965 tmp = tmp.substr(idx + group_string.length());
967 // and find the largest current number
968 int x = atoi(tmp.c_str());
978 snprintf (buf, sizeof(buf), "%d", maxnumber);
980 ret = this->name() + "." + route_group()->name () + "." + buf;
986 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
990 boost::shared_ptr<Track> tr = track ();
991 if (!tr || tr->destructive()) {
995 boost::shared_ptr<const Playlist> pl = tr->playlist();
1002 if (route_group() && route_group()->is_active()) {
1003 name = resolve_new_group_playlist_name(name, playlists_before_op);
1006 while (_session->playlists->by_name(name)) {
1007 name = Playlist::bump_name (name, *_session);
1010 // TODO: The prompter "new" button should be de-activated if the user
1011 // specifies a playlist name which already exists in the session.
1015 ArdourPrompter prompter (true);
1017 prompter.set_title (_("New Copy Playlist"));
1018 prompter.set_prompt (_("Name for new playlist:"));
1019 prompter.set_initial_text (name);
1020 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1021 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1022 prompter.show_all ();
1024 switch (prompter.run ()) {
1025 case Gtk::RESPONSE_ACCEPT:
1026 prompter.get_result (name);
1034 if (name.length()) {
1035 tr->use_copy_playlist ();
1036 tr->playlist()->set_name (name);
1041 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1045 boost::shared_ptr<Track> tr = track ();
1046 if (!tr || tr->destructive()) {
1050 boost::shared_ptr<const Playlist> pl = tr->playlist();
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);
1068 ArdourPrompter prompter (true);
1070 prompter.set_title (_("New Playlist"));
1071 prompter.set_prompt (_("Name for new playlist:"));
1072 prompter.set_initial_text (name);
1073 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1074 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1076 switch (prompter.run ()) {
1077 case Gtk::RESPONSE_ACCEPT:
1078 prompter.get_result (name);
1086 if (name.length()) {
1087 tr->use_new_playlist ();
1088 tr->playlist()->set_name (name);
1093 RouteTimeAxisView::clear_playlist ()
1095 boost::shared_ptr<Track> tr = track ();
1096 if (!tr || tr->destructive()) {
1100 boost::shared_ptr<Playlist> pl = tr->playlist();
1105 _editor.clear_playlist (pl);
1109 RouteTimeAxisView::speed_changed ()
1111 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1115 RouteTimeAxisView::update_diskstream_display ()
1125 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1127 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1129 /* special case: select/deselect all tracks */
1130 if (_editor.get_selection().selected (this)) {
1131 _editor.get_selection().clear_tracks ();
1133 _editor.select_all_tracks ();
1139 switch (ArdourKeyboard::selection_type (ev->state)) {
1140 case Selection::Toggle:
1141 _editor.get_selection().toggle (this);
1144 case Selection::Set:
1145 _editor.get_selection().set (this);
1148 case Selection::Extend:
1149 _editor.extend_selection_to_track (*this);
1152 case Selection::Add:
1153 _editor.get_selection().add (this);
1159 RouteTimeAxisView::set_selected_points (PointSelection& points)
1161 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1162 (*i)->set_selected_points (points);
1167 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1170 _view->set_selected_regionviews (regions);
1174 /** Add the selectable things that we have to a list.
1175 * @param results List to add things to.
1178 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1183 speed = track()->speed();
1186 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1187 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1189 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1190 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1193 /* pick up visible automation tracks */
1195 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1196 if (!(*i)->hidden()) {
1197 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1203 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1206 _view->get_inverted_selectables (sel, results);
1209 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1210 if (!(*i)->hidden()) {
1211 (*i)->get_inverted_selectables (sel, results);
1219 RouteTimeAxisView::route_group () const
1221 return _route->route_group();
1225 RouteTimeAxisView::name() const
1227 return _route->name();
1230 boost::shared_ptr<Playlist>
1231 RouteTimeAxisView::playlist () const
1233 boost::shared_ptr<Track> tr;
1235 if ((tr = track()) != 0) {
1236 return tr->playlist();
1238 return boost::shared_ptr<Playlist> ();
1243 RouteTimeAxisView::name_entry_changed ()
1247 x = name_entry.get_text ();
1249 if (x == _route->name()) {
1253 strip_whitespace_edges(x);
1255 if (x.length() == 0) {
1256 name_entry.set_text (_route->name());
1260 if (!_session->route_name_unique (x)) {
1261 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1262 name_entry.set_text (_route->name());
1263 } else if (_session->route_name_internal (x)) {
1264 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1265 name_entry.set_text (_route->name());
1267 _route->set_name (x);
1271 boost::shared_ptr<Region>
1272 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1274 boost::shared_ptr<Playlist> pl = playlist ();
1277 return pl->find_next_region (pos, point, dir);
1280 return boost::shared_ptr<Region> ();
1284 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1286 boost::shared_ptr<Playlist> pl = playlist ();
1289 return pl->find_next_region_boundary (pos, dir);
1296 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1298 boost::shared_ptr<Playlist> what_we_got;
1299 boost::shared_ptr<Track> tr = track ();
1300 boost::shared_ptr<Playlist> playlist;
1304 /* route is a bus, not a track */
1308 playlist = tr->playlist();
1310 TimeSelection time (selection.time);
1311 float const speed = tr->speed();
1312 if (speed != 1.0f) {
1313 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1314 (*i).start = session_frame_to_track_frame((*i).start, speed);
1315 (*i).end = session_frame_to_track_frame((*i).end, speed);
1319 playlist->clear_history ();
1320 playlist->clear_owned_history ();
1324 if ((what_we_got = playlist->cut (time)) != 0) {
1325 _editor.get_cut_buffer().add (what_we_got);
1327 vector<StatefulDiffCommand*> cmds;
1329 playlist->rdiff (cmds);
1331 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1332 _session->add_command (*c);
1334 _session->add_command (new StatefulDiffCommand (playlist));
1339 if ((what_we_got = playlist->copy (time)) != 0) {
1340 _editor.get_cut_buffer().add (what_we_got);
1345 if ((what_we_got = playlist->cut (time)) != 0) {
1346 vector<StatefulDiffCommand*> cmds;
1348 playlist->rdiff (cmds);
1350 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1351 _session->add_command (*c);
1353 _session->add_command (new StatefulDiffCommand (playlist));
1354 what_we_got->release ();
1364 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1370 boost::shared_ptr<Playlist> pl = playlist ();
1371 PlaylistSelection::iterator p;
1373 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1375 if (p == selection.playlists.end()) {
1379 if (track()->speed() != 1.0f) {
1380 pos = session_frame_to_track_frame (pos, track()->speed());
1383 pl->clear_history ();
1384 pl->paste (*p, pos, times);
1385 _session->add_command (new StatefulDiffCommand (pl));
1391 TimeAxisView::Children
1392 RouteTimeAxisView::get_child_list()
1394 TimeAxisView::Children redirect_children;
1396 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1397 if (!(*i)->hidden()) {
1398 redirect_children.push_back(*i);
1401 return redirect_children;
1405 struct PlaylistSorter {
1406 bool operator() (boost::shared_ptr<Playlist> a, boost::shared_ptr<Playlist> b) const {
1407 return a->sort_id() < b->sort_id();
1412 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1414 using namespace Menu_Helpers;
1416 if (!menu || !is_track()) {
1420 MenuList& playlist_items = menu->items();
1421 menu->set_name ("ArdourContextMenu");
1422 playlist_items.clear();
1424 delete playlist_menu;
1427 vector<boost::shared_ptr<Playlist> > playlists, playlists_tr;
1428 boost::shared_ptr<Track> tr = track();
1429 RadioMenuItem::Group playlist_group;
1431 _session->playlists->get (playlists);
1433 /* find the playlists for this diskstream */
1434 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1435 if (((*i)->get_orig_diskstream_id() == tr->diskstream_id()) || (tr->playlist()->id() == (*i)->id())) {
1436 playlists_tr.push_back(*i);
1440 /* sort the playlists */
1442 sort (playlists_tr.begin(), playlists_tr.end(), cmp);
1444 /* add the playlists to the menu */
1445 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_tr.begin(); i != playlists_tr.end(); ++i) {
1446 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name()));
1447 RadioMenuItem *item = static_cast<RadioMenuItem*>(&playlist_items.back());
1448 item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr<Playlist> (*i)));
1450 if (tr->playlist()->id() == (*i)->id()) {
1456 playlist_items.push_back (SeparatorElem());
1457 playlist_items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1458 playlist_items.push_back (SeparatorElem());
1460 if (!route_group() || !route_group()->is_active()) {
1461 playlist_items.push_back (MenuElem (_("New..."), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1462 playlist_items.push_back (MenuElem (_("New Copy..."), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1465 // Use a label which tells the user what is happening
1466 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1467 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1471 playlist_items.push_back (SeparatorElem());
1472 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1473 playlist_items.push_back (SeparatorElem());
1475 playlist_items.push_back (MenuElem(_("Select from all..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1479 RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr<Playlist> wpl)
1481 assert (is_track());
1483 // exit if we were triggered by deactivating the old playlist
1484 if (!item->get_active()) {
1488 boost::shared_ptr<Playlist> pl (wpl.lock());
1494 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1497 if (track()->playlist() == apl) {
1498 // exit when use_playlist is called by the creation of the playlist menu
1499 // or the playlist choice is unchanged
1502 track()->use_playlist (apl);
1504 if (route_group() && route_group()->is_active()) {
1505 std::string group_string = "."+route_group()->name()+".";
1507 std::string take_name = apl->name();
1508 std::string::size_type idx = take_name.find(group_string);
1510 if (idx == std::string::npos)
1513 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1515 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1517 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1518 if ( (*i) == this->route()) {
1522 std::string playlist_name = (*i)->name()+group_string+take_name;
1524 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1526 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1530 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1532 // No playlist for this track for this take yet, make it
1533 track->use_new_playlist();
1534 track->playlist()->set_name(playlist_name);
1536 track->use_playlist(ipl);
1544 RouteTimeAxisView::show_playlist_selector ()
1546 _editor.playlist_selector().show_for (this);
1550 RouteTimeAxisView::map_frozen ()
1556 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1558 switch (track()->freeze_state()) {
1560 playlist_button.set_sensitive (false);
1561 rec_enable_button->set_sensitive (false);
1564 playlist_button.set_sensitive (true);
1565 rec_enable_button->set_sensitive (true);
1571 RouteTimeAxisView::color_handler ()
1573 //case cTimeStretchOutline:
1574 if (timestretch_rect) {
1575 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1577 //case cTimeStretchFill:
1578 if (timestretch_rect) {
1579 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1585 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1586 * Will add track if necessary.
1589 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1591 boost::shared_ptr<AutomationTimeAxisView> track = automation_child (param);
1592 Gtk::CheckMenuItem* menu = automation_child_menu_item (param);
1595 /* it doesn't exist yet, so we don't care about the button state: just add it */
1596 create_automation_child (param, true);
1599 bool yn = menu->get_active();
1600 if (track->set_visibility (menu->get_active()) && yn) {
1602 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1603 will have done that for us.
1607 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1614 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1616 boost::shared_ptr<AutomationTimeAxisView> track = automation_child (param);
1622 Gtk::CheckMenuItem* menu = automation_child_menu_item (param);
1624 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1625 track->get_state_node()->add_property (X_("shown"), X_("no"));
1627 if (menu && !_hidden) {
1628 ignore_toggle = true;
1629 menu->set_active (false);
1630 ignore_toggle = false;
1633 if (_route && !no_redraw) {
1634 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1640 RouteTimeAxisView::show_all_automation ()
1644 /* Show our automation */
1646 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1647 i->second->set_marked_for_display (true);
1648 i->second->canvas_display()->show();
1649 i->second->get_state_node()->add_property ("shown", X_("yes"));
1651 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1654 menu->set_active(true);
1659 /* Show processor automation */
1661 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1662 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1663 if ((*ii)->view == 0) {
1664 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1667 (*ii)->menu_item->set_active (true);
1675 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1679 RouteTimeAxisView::show_existing_automation ()
1683 /* Show our automation */
1685 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1686 if (i->second->has_automation()) {
1687 i->second->set_marked_for_display (true);
1688 i->second->canvas_display()->show();
1689 i->second->get_state_node()->add_property ("shown", X_("yes"));
1691 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1693 menu->set_active(true);
1698 /* Show processor automation */
1700 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1701 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1702 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1703 (*ii)->menu_item->set_active (true);
1710 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1714 RouteTimeAxisView::hide_all_automation ()
1718 /* Hide our automation */
1720 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1721 i->second->set_marked_for_display (false);
1723 i->second->get_state_node()->add_property ("shown", X_("no"));
1725 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1728 menu->set_active (false);
1732 /* Hide processor automation */
1734 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1735 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1736 (*ii)->menu_item->set_active (false);
1741 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1746 RouteTimeAxisView::region_view_added (RegionView* rv)
1748 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1749 if (is_audio_track()) {
1750 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1751 boost::shared_ptr<AutomationTimeAxisView> atv;
1753 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1759 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1760 (*i)->add_ghost(rv);
1764 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1766 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1772 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1774 parent.remove_processor_automation_node (this);
1778 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1781 remove_child (pan->view);
1785 RouteTimeAxisView::ProcessorAutomationNode*
1786 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1788 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1790 if ((*i)->processor == processor) {
1792 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1793 if ((*ii)->what == what) {
1804 legalize_for_xml_node (string str)
1806 string::size_type pos;
1807 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1813 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1814 legal.replace (pos, 1, "_");
1823 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1826 ProcessorAutomationNode* pan;
1828 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1829 error << _("programming error: ")
1830 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1831 processor->name(), what)
1841 name = processor->describe_parameter (what);
1843 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1847 char state_name[256];
1848 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1850 boost::shared_ptr<AutomationControl> control
1851 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1853 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1854 new AutomationTimeAxisView (_session, _route, processor, control,
1855 _editor, *this, false, parent_canvas, name, state_name));
1857 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1859 if (!pan->view->marked_for_display()) {
1862 pan->menu_item->set_active (true);
1865 add_child (pan->view);
1868 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1871 processor->mark_automation_visible (what, true);
1875 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1878 pan->menu_item->set_active (false);
1881 i->mark_automation_visible (pan->what, false);
1884 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1889 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1891 boost::shared_ptr<Processor> processor (p.lock ());
1896 set<Evoral::Parameter> s;
1897 boost::shared_ptr<AutomationLine> al;
1899 processor->what_has_visible_data (s);
1901 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1903 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1906 add_processor_automation_curve (processor, (*i));
1912 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1914 using namespace Menu_Helpers;
1921 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1923 bool hideit = (!show);
1925 if ((node = track->get_state_node()) != 0) {
1926 if ((prop = node->property ("shown")) != 0) {
1927 if (string_is_affirmative (prop->value())) {
1933 _automation_tracks[param] = track;
1935 track->set_visibility (!hideit);
1938 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1941 if (!EventTypeMap::instance().is_midi_parameter(param)) {
1942 /* MIDI-related parameters are always in the menu, there's no
1943 reason to rebuild the menu just because we added a automation
1944 lane for one of them. But if we add a non-MIDI automation
1945 lane, then we need to invalidate the display menu.
1947 delete display_menu;
1953 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1955 boost::shared_ptr<Processor> processor (p.lock ());
1957 if (!processor || !processor->display_to_user ()) {
1961 using namespace Menu_Helpers;
1962 ProcessorAutomationInfo *rai;
1963 list<ProcessorAutomationInfo*>::iterator x;
1965 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
1966 std::set<Evoral::Parameter> has_visible_automation;
1968 processor->what_has_visible_data(has_visible_automation);
1970 if (automatable.empty()) {
1974 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
1975 if ((*x)->processor == processor) {
1980 if (x == processor_automation.end()) {
1982 rai = new ProcessorAutomationInfo (processor);
1983 processor_automation.push_back (rai);
1991 /* any older menu was deleted at the top of processors_changed()
1992 when we cleared the subplugin menu.
1995 rai->menu = manage (new Menu);
1996 MenuList& items = rai->menu->items();
1997 rai->menu->set_name ("ArdourContextMenu");
2001 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2003 ProcessorAutomationNode* pan;
2004 CheckMenuItem* mitem;
2006 string name = processor->describe_parameter (*i);
2008 items.push_back (CheckMenuElem (name));
2009 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2011 _parameter_menu_map[*i] = mitem;
2013 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2014 mitem->set_active(true);
2017 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2021 pan = new ProcessorAutomationNode (*i, mitem, *this);
2023 rai->lines.push_back (pan);
2027 pan->menu_item = mitem;
2031 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2034 /* add the menu for this processor, because the subplugin
2035 menu is always cleared at the top of processors_changed().
2036 this is the result of some poor design in gtkmm and/or
2040 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2045 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2046 RouteTimeAxisView::ProcessorAutomationNode* pan)
2048 bool showit = pan->menu_item->get_active();
2049 bool redraw = false;
2051 if (pan->view == 0 && showit) {
2052 add_processor_automation_curve (rai->processor, pan->what);
2056 if (pan->view && showit != pan->view->marked_for_display()) {
2059 pan->view->set_marked_for_display (true);
2060 pan->view->canvas_display()->show();
2061 pan->view->canvas_background()->show();
2063 rai->processor->mark_automation_visible (pan->what, true);
2064 pan->view->set_marked_for_display (false);
2072 if (redraw && !no_redraw) {
2073 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2079 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2081 if (c.type == RouteProcessorChange::MeterPointChange) {
2082 /* nothing to do if only the meter point has changed */
2086 using namespace Menu_Helpers;
2088 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2089 (*i)->valid = false;
2092 subplugin_menu.items().clear ();
2094 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2095 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2097 bool deleted_processor_automation = false;
2099 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2101 list<ProcessorAutomationInfo*>::iterator tmp;
2109 processor_automation.erase (i);
2110 deleted_processor_automation = true;
2117 if (deleted_processor_automation && !no_redraw) {
2118 _route->gui_changed ("track_height", this);
2122 boost::shared_ptr<AutomationLine>
2123 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2125 ProcessorAutomationNode* pan;
2127 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2133 return boost::shared_ptr<AutomationLine>();
2137 RouteTimeAxisView::reset_processor_automation_curves ()
2139 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2145 RouteTimeAxisView::update_rec_display ()
2147 RouteUI::update_rec_display ();
2148 name_entry.set_sensitive (!_route->record_enabled());
2152 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2155 _view->set_layer_display (d);
2159 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2163 RouteTimeAxisView::layer_display () const
2166 return _view->layer_display ();
2169 /* we don't know, since we don't have a _view, so just return something */
2175 boost::shared_ptr<AutomationTimeAxisView>
2176 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2178 AutomationTracks::iterator i = _automation_tracks.find(param);
2179 if (i != _automation_tracks.end()) {
2182 return boost::shared_ptr<AutomationTimeAxisView>();
2187 RouteTimeAxisView::fast_update ()
2189 gm.get_level_meter().update_meters ();
2193 RouteTimeAxisView::hide_meter ()
2196 gm.get_level_meter().hide_meters ();
2200 RouteTimeAxisView::show_meter ()
2206 RouteTimeAxisView::reset_meter ()
2208 if (Config->get_show_track_meters()) {
2209 gm.get_level_meter().setup_meters (height-5);
2216 RouteTimeAxisView::clear_meter ()
2218 gm.get_level_meter().clear_meters ();
2222 RouteTimeAxisView::meter_changed ()
2224 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed)
2229 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2235 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2237 using namespace Menu_Helpers;
2239 if (!_underlay_streams.empty()) {
2240 MenuList& parent_items = parent_menu->items();
2241 Menu* gs_menu = manage (new Menu);
2242 gs_menu->set_name ("ArdourContextMenu");
2243 MenuList& gs_items = gs_menu->items();
2245 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2247 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2248 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2249 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2255 RouteTimeAxisView::set_underlay_state()
2257 if (!underlay_xml_node) {
2261 XMLNodeList nlist = underlay_xml_node->children();
2262 XMLNodeConstIterator niter;
2263 XMLNode *child_node;
2265 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2266 child_node = *niter;
2268 if (child_node->name() != "Underlay") {
2272 XMLProperty* prop = child_node->property ("id");
2274 PBD::ID id (prop->value());
2276 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2279 add_underlay(v->view(), false);
2288 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2294 RouteTimeAxisView& other = v->trackview();
2296 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2297 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2298 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2302 _underlay_streams.push_back(v);
2303 other._underlay_mirrors.push_back(this);
2305 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2308 if (!underlay_xml_node) {
2310 underlay_xml_node = xml_node->add_child("Underlays");
2313 XMLNode* node = underlay_xml_node->add_child("Underlay");
2314 XMLProperty* prop = node->add_property("id");
2315 prop->set_value(v->trackview().route()->id().to_s());
2321 RouteTimeAxisView::remove_underlay (StreamView* v)
2327 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2328 RouteTimeAxisView& other = v->trackview();
2330 if (it != _underlay_streams.end()) {
2331 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2333 if (gm == other._underlay_mirrors.end()) {
2334 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2338 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2340 _underlay_streams.erase(it);
2341 other._underlay_mirrors.erase(gm);
2343 if (underlay_xml_node) {
2344 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2350 RouteTimeAxisView::set_button_names ()
2352 rec_enable_button_label.set_text (_("r"));
2354 if (_route && _route->solo_safe()) {
2355 solo_button_label.set_text (X_("!"));
2357 if (Config->get_solo_control_is_listen_control()) {
2358 switch (Config->get_listen_position()) {
2359 case AfterFaderListen:
2360 solo_button_label.set_text (_("A"));
2362 case PreFaderListen:
2363 solo_button_label.set_text (_("P"));
2367 solo_button_label.set_text (_("s"));
2370 mute_button_label.set_text (_("m"));
2374 RouteTimeAxisView::automation_child_menu_item (Evoral::Parameter param)
2376 ParameterMenuMap::iterator i = _parameter_menu_map.find (param);
2377 if (i == _parameter_menu_map.end()) {