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);
199 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
201 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
202 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
204 ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
205 ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
206 ARDOUR_UI::instance()->set_tip(route_group_button, _("Route Group"));
207 ARDOUR_UI::instance()->set_tip(size_button,_("Display Height"));
208 ARDOUR_UI::instance()->set_tip(playlist_button,_("Playlist"));
209 ARDOUR_UI::instance()->set_tip(automation_button, _("Automation"));
210 ARDOUR_UI::instance()->set_tip(visual_button, _("Visual options"));
211 ARDOUR_UI::instance()->set_tip(hide_button, _("Hide this track"));
217 /* old school - when we used to put an extra row of buttons in place */
219 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
220 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
221 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
222 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
226 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
229 if (is_track() && track()->mode() == ARDOUR::Normal) {
230 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
235 _route->processors_changed.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
236 _route->PropertyChanged.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::route_property_changed, this, _1), gui_context());
240 track()->TrackModeChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
241 track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
242 track()->DiskstreamChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::diskstream_changed, this), gui_context());
243 get_diskstream()->SpeedChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
245 /* pick up the correct freeze state */
250 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
251 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
253 PropertyList* plist = new PropertyList();
255 plist->add (ARDOUR::Properties::edit, true);
256 plist->add (ARDOUR::Properties::mute, true);
257 plist->add (ARDOUR::Properties::solo, true);
259 route_group_menu = new RouteGroupMenu (_session, plist);
260 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
262 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
263 gm.get_gain_slider().set_name ("TrackGainFader");
266 RouteTimeAxisView::~RouteTimeAxisView ()
268 CatchDeletion (this);
270 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
274 delete playlist_menu;
277 delete playlist_action_menu;
278 playlist_action_menu = 0;
283 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
287 _automation_tracks.clear ();
289 delete route_group_menu;
293 RouteTimeAxisView::post_construct ()
295 /* map current state of the route */
297 update_diskstream_display ();
299 subplugin_menu.items().clear ();
300 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
301 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
302 reset_processor_automation_curves ();
306 RouteTimeAxisView::edit_click (GdkEventButton *ev)
308 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
309 if (_route->route_group()) {
310 _route->route_group()->remove (_route);
315 route_group_menu->rebuild (_route->route_group ());
316 route_group_menu->popup (ev->button, ev->time);
322 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
327 if (_route->route_group()) {
328 _route->route_group()->remove (_route);
334 RouteTimeAxisView::playlist_changed ()
340 RouteTimeAxisView::label_view ()
342 string x = _route->name();
344 if (x != name_entry.get_text()) {
345 name_entry.set_text (x);
348 ARDOUR_UI::instance()->set_tip (name_entry, x);
352 RouteTimeAxisView::route_property_changed (const PropertyChange& what_changed)
354 if (what_changed.contains (ARDOUR::Properties::name)) {
360 RouteTimeAxisView::take_name_changed (void *src)
369 RouteTimeAxisView::playlist_click ()
371 // always build a new action menu
373 delete playlist_action_menu;
375 playlist_action_menu = new Menu;
376 playlist_action_menu->set_name ("ArdourContextMenu");
378 build_playlist_menu (playlist_action_menu);
380 conditionally_add_to_selection ();
381 playlist_action_menu->popup (1, gtk_get_current_event_time());
385 RouteTimeAxisView::automation_click ()
387 conditionally_add_to_selection ();
388 build_automation_action_menu ();
389 automation_action_menu->popup (1, gtk_get_current_event_time());
393 RouteTimeAxisView::set_state (const XMLNode& node, int version)
395 TimeAxisView::set_state (node, version);
397 XMLNodeList kids = node.children();
398 XMLNodeConstIterator iter;
399 const XMLProperty* prop;
401 if (_view && (prop = node.property ("layer-display"))) {
402 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
405 for (iter = kids.begin(); iter != kids.end(); ++iter) {
406 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
407 if ((prop = (*iter)->property ("automation-id")) != 0) {
409 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
410 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
411 create_automation_child(param, show);
413 warning << "Automation child has no ID" << endmsg;
422 RouteTimeAxisView::build_automation_action_menu ()
424 using namespace Menu_Helpers;
426 delete automation_action_menu;
427 automation_action_menu = new Menu;
429 MenuList& items = automation_action_menu->items();
431 automation_action_menu->set_name ("ArdourContextMenu");
433 items.push_back (MenuElem (_("Show All Automation"),
434 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
436 items.push_back (MenuElem (_("Show Existing Automation"),
437 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
439 items.push_back (MenuElem (_("Hide All Automation"),
440 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
442 /* attach the plugin submenu. It may have previously been used elsewhere, so we detach it first. */
444 detach_menu (subplugin_menu);
445 items.push_back (MenuElem (_("Plugins"), subplugin_menu));
446 items.back().set_sensitive (!subplugin_menu.items().empty());
450 RouteTimeAxisView::build_display_menu ()
452 using namespace Menu_Helpers;
454 /* get the size menu ready */
460 TimeAxisView::build_display_menu ();
462 /* now fill it with our stuff */
464 MenuList& items = display_menu->items();
465 display_menu->set_name ("ArdourContextMenu");
467 items.push_back (MenuElem (_("Height"), *size_menu));
468 items.push_back (MenuElem (_("Color"), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
470 items.push_back (SeparatorElem());
472 if (!Profile->get_sae()) {
473 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
474 /* rebuild this every time */
475 build_automation_action_menu ();
476 detach_menu (*automation_action_menu);
477 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
478 items.push_back (SeparatorElem());
481 // Hook for derived classes to add type specific stuff
482 append_extra_display_menu_items ();
483 items.push_back (SeparatorElem());
487 Menu *layers_menu = manage(new Menu);
488 MenuList &layers_items = layers_menu->items();
489 layers_menu->set_name("ArdourContextMenu");
491 RadioMenuItem::Group layers_group;
493 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
494 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
495 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
496 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
498 items.push_back (MenuElem (_("Layers"), *layers_menu));
500 Menu* alignment_menu = manage (new Menu);
501 MenuList& alignment_items = alignment_menu->items();
502 alignment_menu->set_name ("ArdourContextMenu");
504 RadioMenuItem::Group align_group;
506 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material"),
507 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
508 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
509 if (get_diskstream()->alignment_style() == ExistingMaterial)
510 align_existing_item->set_active();
512 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time"),
513 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
514 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
515 if (get_diskstream()->alignment_style() == CaptureTime)
516 align_capture_item->set_active();
518 if (!Profile->get_sae()) {
520 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
521 get_diskstream()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
523 RadioMenuItem::Group mode_group;
524 items.push_back (RadioMenuElem (mode_group, _("Normal Mode"), sigc::bind (
525 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
527 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
529 items.push_back (RadioMenuElem (mode_group, _("Tape Mode"), sigc::bind (
530 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
531 ARDOUR::Destructive)));
532 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
534 items.push_back (RadioMenuElem (mode_group, _("Non-Layered Mode"),
535 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
536 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
539 _ignore_track_mode_change = true;
541 switch (track()->mode()) {
542 case ARDOUR::Destructive:
543 destructive_track_mode_item->set_active ();
546 normal_track_mode_item->set_active ();
548 case ARDOUR::NonLayered:
549 non_layered_track_mode_item->set_active ();
553 _ignore_track_mode_change = false;
556 get_diskstream()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
558 color_mode_menu = build_color_mode_menu();
559 if (color_mode_menu) {
560 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
563 items.push_back (SeparatorElem());
566 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
567 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
568 route_active_menu_item->set_active (_route->active());
570 items.push_back (SeparatorElem());
571 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &RouteTimeAxisView::hide_click)));
572 if (!Profile->get_sae()) {
573 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
575 items.push_front (SeparatorElem());
576 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
580 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
583 item_2->set_active ();
588 RouteTimeAxisView::set_track_mode (TrackMode mode)
590 if (_ignore_track_mode_change) {
595 RadioMenuItem* other_item;
596 RadioMenuItem* other_item_2;
600 item = normal_track_mode_item;
601 other_item = non_layered_track_mode_item;
602 other_item_2 = destructive_track_mode_item;
604 case ARDOUR::NonLayered:
605 item = non_layered_track_mode_item;
606 other_item = normal_track_mode_item;
607 other_item_2 = destructive_track_mode_item;
609 case ARDOUR::Destructive:
610 item = destructive_track_mode_item;
611 other_item = normal_track_mode_item;
612 other_item_2 = non_layered_track_mode_item;
615 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
620 if (item && other_item && other_item_2 && track()->mode() != mode) {
621 _set_track_mode (track().get(), mode, other_item, other_item_2);
626 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
630 if (!track->can_use_mode (mode, needs_bounce)) {
634 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
637 cerr << "would bounce this one\n";
638 /* XXX: radio menu item becomes inconsistent with track state in this case */
643 track->set_mode (mode);
645 rec_enable_button->remove ();
648 case ARDOUR::NonLayered:
650 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
652 case ARDOUR::Destructive:
653 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
657 rec_enable_button->show_all ();
661 RouteTimeAxisView::track_mode_changed ()
665 switch (track()->mode()) {
667 item = normal_track_mode_item;
669 case ARDOUR::NonLayered:
670 item = non_layered_track_mode_item;
672 case ARDOUR::Destructive:
673 item = destructive_track_mode_item;
676 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
685 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
691 TimeAxisView::show_timestretch (start, end);
701 /* check that the time selection was made in our route, or our route group.
702 remember that route_group() == 0 implies the route is *not* in a edit group.
705 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
706 /* this doesn't apply to us */
710 /* ignore it if our edit group is not active */
712 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
717 if (timestretch_rect == 0) {
718 timestretch_rect = new SimpleRect (*canvas_display ());
719 timestretch_rect->property_x1() = 0.0;
720 timestretch_rect->property_y1() = 0.0;
721 timestretch_rect->property_x2() = 0.0;
722 timestretch_rect->property_y2() = 0.0;
723 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
724 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
727 timestretch_rect->show ();
728 timestretch_rect->raise_to_top ();
730 x1 = start / _editor.get_current_zoom();
731 x2 = (end - 1) / _editor.get_current_zoom();
732 y2 = current_height() - 2;
734 timestretch_rect->property_x1() = x1;
735 timestretch_rect->property_y1() = 1.0;
736 timestretch_rect->property_x2() = x2;
737 timestretch_rect->property_y2() = y2;
741 RouteTimeAxisView::hide_timestretch ()
743 TimeAxisView::hide_timestretch ();
745 if (timestretch_rect) {
746 timestretch_rect->hide ();
751 RouteTimeAxisView::show_selection (TimeSelection& ts)
755 /* ignore it if our edit group is not active or if the selection was started
756 in some other track or route group (remember that route_group() == 0 means
757 that the track is not in an route group).
760 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
761 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
767 TimeAxisView::show_selection (ts);
771 RouteTimeAxisView::set_height (uint32_t h)
774 bool height_changed = (height == 0) || (h != height);
775 gm.get_level_meter().setup_meters (gmlen);
777 TimeAxisView::set_height (h);
782 _view->set_height ((double) current_height());
786 snprintf (buf, sizeof (buf), "%u", height);
787 xml_node->add_property ("height", buf);
789 if (height >= hNormal) {
794 gm.get_gain_slider().show();
796 if (!_route || _route->is_monitor()) {
801 if (rec_enable_button)
802 rec_enable_button->show();
804 route_group_button.show();
806 visual_button.show();
808 automation_button.show();
810 if (is_track() && track()->mode() == ARDOUR::Normal) {
811 playlist_button.show();
814 } else if (height >= hSmaller) {
820 gm.get_gain_slider().hide();
822 if (!_route || _route->is_monitor()) {
827 if (rec_enable_button)
828 rec_enable_button->show();
830 route_group_button.hide ();
832 visual_button.hide ();
834 automation_button.hide ();
836 if (is_track() && track()->mode() == ARDOUR::Normal) {
837 playlist_button.hide ();
843 /* don't allow name_entry to be hidden while
844 it has focus, otherwise the GUI becomes unusable.
847 if (name_entry.has_focus()) {
848 if (name_entry.get_text() != _route->name()) {
849 name_entry_changed ();
851 controls_ebox.grab_focus ();
857 gm.get_gain_slider().hide();
860 if (rec_enable_button)
861 rec_enable_button->hide();
863 route_group_button.hide ();
865 visual_button.hide ();
867 automation_button.hide ();
868 playlist_button.hide ();
869 name_label.set_text (_route->name());
872 if (height_changed && !no_redraw) {
873 /* only emit the signal if the height really changed */
874 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
879 RouteTimeAxisView::select_track_color ()
881 if (RouteUI::choose_color ()) {
884 _view->apply_color (_color, StreamView::RegionColor);
890 RouteTimeAxisView::reset_samples_per_unit ()
892 set_samples_per_unit (_editor.get_current_zoom());
896 RouteTimeAxisView::set_samples_per_unit (double spu)
900 if (get_diskstream() != 0) {
901 speed = get_diskstream()->speed();
905 _view->set_samples_per_unit (spu * speed);
908 TimeAxisView::set_samples_per_unit (spu * speed);
912 RouteTimeAxisView::align_style_changed ()
914 switch (get_diskstream()->alignment_style()) {
915 case ExistingMaterial:
916 if (!align_existing_item->get_active()) {
917 align_existing_item->set_active();
921 if (!align_capture_item->get_active()) {
922 align_capture_item->set_active();
929 RouteTimeAxisView::set_align_style (AlignStyle style)
934 case ExistingMaterial:
935 item = align_existing_item;
938 item = align_capture_item;
941 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
946 if (item->get_active()) {
947 get_diskstream()->set_align_style (style);
952 RouteTimeAxisView::rename_current_playlist ()
954 ArdourPrompter prompter (true);
957 boost::shared_ptr<Diskstream> ds = get_diskstream();
958 if (!ds || ds->destructive())
961 boost::shared_ptr<Playlist> pl = ds->playlist();
965 prompter.set_prompt (_("Name for playlist"));
966 prompter.set_initial_text (pl->name());
967 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
968 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
970 switch (prompter.run ()) {
971 case Gtk::RESPONSE_ACCEPT:
972 prompter.get_result (name);
984 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
986 std::string ret (basename);
988 std::string const group_string = "." + route_group()->name() + ".";
990 // iterate through all playlists
992 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
993 std::string tmp = (*i)->name();
995 std::string::size_type idx = tmp.find(group_string);
996 // find those which belong to this group
997 if (idx != string::npos) {
998 tmp = tmp.substr(idx + group_string.length());
1000 // and find the largest current number
1001 int x = atoi(tmp.c_str());
1002 if (x > maxnumber) {
1011 snprintf (buf, sizeof(buf), "%d", maxnumber);
1013 ret = this->name() + "." + route_group()->name () + "." + buf;
1019 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1023 boost::shared_ptr<Diskstream> ds = get_diskstream();
1024 if (!ds || ds->destructive())
1027 boost::shared_ptr<const Playlist> pl = ds->playlist();
1033 if (route_group() && route_group()->is_active()) {
1034 name = resolve_new_group_playlist_name(name, playlists_before_op);
1037 while (_session->playlists->by_name(name)) {
1038 name = Playlist::bump_name (name, *_session);
1041 // TODO: The prompter "new" button should be de-activated if the user
1042 // specifies a playlist name which already exists in the session.
1046 ArdourPrompter prompter (true);
1048 prompter.set_prompt (_("Name for Playlist"));
1049 prompter.set_initial_text (name);
1050 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1051 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1052 prompter.show_all ();
1054 switch (prompter.run ()) {
1055 case Gtk::RESPONSE_ACCEPT:
1056 prompter.get_result (name);
1064 if (name.length()) {
1065 ds->use_copy_playlist ();
1066 ds->playlist()->set_name (name);
1071 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1075 boost::shared_ptr<Diskstream> ds = get_diskstream();
1076 if (!ds || ds->destructive())
1079 boost::shared_ptr<const Playlist> pl = ds->playlist();
1085 if (route_group() && route_group()->is_active()) {
1086 name = resolve_new_group_playlist_name(name,playlists_before_op);
1089 while (_session->playlists->by_name(name)) {
1090 name = Playlist::bump_name (name, *_session);
1096 ArdourPrompter prompter (true);
1098 prompter.set_prompt (_("Name for Playlist"));
1099 prompter.set_initial_text (name);
1100 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1101 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1103 switch (prompter.run ()) {
1104 case Gtk::RESPONSE_ACCEPT:
1105 prompter.get_result (name);
1113 if (name.length()) {
1114 ds->use_new_playlist ();
1115 ds->playlist()->set_name (name);
1120 RouteTimeAxisView::clear_playlist ()
1122 boost::shared_ptr<Diskstream> ds = get_diskstream();
1123 if (!ds || ds->destructive())
1126 boost::shared_ptr<Playlist> pl = ds->playlist();
1130 _editor.clear_playlist (pl);
1134 RouteTimeAxisView::speed_changed ()
1136 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1140 RouteTimeAxisView::diskstream_changed ()
1142 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::update_diskstream_display, this));
1146 RouteTimeAxisView::update_diskstream_display ()
1148 if (!get_diskstream()) // bus
1155 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1157 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1159 /* special case: select/deselect all tracks */
1160 if (_editor.get_selection().selected (this)) {
1161 _editor.get_selection().clear_tracks ();
1163 _editor.select_all_tracks ();
1169 switch (ArdourKeyboard::selection_type (ev->state)) {
1170 case Selection::Toggle:
1171 _editor.get_selection().toggle (this);
1174 case Selection::Set:
1175 _editor.get_selection().set (this);
1178 case Selection::Extend:
1179 _editor.extend_selection_to_track (*this);
1182 case Selection::Add:
1183 _editor.get_selection().add (this);
1189 RouteTimeAxisView::set_selected_points (PointSelection& points)
1191 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1192 (*i)->set_selected_points (points);
1197 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1200 _view->set_selected_regionviews (regions);
1204 /** Add the selectable things that we have to a list.
1205 * @param results List to add things to.
1208 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1212 if (get_diskstream() != 0) {
1213 speed = get_diskstream()->speed();
1216 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1217 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1219 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1220 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1223 /* pick up visible automation tracks */
1225 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1226 if (!(*i)->hidden()) {
1227 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1233 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1236 _view->get_inverted_selectables (sel, results);
1239 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1240 if (!(*i)->hidden()) {
1241 (*i)->get_inverted_selectables (sel, results);
1249 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1251 return (_show_automation.find(param) != _show_automation.end());
1254 /** Retuns 0 if track for \a param doesn't exist.
1256 RouteTimeAxisView::RouteAutomationNode*
1257 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1259 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1261 if (i != _automation_tracks.end()) {
1268 /** Shorthand for GainAutomation, etc.
1270 RouteTimeAxisView::RouteAutomationNode*
1271 RouteTimeAxisView::automation_track (AutomationType type)
1273 return automation_track (Evoral::Parameter(type));
1277 RouteTimeAxisView::route_group () const
1279 return _route->route_group();
1283 RouteTimeAxisView::name() const
1285 return _route->name();
1288 boost::shared_ptr<Playlist>
1289 RouteTimeAxisView::playlist () const
1291 boost::shared_ptr<Diskstream> ds;
1293 if ((ds = get_diskstream()) != 0) {
1294 return ds->playlist();
1296 return boost::shared_ptr<Playlist> ();
1301 RouteTimeAxisView::name_entry_changed ()
1305 x = name_entry.get_text ();
1307 if (x == _route->name()) {
1311 strip_whitespace_edges(x);
1313 if (x.length() == 0) {
1314 name_entry.set_text (_route->name());
1318 if (!_session->route_name_unique (x)) {
1319 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1320 name_entry.set_text (_route->name());
1321 } else if (_session->route_name_internal (x)) {
1322 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1323 name_entry.set_text (_route->name());
1325 _route->set_name (x);
1330 RouteTimeAxisView::visual_click ()
1332 popup_display_menu (0);
1336 RouteTimeAxisView::hide_click ()
1338 // LAME fix for hide_button refresh fix
1339 hide_button.set_sensitive(false);
1341 _editor.hide_track_in_display (*this);
1343 hide_button.set_sensitive(true);
1346 boost::shared_ptr<Region>
1347 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1349 boost::shared_ptr<Diskstream> stream;
1350 boost::shared_ptr<Playlist> playlist;
1352 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1353 return playlist->find_next_region (pos, point, dir);
1356 return boost::shared_ptr<Region> ();
1360 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1362 boost::shared_ptr<Diskstream> stream;
1363 boost::shared_ptr<Playlist> playlist;
1365 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1366 return playlist->find_next_region_boundary (pos, dir);
1373 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1375 boost::shared_ptr<Playlist> what_we_got;
1376 boost::shared_ptr<Diskstream> ds = get_diskstream();
1377 boost::shared_ptr<Playlist> playlist;
1381 /* route is a bus, not a track */
1385 playlist = ds->playlist();
1387 TimeSelection time (selection.time);
1388 float speed = ds->speed();
1389 if (speed != 1.0f) {
1390 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1391 (*i).start = session_frame_to_track_frame((*i).start, speed);
1392 (*i).end = session_frame_to_track_frame((*i).end, speed);
1396 playlist->clear_history ();
1397 playlist->clear_owned_history ();
1401 if ((what_we_got = playlist->cut (time)) != 0) {
1402 _editor.get_cut_buffer().add (what_we_got);
1404 vector<StatefulDiffCommand*> cmds;
1406 playlist->rdiff (cmds);
1408 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1409 _session->add_command (*c);
1411 _session->add_command (new StatefulDiffCommand (playlist));
1416 if ((what_we_got = playlist->copy (time)) != 0) {
1417 _editor.get_cut_buffer().add (what_we_got);
1422 if ((what_we_got = playlist->cut (time)) != 0) {
1423 vector<StatefulDiffCommand*> cmds;
1425 playlist->rdiff (cmds);
1427 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1428 _session->add_command (*c);
1430 _session->add_command (new StatefulDiffCommand (playlist));
1431 what_we_got->release ();
1441 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1447 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1448 PlaylistSelection::iterator p;
1450 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1452 if (p == selection.playlists.end()) {
1456 if (get_diskstream()->speed() != 1.0f) {
1457 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1460 playlist->clear_history ();
1461 playlist->paste (*p, pos, times);
1462 _session->add_command (new StatefulDiffCommand (playlist));
1468 TimeAxisView::Children
1469 RouteTimeAxisView::get_child_list()
1471 TimeAxisView::Children redirect_children;
1473 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1474 if (!(*i)->hidden()) {
1475 redirect_children.push_back(*i);
1478 return redirect_children;
1482 struct PlaylistSorter {
1483 bool operator() (boost::shared_ptr<Playlist> a, boost::shared_ptr<Playlist> b) const {
1484 return a->sort_id() < b->sort_id();
1489 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1491 using namespace Menu_Helpers;
1493 if (!menu || !is_track()) {
1497 MenuList& playlist_items = menu->items();
1498 menu->set_name ("ArdourContextMenu");
1499 playlist_items.clear();
1501 delete playlist_menu;
1504 vector<boost::shared_ptr<Playlist> > playlists, playlists_ds;
1505 boost::shared_ptr<Diskstream> ds = get_diskstream();
1506 RadioMenuItem::Group playlist_group;
1508 _session->playlists->get (playlists);
1510 /* find the playlists for this diskstream */
1511 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1512 if (((*i)->get_orig_diskstream_id() == ds->id()) || (ds->playlist()->id() == (*i)->id())) {
1513 playlists_ds.push_back(*i);
1517 /* sort the playlists */
1519 sort(playlists_ds.begin(), playlists_ds.end(), cmp);
1521 /* add the playlists to the menu */
1522 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_ds.begin(); i != playlists_ds.end(); ++i) {
1523 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name()));
1524 RadioMenuItem *item = static_cast<RadioMenuItem*>(&playlist_items.back());
1525 item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr<Playlist> (*i)));
1527 if (ds->playlist()->id() == (*i)->id()) {
1533 playlist_items.push_back (SeparatorElem());
1534 playlist_items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1535 playlist_items.push_back (SeparatorElem());
1537 if (!route_group() || !route_group()->is_active()) {
1538 playlist_items.push_back (MenuElem (_("New"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1539 playlist_items.push_back (MenuElem (_("New Copy"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1542 // Use a label which tells the user what is happening
1543 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1544 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1548 playlist_items.push_back (SeparatorElem());
1549 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1550 playlist_items.push_back (SeparatorElem());
1552 playlist_items.push_back (MenuElem(_("Select from all ..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1556 RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr<Playlist> wpl)
1558 assert (is_track());
1560 // exit if we were triggered by deactivating the old playlist
1561 if (!item->get_active()) {
1565 boost::shared_ptr<Playlist> pl (wpl.lock());
1571 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1574 if (get_diskstream()->playlist() == apl) {
1575 // exit when use_playlist is called by the creation of the playlist menu
1576 // or the playlist choice is unchanged
1579 get_diskstream()->use_playlist (apl);
1582 if (route_group() && route_group()->is_active()) {
1583 std::string group_string = "."+route_group()->name()+".";
1585 std::string take_name = apl->name();
1586 std::string::size_type idx = take_name.find(group_string);
1588 if (idx == std::string::npos)
1591 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1593 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1595 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1596 if ( (*i) == this->route()) {
1600 std::string playlist_name = (*i)->name()+group_string+take_name;
1602 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1604 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1608 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1610 // No playlist for this track for this take yet, make it
1611 track->diskstream()->use_new_playlist();
1612 track->diskstream()->playlist()->set_name(playlist_name);
1614 track->diskstream()->use_playlist(ipl);
1622 RouteTimeAxisView::show_playlist_selector ()
1624 _editor.playlist_selector().show_for (this);
1628 RouteTimeAxisView::map_frozen ()
1634 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1636 switch (track()->freeze_state()) {
1638 playlist_button.set_sensitive (false);
1639 rec_enable_button->set_sensitive (false);
1642 playlist_button.set_sensitive (true);
1643 rec_enable_button->set_sensitive (true);
1649 RouteTimeAxisView::color_handler ()
1651 //case cTimeStretchOutline:
1652 if (timestretch_rect) {
1653 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1655 //case cTimeStretchFill:
1656 if (timestretch_rect) {
1657 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1663 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1664 * Will add track if necessary.
1667 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1669 RouteAutomationNode* node = automation_track(param);
1672 /* it doesn't exist yet, so we don't care about the button state: just add it */
1673 create_automation_child (param, true);
1675 bool yn = node->menu_item->get_active();
1676 if (node->track->set_visibility (node->menu_item->get_active()) && yn) {
1678 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1679 will have done that for us.
1683 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1690 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1692 RouteAutomationNode* ran = automation_track(param);
1698 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1699 _show_automation.erase (param);
1700 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1702 if (ran->menu_item && !_hidden) {
1703 ignore_toggle = true;
1704 ran->menu_item->set_active (false);
1705 ignore_toggle = false;
1708 if (_route && !no_redraw) {
1709 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1715 RouteTimeAxisView::show_all_automation ()
1719 /* Show our automation */
1721 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1722 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1723 i->second->track->set_marked_for_display (true);
1724 i->second->track->canvas_display()->show();
1725 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1726 if (i->second->menu_item) {
1727 i->second->menu_item->set_active(true);
1732 /* Show processor automation */
1734 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1735 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1736 if ((*ii)->view == 0) {
1737 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1740 (*ii)->menu_item->set_active (true);
1748 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1752 RouteTimeAxisView::show_existing_automation ()
1756 /* Show our automation */
1758 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1759 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1760 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1761 i->second->track->set_marked_for_display (true);
1762 i->second->track->canvas_display()->show();
1763 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1764 i->second->menu_item->set_active(true);
1769 /* Show processor automation */
1771 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1772 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1773 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1774 (*ii)->menu_item->set_active (true);
1781 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1785 RouteTimeAxisView::hide_all_automation ()
1789 /* Hide our automation */
1791 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1792 i->second->track->set_marked_for_display (false);
1793 i->second->track->hide ();
1794 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1795 if (i->second->menu_item) {
1796 i->second->menu_item->set_active (false);
1800 /* Hide processor automation */
1802 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1803 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1804 (*ii)->menu_item->set_active (false);
1808 _show_automation.clear();
1811 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1816 RouteTimeAxisView::region_view_added (RegionView* rv)
1818 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1819 if (is_audio_track()) {
1820 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1821 boost::shared_ptr<AutomationTimeAxisView> atv;
1823 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1829 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1830 (*i)->add_ghost(rv);
1834 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1836 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1842 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1844 parent.remove_processor_automation_node (this);
1848 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1851 remove_child (pan->view);
1855 RouteTimeAxisView::ProcessorAutomationNode*
1856 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1858 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1860 if ((*i)->processor == processor) {
1862 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1863 if ((*ii)->what == what) {
1874 legalize_for_xml_node (string str)
1876 string::size_type pos;
1877 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1883 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1884 legal.replace (pos, 1, "_");
1893 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1896 ProcessorAutomationNode* pan;
1898 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1899 error << _("programming error: ")
1900 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1901 processor->name(), what)
1911 name = processor->describe_parameter (what);
1913 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1917 char state_name[256];
1918 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1920 boost::shared_ptr<AutomationControl> control
1921 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1923 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1924 new AutomationTimeAxisView (_session, _route, processor, control,
1925 _editor, *this, false, parent_canvas, name, state_name));
1927 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1929 if (!pan->view->marked_for_display()) {
1932 pan->menu_item->set_active (true);
1935 add_child (pan->view);
1938 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1941 processor->mark_automation_visible (what, true);
1945 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1948 pan->menu_item->set_active (false);
1951 i->mark_automation_visible (pan->what, false);
1954 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1959 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1961 boost::shared_ptr<Processor> processor (p.lock ());
1966 set<Evoral::Parameter> s;
1967 boost::shared_ptr<AutomationLine> al;
1969 processor->what_has_visible_data (s);
1971 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1973 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1976 add_processor_automation_curve (processor, (*i));
1982 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1984 using namespace Menu_Helpers;
1991 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1993 bool hideit = (!show);
1995 if ((node = track->get_state_node()) != 0) {
1996 if ((prop = node->property ("shown")) != 0) {
1997 if (string_is_affirmative (prop->value())) {
2003 _automation_tracks.insert (std::make_pair (param, new RouteAutomationNode(param, NULL, track)));
2005 track->set_visibility (!hideit);
2008 _show_automation.insert (param);
2012 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2015 if (!EventTypeMap::instance().is_midi_parameter(param)) {
2016 /* MIDI-related parameters are always in the menu, there's no
2017 reason to rebuild the menu just because we added a automation
2018 lane for one of them. But if we add a non-MIDI automation
2019 lane, then we need to invalidate the display menu.
2021 delete display_menu;
2027 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
2029 boost::shared_ptr<Processor> processor (p.lock ());
2031 if (!processor || !processor->display_to_user ()) {
2035 using namespace Menu_Helpers;
2036 ProcessorAutomationInfo *rai;
2037 list<ProcessorAutomationInfo*>::iterator x;
2039 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2040 std::set<Evoral::Parameter> has_visible_automation;
2042 processor->what_has_visible_data(has_visible_automation);
2044 if (automatable.empty()) {
2048 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2049 if ((*x)->processor == processor) {
2054 if (x == processor_automation.end()) {
2056 rai = new ProcessorAutomationInfo (processor);
2057 processor_automation.push_back (rai);
2065 /* any older menu was deleted at the top of processors_changed()
2066 when we cleared the subplugin menu.
2069 rai->menu = manage (new Menu);
2070 MenuList& items = rai->menu->items();
2071 rai->menu->set_name ("ArdourContextMenu");
2075 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2077 ProcessorAutomationNode* pan;
2078 CheckMenuItem* mitem;
2080 string name = processor->describe_parameter (*i);
2082 items.push_back (CheckMenuElem (name));
2083 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2085 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2086 mitem->set_active(true);
2089 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2093 pan = new ProcessorAutomationNode (*i, mitem, *this);
2095 rai->lines.push_back (pan);
2099 pan->menu_item = mitem;
2103 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2106 /* add the menu for this processor, because the subplugin
2107 menu is always cleared at the top of processors_changed().
2108 this is the result of some poor design in gtkmm and/or
2112 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2117 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2118 RouteTimeAxisView::ProcessorAutomationNode* pan)
2120 bool showit = pan->menu_item->get_active();
2121 bool redraw = false;
2123 if (pan->view == 0 && showit) {
2124 add_processor_automation_curve (rai->processor, pan->what);
2128 if (pan->view && showit != pan->view->marked_for_display()) {
2131 pan->view->set_marked_for_display (true);
2132 pan->view->canvas_display()->show();
2133 pan->view->canvas_background()->show();
2135 rai->processor->mark_automation_visible (pan->what, true);
2136 pan->view->set_marked_for_display (false);
2144 if (redraw && !no_redraw) {
2145 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2151 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2153 if (c.type == RouteProcessorChange::MeterPointChange) {
2154 /* nothing to do if only the meter point has changed */
2158 using namespace Menu_Helpers;
2160 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2161 (*i)->valid = false;
2164 subplugin_menu.items().clear ();
2166 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2167 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2169 bool deleted_processor_automation = false;
2171 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2173 list<ProcessorAutomationInfo*>::iterator tmp;
2181 processor_automation.erase (i);
2182 deleted_processor_automation = true;
2189 if (deleted_processor_automation && !no_redraw) {
2190 _route->gui_changed ("track_height", this);
2194 boost::shared_ptr<AutomationLine>
2195 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2197 ProcessorAutomationNode* pan;
2199 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2205 return boost::shared_ptr<AutomationLine>();
2209 RouteTimeAxisView::reset_processor_automation_curves ()
2211 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2217 RouteTimeAxisView::update_rec_display ()
2219 RouteUI::update_rec_display ();
2220 name_entry.set_sensitive (!_route->record_enabled());
2224 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2227 _view->set_layer_display (d);
2231 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2235 RouteTimeAxisView::layer_display () const
2238 return _view->layer_display ();
2241 /* we don't know, since we don't have a _view, so just return something */
2247 boost::shared_ptr<AutomationTimeAxisView>
2248 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2250 AutomationTracks::iterator i = _automation_tracks.find(param);
2251 if (i != _automation_tracks.end()) {
2252 return i->second->track;
2254 return boost::shared_ptr<AutomationTimeAxisView>();
2259 RouteTimeAxisView::fast_update ()
2261 gm.get_level_meter().update_meters ();
2265 RouteTimeAxisView::hide_meter ()
2268 gm.get_level_meter().hide_meters ();
2272 RouteTimeAxisView::show_meter ()
2278 RouteTimeAxisView::reset_meter ()
2280 if (Config->get_show_track_meters()) {
2281 gm.get_level_meter().setup_meters (height-5);
2288 RouteTimeAxisView::clear_meter ()
2290 gm.get_level_meter().clear_meters ();
2294 RouteTimeAxisView::meter_changed ()
2296 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed)
2301 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2307 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2309 using namespace Menu_Helpers;
2311 if (!_underlay_streams.empty()) {
2312 MenuList& parent_items = parent_menu->items();
2313 Menu* gs_menu = manage (new Menu);
2314 gs_menu->set_name ("ArdourContextMenu");
2315 MenuList& gs_items = gs_menu->items();
2317 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2319 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2320 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2321 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2327 RouteTimeAxisView::set_underlay_state()
2329 if (!underlay_xml_node) {
2333 XMLNodeList nlist = underlay_xml_node->children();
2334 XMLNodeConstIterator niter;
2335 XMLNode *child_node;
2337 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2338 child_node = *niter;
2340 if (child_node->name() != "Underlay") {
2344 XMLProperty* prop = child_node->property ("id");
2346 PBD::ID id (prop->value());
2348 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2351 add_underlay(v->view(), false);
2360 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2366 RouteTimeAxisView& other = v->trackview();
2368 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2369 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2370 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2374 _underlay_streams.push_back(v);
2375 other._underlay_mirrors.push_back(this);
2377 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2380 if (!underlay_xml_node) {
2382 underlay_xml_node = xml_node->add_child("Underlays");
2385 XMLNode* node = underlay_xml_node->add_child("Underlay");
2386 XMLProperty* prop = node->add_property("id");
2387 prop->set_value(v->trackview().route()->id().to_s());
2393 RouteTimeAxisView::remove_underlay (StreamView* v)
2399 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2400 RouteTimeAxisView& other = v->trackview();
2402 if (it != _underlay_streams.end()) {
2403 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2405 if (gm == other._underlay_mirrors.end()) {
2406 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2410 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2412 _underlay_streams.erase(it);
2413 other._underlay_mirrors.erase(gm);
2415 if (underlay_xml_node) {
2416 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2422 RouteTimeAxisView::set_button_names ()
2424 rec_enable_button_label.set_text (_("r"));
2426 if (_route && _route->solo_safe()) {
2427 solo_button_label.set_text (X_("!"));
2429 if (Config->get_solo_control_is_listen_control()) {
2430 switch (Config->get_listen_position()) {
2431 case AfterFaderListen:
2432 solo_button_label.set_text (_("A"));
2434 case PreFaderListen:
2435 solo_button_label.set_text (_("P"));
2439 solo_button_label.set_text (_("s"));
2442 mute_button_label.set_text (_("m"));