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 , automation_button (_("a"))
114 , gm (sess, slider, true, 115)
115 , _ignore_track_mode_change (false)
117 gm.set_controls (_route, _route->shared_peak_meter(), _route->amp());
118 gm.get_level_meter().set_no_show_all();
119 gm.get_level_meter().setup_meters(50);
123 playlist_action_menu = 0;
124 automation_action_menu = 0;
125 plugins_submenu_item = 0;
129 if (!_route->is_hidden()) {
130 _marked_for_display = true;
134 update_solo_display ();
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");
148 route_group_button.unset_flags (Gtk::CAN_FOCUS);
149 playlist_button.unset_flags (Gtk::CAN_FOCUS);
150 automation_button.unset_flags (Gtk::CAN_FOCUS);
152 route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::edit_click), false);
153 playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
154 automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
160 rec_enable_button->remove ();
162 switch (track()->mode()) {
164 case ARDOUR::NonLayered:
165 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
167 case ARDOUR::Destructive:
168 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
171 rec_enable_button->show_all ();
173 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
174 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record"));
176 rec_enable_button->set_sensitive (_session->writable());
179 controls_hbox.pack_start(gm.get_level_meter(), false, false);
180 _route->meter_change.connect (*this, invalidator (*this), bind (&RouteTimeAxisView::meter_changed, this), gui_context());
181 _route->input()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
182 _route->output()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
184 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
186 if (!_route->is_master()) {
187 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
190 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
191 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
193 ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
194 ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
195 ARDOUR_UI::instance()->set_tip(route_group_button, _("Route Group"));
196 ARDOUR_UI::instance()->set_tip(playlist_button,_("Playlist"));
197 ARDOUR_UI::instance()->set_tip(automation_button, _("Automation"));
201 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
203 if (is_track() && track()->mode() == ARDOUR::Normal) {
204 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
209 _route->processors_changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
210 _route->PropertyChanged.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::route_property_changed, this, _1), gui_context());
214 track()->TrackModeChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
215 track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
216 track()->SpeedChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
218 /* pick up the correct freeze state */
223 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
224 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
226 PropertyList* plist = new PropertyList();
228 plist->add (ARDOUR::Properties::edit, true);
229 plist->add (ARDOUR::Properties::mute, true);
230 plist->add (ARDOUR::Properties::solo, true);
232 route_group_menu = new RouteGroupMenu (_session, plist);
233 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
235 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
236 gm.get_gain_slider().set_name ("TrackGainFader");
239 RouteTimeAxisView::~RouteTimeAxisView ()
241 CatchDeletion (this);
243 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
247 delete playlist_menu;
250 delete playlist_action_menu;
251 playlist_action_menu = 0;
256 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
260 _automation_tracks.clear ();
262 delete route_group_menu;
266 RouteTimeAxisView::post_construct ()
268 /* map current state of the route */
270 update_diskstream_display ();
272 subplugin_menu.items().clear ();
273 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
274 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
275 reset_processor_automation_curves ();
279 RouteTimeAxisView::edit_click (GdkEventButton *ev)
281 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
282 if (_route->route_group()) {
283 _route->route_group()->remove (_route);
288 route_group_menu->rebuild (_route->route_group ());
289 route_group_menu->popup (ev->button, ev->time);
295 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
300 if (_route->route_group()) {
301 _route->route_group()->remove (_route);
307 RouteTimeAxisView::playlist_changed ()
313 RouteTimeAxisView::label_view ()
315 string x = _route->name();
317 if (x != name_entry.get_text()) {
318 name_entry.set_text (x);
321 ARDOUR_UI::instance()->set_tip (name_entry, x);
325 RouteTimeAxisView::route_property_changed (const PropertyChange& what_changed)
327 if (what_changed.contains (ARDOUR::Properties::name)) {
333 RouteTimeAxisView::take_name_changed (void *src)
342 RouteTimeAxisView::playlist_click ()
344 // always build a new action menu
346 delete playlist_action_menu;
348 playlist_action_menu = new Menu;
349 playlist_action_menu->set_name ("ArdourContextMenu");
351 build_playlist_menu (playlist_action_menu);
353 conditionally_add_to_selection ();
354 playlist_action_menu->popup (1, gtk_get_current_event_time());
358 RouteTimeAxisView::automation_click ()
360 conditionally_add_to_selection ();
361 build_automation_action_menu ();
362 automation_action_menu->popup (1, gtk_get_current_event_time());
366 RouteTimeAxisView::set_state (const XMLNode& node, int version)
368 TimeAxisView::set_state (node, version);
370 XMLNodeList kids = node.children();
371 XMLNodeConstIterator iter;
372 const XMLProperty* prop;
374 if (_view && (prop = node.property ("layer-display"))) {
375 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
378 for (iter = kids.begin(); iter != kids.end(); ++iter) {
379 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
380 if ((prop = (*iter)->property ("automation-id")) != 0) {
382 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
383 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
384 create_automation_child(param, show);
386 warning << "Automation child has no ID" << endmsg;
395 RouteTimeAxisView::build_automation_action_menu ()
397 using namespace Menu_Helpers;
399 delete automation_action_menu;
400 automation_action_menu = new Menu;
402 MenuList& items = automation_action_menu->items();
404 automation_action_menu->set_name ("ArdourContextMenu");
406 items.push_back (MenuElem (_("Show All Automation"),
407 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
409 items.push_back (MenuElem (_("Show Existing Automation"),
410 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
412 items.push_back (MenuElem (_("Hide All Automation"),
413 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
415 /* attach the plugin submenu. It may have previously been used elsewhere, so we detach it first. */
417 detach_menu (subplugin_menu);
418 items.push_back (MenuElem (_("Plugins"), subplugin_menu));
419 items.back().set_sensitive (!subplugin_menu.items().empty());
423 RouteTimeAxisView::build_display_menu ()
425 using namespace Menu_Helpers;
429 TimeAxisView::build_display_menu ();
431 /* now fill it with our stuff */
433 MenuList& items = display_menu->items();
434 display_menu->set_name ("ArdourContextMenu");
436 items.push_back (MenuElem (_("Color"), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
438 items.push_back (SeparatorElem());
440 if (!Profile->get_sae()) {
441 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
442 /* rebuild this every time */
443 build_automation_action_menu ();
444 detach_menu (*automation_action_menu);
445 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
446 items.push_back (SeparatorElem());
449 // Hook for derived classes to add type specific stuff
450 append_extra_display_menu_items ();
451 items.push_back (SeparatorElem());
455 Menu *layers_menu = manage(new Menu);
456 MenuList &layers_items = layers_menu->items();
457 layers_menu->set_name("ArdourContextMenu");
459 RadioMenuItem::Group layers_group;
461 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
462 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
463 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
464 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
466 items.push_back (MenuElem (_("Layers"), *layers_menu));
468 Menu* alignment_menu = manage (new Menu);
469 MenuList& alignment_items = alignment_menu->items();
470 alignment_menu->set_name ("ArdourContextMenu");
472 RadioMenuItem::Group align_group;
474 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material"),
475 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
476 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
477 if (track()->alignment_style() == ExistingMaterial) {
478 align_existing_item->set_active();
481 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time"),
482 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
483 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
484 if (track()->alignment_style() == CaptureTime) {
485 align_capture_item->set_active();
488 if (!Profile->get_sae()) {
490 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
491 track()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
493 RadioMenuItem::Group mode_group;
494 items.push_back (RadioMenuElem (mode_group, _("Normal Mode"), sigc::bind (
495 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
497 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
499 items.push_back (RadioMenuElem (mode_group, _("Tape Mode"), sigc::bind (
500 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
501 ARDOUR::Destructive)));
502 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
504 items.push_back (RadioMenuElem (mode_group, _("Non-Layered Mode"),
505 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
506 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
509 _ignore_track_mode_change = true;
511 switch (track()->mode()) {
512 case ARDOUR::Destructive:
513 destructive_track_mode_item->set_active ();
516 normal_track_mode_item->set_active ();
518 case ARDOUR::NonLayered:
519 non_layered_track_mode_item->set_active ();
523 _ignore_track_mode_change = false;
526 track()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
528 color_mode_menu = build_color_mode_menu();
529 if (color_mode_menu) {
530 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
533 items.push_back (SeparatorElem());
536 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
537 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
538 route_active_menu_item->set_active (_route->active());
540 items.push_back (SeparatorElem());
541 items.push_back (MenuElem (_("Hide"), sigc::bind (sigc::mem_fun(_editor, &PublicEditor::hide_track_in_display), this, false)));
542 if (!Profile->get_sae()) {
543 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
545 items.push_front (SeparatorElem());
546 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
550 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
553 item_2->set_active ();
558 RouteTimeAxisView::set_track_mode (TrackMode mode)
560 if (_ignore_track_mode_change) {
565 RadioMenuItem* other_item;
566 RadioMenuItem* other_item_2;
570 item = normal_track_mode_item;
571 other_item = non_layered_track_mode_item;
572 other_item_2 = destructive_track_mode_item;
574 case ARDOUR::NonLayered:
575 item = non_layered_track_mode_item;
576 other_item = normal_track_mode_item;
577 other_item_2 = destructive_track_mode_item;
579 case ARDOUR::Destructive:
580 item = destructive_track_mode_item;
581 other_item = normal_track_mode_item;
582 other_item_2 = non_layered_track_mode_item;
585 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
590 if (item && other_item && other_item_2 && track()->mode() != mode) {
591 _set_track_mode (track().get(), mode, other_item, other_item_2);
596 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
600 if (!track->can_use_mode (mode, needs_bounce)) {
604 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
607 cerr << "would bounce this one\n";
608 /* XXX: radio menu item becomes inconsistent with track state in this case */
613 track->set_mode (mode);
615 rec_enable_button->remove ();
618 case ARDOUR::NonLayered:
620 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
622 case ARDOUR::Destructive:
623 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
627 rec_enable_button->show_all ();
631 RouteTimeAxisView::track_mode_changed ()
635 switch (track()->mode()) {
637 item = normal_track_mode_item;
639 case ARDOUR::NonLayered:
640 item = non_layered_track_mode_item;
642 case ARDOUR::Destructive:
643 item = destructive_track_mode_item;
646 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
655 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
661 TimeAxisView::show_timestretch (start, end);
671 /* check that the time selection was made in our route, or our route group.
672 remember that route_group() == 0 implies the route is *not* in a edit group.
675 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
676 /* this doesn't apply to us */
680 /* ignore it if our edit group is not active */
682 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
687 if (timestretch_rect == 0) {
688 timestretch_rect = new SimpleRect (*canvas_display ());
689 timestretch_rect->property_x1() = 0.0;
690 timestretch_rect->property_y1() = 0.0;
691 timestretch_rect->property_x2() = 0.0;
692 timestretch_rect->property_y2() = 0.0;
693 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
694 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
697 timestretch_rect->show ();
698 timestretch_rect->raise_to_top ();
700 x1 = start / _editor.get_current_zoom();
701 x2 = (end - 1) / _editor.get_current_zoom();
702 y2 = current_height() - 2;
704 timestretch_rect->property_x1() = x1;
705 timestretch_rect->property_y1() = 1.0;
706 timestretch_rect->property_x2() = x2;
707 timestretch_rect->property_y2() = y2;
711 RouteTimeAxisView::hide_timestretch ()
713 TimeAxisView::hide_timestretch ();
715 if (timestretch_rect) {
716 timestretch_rect->hide ();
721 RouteTimeAxisView::show_selection (TimeSelection& ts)
725 /* ignore it if our edit group is not active or if the selection was started
726 in some other track or route group (remember that route_group() == 0 means
727 that the track is not in an route group).
730 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
731 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
737 TimeAxisView::show_selection (ts);
741 RouteTimeAxisView::set_height (uint32_t h)
744 bool height_changed = (height == 0) || (h != height);
745 gm.get_level_meter().setup_meters (gmlen);
747 TimeAxisView::set_height (h);
752 _view->set_height ((double) current_height());
756 snprintf (buf, sizeof (buf), "%u", height);
757 xml_node->add_property ("height", buf);
759 if (height >= preset_height (HeightNormal)) {
764 gm.get_gain_slider().show();
766 if (!_route || _route->is_monitor()) {
771 if (rec_enable_button)
772 rec_enable_button->show();
774 route_group_button.show();
775 automation_button.show();
777 if (is_track() && track()->mode() == ARDOUR::Normal) {
778 playlist_button.show();
781 } else if (height >= preset_height (HeightSmaller)) {
787 gm.get_gain_slider().hide();
789 if (!_route || _route->is_monitor()) {
794 if (rec_enable_button)
795 rec_enable_button->show();
797 route_group_button.hide ();
798 automation_button.hide ();
800 if (is_track() && track()->mode() == ARDOUR::Normal) {
801 playlist_button.hide ();
807 /* don't allow name_entry to be hidden while
808 it has focus, otherwise the GUI becomes unusable.
811 if (name_entry.has_focus()) {
812 if (name_entry.get_text() != _route->name()) {
813 name_entry_changed ();
815 controls_ebox.grab_focus ();
821 gm.get_gain_slider().hide();
824 if (rec_enable_button)
825 rec_enable_button->hide();
827 route_group_button.hide ();
828 automation_button.hide ();
829 playlist_button.hide ();
830 name_label.set_text (_route->name());
833 if (height_changed && !no_redraw) {
834 /* only emit the signal if the height really changed */
835 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
840 RouteTimeAxisView::select_track_color ()
842 if (RouteUI::choose_color ()) {
845 _view->apply_color (_color, StreamView::RegionColor);
851 RouteTimeAxisView::reset_samples_per_unit ()
853 set_samples_per_unit (_editor.get_current_zoom());
857 RouteTimeAxisView::set_samples_per_unit (double spu)
862 speed = track()->speed();
866 _view->set_samples_per_unit (spu * speed);
869 TimeAxisView::set_samples_per_unit (spu * speed);
873 RouteTimeAxisView::align_style_changed ()
875 switch (track()->alignment_style()) {
876 case ExistingMaterial:
877 if (!align_existing_item->get_active()) {
878 align_existing_item->set_active();
882 if (!align_capture_item->get_active()) {
883 align_capture_item->set_active();
890 RouteTimeAxisView::set_align_style (AlignStyle style)
895 case ExistingMaterial:
896 item = align_existing_item;
899 item = align_capture_item;
902 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
907 if (item->get_active()) {
908 track()->set_align_style (style);
913 RouteTimeAxisView::rename_current_playlist ()
915 ArdourPrompter prompter (true);
918 boost::shared_ptr<Track> tr = track();
919 if (!tr || tr->destructive()) {
923 boost::shared_ptr<Playlist> pl = tr->playlist();
928 prompter.set_title (_("Rename Playlist"));
929 prompter.set_prompt (_("New name for playlist:"));
930 prompter.set_initial_text (pl->name());
931 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
932 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
934 switch (prompter.run ()) {
935 case Gtk::RESPONSE_ACCEPT:
936 prompter.get_result (name);
948 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
950 std::string ret (basename);
952 std::string const group_string = "." + route_group()->name() + ".";
954 // iterate through all playlists
956 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
957 std::string tmp = (*i)->name();
959 std::string::size_type idx = tmp.find(group_string);
960 // find those which belong to this group
961 if (idx != string::npos) {
962 tmp = tmp.substr(idx + group_string.length());
964 // and find the largest current number
965 int x = atoi(tmp.c_str());
975 snprintf (buf, sizeof(buf), "%d", maxnumber);
977 ret = this->name() + "." + route_group()->name () + "." + buf;
983 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
987 boost::shared_ptr<Track> tr = track ();
988 if (!tr || tr->destructive()) {
992 boost::shared_ptr<const Playlist> pl = tr->playlist();
999 if (route_group() && route_group()->is_active()) {
1000 name = resolve_new_group_playlist_name(name, playlists_before_op);
1003 while (_session->playlists->by_name(name)) {
1004 name = Playlist::bump_name (name, *_session);
1007 // TODO: The prompter "new" button should be de-activated if the user
1008 // specifies a playlist name which already exists in the session.
1012 ArdourPrompter prompter (true);
1014 prompter.set_title (_("New Copy Playlist"));
1015 prompter.set_prompt (_("Name for new playlist:"));
1016 prompter.set_initial_text (name);
1017 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1018 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1019 prompter.show_all ();
1021 switch (prompter.run ()) {
1022 case Gtk::RESPONSE_ACCEPT:
1023 prompter.get_result (name);
1031 if (name.length()) {
1032 tr->use_copy_playlist ();
1033 tr->playlist()->set_name (name);
1038 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1042 boost::shared_ptr<Track> tr = track ();
1043 if (!tr || tr->destructive()) {
1047 boost::shared_ptr<const Playlist> pl = tr->playlist();
1054 if (route_group() && route_group()->is_active()) {
1055 name = resolve_new_group_playlist_name(name,playlists_before_op);
1058 while (_session->playlists->by_name(name)) {
1059 name = Playlist::bump_name (name, *_session);
1065 ArdourPrompter prompter (true);
1067 prompter.set_title (_("New Playlist"));
1068 prompter.set_prompt (_("Name for new playlist:"));
1069 prompter.set_initial_text (name);
1070 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1071 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1073 switch (prompter.run ()) {
1074 case Gtk::RESPONSE_ACCEPT:
1075 prompter.get_result (name);
1083 if (name.length()) {
1084 tr->use_new_playlist ();
1085 tr->playlist()->set_name (name);
1090 RouteTimeAxisView::clear_playlist ()
1092 boost::shared_ptr<Track> tr = track ();
1093 if (!tr || tr->destructive()) {
1097 boost::shared_ptr<Playlist> pl = tr->playlist();
1102 _editor.clear_playlist (pl);
1106 RouteTimeAxisView::speed_changed ()
1108 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1112 RouteTimeAxisView::update_diskstream_display ()
1122 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1124 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1126 /* special case: select/deselect all tracks */
1127 if (_editor.get_selection().selected (this)) {
1128 _editor.get_selection().clear_tracks ();
1130 _editor.select_all_tracks ();
1136 switch (ArdourKeyboard::selection_type (ev->state)) {
1137 case Selection::Toggle:
1138 _editor.get_selection().toggle (this);
1141 case Selection::Set:
1142 _editor.get_selection().set (this);
1145 case Selection::Extend:
1146 _editor.extend_selection_to_track (*this);
1149 case Selection::Add:
1150 _editor.get_selection().add (this);
1156 RouteTimeAxisView::set_selected_points (PointSelection& points)
1158 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1159 (*i)->set_selected_points (points);
1164 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1167 _view->set_selected_regionviews (regions);
1171 /** Add the selectable things that we have to a list.
1172 * @param results List to add things to.
1175 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1180 speed = track()->speed();
1183 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1184 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1186 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1187 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1190 /* pick up visible automation tracks */
1192 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1193 if (!(*i)->hidden()) {
1194 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1200 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1203 _view->get_inverted_selectables (sel, results);
1206 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1207 if (!(*i)->hidden()) {
1208 (*i)->get_inverted_selectables (sel, results);
1216 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1218 return (_show_automation.find(param) != _show_automation.end());
1221 /** Retuns 0 if track for \a param doesn't exist.
1223 RouteTimeAxisView::RouteAutomationNode*
1224 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1226 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1228 if (i != _automation_tracks.end()) {
1235 /** Shorthand for GainAutomation, etc.
1237 RouteTimeAxisView::RouteAutomationNode*
1238 RouteTimeAxisView::automation_track (AutomationType type)
1240 return automation_track (Evoral::Parameter(type));
1244 RouteTimeAxisView::route_group () const
1246 return _route->route_group();
1250 RouteTimeAxisView::name() const
1252 return _route->name();
1255 boost::shared_ptr<Playlist>
1256 RouteTimeAxisView::playlist () const
1258 boost::shared_ptr<Track> tr;
1260 if ((tr = track()) != 0) {
1261 return tr->playlist();
1263 return boost::shared_ptr<Playlist> ();
1268 RouteTimeAxisView::name_entry_changed ()
1272 x = name_entry.get_text ();
1274 if (x == _route->name()) {
1278 strip_whitespace_edges(x);
1280 if (x.length() == 0) {
1281 name_entry.set_text (_route->name());
1285 if (!_session->route_name_unique (x)) {
1286 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1287 name_entry.set_text (_route->name());
1288 } else if (_session->route_name_internal (x)) {
1289 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
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 (nframes64_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;
1329 /* route is a bus, not a track */
1333 playlist = tr->playlist();
1335 TimeSelection time (selection.time);
1336 float const speed = tr->speed();
1337 if (speed != 1.0f) {
1338 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1339 (*i).start = session_frame_to_track_frame((*i).start, speed);
1340 (*i).end = session_frame_to_track_frame((*i).end, speed);
1344 playlist->clear_history ();
1345 playlist->clear_owned_history ();
1349 if ((what_we_got = playlist->cut (time)) != 0) {
1350 _editor.get_cut_buffer().add (what_we_got);
1352 vector<StatefulDiffCommand*> cmds;
1354 playlist->rdiff (cmds);
1356 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1357 _session->add_command (*c);
1359 _session->add_command (new StatefulDiffCommand (playlist));
1364 if ((what_we_got = playlist->copy (time)) != 0) {
1365 _editor.get_cut_buffer().add (what_we_got);
1370 if ((what_we_got = playlist->cut (time)) != 0) {
1371 vector<StatefulDiffCommand*> cmds;
1373 playlist->rdiff (cmds);
1375 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1376 _session->add_command (*c);
1378 _session->add_command (new StatefulDiffCommand (playlist));
1379 what_we_got->release ();
1389 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1395 boost::shared_ptr<Playlist> pl = playlist ();
1396 PlaylistSelection::iterator p;
1398 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1400 if (p == selection.playlists.end()) {
1404 if (track()->speed() != 1.0f) {
1405 pos = session_frame_to_track_frame (pos, track()->speed());
1408 pl->clear_history ();
1409 pl->paste (*p, pos, times);
1410 _session->add_command (new StatefulDiffCommand (pl));
1416 TimeAxisView::Children
1417 RouteTimeAxisView::get_child_list()
1419 TimeAxisView::Children redirect_children;
1421 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1422 if (!(*i)->hidden()) {
1423 redirect_children.push_back(*i);
1426 return redirect_children;
1430 struct PlaylistSorter {
1431 bool operator() (boost::shared_ptr<Playlist> a, boost::shared_ptr<Playlist> b) const {
1432 return a->sort_id() < b->sort_id();
1437 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1439 using namespace Menu_Helpers;
1441 if (!menu || !is_track()) {
1445 MenuList& playlist_items = menu->items();
1446 menu->set_name ("ArdourContextMenu");
1447 playlist_items.clear();
1449 delete playlist_menu;
1452 vector<boost::shared_ptr<Playlist> > playlists, playlists_tr;
1453 boost::shared_ptr<Track> tr = track();
1454 RadioMenuItem::Group playlist_group;
1456 _session->playlists->get (playlists);
1458 /* find the playlists for this diskstream */
1459 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1460 if (((*i)->get_orig_diskstream_id() == tr->diskstream_id()) || (tr->playlist()->id() == (*i)->id())) {
1461 playlists_tr.push_back(*i);
1465 /* sort the playlists */
1467 sort (playlists_tr.begin(), playlists_tr.end(), cmp);
1469 /* add the playlists to the menu */
1470 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_tr.begin(); i != playlists_tr.end(); ++i) {
1471 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name()));
1472 RadioMenuItem *item = static_cast<RadioMenuItem*>(&playlist_items.back());
1473 item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr<Playlist> (*i)));
1475 if (tr->playlist()->id() == (*i)->id()) {
1481 playlist_items.push_back (SeparatorElem());
1482 playlist_items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1483 playlist_items.push_back (SeparatorElem());
1485 if (!route_group() || !route_group()->is_active()) {
1486 playlist_items.push_back (MenuElem (_("New..."), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1487 playlist_items.push_back (MenuElem (_("New Copy..."), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1490 // Use a label which tells the user what is happening
1491 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1492 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1496 playlist_items.push_back (SeparatorElem());
1497 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1498 playlist_items.push_back (SeparatorElem());
1500 playlist_items.push_back (MenuElem(_("Select from all..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1504 RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr<Playlist> wpl)
1506 assert (is_track());
1508 // exit if we were triggered by deactivating the old playlist
1509 if (!item->get_active()) {
1513 boost::shared_ptr<Playlist> pl (wpl.lock());
1519 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1522 if (track()->playlist() == apl) {
1523 // exit when use_playlist is called by the creation of the playlist menu
1524 // or the playlist choice is unchanged
1527 track()->use_playlist (apl);
1529 if (route_group() && route_group()->is_active()) {
1530 std::string group_string = "."+route_group()->name()+".";
1532 std::string take_name = apl->name();
1533 std::string::size_type idx = take_name.find(group_string);
1535 if (idx == std::string::npos)
1538 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1540 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1542 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1543 if ( (*i) == this->route()) {
1547 std::string playlist_name = (*i)->name()+group_string+take_name;
1549 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1551 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1555 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1557 // No playlist for this track for this take yet, make it
1558 track->use_new_playlist();
1559 track->playlist()->set_name(playlist_name);
1561 track->use_playlist(ipl);
1569 RouteTimeAxisView::show_playlist_selector ()
1571 _editor.playlist_selector().show_for (this);
1575 RouteTimeAxisView::map_frozen ()
1581 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1583 switch (track()->freeze_state()) {
1585 playlist_button.set_sensitive (false);
1586 rec_enable_button->set_sensitive (false);
1589 playlist_button.set_sensitive (true);
1590 rec_enable_button->set_sensitive (true);
1596 RouteTimeAxisView::color_handler ()
1598 //case cTimeStretchOutline:
1599 if (timestretch_rect) {
1600 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1602 //case cTimeStretchFill:
1603 if (timestretch_rect) {
1604 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1610 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1611 * Will add track if necessary.
1614 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1616 RouteAutomationNode* node = automation_track(param);
1619 /* it doesn't exist yet, so we don't care about the button state: just add it */
1620 create_automation_child (param, true);
1622 bool yn = node->menu_item->get_active();
1623 if (node->track->set_visibility (node->menu_item->get_active()) && yn) {
1625 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1626 will have done that for us.
1630 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1637 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1639 RouteAutomationNode* ran = automation_track(param);
1645 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1646 _show_automation.erase (param);
1647 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1649 if (ran->menu_item && !_hidden) {
1650 ignore_toggle = true;
1651 ran->menu_item->set_active (false);
1652 ignore_toggle = false;
1655 if (_route && !no_redraw) {
1656 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1662 RouteTimeAxisView::show_all_automation ()
1666 /* Show our automation */
1668 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1669 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1670 i->second->track->set_marked_for_display (true);
1671 i->second->track->canvas_display()->show();
1672 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1673 if (i->second->menu_item) {
1674 i->second->menu_item->set_active(true);
1679 /* Show processor automation */
1681 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1682 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1683 if ((*ii)->view == 0) {
1684 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1687 (*ii)->menu_item->set_active (true);
1695 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1699 RouteTimeAxisView::show_existing_automation ()
1703 /* Show our automation */
1705 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1706 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1707 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1708 i->second->track->set_marked_for_display (true);
1709 i->second->track->canvas_display()->show();
1710 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1711 i->second->menu_item->set_active(true);
1716 /* Show processor automation */
1718 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1719 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1720 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1721 (*ii)->menu_item->set_active (true);
1728 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1732 RouteTimeAxisView::hide_all_automation ()
1736 /* Hide our automation */
1738 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1739 i->second->track->set_marked_for_display (false);
1740 i->second->track->hide ();
1741 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1742 if (i->second->menu_item) {
1743 i->second->menu_item->set_active (false);
1747 /* Hide processor automation */
1749 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1750 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1751 (*ii)->menu_item->set_active (false);
1755 _show_automation.clear();
1758 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1763 RouteTimeAxisView::region_view_added (RegionView* rv)
1765 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1766 if (is_audio_track()) {
1767 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1768 boost::shared_ptr<AutomationTimeAxisView> atv;
1770 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1776 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1777 (*i)->add_ghost(rv);
1781 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1783 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1789 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1791 parent.remove_processor_automation_node (this);
1795 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1798 remove_child (pan->view);
1802 RouteTimeAxisView::ProcessorAutomationNode*
1803 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1805 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1807 if ((*i)->processor == processor) {
1809 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1810 if ((*ii)->what == what) {
1821 legalize_for_xml_node (string str)
1823 string::size_type pos;
1824 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1830 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1831 legal.replace (pos, 1, "_");
1840 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1843 ProcessorAutomationNode* pan;
1845 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1846 error << _("programming error: ")
1847 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1848 processor->name(), what)
1858 name = processor->describe_parameter (what);
1860 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1864 char state_name[256];
1865 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1867 boost::shared_ptr<AutomationControl> control
1868 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1870 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1871 new AutomationTimeAxisView (_session, _route, processor, control,
1872 _editor, *this, false, parent_canvas, name, state_name));
1874 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1876 if (!pan->view->marked_for_display()) {
1879 pan->menu_item->set_active (true);
1882 add_child (pan->view);
1885 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1888 processor->mark_automation_visible (what, true);
1892 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1895 pan->menu_item->set_active (false);
1898 i->mark_automation_visible (pan->what, false);
1901 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1906 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1908 boost::shared_ptr<Processor> processor (p.lock ());
1913 set<Evoral::Parameter> s;
1914 boost::shared_ptr<AutomationLine> al;
1916 processor->what_has_visible_data (s);
1918 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1920 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1923 add_processor_automation_curve (processor, (*i));
1929 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1931 using namespace Menu_Helpers;
1938 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1940 bool hideit = (!show);
1942 if ((node = track->get_state_node()) != 0) {
1943 if ((prop = node->property ("shown")) != 0) {
1944 if (string_is_affirmative (prop->value())) {
1950 _automation_tracks.insert (std::make_pair (param, new RouteAutomationNode(param, NULL, track)));
1952 track->set_visibility (!hideit);
1955 _show_automation.insert (param);
1959 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1962 if (!EventTypeMap::instance().is_midi_parameter(param)) {
1963 /* MIDI-related parameters are always in the menu, there's no
1964 reason to rebuild the menu just because we added a automation
1965 lane for one of them. But if we add a non-MIDI automation
1966 lane, then we need to invalidate the display menu.
1968 delete display_menu;
1974 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1976 boost::shared_ptr<Processor> processor (p.lock ());
1978 if (!processor || !processor->display_to_user ()) {
1982 using namespace Menu_Helpers;
1983 ProcessorAutomationInfo *rai;
1984 list<ProcessorAutomationInfo*>::iterator x;
1986 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
1987 std::set<Evoral::Parameter> has_visible_automation;
1989 processor->what_has_visible_data(has_visible_automation);
1991 if (automatable.empty()) {
1995 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
1996 if ((*x)->processor == processor) {
2001 if (x == processor_automation.end()) {
2003 rai = new ProcessorAutomationInfo (processor);
2004 processor_automation.push_back (rai);
2012 /* any older menu was deleted at the top of processors_changed()
2013 when we cleared the subplugin menu.
2016 rai->menu = manage (new Menu);
2017 MenuList& items = rai->menu->items();
2018 rai->menu->set_name ("ArdourContextMenu");
2022 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2024 ProcessorAutomationNode* pan;
2025 CheckMenuItem* mitem;
2027 string name = processor->describe_parameter (*i);
2029 items.push_back (CheckMenuElem (name));
2030 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2032 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2033 mitem->set_active(true);
2036 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2040 pan = new ProcessorAutomationNode (*i, mitem, *this);
2042 rai->lines.push_back (pan);
2046 pan->menu_item = mitem;
2050 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2053 /* add the menu for this processor, because the subplugin
2054 menu is always cleared at the top of processors_changed().
2055 this is the result of some poor design in gtkmm and/or
2059 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2064 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2065 RouteTimeAxisView::ProcessorAutomationNode* pan)
2067 bool showit = pan->menu_item->get_active();
2068 bool redraw = false;
2070 if (pan->view == 0 && showit) {
2071 add_processor_automation_curve (rai->processor, pan->what);
2075 if (pan->view && showit != pan->view->marked_for_display()) {
2078 pan->view->set_marked_for_display (true);
2079 pan->view->canvas_display()->show();
2080 pan->view->canvas_background()->show();
2082 rai->processor->mark_automation_visible (pan->what, true);
2083 pan->view->set_marked_for_display (false);
2091 if (redraw && !no_redraw) {
2092 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2098 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2100 if (c.type == RouteProcessorChange::MeterPointChange) {
2101 /* nothing to do if only the meter point has changed */
2105 using namespace Menu_Helpers;
2107 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2108 (*i)->valid = false;
2111 subplugin_menu.items().clear ();
2113 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2114 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2116 bool deleted_processor_automation = false;
2118 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2120 list<ProcessorAutomationInfo*>::iterator tmp;
2128 processor_automation.erase (i);
2129 deleted_processor_automation = true;
2136 if (deleted_processor_automation && !no_redraw) {
2137 _route->gui_changed ("track_height", this);
2141 boost::shared_ptr<AutomationLine>
2142 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2144 ProcessorAutomationNode* pan;
2146 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2152 return boost::shared_ptr<AutomationLine>();
2156 RouteTimeAxisView::reset_processor_automation_curves ()
2158 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2164 RouteTimeAxisView::update_rec_display ()
2166 RouteUI::update_rec_display ();
2167 name_entry.set_sensitive (!_route->record_enabled());
2171 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2174 _view->set_layer_display (d);
2178 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2182 RouteTimeAxisView::layer_display () const
2185 return _view->layer_display ();
2188 /* we don't know, since we don't have a _view, so just return something */
2194 boost::shared_ptr<AutomationTimeAxisView>
2195 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2197 AutomationTracks::iterator i = _automation_tracks.find(param);
2198 if (i != _automation_tracks.end()) {
2199 return i->second->track;
2201 return boost::shared_ptr<AutomationTimeAxisView>();
2206 RouteTimeAxisView::fast_update ()
2208 gm.get_level_meter().update_meters ();
2212 RouteTimeAxisView::hide_meter ()
2215 gm.get_level_meter().hide_meters ();
2219 RouteTimeAxisView::show_meter ()
2225 RouteTimeAxisView::reset_meter ()
2227 if (Config->get_show_track_meters()) {
2228 gm.get_level_meter().setup_meters (height-5);
2235 RouteTimeAxisView::clear_meter ()
2237 gm.get_level_meter().clear_meters ();
2241 RouteTimeAxisView::meter_changed ()
2243 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed)
2248 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2254 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2256 using namespace Menu_Helpers;
2258 if (!_underlay_streams.empty()) {
2259 MenuList& parent_items = parent_menu->items();
2260 Menu* gs_menu = manage (new Menu);
2261 gs_menu->set_name ("ArdourContextMenu");
2262 MenuList& gs_items = gs_menu->items();
2264 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2266 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2267 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2268 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2274 RouteTimeAxisView::set_underlay_state()
2276 if (!underlay_xml_node) {
2280 XMLNodeList nlist = underlay_xml_node->children();
2281 XMLNodeConstIterator niter;
2282 XMLNode *child_node;
2284 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2285 child_node = *niter;
2287 if (child_node->name() != "Underlay") {
2291 XMLProperty* prop = child_node->property ("id");
2293 PBD::ID id (prop->value());
2295 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2298 add_underlay(v->view(), false);
2307 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2313 RouteTimeAxisView& other = v->trackview();
2315 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2316 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2317 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2321 _underlay_streams.push_back(v);
2322 other._underlay_mirrors.push_back(this);
2324 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2327 if (!underlay_xml_node) {
2329 underlay_xml_node = xml_node->add_child("Underlays");
2332 XMLNode* node = underlay_xml_node->add_child("Underlay");
2333 XMLProperty* prop = node->add_property("id");
2334 prop->set_value(v->trackview().route()->id().to_s());
2340 RouteTimeAxisView::remove_underlay (StreamView* v)
2346 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2347 RouteTimeAxisView& other = v->trackview();
2349 if (it != _underlay_streams.end()) {
2350 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2352 if (gm == other._underlay_mirrors.end()) {
2353 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2357 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2359 _underlay_streams.erase(it);
2360 other._underlay_mirrors.erase(gm);
2362 if (underlay_xml_node) {
2363 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2369 RouteTimeAxisView::set_button_names ()
2371 rec_enable_button_label.set_text (_("r"));
2373 if (_route && _route->solo_safe()) {
2374 solo_button_label.set_text (X_("!"));
2376 if (Config->get_solo_control_is_listen_control()) {
2377 switch (Config->get_listen_position()) {
2378 case AfterFaderListen:
2379 solo_button_label.set_text (_("A"));
2381 case PreFaderListen:
2382 solo_button_label.set_text (_("P"));
2386 solo_button_label.set_text (_("s"));
2389 mute_button_label.set_text (_("m"));