2 Copyright (C) 2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include <sigc++/bind.h>
31 #include "pbd/error.h"
32 #include "pbd/stl_delete.h"
33 #include "pbd/whitespace.h"
34 #include "pbd/memento_command.h"
35 #include "pbd/enumwriter.h"
36 #include "pbd/stateful_diff_command.h"
38 #include <gtkmm/menu.h>
39 #include <gtkmm/menuitem.h>
40 #include <gtkmm2ext/gtk_ui.h>
41 #include <gtkmm2ext/selector.h>
42 #include <gtkmm2ext/stop_signal.h>
43 #include <gtkmm2ext/bindable_button.h>
44 #include <gtkmm2ext/utils.h>
46 #include "ardour/amp.h"
47 #include "ardour/audioplaylist.h"
48 #include "ardour/diskstream.h"
49 #include "ardour/event_type_map.h"
50 #include "ardour/ladspa_plugin.h"
51 #include "ardour/location.h"
52 #include "ardour/panner.h"
53 #include "ardour/playlist.h"
54 #include "ardour/playlist.h"
55 #include "ardour/processor.h"
56 #include "ardour/profile.h"
57 #include "ardour/route_group.h"
58 #include "ardour/session.h"
59 #include "ardour/session_playlist.h"
60 #include "ardour/debug.h"
61 #include "ardour/utils.h"
62 #include "evoral/Parameter.hpp"
64 #include "ardour_ui.h"
65 #include "route_time_axis.h"
66 #include "automation_time_axis.h"
67 #include "canvas_impl.h"
68 #include "crossfade_view.h"
70 #include "gui_thread.h"
72 #include "playlist_selector.h"
73 #include "point_selection.h"
75 #include "public_editor.h"
76 #include "region_view.h"
77 #include "rgb_macros.h"
78 #include "selection.h"
79 #include "simplerect.h"
80 #include "streamview.h"
82 #include "route_group_menu.h"
84 #include "ardour/track.h"
88 using namespace ARDOUR;
90 using namespace Gtkmm2ext;
92 using namespace Editing;
95 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
98 RouteTimeAxisView::setup_slider_pix ()
100 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
101 throw failed_constructor ();
105 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, boost::shared_ptr<Route> rt, Canvas& canvas)
108 , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
109 , parent_canvas (canvas)
110 , button_table (3, 3)
111 , route_group_button (_("g"))
112 , playlist_button (_("p"))
113 , size_button (_("h"))
114 , automation_button (_("a"))
115 , visual_button (_("v"))
116 , gm (sess, slider, true, 115)
117 , _ignore_track_mode_change (false)
119 gm.set_controls (_route, _route->shared_peak_meter(), _route->amp());
120 gm.get_level_meter().set_no_show_all();
121 gm.get_level_meter().setup_meters(50);
125 playlist_action_menu = 0;
126 automation_action_menu = 0;
127 plugins_submenu_item = 0;
131 if (!_route->is_hidden()) {
132 _marked_for_display = true;
138 timestretch_rect = 0;
140 destructive_track_mode_item = 0;
141 normal_track_mode_item = 0;
142 non_layered_track_mode_item = 0;
144 ignore_toggle = false;
146 route_group_button.set_name ("TrackGroupButton");
147 playlist_button.set_name ("TrackPlaylistButton");
148 automation_button.set_name ("TrackAutomationButton");
149 size_button.set_name ("TrackSizeButton");
150 visual_button.set_name ("TrackVisualButton");
151 hide_button.set_name ("TrackRemoveButton");
153 route_group_button.unset_flags (Gtk::CAN_FOCUS);
154 playlist_button.unset_flags (Gtk::CAN_FOCUS);
155 automation_button.unset_flags (Gtk::CAN_FOCUS);
156 size_button.unset_flags (Gtk::CAN_FOCUS);
157 visual_button.unset_flags (Gtk::CAN_FOCUS);
158 hide_button.unset_flags (Gtk::CAN_FOCUS);
160 hide_button.add (*(manage (new Image (::get_icon("hide")))));
161 hide_button.show_all ();
163 route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::edit_click), false);
164 playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
165 automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
166 size_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::size_click), false);
167 visual_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::visual_click));
168 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::hide_click));
174 rec_enable_button->remove ();
176 switch (track()->mode()) {
178 case ARDOUR::NonLayered:
179 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
181 case ARDOUR::Destructive:
182 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
185 rec_enable_button->show_all ();
187 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
188 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record"));
190 rec_enable_button->set_sensitive (_session->writable());
193 controls_hbox.pack_start(gm.get_level_meter(), false, false);
194 _route->meter_change.connect (*this, invalidator (*this), bind (&RouteTimeAxisView::meter_changed, this), gui_context());
195 _route->input()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
196 _route->output()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
198 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
200 if (!_route->is_master()) {
201 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
204 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
205 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
207 ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
208 ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
209 ARDOUR_UI::instance()->set_tip(route_group_button, _("Route Group"));
210 ARDOUR_UI::instance()->set_tip(size_button,_("Display Height"));
211 ARDOUR_UI::instance()->set_tip(playlist_button,_("Playlist"));
212 ARDOUR_UI::instance()->set_tip(automation_button, _("Automation"));
213 ARDOUR_UI::instance()->set_tip(visual_button, _("Visual options"));
214 ARDOUR_UI::instance()->set_tip(hide_button, _("Hide this track"));
220 /* old school - when we used to put an extra row of buttons in place */
222 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
223 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
224 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
225 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
229 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
232 if (is_track() && track()->mode() == ARDOUR::Normal) {
233 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
238 _route->processors_changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
239 _route->PropertyChanged.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::route_property_changed, this, _1), gui_context());
243 track()->TrackModeChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
244 track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
245 track()->DiskstreamChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::diskstream_changed, this), gui_context());
246 get_diskstream()->SpeedChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
248 /* pick up the correct freeze state */
253 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
254 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
256 PropertyList* plist = new PropertyList();
258 plist->add (ARDOUR::Properties::edit, true);
259 plist->add (ARDOUR::Properties::mute, true);
260 plist->add (ARDOUR::Properties::solo, true);
262 route_group_menu = new RouteGroupMenu (_session, plist);
263 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
265 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
266 gm.get_gain_slider().set_name ("TrackGainFader");
269 RouteTimeAxisView::~RouteTimeAxisView ()
271 CatchDeletion (this);
273 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
277 delete playlist_menu;
280 delete playlist_action_menu;
281 playlist_action_menu = 0;
286 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
290 _automation_tracks.clear ();
292 delete route_group_menu;
296 RouteTimeAxisView::post_construct ()
298 /* map current state of the route */
300 update_diskstream_display ();
302 subplugin_menu.items().clear ();
303 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
304 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
305 reset_processor_automation_curves ();
309 RouteTimeAxisView::edit_click (GdkEventButton *ev)
311 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
312 if (_route->route_group()) {
313 _route->route_group()->remove (_route);
318 route_group_menu->rebuild (_route->route_group ());
319 route_group_menu->popup (ev->button, ev->time);
325 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
330 if (_route->route_group()) {
331 _route->route_group()->remove (_route);
337 RouteTimeAxisView::playlist_changed ()
343 RouteTimeAxisView::label_view ()
345 string x = _route->name();
347 if (x != name_entry.get_text()) {
348 name_entry.set_text (x);
351 ARDOUR_UI::instance()->set_tip (name_entry, x);
355 RouteTimeAxisView::route_property_changed (const PropertyChange& what_changed)
357 if (what_changed.contains (ARDOUR::Properties::name)) {
363 RouteTimeAxisView::take_name_changed (void *src)
372 RouteTimeAxisView::playlist_click ()
374 // always build a new action menu
376 delete playlist_action_menu;
378 playlist_action_menu = new Menu;
379 playlist_action_menu->set_name ("ArdourContextMenu");
381 build_playlist_menu (playlist_action_menu);
383 conditionally_add_to_selection ();
384 playlist_action_menu->popup (1, gtk_get_current_event_time());
388 RouteTimeAxisView::automation_click ()
390 conditionally_add_to_selection ();
391 build_automation_action_menu ();
392 automation_action_menu->popup (1, gtk_get_current_event_time());
396 RouteTimeAxisView::set_state (const XMLNode& node, int version)
398 TimeAxisView::set_state (node, version);
400 XMLNodeList kids = node.children();
401 XMLNodeConstIterator iter;
402 const XMLProperty* prop;
404 if (_view && (prop = node.property ("layer-display"))) {
405 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
408 for (iter = kids.begin(); iter != kids.end(); ++iter) {
409 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
410 if ((prop = (*iter)->property ("automation-id")) != 0) {
412 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
413 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
414 create_automation_child(param, show);
416 warning << "Automation child has no ID" << endmsg;
425 RouteTimeAxisView::build_automation_action_menu ()
427 using namespace Menu_Helpers;
429 delete automation_action_menu;
430 automation_action_menu = new Menu;
432 MenuList& items = automation_action_menu->items();
434 automation_action_menu->set_name ("ArdourContextMenu");
436 items.push_back (MenuElem (_("Show All Automation"),
437 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
439 items.push_back (MenuElem (_("Show Existing Automation"),
440 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
442 items.push_back (MenuElem (_("Hide All Automation"),
443 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
445 /* attach the plugin submenu. It may have previously been used elsewhere, so we detach it first. */
447 detach_menu (subplugin_menu);
448 items.push_back (MenuElem (_("Plugins"), subplugin_menu));
449 items.back().set_sensitive (!subplugin_menu.items().empty());
453 RouteTimeAxisView::build_display_menu ()
455 using namespace Menu_Helpers;
457 /* get the size menu ready */
463 TimeAxisView::build_display_menu ();
465 /* now fill it with our stuff */
467 MenuList& items = display_menu->items();
468 display_menu->set_name ("ArdourContextMenu");
470 items.push_back (MenuElem (_("Height"), *size_menu));
471 items.push_back (MenuElem (_("Color"), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
473 items.push_back (SeparatorElem());
475 if (!Profile->get_sae()) {
476 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
477 /* rebuild this every time */
478 build_automation_action_menu ();
479 detach_menu (*automation_action_menu);
480 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
481 items.push_back (SeparatorElem());
484 // Hook for derived classes to add type specific stuff
485 append_extra_display_menu_items ();
486 items.push_back (SeparatorElem());
490 Menu *layers_menu = manage(new Menu);
491 MenuList &layers_items = layers_menu->items();
492 layers_menu->set_name("ArdourContextMenu");
494 RadioMenuItem::Group layers_group;
496 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
497 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
498 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
499 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
501 items.push_back (MenuElem (_("Layers"), *layers_menu));
503 Menu* alignment_menu = manage (new Menu);
504 MenuList& alignment_items = alignment_menu->items();
505 alignment_menu->set_name ("ArdourContextMenu");
507 RadioMenuItem::Group align_group;
509 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material"),
510 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
511 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
512 if (get_diskstream()->alignment_style() == ExistingMaterial)
513 align_existing_item->set_active();
515 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time"),
516 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
517 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
518 if (get_diskstream()->alignment_style() == CaptureTime)
519 align_capture_item->set_active();
521 if (!Profile->get_sae()) {
523 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
524 get_diskstream()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
526 RadioMenuItem::Group mode_group;
527 items.push_back (RadioMenuElem (mode_group, _("Normal Mode"), sigc::bind (
528 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
530 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
532 items.push_back (RadioMenuElem (mode_group, _("Tape Mode"), sigc::bind (
533 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
534 ARDOUR::Destructive)));
535 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
537 items.push_back (RadioMenuElem (mode_group, _("Non-Layered Mode"),
538 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
539 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
542 _ignore_track_mode_change = true;
544 switch (track()->mode()) {
545 case ARDOUR::Destructive:
546 destructive_track_mode_item->set_active ();
549 normal_track_mode_item->set_active ();
551 case ARDOUR::NonLayered:
552 non_layered_track_mode_item->set_active ();
556 _ignore_track_mode_change = false;
559 get_diskstream()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
561 color_mode_menu = build_color_mode_menu();
562 if (color_mode_menu) {
563 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
566 items.push_back (SeparatorElem());
569 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
570 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
571 route_active_menu_item->set_active (_route->active());
573 items.push_back (SeparatorElem());
574 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &RouteTimeAxisView::hide_click)));
575 if (!Profile->get_sae()) {
576 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
578 items.push_front (SeparatorElem());
579 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
583 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
586 item_2->set_active ();
591 RouteTimeAxisView::set_track_mode (TrackMode mode)
593 if (_ignore_track_mode_change) {
598 RadioMenuItem* other_item;
599 RadioMenuItem* other_item_2;
603 item = normal_track_mode_item;
604 other_item = non_layered_track_mode_item;
605 other_item_2 = destructive_track_mode_item;
607 case ARDOUR::NonLayered:
608 item = non_layered_track_mode_item;
609 other_item = normal_track_mode_item;
610 other_item_2 = destructive_track_mode_item;
612 case ARDOUR::Destructive:
613 item = destructive_track_mode_item;
614 other_item = normal_track_mode_item;
615 other_item_2 = non_layered_track_mode_item;
618 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
623 if (item && other_item && other_item_2 && track()->mode() != mode) {
624 _set_track_mode (track().get(), mode, other_item, other_item_2);
629 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
633 if (!track->can_use_mode (mode, needs_bounce)) {
637 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
640 cerr << "would bounce this one\n";
641 /* XXX: radio menu item becomes inconsistent with track state in this case */
646 track->set_mode (mode);
648 rec_enable_button->remove ();
651 case ARDOUR::NonLayered:
653 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
655 case ARDOUR::Destructive:
656 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
660 rec_enable_button->show_all ();
664 RouteTimeAxisView::track_mode_changed ()
668 switch (track()->mode()) {
670 item = normal_track_mode_item;
672 case ARDOUR::NonLayered:
673 item = non_layered_track_mode_item;
675 case ARDOUR::Destructive:
676 item = destructive_track_mode_item;
679 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
688 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
694 TimeAxisView::show_timestretch (start, end);
704 /* check that the time selection was made in our route, or our route group.
705 remember that route_group() == 0 implies the route is *not* in a edit group.
708 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
709 /* this doesn't apply to us */
713 /* ignore it if our edit group is not active */
715 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
720 if (timestretch_rect == 0) {
721 timestretch_rect = new SimpleRect (*canvas_display ());
722 timestretch_rect->property_x1() = 0.0;
723 timestretch_rect->property_y1() = 0.0;
724 timestretch_rect->property_x2() = 0.0;
725 timestretch_rect->property_y2() = 0.0;
726 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
727 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
730 timestretch_rect->show ();
731 timestretch_rect->raise_to_top ();
733 x1 = start / _editor.get_current_zoom();
734 x2 = (end - 1) / _editor.get_current_zoom();
735 y2 = current_height() - 2;
737 timestretch_rect->property_x1() = x1;
738 timestretch_rect->property_y1() = 1.0;
739 timestretch_rect->property_x2() = x2;
740 timestretch_rect->property_y2() = y2;
744 RouteTimeAxisView::hide_timestretch ()
746 TimeAxisView::hide_timestretch ();
748 if (timestretch_rect) {
749 timestretch_rect->hide ();
754 RouteTimeAxisView::show_selection (TimeSelection& ts)
758 /* ignore it if our edit group is not active or if the selection was started
759 in some other track or route group (remember that route_group() == 0 means
760 that the track is not in an route group).
763 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
764 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
770 TimeAxisView::show_selection (ts);
774 RouteTimeAxisView::set_height (uint32_t h)
777 bool height_changed = (height == 0) || (h != height);
778 gm.get_level_meter().setup_meters (gmlen);
780 TimeAxisView::set_height (h);
785 _view->set_height ((double) current_height());
789 snprintf (buf, sizeof (buf), "%u", height);
790 xml_node->add_property ("height", buf);
792 if (height >= hNormal) {
797 gm.get_gain_slider().show();
799 if (!_route || _route->is_monitor()) {
804 if (rec_enable_button)
805 rec_enable_button->show();
807 route_group_button.show();
809 visual_button.show();
811 automation_button.show();
813 if (is_track() && track()->mode() == ARDOUR::Normal) {
814 playlist_button.show();
817 } else if (height >= hSmaller) {
823 gm.get_gain_slider().hide();
825 if (!_route || _route->is_monitor()) {
830 if (rec_enable_button)
831 rec_enable_button->show();
833 route_group_button.hide ();
835 visual_button.hide ();
837 automation_button.hide ();
839 if (is_track() && track()->mode() == ARDOUR::Normal) {
840 playlist_button.hide ();
846 /* don't allow name_entry to be hidden while
847 it has focus, otherwise the GUI becomes unusable.
850 if (name_entry.has_focus()) {
851 if (name_entry.get_text() != _route->name()) {
852 name_entry_changed ();
854 controls_ebox.grab_focus ();
860 gm.get_gain_slider().hide();
863 if (rec_enable_button)
864 rec_enable_button->hide();
866 route_group_button.hide ();
868 visual_button.hide ();
870 automation_button.hide ();
871 playlist_button.hide ();
872 name_label.set_text (_route->name());
875 if (height_changed && !no_redraw) {
876 /* only emit the signal if the height really changed */
877 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
882 RouteTimeAxisView::select_track_color ()
884 if (RouteUI::choose_color ()) {
887 _view->apply_color (_color, StreamView::RegionColor);
893 RouteTimeAxisView::reset_samples_per_unit ()
895 set_samples_per_unit (_editor.get_current_zoom());
899 RouteTimeAxisView::set_samples_per_unit (double spu)
903 if (get_diskstream() != 0) {
904 speed = get_diskstream()->speed();
908 _view->set_samples_per_unit (spu * speed);
911 TimeAxisView::set_samples_per_unit (spu * speed);
915 RouteTimeAxisView::align_style_changed ()
917 switch (get_diskstream()->alignment_style()) {
918 case ExistingMaterial:
919 if (!align_existing_item->get_active()) {
920 align_existing_item->set_active();
924 if (!align_capture_item->get_active()) {
925 align_capture_item->set_active();
932 RouteTimeAxisView::set_align_style (AlignStyle style)
937 case ExistingMaterial:
938 item = align_existing_item;
941 item = align_capture_item;
944 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
949 if (item->get_active()) {
950 get_diskstream()->set_align_style (style);
955 RouteTimeAxisView::rename_current_playlist ()
957 ArdourPrompter prompter (true);
960 boost::shared_ptr<Diskstream> ds = get_diskstream();
961 if (!ds || ds->destructive())
964 boost::shared_ptr<Playlist> pl = ds->playlist();
968 prompter.set_prompt (_("Name for playlist"));
969 prompter.set_initial_text (pl->name());
970 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
971 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
973 switch (prompter.run ()) {
974 case Gtk::RESPONSE_ACCEPT:
975 prompter.get_result (name);
987 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
989 std::string ret (basename);
991 std::string const group_string = "." + route_group()->name() + ".";
993 // iterate through all playlists
995 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
996 std::string tmp = (*i)->name();
998 std::string::size_type idx = tmp.find(group_string);
999 // find those which belong to this group
1000 if (idx != string::npos) {
1001 tmp = tmp.substr(idx + group_string.length());
1003 // and find the largest current number
1004 int x = atoi(tmp.c_str());
1005 if (x > maxnumber) {
1014 snprintf (buf, sizeof(buf), "%d", maxnumber);
1016 ret = this->name() + "." + route_group()->name () + "." + buf;
1022 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1026 boost::shared_ptr<Diskstream> ds = get_diskstream();
1027 if (!ds || ds->destructive())
1030 boost::shared_ptr<const Playlist> pl = ds->playlist();
1036 if (route_group() && route_group()->is_active()) {
1037 name = resolve_new_group_playlist_name(name, playlists_before_op);
1040 while (_session->playlists->by_name(name)) {
1041 name = Playlist::bump_name (name, *_session);
1044 // TODO: The prompter "new" button should be de-activated if the user
1045 // specifies a playlist name which already exists in the session.
1049 ArdourPrompter prompter (true);
1051 prompter.set_prompt (_("Name for Playlist"));
1052 prompter.set_initial_text (name);
1053 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1054 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1055 prompter.show_all ();
1057 switch (prompter.run ()) {
1058 case Gtk::RESPONSE_ACCEPT:
1059 prompter.get_result (name);
1067 if (name.length()) {
1068 ds->use_copy_playlist ();
1069 ds->playlist()->set_name (name);
1074 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1078 boost::shared_ptr<Diskstream> ds = get_diskstream();
1079 if (!ds || ds->destructive())
1082 boost::shared_ptr<const Playlist> pl = ds->playlist();
1088 if (route_group() && route_group()->is_active()) {
1089 name = resolve_new_group_playlist_name(name,playlists_before_op);
1092 while (_session->playlists->by_name(name)) {
1093 name = Playlist::bump_name (name, *_session);
1099 ArdourPrompter prompter (true);
1101 prompter.set_prompt (_("Name for Playlist"));
1102 prompter.set_initial_text (name);
1103 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1104 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1106 switch (prompter.run ()) {
1107 case Gtk::RESPONSE_ACCEPT:
1108 prompter.get_result (name);
1116 if (name.length()) {
1117 ds->use_new_playlist ();
1118 ds->playlist()->set_name (name);
1123 RouteTimeAxisView::clear_playlist ()
1125 boost::shared_ptr<Diskstream> ds = get_diskstream();
1126 if (!ds || ds->destructive())
1129 boost::shared_ptr<Playlist> pl = ds->playlist();
1133 _editor.clear_playlist (pl);
1137 RouteTimeAxisView::speed_changed ()
1139 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1143 RouteTimeAxisView::diskstream_changed ()
1145 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::update_diskstream_display, this));
1149 RouteTimeAxisView::update_diskstream_display ()
1151 if (!get_diskstream()) // bus
1158 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1160 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1162 /* special case: select/deselect all tracks */
1163 if (_editor.get_selection().selected (this)) {
1164 _editor.get_selection().clear_tracks ();
1166 _editor.select_all_tracks ();
1172 switch (ArdourKeyboard::selection_type (ev->state)) {
1173 case Selection::Toggle:
1174 _editor.get_selection().toggle (this);
1177 case Selection::Set:
1178 _editor.get_selection().set (this);
1181 case Selection::Extend:
1182 _editor.extend_selection_to_track (*this);
1185 case Selection::Add:
1186 _editor.get_selection().add (this);
1192 RouteTimeAxisView::set_selected_points (PointSelection& points)
1194 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1195 (*i)->set_selected_points (points);
1200 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1203 _view->set_selected_regionviews (regions);
1207 /** Add the selectable things that we have to a list.
1208 * @param results List to add things to.
1211 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1215 if (get_diskstream() != 0) {
1216 speed = get_diskstream()->speed();
1219 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1220 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1222 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1223 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1226 /* pick up visible automation tracks */
1228 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1229 if (!(*i)->hidden()) {
1230 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1236 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1239 _view->get_inverted_selectables (sel, results);
1242 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1243 if (!(*i)->hidden()) {
1244 (*i)->get_inverted_selectables (sel, results);
1252 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1254 return (_show_automation.find(param) != _show_automation.end());
1257 /** Retuns 0 if track for \a param doesn't exist.
1259 RouteTimeAxisView::RouteAutomationNode*
1260 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1262 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1264 if (i != _automation_tracks.end()) {
1271 /** Shorthand for GainAutomation, etc.
1273 RouteTimeAxisView::RouteAutomationNode*
1274 RouteTimeAxisView::automation_track (AutomationType type)
1276 return automation_track (Evoral::Parameter(type));
1280 RouteTimeAxisView::route_group () const
1282 return _route->route_group();
1286 RouteTimeAxisView::name() const
1288 return _route->name();
1291 boost::shared_ptr<Playlist>
1292 RouteTimeAxisView::playlist () const
1294 boost::shared_ptr<Diskstream> ds;
1296 if ((ds = get_diskstream()) != 0) {
1297 return ds->playlist();
1299 return boost::shared_ptr<Playlist> ();
1304 RouteTimeAxisView::name_entry_changed ()
1308 x = name_entry.get_text ();
1310 if (x == _route->name()) {
1314 strip_whitespace_edges(x);
1316 if (x.length() == 0) {
1317 name_entry.set_text (_route->name());
1321 if (!_session->route_name_unique (x)) {
1322 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1323 name_entry.set_text (_route->name());
1324 } else if (_session->route_name_internal (x)) {
1325 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1326 name_entry.set_text (_route->name());
1328 _route->set_name (x);
1333 RouteTimeAxisView::visual_click ()
1335 popup_display_menu (0);
1339 RouteTimeAxisView::hide_click ()
1341 // LAME fix for hide_button refresh fix
1342 hide_button.set_sensitive(false);
1344 _editor.hide_track_in_display (*this);
1346 hide_button.set_sensitive(true);
1349 boost::shared_ptr<Region>
1350 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, 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 (pos, point, dir);
1359 return boost::shared_ptr<Region> ();
1363 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1365 boost::shared_ptr<Diskstream> stream;
1366 boost::shared_ptr<Playlist> playlist;
1368 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1369 return playlist->find_next_region_boundary (pos, dir);
1376 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1378 boost::shared_ptr<Playlist> what_we_got;
1379 boost::shared_ptr<Diskstream> ds = get_diskstream();
1380 boost::shared_ptr<Playlist> playlist;
1384 /* route is a bus, not a track */
1388 playlist = ds->playlist();
1390 TimeSelection time (selection.time);
1391 float speed = ds->speed();
1392 if (speed != 1.0f) {
1393 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1394 (*i).start = session_frame_to_track_frame((*i).start, speed);
1395 (*i).end = session_frame_to_track_frame((*i).end, speed);
1399 playlist->clear_history ();
1400 playlist->clear_owned_history ();
1404 if ((what_we_got = playlist->cut (time)) != 0) {
1405 _editor.get_cut_buffer().add (what_we_got);
1407 vector<StatefulDiffCommand*> cmds;
1409 playlist->rdiff (cmds);
1411 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1412 _session->add_command (*c);
1414 _session->add_command (new StatefulDiffCommand (playlist));
1419 if ((what_we_got = playlist->copy (time)) != 0) {
1420 _editor.get_cut_buffer().add (what_we_got);
1425 if ((what_we_got = playlist->cut (time)) != 0) {
1426 vector<StatefulDiffCommand*> cmds;
1428 playlist->rdiff (cmds);
1430 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1431 _session->add_command (*c);
1433 _session->add_command (new StatefulDiffCommand (playlist));
1434 what_we_got->release ();
1444 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1450 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1451 PlaylistSelection::iterator p;
1453 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1455 if (p == selection.playlists.end()) {
1459 if (get_diskstream()->speed() != 1.0f) {
1460 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1463 playlist->clear_history ();
1464 playlist->paste (*p, pos, times);
1465 _session->add_command (new StatefulDiffCommand (playlist));
1471 TimeAxisView::Children
1472 RouteTimeAxisView::get_child_list()
1474 TimeAxisView::Children redirect_children;
1476 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1477 if (!(*i)->hidden()) {
1478 redirect_children.push_back(*i);
1481 return redirect_children;
1485 struct PlaylistSorter {
1486 bool operator() (boost::shared_ptr<Playlist> a, boost::shared_ptr<Playlist> b) const {
1487 return a->sort_id() < b->sort_id();
1492 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1494 using namespace Menu_Helpers;
1496 if (!menu || !is_track()) {
1500 MenuList& playlist_items = menu->items();
1501 menu->set_name ("ArdourContextMenu");
1502 playlist_items.clear();
1504 delete playlist_menu;
1507 vector<boost::shared_ptr<Playlist> > playlists, playlists_ds;
1508 boost::shared_ptr<Diskstream> ds = get_diskstream();
1509 RadioMenuItem::Group playlist_group;
1511 _session->playlists->get (playlists);
1513 /* find the playlists for this diskstream */
1514 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1515 if (((*i)->get_orig_diskstream_id() == ds->id()) || (ds->playlist()->id() == (*i)->id())) {
1516 playlists_ds.push_back(*i);
1520 /* sort the playlists */
1522 sort(playlists_ds.begin(), playlists_ds.end(), cmp);
1524 /* add the playlists to the menu */
1525 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_ds.begin(); i != playlists_ds.end(); ++i) {
1526 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name()));
1527 RadioMenuItem *item = static_cast<RadioMenuItem*>(&playlist_items.back());
1528 item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr<Playlist> (*i)));
1530 if (ds->playlist()->id() == (*i)->id()) {
1536 playlist_items.push_back (SeparatorElem());
1537 playlist_items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1538 playlist_items.push_back (SeparatorElem());
1540 if (!route_group() || !route_group()->is_active()) {
1541 playlist_items.push_back (MenuElem (_("New"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1542 playlist_items.push_back (MenuElem (_("New Copy"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1545 // Use a label which tells the user what is happening
1546 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1547 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1551 playlist_items.push_back (SeparatorElem());
1552 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1553 playlist_items.push_back (SeparatorElem());
1555 playlist_items.push_back (MenuElem(_("Select from all ..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1559 RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr<Playlist> wpl)
1561 assert (is_track());
1563 // exit if we were triggered by deactivating the old playlist
1564 if (!item->get_active()) {
1568 boost::shared_ptr<Playlist> pl (wpl.lock());
1574 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1577 if (get_diskstream()->playlist() == apl) {
1578 // exit when use_playlist is called by the creation of the playlist menu
1579 // or the playlist choice is unchanged
1582 get_diskstream()->use_playlist (apl);
1585 if (route_group() && route_group()->is_active()) {
1586 std::string group_string = "."+route_group()->name()+".";
1588 std::string take_name = apl->name();
1589 std::string::size_type idx = take_name.find(group_string);
1591 if (idx == std::string::npos)
1594 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1596 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1598 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1599 if ( (*i) == this->route()) {
1603 std::string playlist_name = (*i)->name()+group_string+take_name;
1605 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1607 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1611 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1613 // No playlist for this track for this take yet, make it
1614 track->diskstream()->use_new_playlist();
1615 track->diskstream()->playlist()->set_name(playlist_name);
1617 track->diskstream()->use_playlist(ipl);
1625 RouteTimeAxisView::show_playlist_selector ()
1627 _editor.playlist_selector().show_for (this);
1631 RouteTimeAxisView::map_frozen ()
1637 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1639 switch (track()->freeze_state()) {
1641 playlist_button.set_sensitive (false);
1642 rec_enable_button->set_sensitive (false);
1645 playlist_button.set_sensitive (true);
1646 rec_enable_button->set_sensitive (true);
1652 RouteTimeAxisView::color_handler ()
1654 //case cTimeStretchOutline:
1655 if (timestretch_rect) {
1656 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1658 //case cTimeStretchFill:
1659 if (timestretch_rect) {
1660 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1666 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1667 * Will add track if necessary.
1670 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1672 RouteAutomationNode* node = automation_track(param);
1675 /* it doesn't exist yet, so we don't care about the button state: just add it */
1676 create_automation_child (param, true);
1678 bool yn = node->menu_item->get_active();
1679 if (node->track->set_visibility (node->menu_item->get_active()) && yn) {
1681 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1682 will have done that for us.
1686 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1693 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1695 RouteAutomationNode* ran = automation_track(param);
1701 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1702 _show_automation.erase (param);
1703 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1705 if (ran->menu_item && !_hidden) {
1706 ignore_toggle = true;
1707 ran->menu_item->set_active (false);
1708 ignore_toggle = false;
1711 if (_route && !no_redraw) {
1712 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1718 RouteTimeAxisView::show_all_automation ()
1722 /* Show our automation */
1724 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1725 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1726 i->second->track->set_marked_for_display (true);
1727 i->second->track->canvas_display()->show();
1728 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1729 if (i->second->menu_item) {
1730 i->second->menu_item->set_active(true);
1735 /* Show processor automation */
1737 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1738 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1739 if ((*ii)->view == 0) {
1740 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1743 (*ii)->menu_item->set_active (true);
1751 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1755 RouteTimeAxisView::show_existing_automation ()
1759 /* Show our automation */
1761 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1762 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1763 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1764 i->second->track->set_marked_for_display (true);
1765 i->second->track->canvas_display()->show();
1766 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1767 i->second->menu_item->set_active(true);
1772 /* Show processor automation */
1774 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1775 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1776 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1777 (*ii)->menu_item->set_active (true);
1784 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1788 RouteTimeAxisView::hide_all_automation ()
1792 /* Hide our automation */
1794 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1795 i->second->track->set_marked_for_display (false);
1796 i->second->track->hide ();
1797 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1798 if (i->second->menu_item) {
1799 i->second->menu_item->set_active (false);
1803 /* Hide processor automation */
1805 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1806 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1807 (*ii)->menu_item->set_active (false);
1811 _show_automation.clear();
1814 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1819 RouteTimeAxisView::region_view_added (RegionView* rv)
1821 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1822 if (is_audio_track()) {
1823 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1824 boost::shared_ptr<AutomationTimeAxisView> atv;
1826 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1832 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1833 (*i)->add_ghost(rv);
1837 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1839 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1845 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1847 parent.remove_processor_automation_node (this);
1851 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1854 remove_child (pan->view);
1858 RouteTimeAxisView::ProcessorAutomationNode*
1859 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1861 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1863 if ((*i)->processor == processor) {
1865 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1866 if ((*ii)->what == what) {
1877 legalize_for_xml_node (string str)
1879 string::size_type pos;
1880 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1886 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1887 legal.replace (pos, 1, "_");
1896 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1899 ProcessorAutomationNode* pan;
1901 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1902 error << _("programming error: ")
1903 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1904 processor->name(), what)
1914 name = processor->describe_parameter (what);
1916 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1920 char state_name[256];
1921 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1923 boost::shared_ptr<AutomationControl> control
1924 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1926 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1927 new AutomationTimeAxisView (_session, _route, processor, control,
1928 _editor, *this, false, parent_canvas, name, state_name));
1930 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1932 if (!pan->view->marked_for_display()) {
1935 pan->menu_item->set_active (true);
1938 add_child (pan->view);
1941 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1944 processor->mark_automation_visible (what, true);
1948 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1951 pan->menu_item->set_active (false);
1954 i->mark_automation_visible (pan->what, false);
1957 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1962 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1964 boost::shared_ptr<Processor> processor (p.lock ());
1969 set<Evoral::Parameter> s;
1970 boost::shared_ptr<AutomationLine> al;
1972 processor->what_has_visible_data (s);
1974 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1976 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1979 add_processor_automation_curve (processor, (*i));
1985 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1987 using namespace Menu_Helpers;
1994 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1996 bool hideit = (!show);
1998 if ((node = track->get_state_node()) != 0) {
1999 if ((prop = node->property ("shown")) != 0) {
2000 if (string_is_affirmative (prop->value())) {
2006 _automation_tracks.insert (std::make_pair (param, new RouteAutomationNode(param, NULL, track)));
2008 track->set_visibility (!hideit);
2011 _show_automation.insert (param);
2015 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2018 if (!EventTypeMap::instance().is_midi_parameter(param)) {
2019 /* MIDI-related parameters are always in the menu, there's no
2020 reason to rebuild the menu just because we added a automation
2021 lane for one of them. But if we add a non-MIDI automation
2022 lane, then we need to invalidate the display menu.
2024 delete display_menu;
2030 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
2032 boost::shared_ptr<Processor> processor (p.lock ());
2034 if (!processor || !processor->display_to_user ()) {
2038 using namespace Menu_Helpers;
2039 ProcessorAutomationInfo *rai;
2040 list<ProcessorAutomationInfo*>::iterator x;
2042 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2043 std::set<Evoral::Parameter> has_visible_automation;
2045 processor->what_has_visible_data(has_visible_automation);
2047 if (automatable.empty()) {
2051 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2052 if ((*x)->processor == processor) {
2057 if (x == processor_automation.end()) {
2059 rai = new ProcessorAutomationInfo (processor);
2060 processor_automation.push_back (rai);
2068 /* any older menu was deleted at the top of processors_changed()
2069 when we cleared the subplugin menu.
2072 rai->menu = manage (new Menu);
2073 MenuList& items = rai->menu->items();
2074 rai->menu->set_name ("ArdourContextMenu");
2078 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2080 ProcessorAutomationNode* pan;
2081 CheckMenuItem* mitem;
2083 string name = processor->describe_parameter (*i);
2085 items.push_back (CheckMenuElem (name));
2086 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2088 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2089 mitem->set_active(true);
2092 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2096 pan = new ProcessorAutomationNode (*i, mitem, *this);
2098 rai->lines.push_back (pan);
2102 pan->menu_item = mitem;
2106 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2109 /* add the menu for this processor, because the subplugin
2110 menu is always cleared at the top of processors_changed().
2111 this is the result of some poor design in gtkmm and/or
2115 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2120 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2121 RouteTimeAxisView::ProcessorAutomationNode* pan)
2123 bool showit = pan->menu_item->get_active();
2124 bool redraw = false;
2126 if (pan->view == 0 && showit) {
2127 add_processor_automation_curve (rai->processor, pan->what);
2131 if (pan->view && showit != pan->view->marked_for_display()) {
2134 pan->view->set_marked_for_display (true);
2135 pan->view->canvas_display()->show();
2136 pan->view->canvas_background()->show();
2138 rai->processor->mark_automation_visible (pan->what, true);
2139 pan->view->set_marked_for_display (false);
2147 if (redraw && !no_redraw) {
2148 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2154 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2156 if (c.type == RouteProcessorChange::MeterPointChange) {
2157 /* nothing to do if only the meter point has changed */
2161 using namespace Menu_Helpers;
2163 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2164 (*i)->valid = false;
2167 subplugin_menu.items().clear ();
2169 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2170 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2172 bool deleted_processor_automation = false;
2174 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2176 list<ProcessorAutomationInfo*>::iterator tmp;
2184 processor_automation.erase (i);
2185 deleted_processor_automation = true;
2192 if (deleted_processor_automation && !no_redraw) {
2193 _route->gui_changed ("track_height", this);
2197 boost::shared_ptr<AutomationLine>
2198 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2200 ProcessorAutomationNode* pan;
2202 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2208 return boost::shared_ptr<AutomationLine>();
2212 RouteTimeAxisView::reset_processor_automation_curves ()
2214 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2220 RouteTimeAxisView::update_rec_display ()
2222 RouteUI::update_rec_display ();
2223 name_entry.set_sensitive (!_route->record_enabled());
2227 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2230 _view->set_layer_display (d);
2234 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2238 RouteTimeAxisView::layer_display () const
2241 return _view->layer_display ();
2244 /* we don't know, since we don't have a _view, so just return something */
2250 boost::shared_ptr<AutomationTimeAxisView>
2251 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2253 AutomationTracks::iterator i = _automation_tracks.find(param);
2254 if (i != _automation_tracks.end()) {
2255 return i->second->track;
2257 return boost::shared_ptr<AutomationTimeAxisView>();
2262 RouteTimeAxisView::fast_update ()
2264 gm.get_level_meter().update_meters ();
2268 RouteTimeAxisView::hide_meter ()
2271 gm.get_level_meter().hide_meters ();
2275 RouteTimeAxisView::show_meter ()
2281 RouteTimeAxisView::reset_meter ()
2283 if (Config->get_show_track_meters()) {
2284 gm.get_level_meter().setup_meters (height-5);
2291 RouteTimeAxisView::clear_meter ()
2293 gm.get_level_meter().clear_meters ();
2297 RouteTimeAxisView::meter_changed ()
2299 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed)
2304 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2310 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2312 using namespace Menu_Helpers;
2314 if (!_underlay_streams.empty()) {
2315 MenuList& parent_items = parent_menu->items();
2316 Menu* gs_menu = manage (new Menu);
2317 gs_menu->set_name ("ArdourContextMenu");
2318 MenuList& gs_items = gs_menu->items();
2320 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2322 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2323 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2324 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2330 RouteTimeAxisView::set_underlay_state()
2332 if (!underlay_xml_node) {
2336 XMLNodeList nlist = underlay_xml_node->children();
2337 XMLNodeConstIterator niter;
2338 XMLNode *child_node;
2340 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2341 child_node = *niter;
2343 if (child_node->name() != "Underlay") {
2347 XMLProperty* prop = child_node->property ("id");
2349 PBD::ID id (prop->value());
2351 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2354 add_underlay(v->view(), false);
2363 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2369 RouteTimeAxisView& other = v->trackview();
2371 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2372 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2373 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2377 _underlay_streams.push_back(v);
2378 other._underlay_mirrors.push_back(this);
2380 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2383 if (!underlay_xml_node) {
2385 underlay_xml_node = xml_node->add_child("Underlays");
2388 XMLNode* node = underlay_xml_node->add_child("Underlay");
2389 XMLProperty* prop = node->add_property("id");
2390 prop->set_value(v->trackview().route()->id().to_s());
2396 RouteTimeAxisView::remove_underlay (StreamView* v)
2402 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2403 RouteTimeAxisView& other = v->trackview();
2405 if (it != _underlay_streams.end()) {
2406 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2408 if (gm == other._underlay_mirrors.end()) {
2409 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2413 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2415 _underlay_streams.erase(it);
2416 other._underlay_mirrors.erase(gm);
2418 if (underlay_xml_node) {
2419 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2425 RouteTimeAxisView::set_button_names ()
2427 rec_enable_button_label.set_text (_("r"));
2429 if (_route && _route->solo_safe()) {
2430 solo_button_label.set_text (X_("!"));
2432 if (Config->get_solo_control_is_listen_control()) {
2433 switch (Config->get_listen_position()) {
2434 case AfterFaderListen:
2435 solo_button_label.set_text (_("A"));
2437 case PreFaderListen:
2438 solo_button_label.set_text (_("P"));
2442 solo_button_label.set_text (_("s"));
2445 mute_button_label.set_text (_("m"));