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/stop_signal.h>
43 #include <gtkmm2ext/bindable_button.h>
44 #include <gtkmm2ext/utils.h>
46 #include "ardour/amp.h"
47 #include "ardour/audioplaylist.h"
48 #include "ardour/diskstream.h"
49 #include "ardour/event_type_map.h"
50 #include "ardour/ladspa_plugin.h"
51 #include "ardour/location.h"
52 #include "ardour/panner.h"
53 #include "ardour/playlist.h"
54 #include "ardour/playlist.h"
55 #include "ardour/processor.h"
56 #include "ardour/profile.h"
57 #include "ardour/route_group.h"
58 #include "ardour/session.h"
59 #include "ardour/session_playlist.h"
60 #include "ardour/debug.h"
61 #include "ardour/utils.h"
62 #include "evoral/Parameter.hpp"
64 #include "ardour_ui.h"
65 #include "route_time_axis.h"
66 #include "automation_time_axis.h"
67 #include "canvas_impl.h"
68 #include "crossfade_view.h"
70 #include "gui_thread.h"
72 #include "playlist_selector.h"
73 #include "point_selection.h"
75 #include "public_editor.h"
76 #include "region_view.h"
77 #include "rgb_macros.h"
78 #include "selection.h"
79 #include "simplerect.h"
80 #include "streamview.h"
82 #include "route_group_menu.h"
84 #include "ardour/track.h"
88 using namespace ARDOUR;
90 using namespace Gtkmm2ext;
92 using namespace Editing;
95 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
98 RouteTimeAxisView::setup_slider_pix ()
100 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
101 throw failed_constructor ();
105 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, boost::shared_ptr<Route> rt, Canvas& canvas)
108 , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
109 , parent_canvas (canvas)
110 , button_table (3, 3)
111 , route_group_button (_("g"))
112 , playlist_button (_("p"))
113 , size_button (_("h"))
114 , automation_button (_("a"))
115 , visual_button (_("v"))
116 , gm (sess, slider, true, 115)
120 gm.set_controls (_route, _route->shared_peak_meter(), _route->amp());
121 gm.get_level_meter().set_no_show_all();
122 gm.get_level_meter().setup_meters(50);
126 playlist_action_menu = 0;
127 automation_action_menu = 0;
128 plugins_submenu_item = 0;
132 if (!_route->is_hidden()) {
133 _marked_for_display = true;
136 timestretch_rect = 0;
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");
147 size_button.set_name ("TrackSizeButton");
148 visual_button.set_name ("TrackVisualButton");
149 hide_button.set_name ("TrackRemoveButton");
151 route_group_button.unset_flags (Gtk::CAN_FOCUS);
152 playlist_button.unset_flags (Gtk::CAN_FOCUS);
153 automation_button.unset_flags (Gtk::CAN_FOCUS);
154 size_button.unset_flags (Gtk::CAN_FOCUS);
155 visual_button.unset_flags (Gtk::CAN_FOCUS);
156 hide_button.unset_flags (Gtk::CAN_FOCUS);
158 hide_button.add (*(manage (new Image (::get_icon("hide")))));
159 hide_button.show_all ();
161 route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::edit_click), false);
162 playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
163 automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
164 size_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::size_click), false);
165 visual_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::visual_click));
166 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::hide_click));
172 rec_enable_button->remove ();
174 switch (track()->mode()) {
176 case ARDOUR::NonLayered:
177 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
179 case ARDOUR::Destructive:
180 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
183 rec_enable_button->show_all ();
185 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
186 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record"));
188 rec_enable_button->set_sensitive (_session->writable());
191 controls_hbox.pack_start(gm.get_level_meter(), false, false);
192 _route->meter_change.connect (*this, ui_bind (&RouteTimeAxisView::meter_changed, this, _1), gui_context());
193 _route->input()->changed.connect (*this, ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
194 _route->output()->changed.connect (*this, ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
196 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
197 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
199 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
200 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
202 ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
203 ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
204 ARDOUR_UI::instance()->set_tip(route_group_button, _("Route Group"));
205 ARDOUR_UI::instance()->set_tip(size_button,_("Display Height"));
206 ARDOUR_UI::instance()->set_tip(playlist_button,_("Playlist"));
207 ARDOUR_UI::instance()->set_tip(automation_button, _("Automation"));
208 ARDOUR_UI::instance()->set_tip(visual_button, _("Visual options"));
209 ARDOUR_UI::instance()->set_tip(hide_button, _("Hide this track"));
215 /* old school - when we used to put an extra row of buttons in place */
217 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
218 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
219 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
220 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
224 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
227 if (is_track() && track()->mode() == ARDOUR::Normal) {
228 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
233 _route->processors_changed.connect (*this, ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
234 _route->PropertyChanged.connect (*this, ui_bind (&RouteTimeAxisView::route_property_changed, this, _1), gui_context());
238 track()->TrackModeChanged.connect (*this, boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
239 track()->FreezeChange.connect (*this, boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
240 track()->DiskstreamChanged.connect (*this, boost::bind (&RouteTimeAxisView::diskstream_changed, this), gui_context());
241 get_diskstream()->SpeedChanged.connect (*this, boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
243 /* pick up the correct freeze state */
248 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
249 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
251 PropertyList* plist = new PropertyList();
253 plist->add (ARDOUR::Properties::edit, true);
254 plist->add (ARDOUR::Properties::mute, true);
255 plist->add (ARDOUR::Properties::solo, true);
257 route_group_menu = new RouteGroupMenu (_session, plist);
258 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
260 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
261 gm.get_gain_slider().set_name ("TrackGainFader");
264 RouteTimeAxisView::~RouteTimeAxisView ()
266 CatchDeletion (this);
268 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
272 delete playlist_menu;
275 delete playlist_action_menu;
276 playlist_action_menu = 0;
281 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
285 _automation_tracks.clear ();
287 delete route_group_menu;
291 RouteTimeAxisView::post_construct ()
293 /* map current state of the route */
295 update_diskstream_display ();
297 subplugin_menu.items().clear ();
298 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
299 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
300 reset_processor_automation_curves ();
304 RouteTimeAxisView::edit_click (GdkEventButton *ev)
306 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
307 if (_route->route_group()) {
308 _route->route_group()->remove (_route);
313 route_group_menu->rebuild (_route->route_group ());
314 route_group_menu->popup (ev->button, ev->time);
320 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
325 if (_route->route_group()) {
326 _route->route_group()->remove (_route);
332 RouteTimeAxisView::playlist_changed ()
338 RouteTimeAxisView::label_view ()
340 string x = _route->name();
342 if (x != name_entry.get_text()) {
343 name_entry.set_text (x);
346 ARDOUR_UI::instance()->set_tip (name_entry, x);
350 RouteTimeAxisView::route_property_changed (const PropertyChange& what_changed)
352 if (what_changed.contains (ARDOUR::Properties::name)) {
358 RouteTimeAxisView::take_name_changed (void *src)
367 RouteTimeAxisView::playlist_click ()
369 // always build a new action menu
371 delete playlist_action_menu;
373 playlist_action_menu = new Menu;
374 playlist_action_menu->set_name ("ArdourContextMenu");
376 build_playlist_menu (playlist_action_menu);
378 conditionally_add_to_selection ();
379 playlist_action_menu->popup (1, gtk_get_current_event_time());
383 RouteTimeAxisView::automation_click ()
385 conditionally_add_to_selection ();
386 build_automation_action_menu ();
387 automation_action_menu->popup (1, gtk_get_current_event_time());
391 RouteTimeAxisView::set_state (const XMLNode& node, int version)
393 TimeAxisView::set_state (node, version);
395 XMLNodeList kids = node.children();
396 XMLNodeConstIterator iter;
397 const XMLProperty* prop;
399 if (_view && (prop = node.property ("layer-display"))) {
400 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
403 for (iter = kids.begin(); iter != kids.end(); ++iter) {
404 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
405 if ((prop = (*iter)->property ("automation-id")) != 0) {
407 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
408 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
409 create_automation_child(param, show);
411 warning << "Automation child has no ID" << endmsg;
420 RouteTimeAxisView::build_automation_action_menu ()
422 using namespace Menu_Helpers;
424 delete automation_action_menu;
425 automation_action_menu = new Menu;
427 MenuList& items = automation_action_menu->items();
429 automation_action_menu->set_name ("ArdourContextMenu");
431 items.push_back (MenuElem (_("Show all automation"),
432 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
434 items.push_back (MenuElem (_("Show existing automation"),
435 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
437 items.push_back (MenuElem (_("Hide all automation"),
438 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
440 /* attach the plugin submenu. It may have previously been used elsewhere, so we detach it first. */
442 detach_menu (subplugin_menu);
443 items.push_back (MenuElem (_("Plugins"), subplugin_menu));
444 items.back().set_sensitive (!subplugin_menu.items().empty());
448 RouteTimeAxisView::build_display_menu ()
450 using namespace Menu_Helpers;
452 /* get the size menu ready */
458 TimeAxisView::build_display_menu ();
460 /* now fill it with our stuff */
462 MenuList& items = display_menu->items();
463 display_menu->set_name ("ArdourContextMenu");
465 items.push_back (MenuElem (_("Height"), *size_menu));
466 items.push_back (MenuElem (_("Color"), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
468 items.push_back (SeparatorElem());
470 if (!Profile->get_sae()) {
471 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
472 /* rebuild this every time */
473 build_automation_action_menu ();
474 detach_menu (*automation_action_menu);
475 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
476 items.push_back (SeparatorElem());
479 // Hook for derived classes to add type specific stuff
480 append_extra_display_menu_items ();
481 items.push_back (SeparatorElem());
485 Menu *layers_menu = manage(new Menu);
486 MenuList &layers_items = layers_menu->items();
487 layers_menu->set_name("ArdourContextMenu");
489 RadioMenuItem::Group layers_group;
491 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
492 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
493 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
494 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
496 items.push_back (MenuElem (_("Layers"), *layers_menu));
498 Menu* alignment_menu = manage (new Menu);
499 MenuList& alignment_items = alignment_menu->items();
500 alignment_menu->set_name ("ArdourContextMenu");
502 RadioMenuItem::Group align_group;
504 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
505 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
506 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
507 if (get_diskstream()->alignment_style() == ExistingMaterial)
508 align_existing_item->set_active();
510 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
511 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
512 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
513 if (get_diskstream()->alignment_style() == CaptureTime)
514 align_capture_item->set_active();
516 if (!Profile->get_sae()) {
517 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
518 get_diskstream()->AlignmentStyleChanged.connect (route_connections, boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
520 RadioMenuItem::Group mode_group;
521 items.push_back (RadioMenuElem (mode_group, _("Normal mode"), sigc::bind (
522 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
524 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
526 items.push_back (RadioMenuElem (mode_group, _("Tape mode"), sigc::bind (
527 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
528 ARDOUR::Destructive)));
529 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
531 items.push_back (RadioMenuElem (mode_group, _("No layering mode"),
532 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
533 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
537 switch (track()->mode()) {
538 case ARDOUR::Destructive:
539 destructive_track_mode_item->set_active ();
542 normal_track_mode_item->set_active ();
544 case ARDOUR::NonLayered:
545 non_layered_track_mode_item->set_active ();
550 get_diskstream()->AlignmentStyleChanged.connect (route_connections, boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
552 mode_menu = build_mode_menu();
554 items.push_back (MenuElem (_("Mode"), *mode_menu));
556 color_mode_menu = build_color_mode_menu();
558 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
560 items.push_back (SeparatorElem());
563 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
564 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
565 route_active_menu_item->set_active (_route->active());
567 items.push_back (SeparatorElem());
568 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &RouteTimeAxisView::hide_click)));
569 if (!Profile->get_sae()) {
570 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
572 items.push_front (SeparatorElem());
573 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
577 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
580 item_2->set_active ();
585 RouteTimeAxisView::set_track_mode (TrackMode mode)
588 RadioMenuItem* other_item;
589 RadioMenuItem* other_item_2;
593 item = normal_track_mode_item;
594 other_item = non_layered_track_mode_item;
595 other_item_2 = destructive_track_mode_item;
597 case ARDOUR::NonLayered:
598 item = non_layered_track_mode_item;
599 other_item = normal_track_mode_item;
600 other_item_2 = destructive_track_mode_item;
602 case ARDOUR::Destructive:
603 item = destructive_track_mode_item;
604 other_item = normal_track_mode_item;
605 other_item_2 = non_layered_track_mode_item;
608 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
613 if (item && other_item && other_item_2 && item->get_active() && track()->mode() != mode) {
614 _set_track_mode (track().get(), mode, other_item, other_item_2);
619 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
623 if (!track->can_use_mode (mode, needs_bounce)) {
627 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
630 cerr << "would bounce this one\n";
635 track->set_mode (mode);
637 rec_enable_button->remove ();
640 case ARDOUR::NonLayered:
642 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
644 case ARDOUR::Destructive:
645 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
649 rec_enable_button->show_all ();
653 RouteTimeAxisView::track_mode_changed ()
657 switch (track()->mode()) {
659 item = normal_track_mode_item;
661 case ARDOUR::NonLayered:
662 item = non_layered_track_mode_item;
664 case ARDOUR::Destructive:
665 item = destructive_track_mode_item;
668 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
677 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
683 TimeAxisView::show_timestretch (start, end);
693 /* check that the time selection was made in our route, or our route group.
694 remember that route_group() == 0 implies the route is *not* in a edit group.
697 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
698 /* this doesn't apply to us */
702 /* ignore it if our edit group is not active */
704 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
709 if (timestretch_rect == 0) {
710 timestretch_rect = new SimpleRect (*canvas_display ());
711 timestretch_rect->property_x1() = 0.0;
712 timestretch_rect->property_y1() = 0.0;
713 timestretch_rect->property_x2() = 0.0;
714 timestretch_rect->property_y2() = 0.0;
715 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
716 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
719 timestretch_rect->show ();
720 timestretch_rect->raise_to_top ();
722 x1 = start / _editor.get_current_zoom();
723 x2 = (end - 1) / _editor.get_current_zoom();
724 y2 = current_height() - 2;
726 timestretch_rect->property_x1() = x1;
727 timestretch_rect->property_y1() = 1.0;
728 timestretch_rect->property_x2() = x2;
729 timestretch_rect->property_y2() = y2;
733 RouteTimeAxisView::hide_timestretch ()
735 TimeAxisView::hide_timestretch ();
737 if (timestretch_rect) {
738 timestretch_rect->hide ();
743 RouteTimeAxisView::show_selection (TimeSelection& ts)
747 /* ignore it if our edit group is not active or if the selection was started
748 in some other track or route group (remember that route_group() == 0 means
749 that the track is not in an route group).
752 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
753 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
759 TimeAxisView::show_selection (ts);
763 RouteTimeAxisView::set_height (uint32_t h)
766 bool height_changed = (height == 0) || (h != height);
767 gm.get_level_meter().setup_meters (gmlen);
769 TimeAxisView::set_height (h);
774 _view->set_height ((double) current_height());
778 snprintf (buf, sizeof (buf), "%u", height);
779 xml_node->add_property ("height", buf);
781 if (height >= hNormal) {
786 gm.get_gain_slider().show();
788 if (!_route || _route->is_monitor()) {
793 if (rec_enable_button)
794 rec_enable_button->show();
796 route_group_button.show();
798 visual_button.show();
800 automation_button.show();
802 if (is_track() && track()->mode() == ARDOUR::Normal) {
803 playlist_button.show();
806 } else if (height >= hSmaller) {
812 gm.get_gain_slider().hide();
814 if (!_route || _route->is_monitor()) {
819 if (rec_enable_button)
820 rec_enable_button->show();
822 route_group_button.hide ();
824 visual_button.hide ();
826 automation_button.hide ();
828 if (is_track() && track()->mode() == ARDOUR::Normal) {
829 playlist_button.hide ();
835 /* don't allow name_entry to be hidden while
836 it has focus, otherwise the GUI becomes unusable.
839 if (name_entry.has_focus()) {
840 if (name_entry.get_text() != _route->name()) {
841 name_entry_changed ();
843 controls_ebox.grab_focus ();
849 gm.get_gain_slider().hide();
852 if (rec_enable_button)
853 rec_enable_button->hide();
855 route_group_button.hide ();
857 visual_button.hide ();
859 automation_button.hide ();
860 playlist_button.hide ();
861 name_label.set_text (_route->name());
864 if (height_changed && !no_redraw) {
865 /* only emit the signal if the height really changed */
866 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
871 RouteTimeAxisView::select_track_color ()
873 if (RouteUI::choose_color ()) {
876 _view->apply_color (_color, StreamView::RegionColor);
882 RouteTimeAxisView::reset_samples_per_unit ()
884 set_samples_per_unit (_editor.get_current_zoom());
888 RouteTimeAxisView::set_samples_per_unit (double spu)
892 if (get_diskstream() != 0) {
893 speed = get_diskstream()->speed();
897 _view->set_samples_per_unit (spu * speed);
900 TimeAxisView::set_samples_per_unit (spu * speed);
904 RouteTimeAxisView::align_style_changed ()
906 switch (get_diskstream()->alignment_style()) {
907 case ExistingMaterial:
908 if (!align_existing_item->get_active()) {
909 align_existing_item->set_active();
913 if (!align_capture_item->get_active()) {
914 align_capture_item->set_active();
921 RouteTimeAxisView::set_align_style (AlignStyle style)
926 case ExistingMaterial:
927 item = align_existing_item;
930 item = align_capture_item;
933 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
938 if (item->get_active()) {
939 get_diskstream()->set_align_style (style);
944 RouteTimeAxisView::rename_current_playlist ()
946 ArdourPrompter prompter (true);
949 boost::shared_ptr<Diskstream> ds = get_diskstream();
950 if (!ds || ds->destructive())
953 boost::shared_ptr<Playlist> pl = ds->playlist();
957 prompter.set_prompt (_("Name for playlist"));
958 prompter.set_initial_text (pl->name());
959 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
960 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
962 switch (prompter.run ()) {
963 case Gtk::RESPONSE_ACCEPT:
964 prompter.get_result (name);
976 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
978 std::string ret (basename);
980 std::string const group_string = "." + route_group()->name() + ".";
982 // iterate through all playlists
984 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
985 std::string tmp = (*i)->name();
987 std::string::size_type idx = tmp.find(group_string);
988 // find those which belong to this group
989 if (idx != string::npos) {
990 tmp = tmp.substr(idx + group_string.length());
992 // and find the largest current number
993 int x = atoi(tmp.c_str());
1003 snprintf (buf, sizeof(buf), "%d", maxnumber);
1005 ret = this->name() + "." + route_group()->name () + "." + buf;
1011 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1015 boost::shared_ptr<Diskstream> ds = get_diskstream();
1016 if (!ds || ds->destructive())
1019 boost::shared_ptr<const Playlist> pl = ds->playlist();
1025 if (route_group() && route_group()->is_active()) {
1026 name = resolve_new_group_playlist_name(name, playlists_before_op);
1029 while (_session->playlists->by_name(name)) {
1030 name = Playlist::bump_name (name, *_session);
1033 // TODO: The prompter "new" button should be de-activated if the user
1034 // specifies a playlist name which already exists in the session.
1038 ArdourPrompter prompter (true);
1040 prompter.set_prompt (_("Name for Playlist"));
1041 prompter.set_initial_text (name);
1042 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1043 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1044 prompter.show_all ();
1046 switch (prompter.run ()) {
1047 case Gtk::RESPONSE_ACCEPT:
1048 prompter.get_result (name);
1056 if (name.length()) {
1057 ds->use_copy_playlist ();
1058 ds->playlist()->set_name (name);
1063 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1067 boost::shared_ptr<Diskstream> ds = get_diskstream();
1068 if (!ds || ds->destructive())
1071 boost::shared_ptr<const Playlist> pl = ds->playlist();
1077 if (route_group() && route_group()->is_active()) {
1078 name = resolve_new_group_playlist_name(name,playlists_before_op);
1081 while (_session->playlists->by_name(name)) {
1082 name = Playlist::bump_name (name, *_session);
1088 ArdourPrompter prompter (true);
1090 prompter.set_prompt (_("Name for Playlist"));
1091 prompter.set_initial_text (name);
1092 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1093 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1095 switch (prompter.run ()) {
1096 case Gtk::RESPONSE_ACCEPT:
1097 prompter.get_result (name);
1105 if (name.length()) {
1106 ds->use_new_playlist ();
1107 ds->playlist()->set_name (name);
1112 RouteTimeAxisView::clear_playlist ()
1114 boost::shared_ptr<Diskstream> ds = get_diskstream();
1115 if (!ds || ds->destructive())
1118 boost::shared_ptr<Playlist> pl = ds->playlist();
1122 _editor.clear_playlist (pl);
1126 RouteTimeAxisView::speed_changed ()
1128 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1132 RouteTimeAxisView::diskstream_changed ()
1134 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::update_diskstream_display, this));
1138 RouteTimeAxisView::update_diskstream_display ()
1140 if (!get_diskstream()) // bus
1147 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1149 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1151 /* special case: select/deselect all tracks */
1152 if (_editor.get_selection().selected (this)) {
1153 _editor.get_selection().clear_tracks ();
1155 _editor.select_all_tracks ();
1161 switch (ArdourKeyboard::selection_type (ev->state)) {
1162 case Selection::Toggle:
1163 _editor.get_selection().toggle (this);
1166 case Selection::Set:
1167 _editor.get_selection().set (this);
1170 case Selection::Extend:
1171 _editor.extend_selection_to_track (*this);
1174 case Selection::Add:
1175 _editor.get_selection().add (this);
1181 RouteTimeAxisView::set_selected_points (PointSelection& points)
1183 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1184 (*i)->set_selected_points (points);
1189 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1192 _view->set_selected_regionviews (regions);
1196 /** Add the selectable things that we have to a list.
1197 * @param results List to add things to.
1200 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1204 if (get_diskstream() != 0) {
1205 speed = get_diskstream()->speed();
1208 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1209 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1211 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1212 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1215 /* pick up visible automation tracks */
1217 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1218 if (!(*i)->hidden()) {
1219 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1225 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1228 _view->get_inverted_selectables (sel, results);
1231 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1232 if (!(*i)->hidden()) {
1233 (*i)->get_inverted_selectables (sel, results);
1241 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1243 return (_show_automation.find(param) != _show_automation.end());
1246 /** Retuns 0 if track for \a param doesn't exist.
1248 RouteTimeAxisView::RouteAutomationNode*
1249 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1251 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1253 if (i != _automation_tracks.end()) {
1260 /** Shorthand for GainAutomation, etc.
1262 RouteTimeAxisView::RouteAutomationNode*
1263 RouteTimeAxisView::automation_track (AutomationType type)
1265 return automation_track (Evoral::Parameter(type));
1269 RouteTimeAxisView::route_group () const
1271 return _route->route_group();
1275 RouteTimeAxisView::name() const
1277 return _route->name();
1280 boost::shared_ptr<Playlist>
1281 RouteTimeAxisView::playlist () const
1283 boost::shared_ptr<Diskstream> ds;
1285 if ((ds = get_diskstream()) != 0) {
1286 return ds->playlist();
1288 return boost::shared_ptr<Playlist> ();
1293 RouteTimeAxisView::name_entry_changed ()
1297 x = name_entry.get_text ();
1299 if (x == _route->name()) {
1303 strip_whitespace_edges(x);
1305 if (x.length() == 0) {
1306 name_entry.set_text (_route->name());
1310 if (!_session->route_name_unique (x)) {
1311 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1312 name_entry.set_text (_route->name());
1313 } else if (_session->route_name_internal (x)) {
1314 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1315 name_entry.set_text (_route->name());
1317 _route->set_name (x);
1322 RouteTimeAxisView::visual_click ()
1324 popup_display_menu (0);
1328 RouteTimeAxisView::hide_click ()
1330 // LAME fix for hide_button refresh fix
1331 hide_button.set_sensitive(false);
1333 _editor.hide_track_in_display (*this);
1335 hide_button.set_sensitive(true);
1338 boost::shared_ptr<Region>
1339 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1341 boost::shared_ptr<Diskstream> stream;
1342 boost::shared_ptr<Playlist> playlist;
1344 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1345 return playlist->find_next_region (pos, point, dir);
1348 return boost::shared_ptr<Region> ();
1352 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1354 boost::shared_ptr<Diskstream> stream;
1355 boost::shared_ptr<Playlist> playlist;
1357 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1358 return playlist->find_next_region_boundary (pos, dir);
1365 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1367 boost::shared_ptr<Playlist> what_we_got;
1368 boost::shared_ptr<Diskstream> ds = get_diskstream();
1369 boost::shared_ptr<Playlist> playlist;
1373 /* route is a bus, not a track */
1377 playlist = ds->playlist();
1379 TimeSelection time (selection.time);
1380 float speed = ds->speed();
1381 if (speed != 1.0f) {
1382 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1383 (*i).start = session_frame_to_track_frame((*i).start, speed);
1384 (*i).end = session_frame_to_track_frame((*i).end, speed);
1388 playlist->clear_history ();
1389 playlist->clear_owned_history ();
1393 if ((what_we_got = playlist->cut (time)) != 0) {
1394 _editor.get_cut_buffer().add (what_we_got);
1396 vector<StatefulDiffCommand*> cmds;
1398 playlist->rdiff (cmds);
1400 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1401 _session->add_command (*c);
1403 _session->add_command (new StatefulDiffCommand (playlist));
1408 if ((what_we_got = playlist->copy (time)) != 0) {
1409 _editor.get_cut_buffer().add (what_we_got);
1414 if ((what_we_got = playlist->cut (time)) != 0) {
1415 vector<StatefulDiffCommand*> cmds;
1417 playlist->rdiff (cmds);
1419 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1420 _session->add_command (*c);
1422 _session->add_command (new StatefulDiffCommand (playlist));
1423 what_we_got->release ();
1433 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1439 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1440 PlaylistSelection::iterator p;
1442 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1444 if (p == selection.playlists.end()) {
1448 if (get_diskstream()->speed() != 1.0f) {
1449 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1452 playlist->clear_history ();
1453 playlist->paste (*p, pos, times);
1454 _session->add_command (new StatefulDiffCommand (playlist));
1460 TimeAxisView::Children
1461 RouteTimeAxisView::get_child_list()
1463 TimeAxisView::Children redirect_children;
1465 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1466 if (!(*i)->hidden()) {
1467 redirect_children.push_back(*i);
1470 return redirect_children;
1474 struct PlaylistSorter {
1475 bool operator() (boost::shared_ptr<Playlist> a, boost::shared_ptr<Playlist> b) const {
1476 return a->sort_id() < b->sort_id();
1481 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1483 using namespace Menu_Helpers;
1485 if (!menu || !is_track()) {
1489 MenuList& playlist_items = menu->items();
1490 menu->set_name ("ArdourContextMenu");
1491 playlist_items.clear();
1493 delete playlist_menu;
1496 vector<boost::shared_ptr<Playlist> > playlists, playlists_ds;
1497 boost::shared_ptr<Diskstream> ds = get_diskstream();
1498 RadioMenuItem::Group playlist_group;
1500 _session->playlists->get (playlists);
1502 /* find the playlists for this diskstream */
1503 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1504 if (((*i)->get_orig_diskstream_id() == ds->id()) || (ds->playlist()->id() == (*i)->id())) {
1505 playlists_ds.push_back(*i);
1509 /* sort the playlists */
1511 sort(playlists_ds.begin(), playlists_ds.end(), cmp);
1513 /* add the playlists to the menu */
1514 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_ds.begin(); i != playlists_ds.end(); ++i) {
1515 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name()));
1516 RadioMenuItem *item = static_cast<RadioMenuItem*>(&playlist_items.back());
1517 item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr<Playlist> (*i)));
1519 if (ds->playlist()->id() == (*i)->id()) {
1525 playlist_items.push_back (SeparatorElem());
1526 playlist_items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1527 playlist_items.push_back (SeparatorElem());
1529 if (!route_group() || !route_group()->is_active()) {
1530 playlist_items.push_back (MenuElem (_("New"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1531 playlist_items.push_back (MenuElem (_("New Copy"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1534 // Use a label which tells the user what is happening
1535 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1536 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1540 playlist_items.push_back (SeparatorElem());
1541 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1542 playlist_items.push_back (SeparatorElem());
1544 playlist_items.push_back (MenuElem(_("Select from all ..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1548 RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr<Playlist> wpl)
1550 assert (is_track());
1552 // exit if we were triggered by deactivating the old playlist
1553 if (!item->get_active()) {
1557 boost::shared_ptr<Playlist> pl (wpl.lock());
1563 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1566 if (get_diskstream()->playlist() == apl) {
1567 // exit when use_playlist is called by the creation of the playlist menu
1568 // or the playlist choice is unchanged
1571 get_diskstream()->use_playlist (apl);
1574 if (route_group() && route_group()->is_active()) {
1575 std::string group_string = "."+route_group()->name()+".";
1577 std::string take_name = apl->name();
1578 std::string::size_type idx = take_name.find(group_string);
1580 if (idx == std::string::npos)
1583 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1585 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1587 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1588 if ( (*i) == this->route()) {
1592 std::string playlist_name = (*i)->name()+group_string+take_name;
1594 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1596 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1600 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1602 // No playlist for this track for this take yet, make it
1603 track->diskstream()->use_new_playlist();
1604 track->diskstream()->playlist()->set_name(playlist_name);
1606 track->diskstream()->use_playlist(ipl);
1614 RouteTimeAxisView::show_playlist_selector ()
1616 _editor.playlist_selector().show_for (this);
1620 RouteTimeAxisView::map_frozen ()
1626 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1628 switch (track()->freeze_state()) {
1630 playlist_button.set_sensitive (false);
1631 rec_enable_button->set_sensitive (false);
1634 playlist_button.set_sensitive (true);
1635 rec_enable_button->set_sensitive (true);
1641 RouteTimeAxisView::color_handler ()
1643 //case cTimeStretchOutline:
1644 if (timestretch_rect) {
1645 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1647 //case cTimeStretchFill:
1648 if (timestretch_rect) {
1649 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1655 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1656 * Will add track if necessary.
1659 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1661 RouteAutomationNode* node = automation_track(param);
1664 /* it doesn't exist yet, so we don't care about the button state: just add it */
1665 create_automation_child (param, true);
1667 bool yn = node->menu_item->get_active();
1668 if (node->track->set_visibility (node->menu_item->get_active()) && yn) {
1670 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1671 will have done that for us.
1675 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1682 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1684 RouteAutomationNode* ran = automation_track(param);
1690 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1691 _show_automation.erase (param);
1692 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1694 if (ran->menu_item && !_hidden) {
1695 ignore_toggle = true;
1696 ran->menu_item->set_active (false);
1697 ignore_toggle = false;
1700 if (_route && !no_redraw) {
1701 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1707 RouteTimeAxisView::show_all_automation ()
1711 /* Show our automation */
1713 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1714 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1715 i->second->track->set_marked_for_display (true);
1716 i->second->track->canvas_display()->show();
1717 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1718 if (i->second->menu_item) {
1719 i->second->menu_item->set_active(true);
1724 /* Show processor automation */
1726 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1727 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1728 if ((*ii)->view == 0) {
1729 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1732 (*ii)->menu_item->set_active (true);
1740 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1744 RouteTimeAxisView::show_existing_automation ()
1748 /* Show our automation */
1750 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1751 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1752 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1753 i->second->track->set_marked_for_display (true);
1754 i->second->track->canvas_display()->show();
1755 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1756 i->second->menu_item->set_active(true);
1761 /* Show processor automation */
1763 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1764 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1765 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1766 (*ii)->menu_item->set_active (true);
1773 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1777 RouteTimeAxisView::hide_all_automation ()
1781 /* Hide our automation */
1783 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1784 i->second->track->set_marked_for_display (false);
1785 i->second->track->hide ();
1786 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1787 if (i->second->menu_item) {
1788 i->second->menu_item->set_active (false);
1792 /* Hide processor automation */
1794 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1795 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1796 (*ii)->menu_item->set_active (false);
1800 _show_automation.clear();
1803 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1808 RouteTimeAxisView::region_view_added (RegionView* rv)
1810 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1811 if (is_audio_track()) {
1812 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1813 boost::shared_ptr<AutomationTimeAxisView> atv;
1815 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1821 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1822 (*i)->add_ghost(rv);
1826 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1828 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1834 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1836 parent.remove_processor_automation_node (this);
1840 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1843 remove_child (pan->view);
1847 RouteTimeAxisView::ProcessorAutomationNode*
1848 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1850 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1852 if ((*i)->processor == processor) {
1854 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1855 if ((*ii)->what == what) {
1866 legalize_for_xml_node (string str)
1868 string::size_type pos;
1869 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1875 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1876 legal.replace (pos, 1, "_");
1885 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1888 ProcessorAutomationNode* pan;
1890 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1891 error << _("programming error: ")
1892 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1893 processor->name(), what)
1903 name = processor->describe_parameter (what);
1905 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1909 char state_name[256];
1910 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1912 boost::shared_ptr<AutomationControl> control
1913 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1915 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1916 new AutomationTimeAxisView (_session, _route, processor, control,
1917 _editor, *this, false, parent_canvas, name, state_name));
1919 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1921 if (!pan->view->marked_for_display()) {
1924 pan->menu_item->set_active (true);
1927 add_child (pan->view);
1930 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1933 processor->mark_automation_visible (what, true);
1937 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1940 pan->menu_item->set_active (false);
1943 i->mark_automation_visible (pan->what, false);
1946 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1951 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1953 boost::shared_ptr<Processor> processor (p.lock ());
1958 set<Evoral::Parameter> s;
1959 boost::shared_ptr<AutomationLine> al;
1961 processor->what_has_visible_data (s);
1963 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1965 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1968 add_processor_automation_curve (processor, (*i));
1974 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1976 using namespace Menu_Helpers;
1983 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1985 bool hideit = (!show);
1987 if ((node = track->get_state_node()) != 0) {
1988 if ((prop = node->property ("shown")) != 0) {
1989 if (string_is_affirmative (prop->value())) {
1995 _automation_tracks.insert (std::make_pair (param, new RouteAutomationNode(param, NULL, track)));
1997 track->set_visibility (!hideit);
2000 _show_automation.insert (param);
2004 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2007 if (!EventTypeMap::instance().is_midi_parameter(param)) {
2008 /* MIDI-related parameters are always in the menu, there's no
2009 reason to rebuild the menu just because we added a automation
2010 lane for one of them. But if we add a non-MIDI automation
2011 lane, then we need to invalidate the display menu.
2013 delete display_menu;
2019 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
2021 boost::shared_ptr<Processor> processor (p.lock ());
2023 if (!processor || !processor->display_to_user ()) {
2027 using namespace Menu_Helpers;
2028 ProcessorAutomationInfo *rai;
2029 list<ProcessorAutomationInfo*>::iterator x;
2031 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2032 std::set<Evoral::Parameter> has_visible_automation;
2034 processor->what_has_visible_data(has_visible_automation);
2036 if (automatable.empty()) {
2040 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2041 if ((*x)->processor == processor) {
2046 if (x == processor_automation.end()) {
2048 rai = new ProcessorAutomationInfo (processor);
2049 processor_automation.push_back (rai);
2057 /* any older menu was deleted at the top of processors_changed()
2058 when we cleared the subplugin menu.
2061 rai->menu = manage (new Menu);
2062 MenuList& items = rai->menu->items();
2063 rai->menu->set_name ("ArdourContextMenu");
2067 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2069 ProcessorAutomationNode* pan;
2070 CheckMenuItem* mitem;
2072 string name = processor->describe_parameter (*i);
2074 items.push_back (CheckMenuElem (name));
2075 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2077 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2078 mitem->set_active(true);
2081 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2085 pan = new ProcessorAutomationNode (*i, mitem, *this);
2087 rai->lines.push_back (pan);
2091 pan->menu_item = mitem;
2095 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2098 /* add the menu for this processor, because the subplugin
2099 menu is always cleared at the top of processors_changed().
2100 this is the result of some poor design in gtkmm and/or
2104 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2109 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2110 RouteTimeAxisView::ProcessorAutomationNode* pan)
2112 bool showit = pan->menu_item->get_active();
2113 bool redraw = false;
2115 if (pan->view == 0 && showit) {
2116 add_processor_automation_curve (rai->processor, pan->what);
2120 if (pan->view && showit != pan->view->marked_for_display()) {
2123 pan->view->set_marked_for_display (true);
2124 pan->view->canvas_display()->show();
2125 pan->view->canvas_background()->show();
2127 rai->processor->mark_automation_visible (pan->what, true);
2128 pan->view->set_marked_for_display (false);
2136 if (redraw && !no_redraw) {
2137 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2143 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2145 if (c.type == RouteProcessorChange::MeterPointChange) {
2146 /* nothing to do if only the meter point has changed */
2150 using namespace Menu_Helpers;
2152 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2153 (*i)->valid = false;
2156 subplugin_menu.items().clear ();
2158 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2159 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2161 bool deleted_processor_automation = false;
2163 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2165 list<ProcessorAutomationInfo*>::iterator tmp;
2173 processor_automation.erase (i);
2174 deleted_processor_automation = true;
2181 if (deleted_processor_automation && !no_redraw) {
2182 _route->gui_changed ("track_height", this);
2186 boost::shared_ptr<AutomationLine>
2187 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2189 ProcessorAutomationNode* pan;
2191 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2197 return boost::shared_ptr<AutomationLine>();
2201 RouteTimeAxisView::reset_processor_automation_curves ()
2203 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2209 RouteTimeAxisView::update_rec_display ()
2211 RouteUI::update_rec_display ();
2212 name_entry.set_sensitive (!_route->record_enabled());
2216 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2219 _view->set_layer_display (d);
2223 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2227 RouteTimeAxisView::layer_display () const
2230 return _view->layer_display ();
2233 /* we don't know, since we don't have a _view, so just return something */
2239 boost::shared_ptr<AutomationTimeAxisView>
2240 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2242 AutomationTracks::iterator i = _automation_tracks.find(param);
2243 if (i != _automation_tracks.end()) {
2244 return i->second->track;
2246 return boost::shared_ptr<AutomationTimeAxisView>();
2251 RouteTimeAxisView::fast_update ()
2253 gm.get_level_meter().update_meters ();
2257 RouteTimeAxisView::hide_meter ()
2260 gm.get_level_meter().hide_meters ();
2264 RouteTimeAxisView::show_meter ()
2270 RouteTimeAxisView::reset_meter ()
2272 if (Config->get_show_track_meters()) {
2273 gm.get_level_meter().setup_meters (height-5);
2280 RouteTimeAxisView::clear_meter ()
2282 gm.get_level_meter().clear_meters ();
2286 RouteTimeAxisView::meter_changed (void *src)
2288 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed, src)
2293 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2299 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2301 using namespace Menu_Helpers;
2303 if (!_underlay_streams.empty()) {
2304 MenuList& parent_items = parent_menu->items();
2305 Menu* gs_menu = manage (new Menu);
2306 gs_menu->set_name ("ArdourContextMenu");
2307 MenuList& gs_items = gs_menu->items();
2309 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2311 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2312 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2313 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2319 RouteTimeAxisView::set_underlay_state()
2321 if (!underlay_xml_node) {
2325 XMLNodeList nlist = underlay_xml_node->children();
2326 XMLNodeConstIterator niter;
2327 XMLNode *child_node;
2329 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2330 child_node = *niter;
2332 if (child_node->name() != "Underlay") {
2336 XMLProperty* prop = child_node->property ("id");
2338 PBD::ID id (prop->value());
2340 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2343 add_underlay(v->view(), false);
2352 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2358 RouteTimeAxisView& other = v->trackview();
2360 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2361 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2362 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2366 _underlay_streams.push_back(v);
2367 other._underlay_mirrors.push_back(this);
2369 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2372 if (!underlay_xml_node) {
2374 underlay_xml_node = xml_node->add_child("Underlays");
2377 XMLNode* node = underlay_xml_node->add_child("Underlay");
2378 XMLProperty* prop = node->add_property("id");
2379 prop->set_value(v->trackview().route()->id().to_s());
2385 RouteTimeAxisView::remove_underlay (StreamView* v)
2391 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2392 RouteTimeAxisView& other = v->trackview();
2394 if (it != _underlay_streams.end()) {
2395 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2397 if (gm == other._underlay_mirrors.end()) {
2398 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2402 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2404 _underlay_streams.erase(it);
2405 other._underlay_mirrors.erase(gm);
2407 if (underlay_xml_node) {
2408 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2414 RouteTimeAxisView::set_button_names ()
2416 rec_enable_button_label.set_text (_("r"));
2418 if (Config->get_solo_control_is_listen_control()) {
2419 switch (Config->get_listen_position()) {
2420 case AfterFaderListen:
2421 solo_button_label.set_text (_("A"));
2423 case PreFaderListen:
2424 solo_button_label.set_text (_("P"));
2428 solo_button_label.set_text (_("s"));
2431 mute_button_label.set_text (_("m"));