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 slider = ::get_icon ("fader_belt_h");
97 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
99 RouteUI(rt, sess, _("m"), _("s"), _("r")), // mute, solo, and record
100 TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas),
101 parent_canvas (canvas),
103 edit_group_button (_("g")), // group
104 playlist_button (_("p")),
105 size_button (_("h")), // height
106 automation_button (_("a")),
107 visual_button (_("v")),
109 underlay_xml_node (0),
111 gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1)
118 lm.set_no_show_all();
122 playlist_action_menu = 0;
123 automation_action_menu = 0;
125 timestretch_rect = 0;
127 destructive_track_mode_item = 0;
128 normal_track_mode_item = 0;
130 gain_slider = manage (new HSliderController (slider, &gain_adjustment, *_route->gain_control().get(), false));
132 ignore_toggle = false;
134 edit_group_button.set_name ("TrackGroupButton");
135 playlist_button.set_name ("TrackPlaylistButton");
136 automation_button.set_name ("TrackAutomationButton");
137 size_button.set_name ("TrackSizeButton");
138 visual_button.set_name ("TrackVisualButton");
139 hide_button.set_name ("TrackRemoveButton");
141 hide_button.add (*(manage (new Image (::get_icon("hide")))));
142 hide_button.show_all ();
144 edit_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
145 playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
146 automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
147 size_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::size_click), false);
148 visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click));
149 hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click));
151 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
152 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release));
153 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
154 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release));
160 rec_enable_button->remove ();
161 switch (track()->mode()) {
163 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
165 case ARDOUR::Destructive:
166 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
169 rec_enable_button->show_all ();
171 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
172 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
173 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
174 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
178 controls_hbox.pack_start(lm, false, false);
179 _route->meter_change.connect (mem_fun(*this, &RouteTimeAxisView::meter_changed));
180 _route->input_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
181 _route->output_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
183 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
184 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
186 controls_table.attach (edit_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
187 controls_table.attach (*gain_slider, 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
189 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
190 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
191 ARDOUR_UI::instance()->tooltips().set_tip(edit_group_button,_("Edit Group"));
192 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
193 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
194 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
195 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
196 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
202 /* old school - when we used to put an extra row of buttons in place */
204 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
205 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
206 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
207 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
211 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
214 if (is_track() && track()->mode() == ARDOUR::Normal) {
215 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
220 _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
221 _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
222 _route->processors_changed.connect (mem_fun(*this, &RouteTimeAxisView::processors_changed));
223 _route->NameChanged.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
224 _route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
229 track()->TrackModeChanged.connect (mem_fun(*this, &RouteTimeAxisView::track_mode_changed));
230 track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
231 track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
232 get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed));
234 /* pick up the correct freeze state */
239 editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
240 ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
242 gain_slider->signal_button_press_event().connect (mem_fun(*this, &RouteTimeAxisView::start_gain_touch));
243 gain_slider->signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::end_gain_touch));
244 gain_slider->set_name ("TrackGainFader");
246 gain_adjustment.signal_value_changed().connect (mem_fun(*this, &RouteTimeAxisView::gain_adjusted));
247 _route->gain_control()->Changed.connect (mem_fun(*this, &RouteTimeAxisView::gain_changed));
249 gain_slider->show_all();
252 RouteTimeAxisView::~RouteTimeAxisView ()
254 GoingAway (); /* EMIT_SIGNAL */
256 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
261 delete playlist_menu;
265 if (playlist_action_menu) {
266 delete playlist_action_menu;
267 playlist_action_menu = 0;
275 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
279 _automation_tracks.clear ();
283 RouteTimeAxisView::post_construct ()
285 /* map current state of the route */
287 update_diskstream_display ();
288 subplugin_menu.items().clear ();
289 _route->foreach_processor (this, &RouteTimeAxisView::add_processor_to_subplugin_menu);
290 _route->foreach_processor (this, &RouteTimeAxisView::add_existing_processor_automation_curves);
291 reset_processor_automation_curves ();
295 RouteTimeAxisView::set_playlist (boost::shared_ptr<Playlist> newplaylist)
297 boost::shared_ptr<Playlist> pl = playlist();
300 modified_connection.disconnect ();
301 modified_connection = pl->Modified.connect (mem_fun(*this, &RouteTimeAxisView::playlist_modified));
305 RouteTimeAxisView::playlist_modified ()
310 RouteTimeAxisView::set_state (const XMLNode& node)
312 const XMLProperty *prop;
314 TimeAxisView::set_state (node);
316 if ((prop = node.property ("shown_editor")) != 0) {
317 if (prop->value() == "no") {
318 _marked_for_display = false;
320 _marked_for_display = true;
323 _marked_for_display = true;
326 XMLNodeList nlist = node.children();
327 XMLNodeConstIterator niter;
330 _show_automation.clear();
332 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
335 if (child_node->name() == AutomationTimeAxisView::state_node_name) {
336 XMLProperty* prop = child_node->property ("automation-id");
340 Parameter param(prop->value());
346 prop = child_node->property ("shown");
348 if (prop && prop->value() == "yes") {
350 _show_automation.insert(param);
353 if (_automation_tracks.find(param) == _automation_tracks.end()) {
354 create_automation_child(param, show);
357 else if (child_node->name() == "Underlays") {
358 underlay_xml_node = child_node;
360 /* Wait for all gui tracks to be loaded as underlays are cross referencing tracks*/
361 Glib::signal_idle().connect(mem_fun(*this, &RouteTimeAxisView::set_underlay_state));
367 RouteTimeAxisView::get_automation_child_xml_node (Parameter param)
369 return RouteUI::get_automation_child_xml_node (param);
373 RouteTimeAxisView::edit_click (GdkEventButton *ev)
375 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
376 _route->set_edit_group (0, this);
380 using namespace Menu_Helpers;
382 MenuList& items = edit_group_menu.items ();
383 RadioMenuItem::Group group;
386 items.push_back (RadioMenuElem (group, _("No group"),
387 bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), (RouteGroup *) 0)));
389 if (_route->edit_group() == 0) {
390 static_cast<RadioMenuItem*>(&items.back())->set_active ();
393 _session.foreach_edit_group (bind (mem_fun (*this, &RouteTimeAxisView::add_edit_group_menu_item), &group));
394 edit_group_menu.popup (ev->button, ev->time);
400 RouteTimeAxisView::add_edit_group_menu_item (RouteGroup *eg, RadioMenuItem::Group* group)
402 using namespace Menu_Helpers;
404 MenuList &items = edit_group_menu.items();
406 items.push_back (RadioMenuElem (*group, eg->name(), bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), eg)));
407 if (_route->edit_group() == eg) {
408 static_cast<RadioMenuItem*>(&items.back())->set_active ();
413 RouteTimeAxisView::set_edit_group_from_menu (RouteGroup *eg)
415 _route->set_edit_group (eg, this);
419 RouteTimeAxisView::playlist_changed ()
425 set_playlist (get_diskstream()->playlist());
430 RouteTimeAxisView::label_view ()
432 string x = _route->name();
434 if (x != name_entry.get_text()) {
435 name_entry.set_text (x);
438 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
442 RouteTimeAxisView::route_name_changed ()
444 editor.route_name_changed (this);
449 RouteTimeAxisView::take_name_changed (void *src)
458 RouteTimeAxisView::playlist_click ()
460 // always build a new action menu
462 if (playlist_action_menu != 0) {
463 delete playlist_action_menu;
466 playlist_action_menu = new Menu;
467 playlist_action_menu->set_name ("ArdourContextMenu");
469 build_playlist_menu (playlist_action_menu);
471 conditionally_add_to_selection ();
472 playlist_action_menu->popup (1, gtk_get_current_event_time());
476 RouteTimeAxisView::automation_click ()
478 if (automation_action_menu == 0) {
479 /* this seems odd, but the automation action
480 menu is built as part of the display menu.
482 build_display_menu ();
484 conditionally_add_to_selection ();
485 automation_action_menu->popup (1, gtk_get_current_event_time());
489 RouteTimeAxisView::build_automation_action_menu ()
491 using namespace Menu_Helpers;
493 automation_action_menu = manage (new Menu);
494 MenuList& automation_items = automation_action_menu->items();
495 automation_action_menu->set_name ("ArdourContextMenu");
497 automation_items.push_back (MenuElem (_("Show all automation"),
498 mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
500 automation_items.push_back (MenuElem (_("Show existing automation"),
501 mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
503 automation_items.push_back (MenuElem (_("Hide all automation"),
504 mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
506 if (subplugin_menu.get_attach_widget())
507 subplugin_menu.detach();
509 automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
511 map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i;
512 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
514 automation_items.push_back (SeparatorElem());
516 if (i->second->menu_item)
517 delete i->second->menu_item;
519 automation_items.push_back(CheckMenuElem (_route->describe_parameter(i->second->param),
520 bind (mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
522 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&automation_items.back());
524 i->second->menu_item->set_active(show_automation(i->second->param));
525 //i->second->menu_item->set_active(false);
530 RouteTimeAxisView::build_display_menu ()
532 using namespace Menu_Helpers;
534 /* get the size menu ready */
540 TimeAxisView::build_display_menu ();
542 /* now fill it with our stuff */
544 MenuList& items = display_menu->items();
545 display_menu->set_name ("ArdourContextMenu");
547 items.push_back (MenuElem (_("Height"), *size_menu));
548 items.push_back (MenuElem (_("Color"), mem_fun(*this, &RouteTimeAxisView::select_track_color)));
550 items.push_back (SeparatorElem());
552 build_remote_control_menu ();
553 build_automation_action_menu ();
555 if (!Profile->get_sae()) {
556 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
557 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
558 items.push_back (SeparatorElem());
561 // Hook for derived classes to add type specific stuff
562 append_extra_display_menu_items ();
563 items.push_back (SeparatorElem());
567 Menu *layers_menu = manage(new Menu);
568 MenuList &layers_items = layers_menu->items();
569 layers_menu->set_name("ArdourContextMenu");
571 RadioMenuItem::Group layers_group;
573 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
574 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
575 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
576 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
578 items.push_back (MenuElem (_("Layers"), *layers_menu));
580 Menu* alignment_menu = manage (new Menu);
581 MenuList& alignment_items = alignment_menu->items();
582 alignment_menu->set_name ("ArdourContextMenu");
584 RadioMenuItem::Group align_group;
586 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
587 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
588 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
589 if (get_diskstream()->alignment_style() == ExistingMaterial)
590 align_existing_item->set_active();
592 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
593 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
594 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
595 if (get_diskstream()->alignment_style() == CaptureTime)
596 align_capture_item->set_active();
598 if (!Profile->get_sae()) {
599 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
600 get_diskstream()->AlignmentStyleChanged.connect (mem_fun(*this, &RouteTimeAxisView::align_style_changed));
602 RadioMenuItem::Group mode_group;
603 items.push_back (RadioMenuElem (mode_group, _("Normal mode"),
604 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Normal)));
605 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
606 items.push_back (RadioMenuElem (mode_group, _("Tape mode"),
607 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Destructive)));
608 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
610 switch (track()->mode()) {
611 case ARDOUR::Destructive:
612 destructive_track_mode_item->set_active ();
615 normal_track_mode_item->set_active ();
619 get_diskstream()->AlignmentStyleChanged.connect (
620 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
622 mode_menu = build_mode_menu();
624 items.push_back (MenuElem (_("Mode"), *mode_menu));
626 items.push_back (SeparatorElem());
630 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
631 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
632 route_active_menu_item->set_active (_route->active());
634 items.push_back (SeparatorElem());
635 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
638 static bool __reset_item (RadioMenuItem* item)
645 RouteTimeAxisView::set_track_mode (TrackMode mode)
648 RadioMenuItem* other_item;
652 item = normal_track_mode_item;
653 other_item = destructive_track_mode_item;
655 case ARDOUR::Destructive:
656 item = destructive_track_mode_item;
657 other_item = normal_track_mode_item;
660 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
665 if (item && other_item && item->get_active () && track()->mode() != mode) {
666 _set_track_mode (track().get(), mode, other_item);
671 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item)
675 if (!track->can_use_mode (mode, needs_bounce)) {
679 Glib::signal_idle().connect (bind (sigc::ptr_fun (__reset_item), reset_item));
682 cerr << "would bounce this one\n";
687 track->set_mode (mode);
689 rec_enable_button->remove ();
692 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
694 case ARDOUR::Destructive:
695 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
698 rec_enable_button->show_all ();
703 RouteTimeAxisView::track_mode_changed ()
707 switch (track()->mode()) {
709 item = normal_track_mode_item;
711 case ARDOUR::Destructive:
712 item = destructive_track_mode_item;
715 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
724 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
730 TimeAxisView::show_timestretch (start, end);
740 /* check that the time selection was made in our route, or our edit group.
741 remember that edit_group() == 0 implies the route is *not* in a edit group.
744 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->edit_group()))) {
745 /* this doesn't apply to us */
749 /* ignore it if our edit group is not active */
751 if ((ts.track != this) && _route->edit_group() && !_route->edit_group()->is_active()) {
756 if (timestretch_rect == 0) {
757 timestretch_rect = new SimpleRect (*canvas_display);
758 timestretch_rect->property_x1() = 0.0;
759 timestretch_rect->property_y1() = 0.0;
760 timestretch_rect->property_x2() = 0.0;
761 timestretch_rect->property_y2() = 0.0;
762 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
763 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
766 timestretch_rect->show ();
767 timestretch_rect->raise_to_top ();
769 x1 = start / editor.get_current_zoom();
770 x2 = (end - 1) / editor.get_current_zoom();
773 timestretch_rect->property_x1() = x1;
774 timestretch_rect->property_y1() = 1.0;
775 timestretch_rect->property_x2() = x2;
776 timestretch_rect->property_y2() = y2;
780 RouteTimeAxisView::hide_timestretch ()
782 TimeAxisView::hide_timestretch ();
784 if (timestretch_rect) {
785 timestretch_rect->hide ();
790 RouteTimeAxisView::show_selection (TimeSelection& ts)
794 /* ignore it if our edit group is not active or if the selection was started
795 in some other track or edit group (remember that edit_group() == 0 means
796 that the track is not in an edit group).
799 if (((ts.track != this && !is_child (ts.track)) && _route->edit_group() && !_route->edit_group()->is_active()) ||
800 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->edit_group())))) {
806 TimeAxisView::show_selection (ts);
810 RouteTimeAxisView::set_height (TrackHeight h)
812 int gmlen = (height_to_pixels (h)) - 5;
813 bool height_changed = (height == 0) || (h != height_style);
814 lm.setup_meters (gmlen);
815 TimeAxisView::set_height (h);
820 _view->set_height ((double) height);
823 switch (height_style) {
825 xml_node->add_property ("track_height", "largest");
829 xml_node->add_property ("track_height", "large");
833 xml_node->add_property ("track_height", "larger");
837 xml_node->add_property ("track_height", "normal");
841 xml_node->add_property ("track_height", "smaller");
845 xml_node->add_property ("track_height", "small");
849 switch (height_style) {
861 if (rec_enable_button)
862 rec_enable_button->show();
864 edit_group_button.show();
866 visual_button.show();
868 automation_button.show();
870 if (is_track() && track()->mode() == ARDOUR::Normal) {
871 playlist_button.show();
883 if (rec_enable_button)
884 rec_enable_button->show();
886 edit_group_button.hide ();
888 visual_button.hide ();
890 automation_button.hide ();
892 if (is_track() && track()->mode() == ARDOUR::Normal) {
893 playlist_button.hide ();
904 if (rec_enable_button)
905 rec_enable_button->hide();
907 edit_group_button.hide ();
909 visual_button.hide ();
911 automation_button.hide ();
912 playlist_button.hide ();
913 name_label.set_text (_route->name());
917 if (height_changed) {
918 /* only emit the signal if the height really changed */
919 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
924 RouteTimeAxisView::select_track_color ()
926 if (RouteUI::choose_color ()) {
929 _view->apply_color (_color, StreamView::RegionColor);
935 RouteTimeAxisView::reset_samples_per_unit ()
937 set_samples_per_unit (editor.get_current_zoom());
941 RouteTimeAxisView::set_samples_per_unit (double spu)
945 if (get_diskstream() != 0) {
946 speed = get_diskstream()->speed();
950 _view->set_samples_per_unit (spu * speed);
953 TimeAxisView::set_samples_per_unit (spu * speed);
957 RouteTimeAxisView::align_style_changed ()
959 switch (get_diskstream()->alignment_style()) {
960 case ExistingMaterial:
961 if (!align_existing_item->get_active()) {
962 align_existing_item->set_active();
966 if (!align_capture_item->get_active()) {
967 align_capture_item->set_active();
974 RouteTimeAxisView::set_align_style (AlignStyle style)
979 case ExistingMaterial:
980 item = align_existing_item;
983 item = align_capture_item;
986 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
991 if (item->get_active()) {
992 get_diskstream()->set_align_style (style);
997 RouteTimeAxisView::rename_current_playlist ()
999 ArdourPrompter prompter (true);
1002 boost::shared_ptr<Diskstream> ds = get_diskstream();
1003 if (!ds || ds->destructive())
1006 boost::shared_ptr<Playlist> pl = ds->playlist();
1010 prompter.set_prompt (_("Name for playlist"));
1011 prompter.set_initial_text (pl->name());
1012 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1013 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1015 switch (prompter.run ()) {
1016 case Gtk::RESPONSE_ACCEPT:
1017 prompter.get_result (name);
1018 if (name.length()) {
1019 pl->set_name (name);
1029 RouteTimeAxisView::use_copy_playlist (bool prompt)
1033 boost::shared_ptr<Diskstream> ds = get_diskstream();
1034 if (!ds || ds->destructive())
1037 boost::shared_ptr<const Playlist> pl = ds->playlist();
1044 name = Playlist::bump_name (name, _session);
1045 } while (_session.playlist_by_name(name));
1047 // TODO: The prompter "new" button should be de-activated if the user
1048 // specifies a playlist name which already exists in the session.
1052 ArdourPrompter prompter (true);
1054 prompter.set_prompt (_("Name for Playlist"));
1055 prompter.set_initial_text (name);
1056 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1057 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1058 prompter.show_all ();
1060 switch (prompter.run ()) {
1061 case Gtk::RESPONSE_ACCEPT:
1062 prompter.get_result (name);
1070 if (name.length()) {
1071 ds->use_copy_playlist ();
1072 ds->playlist()->set_name (name);
1077 RouteTimeAxisView::use_new_playlist (bool prompt)
1081 boost::shared_ptr<Diskstream> ds = get_diskstream();
1082 if (!ds || ds->destructive())
1085 boost::shared_ptr<const Playlist> pl = ds->playlist();
1092 name = Playlist::bump_name (name, _session);
1093 } while (_session.playlist_by_name(name));
1098 ArdourPrompter prompter (true);
1100 prompter.set_prompt (_("Name for Playlist"));
1101 prompter.set_initial_text (name);
1102 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1103 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1105 switch (prompter.run ()) {
1106 case Gtk::RESPONSE_ACCEPT:
1107 prompter.get_result (name);
1115 if (name.length()) {
1116 ds->use_new_playlist ();
1117 ds->playlist()->set_name (name);
1122 RouteTimeAxisView::clear_playlist ()
1124 boost::shared_ptr<Diskstream> ds = get_diskstream();
1125 if (!ds || ds->destructive())
1128 boost::shared_ptr<Playlist> pl = ds->playlist();
1132 editor.clear_playlist (pl);
1136 RouteTimeAxisView::speed_changed ()
1138 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
1142 RouteTimeAxisView::diskstream_changed ()
1144 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::update_diskstream_display));
1148 RouteTimeAxisView::update_diskstream_display ()
1150 if (!get_diskstream()) // bus
1153 set_playlist (get_diskstream()->playlist());
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->edit_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, 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(Parameter param)
1264 return (_show_automation.find(param) != _show_automation.end());
1267 /** Retuns NULL if track for \a param doesn't exist.
1269 RouteTimeAxisView::RouteAutomationNode*
1270 RouteTimeAxisView::automation_track(Parameter param)
1272 map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find(param);
1274 if (i != _automation_tracks.end())
1280 /** Shorthand for GainAutomation, etc.
1282 RouteTimeAxisView::RouteAutomationNode*
1283 RouteTimeAxisView::automation_track(AutomationType type)
1285 return automation_track(Parameter(type));
1289 RouteTimeAxisView::edit_group() const
1291 return _route->edit_group();
1295 RouteTimeAxisView::name() const
1297 return _route->name();
1300 boost::shared_ptr<Playlist>
1301 RouteTimeAxisView::playlist () const
1303 boost::shared_ptr<Diskstream> ds;
1305 if ((ds = get_diskstream()) != 0) {
1306 return ds->playlist();
1308 return boost::shared_ptr<Playlist> ();
1313 RouteTimeAxisView::name_entry_changed ()
1317 x = name_entry.get_text ();
1319 if (x == _route->name()) {
1323 strip_whitespace_edges(x);
1325 if (x.length() == 0) {
1326 name_entry.set_text (_route->name());
1330 if (_session.route_name_unique (x)) {
1331 _route->set_name (x);
1333 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1334 name_entry.set_text (_route->name());
1339 RouteTimeAxisView::visual_click ()
1341 popup_display_menu (0);
1345 RouteTimeAxisView::hide_click ()
1347 // LAME fix for hide_button refresh fix
1348 hide_button.set_sensitive(false);
1350 editor.hide_track_in_display (*this);
1352 hide_button.set_sensitive(true);
1355 boost::shared_ptr<Region>
1356 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1358 boost::shared_ptr<Diskstream> stream;
1359 boost::shared_ptr<Playlist> playlist;
1361 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1362 return playlist->find_next_region (pos, point, dir);
1365 return boost::shared_ptr<Region> ();
1369 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1371 boost::shared_ptr<Diskstream> stream;
1372 boost::shared_ptr<Playlist> playlist;
1374 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1375 return playlist->find_next_region_boundary (pos, dir);
1382 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1384 boost::shared_ptr<Playlist> what_we_got;
1385 boost::shared_ptr<Diskstream> ds = get_diskstream();
1386 boost::shared_ptr<Playlist> playlist;
1390 /* route is a bus, not a track */
1394 playlist = ds->playlist();
1396 TimeSelection time (selection.time);
1397 float speed = ds->speed();
1398 if (speed != 1.0f) {
1399 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1400 (*i).start = session_frame_to_track_frame((*i).start, speed);
1401 (*i).end = session_frame_to_track_frame((*i).end, speed);
1405 XMLNode &before = playlist->get_state();
1408 if ((what_we_got = playlist->cut (time)) != 0) {
1409 editor.get_cut_buffer().add (what_we_got);
1410 _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1415 if ((what_we_got = playlist->copy (time)) != 0) {
1416 editor.get_cut_buffer().add (what_we_got);
1421 if ((what_we_got = playlist->cut (time)) != 0) {
1422 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1423 what_we_got->release ();
1433 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1439 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1440 PlaylistSelection::iterator p;
1442 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth);
1444 if (p == selection.playlists.end()) {
1448 if (get_diskstream()->speed() != 1.0f)
1449 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1451 XMLNode &before = playlist->get_state();
1452 playlist->paste (*p, pos, times);
1453 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1459 TimeAxisView::Children
1460 RouteTimeAxisView::get_child_list()
1462 TimeAxisView::Children redirect_children;
1464 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1465 if (!(*i)->hidden()) {
1466 redirect_children.push_back(*i);
1469 return redirect_children;
1474 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1476 using namespace Menu_Helpers;
1478 if (!menu || !is_track()) {
1482 MenuList& playlist_items = menu->items();
1483 menu->set_name ("ArdourContextMenu");
1484 playlist_items.clear();
1486 if (playlist_menu) {
1487 delete playlist_menu;
1490 playlist_menu = new Menu;
1491 playlist_menu->set_name ("ArdourContextMenu");
1493 vector<boost::shared_ptr<Playlist> > playlists;
1494 boost::shared_ptr<Diskstream> ds = get_diskstream();
1495 RadioMenuItem::Group playlist_group;
1497 _session.get_playlists (playlists);
1499 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1501 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1502 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1503 boost::weak_ptr<Playlist> (*i))));
1505 if (ds->playlist()->id() == (*i)->id()) {
1506 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1508 } else if (ds->playlist()->id() == (*i)->id()) {
1509 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1510 boost::weak_ptr<Playlist>(*i))));
1511 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1516 playlist_items.push_back (SeparatorElem());
1517 playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1518 playlist_items.push_back (SeparatorElem());
1520 playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(editor, &PublicEditor::new_playlists), this)));
1521 playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(editor, &PublicEditor::copy_playlists), this)));
1522 playlist_items.push_back (SeparatorElem());
1523 playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(editor, &PublicEditor::clear_playlists), this)));
1524 playlist_items.push_back (SeparatorElem());
1526 playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1530 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1532 assert (is_track());
1534 boost::shared_ptr<Playlist> pl (wpl.lock());
1540 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1543 get_diskstream()->use_playlist (apl);
1548 RouteTimeAxisView::show_playlist_selector ()
1550 editor.playlist_selector().show_for (this);
1554 RouteTimeAxisView::map_frozen ()
1560 ENSURE_GUI_THREAD (mem_fun(*this, &RouteTimeAxisView::map_frozen));
1562 switch (track()->freeze_state()) {
1564 playlist_button.set_sensitive (false);
1565 rec_enable_button->set_sensitive (false);
1568 playlist_button.set_sensitive (true);
1569 rec_enable_button->set_sensitive (true);
1575 RouteTimeAxisView::color_handler ()
1577 //case cTimeStretchOutline:
1578 if (timestretch_rect) {
1579 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1581 //case cTimeStretchFill:
1582 if (timestretch_rect) {
1583 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1590 RouteTimeAxisView::toggle_automation_track (Parameter param)
1592 RouteAutomationNode* node = automation_track(param);
1597 bool showit = node->menu_item->get_active();
1599 if (showit != node->track->marked_for_display()) {
1601 node->track->set_marked_for_display (true);
1602 node->track->canvas_display->show();
1603 node->track->get_state_node()->add_property ("shown", X_("yes"));
1605 node->track->set_marked_for_display (false);
1606 node->track->hide ();
1607 node->track->get_state_node()->add_property ("shown", X_("no"));
1610 /* now trigger a redisplay */
1613 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1619 RouteTimeAxisView::automation_track_hidden (Parameter param)
1621 RouteAutomationNode* ran = automation_track(param);
1625 _show_automation.erase(param);
1626 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1628 if (ran->menu_item && !_hidden) {
1629 ran->menu_item->set_active (false);
1632 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1637 RouteTimeAxisView::show_all_automation ()
1641 /* Show our automation */
1643 map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i;
1644 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1645 i->second->track->set_marked_for_display (true);
1646 i->second->track->canvas_display->show();
1647 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1648 i->second->menu_item->set_active(true);
1652 /* Show processor automation */
1654 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1655 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1656 if ((*ii)->view == 0) {
1657 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1660 (*ii)->menu_item->set_active (true);
1669 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1673 RouteTimeAxisView::show_existing_automation ()
1677 /* Show our automation */
1679 map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i;
1680 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1681 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1682 i->second->track->set_marked_for_display (true);
1683 i->second->track->canvas_display->show();
1684 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1685 i->second->menu_item->set_active(true);
1690 /* Show processor automation */
1692 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1693 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1694 if ((*ii)->view != 0 && (*i)->processor->control((*ii)->what)->list()->size() > 0) {
1695 (*ii)->menu_item->set_active (true);
1702 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1706 RouteTimeAxisView::hide_all_automation ()
1710 /* Hide our automation */
1712 for (map<ARDOUR::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1713 i->second->track->set_marked_for_display (false);
1714 i->second->track->hide ();
1715 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1716 i->second->menu_item->set_active (false);
1719 /* Hide processor automation */
1721 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1722 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1723 (*ii)->menu_item->set_active (false);
1727 _show_automation.clear();
1730 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1735 RouteTimeAxisView::region_view_added (RegionView* rv)
1737 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1738 if(is_audio_track()) {
1739 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1740 boost::shared_ptr<AutomationTimeAxisView> atv;
1742 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1748 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1749 (*i)->add_ghost(rv);
1753 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1755 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1761 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1763 parent.remove_processor_automation_node (this);
1767 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1770 remove_child (pan->view);
1774 RouteTimeAxisView::ProcessorAutomationNode*
1775 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Parameter what)
1777 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1779 if ((*i)->processor == processor) {
1781 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1782 if ((*ii)->what == what) {
1793 legalize_for_xml_node (string str)
1795 string::size_type pos;
1796 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1802 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1803 legal.replace (pos, 1, "_");
1812 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Parameter what)
1815 ProcessorAutomationNode* pan;
1817 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1818 fatal << _("programming error: ")
1819 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1820 processor->name(), what)
1830 name = processor->describe_parameter (what);
1832 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1836 char state_name[256];
1837 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1839 boost::shared_ptr<AutomationControl> control = processor->control(what, true);
1841 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1842 new AutomationTimeAxisView (_session, _route, processor, control,
1843 editor, *this, false, parent_canvas, name, state_name));
1845 pan->view->Hiding.connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1847 if (!pan->view->marked_for_display()) {
1850 pan->menu_item->set_active (true);
1853 add_child (pan->view);
1856 _view->foreach_regionview (mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1859 processor->mark_automation_visible (what, true);
1863 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1866 pan->menu_item->set_active (false);
1869 i->mark_automation_visible (pan->what, false);
1871 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1875 RouteTimeAxisView::add_existing_processor_automation_curves (boost::shared_ptr<Processor> processor)
1878 boost::shared_ptr<AutomationLine> al;
1880 processor->what_has_visible_automation (s);
1882 for (set<Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1884 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1887 add_processor_automation_curve (processor, (*i));
1893 RouteTimeAxisView::add_automation_child(Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1895 using namespace Menu_Helpers;
1901 track->Hiding.connect (bind (mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1903 bool hideit = (!show);
1907 if ((node = track->get_state_node()) != 0) {
1908 if ((prop = node->property ("shown")) != 0) {
1909 if (prop->value() == "yes") {
1915 _automation_tracks.insert(std::make_pair(param, new RouteAutomationNode(param, NULL, track)));
1920 _show_automation.insert(param);
1921 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1924 build_display_menu();
1929 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::shared_ptr<Processor> processor)
1931 using namespace Menu_Helpers;
1932 ProcessorAutomationInfo *rai;
1933 list<ProcessorAutomationInfo*>::iterator x;
1935 const std::set<Parameter>& automatable = processor->what_can_be_automated ();
1936 std::set<Parameter> has_visible_automation;
1938 processor->what_has_visible_automation(has_visible_automation);
1940 if (automatable.empty()) {
1944 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
1945 if ((*x)->processor == processor) {
1950 if (x == processor_automation.end()) {
1952 rai = new ProcessorAutomationInfo (processor);
1953 processor_automation.push_back (rai);
1961 /* any older menu was deleted at the top of processors_changed()
1962 when we cleared the subplugin menu.
1965 rai->menu = manage (new Menu);
1966 MenuList& items = rai->menu->items();
1967 rai->menu->set_name ("ArdourContextMenu");
1971 for (std::set<Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
1973 ProcessorAutomationNode* pan;
1974 CheckMenuItem* mitem;
1976 string name = processor->describe_parameter (*i);
1978 items.push_back (CheckMenuElem (name));
1979 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
1981 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
1982 mitem->set_active(true);
1985 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
1989 pan = new ProcessorAutomationNode (*i, mitem, *this);
1991 rai->lines.push_back (pan);
1995 pan->menu_item = mitem;
1999 mitem->signal_toggled().connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2002 /* add the menu for this processor, because the subplugin
2003 menu is always cleared at the top of processors_changed().
2004 this is the result of some poor design in gtkmm and/or
2008 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2013 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2014 RouteTimeAxisView::ProcessorAutomationNode* pan)
2016 bool showit = pan->menu_item->get_active();
2017 bool redraw = false;
2019 if (pan->view == 0 && showit) {
2020 add_processor_automation_curve (rai->processor, pan->what);
2024 if (pan->view && showit != pan->view->marked_for_display()) {
2027 pan->view->set_marked_for_display (true);
2028 pan->view->canvas_display->show();
2030 rai->processor->mark_automation_visible (pan->what, true);
2031 pan->view->set_marked_for_display (false);
2039 if (redraw && !no_redraw) {
2041 /* now trigger a redisplay */
2043 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2049 RouteTimeAxisView::processors_changed ()
2051 using namespace Menu_Helpers;
2053 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2054 (*i)->valid = false;
2057 subplugin_menu.items().clear ();
2059 _route->foreach_processor (this, &RouteTimeAxisView::add_processor_to_subplugin_menu);
2060 _route->foreach_processor (this, &RouteTimeAxisView::add_existing_processor_automation_curves);
2062 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2064 list<ProcessorAutomationInfo*>::iterator tmp;
2072 processor_automation.erase (i);
2079 /* change in visibility was possible */
2081 _route->gui_changed ("track_height", this);
2084 boost::shared_ptr<AutomationLine>
2085 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Parameter what)
2087 ProcessorAutomationNode* pan;
2089 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2095 return boost::shared_ptr<AutomationLine>();
2099 RouteTimeAxisView::reset_processor_automation_curves ()
2101 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2107 RouteTimeAxisView::update_rec_display ()
2109 RouteUI::update_rec_display ();
2110 name_entry.set_sensitive (!_route->record_enabled());
2114 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2116 _view->set_layer_display (d);
2120 boost::shared_ptr<AutomationTimeAxisView>
2121 RouteTimeAxisView::automation_child(ARDOUR::Parameter param)
2123 AutomationTracks::iterator i = _automation_tracks.find(param);
2124 if (i != _automation_tracks.end())
2125 return i->second->track;
2127 return boost::shared_ptr<AutomationTimeAxisView>();
2131 RouteTimeAxisView::fast_update ()
2133 lm.update_meters ();
2137 RouteTimeAxisView::hide_meter ()
2144 RouteTimeAxisView::show_meter ()
2150 RouteTimeAxisView::reset_meter ()
2152 if (Config->get_show_track_meters()) {
2153 lm.setup_meters (height-5);
2160 RouteTimeAxisView::clear_meter ()
2166 RouteTimeAxisView::meter_changed (void *src)
2168 ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::meter_changed), src));
2173 RouteTimeAxisView::io_changed (IOChange change, void *src)
2179 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu) {
2180 using namespace Menu_Helpers;
2182 if(!_underlay_streams.empty()) {
2183 MenuList& parent_items = parent_menu->items();
2184 Menu* gs_menu = manage (new Menu);
2185 gs_menu->set_name ("ArdourContextMenu");
2186 MenuList& gs_items = gs_menu->items();
2188 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2190 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2191 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2192 bind(mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2198 RouteTimeAxisView::set_underlay_state()
2200 if(!underlay_xml_node) {
2204 XMLNodeList nlist = underlay_xml_node->children();
2205 XMLNodeConstIterator niter;
2206 XMLNode *child_node;
2208 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2209 child_node = *niter;
2211 if(child_node->name() != "Underlay") {
2215 XMLProperty* prop = child_node->property ("id");
2217 PBD::ID id(prop->value());
2219 RouteTimeAxisView* v = editor.get_route_view_by_id(id);
2222 add_underlay(v->view(), false);
2231 RouteTimeAxisView::add_underlay(StreamView* v, bool update_xml)
2237 RouteTimeAxisView& other = v->trackview();
2239 if(find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2240 if(find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2241 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2245 _underlay_streams.push_back(v);
2246 other._underlay_mirrors.push_back(this);
2248 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::add_ghost));
2251 if(!underlay_xml_node) {
2253 underlay_xml_node = xml_node->add_child("Underlays");
2256 XMLNode* node = underlay_xml_node->add_child("Underlay");
2257 XMLProperty* prop = node->add_property("id");
2258 prop->set_value(v->trackview().route()->id().to_s());
2264 RouteTimeAxisView::remove_underlay(StreamView* v)
2270 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2271 RouteTimeAxisView& other = v->trackview();
2273 if(it != _underlay_streams.end()) {
2274 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2276 if(gm == other._underlay_mirrors.end()) {
2277 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2281 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2283 _underlay_streams.erase(it);
2284 other._underlay_mirrors.erase(gm);
2286 if(underlay_xml_node) {
2287 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2293 RouteTimeAxisView::start_gain_touch (GdkEventButton* ev)
2295 _route->gain_control()->list()->start_touch ();
2300 RouteTimeAxisView::end_gain_touch (GdkEventButton* ev)
2302 _route->gain_control()->list()->stop_touch ();
2307 RouteTimeAxisView::gain_adjusted ()
2309 _route->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
2313 RouteTimeAxisView::gain_changed ()
2315 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::effective_gain_display));
2319 RouteTimeAxisView::effective_gain_display ()
2321 gfloat value = gain_to_slider_position (_route->effective_gain());
2322 gain_adjustment.set_value (value);