2 Copyright (C) 2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include <sigc++/bind.h>
31 #include "pbd/error.h"
32 #include "pbd/stl_delete.h"
33 #include "pbd/whitespace.h"
34 #include "pbd/memento_command.h"
35 #include "pbd/enumwriter.h"
36 #include "pbd/stateful_diff_command.h"
38 #include <gtkmm/menu.h>
39 #include <gtkmm/menuitem.h>
40 #include <gtkmm2ext/gtk_ui.h>
41 #include <gtkmm2ext/selector.h>
42 #include <gtkmm2ext/bindable_button.h>
43 #include <gtkmm2ext/utils.h>
45 #include "ardour/amp.h"
46 #include "ardour/audioplaylist.h"
47 #include "ardour/diskstream.h"
48 #include "ardour/event_type_map.h"
49 #include "ardour/ladspa_plugin.h"
50 #include "ardour/location.h"
51 #include "ardour/panner.h"
52 #include "ardour/playlist.h"
53 #include "ardour/playlist.h"
54 #include "ardour/processor.h"
55 #include "ardour/profile.h"
56 #include "ardour/route_group.h"
57 #include "ardour/session.h"
58 #include "ardour/session_playlist.h"
59 #include "ardour/debug.h"
60 #include "ardour/utils.h"
61 #include "evoral/Parameter.hpp"
63 #include "ardour_ui.h"
64 #include "route_time_axis.h"
65 #include "automation_time_axis.h"
66 #include "canvas_impl.h"
67 #include "crossfade_view.h"
69 #include "gui_thread.h"
71 #include "playlist_selector.h"
72 #include "point_selection.h"
74 #include "public_editor.h"
75 #include "region_view.h"
76 #include "rgb_macros.h"
77 #include "selection.h"
78 #include "simplerect.h"
79 #include "streamview.h"
81 #include "route_group_menu.h"
83 #include "ardour/track.h"
87 using namespace ARDOUR;
89 using namespace Gtkmm2ext;
91 using namespace Editing;
94 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
97 RouteTimeAxisView::setup_slider_pix ()
99 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
100 throw failed_constructor ();
104 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, boost::shared_ptr<Route> rt, Canvas& canvas)
107 , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
108 , parent_canvas (canvas)
109 , button_table (3, 3)
110 , route_group_button (_("g"))
111 , playlist_button (_("p"))
112 , automation_button (_("a"))
113 , gm (sess, slider, true, 115)
114 , _ignore_track_mode_change (false)
116 gm.set_controls (_route, _route->shared_peak_meter(), _route->amp());
117 gm.get_level_meter().set_no_show_all();
118 gm.get_level_meter().setup_meters(50);
122 playlist_action_menu = 0;
123 automation_action_menu = 0;
124 plugins_submenu_item = 0;
128 if (!_route->is_hidden()) {
129 _marked_for_display = true;
133 update_solo_display ();
135 timestretch_rect = 0;
137 destructive_track_mode_item = 0;
138 normal_track_mode_item = 0;
139 non_layered_track_mode_item = 0;
141 ignore_toggle = false;
143 route_group_button.set_name ("TrackGroupButton");
144 playlist_button.set_name ("TrackPlaylistButton");
145 automation_button.set_name ("TrackAutomationButton");
147 route_group_button.unset_flags (Gtk::CAN_FOCUS);
148 playlist_button.unset_flags (Gtk::CAN_FOCUS);
149 automation_button.unset_flags (Gtk::CAN_FOCUS);
151 route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::route_group_click), false);
152 playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
153 automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
159 rec_enable_button->remove ();
161 switch (track()->mode()) {
163 case ARDOUR::NonLayered:
164 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
166 case ARDOUR::Destructive:
167 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
170 rec_enable_button->show_all ();
172 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
174 if (is_midi_track()) {
175 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record (Right-click for Step Edit)"));
177 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record"));
180 rec_enable_button->set_sensitive (_session->writable());
183 controls_hbox.pack_start(gm.get_level_meter(), false, false);
184 _route->meter_change.connect (*this, invalidator (*this), bind (&RouteTimeAxisView::meter_changed, this), gui_context());
185 _route->input()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
186 _route->output()->changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
188 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
190 if (!_route->is_master()) {
191 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
194 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
195 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
197 ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
198 ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
199 ARDOUR_UI::instance()->set_tip(route_group_button, _("Route Group"));
200 ARDOUR_UI::instance()->set_tip(playlist_button,_("Playlist"));
201 ARDOUR_UI::instance()->set_tip(automation_button, _("Automation"));
205 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
207 if (is_track() && track()->mode() == ARDOUR::Normal) {
208 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
213 _route->processors_changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
214 _route->PropertyChanged.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::route_property_changed, this, _1), gui_context());
218 track()->TrackModeChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
219 track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
220 track()->SpeedChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
222 /* pick up the correct freeze state */
227 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
228 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
230 PropertyList* plist = new PropertyList();
232 plist->add (ARDOUR::Properties::edit, true);
233 plist->add (ARDOUR::Properties::mute, true);
234 plist->add (ARDOUR::Properties::solo, true);
236 route_group_menu = new RouteGroupMenu (_session, plist);
237 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
239 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
240 gm.get_gain_slider().set_name ("TrackGainFader");
243 RouteTimeAxisView::~RouteTimeAxisView ()
245 CatchDeletion (this);
247 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
251 delete playlist_menu;
254 delete playlist_action_menu;
255 playlist_action_menu = 0;
260 _automation_tracks.clear ();
262 delete route_group_menu;
266 RouteTimeAxisView::post_construct ()
268 /* map current state of the route */
270 update_diskstream_display ();
272 _subplugin_menu_map.clear ();
273 subplugin_menu.items().clear ();
274 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
275 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
276 reset_processor_automation_curves ();
280 RouteTimeAxisView::route_group_click (GdkEventButton *ev)
282 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
283 if (_route->route_group()) {
284 _route->route_group()->remove (_route);
289 route_group_menu->rebuild (_route->route_group ());
290 route_group_menu->popup (ev->button, ev->time);
296 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
301 if (_route->route_group()) {
302 _route->route_group()->remove (_route);
308 RouteTimeAxisView::playlist_changed ()
314 RouteTimeAxisView::label_view ()
316 string x = _route->name();
318 if (x != name_entry.get_text()) {
319 name_entry.set_text (x);
322 ARDOUR_UI::instance()->set_tip (name_entry, x);
326 RouteTimeAxisView::route_property_changed (const PropertyChange& what_changed)
328 if (what_changed.contains (ARDOUR::Properties::name)) {
334 RouteTimeAxisView::take_name_changed (void *src)
343 RouteTimeAxisView::playlist_click ()
345 build_playlist_menu ();
346 conditionally_add_to_selection ();
347 playlist_action_menu->popup (1, gtk_get_current_event_time());
351 RouteTimeAxisView::automation_click ()
353 conditionally_add_to_selection ();
354 build_automation_action_menu ();
355 automation_action_menu->popup (1, gtk_get_current_event_time());
359 RouteTimeAxisView::set_state (const XMLNode& node, int version)
361 TimeAxisView::set_state (node, version);
363 XMLNodeList kids = node.children();
364 XMLNodeConstIterator iter;
365 const XMLProperty* prop;
367 if (_view && (prop = node.property ("layer-display"))) {
368 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
371 for (iter = kids.begin(); iter != kids.end(); ++iter) {
372 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
373 if ((prop = (*iter)->property ("automation-id")) != 0) {
375 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
376 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
377 create_automation_child(param, show);
379 warning << "Automation child has no ID" << endmsg;
388 RouteTimeAxisView::build_automation_action_menu ()
390 using namespace Menu_Helpers;
392 /* detach subplugin_menu from automation_action_menu before we delete automation_action_menu,
393 otherwise bad things happen (see comment for similar case in MidiTimeAxisView::build_automation_action_menu)
396 detach_menu (subplugin_menu);
398 _main_automation_menu_map.clear ();
399 delete automation_action_menu;
400 automation_action_menu = new Menu;
402 MenuList& items = automation_action_menu->items();
404 automation_action_menu->set_name ("ArdourContextMenu");
406 items.push_back (MenuElem (_("Show All Automation"),
407 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
409 items.push_back (MenuElem (_("Show Existing Automation"),
410 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
412 items.push_back (MenuElem (_("Hide All Automation"),
413 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
415 items.push_back (SeparatorElem ());
417 /* Attach the plugin submenu. It may have previously been used elsewhere,
418 so it was detached above */
420 items.push_back (MenuElem (_("Plugins"), subplugin_menu));
421 items.back().set_sensitive (!subplugin_menu.items().empty());
425 RouteTimeAxisView::build_display_menu ()
427 using namespace Menu_Helpers;
431 TimeAxisView::build_display_menu ();
433 /* now fill it with our stuff */
435 MenuList& items = display_menu->items();
436 display_menu->set_name ("ArdourContextMenu");
438 items.push_back (MenuElem (_("Color..."), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
440 items.push_back (SeparatorElem());
442 if (!Profile->get_sae()) {
443 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
444 /* rebuild this every time */
445 build_automation_action_menu ();
446 detach_menu (*automation_action_menu);
447 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
448 items.push_back (SeparatorElem());
451 // Hook for derived classes to add type specific stuff
452 append_extra_display_menu_items ();
453 items.push_back (SeparatorElem());
457 Menu *layers_menu = manage(new Menu);
458 MenuList &layers_items = layers_menu->items();
459 layers_menu->set_name("ArdourContextMenu");
461 RadioMenuItem::Group layers_group;
463 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
464 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
465 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
466 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
468 items.push_back (MenuElem (_("Layers"), *layers_menu));
470 if (!Profile->get_sae()) {
472 Menu* alignment_menu = manage (new Menu);
473 MenuList& alignment_items = alignment_menu->items();
474 alignment_menu->set_name ("ArdourContextMenu");
476 RadioMenuItem::Group align_group;
478 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material"),
479 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
480 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
481 if (track()->alignment_style() == ExistingMaterial) {
482 align_existing_item->set_active();
485 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time"),
486 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
487 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
488 if (track()->alignment_style() == CaptureTime) {
489 align_capture_item->set_active();
492 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
493 track()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
495 Menu* mode_menu = manage (new Menu);
496 MenuList& mode_items = mode_menu->items ();
497 mode_menu->set_name ("ArdourContextMenu");
499 RadioMenuItem::Group mode_group;
501 mode_items.push_back (RadioMenuElem (mode_group, _("Normal Mode"), sigc::bind (
502 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
504 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&mode_items.back());
506 mode_items.push_back (RadioMenuElem (mode_group, _("Tape Mode"), sigc::bind (
507 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
508 ARDOUR::Destructive)));
509 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&mode_items.back());
511 mode_items.push_back (RadioMenuElem (mode_group, _("Non-Layered Mode"),
512 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
513 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&mode_items.back());
516 _ignore_track_mode_change = true;
518 switch (track()->mode()) {
519 case ARDOUR::Destructive:
520 destructive_track_mode_item->set_active ();
523 normal_track_mode_item->set_active ();
525 case ARDOUR::NonLayered:
526 non_layered_track_mode_item->set_active ();
530 _ignore_track_mode_change = false;
532 items.push_back (MenuElem (_("Mode"), *mode_menu));
535 color_mode_menu = build_color_mode_menu();
536 if (color_mode_menu) {
537 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
540 items.push_back (SeparatorElem());
542 build_playlist_menu ();
543 items.push_back (MenuElem (_("Playlist"), *playlist_action_menu));
545 route_group_menu->rebuild (_route->route_group ());
546 items.push_back (MenuElem (_("Route Group"), *route_group_menu));
548 build_automation_action_menu ();
549 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
551 items.push_back (SeparatorElem());
554 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
555 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
556 route_active_menu_item->set_active (_route->active());
558 items.push_back (SeparatorElem());
559 items.push_back (MenuElem (_("Hide"), sigc::bind (sigc::mem_fun(_editor, &PublicEditor::hide_track_in_display), this, false)));
560 if (!Profile->get_sae()) {
561 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
563 items.push_front (SeparatorElem());
564 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
568 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
571 item_2->set_active ();
576 RouteTimeAxisView::set_track_mode (TrackMode mode)
578 if (_ignore_track_mode_change) {
583 RadioMenuItem* other_item;
584 RadioMenuItem* other_item_2;
588 item = normal_track_mode_item;
589 other_item = non_layered_track_mode_item;
590 other_item_2 = destructive_track_mode_item;
592 case ARDOUR::NonLayered:
593 item = non_layered_track_mode_item;
594 other_item = normal_track_mode_item;
595 other_item_2 = destructive_track_mode_item;
597 case ARDOUR::Destructive:
598 item = destructive_track_mode_item;
599 other_item = normal_track_mode_item;
600 other_item_2 = non_layered_track_mode_item;
603 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
608 if (item && other_item && other_item_2 && track()->mode() != mode) {
609 _set_track_mode (track().get(), mode, other_item, other_item_2);
614 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
618 if (!track->can_use_mode (mode, needs_bounce)) {
622 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
625 cerr << "would bounce this one\n";
626 /* XXX: radio menu item becomes inconsistent with track state in this case */
631 track->set_mode (mode);
633 rec_enable_button->remove ();
636 case ARDOUR::NonLayered:
638 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
640 case ARDOUR::Destructive:
641 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
645 rec_enable_button->show_all ();
649 RouteTimeAxisView::track_mode_changed ()
653 switch (track()->mode()) {
655 item = normal_track_mode_item;
657 case ARDOUR::NonLayered:
658 item = non_layered_track_mode_item;
660 case ARDOUR::Destructive:
661 item = destructive_track_mode_item;
664 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
673 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
679 TimeAxisView::show_timestretch (start, end);
689 /* check that the time selection was made in our route, or our route group.
690 remember that route_group() == 0 implies the route is *not* in a edit group.
693 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
694 /* this doesn't apply to us */
698 /* ignore it if our edit group is not active */
700 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
705 if (timestretch_rect == 0) {
706 timestretch_rect = new SimpleRect (*canvas_display ());
707 timestretch_rect->property_x1() = 0.0;
708 timestretch_rect->property_y1() = 0.0;
709 timestretch_rect->property_x2() = 0.0;
710 timestretch_rect->property_y2() = 0.0;
711 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
712 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
715 timestretch_rect->show ();
716 timestretch_rect->raise_to_top ();
718 x1 = start / _editor.get_current_zoom();
719 x2 = (end - 1) / _editor.get_current_zoom();
720 y2 = current_height() - 2;
722 timestretch_rect->property_x1() = x1;
723 timestretch_rect->property_y1() = 1.0;
724 timestretch_rect->property_x2() = x2;
725 timestretch_rect->property_y2() = y2;
729 RouteTimeAxisView::hide_timestretch ()
731 TimeAxisView::hide_timestretch ();
733 if (timestretch_rect) {
734 timestretch_rect->hide ();
739 RouteTimeAxisView::show_selection (TimeSelection& ts)
743 /* ignore it if our edit group is not active or if the selection was started
744 in some other track or route group (remember that route_group() == 0 means
745 that the track is not in an route group).
748 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
749 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
755 TimeAxisView::show_selection (ts);
759 RouteTimeAxisView::set_height (uint32_t h)
762 bool height_changed = (height == 0) || (h != height);
763 gm.get_level_meter().setup_meters (gmlen);
765 TimeAxisView::set_height (h);
770 _view->set_height ((double) current_height());
774 snprintf (buf, sizeof (buf), "%u", height);
775 xml_node->add_property ("height", buf);
777 if (height >= preset_height (HeightNormal)) {
782 gm.get_gain_slider().show();
784 if (!_route || _route->is_monitor()) {
789 if (rec_enable_button)
790 rec_enable_button->show();
792 route_group_button.show();
793 automation_button.show();
795 if (is_track() && track()->mode() == ARDOUR::Normal) {
796 playlist_button.show();
799 } else if (height >= preset_height (HeightSmaller)) {
805 gm.get_gain_slider().hide();
807 if (!_route || _route->is_monitor()) {
812 if (rec_enable_button)
813 rec_enable_button->show();
815 route_group_button.hide ();
816 automation_button.hide ();
818 if (is_track() && track()->mode() == ARDOUR::Normal) {
819 playlist_button.hide ();
825 /* don't allow name_entry to be hidden while
826 it has focus, otherwise the GUI becomes unusable.
829 if (name_entry.has_focus()) {
830 if (name_entry.get_text() != _route->name()) {
831 name_entry_changed ();
833 controls_ebox.grab_focus ();
839 gm.get_gain_slider().hide();
842 if (rec_enable_button)
843 rec_enable_button->hide();
845 route_group_button.hide ();
846 automation_button.hide ();
847 playlist_button.hide ();
848 name_label.set_text (_route->name());
851 if (height_changed && !no_redraw) {
852 /* only emit the signal if the height really changed */
853 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
858 RouteTimeAxisView::select_track_color ()
860 if (RouteUI::choose_color ()) {
863 _view->apply_color (_color, StreamView::RegionColor);
869 RouteTimeAxisView::reset_samples_per_unit ()
871 set_samples_per_unit (_editor.get_current_zoom());
875 RouteTimeAxisView::set_samples_per_unit (double spu)
880 speed = track()->speed();
884 _view->set_samples_per_unit (spu * speed);
887 TimeAxisView::set_samples_per_unit (spu * speed);
891 RouteTimeAxisView::align_style_changed ()
893 switch (track()->alignment_style()) {
894 case ExistingMaterial:
895 if (!align_existing_item->get_active()) {
896 align_existing_item->set_active();
900 if (!align_capture_item->get_active()) {
901 align_capture_item->set_active();
908 RouteTimeAxisView::set_align_style (AlignStyle style)
913 case ExistingMaterial:
914 item = align_existing_item;
917 item = align_capture_item;
920 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
925 if (item->get_active()) {
926 track()->set_align_style (style);
931 RouteTimeAxisView::rename_current_playlist ()
933 ArdourPrompter prompter (true);
936 boost::shared_ptr<Track> tr = track();
937 if (!tr || tr->destructive()) {
941 boost::shared_ptr<Playlist> pl = tr->playlist();
946 prompter.set_title (_("Rename Playlist"));
947 prompter.set_prompt (_("New name for playlist:"));
948 prompter.set_initial_text (pl->name());
949 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
950 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
952 switch (prompter.run ()) {
953 case Gtk::RESPONSE_ACCEPT:
954 prompter.get_result (name);
966 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
968 std::string ret (basename);
970 std::string const group_string = "." + route_group()->name() + ".";
972 // iterate through all playlists
974 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
975 std::string tmp = (*i)->name();
977 std::string::size_type idx = tmp.find(group_string);
978 // find those which belong to this group
979 if (idx != string::npos) {
980 tmp = tmp.substr(idx + group_string.length());
982 // and find the largest current number
983 int x = atoi(tmp.c_str());
993 snprintf (buf, sizeof(buf), "%d", maxnumber);
995 ret = this->name() + "." + route_group()->name () + "." + buf;
1001 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1005 boost::shared_ptr<Track> tr = track ();
1006 if (!tr || tr->destructive()) {
1010 boost::shared_ptr<const Playlist> pl = tr->playlist();
1017 if (route_group() && route_group()->is_active()) {
1018 name = resolve_new_group_playlist_name(name, playlists_before_op);
1021 while (_session->playlists->by_name(name)) {
1022 name = Playlist::bump_name (name, *_session);
1025 // TODO: The prompter "new" button should be de-activated if the user
1026 // specifies a playlist name which already exists in the session.
1030 ArdourPrompter prompter (true);
1032 prompter.set_title (_("New Copy Playlist"));
1033 prompter.set_prompt (_("Name for new playlist:"));
1034 prompter.set_initial_text (name);
1035 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1036 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1037 prompter.show_all ();
1039 switch (prompter.run ()) {
1040 case Gtk::RESPONSE_ACCEPT:
1041 prompter.get_result (name);
1049 if (name.length()) {
1050 tr->use_copy_playlist ();
1051 tr->playlist()->set_name (name);
1056 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1060 boost::shared_ptr<Track> tr = track ();
1061 if (!tr || tr->destructive()) {
1065 boost::shared_ptr<const Playlist> pl = tr->playlist();
1072 if (route_group() && route_group()->is_active()) {
1073 name = resolve_new_group_playlist_name(name,playlists_before_op);
1076 while (_session->playlists->by_name(name)) {
1077 name = Playlist::bump_name (name, *_session);
1083 ArdourPrompter prompter (true);
1085 prompter.set_title (_("New Playlist"));
1086 prompter.set_prompt (_("Name for new playlist:"));
1087 prompter.set_initial_text (name);
1088 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1089 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1091 switch (prompter.run ()) {
1092 case Gtk::RESPONSE_ACCEPT:
1093 prompter.get_result (name);
1101 if (name.length()) {
1102 tr->use_new_playlist ();
1103 tr->playlist()->set_name (name);
1108 RouteTimeAxisView::clear_playlist ()
1110 boost::shared_ptr<Track> tr = track ();
1111 if (!tr || tr->destructive()) {
1115 boost::shared_ptr<Playlist> pl = tr->playlist();
1120 _editor.clear_playlist (pl);
1124 RouteTimeAxisView::speed_changed ()
1126 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1130 RouteTimeAxisView::update_diskstream_display ()
1140 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1142 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1144 /* special case: select/deselect all tracks */
1145 if (_editor.get_selection().selected (this)) {
1146 _editor.get_selection().clear_tracks ();
1148 _editor.select_all_tracks ();
1154 switch (ArdourKeyboard::selection_type (ev->state)) {
1155 case Selection::Toggle:
1156 _editor.get_selection().toggle (this);
1159 case Selection::Set:
1160 _editor.get_selection().set (this);
1163 case Selection::Extend:
1164 _editor.extend_selection_to_track (*this);
1167 case Selection::Add:
1168 _editor.get_selection().add (this);
1174 RouteTimeAxisView::set_selected_points (PointSelection& points)
1176 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1177 (*i)->set_selected_points (points);
1182 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1185 _view->set_selected_regionviews (regions);
1189 /** Add the selectable things that we have to a list.
1190 * @param results List to add things to.
1193 RouteTimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list<Selectable*>& results)
1198 speed = track()->speed();
1201 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1202 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1204 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1205 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1208 /* pick up visible automation tracks */
1210 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1211 if (!(*i)->hidden()) {
1212 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1218 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1221 _view->get_inverted_selectables (sel, results);
1224 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1225 if (!(*i)->hidden()) {
1226 (*i)->get_inverted_selectables (sel, results);
1234 RouteTimeAxisView::route_group () const
1236 return _route->route_group();
1240 RouteTimeAxisView::name() const
1242 return _route->name();
1245 boost::shared_ptr<Playlist>
1246 RouteTimeAxisView::playlist () const
1248 boost::shared_ptr<Track> tr;
1250 if ((tr = track()) != 0) {
1251 return tr->playlist();
1253 return boost::shared_ptr<Playlist> ();
1258 RouteTimeAxisView::name_entry_changed ()
1262 x = name_entry.get_text ();
1264 if (x == _route->name()) {
1268 strip_whitespace_edges(x);
1270 if (x.length() == 0) {
1271 name_entry.set_text (_route->name());
1275 if (!_session->route_name_unique (x)) {
1276 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1277 name_entry.set_text (_route->name());
1278 } else if (_session->route_name_internal (x)) {
1279 ARDOUR_UI::instance()->popup_error (string_compose (_("You cannot create a track with that name as it is reserved for %1"),
1281 name_entry.set_text (_route->name());
1283 _route->set_name (x);
1287 boost::shared_ptr<Region>
1288 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1290 boost::shared_ptr<Playlist> pl = playlist ();
1293 return pl->find_next_region (pos, point, dir);
1296 return boost::shared_ptr<Region> ();
1300 RouteTimeAxisView::find_next_region_boundary (framepos_t pos, int32_t dir)
1302 boost::shared_ptr<Playlist> pl = playlist ();
1305 return pl->find_next_region_boundary (pos, dir);
1312 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1314 boost::shared_ptr<Playlist> what_we_got;
1315 boost::shared_ptr<Track> tr = track ();
1316 boost::shared_ptr<Playlist> playlist;
1319 /* route is a bus, not a track */
1323 playlist = tr->playlist();
1325 TimeSelection time (selection.time);
1326 float const speed = tr->speed();
1327 if (speed != 1.0f) {
1328 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1329 (*i).start = session_frame_to_track_frame((*i).start, speed);
1330 (*i).end = session_frame_to_track_frame((*i).end, speed);
1334 playlist->clear_changes ();
1335 playlist->clear_owned_changes ();
1339 if ((what_we_got = playlist->cut (time)) != 0) {
1340 _editor.get_cut_buffer().add (what_we_got);
1342 vector<Command*> cmds;
1343 playlist->rdiff (cmds);
1344 _session->add_commands (cmds);
1346 _session->add_command (new StatefulDiffCommand (playlist));
1350 if ((what_we_got = playlist->copy (time)) != 0) {
1351 _editor.get_cut_buffer().add (what_we_got);
1356 if ((what_we_got = playlist->cut (time)) != 0) {
1358 vector<Command*> cmds;
1359 playlist->rdiff (cmds);
1360 _session->add_commands (cmds);
1361 _session->add_command (new StatefulDiffCommand (playlist));
1362 what_we_got->release ();
1369 RouteTimeAxisView::paste (framepos_t pos, float times, Selection& selection, size_t nth)
1375 boost::shared_ptr<Playlist> pl = playlist ();
1376 PlaylistSelection::iterator p;
1378 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1380 if (p == selection.playlists.end()) {
1384 if (track()->speed() != 1.0f) {
1385 pos = session_frame_to_track_frame (pos, track()->speed());
1388 pl->clear_changes ();
1389 pl->paste (*p, pos, times);
1390 _session->add_command (new StatefulDiffCommand (pl));
1396 struct PlaylistSorter {
1397 bool operator() (boost::shared_ptr<Playlist> a, boost::shared_ptr<Playlist> b) const {
1398 return a->sort_id() < b->sort_id();
1403 RouteTimeAxisView::build_playlist_menu ()
1405 using namespace Menu_Helpers;
1411 delete playlist_action_menu;
1412 playlist_action_menu = new Menu;
1413 playlist_action_menu->set_name ("ArdourContextMenu");
1415 MenuList& playlist_items = playlist_action_menu->items();
1416 playlist_action_menu->set_name ("ArdourContextMenu");
1417 playlist_items.clear();
1419 delete playlist_menu;
1421 vector<boost::shared_ptr<Playlist> > playlists, playlists_tr;
1422 boost::shared_ptr<Track> tr = track();
1423 RadioMenuItem::Group playlist_group;
1425 _session->playlists->get (playlists);
1427 /* find the playlists for this diskstream */
1428 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1429 if (((*i)->get_orig_diskstream_id() == tr->diskstream_id()) || (tr->playlist()->id() == (*i)->id())) {
1430 playlists_tr.push_back(*i);
1434 /* sort the playlists */
1436 sort (playlists_tr.begin(), playlists_tr.end(), cmp);
1438 /* add the playlists to the menu */
1439 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_tr.begin(); i != playlists_tr.end(); ++i) {
1440 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name()));
1441 RadioMenuItem *item = static_cast<RadioMenuItem*>(&playlist_items.back());
1442 item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr<Playlist> (*i)));
1444 if (tr->playlist()->id() == (*i)->id()) {
1450 playlist_items.push_back (SeparatorElem());
1451 playlist_items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1452 playlist_items.push_back (SeparatorElem());
1454 if (!route_group() || !route_group()->is_active()) {
1455 playlist_items.push_back (MenuElem (_("New..."), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1456 playlist_items.push_back (MenuElem (_("New Copy..."), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1459 // Use a label which tells the user what is happening
1460 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1461 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1465 playlist_items.push_back (SeparatorElem());
1466 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1467 playlist_items.push_back (SeparatorElem());
1469 playlist_items.push_back (MenuElem(_("Select from all..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1473 RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr<Playlist> wpl)
1475 assert (is_track());
1477 // exit if we were triggered by deactivating the old playlist
1478 if (!item->get_active()) {
1482 boost::shared_ptr<Playlist> pl (wpl.lock());
1488 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1491 if (track()->playlist() == apl) {
1492 // exit when use_playlist is called by the creation of the playlist menu
1493 // or the playlist choice is unchanged
1496 track()->use_playlist (apl);
1498 if (route_group() && route_group()->is_active()) {
1499 std::string group_string = "."+route_group()->name()+".";
1501 std::string take_name = apl->name();
1502 std::string::size_type idx = take_name.find(group_string);
1504 if (idx == std::string::npos)
1507 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1509 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1511 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1512 if ( (*i) == this->route()) {
1516 std::string playlist_name = (*i)->name()+group_string+take_name;
1518 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1520 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1524 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1526 // No playlist for this track for this take yet, make it
1527 track->use_new_playlist();
1528 track->playlist()->set_name(playlist_name);
1530 track->use_playlist(ipl);
1538 RouteTimeAxisView::show_playlist_selector ()
1540 _editor.playlist_selector().show_for (this);
1544 RouteTimeAxisView::map_frozen ()
1550 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1552 switch (track()->freeze_state()) {
1554 playlist_button.set_sensitive (false);
1555 rec_enable_button->set_sensitive (false);
1558 playlist_button.set_sensitive (true);
1559 rec_enable_button->set_sensitive (true);
1565 RouteTimeAxisView::color_handler ()
1567 //case cTimeStretchOutline:
1568 if (timestretch_rect) {
1569 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1571 //case cTimeStretchFill:
1572 if (timestretch_rect) {
1573 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1579 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1580 * Will add track if necessary.
1583 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1585 boost::shared_ptr<AutomationTimeAxisView> track = automation_child (param);
1586 Gtk::CheckMenuItem* menu = automation_child_menu_item (param);
1589 /* it doesn't exist yet, so we don't care about the button state: just add it */
1590 create_automation_child (param, true);
1593 bool yn = menu->get_active();
1594 if (track->set_visibility (menu->get_active()) && yn) {
1596 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1597 will have done that for us.
1601 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1608 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1610 boost::shared_ptr<AutomationTimeAxisView> track = automation_child (param);
1616 Gtk::CheckMenuItem* menu = automation_child_menu_item (param);
1618 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1619 track->get_state_node()->add_property (X_("shown"), X_("no"));
1621 if (menu && !_hidden) {
1622 ignore_toggle = true;
1623 menu->set_active (false);
1624 ignore_toggle = false;
1627 if (_route && !no_redraw) {
1628 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1634 RouteTimeAxisView::show_all_automation ()
1638 /* Show our automation */
1640 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1641 i->second->set_marked_for_display (true);
1642 i->second->canvas_display()->show();
1643 i->second->get_state_node()->add_property ("shown", X_("yes"));
1645 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1648 menu->set_active(true);
1653 /* Show processor automation */
1655 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1656 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1657 if ((*ii)->view == 0) {
1658 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1661 (*ii)->menu_item->set_active (true);
1669 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1673 RouteTimeAxisView::show_existing_automation ()
1677 /* Show our automation */
1679 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1680 if (i->second->has_automation()) {
1681 i->second->set_marked_for_display (true);
1682 i->second->canvas_display()->show();
1683 i->second->get_state_node()->add_property ("shown", X_("yes"));
1685 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1687 menu->set_active(true);
1693 /* Show processor automation */
1695 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1696 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1697 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1698 (*ii)->menu_item->set_active (true);
1705 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1709 RouteTimeAxisView::hide_all_automation ()
1713 /* Hide our automation */
1715 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1716 i->second->set_marked_for_display (false);
1718 i->second->get_state_node()->add_property ("shown", X_("no"));
1720 Gtk::CheckMenuItem* menu = automation_child_menu_item (i->first);
1723 menu->set_active (false);
1727 /* Hide 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 (*ii)->menu_item->set_active (false);
1736 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1741 RouteTimeAxisView::region_view_added (RegionView* rv)
1743 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1744 if (is_audio_track()) {
1745 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1746 boost::shared_ptr<AutomationTimeAxisView> atv;
1748 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1754 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1755 (*i)->add_ghost(rv);
1759 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1761 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1767 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1769 parent.remove_processor_automation_node (this);
1773 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1776 remove_child (pan->view);
1780 RouteTimeAxisView::ProcessorAutomationNode*
1781 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1783 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1785 if ((*i)->processor == processor) {
1787 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1788 if ((*ii)->what == what) {
1799 legalize_for_xml_node (string str)
1801 string::size_type pos;
1802 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1808 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1809 legal.replace (pos, 1, "_");
1818 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1821 ProcessorAutomationNode* pan;
1823 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1824 /* session state may never have been saved with new plugin */
1825 error << _("programming error: ")
1826 << string_compose (X_("processor automation curve for %1:%2/%3/%4 not registered with track!"),
1827 processor->name(), what.type(), (int) what.channel(), what.id() )
1837 name = processor->describe_parameter (what);
1839 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1843 char state_name[256];
1844 snprintf (state_name, sizeof (state_name), "%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1846 boost::shared_ptr<AutomationControl> control
1847 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1849 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1850 new AutomationTimeAxisView (_session, _route, processor, control,
1851 _editor, *this, false, parent_canvas, name, state_name));
1853 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1855 if (!pan->view->marked_for_display()) {
1858 pan->menu_item->set_active (true);
1861 add_child (pan->view);
1864 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1867 processor->mark_automation_visible (what, true);
1871 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1874 pan->menu_item->set_active (false);
1877 i->mark_automation_visible (pan->what, false);
1880 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1885 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1887 boost::shared_ptr<Processor> processor (p.lock ());
1892 set<Evoral::Parameter> s;
1893 boost::shared_ptr<AutomationLine> al;
1895 processor->what_has_visible_data (s);
1897 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1899 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1902 add_processor_automation_curve (processor, (*i));
1908 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1910 using namespace Menu_Helpers;
1917 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1919 bool hideit = (!show);
1921 if ((node = track->get_state_node()) != 0) {
1922 if ((prop = node->property ("shown")) != 0) {
1923 if (string_is_affirmative (prop->value())) {
1929 _automation_tracks[param] = track;
1931 track->set_visibility (!hideit);
1934 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1937 if (!EventTypeMap::instance().is_midi_parameter(param)) {
1938 /* MIDI-related parameters are always in the menu, there's no
1939 reason to rebuild the menu just because we added a automation
1940 lane for one of them. But if we add a non-MIDI automation
1941 lane, then we need to invalidate the display menu.
1943 delete display_menu;
1949 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1951 boost::shared_ptr<Processor> processor (p.lock ());
1953 if (!processor || !processor->display_to_user ()) {
1957 using namespace Menu_Helpers;
1958 ProcessorAutomationInfo *rai;
1959 list<ProcessorAutomationInfo*>::iterator x;
1961 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
1962 std::set<Evoral::Parameter> has_visible_automation;
1964 processor->what_has_visible_data(has_visible_automation);
1966 if (automatable.empty()) {
1970 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
1971 if ((*x)->processor == processor) {
1976 if (x == processor_automation.end()) {
1978 rai = new ProcessorAutomationInfo (processor);
1979 processor_automation.push_back (rai);
1987 /* any older menu was deleted at the top of processors_changed()
1988 when we cleared the subplugin menu.
1991 rai->menu = manage (new Menu);
1992 MenuList& items = rai->menu->items();
1993 rai->menu->set_name ("ArdourContextMenu");
1997 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
1999 ProcessorAutomationNode* pan;
2000 CheckMenuItem* mitem;
2002 string name = processor->describe_parameter (*i);
2004 items.push_back (CheckMenuElem (name));
2005 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2007 _subplugin_menu_map[*i] = mitem;
2009 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2010 mitem->set_active(true);
2013 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2017 pan = new ProcessorAutomationNode (*i, mitem, *this);
2019 rai->lines.push_back (pan);
2023 pan->menu_item = mitem;
2027 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2030 /* add the menu for this processor, because the subplugin
2031 menu is always cleared at the top of processors_changed().
2032 this is the result of some poor design in gtkmm and/or
2036 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2041 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2042 RouteTimeAxisView::ProcessorAutomationNode* pan)
2044 bool showit = pan->menu_item->get_active();
2045 bool redraw = false;
2047 if (pan->view == 0 && showit) {
2048 add_processor_automation_curve (rai->processor, pan->what);
2052 if (pan->view && showit != pan->view->marked_for_display()) {
2055 pan->view->set_marked_for_display (true);
2056 pan->view->canvas_display()->show();
2057 pan->view->canvas_background()->show();
2059 rai->processor->mark_automation_visible (pan->what, true);
2060 pan->view->set_marked_for_display (false);
2068 if (redraw && !no_redraw) {
2069 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2075 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2077 if (c.type == RouteProcessorChange::MeterPointChange) {
2078 /* nothing to do if only the meter point has changed */
2082 using namespace Menu_Helpers;
2084 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2085 (*i)->valid = false;
2088 _subplugin_menu_map.clear ();
2089 subplugin_menu.items().clear ();
2091 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2092 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2094 bool deleted_processor_automation = false;
2096 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2098 list<ProcessorAutomationInfo*>::iterator tmp;
2106 processor_automation.erase (i);
2107 deleted_processor_automation = true;
2114 if (deleted_processor_automation && !no_redraw) {
2115 _route->gui_changed ("track_height", this);
2119 boost::shared_ptr<AutomationLine>
2120 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2122 ProcessorAutomationNode* pan;
2124 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2130 return boost::shared_ptr<AutomationLine>();
2134 RouteTimeAxisView::reset_processor_automation_curves ()
2136 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2142 RouteTimeAxisView::update_rec_display ()
2144 RouteUI::update_rec_display ();
2145 name_entry.set_sensitive (!_route->record_enabled());
2149 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2152 _view->set_layer_display (d);
2156 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2160 RouteTimeAxisView::layer_display () const
2163 return _view->layer_display ();
2166 /* we don't know, since we don't have a _view, so just return something */
2172 boost::shared_ptr<AutomationTimeAxisView>
2173 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2175 AutomationTracks::iterator i = _automation_tracks.find(param);
2176 if (i != _automation_tracks.end()) {
2179 return boost::shared_ptr<AutomationTimeAxisView>();
2184 RouteTimeAxisView::fast_update ()
2186 gm.get_level_meter().update_meters ();
2190 RouteTimeAxisView::hide_meter ()
2193 gm.get_level_meter().hide_meters ();
2197 RouteTimeAxisView::show_meter ()
2203 RouteTimeAxisView::reset_meter ()
2205 if (Config->get_show_track_meters()) {
2206 gm.get_level_meter().setup_meters (height-5);
2213 RouteTimeAxisView::clear_meter ()
2215 gm.get_level_meter().clear_meters ();
2219 RouteTimeAxisView::meter_changed ()
2221 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed)
2226 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2232 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2234 using namespace Menu_Helpers;
2236 if (!_underlay_streams.empty()) {
2237 MenuList& parent_items = parent_menu->items();
2238 Menu* gs_menu = manage (new Menu);
2239 gs_menu->set_name ("ArdourContextMenu");
2240 MenuList& gs_items = gs_menu->items();
2242 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2244 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2245 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2246 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2252 RouteTimeAxisView::set_underlay_state()
2254 if (!underlay_xml_node) {
2258 XMLNodeList nlist = underlay_xml_node->children();
2259 XMLNodeConstIterator niter;
2260 XMLNode *child_node;
2262 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2263 child_node = *niter;
2265 if (child_node->name() != "Underlay") {
2269 XMLProperty* prop = child_node->property ("id");
2271 PBD::ID id (prop->value());
2273 RouteTimeAxisView* v = _editor.get_route_view_by_route_id (id);
2276 add_underlay(v->view(), false);
2285 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2291 RouteTimeAxisView& other = v->trackview();
2293 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2294 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2295 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2299 _underlay_streams.push_back(v);
2300 other._underlay_mirrors.push_back(this);
2302 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2305 if (!underlay_xml_node) {
2307 underlay_xml_node = xml_node->add_child("Underlays");
2310 XMLNode* node = underlay_xml_node->add_child("Underlay");
2311 XMLProperty* prop = node->add_property("id");
2312 prop->set_value(v->trackview().route()->id().to_s());
2318 RouteTimeAxisView::remove_underlay (StreamView* v)
2324 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2325 RouteTimeAxisView& other = v->trackview();
2327 if (it != _underlay_streams.end()) {
2328 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2330 if (gm == other._underlay_mirrors.end()) {
2331 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2335 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2337 _underlay_streams.erase(it);
2338 other._underlay_mirrors.erase(gm);
2340 if (underlay_xml_node) {
2341 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2347 RouteTimeAxisView::set_button_names ()
2349 rec_enable_button_label.set_text (_("r"));
2351 if (_route && _route->solo_safe()) {
2352 solo_button_label.set_text (X_("!"));
2354 if (Config->get_solo_control_is_listen_control()) {
2355 switch (Config->get_listen_position()) {
2356 case AfterFaderListen:
2357 solo_button_label.set_text (_("A"));
2359 case PreFaderListen:
2360 solo_button_label.set_text (_("P"));
2364 solo_button_label.set_text (_("s"));
2367 mute_button_label.set_text (_("m"));
2371 RouteTimeAxisView::automation_child_menu_item (Evoral::Parameter param)
2373 ParameterMenuMap::iterator i = _main_automation_menu_map.find (param);
2374 if (i != _main_automation_menu_map.end()) {
2378 i = _subplugin_menu_map.find (param);
2379 if (i != _subplugin_menu_map.end()) {
2387 RouteTimeAxisView::create_gain_automation_child (const Evoral::Parameter& param, bool show)
2389 boost::shared_ptr<AutomationControl> c = _route->gain_control();
2391 error << "Route has no gain automation, unable to add automation track view." << endmsg;
2395 gain_track.reset (new AutomationTimeAxisView (_session,
2396 _route, _route->amp(), c,
2401 _route->amp()->describe_parameter(param)));
2403 add_automation_child (Evoral::Parameter(GainAutomation), gain_track, show);