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.
27 #include <sigc++/bind.h>
29 #include <pbd/error.h>
30 #include <pbd/stl_delete.h>
31 #include <pbd/whitespace.h>
32 #include <pbd/memento_command.h>
34 #include <gtkmm/menu.h>
35 #include <gtkmm/menuitem.h>
36 #include <gtkmm2ext/gtk_ui.h>
37 #include <gtkmm2ext/selector.h>
38 #include <gtkmm2ext/stop_signal.h>
39 #include <gtkmm2ext/bindable_button.h>
40 #include <gtkmm2ext/utils.h>
42 #include <ardour/playlist.h>
43 #include <ardour/audioplaylist.h>
44 #include <ardour/diskstream.h>
45 #include <ardour/insert.h>
46 #include <ardour/ladspa_plugin.h>
47 #include <ardour/location.h>
48 #include <ardour/panner.h>
49 #include <ardour/playlist.h>
50 #include <ardour/session.h>
51 #include <ardour/session_playlist.h>
52 #include <ardour/utils.h>
53 #include <ardour/profile.h>
55 #include "ardour_ui.h"
56 #include "route_time_axis.h"
57 #include "automation_time_axis.h"
58 #include "redirect_automation_time_axis.h"
59 #include "redirect_automation_line.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;
87 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
90 RouteTimeAxisView::setup_slider_pix ()
92 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
93 throw failed_constructor ();
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")),
108 gm (sess, slider, true)
111 gm.get_level_meter().set_no_show_all();
112 gm.get_level_meter().setup_meters(50);
116 playlist_action_menu = 0;
117 automation_action_menu = 0;
119 timestretch_rect = 0;
121 destructive_track_mode_item = 0;
122 normal_track_mode_item = 0;
124 ignore_toggle = false;
126 edit_group_button.set_name ("TrackGroupButton");
127 playlist_button.set_name ("TrackPlaylistButton");
128 automation_button.set_name ("TrackAutomationButton");
129 size_button.set_name ("TrackSizeButton");
130 visual_button.set_name ("TrackVisualButton");
131 hide_button.set_name ("TrackRemoveButton");
133 edit_group_button.unset_flags (Gtk::CAN_FOCUS);
134 playlist_button.unset_flags (Gtk::CAN_FOCUS);
135 automation_button.unset_flags (Gtk::CAN_FOCUS);
136 size_button.unset_flags (Gtk::CAN_FOCUS);
137 visual_button.unset_flags (Gtk::CAN_FOCUS);
138 hide_button.unset_flags (Gtk::CAN_FOCUS);
140 hide_button.add (*(manage (new Image (::get_icon("hide")))));
141 hide_button.show_all ();
143 edit_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
144 playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
145 automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
146 size_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::size_click), false);
147 visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click));
148 hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click));
150 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
151 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
152 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
153 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
159 rec_enable_button->remove ();
160 switch (track()->mode()) {
162 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
164 case ARDOUR::Destructive:
165 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
168 rec_enable_button->show_all ();
170 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
171 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
172 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
173 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
177 controls_hbox.pack_start(gm.get_level_meter(), false, false);
178 _route->meter_change.connect (mem_fun(*this, &RouteTimeAxisView::meter_changed));
179 _route->input_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
180 _route->output_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
182 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
183 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
185 controls_table.attach (edit_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
186 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
188 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
189 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
190 ARDOUR_UI::instance()->tooltips().set_tip(edit_group_button,_("Edit Group"));
191 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
192 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
193 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
194 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
195 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
201 /* old school - when we used to put an extra row of buttons in place */
203 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
204 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
205 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
206 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
210 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
213 if (is_track() && track()->mode() == ARDOUR::Normal) {
214 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
219 _route->redirects_changed.connect (mem_fun(*this, &RouteTimeAxisView::redirects_changed));
220 _route->name_changed.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
224 track()->TrackModeChanged.connect (mem_fun(*this, &RouteTimeAxisView::track_mode_changed));
225 track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
226 track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
227 get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed));
229 /* pick up the correct freeze state */
234 editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
235 ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
237 gm.get_gain_slider().signal_scroll_event().connect(mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
238 gm.get_gain_slider().set_name ("TrackGainFader");
241 RouteTimeAxisView::~RouteTimeAxisView ()
243 GoingAway (); /* EMIT_SIGNAL */
245 vector_delete (&redirect_automation_curves);
247 for (list<RedirectAutomationInfo*>::iterator i = redirect_automation.begin(); i != redirect_automation.end(); ++i) {
252 delete playlist_menu;
256 if (playlist_action_menu) {
257 delete playlist_action_menu;
258 playlist_action_menu = 0;
268 RouteTimeAxisView::post_construct ()
270 /* map current state of the route */
272 update_diskstream_display ();
273 subplugin_menu.items().clear ();
274 _route->foreach_redirect (this, &RouteTimeAxisView::add_redirect_to_subplugin_menu);
275 _route->foreach_redirect (this, &RouteTimeAxisView::add_existing_redirect_automation_curves);
276 reset_redirect_automation_curves ();
280 RouteTimeAxisView::set_playlist (boost::shared_ptr<Playlist> newplaylist)
282 boost::shared_ptr<Playlist> pl = playlist();
285 modified_connection.disconnect ();
286 modified_connection = pl->Modified.connect (mem_fun(*this, &RouteTimeAxisView::playlist_modified));
290 RouteTimeAxisView::playlist_modified ()
295 RouteTimeAxisView::edit_click (GdkEventButton *ev)
297 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
298 _route->set_edit_group (0, this);
302 using namespace Menu_Helpers;
304 MenuList& items = edit_group_menu.items ();
305 RadioMenuItem::Group group;
308 items.push_back (RadioMenuElem (group, _("No group"),
309 bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), (RouteGroup *) 0)));
311 if (_route->edit_group() == 0) {
312 static_cast<RadioMenuItem*>(&items.back())->set_active ();
315 _session.foreach_edit_group (bind (mem_fun (*this, &RouteTimeAxisView::add_edit_group_menu_item), &group));
316 edit_group_menu.popup (ev->button, ev->time);
322 RouteTimeAxisView::add_edit_group_menu_item (RouteGroup *eg, RadioMenuItem::Group* group)
324 using namespace Menu_Helpers;
326 MenuList &items = edit_group_menu.items();
328 items.push_back (RadioMenuElem (*group, eg->name(), bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), eg)));
329 if (_route->edit_group() == eg) {
330 static_cast<RadioMenuItem*>(&items.back())->set_active ();
335 RouteTimeAxisView::set_edit_group_from_menu (RouteGroup *eg)
337 _route->set_edit_group (eg, this);
341 RouteTimeAxisView::playlist_changed ()
346 set_playlist (get_diskstream()->playlist());
351 RouteTimeAxisView::label_view ()
353 string x = _route->name();
355 if (x != name_entry.get_text()) {
356 name_entry.set_text (x);
359 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
363 RouteTimeAxisView::route_name_changed (void *src)
365 editor.route_name_changed (this);
370 RouteTimeAxisView::take_name_changed (void *src)
379 RouteTimeAxisView::playlist_click ()
381 // always build a new action menu
383 if (playlist_action_menu != 0) {
384 delete playlist_action_menu;
387 playlist_action_menu = new Menu;
388 playlist_action_menu->set_name ("ArdourContextMenu");
390 build_playlist_menu (playlist_action_menu);
392 conditionally_add_to_selection ();
393 playlist_action_menu->popup (1, gtk_get_current_event_time());
397 RouteTimeAxisView::automation_click ()
399 if (automation_action_menu == 0) {
400 /* this seems odd, but the automation action
401 menu is built as part of the display menu.
403 build_display_menu ();
405 conditionally_add_to_selection ();
406 automation_action_menu->popup (1, gtk_get_current_event_time());
410 RouteTimeAxisView::build_automation_action_menu ()
412 using namespace Menu_Helpers;
414 automation_action_menu = manage (new Menu);
415 MenuList& automation_items = automation_action_menu->items();
416 automation_action_menu->set_name ("ArdourContextMenu");
418 automation_items.push_back (MenuElem (_("Show all automation"),
419 mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
421 automation_items.push_back (MenuElem (_("Show existing automation"),
422 mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
424 automation_items.push_back (MenuElem (_("Hide all automation"),
425 mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
427 automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
431 RouteTimeAxisView::build_display_menu ()
433 using namespace Menu_Helpers;
435 /* get the size menu ready */
441 TimeAxisView::build_display_menu ();
443 /* now fill it with our stuff */
445 MenuList& items = display_menu->items();
446 display_menu->set_name ("ArdourContextMenu");
448 items.push_back (MenuElem (_("Height"), *size_menu));
449 items.push_back (MenuElem (_("Color"), mem_fun(*this, &RouteTimeAxisView::select_track_color)));
451 items.push_back (SeparatorElem());
453 build_remote_control_menu ();
454 build_automation_action_menu ();
456 if (!Profile->get_sae()) {
457 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
458 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
459 items.push_back (SeparatorElem());
462 // Hook for derived classes to add type specific stuff
463 append_extra_display_menu_items ();
464 items.push_back (SeparatorElem());
468 Menu* alignment_menu = manage (new Menu);
469 MenuList& alignment_items = alignment_menu->items();
470 alignment_menu->set_name ("ArdourContextMenu");
472 RadioMenuItem::Group align_group;
474 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
475 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
476 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
477 if (get_diskstream()->alignment_style() == ExistingMaterial)
478 align_existing_item->set_active();
480 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
481 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
482 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
483 if (get_diskstream()->alignment_style() == CaptureTime)
484 align_capture_item->set_active();
486 if (!Profile->get_sae()) {
487 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
488 get_diskstream()->AlignmentStyleChanged.connect (mem_fun(*this, &RouteTimeAxisView::align_style_changed));
490 RadioMenuItem::Group mode_group;
491 items.push_back (RadioMenuElem (mode_group, _("Normal mode"),
492 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Normal)));
493 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
494 items.push_back (RadioMenuElem (mode_group, _("Tape mode"),
495 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Destructive)));
496 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
498 switch (track()->mode()) {
499 case ARDOUR::Destructive:
500 destructive_track_mode_item->set_active ();
503 normal_track_mode_item->set_active ();
507 items.push_back (SeparatorElem());
511 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
512 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
513 route_active_menu_item->set_active (_route->active());
515 items.push_back (SeparatorElem());
516 items.push_back (MenuElem (_("Hide"), mem_fun(*this, &RouteTimeAxisView::hide_click)));
517 if (!Profile->get_sae()) {
518 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
520 items.push_front (SeparatorElem());
521 items.push_front (MenuElem (_("Delete"), mem_fun(*this, &RouteUI::remove_this_route)));
525 static bool __reset_item (RadioMenuItem* item)
532 RouteTimeAxisView::set_track_mode (TrackMode mode)
535 RadioMenuItem* other_item;
539 item = normal_track_mode_item;
540 other_item = destructive_track_mode_item;
542 case ARDOUR::Destructive:
543 item = destructive_track_mode_item;
544 other_item = normal_track_mode_item;
547 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
552 if (item && other_item && item->get_active () && track()->mode() != mode) {
553 _set_track_mode (track(), mode, other_item);
558 RouteTimeAxisView::_set_track_mode (boost::shared_ptr<Track> track, TrackMode mode, RadioMenuItem* reset_item)
562 if (!track->can_use_mode (mode, needs_bounce)) {
566 Glib::signal_idle().connect (bind (sigc::ptr_fun (__reset_item), reset_item));
569 cerr << "would bounce this one\n";
574 track->set_mode (mode);
576 rec_enable_button->remove ();
579 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
581 case ARDOUR::Destructive:
582 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
585 rec_enable_button->show_all ();
590 RouteTimeAxisView::track_mode_changed ()
594 switch (track()->mode()) {
596 item = normal_track_mode_item;
598 case ARDOUR::Destructive:
599 item = destructive_track_mode_item;
602 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
611 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
617 TimeAxisView::show_timestretch (start, end);
627 /* check that the time selection was made in our route, or our edit group.
628 remember that edit_group() == 0 implies the route is *not* in a edit group.
631 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->edit_group()))) {
632 /* this doesn't apply to us */
636 /* ignore it if our edit group is not active */
638 if ((ts.track != this) && _route->edit_group() && !_route->edit_group()->is_active()) {
643 if (timestretch_rect == 0) {
644 timestretch_rect = new SimpleRect (*canvas_display);
645 timestretch_rect->property_x1() = 0.0;
646 timestretch_rect->property_y1() = 0.0;
647 timestretch_rect->property_x2() = 0.0;
648 timestretch_rect->property_y2() = 0.0;
649 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
650 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
653 timestretch_rect->show ();
654 timestretch_rect->raise_to_top ();
656 x1 = start / editor.get_current_zoom();
657 x2 = (end - 1) / editor.get_current_zoom();
658 y2 = current_height() - 2;
660 timestretch_rect->property_x1() = x1;
661 timestretch_rect->property_y1() = 1.0;
662 timestretch_rect->property_x2() = x2;
663 timestretch_rect->property_y2() = y2;
667 RouteTimeAxisView::hide_timestretch ()
669 TimeAxisView::hide_timestretch ();
671 if (timestretch_rect) {
672 timestretch_rect->hide ();
677 RouteTimeAxisView::show_selection (TimeSelection& ts)
681 /* ignore it if our edit group is not active or if the selection was started
682 in some other track or edit group (remember that edit_group() == 0 means
683 that the track is not in an edit group).
686 if (((ts.track != this && !is_child (ts.track)) && _route->edit_group() && !_route->edit_group()->is_active()) ||
687 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->edit_group())))) {
693 TimeAxisView::show_selection (ts);
697 RouteTimeAxisView::set_height (uint32_t h)
700 bool height_changed = (height == 0) || (h != height);
701 gm.get_level_meter().setup_meters (gmlen);
703 TimeAxisView::set_height (h);
708 _view->set_height ((double) current_height());
712 snprintf (buf, sizeof (buf), "%u", height);
713 xml_node->add_property ("height", buf);
715 if (height >= hNormal) {
720 gm.get_gain_slider().show();
723 if (rec_enable_button)
724 rec_enable_button->show();
726 edit_group_button.show();
728 visual_button.show();
730 automation_button.show();
732 if (is_track() && track()->mode() == ARDOUR::Normal) {
733 playlist_button.show();
736 } else if (height >= hSmaller) {
742 gm.get_gain_slider().hide();
745 if (rec_enable_button)
746 rec_enable_button->show();
748 edit_group_button.hide ();
750 visual_button.hide ();
752 automation_button.hide ();
754 if (is_track() && track()->mode() == ARDOUR::Normal) {
755 playlist_button.hide ();
764 gm.get_gain_slider().hide();
767 if (rec_enable_button)
768 rec_enable_button->hide();
770 edit_group_button.hide ();
772 visual_button.hide ();
774 automation_button.hide ();
775 playlist_button.hide ();
776 name_label.set_text (_route->name());
779 if (height_changed) {
780 /* only emit the signal if the height really changed */
781 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
786 RouteTimeAxisView::select_track_color ()
788 if (RouteUI::choose_color ()) {
791 _view->apply_color (_color, StreamView::RegionColor);
797 RouteTimeAxisView::reset_samples_per_unit ()
799 set_samples_per_unit (editor.get_current_zoom());
803 RouteTimeAxisView::set_samples_per_unit (double spu)
807 if (get_diskstream() != 0) {
808 speed = get_diskstream()->speed();
812 _view->set_samples_per_unit (spu * speed);
815 TimeAxisView::set_samples_per_unit (spu * speed);
819 RouteTimeAxisView::align_style_changed ()
821 switch (get_diskstream()->alignment_style()) {
822 case ExistingMaterial:
823 if (!align_existing_item->get_active()) {
824 align_existing_item->set_active();
828 if (!align_capture_item->get_active()) {
829 align_capture_item->set_active();
836 RouteTimeAxisView::set_align_style (AlignStyle style)
841 case ExistingMaterial:
842 item = align_existing_item;
845 item = align_capture_item;
848 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
853 if (item->get_active()) {
854 get_diskstream()->set_align_style (style);
859 RouteTimeAxisView::rename_current_playlist ()
861 ArdourPrompter prompter (true);
864 boost::shared_ptr<Diskstream> ds = get_diskstream();
865 if (!ds || ds->destructive())
868 boost::shared_ptr<Playlist> pl = ds->playlist();
872 prompter.set_prompt (_("Name for playlist"));
873 prompter.set_initial_text (pl->name());
874 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
875 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
877 switch (prompter.run ()) {
878 case Gtk::RESPONSE_ACCEPT:
879 prompter.get_result (name);
891 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
893 std::string ret(basename);
895 std::string group_string = "."+edit_group()->name()+".";
897 // iterate through all playlists
899 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
900 std::string tmp = (*i)->name();
902 std::string::size_type idx = tmp.find(group_string);
903 // find those which belong to this group
904 if (idx != string::npos) {
905 tmp = tmp.substr(idx + group_string.length());
907 // and find the largest current number
908 int x = atoi(tmp.c_str());
918 snprintf (buf, sizeof(buf), "%d", maxnumber);
920 ret = this->name()+"."+edit_group()->name()+"."+buf;
926 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
930 boost::shared_ptr<Diskstream> ds = get_diskstream();
931 if (!ds || ds->destructive())
934 boost::shared_ptr<const Playlist> pl = ds->playlist();
940 if (edit_group() && edit_group()->is_active()) {
941 name = resolve_new_group_playlist_name(name, playlists_before_op);
944 while (_session.playlist_by_name(name)) {
945 name = Playlist::bump_name (name, _session);
948 // TODO: The prompter "new" button should be de-activated if the user
949 // specifies a playlist name which already exists in the session.
953 ArdourPrompter prompter (true);
955 prompter.set_prompt (_("Name for Playlist"));
956 prompter.set_initial_text (name);
957 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
958 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
959 prompter.show_all ();
961 switch (prompter.run ()) {
962 case Gtk::RESPONSE_ACCEPT:
963 prompter.get_result (name);
972 ds->use_copy_playlist ();
973 ds->playlist()->set_name (name);
978 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
982 boost::shared_ptr<Diskstream> ds = get_diskstream();
983 if (!ds || ds->destructive())
986 boost::shared_ptr<const Playlist> pl = ds->playlist();
992 if (edit_group() && edit_group()->is_active()) {
993 name = resolve_new_group_playlist_name(name,playlists_before_op);
996 while (_session.playlist_by_name(name)) {
997 name = Playlist::bump_name (name, _session);
1003 ArdourPrompter prompter (true);
1005 prompter.set_prompt (_("Name for Playlist"));
1006 prompter.set_initial_text (name);
1007 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1008 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1010 switch (prompter.run ()) {
1011 case Gtk::RESPONSE_ACCEPT:
1012 prompter.get_result (name);
1020 if (name.length()) {
1021 ds->use_new_playlist ();
1022 ds->playlist()->set_name (name);
1027 RouteTimeAxisView::clear_playlist ()
1029 boost::shared_ptr<Diskstream> ds = get_diskstream();
1030 if (!ds || ds->destructive())
1033 boost::shared_ptr<Playlist> pl = ds->playlist();
1037 editor.clear_playlist (pl);
1041 RouteTimeAxisView::speed_changed ()
1043 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
1047 RouteTimeAxisView::diskstream_changed ()
1049 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::update_diskstream_display));
1053 RouteTimeAxisView::update_diskstream_display ()
1055 if (!get_diskstream()) // bus
1058 set_playlist (get_diskstream()->playlist());
1063 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1065 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1067 /* special case: select/deselect all tracks */
1068 if (editor.get_selection().selected (this)) {
1069 editor.get_selection().clear_tracks ();
1071 editor.select_all_tracks ();
1077 PublicEditor::TrackViewList* tracks = editor.get_valid_views (this, _route->edit_group());
1079 switch (Keyboard::selection_type (ev->state)) {
1080 case Selection::Toggle:
1081 editor.get_selection().toggle (*tracks);
1084 case Selection::Set:
1085 editor.get_selection().set (*tracks);
1088 case Selection::Extend:
1089 if (tracks->size() > 1) {
1090 /* add each one, do not "extend" */
1091 editor.get_selection().add (*tracks);
1093 /* extend to the single track */
1094 editor.extend_selection_to_track (*tracks->front());
1098 case Selection::Add:
1099 editor.get_selection().add (*tracks);
1107 RouteTimeAxisView::set_selected_points (PointSelection& points)
1109 for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
1110 (*i)->set_selected_points (points);
1115 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1118 _view->set_selected_regionviews (regions);
1123 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1127 if (get_diskstream() != 0) {
1128 speed = get_diskstream()->speed();
1131 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1132 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1134 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1135 _view->get_selectables (start_adjusted, end_adjusted, results);
1138 /* pick up visible automation tracks */
1140 for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
1141 if (!(*i)->hidden()) {
1142 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1148 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1151 _view->get_inverted_selectables (sel, results);
1154 for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
1155 if (!(*i)->hidden()) {
1156 (*i)->get_inverted_selectables (sel, results);
1164 RouteTimeAxisView::edit_group() const
1166 return _route->edit_group();
1170 RouteTimeAxisView::name() const
1172 return _route->name();
1175 boost::shared_ptr<Playlist>
1176 RouteTimeAxisView::playlist () const
1178 boost::shared_ptr<Diskstream> ds;
1180 if ((ds = get_diskstream()) != 0) {
1181 return ds->playlist();
1183 return boost::shared_ptr<Playlist> ();
1188 RouteTimeAxisView::name_entry_changed ()
1192 x = name_entry.get_text ();
1194 if (x == _route->name()) {
1198 strip_whitespace_edges(x);
1200 if (x.length() == 0) {
1201 name_entry.set_text (_route->name());
1205 if (_session.route_name_unique (x)) {
1206 _route->set_name (x, this);
1208 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1209 name_entry.set_text (_route->name());
1214 RouteTimeAxisView::visual_click ()
1216 popup_display_menu (0);
1220 RouteTimeAxisView::hide_click ()
1222 // LAME fix for hide_button refresh fix
1223 hide_button.set_sensitive(false);
1225 editor.hide_track_in_display (*this);
1227 hide_button.set_sensitive(true);
1230 boost::shared_ptr<Region>
1231 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1233 boost::shared_ptr<Diskstream> stream;
1234 boost::shared_ptr<Playlist> playlist;
1236 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1237 return playlist->find_next_region (pos, point, dir);
1240 return boost::shared_ptr<Region> ();
1244 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1246 boost::shared_ptr<Diskstream> stream;
1247 boost::shared_ptr<Playlist> playlist;
1249 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1250 return playlist->find_next_region_boundary (pos, dir);
1257 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1259 boost::shared_ptr<Playlist> what_we_got;
1260 boost::shared_ptr<Diskstream> ds = get_diskstream();
1261 boost::shared_ptr<Playlist> playlist;
1265 /* route is a bus, not a track */
1269 playlist = ds->playlist();
1271 TimeSelection time (selection.time);
1272 float speed = ds->speed();
1273 if (speed != 1.0f) {
1274 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1275 (*i).start = session_frame_to_track_frame((*i).start, speed);
1276 (*i).end = session_frame_to_track_frame((*i).end, speed);
1280 XMLNode &before = playlist->get_state();
1283 if ((what_we_got = playlist->cut (time)) != 0) {
1284 editor.get_cut_buffer().add (what_we_got);
1285 _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1290 if ((what_we_got = playlist->copy (time)) != 0) {
1291 editor.get_cut_buffer().add (what_we_got);
1296 if ((what_we_got = playlist->cut (time)) != 0) {
1297 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1298 what_we_got->release ();
1308 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1314 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1315 PlaylistSelection::iterator p;
1317 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth);
1319 if (p == selection.playlists.end()) {
1323 if (get_diskstream()->speed() != 1.0f)
1324 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1326 XMLNode &before = playlist->get_state();
1327 playlist->paste (*p, pos, times);
1328 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1335 RouteTimeAxisView::get_child_list()
1338 list<TimeAxisView*>redirect_children;
1340 for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
1341 if (!(*i)->hidden()) {
1342 redirect_children.push_back(*i);
1345 return redirect_children;
1350 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1352 using namespace Menu_Helpers;
1354 if (!menu || !is_track()) {
1358 MenuList& playlist_items = menu->items();
1359 menu->set_name ("ArdourContextMenu");
1360 playlist_items.clear();
1362 if (playlist_menu) {
1363 delete playlist_menu;
1366 playlist_menu = new Menu;
1367 playlist_menu->set_name ("ArdourContextMenu");
1369 vector<boost::shared_ptr<Playlist> > playlists;
1370 boost::shared_ptr<Diskstream> ds = get_diskstream();
1371 RadioMenuItem::Group playlist_group;
1373 _session.get_playlists (playlists);
1375 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1377 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1378 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1379 boost::weak_ptr<Playlist> (*i))));
1381 if (ds->playlist()->id() == (*i)->id()) {
1382 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1384 } else if (ds->playlist()->id() == (*i)->id()) {
1385 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1386 boost::weak_ptr<Playlist>(*i))));
1387 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1392 playlist_items.push_back (SeparatorElem());
1393 playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1394 playlist_items.push_back (SeparatorElem());
1396 if (!edit_group() || !edit_group()->is_active()) {
1397 playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(editor, &PublicEditor::new_playlists), this)));
1398 playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(editor, &PublicEditor::copy_playlists), this)));
1401 // Use a label which tells the user what is happening
1402 playlist_items.push_back (MenuElem (_("New Take"), bind(mem_fun(editor, &PublicEditor::new_playlists), this)));
1403 playlist_items.push_back (MenuElem (_("Copy Take"), bind(mem_fun(editor, &PublicEditor::copy_playlists), this)));
1407 playlist_items.push_back (SeparatorElem());
1408 playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(editor, &PublicEditor::clear_playlists), this)));
1409 playlist_items.push_back (SeparatorElem());
1411 playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1415 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1417 assert (is_track());
1419 boost::shared_ptr<Playlist> pl (wpl.lock());
1425 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1428 if (get_diskstream()->playlist() == apl) {
1429 // radio button cotnrols mean this function is called for both the
1430 // old and new playlist
1433 get_diskstream()->use_playlist (apl);
1436 if (edit_group() && edit_group()->is_active()) {
1437 //PBD::stacktrace(cerr, 20);
1438 std::string group_string = "."+edit_group()->name()+".";
1440 std::string take_name = apl->name();
1441 std::string::size_type idx = take_name.find(group_string);
1443 if (idx == std::string::npos)
1446 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1448 for (list<Route*>::const_iterator i = edit_group()->route_list().begin(); i != edit_group()->route_list().end(); ++i) {
1449 if ( (*i) == this->route().get()) {
1453 std::string playlist_name = (*i)->name()+group_string+take_name;
1455 Track *track = dynamic_cast<Track *>(*i);
1457 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1461 boost::shared_ptr<Playlist> ipl = session().playlist_by_name(playlist_name);
1463 // No playlist for this track for this take yet, make it
1464 track->diskstream()->use_new_playlist();
1465 track->diskstream()->playlist()->set_name(playlist_name);
1467 track->diskstream()->use_playlist(ipl);
1477 RouteTimeAxisView::show_playlist_selector ()
1479 editor.playlist_selector().show_for (this);
1483 RouteTimeAxisView::map_frozen ()
1489 ENSURE_GUI_THREAD (mem_fun(*this, &RouteTimeAxisView::map_frozen));
1491 switch (track()->freeze_state()) {
1493 playlist_button.set_sensitive (false);
1494 rec_enable_button->set_sensitive (false);
1497 playlist_button.set_sensitive (true);
1498 rec_enable_button->set_sensitive (true);
1504 RouteTimeAxisView::color_handler ()
1506 if (timestretch_rect) {
1507 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1510 if (timestretch_rect) {
1511 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1518 RouteTimeAxisView::show_all_automation ()
1522 for (list<RedirectAutomationInfo*>::iterator i = redirect_automation.begin(); i != redirect_automation.end(); ++i) {
1523 for (vector<RedirectAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1524 if ((*ii)->view == 0) {
1525 add_redirect_automation_curve ((*i)->redirect, (*ii)->what);
1528 (*ii)->menu_item->set_active (true);
1534 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1538 RouteTimeAxisView::show_existing_automation ()
1542 for (list<RedirectAutomationInfo*>::iterator i = redirect_automation.begin(); i != redirect_automation.end(); ++i) {
1543 for (vector<RedirectAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1544 if ((*ii)->view != 0) {
1545 (*ii)->menu_item->set_active (true);
1552 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1556 RouteTimeAxisView::hide_all_automation ()
1560 for (list<RedirectAutomationInfo*>::iterator i = redirect_automation.begin(); i != redirect_automation.end(); ++i) {
1561 for (vector<RedirectAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1562 (*ii)->menu_item->set_active (false);
1567 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1572 RouteTimeAxisView::region_view_added (RegionView* rv)
1574 for (vector<TimeAxisView*>::iterator i = children.begin(); i != children.end(); ++i) {
1575 AutomationTimeAxisView* atv;
1577 if ((atv = dynamic_cast<AutomationTimeAxisView*> (*i)) != 0) {
1578 rv->add_ghost (*atv);
1584 RouteTimeAxisView::add_ghost_to_redirect (RegionView* rv, AutomationTimeAxisView* atv)
1586 rv->add_ghost (*atv);
1589 RouteTimeAxisView::RedirectAutomationInfo::~RedirectAutomationInfo ()
1591 for (vector<RedirectAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1597 RouteTimeAxisView::RedirectAutomationNode::~RedirectAutomationNode ()
1599 parent.remove_ran (this);
1607 RouteTimeAxisView::remove_ran (RedirectAutomationNode* ran)
1610 remove_child (ran->view);
1614 RouteTimeAxisView::RedirectAutomationNode*
1615 RouteTimeAxisView::find_redirect_automation_node (boost::shared_ptr<Redirect> redirect, uint32_t what)
1617 for (list<RedirectAutomationInfo*>::iterator i = redirect_automation.begin(); i != redirect_automation.end(); ++i) {
1619 if ((*i)->redirect == redirect) {
1621 for (vector<RedirectAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1622 if ((*ii)->what == what) {
1632 // FIXME: duplicated in midi_time_axis.cc
1634 legalize_for_xml_node (string str)
1636 string::size_type pos;
1637 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1643 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1644 legal.replace (pos, 1, "_");
1653 RouteTimeAxisView::add_redirect_automation_curve (boost::shared_ptr<Redirect> redirect, uint32_t what)
1655 RedirectAutomationLine* ral;
1657 RedirectAutomationNode* ran;
1659 if ((ran = find_redirect_automation_node (redirect, what)) == 0) {
1660 fatal << _("programming error: ")
1661 << string_compose (X_("redirect automation curve for %1:%2 not registered with audio track!"),
1662 redirect->name(), what)
1672 name = redirect->describe_parameter (what);
1674 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1676 char state_name[256];
1677 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (redirect->name()).c_str(), what);
1679 ran->view = new RedirectAutomationTimeAxisView (_session, _route, editor, *this, parent_canvas, name, what, *redirect, state_name);
1681 ral = new RedirectAutomationLine (name,
1682 *redirect, what, _session, *ran->view,
1683 *ran->view->canvas_display, redirect->automation_list (what));
1685 ral->set_line_color (ARDOUR_UI::config()->canvasvar_RedirectAutomationLine.get());
1686 ral->queue_reset ();
1688 ran->view->add_line (*ral);
1690 ran->view->Hiding.connect (bind (mem_fun(*this, &RouteTimeAxisView::redirect_automation_track_hidden), ran, redirect));
1692 if (!ran->view->marked_for_display()) {
1695 ran->menu_item->set_active (true);
1698 add_child (ran->view);
1701 _view->foreach_regionview (bind (mem_fun(*this, &RouteTimeAxisView::add_ghost_to_redirect), ran->view));
1704 redirect->mark_automation_visible (what, true);
1708 RouteTimeAxisView::redirect_automation_track_hidden (RouteTimeAxisView::RedirectAutomationNode* ran, boost::shared_ptr<Redirect> r)
1711 ran->menu_item->set_active (false);
1714 r->mark_automation_visible (ran->what, false);
1716 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1720 RouteTimeAxisView::add_existing_redirect_automation_curves (boost::shared_ptr<Redirect> redirect)
1723 RedirectAutomationLine *ral;
1725 redirect->what_has_visible_automation (s);
1727 for (set<uint32_t>::iterator i = s.begin(); i != s.end(); ++i) {
1729 if ((ral = find_redirect_automation_curve (redirect, *i)) != 0) {
1730 ral->queue_reset ();
1732 add_redirect_automation_curve (redirect, (*i));
1738 RouteTimeAxisView::add_redirect_to_subplugin_menu (boost::shared_ptr<Redirect> r)
1740 using namespace Menu_Helpers;
1741 RedirectAutomationInfo *rai;
1742 list<RedirectAutomationInfo*>::iterator x;
1744 const std::set<uint32_t>& automatable = r->what_can_be_automated ();
1745 std::set<uint32_t> has_visible_automation;
1747 r->what_has_visible_automation(has_visible_automation);
1749 if (automatable.empty()) {
1753 for (x = redirect_automation.begin(); x != redirect_automation.end(); ++x) {
1754 if ((*x)->redirect == r) {
1759 if (x == redirect_automation.end()) {
1761 rai = new RedirectAutomationInfo (r);
1762 redirect_automation.push_back (rai);
1770 /* any older menu was deleted at the top of redirects_changed()
1771 when we cleared the subplugin menu.
1774 rai->menu = manage (new Menu);
1775 MenuList& items = rai->menu->items();
1776 rai->menu->set_name ("ArdourContextMenu");
1780 for (std::set<uint32_t>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
1782 RedirectAutomationNode* ran;
1783 CheckMenuItem* mitem;
1785 string name = r->describe_parameter (*i);
1787 items.push_back (CheckMenuElem (name));
1788 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
1790 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
1791 mitem->set_active(true);
1794 if ((ran = find_redirect_automation_node (r, *i)) == 0) {
1798 ran = new RedirectAutomationNode (*i, mitem, *this);
1800 rai->lines.push_back (ran);
1804 ran->menu_item = mitem;
1808 mitem->signal_toggled().connect (bind (mem_fun(*this, &RouteTimeAxisView::redirect_menu_item_toggled), rai, ran));
1811 /* add the menu for this redirect, because the subplugin
1812 menu is always cleared at the top of redirects_changed().
1813 this is the result of some poor design in gtkmm and/or
1817 subplugin_menu.items().push_back (MenuElem (r->name(), *rai->menu));
1822 RouteTimeAxisView::redirect_menu_item_toggled (RouteTimeAxisView::RedirectAutomationInfo* rai,
1823 RouteTimeAxisView::RedirectAutomationNode* ran)
1825 bool showit = ran->menu_item->get_active();
1826 bool redraw = false;
1828 if (ran->view == 0 && showit) {
1829 add_redirect_automation_curve (rai->redirect, ran->what);
1833 if (showit != ran->view->marked_for_display()) {
1836 ran->view->set_marked_for_display (true);
1837 ran->view->canvas_display->show();
1838 ran->view->canvas_background->show();
1840 rai->redirect->mark_automation_visible (ran->what, true);
1841 ran->view->set_marked_for_display (false);
1849 if (redraw && !no_redraw) {
1851 /* now trigger a redisplay */
1853 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1859 RouteTimeAxisView::redirects_changed (void *src)
1861 using namespace Menu_Helpers;
1863 for (list<RedirectAutomationInfo*>::iterator i = redirect_automation.begin(); i != redirect_automation.end(); ++i) {
1864 (*i)->valid = false;
1867 subplugin_menu.items().clear ();
1869 _route->foreach_redirect (this, &RouteTimeAxisView::add_redirect_to_subplugin_menu);
1870 _route->foreach_redirect (this, &RouteTimeAxisView::add_existing_redirect_automation_curves);
1872 for (list<RedirectAutomationInfo*>::iterator i = redirect_automation.begin(); i != redirect_automation.end(); ) {
1874 list<RedirectAutomationInfo*>::iterator tmp;
1882 redirect_automation.erase (i);
1889 /* change in visibility was possible */
1891 _route->gui_changed ("visible_tracks", this);
1894 RedirectAutomationLine *
1895 RouteTimeAxisView::find_redirect_automation_curve (boost::shared_ptr<Redirect> redirect, uint32_t what)
1897 RedirectAutomationNode* ran;
1899 if ((ran = find_redirect_automation_node (redirect, what)) != 0) {
1901 return dynamic_cast<RedirectAutomationLine*> (ran->view->lines.front());
1909 RouteTimeAxisView::reset_redirect_automation_curves ()
1911 for (vector<RedirectAutomationLine*>::iterator i = redirect_automation_curves.begin(); i != redirect_automation_curves.end(); ++i) {
1917 RouteTimeAxisView::update_rec_display ()
1919 RouteUI::update_rec_display ();
1920 name_entry.set_sensitive (!_route->record_enabled());
1924 RouteTimeAxisView::fast_update ()
1926 gm.get_level_meter().update_meters ();
1930 RouteTimeAxisView::hide_meter ()
1933 gm.get_level_meter().hide_meters ();
1937 RouteTimeAxisView::show_meter ()
1943 RouteTimeAxisView::reset_meter ()
1945 if (Config->get_show_track_meters()) {
1946 gm.get_level_meter().setup_meters (height-5);
1953 RouteTimeAxisView::clear_meter ()
1955 gm.get_level_meter().clear_meters ();
1959 RouteTimeAxisView::meter_changed (void *src)
1961 ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::meter_changed), src));
1966 RouteTimeAxisView::io_changed (IOChange change, void *src)