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>
35 #include <gtkmm/menu.h>
36 #include <gtkmm/menuitem.h>
37 #include <gtkmm2ext/gtk_ui.h>
38 #include <gtkmm2ext/selector.h>
39 #include <gtkmm2ext/stop_signal.h>
40 #include <gtkmm2ext/bindable_button.h>
41 #include <gtkmm2ext/utils.h>
43 #include <ardour/playlist.h>
44 #include <ardour/audioplaylist.h>
45 #include <ardour/diskstream.h>
46 #include <ardour/processor.h>
47 #include <ardour/ladspa_plugin.h>
48 #include <ardour/location.h>
49 #include <ardour/panner.h>
50 #include <ardour/playlist.h>
51 #include <ardour/session.h>
52 #include <ardour/session_playlist.h>
53 #include <ardour/utils.h>
54 #include <ardour/parameter.h>
55 #include <ardour/profile.h>
57 #include "ardour_ui.h"
58 #include "route_time_axis.h"
59 #include "automation_time_axis.h"
60 #include "canvas_impl.h"
61 #include "crossfade_view.h"
63 #include "gui_thread.h"
65 #include "playlist_selector.h"
66 #include "point_selection.h"
68 #include "public_editor.h"
69 #include "region_view.h"
70 #include "rgb_macros.h"
71 #include "selection.h"
72 #include "simplerect.h"
73 #include "streamview.h"
76 #include <ardour/track.h>
80 using namespace ARDOUR;
82 using namespace Gtkmm2ext;
84 using namespace Editing;
88 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
91 RouteTimeAxisView::setup_slider_pix ()
93 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
94 throw failed_constructor ();
98 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
100 RouteUI(rt, sess, _("m"), _("s"), _("r")), // mute, solo, and record
101 TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas),
102 parent_canvas (canvas),
104 edit_group_button (_("g")), // group
105 playlist_button (_("p")),
106 size_button (_("h")), // height
107 automation_button (_("a")),
108 visual_button (_("v")),
109 gm (rt, sess, slider, true)
112 gm.get_level_meter().set_no_show_all();
113 gm.get_level_meter().setup_meters(50);
117 playlist_action_menu = 0;
118 automation_action_menu = 0;
121 if (!_route->is_hidden()) {
122 _marked_for_display = true;
125 timestretch_rect = 0;
127 destructive_track_mode_item = 0;
128 normal_track_mode_item = 0;
130 ignore_toggle = false;
132 edit_group_button.set_name ("TrackGroupButton");
133 playlist_button.set_name ("TrackPlaylistButton");
134 automation_button.set_name ("TrackAutomationButton");
135 size_button.set_name ("TrackSizeButton");
136 visual_button.set_name ("TrackVisualButton");
137 hide_button.set_name ("TrackRemoveButton");
139 hide_button.add (*(manage (new Image (::get_icon("hide")))));
140 hide_button.show_all ();
142 edit_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
143 playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
144 automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
145 size_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::size_click), false);
146 visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click));
147 hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click));
149 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
150 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release));
151 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
152 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release));
158 rec_enable_button->remove ();
159 switch (track()->mode()) {
161 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
163 case ARDOUR::Destructive:
164 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
167 rec_enable_button->show_all ();
169 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
170 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
171 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
172 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
176 controls_hbox.pack_start(gm.get_level_meter(), false, false);
177 _route->meter_change.connect (mem_fun(*this, &RouteTimeAxisView::meter_changed));
178 _route->input_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
179 _route->output_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
181 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
182 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
184 controls_table.attach (edit_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
185 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
187 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
188 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
189 ARDOUR_UI::instance()->tooltips().set_tip(edit_group_button,_("Edit Group"));
190 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
191 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
192 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
193 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
194 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
200 /* old school - when we used to put an extra row of buttons in place */
202 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
203 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
204 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
205 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
209 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
212 if (is_track() && track()->mode() == ARDOUR::Normal) {
213 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
218 _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
219 _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
220 _route->processors_changed.connect (mem_fun(*this, &RouteTimeAxisView::processors_changed));
221 _route->NameChanged.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
222 _route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
227 track()->TrackModeChanged.connect (mem_fun(*this, &RouteTimeAxisView::track_mode_changed));
228 track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
229 track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
230 get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed));
232 /* pick up the correct freeze state */
237 editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
238 ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
240 gm.get_gain_slider().signal_scroll_event().connect(mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
241 gm.get_gain_slider().set_name ("TrackGainFader");
244 RouteTimeAxisView::~RouteTimeAxisView ()
246 GoingAway (); /* EMIT_SIGNAL */
248 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
253 delete playlist_menu;
257 if (playlist_action_menu) {
258 delete playlist_action_menu;
259 playlist_action_menu = 0;
267 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
271 _automation_tracks.clear ();
275 RouteTimeAxisView::post_construct ()
277 /* map current state of the route */
279 update_diskstream_display ();
281 subplugin_menu.items().clear ();
282 _route->foreach_processor (this, &RouteTimeAxisView::add_processor_to_subplugin_menu);
283 _route->foreach_processor (this, &RouteTimeAxisView::add_existing_processor_automation_curves);
284 reset_processor_automation_curves ();
288 RouteTimeAxisView::set_playlist (boost::shared_ptr<Playlist> newplaylist)
290 boost::shared_ptr<Playlist> pl = playlist();
293 modified_connection.disconnect ();
294 modified_connection = pl->Modified.connect (mem_fun(*this, &RouteTimeAxisView::playlist_modified));
298 RouteTimeAxisView::playlist_modified ()
303 RouteTimeAxisView::edit_click (GdkEventButton *ev)
305 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
306 _route->set_edit_group (0, this);
310 using namespace Menu_Helpers;
312 MenuList& items = edit_group_menu.items ();
313 RadioMenuItem::Group group;
316 items.push_back (RadioMenuElem (group, _("No group"),
317 bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), (RouteGroup *) 0)));
319 if (_route->edit_group() == 0) {
320 static_cast<RadioMenuItem*>(&items.back())->set_active ();
323 _session.foreach_edit_group (bind (mem_fun (*this, &RouteTimeAxisView::add_edit_group_menu_item), &group));
324 edit_group_menu.popup (ev->button, ev->time);
330 RouteTimeAxisView::add_edit_group_menu_item (RouteGroup *eg, RadioMenuItem::Group* group)
332 using namespace Menu_Helpers;
334 MenuList &items = edit_group_menu.items();
336 items.push_back (RadioMenuElem (*group, eg->name(), bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), eg)));
337 if (_route->edit_group() == eg) {
338 static_cast<RadioMenuItem*>(&items.back())->set_active ();
343 RouteTimeAxisView::set_edit_group_from_menu (RouteGroup *eg)
345 _route->set_edit_group (eg, this);
349 RouteTimeAxisView::playlist_changed ()
355 set_playlist (get_diskstream()->playlist());
360 RouteTimeAxisView::label_view ()
362 string x = _route->name();
364 if (x != name_entry.get_text()) {
365 name_entry.set_text (x);
368 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
372 RouteTimeAxisView::route_name_changed ()
374 editor.route_name_changed (this);
379 RouteTimeAxisView::take_name_changed (void *src)
388 RouteTimeAxisView::playlist_click ()
390 // always build a new action menu
392 if (playlist_action_menu != 0) {
393 delete playlist_action_menu;
396 playlist_action_menu = new Menu;
397 playlist_action_menu->set_name ("ArdourContextMenu");
399 build_playlist_menu (playlist_action_menu);
401 conditionally_add_to_selection ();
402 playlist_action_menu->popup (1, gtk_get_current_event_time());
406 RouteTimeAxisView::automation_click ()
408 if (automation_action_menu == 0) {
409 /* this seems odd, but the automation action
410 menu is built as part of the display menu.
412 build_display_menu ();
414 conditionally_add_to_selection ();
415 automation_action_menu->popup (1, gtk_get_current_event_time());
419 RouteTimeAxisView::set_state (const XMLNode& node)
421 TimeAxisView::set_state (node);
423 XMLNodeList kids = node.children();
424 XMLNodeConstIterator iter;
425 const XMLProperty* prop;
427 for (iter = kids.begin(); iter != kids.end(); ++iter) {
428 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
429 if ((prop = (*iter)->property ("automation-id")) != 0) {
430 Parameter param(prop->value());
431 bool show = ((prop = (*iter)->property ("shown")) != 0) && prop->value() == "yes";
432 create_automation_child(param, show);
434 warning << "Automation child has no ID" << endmsg;
442 RouteTimeAxisView::build_automation_action_menu ()
444 using namespace Menu_Helpers;
446 automation_action_menu = manage (new Menu);
447 MenuList& automation_items = automation_action_menu->items();
448 automation_action_menu->set_name ("ArdourContextMenu");
450 automation_items.push_back (MenuElem (_("Show all automation"),
451 mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
453 automation_items.push_back (MenuElem (_("Show existing automation"),
454 mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
456 automation_items.push_back (MenuElem (_("Hide all automation"),
457 mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
459 if (subplugin_menu.get_attach_widget())
460 subplugin_menu.detach();
462 automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
464 map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i;
465 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
467 automation_items.push_back (SeparatorElem());
469 if (i->second->menu_item)
470 delete i->second->menu_item;
472 automation_items.push_back(CheckMenuElem (_route->describe_parameter(i->second->param),
473 bind (mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
475 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&automation_items.back());
477 i->second->menu_item->set_active(show_automation(i->second->param));
478 //i->second->menu_item->set_active(false);
483 RouteTimeAxisView::build_display_menu ()
485 using namespace Menu_Helpers;
487 /* get the size menu ready */
493 TimeAxisView::build_display_menu ();
495 /* now fill it with our stuff */
497 MenuList& items = display_menu->items();
498 display_menu->set_name ("ArdourContextMenu");
500 items.push_back (MenuElem (_("Height"), *size_menu));
501 items.push_back (MenuElem (_("Color"), mem_fun(*this, &RouteTimeAxisView::select_track_color)));
503 items.push_back (SeparatorElem());
505 build_remote_control_menu ();
506 build_automation_action_menu ();
508 if (!Profile->get_sae()) {
509 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
510 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
511 items.push_back (SeparatorElem());
514 // Hook for derived classes to add type specific stuff
515 append_extra_display_menu_items ();
516 items.push_back (SeparatorElem());
520 Menu *layers_menu = manage(new Menu);
521 MenuList &layers_items = layers_menu->items();
522 layers_menu->set_name("ArdourContextMenu");
524 RadioMenuItem::Group layers_group;
526 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
527 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
528 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
529 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
531 items.push_back (MenuElem (_("Layers"), *layers_menu));
533 Menu* alignment_menu = manage (new Menu);
534 MenuList& alignment_items = alignment_menu->items();
535 alignment_menu->set_name ("ArdourContextMenu");
537 RadioMenuItem::Group align_group;
539 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
540 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
541 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
542 if (get_diskstream()->alignment_style() == ExistingMaterial)
543 align_existing_item->set_active();
545 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
546 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
547 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
548 if (get_diskstream()->alignment_style() == CaptureTime)
549 align_capture_item->set_active();
551 if (!Profile->get_sae()) {
552 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
553 get_diskstream()->AlignmentStyleChanged.connect (mem_fun(*this, &RouteTimeAxisView::align_style_changed));
555 RadioMenuItem::Group mode_group;
556 items.push_back (RadioMenuElem (mode_group, _("Normal mode"),
557 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Normal)));
558 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
559 items.push_back (RadioMenuElem (mode_group, _("Tape mode"),
560 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Destructive)));
561 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
563 switch (track()->mode()) {
564 case ARDOUR::Destructive:
565 destructive_track_mode_item->set_active ();
568 normal_track_mode_item->set_active ();
572 get_diskstream()->AlignmentStyleChanged.connect (
573 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
575 mode_menu = build_mode_menu();
577 items.push_back (MenuElem (_("Mode"), *mode_menu));
579 items.push_back (SeparatorElem());
583 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
584 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
585 route_active_menu_item->set_active (_route->active());
587 items.push_back (SeparatorElem());
588 items.push_back (MenuElem (_("Hide"), mem_fun(*this, &RouteTimeAxisView::hide_click)));
589 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
592 static bool __reset_item (RadioMenuItem* item)
599 RouteTimeAxisView::set_track_mode (TrackMode mode)
602 RadioMenuItem* other_item;
606 item = normal_track_mode_item;
607 other_item = destructive_track_mode_item;
609 case ARDOUR::Destructive:
610 item = destructive_track_mode_item;
611 other_item = normal_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 && item->get_active () && track()->mode() != mode) {
620 _set_track_mode (track().get(), mode, other_item);
625 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item)
629 if (!track->can_use_mode (mode, needs_bounce)) {
633 Glib::signal_idle().connect (bind (sigc::ptr_fun (__reset_item), reset_item));
636 cerr << "would bounce this one\n";
641 track->set_mode (mode);
643 rec_enable_button->remove ();
646 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
648 case ARDOUR::Destructive:
649 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
652 rec_enable_button->show_all ();
657 RouteTimeAxisView::track_mode_changed ()
661 switch (track()->mode()) {
663 item = normal_track_mode_item;
665 case ARDOUR::Destructive:
666 item = destructive_track_mode_item;
669 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
678 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
684 TimeAxisView::show_timestretch (start, end);
694 /* check that the time selection was made in our route, or our edit group.
695 remember that edit_group() == 0 implies the route is *not* in a edit group.
698 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->edit_group()))) {
699 /* this doesn't apply to us */
703 /* ignore it if our edit group is not active */
705 if ((ts.track != this) && _route->edit_group() && !_route->edit_group()->is_active()) {
710 if (timestretch_rect == 0) {
711 timestretch_rect = new SimpleRect (*canvas_display);
712 timestretch_rect->property_x1() = 0.0;
713 timestretch_rect->property_y1() = 0.0;
714 timestretch_rect->property_x2() = 0.0;
715 timestretch_rect->property_y2() = 0.0;
716 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
717 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
720 timestretch_rect->show ();
721 timestretch_rect->raise_to_top ();
723 x1 = start / editor.get_current_zoom();
724 x2 = (end - 1) / editor.get_current_zoom();
725 y2 = current_height() - 2;
727 timestretch_rect->property_x1() = x1;
728 timestretch_rect->property_y1() = 1.0;
729 timestretch_rect->property_x2() = x2;
730 timestretch_rect->property_y2() = y2;
734 RouteTimeAxisView::hide_timestretch ()
736 TimeAxisView::hide_timestretch ();
738 if (timestretch_rect) {
739 timestretch_rect->hide ();
744 RouteTimeAxisView::show_selection (TimeSelection& ts)
748 /* ignore it if our edit group is not active or if the selection was started
749 in some other track or edit group (remember that edit_group() == 0 means
750 that the track is not in an edit group).
753 if (((ts.track != this && !is_child (ts.track)) && _route->edit_group() && !_route->edit_group()->is_active()) ||
754 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->edit_group())))) {
760 TimeAxisView::show_selection (ts);
764 RouteTimeAxisView::set_height (uint32_t h)
767 bool height_changed = (height == 0) || (h != height);
768 gm.get_level_meter().setup_meters (gmlen);
770 TimeAxisView::set_height (h);
775 _view->set_height ((double) current_height());
779 snprintf (buf, sizeof (buf), "%u", height);
780 xml_node->add_property ("height", buf);
782 if (height >= hNormal) {
787 gm.get_gain_slider().show();
790 if (rec_enable_button)
791 rec_enable_button->show();
793 edit_group_button.show();
795 visual_button.show();
797 automation_button.show();
799 if (is_track() && track()->mode() == ARDOUR::Normal) {
800 playlist_button.show();
803 } else if (height >= hSmaller) {
809 gm.get_gain_slider().hide();
812 if (rec_enable_button)
813 rec_enable_button->show();
815 edit_group_button.hide ();
817 visual_button.hide ();
819 automation_button.hide ();
821 if (is_track() && track()->mode() == ARDOUR::Normal) {
822 playlist_button.hide ();
830 gm.get_gain_slider().hide();
833 if (rec_enable_button)
834 rec_enable_button->hide();
836 edit_group_button.hide ();
838 visual_button.hide ();
840 automation_button.hide ();
841 playlist_button.hide ();
842 name_label.set_text (_route->name());
845 if (height_changed) {
846 /* only emit the signal if the height really changed */
847 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
852 RouteTimeAxisView::select_track_color ()
854 if (RouteUI::choose_color ()) {
857 _view->apply_color (_color, StreamView::RegionColor);
863 RouteTimeAxisView::reset_samples_per_unit ()
865 set_samples_per_unit (editor.get_current_zoom());
869 RouteTimeAxisView::set_samples_per_unit (double spu)
873 if (get_diskstream() != 0) {
874 speed = get_diskstream()->speed();
878 _view->set_samples_per_unit (spu * speed);
881 TimeAxisView::set_samples_per_unit (spu * speed);
885 RouteTimeAxisView::align_style_changed ()
887 switch (get_diskstream()->alignment_style()) {
888 case ExistingMaterial:
889 if (!align_existing_item->get_active()) {
890 align_existing_item->set_active();
894 if (!align_capture_item->get_active()) {
895 align_capture_item->set_active();
902 RouteTimeAxisView::set_align_style (AlignStyle style)
907 case ExistingMaterial:
908 item = align_existing_item;
911 item = align_capture_item;
914 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
919 if (item->get_active()) {
920 get_diskstream()->set_align_style (style);
925 RouteTimeAxisView::rename_current_playlist ()
927 ArdourPrompter prompter (true);
930 boost::shared_ptr<Diskstream> ds = get_diskstream();
931 if (!ds || ds->destructive())
934 boost::shared_ptr<Playlist> pl = ds->playlist();
938 prompter.set_prompt (_("Name for playlist"));
939 prompter.set_initial_text (pl->name());
940 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
941 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
943 switch (prompter.run ()) {
944 case Gtk::RESPONSE_ACCEPT:
945 prompter.get_result (name);
957 RouteTimeAxisView::use_copy_playlist (bool prompt)
961 boost::shared_ptr<Diskstream> ds = get_diskstream();
962 if (!ds || ds->destructive())
965 boost::shared_ptr<const Playlist> pl = ds->playlist();
972 name = Playlist::bump_name (name, _session);
973 } while (_session.playlist_by_name(name));
975 // TODO: The prompter "new" button should be de-activated if the user
976 // specifies a playlist name which already exists in the session.
980 ArdourPrompter prompter (true);
982 prompter.set_prompt (_("Name for Playlist"));
983 prompter.set_initial_text (name);
984 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
985 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
986 prompter.show_all ();
988 switch (prompter.run ()) {
989 case Gtk::RESPONSE_ACCEPT:
990 prompter.get_result (name);
999 ds->use_copy_playlist ();
1000 ds->playlist()->set_name (name);
1005 RouteTimeAxisView::use_new_playlist (bool prompt)
1009 boost::shared_ptr<Diskstream> ds = get_diskstream();
1010 if (!ds || ds->destructive())
1013 boost::shared_ptr<const Playlist> pl = ds->playlist();
1020 name = Playlist::bump_name (name, _session);
1021 } while (_session.playlist_by_name(name));
1026 ArdourPrompter prompter (true);
1028 prompter.set_prompt (_("Name for Playlist"));
1029 prompter.set_initial_text (name);
1030 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1031 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1033 switch (prompter.run ()) {
1034 case Gtk::RESPONSE_ACCEPT:
1035 prompter.get_result (name);
1043 if (name.length()) {
1044 ds->use_new_playlist ();
1045 ds->playlist()->set_name (name);
1050 RouteTimeAxisView::clear_playlist ()
1052 boost::shared_ptr<Diskstream> ds = get_diskstream();
1053 if (!ds || ds->destructive())
1056 boost::shared_ptr<Playlist> pl = ds->playlist();
1060 editor.clear_playlist (pl);
1064 RouteTimeAxisView::speed_changed ()
1066 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
1070 RouteTimeAxisView::diskstream_changed ()
1072 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::update_diskstream_display));
1076 RouteTimeAxisView::update_diskstream_display ()
1078 if (!get_diskstream()) // bus
1081 set_playlist (get_diskstream()->playlist());
1086 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1088 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1090 /* special case: select/deselect all tracks */
1091 if (editor.get_selection().selected (this)) {
1092 editor.get_selection().clear_tracks ();
1094 editor.select_all_tracks ();
1100 PublicEditor::TrackViewList* tracks = editor.get_valid_views (this, _route->edit_group());
1102 switch (Keyboard::selection_type (ev->state)) {
1103 case Selection::Toggle:
1104 editor.get_selection().toggle (*tracks);
1107 case Selection::Set:
1108 editor.get_selection().set (*tracks);
1111 case Selection::Extend:
1112 if (tracks->size() > 1) {
1113 /* add each one, do not "extend" */
1114 editor.get_selection().add (*tracks);
1116 /* extend to the single track */
1117 editor.extend_selection_to_track (*tracks->front());
1121 case Selection::Add:
1122 editor.get_selection().add (*tracks);
1130 RouteTimeAxisView::set_selected_points (PointSelection& points)
1132 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1133 (*i)->set_selected_points (points);
1138 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1141 _view->set_selected_regionviews (regions);
1145 /** Add the selectable things that we have to a list.
1146 * @param results List to add things to.
1149 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1153 if (get_diskstream() != 0) {
1154 speed = get_diskstream()->speed();
1157 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1158 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1160 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1161 _view->get_selectables (start_adjusted, end_adjusted, results);
1164 /* pick up visible automation tracks */
1166 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1167 if (!(*i)->hidden()) {
1168 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1174 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1177 _view->get_inverted_selectables (sel, results);
1180 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1181 if (!(*i)->hidden()) {
1182 (*i)->get_inverted_selectables (sel, results);
1190 RouteTimeAxisView::show_automation(Parameter param)
1192 return (_show_automation.find(param) != _show_automation.end());
1195 /** Retuns NULL if track for \a param doesn't exist.
1197 RouteTimeAxisView::RouteAutomationNode*
1198 RouteTimeAxisView::automation_track(Parameter param)
1200 map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find(param);
1202 if (i != _automation_tracks.end())
1208 /** Shorthand for GainAutomation, etc.
1210 RouteTimeAxisView::RouteAutomationNode*
1211 RouteTimeAxisView::automation_track(AutomationType type)
1213 return automation_track(Parameter(type));
1217 RouteTimeAxisView::edit_group() const
1219 return _route->edit_group();
1223 RouteTimeAxisView::name() const
1225 return _route->name();
1228 boost::shared_ptr<Playlist>
1229 RouteTimeAxisView::playlist () const
1231 boost::shared_ptr<Diskstream> ds;
1233 if ((ds = get_diskstream()) != 0) {
1234 return ds->playlist();
1236 return boost::shared_ptr<Playlist> ();
1241 RouteTimeAxisView::name_entry_changed ()
1245 x = name_entry.get_text ();
1247 if (x == _route->name()) {
1251 strip_whitespace_edges(x);
1253 if (x.length() == 0) {
1254 name_entry.set_text (_route->name());
1258 if (_session.route_name_unique (x)) {
1259 _route->set_name (x);
1261 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1262 name_entry.set_text (_route->name());
1267 RouteTimeAxisView::visual_click ()
1269 popup_display_menu (0);
1273 RouteTimeAxisView::hide_click ()
1275 // LAME fix for hide_button refresh fix
1276 hide_button.set_sensitive(false);
1278 editor.hide_track_in_display (*this);
1280 hide_button.set_sensitive(true);
1283 boost::shared_ptr<Region>
1284 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1286 boost::shared_ptr<Diskstream> stream;
1287 boost::shared_ptr<Playlist> playlist;
1289 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1290 return playlist->find_next_region (pos, point, dir);
1293 return boost::shared_ptr<Region> ();
1297 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1299 boost::shared_ptr<Diskstream> stream;
1300 boost::shared_ptr<Playlist> playlist;
1302 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1303 return playlist->find_next_region_boundary (pos, dir);
1310 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1312 boost::shared_ptr<Playlist> what_we_got;
1313 boost::shared_ptr<Diskstream> ds = get_diskstream();
1314 boost::shared_ptr<Playlist> playlist;
1318 /* route is a bus, not a track */
1322 playlist = ds->playlist();
1324 TimeSelection time (selection.time);
1325 float speed = ds->speed();
1326 if (speed != 1.0f) {
1327 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1328 (*i).start = session_frame_to_track_frame((*i).start, speed);
1329 (*i).end = session_frame_to_track_frame((*i).end, speed);
1333 XMLNode &before = playlist->get_state();
1336 if ((what_we_got = playlist->cut (time)) != 0) {
1337 editor.get_cut_buffer().add (what_we_got);
1338 _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1343 if ((what_we_got = playlist->copy (time)) != 0) {
1344 editor.get_cut_buffer().add (what_we_got);
1349 if ((what_we_got = playlist->cut (time)) != 0) {
1350 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1351 what_we_got->release ();
1361 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1367 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1368 PlaylistSelection::iterator p;
1370 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth);
1372 if (p == selection.playlists.end()) {
1376 if (get_diskstream()->speed() != 1.0f)
1377 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1379 XMLNode &before = playlist->get_state();
1380 playlist->paste (*p, pos, times);
1381 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1387 TimeAxisView::Children
1388 RouteTimeAxisView::get_child_list()
1390 TimeAxisView::Children redirect_children;
1392 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1393 if (!(*i)->hidden()) {
1394 redirect_children.push_back(*i);
1397 return redirect_children;
1402 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1404 using namespace Menu_Helpers;
1406 if (!menu || !is_track()) {
1410 MenuList& playlist_items = menu->items();
1411 menu->set_name ("ArdourContextMenu");
1412 playlist_items.clear();
1414 if (playlist_menu) {
1415 delete playlist_menu;
1418 playlist_menu = new Menu;
1419 playlist_menu->set_name ("ArdourContextMenu");
1421 vector<boost::shared_ptr<Playlist> > playlists;
1422 boost::shared_ptr<Diskstream> ds = get_diskstream();
1423 RadioMenuItem::Group playlist_group;
1425 _session.get_playlists (playlists);
1427 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1429 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1430 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1431 boost::weak_ptr<Playlist> (*i))));
1433 if (ds->playlist()->id() == (*i)->id()) {
1434 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1436 } else if (ds->playlist()->id() == (*i)->id()) {
1437 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1438 boost::weak_ptr<Playlist>(*i))));
1439 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1444 playlist_items.push_back (SeparatorElem());
1445 playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1446 playlist_items.push_back (SeparatorElem());
1448 playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(editor, &PublicEditor::new_playlists), this)));
1449 playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(editor, &PublicEditor::copy_playlists), this)));
1450 playlist_items.push_back (SeparatorElem());
1451 playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(editor, &PublicEditor::clear_playlists), this)));
1452 playlist_items.push_back (SeparatorElem());
1454 playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1458 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1460 assert (is_track());
1462 boost::shared_ptr<Playlist> pl (wpl.lock());
1468 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1471 get_diskstream()->use_playlist (apl);
1476 RouteTimeAxisView::show_playlist_selector ()
1478 editor.playlist_selector().show_for (this);
1482 RouteTimeAxisView::map_frozen ()
1488 ENSURE_GUI_THREAD (mem_fun(*this, &RouteTimeAxisView::map_frozen));
1490 switch (track()->freeze_state()) {
1492 playlist_button.set_sensitive (false);
1493 rec_enable_button->set_sensitive (false);
1496 playlist_button.set_sensitive (true);
1497 rec_enable_button->set_sensitive (true);
1503 RouteTimeAxisView::color_handler ()
1505 //case cTimeStretchOutline:
1506 if (timestretch_rect) {
1507 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1509 //case cTimeStretchFill:
1510 if (timestretch_rect) {
1511 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1518 RouteTimeAxisView::toggle_automation_track (Parameter param)
1520 RouteAutomationNode* node = automation_track(param);
1525 bool showit = node->menu_item->get_active();
1527 if (showit != node->track->marked_for_display()) {
1529 node->track->set_marked_for_display (true);
1530 node->track->canvas_display->show();
1531 node->track->get_state_node()->add_property ("shown", X_("yes"));
1533 node->track->set_marked_for_display (false);
1534 node->track->hide ();
1535 node->track->get_state_node()->add_property ("shown", X_("no"));
1538 /* now trigger a redisplay */
1541 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1547 RouteTimeAxisView::automation_track_hidden (Parameter param)
1549 RouteAutomationNode* ran = automation_track(param);
1554 _show_automation.erase(param);
1555 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1557 if (ran->menu_item && !_hidden) {
1558 ran->menu_item->set_active (false);
1561 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1566 RouteTimeAxisView::show_all_automation ()
1570 /* Show our automation */
1572 map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i;
1573 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1574 i->second->track->set_marked_for_display (true);
1575 i->second->track->canvas_display->show();
1576 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1577 i->second->menu_item->set_active(true);
1581 /* Show processor automation */
1583 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1584 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1585 if ((*ii)->view == 0) {
1586 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1589 (*ii)->menu_item->set_active (true);
1597 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1601 RouteTimeAxisView::show_existing_automation ()
1605 /* Show our automation */
1607 map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i;
1608 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1609 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1610 i->second->track->set_marked_for_display (true);
1611 i->second->track->canvas_display->show();
1612 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1613 i->second->menu_item->set_active(true);
1618 /* Show processor automation */
1620 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1621 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1622 if ((*ii)->view != 0 && (*i)->processor->data().control((*ii)->what)->list()->size() > 0) {
1623 (*ii)->menu_item->set_active (true);
1630 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1634 RouteTimeAxisView::hide_all_automation ()
1638 /* Hide our automation */
1640 for (map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1641 i->second->track->set_marked_for_display (false);
1642 i->second->track->hide ();
1643 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1644 i->second->menu_item->set_active (false);
1647 /* Hide processor automation */
1649 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1650 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1651 (*ii)->menu_item->set_active (false);
1655 _show_automation.clear();
1658 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1663 RouteTimeAxisView::region_view_added (RegionView* rv)
1665 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1666 if(is_audio_track()) {
1667 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1668 boost::shared_ptr<AutomationTimeAxisView> atv;
1670 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1676 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1677 (*i)->add_ghost(rv);
1681 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1683 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1689 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1691 parent.remove_processor_automation_node (this);
1695 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1698 remove_child (pan->view);
1702 RouteTimeAxisView::ProcessorAutomationNode*
1703 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Parameter what)
1705 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1707 if ((*i)->processor == processor) {
1709 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1710 if ((*ii)->what == what) {
1721 legalize_for_xml_node (string str)
1723 string::size_type pos;
1724 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1730 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1731 legal.replace (pos, 1, "_");
1740 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Parameter what)
1743 ProcessorAutomationNode* pan;
1745 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1746 fatal << _("programming error: ")
1747 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1748 processor->name(), what)
1758 name = processor->describe_parameter (what);
1760 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1764 char state_name[256];
1765 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1767 boost::shared_ptr<AutomationControl> control
1768 = boost::dynamic_pointer_cast<AutomationControl>(processor->data().control(what, true));
1770 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1771 new AutomationTimeAxisView (_session, _route, processor, control,
1772 editor, *this, false, parent_canvas, name, state_name));
1774 pan->view->Hiding.connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1776 if (!pan->view->marked_for_display()) {
1779 pan->menu_item->set_active (true);
1782 add_child (pan->view);
1785 _view->foreach_regionview (mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1788 processor->mark_automation_visible (what, true);
1792 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1795 pan->menu_item->set_active (false);
1798 i->mark_automation_visible (pan->what, false);
1800 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1804 RouteTimeAxisView::add_existing_processor_automation_curves (boost::shared_ptr<Processor> processor)
1807 boost::shared_ptr<AutomationLine> al;
1809 processor->what_has_visible_data (s);
1811 for (set<Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1813 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1816 add_processor_automation_curve (processor, (*i));
1822 RouteTimeAxisView::add_automation_child(Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1824 using namespace Menu_Helpers;
1831 track->Hiding.connect (bind (mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1833 bool hideit = (!show);
1835 if ((node = track->get_state_node()) != 0) {
1836 if ((prop = node->property ("shown")) != 0) {
1837 if (prop->value() == "yes") {
1843 _automation_tracks.insert(std::make_pair(param, new RouteAutomationNode(param, NULL, track)));
1848 _show_automation.insert (param);
1852 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1856 build_display_menu();
1861 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::shared_ptr<Processor> processor)
1863 using namespace Menu_Helpers;
1864 ProcessorAutomationInfo *rai;
1865 list<ProcessorAutomationInfo*>::iterator x;
1867 const std::set<Parameter>& automatable = processor->what_can_be_automated ();
1868 std::set<Parameter> has_visible_automation;
1870 processor->what_has_visible_data(has_visible_automation);
1872 if (automatable.empty()) {
1876 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
1877 if ((*x)->processor == processor) {
1882 if (x == processor_automation.end()) {
1884 rai = new ProcessorAutomationInfo (processor);
1885 processor_automation.push_back (rai);
1893 /* any older menu was deleted at the top of processors_changed()
1894 when we cleared the subplugin menu.
1897 rai->menu = manage (new Menu);
1898 MenuList& items = rai->menu->items();
1899 rai->menu->set_name ("ArdourContextMenu");
1903 for (std::set<Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
1905 ProcessorAutomationNode* pan;
1906 CheckMenuItem* mitem;
1908 string name = processor->describe_parameter (*i);
1910 items.push_back (CheckMenuElem (name));
1911 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
1913 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
1914 mitem->set_active(true);
1917 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
1921 pan = new ProcessorAutomationNode (*i, mitem, *this);
1923 rai->lines.push_back (pan);
1927 pan->menu_item = mitem;
1931 mitem->signal_toggled().connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
1934 /* add the menu for this processor, because the subplugin
1935 menu is always cleared at the top of processors_changed().
1936 this is the result of some poor design in gtkmm and/or
1940 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
1945 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
1946 RouteTimeAxisView::ProcessorAutomationNode* pan)
1948 bool showit = pan->menu_item->get_active();
1949 bool redraw = false;
1951 if (pan->view == 0 && showit) {
1952 add_processor_automation_curve (rai->processor, pan->what);
1956 if (pan->view && showit != pan->view->marked_for_display()) {
1959 pan->view->set_marked_for_display (true);
1960 pan->view->canvas_display->show();
1962 rai->processor->mark_automation_visible (pan->what, true);
1963 pan->view->set_marked_for_display (false);
1971 if (redraw && !no_redraw) {
1973 /* now trigger a redisplay */
1975 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1981 RouteTimeAxisView::processors_changed ()
1983 using namespace Menu_Helpers;
1985 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1986 (*i)->valid = false;
1989 subplugin_menu.items().clear ();
1991 _route->foreach_processor (this, &RouteTimeAxisView::add_processor_to_subplugin_menu);
1992 _route->foreach_processor (this, &RouteTimeAxisView::add_existing_processor_automation_curves);
1994 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
1996 list<ProcessorAutomationInfo*>::iterator tmp;
2004 processor_automation.erase (i);
2011 /* change in visibility was possible */
2013 _route->gui_changed ("visible_tracks", this);
2016 boost::shared_ptr<AutomationLine>
2017 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Parameter what)
2019 ProcessorAutomationNode* pan;
2021 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2027 return boost::shared_ptr<AutomationLine>();
2031 RouteTimeAxisView::reset_processor_automation_curves ()
2033 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2039 RouteTimeAxisView::update_rec_display ()
2041 RouteUI::update_rec_display ();
2042 name_entry.set_sensitive (!_route->record_enabled());
2046 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2048 _view->set_layer_display (d);
2052 boost::shared_ptr<AutomationTimeAxisView>
2053 RouteTimeAxisView::automation_child(ARDOUR::Parameter param)
2055 AutomationTracks::iterator i = _automation_tracks.find(param);
2056 if (i != _automation_tracks.end())
2057 return i->second->track;
2059 return boost::shared_ptr<AutomationTimeAxisView>();
2063 RouteTimeAxisView::fast_update ()
2065 gm.get_level_meter().update_meters ();
2069 RouteTimeAxisView::hide_meter ()
2072 gm.get_level_meter().hide_meters ();
2076 RouteTimeAxisView::show_meter ()
2082 RouteTimeAxisView::reset_meter ()
2084 if (Config->get_show_track_meters()) {
2085 gm.get_level_meter().setup_meters (height-5);
2092 RouteTimeAxisView::clear_meter ()
2094 gm.get_level_meter().clear_meters ();
2098 RouteTimeAxisView::meter_changed (void *src)
2100 ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::meter_changed), src));
2105 RouteTimeAxisView::io_changed (IOChange change, void *src)
2111 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu) {
2112 using namespace Menu_Helpers;
2114 if(!_underlay_streams.empty()) {
2115 MenuList& parent_items = parent_menu->items();
2116 Menu* gs_menu = manage (new Menu);
2117 gs_menu->set_name ("ArdourContextMenu");
2118 MenuList& gs_items = gs_menu->items();
2120 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2122 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2123 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2124 bind(mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2130 RouteTimeAxisView::set_underlay_state()
2132 if(!underlay_xml_node) {
2136 XMLNodeList nlist = underlay_xml_node->children();
2137 XMLNodeConstIterator niter;
2138 XMLNode *child_node;
2140 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2141 child_node = *niter;
2143 if(child_node->name() != "Underlay") {
2147 XMLProperty* prop = child_node->property ("id");
2149 PBD::ID id(prop->value());
2151 RouteTimeAxisView* v = editor.get_route_view_by_id(id);
2154 add_underlay(v->view(), false);
2163 RouteTimeAxisView::add_underlay(StreamView* v, bool update_xml)
2169 RouteTimeAxisView& other = v->trackview();
2171 if(find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2172 if(find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2173 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2177 _underlay_streams.push_back(v);
2178 other._underlay_mirrors.push_back(this);
2180 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::add_ghost));
2183 if(!underlay_xml_node) {
2185 underlay_xml_node = xml_node->add_child("Underlays");
2188 XMLNode* node = underlay_xml_node->add_child("Underlay");
2189 XMLProperty* prop = node->add_property("id");
2190 prop->set_value(v->trackview().route()->id().to_s());
2196 RouteTimeAxisView::remove_underlay(StreamView* v)
2202 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2203 RouteTimeAxisView& other = v->trackview();
2205 if(it != _underlay_streams.end()) {
2206 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2208 if(gm == other._underlay_mirrors.end()) {
2209 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2213 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2215 _underlay_streams.erase(it);
2216 other._underlay_mirrors.erase(gm);
2218 if(underlay_xml_node) {
2219 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());