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()->set_tip(*rec_enable_button, _("Record"));
188 rec_enable_button->set_sensitive (_session->writable());
191 controls_hbox.pack_start(gm.get_level_meter(), false, false);
192 _route->meter_change.connect (*this, ui_bind (&RouteTimeAxisView::meter_changed, this, _1), gui_context());
193 _route->input()->changed.connect (*this, ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
194 _route->output()->changed.connect (*this, ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
196 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
197 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
199 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
200 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
202 ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
203 ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
204 ARDOUR_UI::instance()->set_tip(route_group_button, _("Route Group"));
205 ARDOUR_UI::instance()->set_tip(size_button,_("Display Height"));
206 ARDOUR_UI::instance()->set_tip(playlist_button,_("Playlist"));
207 ARDOUR_UI::instance()->set_tip(automation_button, _("Automation"));
208 ARDOUR_UI::instance()->set_tip(visual_button, _("Visual options"));
209 ARDOUR_UI::instance()->set_tip(hide_button, _("Hide this track"));
215 /* old school - when we used to put an extra row of buttons in place */
217 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
218 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
219 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
220 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
224 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
227 if (is_track() && track()->mode() == ARDOUR::Normal) {
228 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
233 _route->processors_changed.connect (*this, ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
234 _route->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 PropertyList* plist = new PropertyList();
253 plist->add (ARDOUR::Properties::edit, true);
254 plist->add (ARDOUR::Properties::mute, true);
255 plist->add (ARDOUR::Properties::solo, true);
257 route_group_menu = new RouteGroupMenu (_session, plist);
258 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
260 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
261 gm.get_gain_slider().set_name ("TrackGainFader");
264 RouteTimeAxisView::~RouteTimeAxisView ()
266 CatchDeletion (this);
268 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
272 delete playlist_menu;
275 delete playlist_action_menu;
276 playlist_action_menu = 0;
281 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
285 _automation_tracks.clear ();
287 delete route_group_menu;
291 RouteTimeAxisView::post_construct ()
293 /* map current state of the route */
295 update_diskstream_display ();
297 subplugin_menu.items().clear ();
298 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
299 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
300 reset_processor_automation_curves ();
304 RouteTimeAxisView::edit_click (GdkEventButton *ev)
306 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
307 if (_route->route_group()) {
308 _route->route_group()->remove (_route);
313 route_group_menu->rebuild (_route->route_group ());
314 route_group_menu->popup (ev->button, ev->time);
320 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
325 if (_route->route_group()) {
326 _route->route_group()->remove (_route);
332 RouteTimeAxisView::playlist_changed ()
338 RouteTimeAxisView::label_view ()
340 string x = _route->name();
342 if (x != name_entry.get_text()) {
343 name_entry.set_text (x);
346 ARDOUR_UI::instance()->set_tip (name_entry, x);
350 RouteTimeAxisView::route_name_changed ()
356 RouteTimeAxisView::take_name_changed (void *src)
365 RouteTimeAxisView::playlist_click ()
367 // always build a new action menu
369 delete playlist_action_menu;
371 playlist_action_menu = new Menu;
372 playlist_action_menu->set_name ("ArdourContextMenu");
374 build_playlist_menu (playlist_action_menu);
376 conditionally_add_to_selection ();
377 playlist_action_menu->popup (1, gtk_get_current_event_time());
381 RouteTimeAxisView::automation_click ()
383 conditionally_add_to_selection ();
384 build_automation_action_menu ();
385 automation_action_menu->popup (1, gtk_get_current_event_time());
389 RouteTimeAxisView::set_state (const XMLNode& node, int version)
391 TimeAxisView::set_state (node, version);
393 XMLNodeList kids = node.children();
394 XMLNodeConstIterator iter;
395 const XMLProperty* prop;
397 if (_view && (prop = node.property ("layer-display"))) {
398 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
401 for (iter = kids.begin(); iter != kids.end(); ++iter) {
402 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
403 if ((prop = (*iter)->property ("automation-id")) != 0) {
405 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
406 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
407 create_automation_child(param, show);
409 warning << "Automation child has no ID" << endmsg;
418 RouteTimeAxisView::build_automation_action_menu ()
420 using namespace Menu_Helpers;
422 delete automation_action_menu;
423 automation_action_menu = new Menu;
425 MenuList& items = automation_action_menu->items();
427 automation_action_menu->set_name ("ArdourContextMenu");
429 items.push_back (MenuElem (_("Show all automation"),
430 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
432 items.push_back (MenuElem (_("Show existing automation"),
433 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
435 items.push_back (MenuElem (_("Hide all automation"),
436 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
438 /* attach the plugin submenu. It may have previously been used elsewhere, so we detach it first. */
440 detach_menu (subplugin_menu);
441 items.push_back (MenuElem (_("Plugins"), subplugin_menu));
442 items.back().set_sensitive (!subplugin_menu.items().empty());
446 RouteTimeAxisView::build_display_menu ()
448 using namespace Menu_Helpers;
450 /* get the size menu ready */
456 TimeAxisView::build_display_menu ();
458 /* now fill it with our stuff */
460 MenuList& items = display_menu->items();
461 display_menu->set_name ("ArdourContextMenu");
463 items.push_back (MenuElem (_("Height"), *size_menu));
464 items.push_back (MenuElem (_("Color"), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
466 items.push_back (SeparatorElem());
468 if (!Profile->get_sae()) {
469 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
470 /* rebuild this every time */
471 build_automation_action_menu ();
472 detach_menu (*automation_action_menu);
473 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
474 items.push_back (SeparatorElem());
477 // Hook for derived classes to add type specific stuff
478 append_extra_display_menu_items ();
479 items.push_back (SeparatorElem());
483 Menu *layers_menu = manage(new Menu);
484 MenuList &layers_items = layers_menu->items();
485 layers_menu->set_name("ArdourContextMenu");
487 RadioMenuItem::Group layers_group;
489 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
490 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
491 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
492 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
494 items.push_back (MenuElem (_("Layers"), *layers_menu));
496 Menu* alignment_menu = manage (new Menu);
497 MenuList& alignment_items = alignment_menu->items();
498 alignment_menu->set_name ("ArdourContextMenu");
500 RadioMenuItem::Group align_group;
502 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
503 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
504 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
505 if (get_diskstream()->alignment_style() == ExistingMaterial)
506 align_existing_item->set_active();
508 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
509 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
510 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
511 if (get_diskstream()->alignment_style() == CaptureTime)
512 align_capture_item->set_active();
514 if (!Profile->get_sae()) {
515 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
516 get_diskstream()->AlignmentStyleChanged.connect (route_connections, boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
518 RadioMenuItem::Group mode_group;
519 items.push_back (RadioMenuElem (mode_group, _("Normal mode"), sigc::bind (
520 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
522 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
524 items.push_back (RadioMenuElem (mode_group, _("Tape mode"), sigc::bind (
525 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
526 ARDOUR::Destructive)));
527 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
529 items.push_back (RadioMenuElem (mode_group, _("No layering mode"),
530 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
531 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
535 switch (track()->mode()) {
536 case ARDOUR::Destructive:
537 destructive_track_mode_item->set_active ();
540 normal_track_mode_item->set_active ();
542 case ARDOUR::NonLayered:
543 non_layered_track_mode_item->set_active ();
548 get_diskstream()->AlignmentStyleChanged.connect (route_connections, boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
550 mode_menu = build_mode_menu();
552 items.push_back (MenuElem (_("Mode"), *mode_menu));
554 color_mode_menu = build_color_mode_menu();
556 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
558 items.push_back (SeparatorElem());
561 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
562 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
563 route_active_menu_item->set_active (_route->active());
565 items.push_back (SeparatorElem());
566 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &RouteTimeAxisView::hide_click)));
567 if (!Profile->get_sae()) {
568 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
570 items.push_front (SeparatorElem());
571 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
575 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
578 item_2->set_active ();
583 RouteTimeAxisView::set_track_mode (TrackMode mode)
586 RadioMenuItem* other_item;
587 RadioMenuItem* other_item_2;
591 item = normal_track_mode_item;
592 other_item = non_layered_track_mode_item;
593 other_item_2 = destructive_track_mode_item;
595 case ARDOUR::NonLayered:
596 item = non_layered_track_mode_item;
597 other_item = normal_track_mode_item;
598 other_item_2 = destructive_track_mode_item;
600 case ARDOUR::Destructive:
601 item = destructive_track_mode_item;
602 other_item = normal_track_mode_item;
603 other_item_2 = non_layered_track_mode_item;
606 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
611 if (item && other_item && other_item_2 && item->get_active() && track()->mode() != mode) {
612 _set_track_mode (track().get(), mode, other_item, other_item_2);
617 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
621 if (!track->can_use_mode (mode, needs_bounce)) {
625 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
628 cerr << "would bounce this one\n";
633 track->set_mode (mode);
635 rec_enable_button->remove ();
638 case ARDOUR::NonLayered:
640 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
642 case ARDOUR::Destructive:
643 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
647 rec_enable_button->show_all ();
651 RouteTimeAxisView::track_mode_changed ()
655 switch (track()->mode()) {
657 item = normal_track_mode_item;
659 case ARDOUR::NonLayered:
660 item = non_layered_track_mode_item;
662 case ARDOUR::Destructive:
663 item = destructive_track_mode_item;
666 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
675 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
681 TimeAxisView::show_timestretch (start, end);
691 /* check that the time selection was made in our route, or our route group.
692 remember that route_group() == 0 implies the route is *not* in a edit group.
695 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
696 /* this doesn't apply to us */
700 /* ignore it if our edit group is not active */
702 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
707 if (timestretch_rect == 0) {
708 timestretch_rect = new SimpleRect (*canvas_display ());
709 timestretch_rect->property_x1() = 0.0;
710 timestretch_rect->property_y1() = 0.0;
711 timestretch_rect->property_x2() = 0.0;
712 timestretch_rect->property_y2() = 0.0;
713 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
714 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
717 timestretch_rect->show ();
718 timestretch_rect->raise_to_top ();
720 x1 = start / _editor.get_current_zoom();
721 x2 = (end - 1) / _editor.get_current_zoom();
722 y2 = current_height() - 2;
724 timestretch_rect->property_x1() = x1;
725 timestretch_rect->property_y1() = 1.0;
726 timestretch_rect->property_x2() = x2;
727 timestretch_rect->property_y2() = y2;
731 RouteTimeAxisView::hide_timestretch ()
733 TimeAxisView::hide_timestretch ();
735 if (timestretch_rect) {
736 timestretch_rect->hide ();
741 RouteTimeAxisView::show_selection (TimeSelection& ts)
745 /* ignore it if our edit group is not active or if the selection was started
746 in some other track or route group (remember that route_group() == 0 means
747 that the track is not in an route group).
750 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
751 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
757 TimeAxisView::show_selection (ts);
761 RouteTimeAxisView::set_height (uint32_t h)
764 bool height_changed = (height == 0) || (h != height);
765 gm.get_level_meter().setup_meters (gmlen);
767 TimeAxisView::set_height (h);
772 _view->set_height ((double) current_height());
776 snprintf (buf, sizeof (buf), "%u", height);
777 xml_node->add_property ("height", buf);
779 if (height >= hNormal) {
784 gm.get_gain_slider().show();
786 if (!_route || _route->is_control()) {
791 if (rec_enable_button)
792 rec_enable_button->show();
794 route_group_button.show();
796 visual_button.show();
798 automation_button.show();
800 if (is_track() && track()->mode() == ARDOUR::Normal) {
801 playlist_button.show();
804 } else if (height >= hSmaller) {
810 gm.get_gain_slider().hide();
812 if (!_route || _route->is_control()) {
817 if (rec_enable_button)
818 rec_enable_button->show();
820 route_group_button.hide ();
822 visual_button.hide ();
824 automation_button.hide ();
826 if (is_track() && track()->mode() == ARDOUR::Normal) {
827 playlist_button.hide ();
833 /* don't allow name_entry to be hidden while
834 it has focus, otherwise the GUI becomes unusable.
837 if (name_entry.has_focus()) {
838 if (name_entry.get_text() != _route->name()) {
839 name_entry_changed ();
841 controls_ebox.grab_focus ();
847 gm.get_gain_slider().hide();
850 if (rec_enable_button)
851 rec_enable_button->hide();
853 route_group_button.hide ();
855 visual_button.hide ();
857 automation_button.hide ();
858 playlist_button.hide ();
859 name_label.set_text (_route->name());
862 if (height_changed && !no_redraw) {
863 /* only emit the signal if the height really changed */
864 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
869 RouteTimeAxisView::select_track_color ()
871 if (RouteUI::choose_color ()) {
874 _view->apply_color (_color, StreamView::RegionColor);
880 RouteTimeAxisView::reset_samples_per_unit ()
882 set_samples_per_unit (_editor.get_current_zoom());
886 RouteTimeAxisView::set_samples_per_unit (double spu)
890 if (get_diskstream() != 0) {
891 speed = get_diskstream()->speed();
895 _view->set_samples_per_unit (spu * speed);
898 TimeAxisView::set_samples_per_unit (spu * speed);
902 RouteTimeAxisView::align_style_changed ()
904 switch (get_diskstream()->alignment_style()) {
905 case ExistingMaterial:
906 if (!align_existing_item->get_active()) {
907 align_existing_item->set_active();
911 if (!align_capture_item->get_active()) {
912 align_capture_item->set_active();
919 RouteTimeAxisView::set_align_style (AlignStyle style)
924 case ExistingMaterial:
925 item = align_existing_item;
928 item = align_capture_item;
931 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
936 if (item->get_active()) {
937 get_diskstream()->set_align_style (style);
942 RouteTimeAxisView::rename_current_playlist ()
944 ArdourPrompter prompter (true);
947 boost::shared_ptr<Diskstream> ds = get_diskstream();
948 if (!ds || ds->destructive())
951 boost::shared_ptr<Playlist> pl = ds->playlist();
955 prompter.set_prompt (_("Name for playlist"));
956 prompter.set_initial_text (pl->name());
957 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
958 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
960 switch (prompter.run ()) {
961 case Gtk::RESPONSE_ACCEPT:
962 prompter.get_result (name);
974 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
976 std::string ret (basename);
978 std::string const group_string = "." + route_group()->name() + ".";
980 // iterate through all playlists
982 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
983 std::string tmp = (*i)->name();
985 std::string::size_type idx = tmp.find(group_string);
986 // find those which belong to this group
987 if (idx != string::npos) {
988 tmp = tmp.substr(idx + group_string.length());
990 // and find the largest current number
991 int x = atoi(tmp.c_str());
1001 snprintf (buf, sizeof(buf), "%d", maxnumber);
1003 ret = this->name() + "." + route_group()->name () + "." + buf;
1009 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1013 boost::shared_ptr<Diskstream> ds = get_diskstream();
1014 if (!ds || ds->destructive())
1017 boost::shared_ptr<const Playlist> pl = ds->playlist();
1023 if (route_group() && route_group()->is_active()) {
1024 name = resolve_new_group_playlist_name(name, playlists_before_op);
1027 while (_session->playlists->by_name(name)) {
1028 name = Playlist::bump_name (name, *_session);
1031 // TODO: The prompter "new" button should be de-activated if the user
1032 // specifies a playlist name which already exists in the session.
1036 ArdourPrompter prompter (true);
1038 prompter.set_prompt (_("Name for Playlist"));
1039 prompter.set_initial_text (name);
1040 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1041 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1042 prompter.show_all ();
1044 switch (prompter.run ()) {
1045 case Gtk::RESPONSE_ACCEPT:
1046 prompter.get_result (name);
1054 if (name.length()) {
1055 ds->use_copy_playlist ();
1056 ds->playlist()->set_name (name);
1061 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1065 boost::shared_ptr<Diskstream> ds = get_diskstream();
1066 if (!ds || ds->destructive())
1069 boost::shared_ptr<const Playlist> pl = ds->playlist();
1075 if (route_group() && route_group()->is_active()) {
1076 name = resolve_new_group_playlist_name(name,playlists_before_op);
1079 while (_session->playlists->by_name(name)) {
1080 name = Playlist::bump_name (name, *_session);
1086 ArdourPrompter prompter (true);
1088 prompter.set_prompt (_("Name for Playlist"));
1089 prompter.set_initial_text (name);
1090 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1091 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1093 switch (prompter.run ()) {
1094 case Gtk::RESPONSE_ACCEPT:
1095 prompter.get_result (name);
1103 if (name.length()) {
1104 ds->use_new_playlist ();
1105 ds->playlist()->set_name (name);
1110 RouteTimeAxisView::clear_playlist ()
1112 boost::shared_ptr<Diskstream> ds = get_diskstream();
1113 if (!ds || ds->destructive())
1116 boost::shared_ptr<Playlist> pl = ds->playlist();
1120 _editor.clear_playlist (pl);
1124 RouteTimeAxisView::speed_changed ()
1126 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1130 RouteTimeAxisView::diskstream_changed ()
1132 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::update_diskstream_display, this));
1136 RouteTimeAxisView::update_diskstream_display ()
1138 if (!get_diskstream()) // bus
1145 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1147 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1149 /* special case: select/deselect all tracks */
1150 if (_editor.get_selection().selected (this)) {
1151 _editor.get_selection().clear_tracks ();
1153 _editor.select_all_tracks ();
1159 switch (ArdourKeyboard::selection_type (ev->state)) {
1160 case Selection::Toggle:
1161 _editor.get_selection().toggle (this);
1164 case Selection::Set:
1165 _editor.get_selection().set (this);
1168 case Selection::Extend:
1169 _editor.extend_selection_to_track (*this);
1172 case Selection::Add:
1173 _editor.get_selection().add (this);
1179 RouteTimeAxisView::set_selected_points (PointSelection& points)
1181 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1182 (*i)->set_selected_points (points);
1187 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1190 _view->set_selected_regionviews (regions);
1194 /** Add the selectable things that we have to a list.
1195 * @param results List to add things to.
1198 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1202 if (get_diskstream() != 0) {
1203 speed = get_diskstream()->speed();
1206 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1207 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1209 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1210 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1213 /* pick up visible automation tracks */
1215 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1216 if (!(*i)->hidden()) {
1217 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1223 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1226 _view->get_inverted_selectables (sel, results);
1229 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1230 if (!(*i)->hidden()) {
1231 (*i)->get_inverted_selectables (sel, results);
1239 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1241 return (_show_automation.find(param) != _show_automation.end());
1244 /** Retuns 0 if track for \a param doesn't exist.
1246 RouteTimeAxisView::RouteAutomationNode*
1247 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1249 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1251 if (i != _automation_tracks.end()) {
1258 /** Shorthand for GainAutomation, etc.
1260 RouteTimeAxisView::RouteAutomationNode*
1261 RouteTimeAxisView::automation_track (AutomationType type)
1263 return automation_track (Evoral::Parameter(type));
1267 RouteTimeAxisView::route_group () const
1269 return _route->route_group();
1273 RouteTimeAxisView::name() const
1275 return _route->name();
1278 boost::shared_ptr<Playlist>
1279 RouteTimeAxisView::playlist () const
1281 boost::shared_ptr<Diskstream> ds;
1283 if ((ds = get_diskstream()) != 0) {
1284 return ds->playlist();
1286 return boost::shared_ptr<Playlist> ();
1291 RouteTimeAxisView::name_entry_changed ()
1295 x = name_entry.get_text ();
1297 if (x == _route->name()) {
1301 strip_whitespace_edges(x);
1303 if (x.length() == 0) {
1304 name_entry.set_text (_route->name());
1308 if (!_session->route_name_unique (x)) {
1309 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1310 name_entry.set_text (_route->name());
1311 } else if (_session->route_name_internal (x)) {
1312 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1313 name_entry.set_text (_route->name());
1315 _route->set_name (x);
1320 RouteTimeAxisView::visual_click ()
1322 popup_display_menu (0);
1326 RouteTimeAxisView::hide_click ()
1328 // LAME fix for hide_button refresh fix
1329 hide_button.set_sensitive(false);
1331 _editor.hide_track_in_display (*this);
1333 hide_button.set_sensitive(true);
1336 boost::shared_ptr<Region>
1337 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1339 boost::shared_ptr<Diskstream> stream;
1340 boost::shared_ptr<Playlist> playlist;
1342 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1343 return playlist->find_next_region (pos, point, dir);
1346 return boost::shared_ptr<Region> ();
1350 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1352 boost::shared_ptr<Diskstream> stream;
1353 boost::shared_ptr<Playlist> playlist;
1355 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1356 return playlist->find_next_region_boundary (pos, dir);
1363 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1365 boost::shared_ptr<Playlist> what_we_got;
1366 boost::shared_ptr<Diskstream> ds = get_diskstream();
1367 boost::shared_ptr<Playlist> playlist;
1371 /* route is a bus, not a track */
1375 playlist = ds->playlist();
1377 TimeSelection time (selection.time);
1378 float speed = ds->speed();
1379 if (speed != 1.0f) {
1380 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1381 (*i).start = session_frame_to_track_frame((*i).start, speed);
1382 (*i).end = session_frame_to_track_frame((*i).end, speed);
1386 XMLNode &before = playlist->get_state();
1389 if ((what_we_got = playlist->cut (time)) != 0) {
1390 _editor.get_cut_buffer().add (what_we_got);
1391 _session->add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1396 if ((what_we_got = playlist->copy (time)) != 0) {
1397 _editor.get_cut_buffer().add (what_we_got);
1402 if ((what_we_got = playlist->cut (time)) != 0) {
1403 _session->add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1404 what_we_got->release ();
1414 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1420 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1421 PlaylistSelection::iterator p;
1423 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1425 if (p == selection.playlists.end()) {
1429 if (get_diskstream()->speed() != 1.0f) {
1430 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1433 XMLNode &before = playlist->get_state();
1434 playlist->paste (*p, pos, times);
1435 _session->add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1441 TimeAxisView::Children
1442 RouteTimeAxisView::get_child_list()
1444 TimeAxisView::Children redirect_children;
1446 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1447 if (!(*i)->hidden()) {
1448 redirect_children.push_back(*i);
1451 return redirect_children;
1456 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1458 using namespace Menu_Helpers;
1460 if (!menu || !is_track()) {
1464 MenuList& playlist_items = menu->items();
1465 menu->set_name ("ArdourContextMenu");
1466 playlist_items.clear();
1468 delete playlist_menu;
1470 playlist_menu = new Menu;
1471 playlist_menu->set_name ("ArdourContextMenu");
1473 vector<boost::shared_ptr<Playlist> > playlists;
1474 boost::shared_ptr<Diskstream> ds = get_diskstream();
1475 RadioMenuItem::Group playlist_group;
1477 _session->playlists->get (playlists);
1479 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1481 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1482 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist),
1483 boost::weak_ptr<Playlist> (*i))));
1485 if (ds->playlist()->id() == (*i)->id()) {
1486 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1488 } else if (ds->playlist()->id() == (*i)->id()) {
1489 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist),
1490 boost::weak_ptr<Playlist>(*i))));
1491 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1496 playlist_items.push_back (SeparatorElem());
1497 playlist_items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1498 playlist_items.push_back (SeparatorElem());
1500 if (!route_group() || !route_group()->is_active()) {
1501 playlist_items.push_back (MenuElem (_("New"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1502 playlist_items.push_back (MenuElem (_("New Copy"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1505 // Use a label which tells the user what is happening
1506 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1507 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1511 playlist_items.push_back (SeparatorElem());
1512 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1513 playlist_items.push_back (SeparatorElem());
1515 playlist_items.push_back (MenuElem(_("Select from all ..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1519 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1521 assert (is_track());
1523 boost::shared_ptr<Playlist> pl (wpl.lock());
1529 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1532 if (get_diskstream()->playlist() == apl) {
1533 // radio button cotnrols mean this function is called for both the
1534 // old and new playlist
1537 get_diskstream()->use_playlist (apl);
1540 if (route_group() && route_group()->is_active()) {
1541 std::string group_string = "."+route_group()->name()+".";
1543 std::string take_name = apl->name();
1544 std::string::size_type idx = take_name.find(group_string);
1546 if (idx == std::string::npos)
1549 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1551 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1553 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1554 if ( (*i) == this->route()) {
1558 std::string playlist_name = (*i)->name()+group_string+take_name;
1560 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1562 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1566 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1568 // No playlist for this track for this take yet, make it
1569 track->diskstream()->use_new_playlist();
1570 track->diskstream()->playlist()->set_name(playlist_name);
1572 track->diskstream()->use_playlist(ipl);
1580 RouteTimeAxisView::show_playlist_selector ()
1582 _editor.playlist_selector().show_for (this);
1586 RouteTimeAxisView::map_frozen ()
1592 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1594 switch (track()->freeze_state()) {
1596 playlist_button.set_sensitive (false);
1597 rec_enable_button->set_sensitive (false);
1600 playlist_button.set_sensitive (true);
1601 rec_enable_button->set_sensitive (true);
1607 RouteTimeAxisView::color_handler ()
1609 //case cTimeStretchOutline:
1610 if (timestretch_rect) {
1611 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1613 //case cTimeStretchFill:
1614 if (timestretch_rect) {
1615 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1621 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1622 * Will add track if necessary.
1625 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1627 RouteAutomationNode* node = automation_track(param);
1630 /* it doesn't exist yet, so we don't care about the button state: just add it */
1631 create_automation_child (param, true);
1633 bool yn = node->menu_item->get_active();
1634 if (node->track->set_visibility (node->menu_item->get_active()) && yn) {
1636 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1637 will have done that for us.
1641 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1648 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1650 RouteAutomationNode* ran = automation_track(param);
1656 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1657 _show_automation.erase (param);
1658 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1660 if (ran->menu_item && !_hidden) {
1661 ignore_toggle = true;
1662 ran->menu_item->set_active (false);
1663 ignore_toggle = false;
1666 if (_route && !no_redraw) {
1667 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1673 RouteTimeAxisView::show_all_automation ()
1677 /* Show our automation */
1679 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1680 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1681 i->second->track->set_marked_for_display (true);
1682 i->second->track->canvas_display()->show();
1683 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1684 if (i->second->menu_item) {
1685 i->second->menu_item->set_active(true);
1690 /* Show processor automation */
1692 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1693 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1694 if ((*ii)->view == 0) {
1695 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1698 (*ii)->menu_item->set_active (true);
1706 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1710 RouteTimeAxisView::show_existing_automation ()
1714 /* Show our automation */
1716 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1717 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1718 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1719 i->second->track->set_marked_for_display (true);
1720 i->second->track->canvas_display()->show();
1721 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1722 i->second->menu_item->set_active(true);
1727 /* Show processor automation */
1729 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1730 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1731 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1732 (*ii)->menu_item->set_active (true);
1739 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1743 RouteTimeAxisView::hide_all_automation ()
1747 /* Hide our automation */
1749 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1750 i->second->track->set_marked_for_display (false);
1751 i->second->track->hide ();
1752 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1753 if (i->second->menu_item) {
1754 i->second->menu_item->set_active (false);
1758 /* Hide processor automation */
1760 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1761 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1762 (*ii)->menu_item->set_active (false);
1766 _show_automation.clear();
1769 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1774 RouteTimeAxisView::region_view_added (RegionView* rv)
1776 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1777 if (is_audio_track()) {
1778 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1779 boost::shared_ptr<AutomationTimeAxisView> atv;
1781 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1787 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1788 (*i)->add_ghost(rv);
1792 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1794 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1800 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1802 parent.remove_processor_automation_node (this);
1806 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1809 remove_child (pan->view);
1813 RouteTimeAxisView::ProcessorAutomationNode*
1814 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1816 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1818 if ((*i)->processor == processor) {
1820 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1821 if ((*ii)->what == what) {
1832 legalize_for_xml_node (string str)
1834 string::size_type pos;
1835 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1841 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1842 legal.replace (pos, 1, "_");
1851 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1854 ProcessorAutomationNode* pan;
1856 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1857 error << _("programming error: ")
1858 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1859 processor->name(), what)
1869 name = processor->describe_parameter (what);
1871 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1875 char state_name[256];
1876 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1878 boost::shared_ptr<AutomationControl> control
1879 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1881 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1882 new AutomationTimeAxisView (_session, _route, processor, control,
1883 _editor, *this, false, parent_canvas, name, state_name));
1885 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1887 if (!pan->view->marked_for_display()) {
1890 pan->menu_item->set_active (true);
1893 add_child (pan->view);
1896 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1899 processor->mark_automation_visible (what, true);
1903 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1906 pan->menu_item->set_active (false);
1909 i->mark_automation_visible (pan->what, false);
1912 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1917 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1919 boost::shared_ptr<Processor> processor (p.lock ());
1924 set<Evoral::Parameter> s;
1925 boost::shared_ptr<AutomationLine> al;
1927 processor->what_has_visible_data (s);
1929 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1931 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1934 add_processor_automation_curve (processor, (*i));
1940 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1942 using namespace Menu_Helpers;
1949 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1951 bool hideit = (!show);
1953 if ((node = track->get_state_node()) != 0) {
1954 if ((prop = node->property ("shown")) != 0) {
1955 if (string_is_affirmative (prop->value())) {
1961 _automation_tracks.insert (std::make_pair (param, new RouteAutomationNode(param, NULL, track)));
1963 track->set_visibility (!hideit);
1966 _show_automation.insert (param);
1970 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1973 if (!EventTypeMap::instance().is_midi_parameter(param)) {
1974 /* MIDI-related parameters are always in the menu, there's no
1975 reason to rebuild the menu just because we added a automation
1976 lane for one of them. But if we add a non-MIDI automation
1977 lane, then we need to invalidate the display menu.
1979 delete display_menu;
1985 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1987 boost::shared_ptr<Processor> processor (p.lock ());
1989 if (!processor || !processor->display_to_user ()) {
1993 using namespace Menu_Helpers;
1994 ProcessorAutomationInfo *rai;
1995 list<ProcessorAutomationInfo*>::iterator x;
1997 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
1998 std::set<Evoral::Parameter> has_visible_automation;
2000 processor->what_has_visible_data(has_visible_automation);
2002 if (automatable.empty()) {
2006 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2007 if ((*x)->processor == processor) {
2012 if (x == processor_automation.end()) {
2014 rai = new ProcessorAutomationInfo (processor);
2015 processor_automation.push_back (rai);
2023 /* any older menu was deleted at the top of processors_changed()
2024 when we cleared the subplugin menu.
2027 rai->menu = manage (new Menu);
2028 MenuList& items = rai->menu->items();
2029 rai->menu->set_name ("ArdourContextMenu");
2033 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2035 ProcessorAutomationNode* pan;
2036 CheckMenuItem* mitem;
2038 string name = processor->describe_parameter (*i);
2040 items.push_back (CheckMenuElem (name));
2041 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2043 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2044 mitem->set_active(true);
2047 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2051 pan = new ProcessorAutomationNode (*i, mitem, *this);
2053 rai->lines.push_back (pan);
2057 pan->menu_item = mitem;
2061 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2064 /* add the menu for this processor, because the subplugin
2065 menu is always cleared at the top of processors_changed().
2066 this is the result of some poor design in gtkmm and/or
2070 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2075 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2076 RouteTimeAxisView::ProcessorAutomationNode* pan)
2078 bool showit = pan->menu_item->get_active();
2079 bool redraw = false;
2081 if (pan->view == 0 && showit) {
2082 add_processor_automation_curve (rai->processor, pan->what);
2086 if (pan->view && showit != pan->view->marked_for_display()) {
2089 pan->view->set_marked_for_display (true);
2090 pan->view->canvas_display()->show();
2091 pan->view->canvas_background()->show();
2093 rai->processor->mark_automation_visible (pan->what, true);
2094 pan->view->set_marked_for_display (false);
2102 if (redraw && !no_redraw) {
2103 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2109 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2111 if (c.type == RouteProcessorChange::MeterPointChange) {
2112 /* nothing to do if only the meter point has changed */
2116 using namespace Menu_Helpers;
2118 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2119 (*i)->valid = false;
2122 subplugin_menu.items().clear ();
2124 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2125 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2127 bool deleted_processor_automation = false;
2129 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2131 list<ProcessorAutomationInfo*>::iterator tmp;
2139 processor_automation.erase (i);
2140 deleted_processor_automation = true;
2147 if (deleted_processor_automation && !no_redraw) {
2148 _route->gui_changed ("track_height", this);
2152 boost::shared_ptr<AutomationLine>
2153 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2155 ProcessorAutomationNode* pan;
2157 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2163 return boost::shared_ptr<AutomationLine>();
2167 RouteTimeAxisView::reset_processor_automation_curves ()
2169 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2175 RouteTimeAxisView::update_rec_display ()
2177 RouteUI::update_rec_display ();
2178 name_entry.set_sensitive (!_route->record_enabled());
2182 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2185 _view->set_layer_display (d);
2189 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2193 RouteTimeAxisView::layer_display () const
2196 return _view->layer_display ();
2199 /* we don't know, since we don't have a _view, so just return something */
2205 boost::shared_ptr<AutomationTimeAxisView>
2206 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2208 AutomationTracks::iterator i = _automation_tracks.find(param);
2209 if (i != _automation_tracks.end()) {
2210 return i->second->track;
2212 return boost::shared_ptr<AutomationTimeAxisView>();
2217 RouteTimeAxisView::fast_update ()
2219 gm.get_level_meter().update_meters ();
2223 RouteTimeAxisView::hide_meter ()
2226 gm.get_level_meter().hide_meters ();
2230 RouteTimeAxisView::show_meter ()
2236 RouteTimeAxisView::reset_meter ()
2238 if (Config->get_show_track_meters()) {
2239 gm.get_level_meter().setup_meters (height-5);
2246 RouteTimeAxisView::clear_meter ()
2248 gm.get_level_meter().clear_meters ();
2252 RouteTimeAxisView::meter_changed (void *src)
2254 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed, src)
2259 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2265 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2267 using namespace Menu_Helpers;
2269 if (!_underlay_streams.empty()) {
2270 MenuList& parent_items = parent_menu->items();
2271 Menu* gs_menu = manage (new Menu);
2272 gs_menu->set_name ("ArdourContextMenu");
2273 MenuList& gs_items = gs_menu->items();
2275 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2277 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2278 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2279 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2285 RouteTimeAxisView::set_underlay_state()
2287 if (!underlay_xml_node) {
2291 XMLNodeList nlist = underlay_xml_node->children();
2292 XMLNodeConstIterator niter;
2293 XMLNode *child_node;
2295 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2296 child_node = *niter;
2298 if (child_node->name() != "Underlay") {
2302 XMLProperty* prop = child_node->property ("id");
2304 PBD::ID id (prop->value());
2306 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2309 add_underlay(v->view(), false);
2318 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2324 RouteTimeAxisView& other = v->trackview();
2326 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2327 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2328 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2332 _underlay_streams.push_back(v);
2333 other._underlay_mirrors.push_back(this);
2335 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2338 if (!underlay_xml_node) {
2340 underlay_xml_node = xml_node->add_child("Underlays");
2343 XMLNode* node = underlay_xml_node->add_child("Underlay");
2344 XMLProperty* prop = node->add_property("id");
2345 prop->set_value(v->trackview().route()->id().to_s());
2351 RouteTimeAxisView::remove_underlay (StreamView* v)
2357 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2358 RouteTimeAxisView& other = v->trackview();
2360 if (it != _underlay_streams.end()) {
2361 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2363 if (gm == other._underlay_mirrors.end()) {
2364 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2368 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2370 _underlay_streams.erase(it);
2371 other._underlay_mirrors.erase(gm);
2373 if (underlay_xml_node) {
2374 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2380 RouteTimeAxisView::set_button_names ()
2382 rec_enable_button_label.set_text (_("r"));
2384 if (Config->get_solo_control_is_listen_control()) {
2385 switch (Config->get_listen_position()) {
2386 case AfterFaderListen:
2387 solo_button_label.set_text (_("A"));
2389 case PreFaderListen:
2390 solo_button_label.set_text (_("P"));
2394 solo_button_label.set_text (_("s"));
2397 mute_button_label.set_text (_("m"));