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)
121 gm.set_controls (_route, _route->shared_peak_meter(), _route->amp());
122 gm.get_level_meter().set_no_show_all();
123 gm.get_level_meter().setup_meters(50);
127 playlist_action_menu = 0;
128 automation_action_menu = 0;
129 plugins_submenu_item = 0;
133 if (!_route->is_hidden()) {
134 _marked_for_display = true;
137 timestretch_rect = 0;
139 destructive_track_mode_item = 0;
140 normal_track_mode_item = 0;
141 non_layered_track_mode_item = 0;
143 ignore_toggle = false;
145 route_group_button.set_name ("TrackGroupButton");
146 playlist_button.set_name ("TrackPlaylistButton");
147 automation_button.set_name ("TrackAutomationButton");
148 size_button.set_name ("TrackSizeButton");
149 visual_button.set_name ("TrackVisualButton");
150 hide_button.set_name ("TrackRemoveButton");
152 route_group_button.unset_flags (Gtk::CAN_FOCUS);
153 playlist_button.unset_flags (Gtk::CAN_FOCUS);
154 automation_button.unset_flags (Gtk::CAN_FOCUS);
155 size_button.unset_flags (Gtk::CAN_FOCUS);
156 visual_button.unset_flags (Gtk::CAN_FOCUS);
157 hide_button.unset_flags (Gtk::CAN_FOCUS);
159 hide_button.add (*(manage (new Image (::get_icon("hide")))));
160 hide_button.show_all ();
162 route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::edit_click), false);
163 playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
164 automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
165 size_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::size_click), false);
166 visual_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::visual_click));
167 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::hide_click));
173 rec_enable_button->remove ();
175 switch (track()->mode()) {
177 case ARDOUR::NonLayered:
178 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
180 case ARDOUR::Destructive:
181 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
184 rec_enable_button->show_all ();
186 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
187 ARDOUR_UI::instance()->set_tip(*rec_enable_button, _("Record"));
189 rec_enable_button->set_sensitive (_session->writable());
192 controls_hbox.pack_start(gm.get_level_meter(), false, false);
193 _route->meter_change.connect (*this, ui_bind (&RouteTimeAxisView::meter_changed, this, _1), gui_context());
194 _route->input()->changed.connect (*this, ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
195 _route->output()->changed.connect (*this, ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
197 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
198 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
200 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
201 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
203 ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo"));
204 ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute"));
205 ARDOUR_UI::instance()->set_tip(route_group_button, _("Route Group"));
206 ARDOUR_UI::instance()->set_tip(size_button,_("Display Height"));
207 ARDOUR_UI::instance()->set_tip(playlist_button,_("Playlist"));
208 ARDOUR_UI::instance()->set_tip(automation_button, _("Automation"));
209 ARDOUR_UI::instance()->set_tip(visual_button, _("Visual options"));
210 ARDOUR_UI::instance()->set_tip(hide_button, _("Hide this track"));
216 /* old school - when we used to put an extra row of buttons in place */
218 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
219 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
220 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
221 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
225 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
228 if (is_track() && track()->mode() == ARDOUR::Normal) {
229 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
234 _route->processors_changed.connect (*this, ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
235 _route->PropertyChanged.connect (*this, ui_bind (&RouteTimeAxisView::route_property_changed, this, _1), gui_context());
239 track()->TrackModeChanged.connect (*this, boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
240 track()->FreezeChange.connect (*this, boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
241 track()->DiskstreamChanged.connect (*this, boost::bind (&RouteTimeAxisView::diskstream_changed, this), gui_context());
242 get_diskstream()->SpeedChanged.connect (*this, boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
244 /* pick up the correct freeze state */
249 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
250 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
252 PropertyList* plist = new PropertyList();
254 plist->add (ARDOUR::Properties::edit, true);
255 plist->add (ARDOUR::Properties::mute, true);
256 plist->add (ARDOUR::Properties::solo, true);
258 route_group_menu = new RouteGroupMenu (_session, plist);
259 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
261 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
262 gm.get_gain_slider().set_name ("TrackGainFader");
265 RouteTimeAxisView::~RouteTimeAxisView ()
267 CatchDeletion (this);
269 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
273 delete playlist_menu;
276 delete playlist_action_menu;
277 playlist_action_menu = 0;
282 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
286 _automation_tracks.clear ();
288 delete route_group_menu;
292 RouteTimeAxisView::post_construct ()
294 /* map current state of the route */
296 update_diskstream_display ();
298 subplugin_menu.items().clear ();
299 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
300 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
301 reset_processor_automation_curves ();
305 RouteTimeAxisView::edit_click (GdkEventButton *ev)
307 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
308 if (_route->route_group()) {
309 _route->route_group()->remove (_route);
314 route_group_menu->rebuild (_route->route_group ());
315 route_group_menu->popup (ev->button, ev->time);
321 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
326 if (_route->route_group()) {
327 _route->route_group()->remove (_route);
333 RouteTimeAxisView::playlist_changed ()
339 RouteTimeAxisView::label_view ()
341 string x = _route->name();
343 if (x != name_entry.get_text()) {
344 name_entry.set_text (x);
347 ARDOUR_UI::instance()->set_tip (name_entry, x);
351 RouteTimeAxisView::route_property_changed (const PropertyChange& what_changed)
353 if (what_changed.contains (ARDOUR::Properties::name)) {
359 RouteTimeAxisView::take_name_changed (void *src)
368 RouteTimeAxisView::playlist_click ()
370 // always build a new action menu
372 delete playlist_action_menu;
374 playlist_action_menu = new Menu;
375 playlist_action_menu->set_name ("ArdourContextMenu");
377 build_playlist_menu (playlist_action_menu);
379 conditionally_add_to_selection ();
380 playlist_action_menu->popup (1, gtk_get_current_event_time());
384 RouteTimeAxisView::automation_click ()
386 conditionally_add_to_selection ();
387 build_automation_action_menu ();
388 automation_action_menu->popup (1, gtk_get_current_event_time());
392 RouteTimeAxisView::set_state (const XMLNode& node, int version)
394 TimeAxisView::set_state (node, version);
396 XMLNodeList kids = node.children();
397 XMLNodeConstIterator iter;
398 const XMLProperty* prop;
400 if (_view && (prop = node.property ("layer-display"))) {
401 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
404 for (iter = kids.begin(); iter != kids.end(); ++iter) {
405 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
406 if ((prop = (*iter)->property ("automation-id")) != 0) {
408 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
409 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
410 create_automation_child(param, show);
412 warning << "Automation child has no ID" << endmsg;
421 RouteTimeAxisView::build_automation_action_menu ()
423 using namespace Menu_Helpers;
425 delete automation_action_menu;
426 automation_action_menu = new Menu;
428 MenuList& items = automation_action_menu->items();
430 automation_action_menu->set_name ("ArdourContextMenu");
432 items.push_back (MenuElem (_("Show All Automation"),
433 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
435 items.push_back (MenuElem (_("Show Existing Automation"),
436 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
438 items.push_back (MenuElem (_("Hide All Automation"),
439 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
441 /* attach the plugin submenu. It may have previously been used elsewhere, so we detach it first. */
443 detach_menu (subplugin_menu);
444 items.push_back (MenuElem (_("Plugins"), subplugin_menu));
445 items.back().set_sensitive (!subplugin_menu.items().empty());
449 RouteTimeAxisView::build_display_menu ()
451 using namespace Menu_Helpers;
453 /* get the size menu ready */
459 TimeAxisView::build_display_menu ();
461 /* now fill it with our stuff */
463 MenuList& items = display_menu->items();
464 display_menu->set_name ("ArdourContextMenu");
466 items.push_back (MenuElem (_("Height"), *size_menu));
467 items.push_back (MenuElem (_("Color"), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
469 items.push_back (SeparatorElem());
471 if (!Profile->get_sae()) {
472 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
473 /* rebuild this every time */
474 build_automation_action_menu ();
475 detach_menu (*automation_action_menu);
476 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
477 items.push_back (SeparatorElem());
480 // Hook for derived classes to add type specific stuff
481 append_extra_display_menu_items ();
482 items.push_back (SeparatorElem());
486 Menu *layers_menu = manage(new Menu);
487 MenuList &layers_items = layers_menu->items();
488 layers_menu->set_name("ArdourContextMenu");
490 RadioMenuItem::Group layers_group;
492 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
493 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
494 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
495 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
497 items.push_back (MenuElem (_("Layers"), *layers_menu));
499 Menu* alignment_menu = manage (new Menu);
500 MenuList& alignment_items = alignment_menu->items();
501 alignment_menu->set_name ("ArdourContextMenu");
503 RadioMenuItem::Group align_group;
505 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material"),
506 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
507 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
508 if (get_diskstream()->alignment_style() == ExistingMaterial)
509 align_existing_item->set_active();
511 alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time"),
512 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
513 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
514 if (get_diskstream()->alignment_style() == CaptureTime)
515 align_capture_item->set_active();
517 if (!Profile->get_sae()) {
519 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
520 get_diskstream()->AlignmentStyleChanged.connect (route_connections, boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
522 RadioMenuItem::Group mode_group;
523 items.push_back (RadioMenuElem (mode_group, _("Normal Mode"), sigc::bind (
524 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
526 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
528 items.push_back (RadioMenuElem (mode_group, _("Tape Mode"), sigc::bind (
529 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
530 ARDOUR::Destructive)));
531 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
533 items.push_back (RadioMenuElem (mode_group, _("Non-Layered Mode"),
534 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
535 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
538 _ignore_track_mode_change = true;
540 switch (track()->mode()) {
541 case ARDOUR::Destructive:
542 destructive_track_mode_item->set_active ();
545 normal_track_mode_item->set_active ();
547 case ARDOUR::NonLayered:
548 non_layered_track_mode_item->set_active ();
552 _ignore_track_mode_change = false;
555 get_diskstream()->AlignmentStyleChanged.connect (route_connections, boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
557 color_mode_menu = build_color_mode_menu();
558 if (color_mode_menu) {
559 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
562 items.push_back (SeparatorElem());
565 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
566 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
567 route_active_menu_item->set_active (_route->active());
569 items.push_back (SeparatorElem());
570 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &RouteTimeAxisView::hide_click)));
571 if (!Profile->get_sae()) {
572 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
574 items.push_front (SeparatorElem());
575 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
579 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
582 item_2->set_active ();
587 RouteTimeAxisView::set_track_mode (TrackMode mode)
589 if (_ignore_track_mode_change) {
594 RadioMenuItem* other_item;
595 RadioMenuItem* other_item_2;
599 item = normal_track_mode_item;
600 other_item = non_layered_track_mode_item;
601 other_item_2 = destructive_track_mode_item;
603 case ARDOUR::NonLayered:
604 item = non_layered_track_mode_item;
605 other_item = normal_track_mode_item;
606 other_item_2 = destructive_track_mode_item;
608 case ARDOUR::Destructive:
609 item = destructive_track_mode_item;
610 other_item = normal_track_mode_item;
611 other_item_2 = non_layered_track_mode_item;
614 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
619 if (item && other_item && other_item_2 && track()->mode() != mode) {
620 _set_track_mode (track().get(), mode, other_item, other_item_2);
625 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
629 if (!track->can_use_mode (mode, needs_bounce)) {
633 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
636 cerr << "would bounce this one\n";
637 /* XXX: radio menu item becomes inconsistent with track state in this case */
642 track->set_mode (mode);
644 rec_enable_button->remove ();
647 case ARDOUR::NonLayered:
649 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
651 case ARDOUR::Destructive:
652 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
656 rec_enable_button->show_all ();
660 RouteTimeAxisView::track_mode_changed ()
664 switch (track()->mode()) {
666 item = normal_track_mode_item;
668 case ARDOUR::NonLayered:
669 item = non_layered_track_mode_item;
671 case ARDOUR::Destructive:
672 item = destructive_track_mode_item;
675 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
684 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
690 TimeAxisView::show_timestretch (start, end);
700 /* check that the time selection was made in our route, or our route group.
701 remember that route_group() == 0 implies the route is *not* in a edit group.
704 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
705 /* this doesn't apply to us */
709 /* ignore it if our edit group is not active */
711 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
716 if (timestretch_rect == 0) {
717 timestretch_rect = new SimpleRect (*canvas_display ());
718 timestretch_rect->property_x1() = 0.0;
719 timestretch_rect->property_y1() = 0.0;
720 timestretch_rect->property_x2() = 0.0;
721 timestretch_rect->property_y2() = 0.0;
722 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
723 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
726 timestretch_rect->show ();
727 timestretch_rect->raise_to_top ();
729 x1 = start / _editor.get_current_zoom();
730 x2 = (end - 1) / _editor.get_current_zoom();
731 y2 = current_height() - 2;
733 timestretch_rect->property_x1() = x1;
734 timestretch_rect->property_y1() = 1.0;
735 timestretch_rect->property_x2() = x2;
736 timestretch_rect->property_y2() = y2;
740 RouteTimeAxisView::hide_timestretch ()
742 TimeAxisView::hide_timestretch ();
744 if (timestretch_rect) {
745 timestretch_rect->hide ();
750 RouteTimeAxisView::show_selection (TimeSelection& ts)
754 /* ignore it if our edit group is not active or if the selection was started
755 in some other track or route group (remember that route_group() == 0 means
756 that the track is not in an route group).
759 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
760 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
766 TimeAxisView::show_selection (ts);
770 RouteTimeAxisView::set_height (uint32_t h)
773 bool height_changed = (height == 0) || (h != height);
774 gm.get_level_meter().setup_meters (gmlen);
776 TimeAxisView::set_height (h);
781 _view->set_height ((double) current_height());
785 snprintf (buf, sizeof (buf), "%u", height);
786 xml_node->add_property ("height", buf);
788 if (height >= hNormal) {
793 gm.get_gain_slider().show();
795 if (!_route || _route->is_monitor()) {
800 if (rec_enable_button)
801 rec_enable_button->show();
803 route_group_button.show();
805 visual_button.show();
807 automation_button.show();
809 if (is_track() && track()->mode() == ARDOUR::Normal) {
810 playlist_button.show();
813 } else if (height >= hSmaller) {
819 gm.get_gain_slider().hide();
821 if (!_route || _route->is_monitor()) {
826 if (rec_enable_button)
827 rec_enable_button->show();
829 route_group_button.hide ();
831 visual_button.hide ();
833 automation_button.hide ();
835 if (is_track() && track()->mode() == ARDOUR::Normal) {
836 playlist_button.hide ();
842 /* don't allow name_entry to be hidden while
843 it has focus, otherwise the GUI becomes unusable.
846 if (name_entry.has_focus()) {
847 if (name_entry.get_text() != _route->name()) {
848 name_entry_changed ();
850 controls_ebox.grab_focus ();
856 gm.get_gain_slider().hide();
859 if (rec_enable_button)
860 rec_enable_button->hide();
862 route_group_button.hide ();
864 visual_button.hide ();
866 automation_button.hide ();
867 playlist_button.hide ();
868 name_label.set_text (_route->name());
871 if (height_changed && !no_redraw) {
872 /* only emit the signal if the height really changed */
873 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
878 RouteTimeAxisView::select_track_color ()
880 if (RouteUI::choose_color ()) {
883 _view->apply_color (_color, StreamView::RegionColor);
889 RouteTimeAxisView::reset_samples_per_unit ()
891 set_samples_per_unit (_editor.get_current_zoom());
895 RouteTimeAxisView::set_samples_per_unit (double spu)
899 if (get_diskstream() != 0) {
900 speed = get_diskstream()->speed();
904 _view->set_samples_per_unit (spu * speed);
907 TimeAxisView::set_samples_per_unit (spu * speed);
911 RouteTimeAxisView::align_style_changed ()
913 switch (get_diskstream()->alignment_style()) {
914 case ExistingMaterial:
915 if (!align_existing_item->get_active()) {
916 align_existing_item->set_active();
920 if (!align_capture_item->get_active()) {
921 align_capture_item->set_active();
928 RouteTimeAxisView::set_align_style (AlignStyle style)
933 case ExistingMaterial:
934 item = align_existing_item;
937 item = align_capture_item;
940 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
945 if (item->get_active()) {
946 get_diskstream()->set_align_style (style);
951 RouteTimeAxisView::rename_current_playlist ()
953 ArdourPrompter prompter (true);
956 boost::shared_ptr<Diskstream> ds = get_diskstream();
957 if (!ds || ds->destructive())
960 boost::shared_ptr<Playlist> pl = ds->playlist();
964 prompter.set_prompt (_("Name for playlist"));
965 prompter.set_initial_text (pl->name());
966 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
967 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
969 switch (prompter.run ()) {
970 case Gtk::RESPONSE_ACCEPT:
971 prompter.get_result (name);
983 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
985 std::string ret (basename);
987 std::string const group_string = "." + route_group()->name() + ".";
989 // iterate through all playlists
991 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
992 std::string tmp = (*i)->name();
994 std::string::size_type idx = tmp.find(group_string);
995 // find those which belong to this group
996 if (idx != string::npos) {
997 tmp = tmp.substr(idx + group_string.length());
999 // and find the largest current number
1000 int x = atoi(tmp.c_str());
1001 if (x > maxnumber) {
1010 snprintf (buf, sizeof(buf), "%d", maxnumber);
1012 ret = this->name() + "." + route_group()->name () + "." + buf;
1018 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1022 boost::shared_ptr<Diskstream> ds = get_diskstream();
1023 if (!ds || ds->destructive())
1026 boost::shared_ptr<const Playlist> pl = ds->playlist();
1032 if (route_group() && route_group()->is_active()) {
1033 name = resolve_new_group_playlist_name(name, playlists_before_op);
1036 while (_session->playlists->by_name(name)) {
1037 name = Playlist::bump_name (name, *_session);
1040 // TODO: The prompter "new" button should be de-activated if the user
1041 // specifies a playlist name which already exists in the session.
1045 ArdourPrompter prompter (true);
1047 prompter.set_prompt (_("Name for Playlist"));
1048 prompter.set_initial_text (name);
1049 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1050 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1051 prompter.show_all ();
1053 switch (prompter.run ()) {
1054 case Gtk::RESPONSE_ACCEPT:
1055 prompter.get_result (name);
1063 if (name.length()) {
1064 ds->use_copy_playlist ();
1065 ds->playlist()->set_name (name);
1070 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1074 boost::shared_ptr<Diskstream> ds = get_diskstream();
1075 if (!ds || ds->destructive())
1078 boost::shared_ptr<const Playlist> pl = ds->playlist();
1084 if (route_group() && route_group()->is_active()) {
1085 name = resolve_new_group_playlist_name(name,playlists_before_op);
1088 while (_session->playlists->by_name(name)) {
1089 name = Playlist::bump_name (name, *_session);
1095 ArdourPrompter prompter (true);
1097 prompter.set_prompt (_("Name for Playlist"));
1098 prompter.set_initial_text (name);
1099 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1100 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1102 switch (prompter.run ()) {
1103 case Gtk::RESPONSE_ACCEPT:
1104 prompter.get_result (name);
1112 if (name.length()) {
1113 ds->use_new_playlist ();
1114 ds->playlist()->set_name (name);
1119 RouteTimeAxisView::clear_playlist ()
1121 boost::shared_ptr<Diskstream> ds = get_diskstream();
1122 if (!ds || ds->destructive())
1125 boost::shared_ptr<Playlist> pl = ds->playlist();
1129 _editor.clear_playlist (pl);
1133 RouteTimeAxisView::speed_changed ()
1135 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1139 RouteTimeAxisView::diskstream_changed ()
1141 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::update_diskstream_display, this));
1145 RouteTimeAxisView::update_diskstream_display ()
1147 if (!get_diskstream()) // bus
1154 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1156 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1158 /* special case: select/deselect all tracks */
1159 if (_editor.get_selection().selected (this)) {
1160 _editor.get_selection().clear_tracks ();
1162 _editor.select_all_tracks ();
1168 switch (ArdourKeyboard::selection_type (ev->state)) {
1169 case Selection::Toggle:
1170 _editor.get_selection().toggle (this);
1173 case Selection::Set:
1174 _editor.get_selection().set (this);
1177 case Selection::Extend:
1178 _editor.extend_selection_to_track (*this);
1181 case Selection::Add:
1182 _editor.get_selection().add (this);
1188 RouteTimeAxisView::set_selected_points (PointSelection& points)
1190 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1191 (*i)->set_selected_points (points);
1196 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1199 _view->set_selected_regionviews (regions);
1203 /** Add the selectable things that we have to a list.
1204 * @param results List to add things to.
1207 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1211 if (get_diskstream() != 0) {
1212 speed = get_diskstream()->speed();
1215 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1216 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1218 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1219 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1222 /* pick up visible automation tracks */
1224 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1225 if (!(*i)->hidden()) {
1226 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1232 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1235 _view->get_inverted_selectables (sel, results);
1238 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1239 if (!(*i)->hidden()) {
1240 (*i)->get_inverted_selectables (sel, results);
1248 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1250 return (_show_automation.find(param) != _show_automation.end());
1253 /** Retuns 0 if track for \a param doesn't exist.
1255 RouteTimeAxisView::RouteAutomationNode*
1256 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1258 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1260 if (i != _automation_tracks.end()) {
1267 /** Shorthand for GainAutomation, etc.
1269 RouteTimeAxisView::RouteAutomationNode*
1270 RouteTimeAxisView::automation_track (AutomationType type)
1272 return automation_track (Evoral::Parameter(type));
1276 RouteTimeAxisView::route_group () const
1278 return _route->route_group();
1282 RouteTimeAxisView::name() const
1284 return _route->name();
1287 boost::shared_ptr<Playlist>
1288 RouteTimeAxisView::playlist () const
1290 boost::shared_ptr<Diskstream> ds;
1292 if ((ds = get_diskstream()) != 0) {
1293 return ds->playlist();
1295 return boost::shared_ptr<Playlist> ();
1300 RouteTimeAxisView::name_entry_changed ()
1304 x = name_entry.get_text ();
1306 if (x == _route->name()) {
1310 strip_whitespace_edges(x);
1312 if (x.length() == 0) {
1313 name_entry.set_text (_route->name());
1317 if (!_session->route_name_unique (x)) {
1318 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1319 name_entry.set_text (_route->name());
1320 } else if (_session->route_name_internal (x)) {
1321 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1322 name_entry.set_text (_route->name());
1324 _route->set_name (x);
1329 RouteTimeAxisView::visual_click ()
1331 popup_display_menu (0);
1335 RouteTimeAxisView::hide_click ()
1337 // LAME fix for hide_button refresh fix
1338 hide_button.set_sensitive(false);
1340 _editor.hide_track_in_display (*this);
1342 hide_button.set_sensitive(true);
1345 boost::shared_ptr<Region>
1346 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1348 boost::shared_ptr<Diskstream> stream;
1349 boost::shared_ptr<Playlist> playlist;
1351 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1352 return playlist->find_next_region (pos, point, dir);
1355 return boost::shared_ptr<Region> ();
1359 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1361 boost::shared_ptr<Diskstream> stream;
1362 boost::shared_ptr<Playlist> playlist;
1364 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1365 return playlist->find_next_region_boundary (pos, dir);
1372 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1374 boost::shared_ptr<Playlist> what_we_got;
1375 boost::shared_ptr<Diskstream> ds = get_diskstream();
1376 boost::shared_ptr<Playlist> playlist;
1380 /* route is a bus, not a track */
1384 playlist = ds->playlist();
1386 TimeSelection time (selection.time);
1387 float speed = ds->speed();
1388 if (speed != 1.0f) {
1389 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1390 (*i).start = session_frame_to_track_frame((*i).start, speed);
1391 (*i).end = session_frame_to_track_frame((*i).end, speed);
1395 playlist->clear_history ();
1396 playlist->clear_owned_history ();
1400 if ((what_we_got = playlist->cut (time)) != 0) {
1401 _editor.get_cut_buffer().add (what_we_got);
1403 vector<StatefulDiffCommand*> cmds;
1405 playlist->rdiff (cmds);
1407 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1408 _session->add_command (*c);
1410 _session->add_command (new StatefulDiffCommand (playlist));
1415 if ((what_we_got = playlist->copy (time)) != 0) {
1416 _editor.get_cut_buffer().add (what_we_got);
1421 if ((what_we_got = playlist->cut (time)) != 0) {
1422 vector<StatefulDiffCommand*> cmds;
1424 playlist->rdiff (cmds);
1426 for (vector<StatefulDiffCommand*>::iterator c = cmds.begin(); c != cmds.end(); ++c) {
1427 _session->add_command (*c);
1429 _session->add_command (new StatefulDiffCommand (playlist));
1430 what_we_got->release ();
1440 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1446 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1447 PlaylistSelection::iterator p;
1449 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1451 if (p == selection.playlists.end()) {
1455 if (get_diskstream()->speed() != 1.0f) {
1456 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1459 playlist->clear_history ();
1460 playlist->paste (*p, pos, times);
1461 _session->add_command (new StatefulDiffCommand (playlist));
1467 TimeAxisView::Children
1468 RouteTimeAxisView::get_child_list()
1470 TimeAxisView::Children redirect_children;
1472 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1473 if (!(*i)->hidden()) {
1474 redirect_children.push_back(*i);
1477 return redirect_children;
1481 struct PlaylistSorter {
1482 bool operator() (boost::shared_ptr<Playlist> a, boost::shared_ptr<Playlist> b) const {
1483 return a->sort_id() < b->sort_id();
1488 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1490 using namespace Menu_Helpers;
1492 if (!menu || !is_track()) {
1496 MenuList& playlist_items = menu->items();
1497 menu->set_name ("ArdourContextMenu");
1498 playlist_items.clear();
1500 delete playlist_menu;
1503 vector<boost::shared_ptr<Playlist> > playlists, playlists_ds;
1504 boost::shared_ptr<Diskstream> ds = get_diskstream();
1505 RadioMenuItem::Group playlist_group;
1507 _session->playlists->get (playlists);
1509 /* find the playlists for this diskstream */
1510 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1511 if (((*i)->get_orig_diskstream_id() == ds->id()) || (ds->playlist()->id() == (*i)->id())) {
1512 playlists_ds.push_back(*i);
1516 /* sort the playlists */
1518 sort(playlists_ds.begin(), playlists_ds.end(), cmp);
1520 /* add the playlists to the menu */
1521 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_ds.begin(); i != playlists_ds.end(); ++i) {
1522 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name()));
1523 RadioMenuItem *item = static_cast<RadioMenuItem*>(&playlist_items.back());
1524 item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr<Playlist> (*i)));
1526 if (ds->playlist()->id() == (*i)->id()) {
1532 playlist_items.push_back (SeparatorElem());
1533 playlist_items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1534 playlist_items.push_back (SeparatorElem());
1536 if (!route_group() || !route_group()->is_active()) {
1537 playlist_items.push_back (MenuElem (_("New"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1538 playlist_items.push_back (MenuElem (_("New Copy"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1541 // Use a label which tells the user what is happening
1542 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1543 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1547 playlist_items.push_back (SeparatorElem());
1548 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1549 playlist_items.push_back (SeparatorElem());
1551 playlist_items.push_back (MenuElem(_("Select from all ..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1555 RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr<Playlist> wpl)
1557 assert (is_track());
1559 // exit if we were triggered by deactivating the old playlist
1560 if (!item->get_active()) {
1564 boost::shared_ptr<Playlist> pl (wpl.lock());
1570 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1573 if (get_diskstream()->playlist() == apl) {
1574 // exit when use_playlist is called by the creation of the playlist menu
1575 // or the playlist choice is unchanged
1578 get_diskstream()->use_playlist (apl);
1581 if (route_group() && route_group()->is_active()) {
1582 std::string group_string = "."+route_group()->name()+".";
1584 std::string take_name = apl->name();
1585 std::string::size_type idx = take_name.find(group_string);
1587 if (idx == std::string::npos)
1590 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1592 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1594 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1595 if ( (*i) == this->route()) {
1599 std::string playlist_name = (*i)->name()+group_string+take_name;
1601 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1603 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1607 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1609 // No playlist for this track for this take yet, make it
1610 track->diskstream()->use_new_playlist();
1611 track->diskstream()->playlist()->set_name(playlist_name);
1613 track->diskstream()->use_playlist(ipl);
1621 RouteTimeAxisView::show_playlist_selector ()
1623 _editor.playlist_selector().show_for (this);
1627 RouteTimeAxisView::map_frozen ()
1633 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1635 switch (track()->freeze_state()) {
1637 playlist_button.set_sensitive (false);
1638 rec_enable_button->set_sensitive (false);
1641 playlist_button.set_sensitive (true);
1642 rec_enable_button->set_sensitive (true);
1648 RouteTimeAxisView::color_handler ()
1650 //case cTimeStretchOutline:
1651 if (timestretch_rect) {
1652 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1654 //case cTimeStretchFill:
1655 if (timestretch_rect) {
1656 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1662 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1663 * Will add track if necessary.
1666 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter& param)
1668 RouteAutomationNode* node = automation_track(param);
1671 /* it doesn't exist yet, so we don't care about the button state: just add it */
1672 create_automation_child (param, true);
1674 bool yn = node->menu_item->get_active();
1675 if (node->track->set_visibility (node->menu_item->get_active()) && yn) {
1677 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1678 will have done that for us.
1682 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1689 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1691 RouteAutomationNode* ran = automation_track(param);
1697 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1698 _show_automation.erase (param);
1699 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1701 if (ran->menu_item && !_hidden) {
1702 ignore_toggle = true;
1703 ran->menu_item->set_active (false);
1704 ignore_toggle = false;
1707 if (_route && !no_redraw) {
1708 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1714 RouteTimeAxisView::show_all_automation ()
1718 /* Show our automation */
1720 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1721 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1722 i->second->track->set_marked_for_display (true);
1723 i->second->track->canvas_display()->show();
1724 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1725 if (i->second->menu_item) {
1726 i->second->menu_item->set_active(true);
1731 /* Show processor automation */
1733 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1734 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1735 if ((*ii)->view == 0) {
1736 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1739 (*ii)->menu_item->set_active (true);
1747 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1751 RouteTimeAxisView::show_existing_automation ()
1755 /* Show our automation */
1757 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1758 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1759 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1760 i->second->track->set_marked_for_display (true);
1761 i->second->track->canvas_display()->show();
1762 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1763 i->second->menu_item->set_active(true);
1768 /* Show processor automation */
1770 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1771 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1772 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1773 (*ii)->menu_item->set_active (true);
1780 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1784 RouteTimeAxisView::hide_all_automation ()
1788 /* Hide our automation */
1790 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1791 i->second->track->set_marked_for_display (false);
1792 i->second->track->hide ();
1793 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1794 if (i->second->menu_item) {
1795 i->second->menu_item->set_active (false);
1799 /* Hide processor automation */
1801 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1802 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1803 (*ii)->menu_item->set_active (false);
1807 _show_automation.clear();
1810 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1815 RouteTimeAxisView::region_view_added (RegionView* rv)
1817 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1818 if (is_audio_track()) {
1819 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1820 boost::shared_ptr<AutomationTimeAxisView> atv;
1822 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1828 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1829 (*i)->add_ghost(rv);
1833 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1835 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1841 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1843 parent.remove_processor_automation_node (this);
1847 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1850 remove_child (pan->view);
1854 RouteTimeAxisView::ProcessorAutomationNode*
1855 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1857 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1859 if ((*i)->processor == processor) {
1861 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1862 if ((*ii)->what == what) {
1873 legalize_for_xml_node (string str)
1875 string::size_type pos;
1876 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1882 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1883 legal.replace (pos, 1, "_");
1892 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1895 ProcessorAutomationNode* pan;
1897 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1898 error << _("programming error: ")
1899 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1900 processor->name(), what)
1910 name = processor->describe_parameter (what);
1912 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1916 char state_name[256];
1917 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1919 boost::shared_ptr<AutomationControl> control
1920 = boost::dynamic_pointer_cast<AutomationControl>(processor->control(what, true));
1922 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1923 new AutomationTimeAxisView (_session, _route, processor, control,
1924 _editor, *this, false, parent_canvas, name, state_name));
1926 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1928 if (!pan->view->marked_for_display()) {
1931 pan->menu_item->set_active (true);
1934 add_child (pan->view);
1937 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1940 processor->mark_automation_visible (what, true);
1944 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1947 pan->menu_item->set_active (false);
1950 i->mark_automation_visible (pan->what, false);
1953 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1958 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1960 boost::shared_ptr<Processor> processor (p.lock ());
1965 set<Evoral::Parameter> s;
1966 boost::shared_ptr<AutomationLine> al;
1968 processor->what_has_visible_data (s);
1970 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1972 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1975 add_processor_automation_curve (processor, (*i));
1981 RouteTimeAxisView::add_automation_child (Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1983 using namespace Menu_Helpers;
1990 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1992 bool hideit = (!show);
1994 if ((node = track->get_state_node()) != 0) {
1995 if ((prop = node->property ("shown")) != 0) {
1996 if (string_is_affirmative (prop->value())) {
2002 _automation_tracks.insert (std::make_pair (param, new RouteAutomationNode(param, NULL, track)));
2004 track->set_visibility (!hideit);
2007 _show_automation.insert (param);
2011 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2014 if (!EventTypeMap::instance().is_midi_parameter(param)) {
2015 /* MIDI-related parameters are always in the menu, there's no
2016 reason to rebuild the menu just because we added a automation
2017 lane for one of them. But if we add a non-MIDI automation
2018 lane, then we need to invalidate the display menu.
2020 delete display_menu;
2026 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
2028 boost::shared_ptr<Processor> processor (p.lock ());
2030 if (!processor || !processor->display_to_user ()) {
2034 using namespace Menu_Helpers;
2035 ProcessorAutomationInfo *rai;
2036 list<ProcessorAutomationInfo*>::iterator x;
2038 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2039 std::set<Evoral::Parameter> has_visible_automation;
2041 processor->what_has_visible_data(has_visible_automation);
2043 if (automatable.empty()) {
2047 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2048 if ((*x)->processor == processor) {
2053 if (x == processor_automation.end()) {
2055 rai = new ProcessorAutomationInfo (processor);
2056 processor_automation.push_back (rai);
2064 /* any older menu was deleted at the top of processors_changed()
2065 when we cleared the subplugin menu.
2068 rai->menu = manage (new Menu);
2069 MenuList& items = rai->menu->items();
2070 rai->menu->set_name ("ArdourContextMenu");
2074 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2076 ProcessorAutomationNode* pan;
2077 CheckMenuItem* mitem;
2079 string name = processor->describe_parameter (*i);
2081 items.push_back (CheckMenuElem (name));
2082 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2084 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2085 mitem->set_active(true);
2088 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2092 pan = new ProcessorAutomationNode (*i, mitem, *this);
2094 rai->lines.push_back (pan);
2098 pan->menu_item = mitem;
2102 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2105 /* add the menu for this processor, because the subplugin
2106 menu is always cleared at the top of processors_changed().
2107 this is the result of some poor design in gtkmm and/or
2111 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2116 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2117 RouteTimeAxisView::ProcessorAutomationNode* pan)
2119 bool showit = pan->menu_item->get_active();
2120 bool redraw = false;
2122 if (pan->view == 0 && showit) {
2123 add_processor_automation_curve (rai->processor, pan->what);
2127 if (pan->view && showit != pan->view->marked_for_display()) {
2130 pan->view->set_marked_for_display (true);
2131 pan->view->canvas_display()->show();
2132 pan->view->canvas_background()->show();
2134 rai->processor->mark_automation_visible (pan->what, true);
2135 pan->view->set_marked_for_display (false);
2143 if (redraw && !no_redraw) {
2144 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2150 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2152 if (c.type == RouteProcessorChange::MeterPointChange) {
2153 /* nothing to do if only the meter point has changed */
2157 using namespace Menu_Helpers;
2159 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2160 (*i)->valid = false;
2163 subplugin_menu.items().clear ();
2165 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2166 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2168 bool deleted_processor_automation = false;
2170 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2172 list<ProcessorAutomationInfo*>::iterator tmp;
2180 processor_automation.erase (i);
2181 deleted_processor_automation = true;
2188 if (deleted_processor_automation && !no_redraw) {
2189 _route->gui_changed ("track_height", this);
2193 boost::shared_ptr<AutomationLine>
2194 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2196 ProcessorAutomationNode* pan;
2198 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2204 return boost::shared_ptr<AutomationLine>();
2208 RouteTimeAxisView::reset_processor_automation_curves ()
2210 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2216 RouteTimeAxisView::update_rec_display ()
2218 RouteUI::update_rec_display ();
2219 name_entry.set_sensitive (!_route->record_enabled());
2223 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2226 _view->set_layer_display (d);
2230 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2234 RouteTimeAxisView::layer_display () const
2237 return _view->layer_display ();
2240 /* we don't know, since we don't have a _view, so just return something */
2246 boost::shared_ptr<AutomationTimeAxisView>
2247 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2249 AutomationTracks::iterator i = _automation_tracks.find(param);
2250 if (i != _automation_tracks.end()) {
2251 return i->second->track;
2253 return boost::shared_ptr<AutomationTimeAxisView>();
2258 RouteTimeAxisView::fast_update ()
2260 gm.get_level_meter().update_meters ();
2264 RouteTimeAxisView::hide_meter ()
2267 gm.get_level_meter().hide_meters ();
2271 RouteTimeAxisView::show_meter ()
2277 RouteTimeAxisView::reset_meter ()
2279 if (Config->get_show_track_meters()) {
2280 gm.get_level_meter().setup_meters (height-5);
2287 RouteTimeAxisView::clear_meter ()
2289 gm.get_level_meter().clear_meters ();
2293 RouteTimeAxisView::meter_changed (void *src)
2295 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed, src)
2300 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2306 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2308 using namespace Menu_Helpers;
2310 if (!_underlay_streams.empty()) {
2311 MenuList& parent_items = parent_menu->items();
2312 Menu* gs_menu = manage (new Menu);
2313 gs_menu->set_name ("ArdourContextMenu");
2314 MenuList& gs_items = gs_menu->items();
2316 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2318 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2319 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2320 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2326 RouteTimeAxisView::set_underlay_state()
2328 if (!underlay_xml_node) {
2332 XMLNodeList nlist = underlay_xml_node->children();
2333 XMLNodeConstIterator niter;
2334 XMLNode *child_node;
2336 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2337 child_node = *niter;
2339 if (child_node->name() != "Underlay") {
2343 XMLProperty* prop = child_node->property ("id");
2345 PBD::ID id (prop->value());
2347 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2350 add_underlay(v->view(), false);
2359 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2365 RouteTimeAxisView& other = v->trackview();
2367 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2368 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2369 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2373 _underlay_streams.push_back(v);
2374 other._underlay_mirrors.push_back(this);
2376 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2379 if (!underlay_xml_node) {
2381 underlay_xml_node = xml_node->add_child("Underlays");
2384 XMLNode* node = underlay_xml_node->add_child("Underlay");
2385 XMLProperty* prop = node->add_property("id");
2386 prop->set_value(v->trackview().route()->id().to_s());
2392 RouteTimeAxisView::remove_underlay (StreamView* v)
2398 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2399 RouteTimeAxisView& other = v->trackview();
2401 if (it != _underlay_streams.end()) {
2402 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2404 if (gm == other._underlay_mirrors.end()) {
2405 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2409 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2411 _underlay_streams.erase(it);
2412 other._underlay_mirrors.erase(gm);
2414 if (underlay_xml_node) {
2415 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2421 RouteTimeAxisView::set_button_names ()
2423 rec_enable_button_label.set_text (_("r"));
2425 if (Config->get_solo_control_is_listen_control()) {
2426 switch (Config->get_listen_position()) {
2427 case AfterFaderListen:
2428 solo_button_label.set_text (_("A"));
2430 case PreFaderListen:
2431 solo_button_label.set_text (_("P"));
2435 solo_button_label.set_text (_("s"));
2438 mute_button_label.set_text (_("m"));