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::route_group_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);
174 if (is_midi_track()) {
175 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record (Right-click for Step Edit)"));
177 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record"));
180 rec_enable_button->set_sensitive (_session->writable());
183 controls_hbox.pack_start(gm.get_level_meter(), false, false);
184 _route->meter_change.connect (*this, invalidator (*this), bind (&RouteTimeAxisView::meter_changed, this), gui_context());
185 _route->input()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
186 _route->output()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
188 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
190 if (!_route->is_master()) {
191 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
194 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
195 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
197 ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
198 ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
199 ARDOUR_UI::instance()->set_tip(route_group_button, _("Route Group"));
200 ARDOUR_UI::instance()->set_tip(playlist_button,_("Playlist"));
201 ARDOUR_UI::instance()->set_tip(automation_button, _("Automation"));
205 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
207 if (is_track() && track()->mode() == ARDOUR::Normal) {
208 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
213 _route->processors_changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
214 _route->PropertyChanged.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::route_property_changed, this, _1), gui_context());
218 track()->TrackModeChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
219 track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
220 track()->SpeedChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
222 /* pick up the correct freeze state */
227 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
228 _editor.HorizontalPositionChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::horizontal_position_changed));
229 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
231 PropertyList* plist = new PropertyList();
233 plist->add (ARDOUR::Properties::edit, true);
234 plist->add (ARDOUR::Properties::mute, true);
235 plist->add (ARDOUR::Properties::solo, true);
237 route_group_menu = new RouteGroupMenu (_session, plist);
238 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
240 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
241 gm.get_gain_slider().set_name ("TrackGainFader");
244 RouteTimeAxisView::~RouteTimeAxisView ()
246 CatchDeletion (this);
248 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
252 delete playlist_menu;
255 delete playlist_action_menu;
256 playlist_action_menu = 0;
261 _automation_tracks.clear ();
263 delete route_group_menu;
267 RouteTimeAxisView::post_construct ()
269 /* map current state of the route */
271 update_diskstream_display ();
273 _subplugin_menu_map.clear ();
274 subplugin_menu.items().clear ();
275 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
276 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
277 reset_processor_automation_curves ();
281 RouteTimeAxisView::route_group_click (GdkEventButton *ev)
283 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
284 if (_route->route_group()) {
285 _route->route_group()->remove (_route);
290 route_group_menu->rebuild (_route->route_group ());
291 route_group_menu->popup (ev->button, ev->time);
297 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
302 if (_route->route_group()) {
303 _route->route_group()->remove (_route);
309 RouteTimeAxisView::playlist_changed ()
315 RouteTimeAxisView::label_view ()
317 string x = _route->name();
319 if (x != name_entry.get_text()) {
320 name_entry.set_text (x);
323 ARDOUR_UI::instance()->set_tip (name_entry, x);
327 RouteTimeAxisView::route_property_changed (const PropertyChange& what_changed)
329 if (what_changed.contains (ARDOUR::Properties::name)) {
335 RouteTimeAxisView::take_name_changed (void *src)
344 RouteTimeAxisView::playlist_click ()
346 build_playlist_menu ();
347 conditionally_add_to_selection ();
348 playlist_action_menu->popup (1, gtk_get_current_event_time());
352 RouteTimeAxisView::automation_click ()
354 conditionally_add_to_selection ();
355 build_automation_action_menu ();
356 automation_action_menu->popup (1, gtk_get_current_event_time());
360 RouteTimeAxisView::set_state (const XMLNode& node, int version)
362 TimeAxisView::set_state (node, version);
364 XMLNodeList kids = node.children();
365 XMLNodeConstIterator iter;
366 const XMLProperty* prop;
368 if (_view && (prop = node.property ("layer-display"))) {
369 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
372 for (iter = kids.begin(); iter != kids.end(); ++iter) {
373 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
374 if ((prop = (*iter)->property ("automation-id")) != 0) {
376 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
377 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
378 create_automation_child(param, show);
380 warning << "Automation child has no ID" << endmsg;
389 RouteTimeAxisView::build_automation_action_menu ()
391 using namespace Menu_Helpers;
393 /* detach subplugin_menu from automation_action_menu before we delete automation_action_menu,
394 otherwise bad things happen (see comment for similar case in MidiTimeAxisView::build_automation_action_menu)
397 detach_menu (subplugin_menu);
399 _main_automation_menu_map.clear ();
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 if (!Profile->get_sae()) {
473 Menu* alignment_menu = manage (new Menu);
474 MenuList& alignment_items = alignment_menu->items();
475 alignment_menu->set_name ("ArdourContextMenu");
477 RadioMenuItem::Group align_group;
479 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material"),
480 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
481 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
482 if (track()->alignment_style() == ExistingMaterial) {
483 align_existing_item->set_active();
486 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time"),
487 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
488 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
489 if (track()->alignment_style() == CaptureTime) {
490 align_capture_item->set_active();
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 Menu* mode_menu = manage (new Menu);
497 MenuList& mode_items = mode_menu->items ();
498 mode_menu->set_name ("ArdourContextMenu");
500 RadioMenuItem::Group mode_group;
502 mode_items.push_back (RadioMenuElem (mode_group, _("Normal Mode"), sigc::bind (
503 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
505 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&mode_items.back());
507 mode_items.push_back (RadioMenuElem (mode_group, _("Tape Mode"), sigc::bind (
508 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
509 ARDOUR::Destructive)));
510 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&mode_items.back());
512 mode_items.push_back (RadioMenuElem (mode_group, _("Non-Layered Mode"),
513 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
514 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&mode_items.back());
517 _ignore_track_mode_change = true;
519 switch (track()->mode()) {
520 case ARDOUR::Destructive:
521 destructive_track_mode_item->set_active ();
524 normal_track_mode_item->set_active ();
526 case ARDOUR::NonLayered:
527 non_layered_track_mode_item->set_active ();
531 _ignore_track_mode_change = false;
533 items.push_back (MenuElem (_("Mode"), *mode_menu));
536 color_mode_menu = build_color_mode_menu();
537 if (color_mode_menu) {
538 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
541 items.push_back (SeparatorElem());
543 build_playlist_menu ();
544 items.push_back (MenuElem (_("Playlist"), *playlist_action_menu));
546 route_group_menu->rebuild (_route->route_group ());
547 items.push_back (MenuElem (_("Route Group"), *route_group_menu));
549 build_automation_action_menu ();
550 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
552 items.push_back (SeparatorElem());
555 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
556 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
557 route_active_menu_item->set_active (_route->active());
559 items.push_back (SeparatorElem());
560 items.push_back (MenuElem (_("Hide"), sigc::bind (sigc::mem_fun(_editor, &PublicEditor::hide_track_in_display), this, false)));
561 if (!Profile->get_sae()) {
562 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
564 items.push_front (SeparatorElem());
565 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
569 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
572 item_2->set_active ();
577 RouteTimeAxisView::set_track_mode (TrackMode mode)
579 if (_ignore_track_mode_change) {
584 RadioMenuItem* other_item;
585 RadioMenuItem* other_item_2;
589 item = normal_track_mode_item;
590 other_item = non_layered_track_mode_item;
591 other_item_2 = destructive_track_mode_item;
593 case ARDOUR::NonLayered:
594 item = non_layered_track_mode_item;
595 other_item = normal_track_mode_item;
596 other_item_2 = destructive_track_mode_item;
598 case ARDOUR::Destructive:
599 item = destructive_track_mode_item;
600 other_item = normal_track_mode_item;
601 other_item_2 = non_layered_track_mode_item;
604 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
609 if (item && other_item && other_item_2 && track()->mode() != mode) {
610 _set_track_mode (track().get(), mode, other_item, other_item_2);
615 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
619 if (!track->can_use_mode (mode, needs_bounce)) {
623 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
626 cerr << "would bounce this one\n";
627 /* XXX: radio menu item becomes inconsistent with track state in this case */
632 track->set_mode (mode);
634 rec_enable_button->remove ();
637 case ARDOUR::NonLayered:
639 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
641 case ARDOUR::Destructive:
642 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
646 rec_enable_button->show_all ();
650 RouteTimeAxisView::track_mode_changed ()
654 switch (track()->mode()) {
656 item = normal_track_mode_item;
658 case ARDOUR::NonLayered:
659 item = non_layered_track_mode_item;
661 case ARDOUR::Destructive:
662 item = destructive_track_mode_item;
665 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
674 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
680 TimeAxisView::show_timestretch (start, end);
690 /* check that the time selection was made in our route, or our route group.
691 remember that route_group() == 0 implies the route is *not* in a edit group.
694 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
695 /* this doesn't apply to us */
699 /* ignore it if our edit group is not active */
701 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
706 if (timestretch_rect == 0) {
707 timestretch_rect = new SimpleRect (*canvas_display ());
708 timestretch_rect->property_x1() = 0.0;
709 timestretch_rect->property_y1() = 0.0;
710 timestretch_rect->property_x2() = 0.0;
711 timestretch_rect->property_y2() = 0.0;
712 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
713 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
716 timestretch_rect->show ();
717 timestretch_rect->raise_to_top ();
719 x1 = start / _editor.get_current_zoom();
720 x2 = (end - 1) / _editor.get_current_zoom();
721 y2 = current_height() - 2;
723 timestretch_rect->property_x1() = x1;
724 timestretch_rect->property_y1() = 1.0;
725 timestretch_rect->property_x2() = x2;
726 timestretch_rect->property_y2() = y2;
730 RouteTimeAxisView::hide_timestretch ()
732 TimeAxisView::hide_timestretch ();
734 if (timestretch_rect) {
735 timestretch_rect->hide ();
740 RouteTimeAxisView::show_selection (TimeSelection& ts)
744 /* ignore it if our edit group is not active or if the selection was started
745 in some other track or route group (remember that route_group() == 0 means
746 that the track is not in an route group).
749 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
750 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
756 TimeAxisView::show_selection (ts);
760 RouteTimeAxisView::set_height (uint32_t h)
763 bool height_changed = (height == 0) || (h != height);
764 gm.get_level_meter().setup_meters (gmlen);
766 TimeAxisView::set_height (h);
771 _view->set_height ((double) current_height());
775 snprintf (buf, sizeof (buf), "%u", height);
776 xml_node->add_property ("height", buf);
778 if (height >= preset_height (HeightNormal)) {
783 gm.get_gain_slider().show();
785 if (!_route || _route->is_monitor()) {
790 if (rec_enable_button)
791 rec_enable_button->show();
793 route_group_button.show();
794 automation_button.show();
796 if (is_track() && track()->mode() == ARDOUR::Normal) {
797 playlist_button.show();
800 } else if (height >= preset_height (HeightSmaller)) {
806 gm.get_gain_slider().hide();
808 if (!_route || _route->is_monitor()) {
813 if (rec_enable_button)
814 rec_enable_button->show();
816 route_group_button.hide ();
817 automation_button.hide ();
819 if (is_track() && track()->mode() == ARDOUR::Normal) {
820 playlist_button.hide ();
826 /* don't allow name_entry to be hidden while
827 it has focus, otherwise the GUI becomes unusable.
830 if (name_entry.has_focus()) {
831 if (name_entry.get_text() != _route->name()) {
832 name_entry_changed ();
834 controls_ebox.grab_focus ();
840 gm.get_gain_slider().hide();
843 if (rec_enable_button)
844 rec_enable_button->hide();
846 route_group_button.hide ();
847 automation_button.hide ();
848 playlist_button.hide ();
849 name_label.set_text (_route->name());
852 if (height_changed && !no_redraw) {
853 /* only emit the signal if the height really changed */
854 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
859 RouteTimeAxisView::select_track_color ()
861 if (RouteUI::choose_color ()) {
864 _view->apply_color (_color, StreamView::RegionColor);
870 RouteTimeAxisView::reset_samples_per_unit ()
872 set_samples_per_unit (_editor.get_current_zoom());
876 RouteTimeAxisView::horizontal_position_changed ()
879 _view->horizontal_position_changed ();
884 RouteTimeAxisView::set_samples_per_unit (double spu)
889 speed = track()->speed();
893 _view->set_samples_per_unit (spu * speed);
896 TimeAxisView::set_samples_per_unit (spu * speed);
900 RouteTimeAxisView::align_style_changed ()
902 switch (track()->alignment_style()) {
903 case ExistingMaterial:
904 if (!align_existing_item->get_active()) {
905 align_existing_item->set_active();
909 if (!align_capture_item->get_active()) {
910 align_capture_item->set_active();
917 RouteTimeAxisView::set_align_style (AlignStyle style)
922 case ExistingMaterial:
923 item = align_existing_item;
926 item = align_capture_item;
929 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
934 if (item->get_active()) {
935 track()->set_align_style (style);
940 RouteTimeAxisView::rename_current_playlist ()
942 ArdourPrompter prompter (true);
945 boost::shared_ptr<Track> tr = track();
946 if (!tr || tr->destructive()) {
950 boost::shared_ptr<Playlist> pl = tr->playlist();
955 prompter.set_title (_("Rename Playlist"));
956 prompter.set_prompt (_("New name for playlist:"));
957 prompter.set_initial_text (pl->name());
958 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
959 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
961 switch (prompter.run ()) {
962 case Gtk::RESPONSE_ACCEPT:
963 prompter.get_result (name);
975 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
977 std::string ret (basename);
979 std::string const group_string = "." + route_group()->name() + ".";
981 // iterate through all playlists
983 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
984 std::string tmp = (*i)->name();
986 std::string::size_type idx = tmp.find(group_string);
987 // find those which belong to this group
988 if (idx != string::npos) {
989 tmp = tmp.substr(idx + group_string.length());
991 // and find the largest current number
992 int x = atoi(tmp.c_str());
1002 snprintf (buf, sizeof(buf), "%d", maxnumber);
1004 ret = this->name() + "." + route_group()->name () + "." + buf;
1010 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1014 boost::shared_ptr<Track> tr = track ();
1015 if (!tr || tr->destructive()) {
1019 boost::shared_ptr<const Playlist> pl = tr->playlist();
1026 if (route_group() && route_group()->is_active()) {
1027 name = resolve_new_group_playlist_name(name, playlists_before_op);
1030 while (_session->playlists->by_name(name)) {
1031 name = Playlist::bump_name (name, *_session);
1034 // TODO: The prompter "new" button should be de-activated if the user
1035 // specifies a playlist name which already exists in the session.
1039 ArdourPrompter prompter (true);
1041 prompter.set_title (_("New Copy Playlist"));
1042 prompter.set_prompt (_("Name for new playlist:"));
1043 prompter.set_initial_text (name);
1044 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1045 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1046 prompter.show_all ();
1048 switch (prompter.run ()) {
1049 case Gtk::RESPONSE_ACCEPT:
1050 prompter.get_result (name);
1058 if (name.length()) {
1059 tr->use_copy_playlist ();
1060 tr->playlist()->set_name (name);
1065 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1069 boost::shared_ptr<Track> tr = track ();
1070 if (!tr || tr->destructive()) {
1074 boost::shared_ptr<const Playlist> pl = tr->playlist();
1081 if (route_group() && route_group()->is_active()) {
1082 name = resolve_new_group_playlist_name(name,playlists_before_op);
1085 while (_session->playlists->by_name(name)) {
1086 name = Playlist::bump_name (name, *_session);
1092 ArdourPrompter prompter (true);
1094 prompter.set_title (_("New Playlist"));
1095 prompter.set_prompt (_("Name for new playlist:"));
1096 prompter.set_initial_text (name);
1097 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1098 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1100 switch (prompter.run ()) {
1101 case Gtk::RESPONSE_ACCEPT:
1102 prompter.get_result (name);
1110 if (name.length()) {
1111 tr->use_new_playlist ();
1112 tr->playlist()->set_name (name);
1117 RouteTimeAxisView::clear_playlist ()
1119 boost::shared_ptr<Track> tr = track ();
1120 if (!tr || tr->destructive()) {
1124 boost::shared_ptr<Playlist> pl = tr->playlist();
1129 _editor.clear_playlist (pl);
1133 RouteTimeAxisView::speed_changed ()
1135 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1139 RouteTimeAxisView::update_diskstream_display ()
1149 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1151 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1153 /* special case: select/deselect all tracks */
1154 if (_editor.get_selection().selected (this)) {
1155 _editor.get_selection().clear_tracks ();
1157 _editor.select_all_tracks ();
1163 switch (ArdourKeyboard::selection_type (ev->state)) {
1164 case Selection::Toggle:
1165 _editor.get_selection().toggle (this);
1168 case Selection::Set:
1169 _editor.get_selection().set (this);
1172 case Selection::Extend:
1173 _editor.extend_selection_to_track (*this);
1176 case Selection::Add:
1177 _editor.get_selection().add (this);
1183 RouteTimeAxisView::set_selected_points (PointSelection& points)
1185 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1186 (*i)->set_selected_points (points);
1191 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1194 _view->set_selected_regionviews (regions);
1198 /** Add the selectable things that we have to a list.
1199 * @param results List to add things to.
1202 RouteTimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list<Selectable*>& results)
1207 speed = track()->speed();
1210 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1211 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1213 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1214 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1217 /* pick up visible automation tracks */
1219 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1220 if (!(*i)->hidden()) {
1221 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1227 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1230 _view->get_inverted_selectables (sel, results);
1233 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1234 if (!(*i)->hidden()) {
1235 (*i)->get_inverted_selectables (sel, results);
1243 RouteTimeAxisView::route_group () const
1245 return _route->route_group();
1249 RouteTimeAxisView::name() const
1251 return _route->name();
1254 boost::shared_ptr<Playlist>
1255 RouteTimeAxisView::playlist () const
1257 boost::shared_ptr<Track> tr;
1259 if ((tr = track()) != 0) {
1260 return tr->playlist();
1262 return boost::shared_ptr<Playlist> ();
1267 RouteTimeAxisView::name_entry_changed ()
1271 x = name_entry.get_text ();
1273 if (x == _route->name()) {
1277 strip_whitespace_edges(x);
1279 if (x.length() == 0) {
1280 name_entry.set_text (_route->name());
1284 if (!_session->route_name_unique (x)) {
1285 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1286 name_entry.set_text (_route->name());
1287 } else if (_session->route_name_internal (x)) {
1288 ARDOUR_UI::instance()->popup_error (string_compose (_("You cannot create a track with that name as it is reserved for %1"),
1290 name_entry.set_text (_route->name());
1292 _route->set_name (x);
1296 boost::shared_ptr<Region>
1297 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1299 boost::shared_ptr<Playlist> pl = playlist ();
1302 return pl->find_next_region (pos, point, dir);
1305 return boost::shared_ptr<Region> ();
1309 RouteTimeAxisView::find_next_region_boundary (framepos_t pos, int32_t dir)
1311 boost::shared_ptr<Playlist> pl = playlist ();
1314 return pl->find_next_region_boundary (pos, dir);
1321 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1323 boost::shared_ptr<Playlist> what_we_got;
1324 boost::shared_ptr<Track> tr = track ();
1325 boost::shared_ptr<Playlist> playlist;
1328 /* route is a bus, not a track */
1332 playlist = tr->playlist();
1334 TimeSelection time (selection.time);
1335 float const speed = tr->speed();
1336 if (speed != 1.0f) {
1337 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1338 (*i).start = session_frame_to_track_frame((*i).start, speed);
1339 (*i).end = session_frame_to_track_frame((*i).end, speed);
1343 playlist->clear_changes ();
1344 playlist->clear_owned_changes ();
1348 if ((what_we_got = playlist->cut (time)) != 0) {
1349 _editor.get_cut_buffer().add (what_we_got);
1351 vector<Command*> cmds;
1352 playlist->rdiff (cmds);
1353 _session->add_commands (cmds);
1355 _session->add_command (new StatefulDiffCommand (playlist));
1359 if ((what_we_got = playlist->copy (time)) != 0) {
1360 _editor.get_cut_buffer().add (what_we_got);
1365 if ((what_we_got = playlist->cut (time)) != 0) {
1367 vector<Command*> cmds;
1368 playlist->rdiff (cmds);
1369 _session->add_commands (cmds);
1370 _session->add_command (new StatefulDiffCommand (playlist));
1371 what_we_got->release ();
1378 RouteTimeAxisView::paste (framepos_t pos, float times, Selection& selection, size_t nth)
1384 boost::shared_ptr<Playlist> pl = playlist ();
1385 PlaylistSelection::iterator p;
1387 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1389 if (p == selection.playlists.end()) {
1393 if (track()->speed() != 1.0f) {
1394 pos = session_frame_to_track_frame (pos, track()->speed());
1397 pl->clear_changes ();
1398 pl->paste (*p, pos, times);
1399 _session->add_command (new StatefulDiffCommand (pl));
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 ()
1414 using namespace Menu_Helpers;
1420 delete playlist_action_menu;
1421 playlist_action_menu = new Menu;
1422 playlist_action_menu->set_name ("ArdourContextMenu");
1424 MenuList& playlist_items = playlist_action_menu->items();
1425 playlist_action_menu->set_name ("ArdourContextMenu");
1426 playlist_items.clear();
1428 delete playlist_menu;
1430 vector<boost::shared_ptr<Playlist> > playlists, playlists_tr;
1431 boost::shared_ptr<Track> tr = track();
1432 RadioMenuItem::Group playlist_group;
1434 _session->playlists->get (playlists);
1436 /* find the playlists for this diskstream */
1437 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1438 if (((*i)->get_orig_diskstream_id() == tr->diskstream_id()) || (tr->playlist()->id() == (*i)->id())) {
1439 playlists_tr.push_back(*i);
1443 /* sort the playlists */
1445 sort (playlists_tr.begin(), playlists_tr.end(), cmp);
1447 /* add the playlists to the menu */
1448 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_tr.begin(); i != playlists_tr.end(); ++i) {
1449 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name()));
1450 RadioMenuItem *item = static_cast<RadioMenuItem*>(&playlist_items.back());
1451 item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr<Playlist> (*i)));
1453 if (tr->playlist()->id() == (*i)->id()) {
1459 playlist_items.push_back (SeparatorElem());
1460 playlist_items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1461 playlist_items.push_back (SeparatorElem());
1463 if (!route_group() || !route_group()->is_active()) {
1464 playlist_items.push_back (MenuElem (_("New..."), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1465 playlist_items.push_back (MenuElem (_("New Copy..."), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1468 // Use a label which tells the user what is happening
1469 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1470 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1474 playlist_items.push_back (SeparatorElem());
1475 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1476 playlist_items.push_back (SeparatorElem());
1478 playlist_items.push_back (MenuElem(_("Select from all..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1482 RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr<Playlist> wpl)
1484 assert (is_track());
1486 // exit if we were triggered by deactivating the old playlist
1487 if (!item->get_active()) {
1491 boost::shared_ptr<Playlist> pl (wpl.lock());
1497 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1500 if (track()->playlist() == apl) {
1501 // exit when use_playlist is called by the creation of the playlist menu
1502 // or the playlist choice is unchanged
1505 track()->use_playlist (apl);
1507 if (route_group() && route_group()->is_active()) {
1508 std::string group_string = "."+route_group()->name()+".";
1510 std::string take_name = apl->name();
1511 std::string::size_type idx = take_name.find(group_string);
1513 if (idx == std::string::npos)
1516 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1518 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1520 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1521 if ( (*i) == this->route()) {
1525 std::string playlist_name = (*i)->name()+group_string+take_name;
1527 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1529 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1533 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1535 // No playlist for this track for this take yet, make it
1536 track->use_new_playlist();
1537 track->playlist()->set_name(playlist_name);
1539 track->use_playlist(ipl);
1547 RouteTimeAxisView::show_playlist_selector ()
1549 _editor.playlist_selector().show_for (this);
1553 RouteTimeAxisView::map_frozen ()
1559 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1561 switch (track()->freeze_state()) {
1563 playlist_button.set_sensitive (false);
1564 rec_enable_button->set_sensitive (false);
1567 playlist_button.set_sensitive (true);
1568 rec_enable_button->set_sensitive (true);
1574 RouteTimeAxisView::color_handler ()
1576 //case cTimeStretchOutline:
1577 if (timestretch_rect) {
1578 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1580 //case cTimeStretchFill:
1581 if (timestretch_rect) {
1582 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1588 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1589 * Will add track if necessary.
1592 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1594 boost::shared_ptr<AutomationTimeAxisView> track = automation_child (param);
1595 Gtk::CheckMenuItem* menu = automation_child_menu_item (param);
1598 /* it doesn't exist yet, so we don't care about the button state: just add it */
1599 create_automation_child (param, true);
1602 bool yn = menu->get_active();
1603 if (track->set_visibility (menu->get_active()) && yn) {
1605 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1606 will have done that for us.
1610 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1617 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1619 boost::shared_ptr<AutomationTimeAxisView> track = automation_child (param);
1625 Gtk::CheckMenuItem* menu = automation_child_menu_item (param);
1627 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1628 track->get_state_node()->add_property (X_("shown"), X_("no"));
1630 if (menu && !_hidden) {
1631 ignore_toggle = true;
1632 menu->set_active (false);
1633 ignore_toggle = false;
1636 if (_route && !no_redraw) {
1637 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1643 RouteTimeAxisView::show_all_automation ()
1647 /* Show our automation */
1649 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1650 i->second->set_marked_for_display (true);
1651 i->second->canvas_display()->show();
1652 i->second->get_state_node()->add_property ("shown", X_("yes"));
1654 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1657 menu->set_active(true);
1662 /* Show processor automation */
1664 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1665 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1666 if ((*ii)->view == 0) {
1667 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1670 (*ii)->menu_item->set_active (true);
1678 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1682 RouteTimeAxisView::show_existing_automation ()
1686 /* Show our automation */
1688 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1689 if (i->second->has_automation()) {
1690 i->second->set_marked_for_display (true);
1691 i->second->canvas_display()->show();
1692 i->second->get_state_node()->add_property ("shown", X_("yes"));
1694 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1696 menu->set_active(true);
1702 /* Show processor automation */
1704 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1705 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1706 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1707 (*ii)->menu_item->set_active (true);
1714 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1718 RouteTimeAxisView::hide_all_automation ()
1722 /* Hide our automation */
1724 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1725 i->second->set_marked_for_display (false);
1727 i->second->get_state_node()->add_property ("shown", X_("no"));
1729 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1732 menu->set_active (false);
1736 /* Hide processor automation */
1738 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1739 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1740 (*ii)->menu_item->set_active (false);
1745 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1750 RouteTimeAxisView::region_view_added (RegionView* rv)
1752 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1753 if (is_audio_track()) {
1754 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1755 boost::shared_ptr<AutomationTimeAxisView> atv;
1757 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1763 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1764 (*i)->add_ghost(rv);
1768 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1770 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1776 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1778 parent.remove_processor_automation_node (this);
1782 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1785 remove_child (pan->view);
1789 RouteTimeAxisView::ProcessorAutomationNode*
1790 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1792 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1794 if ((*i)->processor == processor) {
1796 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1797 if ((*ii)->what == what) {
1808 legalize_for_xml_node (string str)
1810 string::size_type pos;
1811 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1817 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1818 legal.replace (pos, 1, "_");
1827 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1830 ProcessorAutomationNode* pan;
1832 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1833 /* session state may never have been saved with new plugin */
1834 error << _("programming error: ")
1835 << string_compose (X_("processor automation curve for %1:%2/%3/%4 not registered with track!"),
1836 processor->name(), what.type(), (int) what.channel(), what.id() )
1846 name = processor->describe_parameter (what);
1848 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1852 char state_name[256];
1853 snprintf (state_name, sizeof (state_name), "%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1855 boost::shared_ptr<AutomationControl> control
1856 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1858 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1859 new AutomationTimeAxisView (_session, _route, processor, control,
1860 _editor, *this, false, parent_canvas, name, state_name));
1862 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1864 if (!pan->view->marked_for_display()) {
1867 pan->menu_item->set_active (true);
1870 add_child (pan->view);
1873 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1876 processor->mark_automation_visible (what, true);
1880 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1883 pan->menu_item->set_active (false);
1886 i->mark_automation_visible (pan->what, false);
1889 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1894 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1896 boost::shared_ptr<Processor> processor (p.lock ());
1901 set<Evoral::Parameter> s;
1902 boost::shared_ptr<AutomationLine> al;
1904 processor->what_has_visible_data (s);
1906 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1908 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1911 add_processor_automation_curve (processor, (*i));
1917 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1919 using namespace Menu_Helpers;
1926 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1928 bool hideit = (!show);
1930 if ((node = track->get_state_node()) != 0) {
1931 if ((prop = node->property ("shown")) != 0) {
1932 if (string_is_affirmative (prop->value())) {
1938 _automation_tracks[param] = track;
1940 track->set_visibility (!hideit);
1943 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1946 if (!EventTypeMap::instance().is_midi_parameter(param)) {
1947 /* MIDI-related parameters are always in the menu, there's no
1948 reason to rebuild the menu just because we added a automation
1949 lane for one of them. But if we add a non-MIDI automation
1950 lane, then we need to invalidate the display menu.
1952 delete display_menu;
1958 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1960 boost::shared_ptr<Processor> processor (p.lock ());
1962 if (!processor || !processor->display_to_user ()) {
1966 using namespace Menu_Helpers;
1967 ProcessorAutomationInfo *rai;
1968 list<ProcessorAutomationInfo*>::iterator x;
1970 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
1971 std::set<Evoral::Parameter> has_visible_automation;
1973 processor->what_has_visible_data(has_visible_automation);
1975 if (automatable.empty()) {
1979 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
1980 if ((*x)->processor == processor) {
1985 if (x == processor_automation.end()) {
1987 rai = new ProcessorAutomationInfo (processor);
1988 processor_automation.push_back (rai);
1996 /* any older menu was deleted at the top of processors_changed()
1997 when we cleared the subplugin menu.
2000 rai->menu = manage (new Menu);
2001 MenuList& items = rai->menu->items();
2002 rai->menu->set_name ("ArdourContextMenu");
2006 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2008 ProcessorAutomationNode* pan;
2009 CheckMenuItem* mitem;
2011 string name = processor->describe_parameter (*i);
2013 items.push_back (CheckMenuElem (name));
2014 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2016 _subplugin_menu_map[*i] = mitem;
2018 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2019 mitem->set_active(true);
2022 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2026 pan = new ProcessorAutomationNode (*i, mitem, *this);
2028 rai->lines.push_back (pan);
2032 pan->menu_item = mitem;
2036 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2039 /* add the menu for this processor, because the subplugin
2040 menu is always cleared at the top of processors_changed().
2041 this is the result of some poor design in gtkmm and/or
2045 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2050 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2051 RouteTimeAxisView::ProcessorAutomationNode* pan)
2053 bool showit = pan->menu_item->get_active();
2054 bool redraw = false;
2056 if (pan->view == 0 && showit) {
2057 add_processor_automation_curve (rai->processor, pan->what);
2061 if (pan->view && showit != pan->view->marked_for_display()) {
2064 pan->view->set_marked_for_display (true);
2065 pan->view->canvas_display()->show();
2066 pan->view->canvas_background()->show();
2068 rai->processor->mark_automation_visible (pan->what, true);
2069 pan->view->set_marked_for_display (false);
2077 if (redraw && !no_redraw) {
2078 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2084 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2086 if (c.type == RouteProcessorChange::MeterPointChange) {
2087 /* nothing to do if only the meter point has changed */
2091 using namespace Menu_Helpers;
2093 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2094 (*i)->valid = false;
2097 _subplugin_menu_map.clear ();
2098 subplugin_menu.items().clear ();
2100 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2101 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2103 bool deleted_processor_automation = false;
2105 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2107 list<ProcessorAutomationInfo*>::iterator tmp;
2115 processor_automation.erase (i);
2116 deleted_processor_automation = true;
2123 if (deleted_processor_automation && !no_redraw) {
2124 _route->gui_changed ("track_height", this);
2128 boost::shared_ptr<AutomationLine>
2129 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2131 ProcessorAutomationNode* pan;
2133 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2139 return boost::shared_ptr<AutomationLine>();
2143 RouteTimeAxisView::reset_processor_automation_curves ()
2145 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2151 RouteTimeAxisView::update_rec_display ()
2153 RouteUI::update_rec_display ();
2154 name_entry.set_sensitive (!_route->record_enabled());
2158 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2161 _view->set_layer_display (d);
2165 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2169 RouteTimeAxisView::layer_display () const
2172 return _view->layer_display ();
2175 /* we don't know, since we don't have a _view, so just return something */
2181 boost::shared_ptr<AutomationTimeAxisView>
2182 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2184 AutomationTracks::iterator i = _automation_tracks.find(param);
2185 if (i != _automation_tracks.end()) {
2188 return boost::shared_ptr<AutomationTimeAxisView>();
2193 RouteTimeAxisView::fast_update ()
2195 gm.get_level_meter().update_meters ();
2199 RouteTimeAxisView::hide_meter ()
2202 gm.get_level_meter().hide_meters ();
2206 RouteTimeAxisView::show_meter ()
2212 RouteTimeAxisView::reset_meter ()
2214 if (Config->get_show_track_meters()) {
2215 gm.get_level_meter().setup_meters (height-5);
2222 RouteTimeAxisView::clear_meter ()
2224 gm.get_level_meter().clear_meters ();
2228 RouteTimeAxisView::meter_changed ()
2230 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed)
2235 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2241 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2243 using namespace Menu_Helpers;
2245 if (!_underlay_streams.empty()) {
2246 MenuList& parent_items = parent_menu->items();
2247 Menu* gs_menu = manage (new Menu);
2248 gs_menu->set_name ("ArdourContextMenu");
2249 MenuList& gs_items = gs_menu->items();
2251 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2253 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2254 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2255 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2261 RouteTimeAxisView::set_underlay_state()
2263 if (!underlay_xml_node) {
2267 XMLNodeList nlist = underlay_xml_node->children();
2268 XMLNodeConstIterator niter;
2269 XMLNode *child_node;
2271 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2272 child_node = *niter;
2274 if (child_node->name() != "Underlay") {
2278 XMLProperty* prop = child_node->property ("id");
2280 PBD::ID id (prop->value());
2282 RouteTimeAxisView* v = _editor.get_route_view_by_route_id (id);
2285 add_underlay(v->view(), false);
2294 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2300 RouteTimeAxisView& other = v->trackview();
2302 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2303 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2304 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2308 _underlay_streams.push_back(v);
2309 other._underlay_mirrors.push_back(this);
2311 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2314 if (!underlay_xml_node) {
2316 underlay_xml_node = xml_node->add_child("Underlays");
2319 XMLNode* node = underlay_xml_node->add_child("Underlay");
2320 XMLProperty* prop = node->add_property("id");
2321 prop->set_value(v->trackview().route()->id().to_s());
2327 RouteTimeAxisView::remove_underlay (StreamView* v)
2333 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2334 RouteTimeAxisView& other = v->trackview();
2336 if (it != _underlay_streams.end()) {
2337 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2339 if (gm == other._underlay_mirrors.end()) {
2340 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2344 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2346 _underlay_streams.erase(it);
2347 other._underlay_mirrors.erase(gm);
2349 if (underlay_xml_node) {
2350 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2356 RouteTimeAxisView::set_button_names ()
2358 rec_enable_button_label.set_text (_("r"));
2360 if (_route && _route->solo_safe()) {
2361 solo_button_label.set_text (X_("!"));
2363 if (Config->get_solo_control_is_listen_control()) {
2364 switch (Config->get_listen_position()) {
2365 case AfterFaderListen:
2366 solo_button_label.set_text (_("A"));
2368 case PreFaderListen:
2369 solo_button_label.set_text (_("P"));
2373 solo_button_label.set_text (_("s"));
2376 mute_button_label.set_text (_("m"));
2380 RouteTimeAxisView::automation_child_menu_item (Evoral::Parameter param)
2382 ParameterMenuMap::iterator i = _main_automation_menu_map.find (param);
2383 if (i != _main_automation_menu_map.end()) {
2387 i = _subplugin_menu_map.find (param);
2388 if (i != _subplugin_menu_map.end()) {
2396 RouteTimeAxisView::create_gain_automation_child (const Evoral::Parameter& param, bool show)
2398 boost::shared_ptr<AutomationControl> c = _route->gain_control();
2400 error << "Route has no gain automation, unable to add automation track view." << endmsg;
2404 gain_track.reset (new AutomationTimeAxisView (_session,
2405 _route, _route->amp(), c,
2410 _route->amp()->describe_parameter(param)));
2412 add_automation_child (Evoral::Parameter(GainAutomation), gain_track, show);