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/stacktrace.h"
38 #include <gtkmm/menu.h>
39 #include <gtkmm/menuitem.h>
40 #include <gtkmm2ext/gtk_ui.h>
41 #include <gtkmm2ext/selector.h>
42 #include <gtkmm2ext/stop_signal.h>
43 #include <gtkmm2ext/bindable_button.h>
44 #include <gtkmm2ext/utils.h>
46 #include "ardour/amp.h"
47 #include "ardour/audioplaylist.h"
48 #include "ardour/diskstream.h"
49 #include "ardour/event_type_map.h"
50 #include "ardour/ladspa_plugin.h"
51 #include "ardour/location.h"
52 #include "ardour/panner.h"
53 #include "ardour/playlist.h"
54 #include "ardour/playlist.h"
55 #include "ardour/processor.h"
56 #include "ardour/profile.h"
57 #include "ardour/route_group.h"
58 #include "ardour/session.h"
59 #include "ardour/session_playlist.h"
60 #include "ardour/debug.h"
61 #include "ardour/utils.h"
62 #include "evoral/Parameter.hpp"
64 #include "ardour_ui.h"
65 #include "route_time_axis.h"
66 #include "automation_time_axis.h"
67 #include "canvas_impl.h"
68 #include "crossfade_view.h"
70 #include "gui_thread.h"
72 #include "playlist_selector.h"
73 #include "point_selection.h"
75 #include "public_editor.h"
76 #include "region_view.h"
77 #include "rgb_macros.h"
78 #include "selection.h"
79 #include "simplerect.h"
80 #include "streamview.h"
82 #include "route_group_menu.h"
84 #include "ardour/track.h"
88 using namespace ARDOUR;
90 using namespace Gtkmm2ext;
92 using namespace Editing;
95 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
98 RouteTimeAxisView::setup_slider_pix ()
100 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
101 throw failed_constructor ();
105 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, boost::shared_ptr<Route> rt, Canvas& canvas)
108 , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
109 , parent_canvas (canvas)
110 , button_table (3, 3)
111 , route_group_button (_("g"))
112 , playlist_button (_("p"))
113 , size_button (_("h"))
114 , automation_button (_("a"))
115 , visual_button (_("v"))
116 , gm (sess, slider, true, 115)
120 gm.set_controls (_route, _route->shared_peak_meter(), _route->amp());
121 gm.get_level_meter().set_no_show_all();
122 gm.get_level_meter().setup_meters(50);
126 playlist_action_menu = 0;
127 automation_action_menu = 0;
128 plugins_submenu_item = 0;
132 if (!_route->is_hidden()) {
133 _marked_for_display = true;
136 timestretch_rect = 0;
138 destructive_track_mode_item = 0;
139 normal_track_mode_item = 0;
140 non_layered_track_mode_item = 0;
142 ignore_toggle = false;
144 route_group_button.set_name ("TrackGroupButton");
145 playlist_button.set_name ("TrackPlaylistButton");
146 automation_button.set_name ("TrackAutomationButton");
147 size_button.set_name ("TrackSizeButton");
148 visual_button.set_name ("TrackVisualButton");
149 hide_button.set_name ("TrackRemoveButton");
151 route_group_button.unset_flags (Gtk::CAN_FOCUS);
152 playlist_button.unset_flags (Gtk::CAN_FOCUS);
153 automation_button.unset_flags (Gtk::CAN_FOCUS);
154 size_button.unset_flags (Gtk::CAN_FOCUS);
155 visual_button.unset_flags (Gtk::CAN_FOCUS);
156 hide_button.unset_flags (Gtk::CAN_FOCUS);
158 hide_button.add (*(manage (new Image (::get_icon("hide")))));
159 hide_button.show_all ();
161 route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::edit_click), false);
162 playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
163 automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
164 size_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::size_click), false);
165 visual_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::visual_click));
166 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::hide_click));
172 rec_enable_button->remove ();
174 switch (track()->mode()) {
176 case ARDOUR::NonLayered:
177 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
179 case ARDOUR::Destructive:
180 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
183 rec_enable_button->show_all ();
185 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
186 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
188 rec_enable_button->set_sensitive (_session->writable());
191 controls_hbox.pack_start(gm.get_level_meter(), false, false);
192 _route->meter_change.connect (*this, ui_bind (&RouteTimeAxisView::meter_changed, this, _1), gui_context());
193 _route->input()->changed.connect (*this, ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
194 _route->output()->changed.connect (*this, ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
196 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
197 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
199 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
200 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
202 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
203 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
204 ARDOUR_UI::instance()->tooltips().set_tip(route_group_button, _("Route Group"));
205 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
206 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
207 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
208 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
209 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
215 /* old school - when we used to put an extra row of buttons in place */
217 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
218 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
219 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
220 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
224 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
227 if (is_track() && track()->mode() == ARDOUR::Normal) {
228 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
233 _route->processors_changed.connect (*this, ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
234 _route->NameChanged.connect (*this, boost::bind (&RouteTimeAxisView::route_name_changed, this), gui_context());
238 track()->TrackModeChanged.connect (*this, boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
239 track()->FreezeChange.connect (*this, boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
240 track()->DiskstreamChanged.connect (*this, boost::bind (&RouteTimeAxisView::diskstream_changed, this), gui_context());
241 get_diskstream()->SpeedChanged.connect (*this, boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
243 /* pick up the correct freeze state */
248 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
249 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
251 route_group_menu = new RouteGroupMenu (
253 (RouteGroup::Property) (RouteGroup::Mute | RouteGroup::Solo | RouteGroup::Edit)
256 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
258 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
259 gm.get_gain_slider().set_name ("TrackGainFader");
262 RouteTimeAxisView::~RouteTimeAxisView ()
264 CatchDeletion (this);
266 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
270 delete playlist_menu;
273 delete playlist_action_menu;
274 playlist_action_menu = 0;
279 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
283 _automation_tracks.clear ();
285 delete route_group_menu;
289 RouteTimeAxisView::post_construct ()
291 /* map current state of the route */
293 update_diskstream_display ();
295 subplugin_menu.items().clear ();
296 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
297 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
298 reset_processor_automation_curves ();
302 RouteTimeAxisView::edit_click (GdkEventButton *ev)
304 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
305 if (_route->route_group()) {
306 _route->route_group()->remove (_route);
311 route_group_menu->rebuild (_route->route_group ());
312 route_group_menu->popup (ev->button, ev->time);
318 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
323 if (_route->route_group()) {
324 _route->route_group()->remove (_route);
330 RouteTimeAxisView::playlist_changed ()
336 RouteTimeAxisView::label_view ()
338 string x = _route->name();
340 if (x != name_entry.get_text()) {
341 name_entry.set_text (x);
344 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
348 RouteTimeAxisView::route_name_changed ()
354 RouteTimeAxisView::take_name_changed (void *src)
363 RouteTimeAxisView::playlist_click ()
365 // always build a new action menu
367 delete playlist_action_menu;
369 playlist_action_menu = new Menu;
370 playlist_action_menu->set_name ("ArdourContextMenu");
372 build_playlist_menu (playlist_action_menu);
374 conditionally_add_to_selection ();
375 playlist_action_menu->popup (1, gtk_get_current_event_time());
379 RouteTimeAxisView::automation_click ()
381 conditionally_add_to_selection ();
382 build_automation_action_menu ();
383 automation_action_menu->popup (1, gtk_get_current_event_time());
387 RouteTimeAxisView::set_state (const XMLNode& node, int version)
389 TimeAxisView::set_state (node, version);
391 XMLNodeList kids = node.children();
392 XMLNodeConstIterator iter;
393 const XMLProperty* prop;
395 if (_view && (prop = node.property ("layer-display"))) {
396 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
399 for (iter = kids.begin(); iter != kids.end(); ++iter) {
400 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
401 if ((prop = (*iter)->property ("automation-id")) != 0) {
403 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
404 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
405 create_automation_child(param, show);
407 warning << "Automation child has no ID" << endmsg;
416 RouteTimeAxisView::build_automation_action_menu ()
418 using namespace Menu_Helpers;
420 delete automation_action_menu;
421 automation_action_menu = new Menu;
423 MenuList& items = automation_action_menu->items();
425 automation_action_menu->set_name ("ArdourContextMenu");
427 items.push_back (MenuElem (_("Show all automation"),
428 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
430 items.push_back (MenuElem (_("Show existing automation"),
431 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
433 items.push_back (MenuElem (_("Hide all automation"),
434 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
436 /* attach the plugin submenu. It may have previously been used elsewhere, so we detach it first. */
438 detach_menu (subplugin_menu);
439 items.push_back (MenuElem (_("Plugins"), subplugin_menu));
440 items.back().set_sensitive (!subplugin_menu.items().empty());
444 RouteTimeAxisView::build_display_menu ()
446 using namespace Menu_Helpers;
448 /* get the size menu ready */
454 TimeAxisView::build_display_menu ();
456 /* now fill it with our stuff */
458 MenuList& items = display_menu->items();
459 display_menu->set_name ("ArdourContextMenu");
461 items.push_back (MenuElem (_("Height"), *size_menu));
462 items.push_back (MenuElem (_("Color"), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
464 items.push_back (SeparatorElem());
466 if (!Profile->get_sae()) {
467 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
468 /* rebuild this every time */
469 build_automation_action_menu ();
470 detach_menu (*automation_action_menu);
471 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
472 items.push_back (SeparatorElem());
475 // Hook for derived classes to add type specific stuff
476 append_extra_display_menu_items ();
477 items.push_back (SeparatorElem());
481 Menu *layers_menu = manage(new Menu);
482 MenuList &layers_items = layers_menu->items();
483 layers_menu->set_name("ArdourContextMenu");
485 RadioMenuItem::Group layers_group;
487 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
488 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
489 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
490 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
492 items.push_back (MenuElem (_("Layers"), *layers_menu));
494 Menu* alignment_menu = manage (new Menu);
495 MenuList& alignment_items = alignment_menu->items();
496 alignment_menu->set_name ("ArdourContextMenu");
498 RadioMenuItem::Group align_group;
500 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
501 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
502 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
503 if (get_diskstream()->alignment_style() == ExistingMaterial)
504 align_existing_item->set_active();
506 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
507 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
508 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
509 if (get_diskstream()->alignment_style() == CaptureTime)
510 align_capture_item->set_active();
512 if (!Profile->get_sae()) {
513 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
514 get_diskstream()->AlignmentStyleChanged.connect (route_connections, boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
516 RadioMenuItem::Group mode_group;
517 items.push_back (RadioMenuElem (mode_group, _("Normal mode"), sigc::bind (
518 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
520 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
522 items.push_back (RadioMenuElem (mode_group, _("Tape mode"), sigc::bind (
523 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
524 ARDOUR::Destructive)));
525 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
527 items.push_back (RadioMenuElem (mode_group, _("No layering mode"),
528 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
529 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
533 switch (track()->mode()) {
534 case ARDOUR::Destructive:
535 destructive_track_mode_item->set_active ();
538 normal_track_mode_item->set_active ();
540 case ARDOUR::NonLayered:
541 non_layered_track_mode_item->set_active ();
546 get_diskstream()->AlignmentStyleChanged.connect (route_connections, boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
548 mode_menu = build_mode_menu();
550 items.push_back (MenuElem (_("Mode"), *mode_menu));
552 color_mode_menu = build_color_mode_menu();
554 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
556 items.push_back (SeparatorElem());
559 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
560 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
561 route_active_menu_item->set_active (_route->active());
563 items.push_back (SeparatorElem());
564 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &RouteTimeAxisView::hide_click)));
565 if (!Profile->get_sae()) {
566 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
568 items.push_front (SeparatorElem());
569 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
573 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
576 item_2->set_active ();
581 RouteTimeAxisView::set_track_mode (TrackMode mode)
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 && item->get_active() && 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";
631 track->set_mode (mode);
633 rec_enable_button->remove ();
636 case ARDOUR::NonLayered:
638 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
640 case ARDOUR::Destructive:
641 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
645 rec_enable_button->show_all ();
649 RouteTimeAxisView::track_mode_changed ()
653 switch (track()->mode()) {
655 item = normal_track_mode_item;
657 case ARDOUR::NonLayered:
658 item = non_layered_track_mode_item;
660 case ARDOUR::Destructive:
661 item = destructive_track_mode_item;
664 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
673 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
679 TimeAxisView::show_timestretch (start, end);
689 /* check that the time selection was made in our route, or our route group.
690 remember that route_group() == 0 implies the route is *not* in a edit group.
693 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
694 /* this doesn't apply to us */
698 /* ignore it if our edit group is not active */
700 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
705 if (timestretch_rect == 0) {
706 timestretch_rect = new SimpleRect (*canvas_display ());
707 timestretch_rect->property_x1() = 0.0;
708 timestretch_rect->property_y1() = 0.0;
709 timestretch_rect->property_x2() = 0.0;
710 timestretch_rect->property_y2() = 0.0;
711 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
712 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
715 timestretch_rect->show ();
716 timestretch_rect->raise_to_top ();
718 x1 = start / _editor.get_current_zoom();
719 x2 = (end - 1) / _editor.get_current_zoom();
720 y2 = current_height() - 2;
722 timestretch_rect->property_x1() = x1;
723 timestretch_rect->property_y1() = 1.0;
724 timestretch_rect->property_x2() = x2;
725 timestretch_rect->property_y2() = y2;
729 RouteTimeAxisView::hide_timestretch ()
731 TimeAxisView::hide_timestretch ();
733 if (timestretch_rect) {
734 timestretch_rect->hide ();
739 RouteTimeAxisView::show_selection (TimeSelection& ts)
743 /* ignore it if our edit group is not active or if the selection was started
744 in some other track or route group (remember that route_group() == 0 means
745 that the track is not in an route group).
748 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
749 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
755 TimeAxisView::show_selection (ts);
759 RouteTimeAxisView::set_height (uint32_t h)
762 bool height_changed = (height == 0) || (h != height);
763 gm.get_level_meter().setup_meters (gmlen);
765 TimeAxisView::set_height (h);
770 _view->set_height ((double) current_height());
774 snprintf (buf, sizeof (buf), "%u", height);
775 xml_node->add_property ("height", buf);
777 if (height >= hNormal) {
782 gm.get_gain_slider().show();
784 if (!_route || _route->is_control()) {
789 if (rec_enable_button)
790 rec_enable_button->show();
792 route_group_button.show();
794 visual_button.show();
796 automation_button.show();
798 if (is_track() && track()->mode() == ARDOUR::Normal) {
799 playlist_button.show();
802 } else if (height >= hSmaller) {
808 gm.get_gain_slider().hide();
810 if (!_route || _route->is_control()) {
815 if (rec_enable_button)
816 rec_enable_button->show();
818 route_group_button.hide ();
820 visual_button.hide ();
822 automation_button.hide ();
824 if (is_track() && track()->mode() == ARDOUR::Normal) {
825 playlist_button.hide ();
831 /* don't allow name_entry to be hidden while
832 it has focus, otherwise the GUI becomes unusable.
835 if (name_entry.has_focus()) {
836 if (name_entry.get_text() != _route->name()) {
837 name_entry_changed ();
839 controls_ebox.grab_focus ();
845 gm.get_gain_slider().hide();
848 if (rec_enable_button)
849 rec_enable_button->hide();
851 route_group_button.hide ();
853 visual_button.hide ();
855 automation_button.hide ();
856 playlist_button.hide ();
857 name_label.set_text (_route->name());
860 if (height_changed && !no_redraw) {
861 /* only emit the signal if the height really changed */
862 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
867 RouteTimeAxisView::select_track_color ()
869 if (RouteUI::choose_color ()) {
872 _view->apply_color (_color, StreamView::RegionColor);
878 RouteTimeAxisView::reset_samples_per_unit ()
880 set_samples_per_unit (_editor.get_current_zoom());
884 RouteTimeAxisView::set_samples_per_unit (double spu)
888 if (get_diskstream() != 0) {
889 speed = get_diskstream()->speed();
893 _view->set_samples_per_unit (spu * speed);
896 TimeAxisView::set_samples_per_unit (spu * speed);
900 RouteTimeAxisView::align_style_changed ()
902 switch (get_diskstream()->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 get_diskstream()->set_align_style (style);
940 RouteTimeAxisView::rename_current_playlist ()
942 ArdourPrompter prompter (true);
945 boost::shared_ptr<Diskstream> ds = get_diskstream();
946 if (!ds || ds->destructive())
949 boost::shared_ptr<Playlist> pl = ds->playlist();
953 prompter.set_prompt (_("Name for playlist"));
954 prompter.set_initial_text (pl->name());
955 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
956 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
958 switch (prompter.run ()) {
959 case Gtk::RESPONSE_ACCEPT:
960 prompter.get_result (name);
972 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
974 std::string ret (basename);
976 std::string const group_string = "." + route_group()->name() + ".";
978 // iterate through all playlists
980 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
981 std::string tmp = (*i)->name();
983 std::string::size_type idx = tmp.find(group_string);
984 // find those which belong to this group
985 if (idx != string::npos) {
986 tmp = tmp.substr(idx + group_string.length());
988 // and find the largest current number
989 int x = atoi(tmp.c_str());
999 snprintf (buf, sizeof(buf), "%d", maxnumber);
1001 ret = this->name() + "." + route_group()->name () + "." + buf;
1007 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1011 boost::shared_ptr<Diskstream> ds = get_diskstream();
1012 if (!ds || ds->destructive())
1015 boost::shared_ptr<const Playlist> pl = ds->playlist();
1021 if (route_group() && route_group()->is_active()) {
1022 name = resolve_new_group_playlist_name(name, playlists_before_op);
1025 while (_session->playlists->by_name(name)) {
1026 name = Playlist::bump_name (name, *_session);
1029 // TODO: The prompter "new" button should be de-activated if the user
1030 // specifies a playlist name which already exists in the session.
1034 ArdourPrompter prompter (true);
1036 prompter.set_prompt (_("Name for Playlist"));
1037 prompter.set_initial_text (name);
1038 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1039 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1040 prompter.show_all ();
1042 switch (prompter.run ()) {
1043 case Gtk::RESPONSE_ACCEPT:
1044 prompter.get_result (name);
1052 if (name.length()) {
1053 ds->use_copy_playlist ();
1054 ds->playlist()->set_name (name);
1059 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1063 boost::shared_ptr<Diskstream> ds = get_diskstream();
1064 if (!ds || ds->destructive())
1067 boost::shared_ptr<const Playlist> pl = ds->playlist();
1073 if (route_group() && route_group()->is_active()) {
1074 name = resolve_new_group_playlist_name(name,playlists_before_op);
1077 while (_session->playlists->by_name(name)) {
1078 name = Playlist::bump_name (name, *_session);
1084 ArdourPrompter prompter (true);
1086 prompter.set_prompt (_("Name for Playlist"));
1087 prompter.set_initial_text (name);
1088 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1089 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1091 switch (prompter.run ()) {
1092 case Gtk::RESPONSE_ACCEPT:
1093 prompter.get_result (name);
1101 if (name.length()) {
1102 ds->use_new_playlist ();
1103 ds->playlist()->set_name (name);
1108 RouteTimeAxisView::clear_playlist ()
1110 boost::shared_ptr<Diskstream> ds = get_diskstream();
1111 if (!ds || ds->destructive())
1114 boost::shared_ptr<Playlist> pl = ds->playlist();
1118 _editor.clear_playlist (pl);
1122 RouteTimeAxisView::speed_changed ()
1124 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1128 RouteTimeAxisView::diskstream_changed ()
1130 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::update_diskstream_display, this));
1134 RouteTimeAxisView::update_diskstream_display ()
1136 if (!get_diskstream()) // bus
1143 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1145 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1147 /* special case: select/deselect all tracks */
1148 if (_editor.get_selection().selected (this)) {
1149 _editor.get_selection().clear_tracks ();
1151 _editor.select_all_tracks ();
1157 switch (ArdourKeyboard::selection_type (ev->state)) {
1158 case Selection::Toggle:
1159 _editor.get_selection().toggle (this);
1162 case Selection::Set:
1163 _editor.get_selection().set (this);
1166 case Selection::Extend:
1167 _editor.extend_selection_to_track (*this);
1170 case Selection::Add:
1171 _editor.get_selection().add (this);
1177 RouteTimeAxisView::set_selected_points (PointSelection& points)
1179 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1180 (*i)->set_selected_points (points);
1185 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1188 _view->set_selected_regionviews (regions);
1192 /** Add the selectable things that we have to a list.
1193 * @param results List to add things to.
1196 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1200 if (get_diskstream() != 0) {
1201 speed = get_diskstream()->speed();
1204 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1205 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1207 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1208 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1211 /* pick up visible automation tracks */
1213 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1214 if (!(*i)->hidden()) {
1215 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1221 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1224 _view->get_inverted_selectables (sel, results);
1227 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1228 if (!(*i)->hidden()) {
1229 (*i)->get_inverted_selectables (sel, results);
1237 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1239 return (_show_automation.find(param) != _show_automation.end());
1242 /** Retuns 0 if track for \a param doesn't exist.
1244 RouteTimeAxisView::RouteAutomationNode*
1245 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1247 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1249 if (i != _automation_tracks.end()) {
1256 /** Shorthand for GainAutomation, etc.
1258 RouteTimeAxisView::RouteAutomationNode*
1259 RouteTimeAxisView::automation_track (AutomationType type)
1261 return automation_track (Evoral::Parameter(type));
1265 RouteTimeAxisView::route_group () const
1267 return _route->route_group();
1271 RouteTimeAxisView::name() const
1273 return _route->name();
1276 boost::shared_ptr<Playlist>
1277 RouteTimeAxisView::playlist () const
1279 boost::shared_ptr<Diskstream> ds;
1281 if ((ds = get_diskstream()) != 0) {
1282 return ds->playlist();
1284 return boost::shared_ptr<Playlist> ();
1289 RouteTimeAxisView::name_entry_changed ()
1293 x = name_entry.get_text ();
1295 if (x == _route->name()) {
1299 strip_whitespace_edges(x);
1301 if (x.length() == 0) {
1302 name_entry.set_text (_route->name());
1306 if (!_session->route_name_unique (x)) {
1307 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1308 name_entry.set_text (_route->name());
1309 } else if (_session->route_name_internal (x)) {
1310 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1311 name_entry.set_text (_route->name());
1313 _route->set_name (x);
1318 RouteTimeAxisView::visual_click ()
1320 popup_display_menu (0);
1324 RouteTimeAxisView::hide_click ()
1326 // LAME fix for hide_button refresh fix
1327 hide_button.set_sensitive(false);
1329 _editor.hide_track_in_display (*this);
1331 hide_button.set_sensitive(true);
1334 boost::shared_ptr<Region>
1335 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1337 boost::shared_ptr<Diskstream> stream;
1338 boost::shared_ptr<Playlist> playlist;
1340 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1341 return playlist->find_next_region (pos, point, dir);
1344 return boost::shared_ptr<Region> ();
1348 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1350 boost::shared_ptr<Diskstream> stream;
1351 boost::shared_ptr<Playlist> playlist;
1353 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1354 return playlist->find_next_region_boundary (pos, dir);
1361 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1363 boost::shared_ptr<Playlist> what_we_got;
1364 boost::shared_ptr<Diskstream> ds = get_diskstream();
1365 boost::shared_ptr<Playlist> playlist;
1369 /* route is a bus, not a track */
1373 playlist = ds->playlist();
1375 TimeSelection time (selection.time);
1376 float speed = ds->speed();
1377 if (speed != 1.0f) {
1378 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1379 (*i).start = session_frame_to_track_frame((*i).start, speed);
1380 (*i).end = session_frame_to_track_frame((*i).end, speed);
1384 XMLNode &before = playlist->get_state();
1387 if ((what_we_got = playlist->cut (time)) != 0) {
1388 _editor.get_cut_buffer().add (what_we_got);
1389 _session->add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1394 if ((what_we_got = playlist->copy (time)) != 0) {
1395 _editor.get_cut_buffer().add (what_we_got);
1400 if ((what_we_got = playlist->cut (time)) != 0) {
1401 _session->add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1402 what_we_got->release ();
1412 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1418 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1419 PlaylistSelection::iterator p;
1421 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1423 if (p == selection.playlists.end()) {
1427 if (get_diskstream()->speed() != 1.0f) {
1428 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1431 XMLNode &before = playlist->get_state();
1432 playlist->paste (*p, pos, times);
1433 _session->add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1439 TimeAxisView::Children
1440 RouteTimeAxisView::get_child_list()
1442 TimeAxisView::Children redirect_children;
1444 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1445 if (!(*i)->hidden()) {
1446 redirect_children.push_back(*i);
1449 return redirect_children;
1454 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1456 using namespace Menu_Helpers;
1458 if (!menu || !is_track()) {
1462 MenuList& playlist_items = menu->items();
1463 menu->set_name ("ArdourContextMenu");
1464 playlist_items.clear();
1466 delete playlist_menu;
1468 playlist_menu = new Menu;
1469 playlist_menu->set_name ("ArdourContextMenu");
1471 vector<boost::shared_ptr<Playlist> > playlists;
1472 boost::shared_ptr<Diskstream> ds = get_diskstream();
1473 RadioMenuItem::Group playlist_group;
1475 _session->playlists->get (playlists);
1477 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1479 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1480 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist),
1481 boost::weak_ptr<Playlist> (*i))));
1483 if (ds->playlist()->id() == (*i)->id()) {
1484 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1486 } else if (ds->playlist()->id() == (*i)->id()) {
1487 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist),
1488 boost::weak_ptr<Playlist>(*i))));
1489 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1494 playlist_items.push_back (SeparatorElem());
1495 playlist_items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1496 playlist_items.push_back (SeparatorElem());
1498 if (!route_group() || !route_group()->is_active()) {
1499 playlist_items.push_back (MenuElem (_("New"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1500 playlist_items.push_back (MenuElem (_("New Copy"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1503 // Use a label which tells the user what is happening
1504 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1505 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1509 playlist_items.push_back (SeparatorElem());
1510 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1511 playlist_items.push_back (SeparatorElem());
1513 playlist_items.push_back (MenuElem(_("Select from all ..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1517 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1519 assert (is_track());
1521 boost::shared_ptr<Playlist> pl (wpl.lock());
1527 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1530 if (get_diskstream()->playlist() == apl) {
1531 // radio button cotnrols mean this function is called for both the
1532 // old and new playlist
1535 get_diskstream()->use_playlist (apl);
1538 if (route_group() && route_group()->is_active()) {
1539 std::string group_string = "."+route_group()->name()+".";
1541 std::string take_name = apl->name();
1542 std::string::size_type idx = take_name.find(group_string);
1544 if (idx == std::string::npos)
1547 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1549 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1551 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1552 if ( (*i) == this->route()) {
1556 std::string playlist_name = (*i)->name()+group_string+take_name;
1558 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1560 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1564 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1566 // No playlist for this track for this take yet, make it
1567 track->diskstream()->use_new_playlist();
1568 track->diskstream()->playlist()->set_name(playlist_name);
1570 track->diskstream()->use_playlist(ipl);
1578 RouteTimeAxisView::show_playlist_selector ()
1580 _editor.playlist_selector().show_for (this);
1584 RouteTimeAxisView::map_frozen ()
1590 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1592 switch (track()->freeze_state()) {
1594 playlist_button.set_sensitive (false);
1595 rec_enable_button->set_sensitive (false);
1598 playlist_button.set_sensitive (true);
1599 rec_enable_button->set_sensitive (true);
1605 RouteTimeAxisView::color_handler ()
1607 //case cTimeStretchOutline:
1608 if (timestretch_rect) {
1609 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1611 //case cTimeStretchFill:
1612 if (timestretch_rect) {
1613 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1619 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1620 * Will add track if necessary.
1623 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1625 RouteAutomationNode* node = automation_track(param);
1628 /* it doesn't exist yet, so we don't care about the button state: just add it */
1629 create_automation_child (param, true);
1631 bool yn = node->menu_item->get_active();
1632 if (node->track->set_visibility (node->menu_item->get_active()) && yn) {
1634 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1635 will have done that for us.
1639 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1646 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1648 RouteAutomationNode* ran = automation_track(param);
1654 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1655 _show_automation.erase (param);
1656 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1658 if (ran->menu_item && !_hidden) {
1659 ignore_toggle = true;
1660 ran->menu_item->set_active (false);
1661 ignore_toggle = false;
1664 if (_route && !no_redraw) {
1665 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1671 RouteTimeAxisView::show_all_automation ()
1675 /* Show our automation */
1677 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1678 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1679 i->second->track->set_marked_for_display (true);
1680 i->second->track->canvas_display()->show();
1681 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1682 if (i->second->menu_item) {
1683 i->second->menu_item->set_active(true);
1688 /* Show processor automation */
1690 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1691 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1692 if ((*ii)->view == 0) {
1693 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1696 (*ii)->menu_item->set_active (true);
1704 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1708 RouteTimeAxisView::show_existing_automation ()
1712 /* Show our automation */
1714 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1715 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1716 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1717 i->second->track->set_marked_for_display (true);
1718 i->second->track->canvas_display()->show();
1719 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1720 i->second->menu_item->set_active(true);
1725 /* Show processor automation */
1727 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1728 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1729 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1730 (*ii)->menu_item->set_active (true);
1737 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1741 RouteTimeAxisView::hide_all_automation ()
1745 /* Hide our automation */
1747 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1748 i->second->track->set_marked_for_display (false);
1749 i->second->track->hide ();
1750 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1751 if (i->second->menu_item) {
1752 i->second->menu_item->set_active (false);
1756 /* Hide processor automation */
1758 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1759 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1760 (*ii)->menu_item->set_active (false);
1764 _show_automation.clear();
1767 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1772 RouteTimeAxisView::region_view_added (RegionView* rv)
1774 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1775 if (is_audio_track()) {
1776 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1777 boost::shared_ptr<AutomationTimeAxisView> atv;
1779 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1785 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1786 (*i)->add_ghost(rv);
1790 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1792 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1798 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1800 parent.remove_processor_automation_node (this);
1804 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1807 remove_child (pan->view);
1811 RouteTimeAxisView::ProcessorAutomationNode*
1812 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1814 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1816 if ((*i)->processor == processor) {
1818 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1819 if ((*ii)->what == what) {
1830 legalize_for_xml_node (string str)
1832 string::size_type pos;
1833 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1839 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1840 legal.replace (pos, 1, "_");
1849 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1852 ProcessorAutomationNode* pan;
1854 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1855 error << _("programming error: ")
1856 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1857 processor->name(), what)
1867 name = processor->describe_parameter (what);
1869 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1873 char state_name[256];
1874 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1876 boost::shared_ptr<AutomationControl> control
1877 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1879 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1880 new AutomationTimeAxisView (_session, _route, processor, control,
1881 _editor, *this, false, parent_canvas, name, state_name));
1883 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1885 if (!pan->view->marked_for_display()) {
1888 pan->menu_item->set_active (true);
1891 add_child (pan->view);
1894 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1897 processor->mark_automation_visible (what, true);
1901 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1904 pan->menu_item->set_active (false);
1907 i->mark_automation_visible (pan->what, false);
1910 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1915 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1917 boost::shared_ptr<Processor> processor (p.lock ());
1922 set<Evoral::Parameter> s;
1923 boost::shared_ptr<AutomationLine> al;
1925 processor->what_has_visible_data (s);
1927 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1929 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1932 add_processor_automation_curve (processor, (*i));
1938 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1940 using namespace Menu_Helpers;
1947 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1949 bool hideit = (!show);
1951 if ((node = track->get_state_node()) != 0) {
1952 if ((prop = node->property ("shown")) != 0) {
1953 if (string_is_affirmative (prop->value())) {
1959 _automation_tracks.insert (std::make_pair (param, new RouteAutomationNode(param, NULL, track)));
1961 track->set_visibility (!hideit);
1964 _show_automation.insert (param);
1968 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1971 if (!EventTypeMap::instance().is_midi_parameter(param)) {
1972 /* MIDI-related parameters are always in the menu, there's no
1973 reason to rebuild the menu just because we added a automation
1974 lane for one of them. But if we add a non-MIDI automation
1975 lane, then we need to invalidate the display menu.
1977 delete display_menu;
1983 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1985 boost::shared_ptr<Processor> processor (p.lock ());
1987 if (!processor || !processor->display_to_user ()) {
1991 using namespace Menu_Helpers;
1992 ProcessorAutomationInfo *rai;
1993 list<ProcessorAutomationInfo*>::iterator x;
1995 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
1996 std::set<Evoral::Parameter> has_visible_automation;
1998 processor->what_has_visible_data(has_visible_automation);
2000 if (automatable.empty()) {
2004 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2005 if ((*x)->processor == processor) {
2010 if (x == processor_automation.end()) {
2012 rai = new ProcessorAutomationInfo (processor);
2013 processor_automation.push_back (rai);
2021 /* any older menu was deleted at the top of processors_changed()
2022 when we cleared the subplugin menu.
2025 rai->menu = manage (new Menu);
2026 MenuList& items = rai->menu->items();
2027 rai->menu->set_name ("ArdourContextMenu");
2031 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2033 ProcessorAutomationNode* pan;
2034 CheckMenuItem* mitem;
2036 string name = processor->describe_parameter (*i);
2038 items.push_back (CheckMenuElem (name));
2039 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2041 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2042 mitem->set_active(true);
2045 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2049 pan = new ProcessorAutomationNode (*i, mitem, *this);
2051 rai->lines.push_back (pan);
2055 pan->menu_item = mitem;
2059 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2062 /* add the menu for this processor, because the subplugin
2063 menu is always cleared at the top of processors_changed().
2064 this is the result of some poor design in gtkmm and/or
2068 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2073 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2074 RouteTimeAxisView::ProcessorAutomationNode* pan)
2076 bool showit = pan->menu_item->get_active();
2077 bool redraw = false;
2079 if (pan->view == 0 && showit) {
2080 add_processor_automation_curve (rai->processor, pan->what);
2084 if (pan->view && showit != pan->view->marked_for_display()) {
2087 pan->view->set_marked_for_display (true);
2088 pan->view->canvas_display()->show();
2089 pan->view->canvas_background()->show();
2091 rai->processor->mark_automation_visible (pan->what, true);
2092 pan->view->set_marked_for_display (false);
2100 if (redraw && !no_redraw) {
2101 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2107 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2109 if (c.type == RouteProcessorChange::MeterPointChange) {
2110 /* nothing to do if only the meter point has changed */
2114 using namespace Menu_Helpers;
2116 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2117 (*i)->valid = false;
2120 subplugin_menu.items().clear ();
2122 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2123 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2125 bool deleted_processor_automation = false;
2127 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2129 list<ProcessorAutomationInfo*>::iterator tmp;
2137 processor_automation.erase (i);
2138 deleted_processor_automation = true;
2145 if (deleted_processor_automation && !no_redraw) {
2146 _route->gui_changed ("track_height", this);
2150 boost::shared_ptr<AutomationLine>
2151 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2153 ProcessorAutomationNode* pan;
2155 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2161 return boost::shared_ptr<AutomationLine>();
2165 RouteTimeAxisView::reset_processor_automation_curves ()
2167 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2173 RouteTimeAxisView::update_rec_display ()
2175 RouteUI::update_rec_display ();
2176 name_entry.set_sensitive (!_route->record_enabled());
2180 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2183 _view->set_layer_display (d);
2187 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2191 RouteTimeAxisView::layer_display () const
2194 return _view->layer_display ();
2197 /* we don't know, since we don't have a _view, so just return something */
2203 boost::shared_ptr<AutomationTimeAxisView>
2204 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2206 AutomationTracks::iterator i = _automation_tracks.find(param);
2207 if (i != _automation_tracks.end()) {
2208 return i->second->track;
2210 return boost::shared_ptr<AutomationTimeAxisView>();
2215 RouteTimeAxisView::fast_update ()
2217 gm.get_level_meter().update_meters ();
2221 RouteTimeAxisView::hide_meter ()
2224 gm.get_level_meter().hide_meters ();
2228 RouteTimeAxisView::show_meter ()
2234 RouteTimeAxisView::reset_meter ()
2236 if (Config->get_show_track_meters()) {
2237 gm.get_level_meter().setup_meters (height-5);
2244 RouteTimeAxisView::clear_meter ()
2246 gm.get_level_meter().clear_meters ();
2250 RouteTimeAxisView::meter_changed (void *src)
2252 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed, src)
2257 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2263 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2265 using namespace Menu_Helpers;
2267 if (!_underlay_streams.empty()) {
2268 MenuList& parent_items = parent_menu->items();
2269 Menu* gs_menu = manage (new Menu);
2270 gs_menu->set_name ("ArdourContextMenu");
2271 MenuList& gs_items = gs_menu->items();
2273 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2275 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2276 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2277 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2283 RouteTimeAxisView::set_underlay_state()
2285 if (!underlay_xml_node) {
2289 XMLNodeList nlist = underlay_xml_node->children();
2290 XMLNodeConstIterator niter;
2291 XMLNode *child_node;
2293 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2294 child_node = *niter;
2296 if (child_node->name() != "Underlay") {
2300 XMLProperty* prop = child_node->property ("id");
2302 PBD::ID id (prop->value());
2304 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2307 add_underlay(v->view(), false);
2316 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2322 RouteTimeAxisView& other = v->trackview();
2324 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2325 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2326 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2330 _underlay_streams.push_back(v);
2331 other._underlay_mirrors.push_back(this);
2333 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2336 if (!underlay_xml_node) {
2338 underlay_xml_node = xml_node->add_child("Underlays");
2341 XMLNode* node = underlay_xml_node->add_child("Underlay");
2342 XMLProperty* prop = node->add_property("id");
2343 prop->set_value(v->trackview().route()->id().to_s());
2349 RouteTimeAxisView::remove_underlay (StreamView* v)
2355 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2356 RouteTimeAxisView& other = v->trackview();
2358 if (it != _underlay_streams.end()) {
2359 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2361 if (gm == other._underlay_mirrors.end()) {
2362 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2366 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2368 _underlay_streams.erase(it);
2369 other._underlay_mirrors.erase(gm);
2371 if (underlay_xml_node) {
2372 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2378 RouteTimeAxisView::set_button_names ()
2380 rec_enable_button_label.set_text (_("r"));
2382 if (Config->get_solo_control_is_listen_control()) {
2383 switch (Config->get_listen_position()) {
2384 case AfterFaderListen:
2385 solo_button_label.set_text (_("A"));
2387 case PreFaderListen:
2388 solo_button_label.set_text (_("P"));
2392 solo_button_label.set_text (_("s"));
2395 mute_button_label.set_text (_("m"));