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.
28 #include <sigc++/bind.h>
30 #include "pbd/error.h"
31 #include "pbd/stl_delete.h"
32 #include "pbd/whitespace.h"
33 #include "pbd/memento_command.h"
34 #include "pbd/enumwriter.h"
36 #include <gtkmm/menu.h>
37 #include <gtkmm/menuitem.h>
38 #include <gtkmm2ext/gtk_ui.h>
39 #include <gtkmm2ext/selector.h>
40 #include <gtkmm2ext/stop_signal.h>
41 #include <gtkmm2ext/bindable_button.h>
42 #include <gtkmm2ext/utils.h>
44 #include "ardour/amp.h"
45 #include "ardour/audioplaylist.h"
46 #include "ardour/diskstream.h"
47 #include "ardour/event_type_map.h"
48 #include "ardour/ladspa_plugin.h"
49 #include "ardour/location.h"
50 #include "ardour/panner.h"
51 #include "ardour/playlist.h"
52 #include "ardour/playlist.h"
53 #include "ardour/processor.h"
54 #include "ardour/profile.h"
55 #include "ardour/route_group.h"
56 #include "ardour/session.h"
57 #include "ardour/session_playlist.h"
58 #include "ardour/debug.h"
59 #include "ardour/utils.h"
60 #include "evoral/Parameter.hpp"
62 #include "ardour_ui.h"
63 #include "route_time_axis.h"
64 #include "automation_time_axis.h"
65 #include "canvas_impl.h"
66 #include "crossfade_view.h"
68 #include "gui_thread.h"
70 #include "playlist_selector.h"
71 #include "point_selection.h"
73 #include "public_editor.h"
74 #include "region_view.h"
75 #include "rgb_macros.h"
76 #include "selection.h"
77 #include "simplerect.h"
78 #include "streamview.h"
80 #include "route_group_menu.h"
82 #include "ardour/track.h"
86 using namespace ARDOUR;
88 using namespace Gtkmm2ext;
90 using namespace Editing;
94 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
97 RouteTimeAxisView::setup_slider_pix ()
99 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
100 throw failed_constructor ();
104 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
107 , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
108 , parent_canvas (canvas)
109 , button_table (3, 3)
110 , route_group_button (_("g"))
111 , playlist_button (_("p"))
112 , size_button (_("h"))
113 , automation_button (_("a"))
114 , visual_button (_("v"))
115 , gm (sess, slider, true, 115)
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;
130 if (!_route->is_hidden()) {
131 _marked_for_display = true;
134 timestretch_rect = 0;
136 destructive_track_mode_item = 0;
137 normal_track_mode_item = 0;
138 non_layered_track_mode_item = 0;
140 ignore_toggle = false;
142 route_group_button.set_name ("TrackGroupButton");
143 playlist_button.set_name ("TrackPlaylistButton");
144 automation_button.set_name ("TrackAutomationButton");
145 size_button.set_name ("TrackSizeButton");
146 visual_button.set_name ("TrackVisualButton");
147 hide_button.set_name ("TrackRemoveButton");
149 route_group_button.unset_flags (Gtk::CAN_FOCUS);
150 playlist_button.unset_flags (Gtk::CAN_FOCUS);
151 automation_button.unset_flags (Gtk::CAN_FOCUS);
152 size_button.unset_flags (Gtk::CAN_FOCUS);
153 visual_button.unset_flags (Gtk::CAN_FOCUS);
154 hide_button.unset_flags (Gtk::CAN_FOCUS);
156 hide_button.add (*(manage (new Image (::get_icon("hide")))));
157 hide_button.show_all ();
159 route_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
160 playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
161 automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
162 size_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::size_click), false);
163 visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click));
164 hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click));
166 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
167 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
168 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
169 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
175 rec_enable_button->remove ();
177 switch (track()->mode()) {
179 case ARDOUR::NonLayered:
180 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
182 case ARDOUR::Destructive:
183 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
186 rec_enable_button->show_all ();
188 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
189 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release), false);
190 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
191 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
193 rec_enable_button->set_sensitive (_session.writable());
196 controls_hbox.pack_start(gm.get_level_meter(), false, false);
197 _route->meter_change.connect (mem_fun(*this, &RouteTimeAxisView::meter_changed));
198 _route->input()->changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
199 _route->output()->changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
201 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
202 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
204 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
205 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
207 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
208 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
209 ARDOUR_UI::instance()->tooltips().set_tip(route_group_button, _("Route Group"));
210 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
211 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
212 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
213 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
214 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
220 /* old school - when we used to put an extra row of buttons in place */
222 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
223 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
224 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
225 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
229 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
232 if (is_track() && track()->mode() == ARDOUR::Normal) {
233 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
238 _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
239 _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
240 _route->processors_changed.connect (mem_fun(*this, &RouteTimeAxisView::processors_changed));
241 _route->NameChanged.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
242 _route->solo_isolated_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
247 track()->TrackModeChanged.connect (mem_fun(*this, &RouteTimeAxisView::track_mode_changed));
248 track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
249 track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
250 get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed));
252 /* pick up the correct freeze state */
257 _editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
258 ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
260 route_group_menu = new RouteGroupMenu (
262 (RouteGroup::Property) (RouteGroup::Mute | RouteGroup::Solo | RouteGroup::Edit)
265 route_group_menu->GroupSelected.connect (mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
267 gm.get_gain_slider().signal_scroll_event().connect(mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
268 gm.get_gain_slider().set_name ("TrackGainFader");
271 RouteTimeAxisView::~RouteTimeAxisView ()
273 GoingAway (); /* EMIT_SIGNAL */
275 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
279 delete playlist_menu;
282 delete playlist_action_menu;
283 playlist_action_menu = 0;
288 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
292 _automation_tracks.clear ();
294 delete route_group_menu;
298 RouteTimeAxisView::post_construct ()
300 /* map current state of the route */
302 update_diskstream_display ();
304 subplugin_menu.items().clear ();
305 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
306 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
307 reset_processor_automation_curves ();
311 RouteTimeAxisView::edit_click (GdkEventButton *ev)
313 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
314 _route->set_route_group (0, this);
318 route_group_menu->rebuild (_route->route_group ());
319 route_group_menu->popup (ev->button, ev->time);
325 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
327 _route->set_route_group (eg, this);
331 RouteTimeAxisView::playlist_changed ()
337 RouteTimeAxisView::label_view ()
339 string x = _route->name();
341 if (x != name_entry.get_text()) {
342 name_entry.set_text (x);
345 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
349 RouteTimeAxisView::route_name_changed ()
355 RouteTimeAxisView::take_name_changed (void *src)
364 RouteTimeAxisView::playlist_click ()
366 // always build a new action menu
368 delete playlist_action_menu;
370 playlist_action_menu = new Menu;
371 playlist_action_menu->set_name ("ArdourContextMenu");
373 build_playlist_menu (playlist_action_menu);
375 conditionally_add_to_selection ();
376 playlist_action_menu->popup (1, gtk_get_current_event_time());
380 RouteTimeAxisView::automation_click ()
382 conditionally_add_to_selection ();
383 build_automation_action_menu ();
384 automation_action_menu->popup (1, gtk_get_current_event_time());
388 RouteTimeAxisView::set_state (const XMLNode& node, int version)
390 TimeAxisView::set_state (node, version);
392 XMLNodeList kids = node.children();
393 XMLNodeConstIterator iter;
394 const XMLProperty* prop;
396 if (_view && (prop = node.property ("layer-display"))) {
397 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
400 for (iter = kids.begin(); iter != kids.end(); ++iter) {
401 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
402 if ((prop = (*iter)->property ("automation-id")) != 0) {
404 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
405 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
406 create_automation_child(param, show);
408 warning << "Automation child has no ID" << endmsg;
417 RouteTimeAxisView::build_automation_action_menu ()
419 using namespace Menu_Helpers;
421 automation_action_menu = manage (new Menu);
422 MenuList& automation_items = automation_action_menu->items();
423 automation_action_menu->set_name ("ArdourContextMenu");
425 automation_items.push_back (MenuElem (_("Show all automation"),
426 mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
428 automation_items.push_back (MenuElem (_("Show existing automation"),
429 mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
431 automation_items.push_back (MenuElem (_("Hide all automation"),
432 mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
434 if (subplugin_menu.get_attach_widget())
435 subplugin_menu.detach();
437 automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
438 automation_items.back().set_sensitive (!subplugin_menu.items().empty());
440 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
441 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
443 automation_items.push_back (SeparatorElem());
445 delete i->second->menu_item;
447 automation_items.push_back(CheckMenuElem (_route->describe_parameter(i->second->param),
448 bind (mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
450 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&automation_items.back());
452 i->second->menu_item->set_active(show_automation(i->second->param));
453 //i->second->menu_item->set_active(false);
458 RouteTimeAxisView::build_display_menu ()
460 using namespace Menu_Helpers;
462 /* get the size menu ready */
468 TimeAxisView::build_display_menu ();
470 /* now fill it with our stuff */
472 MenuList& items = display_menu->items();
473 display_menu->set_name ("ArdourContextMenu");
475 items.push_back (MenuElem (_("Height"), *size_menu));
476 items.push_back (MenuElem (_("Color"), mem_fun(*this, &RouteTimeAxisView::select_track_color)));
478 items.push_back (SeparatorElem());
480 if (!Profile->get_sae()) {
481 items.push_back (MenuElem (_("Remote Control ID..."), mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
482 /* rebuild this every time */
483 build_automation_action_menu ();
484 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
485 items.push_back (SeparatorElem());
488 // Hook for derived classes to add type specific stuff
489 append_extra_display_menu_items ();
490 items.push_back (SeparatorElem());
494 Menu *layers_menu = manage(new Menu);
495 MenuList &layers_items = layers_menu->items();
496 layers_menu->set_name("ArdourContextMenu");
498 RadioMenuItem::Group layers_group;
500 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
501 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
502 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
503 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
505 items.push_back (MenuElem (_("Layers"), *layers_menu));
507 Menu* alignment_menu = manage (new Menu);
508 MenuList& alignment_items = alignment_menu->items();
509 alignment_menu->set_name ("ArdourContextMenu");
511 RadioMenuItem::Group align_group;
513 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
514 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
515 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
516 if (get_diskstream()->alignment_style() == ExistingMaterial)
517 align_existing_item->set_active();
519 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
520 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
521 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
522 if (get_diskstream()->alignment_style() == CaptureTime)
523 align_capture_item->set_active();
525 if (!Profile->get_sae()) {
526 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
527 get_diskstream()->AlignmentStyleChanged.connect (
528 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
530 RadioMenuItem::Group mode_group;
531 items.push_back (RadioMenuElem (mode_group, _("Normal mode"), bind (
532 mem_fun (*this, &RouteTimeAxisView::set_track_mode),
534 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
536 items.push_back (RadioMenuElem (mode_group, _("Tape mode"), bind (
537 mem_fun (*this, &RouteTimeAxisView::set_track_mode),
538 ARDOUR::Destructive)));
539 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
541 items.push_back (RadioMenuElem (mode_group, _("No layering mode"),
542 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
543 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
547 switch (track()->mode()) {
548 case ARDOUR::Destructive:
549 destructive_track_mode_item->set_active ();
552 normal_track_mode_item->set_active ();
554 case ARDOUR::NonLayered:
555 non_layered_track_mode_item->set_active ();
560 get_diskstream()->AlignmentStyleChanged.connect (
561 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
563 mode_menu = build_mode_menu();
565 items.push_back (MenuElem (_("Mode"), *mode_menu));
567 color_mode_menu = build_color_mode_menu();
569 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
571 items.push_back (SeparatorElem());
574 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
575 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
576 route_active_menu_item->set_active (_route->active());
578 items.push_back (SeparatorElem());
579 items.push_back (MenuElem (_("Hide"), mem_fun(*this, &RouteTimeAxisView::hide_click)));
580 if (!Profile->get_sae()) {
581 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
583 items.push_front (SeparatorElem());
584 items.push_front (MenuElem (_("Delete"), mem_fun(*this, &RouteUI::remove_this_route)));
588 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
591 item_2->set_active ();
596 RouteTimeAxisView::set_track_mode (TrackMode mode)
599 RadioMenuItem* other_item;
600 RadioMenuItem* other_item_2;
604 item = normal_track_mode_item;
605 other_item = non_layered_track_mode_item;
606 other_item_2 = destructive_track_mode_item;
608 case ARDOUR::NonLayered:
609 item = non_layered_track_mode_item;
610 other_item = normal_track_mode_item;
611 other_item_2 = destructive_track_mode_item;
613 case ARDOUR::Destructive:
614 item = destructive_track_mode_item;
615 other_item = normal_track_mode_item;
616 other_item_2 = non_layered_track_mode_item;
619 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
624 if (item && other_item && other_item_2 && item->get_active() && track()->mode() != mode) {
625 _set_track_mode (track().get(), mode, other_item, other_item_2);
630 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
634 if (!track->can_use_mode (mode, needs_bounce)) {
638 Glib::signal_idle().connect (bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
641 cerr << "would bounce this one\n";
646 track->set_mode (mode);
648 rec_enable_button->remove ();
651 case ARDOUR::NonLayered:
653 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
655 case ARDOUR::Destructive:
656 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
660 rec_enable_button->show_all ();
664 RouteTimeAxisView::track_mode_changed ()
668 switch (track()->mode()) {
670 item = normal_track_mode_item;
672 case ARDOUR::NonLayered:
673 item = non_layered_track_mode_item;
675 case ARDOUR::Destructive:
676 item = destructive_track_mode_item;
679 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
688 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
694 TimeAxisView::show_timestretch (start, end);
704 /* check that the time selection was made in our route, or our route group.
705 remember that route_group() == 0 implies the route is *not* in a edit group.
708 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
709 /* this doesn't apply to us */
713 /* ignore it if our edit group is not active */
715 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
720 if (timestretch_rect == 0) {
721 timestretch_rect = new SimpleRect (*canvas_display ());
722 timestretch_rect->property_x1() = 0.0;
723 timestretch_rect->property_y1() = 0.0;
724 timestretch_rect->property_x2() = 0.0;
725 timestretch_rect->property_y2() = 0.0;
726 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
727 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
730 timestretch_rect->show ();
731 timestretch_rect->raise_to_top ();
733 x1 = start / _editor.get_current_zoom();
734 x2 = (end - 1) / _editor.get_current_zoom();
735 y2 = current_height() - 2;
737 timestretch_rect->property_x1() = x1;
738 timestretch_rect->property_y1() = 1.0;
739 timestretch_rect->property_x2() = x2;
740 timestretch_rect->property_y2() = y2;
744 RouteTimeAxisView::hide_timestretch ()
746 TimeAxisView::hide_timestretch ();
748 if (timestretch_rect) {
749 timestretch_rect->hide ();
754 RouteTimeAxisView::show_selection (TimeSelection& ts)
758 /* ignore it if our edit group is not active or if the selection was started
759 in some other track or route group (remember that route_group() == 0 means
760 that the track is not in an route group).
763 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
764 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
770 TimeAxisView::show_selection (ts);
774 RouteTimeAxisView::set_height (uint32_t h)
777 bool height_changed = (height == 0) || (h != height);
778 gm.get_level_meter().setup_meters (gmlen);
780 TimeAxisView::set_height (h);
785 _view->set_height ((double) current_height());
789 snprintf (buf, sizeof (buf), "%u", height);
790 xml_node->add_property ("height", buf);
792 if (height >= hNormal) {
797 gm.get_gain_slider().show();
799 if (!_route || _route->is_control()) {
804 if (rec_enable_button)
805 rec_enable_button->show();
807 route_group_button.show();
809 visual_button.show();
811 automation_button.show();
813 if (is_track() && track()->mode() == ARDOUR::Normal) {
814 playlist_button.show();
817 } else if (height >= hSmaller) {
823 gm.get_gain_slider().hide();
825 if (!_route || _route->is_control()) {
830 if (rec_enable_button)
831 rec_enable_button->show();
833 route_group_button.hide ();
835 visual_button.hide ();
837 automation_button.hide ();
839 if (is_track() && track()->mode() == ARDOUR::Normal) {
840 playlist_button.hide ();
846 /* don't allow name_entry to be hidden while
847 it has focus, otherwise the GUI becomes unusable.
850 if (name_entry.has_focus()) {
851 if (name_entry.get_text() != _route->name()) {
852 name_entry_changed ();
854 controls_ebox.grab_focus ();
860 gm.get_gain_slider().hide();
863 if (rec_enable_button)
864 rec_enable_button->hide();
866 route_group_button.hide ();
868 visual_button.hide ();
870 automation_button.hide ();
871 playlist_button.hide ();
872 name_label.set_text (_route->name());
875 if (height_changed) {
876 /* only emit the signal if the height really changed */
877 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
882 RouteTimeAxisView::select_track_color ()
884 if (RouteUI::choose_color ()) {
887 _view->apply_color (_color, StreamView::RegionColor);
893 RouteTimeAxisView::reset_samples_per_unit ()
895 set_samples_per_unit (_editor.get_current_zoom());
899 RouteTimeAxisView::set_samples_per_unit (double spu)
903 if (get_diskstream() != 0) {
904 speed = get_diskstream()->speed();
908 _view->set_samples_per_unit (spu * speed);
911 TimeAxisView::set_samples_per_unit (spu * speed);
915 RouteTimeAxisView::align_style_changed ()
917 switch (get_diskstream()->alignment_style()) {
918 case ExistingMaterial:
919 if (!align_existing_item->get_active()) {
920 align_existing_item->set_active();
924 if (!align_capture_item->get_active()) {
925 align_capture_item->set_active();
932 RouteTimeAxisView::set_align_style (AlignStyle style)
937 case ExistingMaterial:
938 item = align_existing_item;
941 item = align_capture_item;
944 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
949 if (item->get_active()) {
950 get_diskstream()->set_align_style (style);
955 RouteTimeAxisView::rename_current_playlist ()
957 ArdourPrompter prompter (true);
960 boost::shared_ptr<Diskstream> ds = get_diskstream();
961 if (!ds || ds->destructive())
964 boost::shared_ptr<Playlist> pl = ds->playlist();
968 prompter.set_prompt (_("Name for playlist"));
969 prompter.set_initial_text (pl->name());
970 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
971 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
973 switch (prompter.run ()) {
974 case Gtk::RESPONSE_ACCEPT:
975 prompter.get_result (name);
987 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
989 std::string ret (basename);
991 std::string const group_string = "." + route_group()->name() + ".";
993 // iterate through all playlists
995 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
996 std::string tmp = (*i)->name();
998 std::string::size_type idx = tmp.find(group_string);
999 // find those which belong to this group
1000 if (idx != string::npos) {
1001 tmp = tmp.substr(idx + group_string.length());
1003 // and find the largest current number
1004 int x = atoi(tmp.c_str());
1005 if (x > maxnumber) {
1014 snprintf (buf, sizeof(buf), "%d", maxnumber);
1016 ret = this->name() + "." + route_group()->name () + "." + buf;
1022 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1026 boost::shared_ptr<Diskstream> ds = get_diskstream();
1027 if (!ds || ds->destructive())
1030 boost::shared_ptr<const Playlist> pl = ds->playlist();
1036 if (route_group() && route_group()->is_active()) {
1037 name = resolve_new_group_playlist_name(name, playlists_before_op);
1040 while (_session.playlists->by_name(name)) {
1041 name = Playlist::bump_name (name, _session);
1044 // TODO: The prompter "new" button should be de-activated if the user
1045 // specifies a playlist name which already exists in the session.
1049 ArdourPrompter prompter (true);
1051 prompter.set_prompt (_("Name for Playlist"));
1052 prompter.set_initial_text (name);
1053 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1054 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1055 prompter.show_all ();
1057 switch (prompter.run ()) {
1058 case Gtk::RESPONSE_ACCEPT:
1059 prompter.get_result (name);
1067 if (name.length()) {
1068 ds->use_copy_playlist ();
1069 ds->playlist()->set_name (name);
1074 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1078 boost::shared_ptr<Diskstream> ds = get_diskstream();
1079 if (!ds || ds->destructive())
1082 boost::shared_ptr<const Playlist> pl = ds->playlist();
1088 if (route_group() && route_group()->is_active()) {
1089 name = resolve_new_group_playlist_name(name,playlists_before_op);
1092 while (_session.playlists->by_name(name)) {
1093 name = Playlist::bump_name (name, _session);
1099 ArdourPrompter prompter (true);
1101 prompter.set_prompt (_("Name for Playlist"));
1102 prompter.set_initial_text (name);
1103 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1104 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1106 switch (prompter.run ()) {
1107 case Gtk::RESPONSE_ACCEPT:
1108 prompter.get_result (name);
1116 if (name.length()) {
1117 ds->use_new_playlist ();
1118 ds->playlist()->set_name (name);
1123 RouteTimeAxisView::clear_playlist ()
1125 boost::shared_ptr<Diskstream> ds = get_diskstream();
1126 if (!ds || ds->destructive())
1129 boost::shared_ptr<Playlist> pl = ds->playlist();
1133 _editor.clear_playlist (pl);
1137 RouteTimeAxisView::speed_changed ()
1139 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
1143 RouteTimeAxisView::diskstream_changed ()
1145 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::update_diskstream_display));
1149 RouteTimeAxisView::update_diskstream_display ()
1151 if (!get_diskstream()) // bus
1158 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1160 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1162 /* special case: select/deselect all tracks */
1163 if (_editor.get_selection().selected (this)) {
1164 _editor.get_selection().clear_tracks ();
1166 _editor.select_all_tracks ();
1172 PublicEditor::TrackViewList* tracks = _editor.get_valid_views (this, _route->route_group());
1174 switch (Keyboard::selection_type (ev->state)) {
1175 case Selection::Toggle:
1176 _editor.get_selection().toggle (*tracks);
1179 case Selection::Set:
1180 _editor.get_selection().set (*tracks);
1183 case Selection::Extend:
1184 if (tracks->size() > 1) {
1185 /* add each one, do not "extend" */
1186 _editor.get_selection().add (*tracks);
1188 /* extend to the single track */
1189 _editor.extend_selection_to_track (*tracks->front());
1193 case Selection::Add:
1194 _editor.get_selection().add (*tracks);
1202 RouteTimeAxisView::set_selected_points (PointSelection& points)
1204 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1205 (*i)->set_selected_points (points);
1210 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1213 _view->set_selected_regionviews (regions);
1217 /** Add the selectable things that we have to a list.
1218 * @param results List to add things to.
1221 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1225 if (get_diskstream() != 0) {
1226 speed = get_diskstream()->speed();
1229 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1230 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1232 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1233 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1236 /* pick up visible automation tracks */
1238 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1239 if (!(*i)->hidden()) {
1240 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1246 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1249 _view->get_inverted_selectables (sel, results);
1252 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1253 if (!(*i)->hidden()) {
1254 (*i)->get_inverted_selectables (sel, results);
1262 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1264 return (_show_automation.find(param) != _show_automation.end());
1267 /** Retuns 0 if track for \a param doesn't exist.
1269 RouteTimeAxisView::RouteAutomationNode*
1270 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1272 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1274 if (i != _automation_tracks.end()) {
1281 /** Shorthand for GainAutomation, etc.
1283 RouteTimeAxisView::RouteAutomationNode*
1284 RouteTimeAxisView::automation_track (AutomationType type)
1286 return automation_track (Evoral::Parameter(type));
1290 RouteTimeAxisView::route_group () const
1292 return _route->route_group();
1296 RouteTimeAxisView::name() const
1298 return _route->name();
1301 boost::shared_ptr<Playlist>
1302 RouteTimeAxisView::playlist () const
1304 boost::shared_ptr<Diskstream> ds;
1306 if ((ds = get_diskstream()) != 0) {
1307 return ds->playlist();
1309 return boost::shared_ptr<Playlist> ();
1314 RouteTimeAxisView::name_entry_changed ()
1318 x = name_entry.get_text ();
1320 if (x == _route->name()) {
1324 strip_whitespace_edges(x);
1326 if (x.length() == 0) {
1327 name_entry.set_text (_route->name());
1331 if (!_session.route_name_unique (x)) {
1332 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1333 name_entry.set_text (_route->name());
1334 } else if (_session.route_name_internal (x)) {
1335 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1336 name_entry.set_text (_route->name());
1338 _route->set_name (x);
1343 RouteTimeAxisView::visual_click ()
1345 popup_display_menu (0);
1349 RouteTimeAxisView::hide_click ()
1351 // LAME fix for hide_button refresh fix
1352 hide_button.set_sensitive(false);
1354 _editor.hide_track_in_display (*this);
1356 hide_button.set_sensitive(true);
1359 boost::shared_ptr<Region>
1360 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, 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 (pos, point, dir);
1369 return boost::shared_ptr<Region> ();
1373 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1375 boost::shared_ptr<Diskstream> stream;
1376 boost::shared_ptr<Playlist> playlist;
1378 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1379 return playlist->find_next_region_boundary (pos, dir);
1386 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1388 boost::shared_ptr<Playlist> what_we_got;
1389 boost::shared_ptr<Diskstream> ds = get_diskstream();
1390 boost::shared_ptr<Playlist> playlist;
1394 /* route is a bus, not a track */
1398 playlist = ds->playlist();
1400 TimeSelection time (selection.time);
1401 float speed = ds->speed();
1402 if (speed != 1.0f) {
1403 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1404 (*i).start = session_frame_to_track_frame((*i).start, speed);
1405 (*i).end = session_frame_to_track_frame((*i).end, speed);
1409 XMLNode &before = playlist->get_state();
1412 if ((what_we_got = playlist->cut (time)) != 0) {
1413 _editor.get_cut_buffer().add (what_we_got);
1414 _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1419 if ((what_we_got = playlist->copy (time)) != 0) {
1420 _editor.get_cut_buffer().add (what_we_got);
1425 if ((what_we_got = playlist->cut (time)) != 0) {
1426 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1427 what_we_got->release ();
1437 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1443 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1444 PlaylistSelection::iterator p;
1446 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1448 if (p == selection.playlists.end()) {
1452 if (get_diskstream()->speed() != 1.0f) {
1453 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1456 XMLNode &before = playlist->get_state();
1457 playlist->paste (*p, pos, times);
1458 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1464 TimeAxisView::Children
1465 RouteTimeAxisView::get_child_list()
1467 TimeAxisView::Children redirect_children;
1469 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1470 if (!(*i)->hidden()) {
1471 redirect_children.push_back(*i);
1474 return redirect_children;
1479 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1481 using namespace Menu_Helpers;
1483 if (!menu || !is_track()) {
1487 MenuList& playlist_items = menu->items();
1488 menu->set_name ("ArdourContextMenu");
1489 playlist_items.clear();
1491 delete playlist_menu;
1493 playlist_menu = new Menu;
1494 playlist_menu->set_name ("ArdourContextMenu");
1496 vector<boost::shared_ptr<Playlist> > playlists;
1497 boost::shared_ptr<Diskstream> ds = get_diskstream();
1498 RadioMenuItem::Group playlist_group;
1500 _session.playlists->get (playlists);
1502 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1504 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1505 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1506 boost::weak_ptr<Playlist> (*i))));
1508 if (ds->playlist()->id() == (*i)->id()) {
1509 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1511 } else if (ds->playlist()->id() == (*i)->id()) {
1512 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1513 boost::weak_ptr<Playlist>(*i))));
1514 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1519 playlist_items.push_back (SeparatorElem());
1520 playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1521 playlist_items.push_back (SeparatorElem());
1523 if (!route_group() || !route_group()->is_active()) {
1524 playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
1525 playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1528 // Use a label which tells the user what is happening
1529 playlist_items.push_back (MenuElem (_("New Take"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
1530 playlist_items.push_back (MenuElem (_("Copy Take"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1534 playlist_items.push_back (SeparatorElem());
1535 playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1536 playlist_items.push_back (SeparatorElem());
1538 playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1542 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1544 assert (is_track());
1546 boost::shared_ptr<Playlist> pl (wpl.lock());
1552 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1555 if (get_diskstream()->playlist() == apl) {
1556 // radio button cotnrols mean this function is called for both the
1557 // old and new playlist
1560 get_diskstream()->use_playlist (apl);
1563 if (route_group() && route_group()->is_active()) {
1564 //PBD::stacktrace(cerr, 20);
1565 std::string group_string = "."+route_group()->name()+".";
1567 std::string take_name = apl->name();
1568 std::string::size_type idx = take_name.find(group_string);
1570 if (idx == std::string::npos)
1573 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1575 for (list<Route*>::const_iterator i = route_group()->route_list().begin(); i != route_group()->route_list().end(); ++i) {
1576 if ( (*i) == this->route().get()) {
1580 std::string playlist_name = (*i)->name()+group_string+take_name;
1582 Track *track = dynamic_cast<Track *>(*i);
1584 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1588 boost::shared_ptr<Playlist> ipl = session().playlists->by_name(playlist_name);
1590 // No playlist for this track for this take yet, make it
1591 track->diskstream()->use_new_playlist();
1592 track->diskstream()->playlist()->set_name(playlist_name);
1594 track->diskstream()->use_playlist(ipl);
1604 RouteTimeAxisView::show_playlist_selector ()
1606 _editor.playlist_selector().show_for (this);
1610 RouteTimeAxisView::map_frozen ()
1616 ENSURE_GUI_THREAD (mem_fun(*this, &RouteTimeAxisView::map_frozen));
1618 switch (track()->freeze_state()) {
1620 playlist_button.set_sensitive (false);
1621 rec_enable_button->set_sensitive (false);
1624 playlist_button.set_sensitive (true);
1625 rec_enable_button->set_sensitive (true);
1631 RouteTimeAxisView::color_handler ()
1633 //case cTimeStretchOutline:
1634 if (timestretch_rect) {
1635 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1637 //case cTimeStretchFill:
1638 if (timestretch_rect) {
1639 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1646 RouteTimeAxisView::toggle_automation_track (Evoral::Parameter param)
1648 RouteAutomationNode* node = automation_track(param);
1653 bool showit = node->menu_item->get_active();
1655 if (showit != node->track->marked_for_display()) {
1657 node->track->set_marked_for_display (true);
1658 node->track->canvas_display()->show();
1659 node->track->get_state_node()->add_property ("shown", X_("yes"));
1661 node->track->set_marked_for_display (false);
1662 node->track->hide ();
1663 node->track->get_state_node()->add_property ("shown", X_("no"));
1666 /* now trigger a redisplay */
1669 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1675 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1677 RouteAutomationNode* ran = automation_track(param);
1682 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1683 _show_automation.erase(param);
1684 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1686 if (ran->menu_item && !_hidden) {
1687 ran->menu_item->set_active (false);
1690 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1695 RouteTimeAxisView::show_all_automation ()
1699 /* Show our automation */
1701 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1702 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1703 i->second->track->set_marked_for_display (true);
1704 i->second->track->canvas_display()->show();
1705 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1706 i->second->menu_item->set_active(true);
1710 /* Show processor automation */
1712 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1713 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1714 if ((*ii)->view == 0) {
1715 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1718 (*ii)->menu_item->set_active (true);
1726 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1730 RouteTimeAxisView::show_existing_automation ()
1734 /* Show our automation */
1736 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1737 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1738 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1739 i->second->track->set_marked_for_display (true);
1740 i->second->track->canvas_display()->show();
1741 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1742 i->second->menu_item->set_active(true);
1747 /* Show processor automation */
1749 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1750 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1751 if ((*ii)->view != 0 && (*i)->processor->data().control((*ii)->what)->list()->size() > 0) {
1752 (*ii)->menu_item->set_active (true);
1759 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1763 RouteTimeAxisView::hide_all_automation ()
1767 /* Hide our automation */
1769 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1770 i->second->track->set_marked_for_display (false);
1771 i->second->track->hide ();
1772 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1773 i->second->menu_item->set_active (false);
1776 /* Hide processor automation */
1778 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1779 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1780 (*ii)->menu_item->set_active (false);
1784 _show_automation.clear();
1787 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1792 RouteTimeAxisView::region_view_added (RegionView* rv)
1794 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1795 if(is_audio_track()) {
1796 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1797 boost::shared_ptr<AutomationTimeAxisView> atv;
1799 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1805 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1806 (*i)->add_ghost(rv);
1810 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1812 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1818 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1820 parent.remove_processor_automation_node (this);
1824 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1827 remove_child (pan->view);
1831 RouteTimeAxisView::ProcessorAutomationNode*
1832 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1834 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1836 if ((*i)->processor == processor) {
1838 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1839 if ((*ii)->what == what) {
1850 legalize_for_xml_node (string str)
1852 string::size_type pos;
1853 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1859 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1860 legal.replace (pos, 1, "_");
1869 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1872 ProcessorAutomationNode* pan;
1874 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1875 error << _("programming error: ")
1876 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1877 processor->name(), what)
1887 name = processor->describe_parameter (what);
1889 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1893 char state_name[256];
1894 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1896 boost::shared_ptr<AutomationControl> control
1897 = boost::dynamic_pointer_cast<AutomationControl>(processor->data().control(what, true));
1899 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1900 new AutomationTimeAxisView (_session, _route, processor, control,
1901 _editor, *this, false, parent_canvas, name, state_name));
1903 pan->view->Hiding.connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1905 if (!pan->view->marked_for_display()) {
1908 pan->menu_item->set_active (true);
1911 add_child (pan->view);
1914 _view->foreach_regionview (mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1917 processor->mark_automation_visible (what, true);
1921 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1924 pan->menu_item->set_active (false);
1927 i->mark_automation_visible (pan->what, false);
1929 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1933 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1935 boost::shared_ptr<Processor> processor (p.lock ());
1940 set<Evoral::Parameter> s;
1941 boost::shared_ptr<AutomationLine> al;
1943 processor->what_has_visible_data (s);
1945 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1947 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1950 add_processor_automation_curve (processor, (*i));
1956 RouteTimeAxisView::add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1958 using namespace Menu_Helpers;
1965 track->Hiding.connect (bind (mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1967 bool hideit = (!show);
1969 if ((node = track->get_state_node()) != 0) {
1970 if ((prop = node->property ("shown")) != 0) {
1971 if (string_is_affirmative (prop->value())) {
1977 _automation_tracks.insert(std::make_pair(param, new RouteAutomationNode(param, NULL, track)));
1982 _show_automation.insert (param);
1986 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1990 build_display_menu();
1995 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1997 boost::shared_ptr<Processor> processor (p.lock ());
1999 if (!processor || !processor->display_to_user ()) {
2003 using namespace Menu_Helpers;
2004 ProcessorAutomationInfo *rai;
2005 list<ProcessorAutomationInfo*>::iterator x;
2007 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2008 std::set<Evoral::Parameter> has_visible_automation;
2010 processor->what_has_visible_data(has_visible_automation);
2012 if (automatable.empty()) {
2016 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2017 if ((*x)->processor == processor) {
2022 if (x == processor_automation.end()) {
2024 rai = new ProcessorAutomationInfo (processor);
2025 processor_automation.push_back (rai);
2033 /* any older menu was deleted at the top of processors_changed()
2034 when we cleared the subplugin menu.
2037 rai->menu = manage (new Menu);
2038 MenuList& items = rai->menu->items();
2039 rai->menu->set_name ("ArdourContextMenu");
2043 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2045 ProcessorAutomationNode* pan;
2046 CheckMenuItem* mitem;
2048 string name = processor->describe_parameter (*i);
2050 items.push_back (CheckMenuElem (name));
2051 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2053 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2054 mitem->set_active(true);
2057 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2061 pan = new ProcessorAutomationNode (*i, mitem, *this);
2063 rai->lines.push_back (pan);
2067 pan->menu_item = mitem;
2071 mitem->signal_toggled().connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2074 /* add the menu for this processor, because the subplugin
2075 menu is always cleared at the top of processors_changed().
2076 this is the result of some poor design in gtkmm and/or
2080 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2085 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2086 RouteTimeAxisView::ProcessorAutomationNode* pan)
2088 bool showit = pan->menu_item->get_active();
2089 bool redraw = false;
2091 if (pan->view == 0 && showit) {
2092 add_processor_automation_curve (rai->processor, pan->what);
2096 if (pan->view && showit != pan->view->marked_for_display()) {
2099 pan->view->set_marked_for_display (true);
2100 pan->view->canvas_display()->show();
2101 pan->view->canvas_background()->show();
2103 rai->processor->mark_automation_visible (pan->what, true);
2104 pan->view->set_marked_for_display (false);
2112 if (redraw && !no_redraw) {
2114 /* now trigger a redisplay */
2116 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2122 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2124 if (c.type == RouteProcessorChange::MeterPointChange) {
2125 /* nothing to do if only the meter point has changed */
2129 using namespace Menu_Helpers;
2131 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2132 (*i)->valid = false;
2135 subplugin_menu.items().clear ();
2137 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2138 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2140 bool deleted_processor_automation = false;
2142 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2144 list<ProcessorAutomationInfo*>::iterator tmp;
2152 processor_automation.erase (i);
2153 deleted_processor_automation = true;
2160 if (deleted_processor_automation) {
2161 _route->gui_changed ("visible_tracks", this);
2165 boost::shared_ptr<AutomationLine>
2166 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2168 ProcessorAutomationNode* pan;
2170 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2176 return boost::shared_ptr<AutomationLine>();
2180 RouteTimeAxisView::reset_processor_automation_curves ()
2182 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2188 RouteTimeAxisView::update_rec_display ()
2190 RouteUI::update_rec_display ();
2191 name_entry.set_sensitive (!_route->record_enabled());
2195 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2198 _view->set_layer_display (d);
2202 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2206 RouteTimeAxisView::layer_display () const
2209 return _view->layer_display ();
2212 /* we don't know, since we don't have a _view, so just return something */
2218 boost::shared_ptr<AutomationTimeAxisView>
2219 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2221 AutomationTracks::iterator i = _automation_tracks.find(param);
2222 if (i != _automation_tracks.end())
2223 return i->second->track;
2225 return boost::shared_ptr<AutomationTimeAxisView>();
2229 RouteTimeAxisView::fast_update ()
2231 gm.get_level_meter().update_meters ();
2235 RouteTimeAxisView::hide_meter ()
2238 gm.get_level_meter().hide_meters ();
2242 RouteTimeAxisView::show_meter ()
2248 RouteTimeAxisView::reset_meter ()
2250 if (Config->get_show_track_meters()) {
2251 gm.get_level_meter().setup_meters (height-5);
2258 RouteTimeAxisView::clear_meter ()
2260 gm.get_level_meter().clear_meters ();
2264 RouteTimeAxisView::meter_changed (void *src)
2266 ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::meter_changed), src));
2271 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2277 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu) {
2278 using namespace Menu_Helpers;
2280 if(!_underlay_streams.empty()) {
2281 MenuList& parent_items = parent_menu->items();
2282 Menu* gs_menu = manage (new Menu);
2283 gs_menu->set_name ("ArdourContextMenu");
2284 MenuList& gs_items = gs_menu->items();
2286 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2288 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2289 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2290 bind(mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2296 RouteTimeAxisView::set_underlay_state()
2298 if(!underlay_xml_node) {
2302 XMLNodeList nlist = underlay_xml_node->children();
2303 XMLNodeConstIterator niter;
2304 XMLNode *child_node;
2306 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2307 child_node = *niter;
2309 if(child_node->name() != "Underlay") {
2313 XMLProperty* prop = child_node->property ("id");
2315 PBD::ID id (prop->value());
2317 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2320 add_underlay(v->view(), false);
2329 RouteTimeAxisView::add_underlay(StreamView* v, bool update_xml)
2335 RouteTimeAxisView& other = v->trackview();
2337 if(find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2338 if(find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2339 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2343 _underlay_streams.push_back(v);
2344 other._underlay_mirrors.push_back(this);
2346 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::add_ghost));
2349 if(!underlay_xml_node) {
2351 underlay_xml_node = xml_node->add_child("Underlays");
2354 XMLNode* node = underlay_xml_node->add_child("Underlay");
2355 XMLProperty* prop = node->add_property("id");
2356 prop->set_value(v->trackview().route()->id().to_s());
2362 RouteTimeAxisView::remove_underlay(StreamView* v)
2368 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2369 RouteTimeAxisView& other = v->trackview();
2371 if(it != _underlay_streams.end()) {
2372 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2374 if(gm == other._underlay_mirrors.end()) {
2375 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2379 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2381 _underlay_streams.erase(it);
2382 other._underlay_mirrors.erase(gm);
2384 if(underlay_xml_node) {
2385 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2391 RouteTimeAxisView::set_button_names ()
2393 rec_enable_button_label.set_text (_("r"));
2395 if (Config->get_solo_control_is_listen_control()) {
2396 switch (Config->get_listen_position()) {
2397 case AfterFaderListen:
2398 solo_button_label.set_text (_("A"));
2400 case PreFaderListen:
2401 solo_button_label.set_text (_("P"));
2405 solo_button_label.set_text (_("s"));
2408 mute_button_label.set_text (_("m"));