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 <evoral/Parameter.hpp>
55 #include <ardour/profile.h>
57 #include "ardour_ui.h"
58 #include "route_time_axis.h"
59 #include "automation_time_axis.h"
60 #include "canvas_impl.h"
61 #include "crossfade_view.h"
63 #include "gui_thread.h"
65 #include "playlist_selector.h"
66 #include "point_selection.h"
68 #include "public_editor.h"
69 #include "region_view.h"
70 #include "rgb_macros.h"
71 #include "selection.h"
72 #include "simplerect.h"
73 #include "streamview.h"
76 #include <ardour/track.h>
80 using namespace ARDOUR;
82 using namespace Gtkmm2ext;
84 using namespace Editing;
88 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
91 RouteTimeAxisView::setup_slider_pix ()
93 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
94 throw failed_constructor ();
98 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
100 RouteUI(rt, sess, _("m"), _("s"), _("r")), // mute, solo, and record
101 TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas),
102 parent_canvas (canvas),
104 edit_group_button (_("g")), // group
105 playlist_button (_("p")),
106 size_button (_("h")), // height
107 automation_button (_("a")),
108 visual_button (_("v")),
109 gm (sess, slider, true)
112 gm.get_level_meter().set_no_show_all();
113 gm.get_level_meter().setup_meters(50);
117 playlist_action_menu = 0;
118 automation_action_menu = 0;
121 if (!_route->is_hidden()) {
122 _marked_for_display = true;
125 timestretch_rect = 0;
127 destructive_track_mode_item = 0;
128 normal_track_mode_item = 0;
130 ignore_toggle = false;
132 edit_group_button.set_name ("TrackGroupButton");
133 playlist_button.set_name ("TrackPlaylistButton");
134 automation_button.set_name ("TrackAutomationButton");
135 size_button.set_name ("TrackSizeButton");
136 visual_button.set_name ("TrackVisualButton");
137 hide_button.set_name ("TrackRemoveButton");
139 edit_group_button.unset_flags (Gtk::CAN_FOCUS);
140 playlist_button.unset_flags (Gtk::CAN_FOCUS);
141 automation_button.unset_flags (Gtk::CAN_FOCUS);
142 size_button.unset_flags (Gtk::CAN_FOCUS);
143 visual_button.unset_flags (Gtk::CAN_FOCUS);
144 hide_button.unset_flags (Gtk::CAN_FOCUS);
146 hide_button.add (*(manage (new Image (::get_icon("hide")))));
147 hide_button.show_all ();
149 edit_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
150 playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
151 automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
152 size_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::size_click), false);
153 visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click));
154 hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click));
156 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
157 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
158 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
159 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
165 rec_enable_button->remove ();
166 switch (track()->mode()) {
168 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
170 case ARDOUR::Destructive:
171 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
174 rec_enable_button->show_all ();
176 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
177 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
178 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
179 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
183 controls_hbox.pack_start(gm.get_level_meter(), false, false);
184 _route->meter_change.connect (mem_fun(*this, &RouteTimeAxisView::meter_changed));
185 _route->input_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
186 _route->output_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
188 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
189 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
191 controls_table.attach (edit_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
192 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
194 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
195 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
196 ARDOUR_UI::instance()->tooltips().set_tip(edit_group_button,_("Edit Group"));
197 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
198 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
199 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
200 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
201 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
207 /* old school - when we used to put an extra row of buttons in place */
209 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
210 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
211 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
212 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
216 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
219 if (is_track() && track()->mode() == ARDOUR::Normal) {
220 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
225 _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
226 _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
227 _route->processors_changed.connect (mem_fun(*this, &RouteTimeAxisView::processors_changed));
228 _route->NameChanged.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
229 _route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
234 track()->TrackModeChanged.connect (mem_fun(*this, &RouteTimeAxisView::track_mode_changed));
235 track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
236 track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
237 get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed));
239 /* pick up the correct freeze state */
244 editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
245 ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
247 gm.get_gain_slider().signal_scroll_event().connect(mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
248 gm.get_gain_slider().set_name ("TrackGainFader");
251 RouteTimeAxisView::~RouteTimeAxisView ()
253 GoingAway (); /* EMIT_SIGNAL */
255 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
259 delete playlist_menu;
262 delete playlist_action_menu;
263 playlist_action_menu = 0;
268 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
272 _automation_tracks.clear ();
276 RouteTimeAxisView::post_construct ()
278 /* map current state of the route */
280 update_diskstream_display ();
282 subplugin_menu.items().clear ();
283 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
284 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
285 reset_processor_automation_curves ();
289 RouteTimeAxisView::set_playlist (boost::shared_ptr<Playlist> newplaylist)
291 boost::shared_ptr<Playlist> pl = playlist();
294 modified_connection.disconnect ();
295 modified_connection = pl->Modified.connect (mem_fun(*this, &RouteTimeAxisView::playlist_modified));
299 RouteTimeAxisView::playlist_modified ()
304 RouteTimeAxisView::edit_click (GdkEventButton *ev)
306 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
307 _route->set_edit_group (0, this);
311 using namespace Menu_Helpers;
313 MenuList& items = edit_group_menu.items ();
314 RadioMenuItem::Group group;
317 items.push_back (RadioMenuElem (group, _("No group"),
318 bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), (RouteGroup *) 0)));
320 if (_route->edit_group() == 0) {
321 static_cast<RadioMenuItem*>(&items.back())->set_active ();
324 _session.foreach_edit_group (bind (mem_fun (*this, &RouteTimeAxisView::add_edit_group_menu_item), &group));
325 edit_group_menu.popup (ev->button, ev->time);
331 RouteTimeAxisView::add_edit_group_menu_item (RouteGroup *eg, RadioMenuItem::Group* group)
333 using namespace Menu_Helpers;
335 MenuList &items = edit_group_menu.items();
337 items.push_back (RadioMenuElem (*group, eg->name(), bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), eg)));
338 if (_route->edit_group() == eg) {
339 static_cast<RadioMenuItem*>(&items.back())->set_active ();
344 RouteTimeAxisView::set_edit_group_from_menu (RouteGroup *eg)
346 _route->set_edit_group (eg, this);
350 RouteTimeAxisView::playlist_changed ()
356 set_playlist (get_diskstream()->playlist());
361 RouteTimeAxisView::label_view ()
363 string x = _route->name();
365 if (x != name_entry.get_text()) {
366 name_entry.set_text (x);
369 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
373 RouteTimeAxisView::route_name_changed ()
375 editor.route_name_changed (this);
380 RouteTimeAxisView::take_name_changed (void *src)
389 RouteTimeAxisView::playlist_click ()
391 // always build a new action menu
393 delete playlist_action_menu;
395 playlist_action_menu = new Menu;
396 playlist_action_menu->set_name ("ArdourContextMenu");
398 build_playlist_menu (playlist_action_menu);
400 conditionally_add_to_selection ();
401 playlist_action_menu->popup (1, gtk_get_current_event_time());
405 RouteTimeAxisView::automation_click ()
407 if (automation_action_menu == 0) {
408 /* this seems odd, but the automation action
409 menu is built as part of the display menu.
411 build_display_menu ();
413 conditionally_add_to_selection ();
414 automation_action_menu->popup (1, gtk_get_current_event_time());
418 RouteTimeAxisView::set_state (const XMLNode& node)
420 TimeAxisView::set_state (node);
422 XMLNodeList kids = node.children();
423 XMLNodeConstIterator iter;
424 const XMLProperty* prop;
426 for (iter = kids.begin(); iter != kids.end(); ++iter) {
427 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
428 if ((prop = (*iter)->property ("automation-id")) != 0) {
430 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
431 bool show = ((prop = (*iter)->property ("shown")) != 0) && prop->value() == "yes";
432 create_automation_child(param, show);
434 warning << "Automation child has no ID" << endmsg;
443 RouteTimeAxisView::build_automation_action_menu ()
445 using namespace Menu_Helpers;
447 automation_action_menu = manage (new Menu);
448 MenuList& automation_items = automation_action_menu->items();
449 automation_action_menu->set_name ("ArdourContextMenu");
451 automation_items.push_back (MenuElem (_("Show all automation"),
452 mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
454 automation_items.push_back (MenuElem (_("Show existing automation"),
455 mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
457 automation_items.push_back (MenuElem (_("Hide all automation"),
458 mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
460 if (subplugin_menu.get_attach_widget())
461 subplugin_menu.detach();
463 automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
465 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
466 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
468 automation_items.push_back (SeparatorElem());
470 delete i->second->menu_item;
472 automation_items.push_back(CheckMenuElem (_route->describe_parameter(i->second->param),
473 bind (mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
475 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&automation_items.back());
477 i->second->menu_item->set_active(show_automation(i->second->param));
478 //i->second->menu_item->set_active(false);
483 RouteTimeAxisView::build_display_menu ()
485 using namespace Menu_Helpers;
487 /* get the size menu ready */
493 TimeAxisView::build_display_menu ();
495 /* now fill it with our stuff */
497 MenuList& items = display_menu->items();
498 display_menu->set_name ("ArdourContextMenu");
500 items.push_back (MenuElem (_("Height"), *size_menu));
501 items.push_back (MenuElem (_("Color"), mem_fun(*this, &RouteTimeAxisView::select_track_color)));
503 items.push_back (SeparatorElem());
505 if (!Profile->get_sae()) {
506 build_remote_control_menu ();
507 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
508 build_automation_action_menu ();
509 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
510 items.push_back (SeparatorElem());
513 // Hook for derived classes to add type specific stuff
514 append_extra_display_menu_items ();
515 items.push_back (SeparatorElem());
519 Menu *layers_menu = manage(new Menu);
520 MenuList &layers_items = layers_menu->items();
521 layers_menu->set_name("ArdourContextMenu");
523 RadioMenuItem::Group layers_group;
525 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
526 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
527 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
528 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
530 items.push_back (MenuElem (_("Layers"), *layers_menu));
532 Menu* alignment_menu = manage (new Menu);
533 MenuList& alignment_items = alignment_menu->items();
534 alignment_menu->set_name ("ArdourContextMenu");
536 RadioMenuItem::Group align_group;
538 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
539 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
540 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
541 if (get_diskstream()->alignment_style() == ExistingMaterial)
542 align_existing_item->set_active();
544 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
545 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
546 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
547 if (get_diskstream()->alignment_style() == CaptureTime)
548 align_capture_item->set_active();
550 if (!Profile->get_sae()) {
551 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
552 get_diskstream()->AlignmentStyleChanged.connect (mem_fun(*this, &RouteTimeAxisView::align_style_changed));
554 RadioMenuItem::Group mode_group;
555 items.push_back (RadioMenuElem (mode_group, _("Normal mode"),
556 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Normal)));
557 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
558 items.push_back (RadioMenuElem (mode_group, _("Tape mode"),
559 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::Destructive)));
560 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
562 switch (track()->mode()) {
563 case ARDOUR::Destructive:
564 destructive_track_mode_item->set_active ();
567 normal_track_mode_item->set_active ();
571 get_diskstream()->AlignmentStyleChanged.connect (
572 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
574 mode_menu = build_mode_menu();
576 items.push_back (MenuElem (_("Mode"), *mode_menu));
578 items.push_back (SeparatorElem());
582 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
583 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
584 route_active_menu_item->set_active (_route->active());
586 items.push_back (SeparatorElem());
587 items.push_back (MenuElem (_("Hide"), mem_fun(*this, &RouteTimeAxisView::hide_click)));
588 if (!Profile->get_sae()) {
589 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
591 items.push_front (SeparatorElem());
592 items.push_front (MenuElem (_("Delete"), mem_fun(*this, &RouteUI::remove_this_route)));
596 static bool __reset_item (RadioMenuItem* item)
603 RouteTimeAxisView::set_track_mode (TrackMode mode)
606 RadioMenuItem* other_item;
610 item = normal_track_mode_item;
611 other_item = destructive_track_mode_item;
613 case ARDOUR::Destructive:
614 item = destructive_track_mode_item;
615 other_item = normal_track_mode_item;
618 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
623 if (item && other_item && item->get_active () && track()->mode() != mode) {
624 _set_track_mode (track().get(), mode, other_item);
629 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item)
633 if (!track->can_use_mode (mode, needs_bounce)) {
637 Glib::signal_idle().connect (bind (sigc::ptr_fun (__reset_item), reset_item));
640 cerr << "would bounce this one\n";
645 track->set_mode (mode);
647 rec_enable_button->remove ();
650 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
652 case ARDOUR::Destructive:
653 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
656 rec_enable_button->show_all ();
661 RouteTimeAxisView::track_mode_changed ()
665 switch (track()->mode()) {
667 item = normal_track_mode_item;
669 case ARDOUR::Destructive:
670 item = destructive_track_mode_item;
673 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
682 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
688 TimeAxisView::show_timestretch (start, end);
698 /* check that the time selection was made in our route, or our edit group.
699 remember that edit_group() == 0 implies the route is *not* in a edit group.
702 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->edit_group()))) {
703 /* this doesn't apply to us */
707 /* ignore it if our edit group is not active */
709 if ((ts.track != this) && _route->edit_group() && !_route->edit_group()->is_active()) {
714 if (timestretch_rect == 0) {
715 timestretch_rect = new SimpleRect (*canvas_display);
716 timestretch_rect->property_x1() = 0.0;
717 timestretch_rect->property_y1() = 0.0;
718 timestretch_rect->property_x2() = 0.0;
719 timestretch_rect->property_y2() = 0.0;
720 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
721 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
724 timestretch_rect->show ();
725 timestretch_rect->raise_to_top ();
727 x1 = start / editor.get_current_zoom();
728 x2 = (end - 1) / editor.get_current_zoom();
729 y2 = current_height() - 2;
731 timestretch_rect->property_x1() = x1;
732 timestretch_rect->property_y1() = 1.0;
733 timestretch_rect->property_x2() = x2;
734 timestretch_rect->property_y2() = y2;
738 RouteTimeAxisView::hide_timestretch ()
740 TimeAxisView::hide_timestretch ();
742 if (timestretch_rect) {
743 timestretch_rect->hide ();
748 RouteTimeAxisView::show_selection (TimeSelection& ts)
752 /* ignore it if our edit group is not active or if the selection was started
753 in some other track or edit group (remember that edit_group() == 0 means
754 that the track is not in an edit group).
757 if (((ts.track != this && !is_child (ts.track)) && _route->edit_group() && !_route->edit_group()->is_active()) ||
758 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->edit_group())))) {
764 TimeAxisView::show_selection (ts);
768 RouteTimeAxisView::set_height (uint32_t h)
771 bool height_changed = (height == 0) || (h != height);
772 gm.get_level_meter().setup_meters (gmlen);
774 TimeAxisView::set_height (h);
779 _view->set_height ((double) current_height());
783 snprintf (buf, sizeof (buf), "%u", height);
784 xml_node->add_property ("height", buf);
786 if (height >= hNormal) {
791 gm.get_gain_slider().show();
794 if (rec_enable_button)
795 rec_enable_button->show();
797 edit_group_button.show();
799 visual_button.show();
801 automation_button.show();
803 if (is_track() && track()->mode() == ARDOUR::Normal) {
804 playlist_button.show();
807 } else if (height >= hSmaller) {
813 gm.get_gain_slider().hide();
816 if (rec_enable_button)
817 rec_enable_button->show();
819 edit_group_button.hide ();
821 visual_button.hide ();
823 automation_button.hide ();
825 if (is_track() && track()->mode() == ARDOUR::Normal) {
826 playlist_button.hide ();
832 /* don't allow name_entry to be hidden while
833 it has focus, otherwise the GUI becomes unusable.
836 if (name_entry.has_focus()) {
837 if (name_entry.get_text() != _route->name()) {
838 name_entry_changed ();
840 controls_ebox.grab_focus ();
846 gm.get_gain_slider().hide();
849 if (rec_enable_button)
850 rec_enable_button->hide();
852 edit_group_button.hide ();
854 visual_button.hide ();
856 automation_button.hide ();
857 playlist_button.hide ();
858 name_label.set_text (_route->name());
861 if (height_changed) {
862 /* only emit the signal if the height really changed */
863 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
868 RouteTimeAxisView::select_track_color ()
870 if (RouteUI::choose_color ()) {
873 _view->apply_color (_color, StreamView::RegionColor);
879 RouteTimeAxisView::reset_samples_per_unit ()
881 set_samples_per_unit (editor.get_current_zoom());
885 RouteTimeAxisView::set_samples_per_unit (double spu)
889 if (get_diskstream() != 0) {
890 speed = get_diskstream()->speed();
894 _view->set_samples_per_unit (spu * speed);
897 TimeAxisView::set_samples_per_unit (spu * speed);
901 RouteTimeAxisView::align_style_changed ()
903 switch (get_diskstream()->alignment_style()) {
904 case ExistingMaterial:
905 if (!align_existing_item->get_active()) {
906 align_existing_item->set_active();
910 if (!align_capture_item->get_active()) {
911 align_capture_item->set_active();
918 RouteTimeAxisView::set_align_style (AlignStyle style)
923 case ExistingMaterial:
924 item = align_existing_item;
927 item = align_capture_item;
930 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
935 if (item->get_active()) {
936 get_diskstream()->set_align_style (style);
941 RouteTimeAxisView::rename_current_playlist ()
943 ArdourPrompter prompter (true);
946 boost::shared_ptr<Diskstream> ds = get_diskstream();
947 if (!ds || ds->destructive())
950 boost::shared_ptr<Playlist> pl = ds->playlist();
954 prompter.set_prompt (_("Name for playlist"));
955 prompter.set_initial_text (pl->name());
956 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
957 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
959 switch (prompter.run ()) {
960 case Gtk::RESPONSE_ACCEPT:
961 prompter.get_result (name);
973 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
975 std::string ret(basename);
977 std::string group_string = "."+edit_group()->name()+".";
979 // iterate through all playlists
981 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
982 std::string tmp = (*i)->name();
984 std::string::size_type idx = tmp.find(group_string);
985 // find those which belong to this group
986 if (idx != string::npos) {
987 tmp = tmp.substr(idx + group_string.length());
989 // and find the largest current number
990 int x = atoi(tmp.c_str());
1000 snprintf (buf, sizeof(buf), "%d", maxnumber);
1002 ret = this->name()+"."+edit_group()->name()+"."+buf;
1008 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1012 boost::shared_ptr<Diskstream> ds = get_diskstream();
1013 if (!ds || ds->destructive())
1016 boost::shared_ptr<const Playlist> pl = ds->playlist();
1022 if (edit_group() && edit_group()->is_active()) {
1023 name = resolve_new_group_playlist_name(name, playlists_before_op);
1026 while (_session.playlist_by_name(name)) {
1027 name = Playlist::bump_name (name, _session);
1030 // TODO: The prompter "new" button should be de-activated if the user
1031 // specifies a playlist name which already exists in the session.
1035 ArdourPrompter prompter (true);
1037 prompter.set_prompt (_("Name for Playlist"));
1038 prompter.set_initial_text (name);
1039 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1040 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1041 prompter.show_all ();
1043 switch (prompter.run ()) {
1044 case Gtk::RESPONSE_ACCEPT:
1045 prompter.get_result (name);
1053 if (name.length()) {
1054 ds->use_copy_playlist ();
1055 ds->playlist()->set_name (name);
1060 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1064 boost::shared_ptr<Diskstream> ds = get_diskstream();
1065 if (!ds || ds->destructive())
1068 boost::shared_ptr<const Playlist> pl = ds->playlist();
1074 if (edit_group() && edit_group()->is_active()) {
1075 name = resolve_new_group_playlist_name(name,playlists_before_op);
1078 while (_session.playlist_by_name(name)) {
1079 name = Playlist::bump_name (name, _session);
1085 ArdourPrompter prompter (true);
1087 prompter.set_prompt (_("Name for Playlist"));
1088 prompter.set_initial_text (name);
1089 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1090 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1092 switch (prompter.run ()) {
1093 case Gtk::RESPONSE_ACCEPT:
1094 prompter.get_result (name);
1102 if (name.length()) {
1103 ds->use_new_playlist ();
1104 ds->playlist()->set_name (name);
1109 RouteTimeAxisView::clear_playlist ()
1111 boost::shared_ptr<Diskstream> ds = get_diskstream();
1112 if (!ds || ds->destructive())
1115 boost::shared_ptr<Playlist> pl = ds->playlist();
1119 editor.clear_playlist (pl);
1123 RouteTimeAxisView::speed_changed ()
1125 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
1129 RouteTimeAxisView::diskstream_changed ()
1131 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::update_diskstream_display));
1135 RouteTimeAxisView::update_diskstream_display ()
1137 if (!get_diskstream()) // bus
1140 set_playlist (get_diskstream()->playlist());
1145 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1147 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1149 /* special case: select/deselect all tracks */
1150 if (editor.get_selection().selected (this)) {
1151 editor.get_selection().clear_tracks ();
1153 editor.select_all_tracks ();
1159 PublicEditor::TrackViewList* tracks = editor.get_valid_views (this, _route->edit_group());
1161 switch (Keyboard::selection_type (ev->state)) {
1162 case Selection::Toggle:
1163 editor.get_selection().toggle (*tracks);
1166 case Selection::Set:
1167 editor.get_selection().set (*tracks);
1170 case Selection::Extend:
1171 if (tracks->size() > 1) {
1172 /* add each one, do not "extend" */
1173 editor.get_selection().add (*tracks);
1175 /* extend to the single track */
1176 editor.extend_selection_to_track (*tracks->front());
1180 case Selection::Add:
1181 editor.get_selection().add (*tracks);
1189 RouteTimeAxisView::set_selected_points (PointSelection& points)
1191 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1192 (*i)->set_selected_points (points);
1197 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1200 _view->set_selected_regionviews (regions);
1204 /** Add the selectable things that we have to a list.
1205 * @param results List to add things to.
1208 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1212 if (get_diskstream() != 0) {
1213 speed = get_diskstream()->speed();
1216 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1217 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1219 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1220 _view->get_selectables (start_adjusted, end_adjusted, results);
1223 /* pick up visible automation tracks */
1225 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1226 if (!(*i)->hidden()) {
1227 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1233 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1236 _view->get_inverted_selectables (sel, results);
1239 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1240 if (!(*i)->hidden()) {
1241 (*i)->get_inverted_selectables (sel, results);
1249 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1251 return (_show_automation.find(param) != _show_automation.end());
1254 /** Retuns 0 if track for \a param doesn't exist.
1256 RouteTimeAxisView::RouteAutomationNode*
1257 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1259 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1261 if (i != _automation_tracks.end()) {
1268 /** Shorthand for GainAutomation, etc.
1270 RouteTimeAxisView::RouteAutomationNode*
1271 RouteTimeAxisView::automation_track (AutomationType type)
1273 return automation_track (Evoral::Parameter(type));
1277 RouteTimeAxisView::edit_group() const
1279 return _route->edit_group();
1283 RouteTimeAxisView::name() const
1285 return _route->name();
1288 boost::shared_ptr<Playlist>
1289 RouteTimeAxisView::playlist () const
1291 boost::shared_ptr<Diskstream> ds;
1293 if ((ds = get_diskstream()) != 0) {
1294 return ds->playlist();
1296 return boost::shared_ptr<Playlist> ();
1301 RouteTimeAxisView::name_entry_changed ()
1305 x = name_entry.get_text ();
1307 if (x == _route->name()) {
1311 strip_whitespace_edges(x);
1313 if (x.length() == 0) {
1314 name_entry.set_text (_route->name());
1318 if (_session.route_name_unique (x)) {
1319 _route->set_name (x);
1321 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1322 name_entry.set_text (_route->name());
1327 RouteTimeAxisView::visual_click ()
1329 popup_display_menu (0);
1333 RouteTimeAxisView::hide_click ()
1335 // LAME fix for hide_button refresh fix
1336 hide_button.set_sensitive(false);
1338 editor.hide_track_in_display (*this);
1340 hide_button.set_sensitive(true);
1343 boost::shared_ptr<Region>
1344 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1346 boost::shared_ptr<Diskstream> stream;
1347 boost::shared_ptr<Playlist> playlist;
1349 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1350 return playlist->find_next_region (pos, point, dir);
1353 return boost::shared_ptr<Region> ();
1357 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1359 boost::shared_ptr<Diskstream> stream;
1360 boost::shared_ptr<Playlist> playlist;
1362 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1363 return playlist->find_next_region_boundary (pos, dir);
1370 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1372 boost::shared_ptr<Playlist> what_we_got;
1373 boost::shared_ptr<Diskstream> ds = get_diskstream();
1374 boost::shared_ptr<Playlist> playlist;
1378 /* route is a bus, not a track */
1382 playlist = ds->playlist();
1384 TimeSelection time (selection.time);
1385 float speed = ds->speed();
1386 if (speed != 1.0f) {
1387 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1388 (*i).start = session_frame_to_track_frame((*i).start, speed);
1389 (*i).end = session_frame_to_track_frame((*i).end, speed);
1393 XMLNode &before = playlist->get_state();
1396 if ((what_we_got = playlist->cut (time)) != 0) {
1397 editor.get_cut_buffer().add (what_we_got);
1398 _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1403 if ((what_we_got = playlist->copy (time)) != 0) {
1404 editor.get_cut_buffer().add (what_we_got);
1409 if ((what_we_got = playlist->cut (time)) != 0) {
1410 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1411 what_we_got->release ();
1421 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1427 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1428 PlaylistSelection::iterator p;
1430 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth);
1432 if (p == selection.playlists.end()) {
1436 if (get_diskstream()->speed() != 1.0f)
1437 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1439 XMLNode &before = playlist->get_state();
1440 playlist->paste (*p, pos, times);
1441 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1447 TimeAxisView::Children
1448 RouteTimeAxisView::get_child_list()
1450 TimeAxisView::Children redirect_children;
1452 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1453 if (!(*i)->hidden()) {
1454 redirect_children.push_back(*i);
1457 return redirect_children;
1462 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1464 using namespace Menu_Helpers;
1466 if (!menu || !is_track()) {
1470 MenuList& playlist_items = menu->items();
1471 menu->set_name ("ArdourContextMenu");
1472 playlist_items.clear();
1474 delete playlist_menu;
1476 playlist_menu = new Menu;
1477 playlist_menu->set_name ("ArdourContextMenu");
1479 vector<boost::shared_ptr<Playlist> > playlists;
1480 boost::shared_ptr<Diskstream> ds = get_diskstream();
1481 RadioMenuItem::Group playlist_group;
1483 _session.get_playlists (playlists);
1485 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1487 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1488 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1489 boost::weak_ptr<Playlist> (*i))));
1491 if (ds->playlist()->id() == (*i)->id()) {
1492 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1494 } else if (ds->playlist()->id() == (*i)->id()) {
1495 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1496 boost::weak_ptr<Playlist>(*i))));
1497 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1502 playlist_items.push_back (SeparatorElem());
1503 playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1504 playlist_items.push_back (SeparatorElem());
1506 if (!edit_group() || !edit_group()->is_active()) {
1507 playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(editor, &PublicEditor::new_playlists), this)));
1508 playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(editor, &PublicEditor::copy_playlists), this)));
1511 // Use a label which tells the user what is happening
1512 playlist_items.push_back (MenuElem (_("New Take"), bind(mem_fun(editor, &PublicEditor::new_playlists), this)));
1513 playlist_items.push_back (MenuElem (_("Copy Take"), bind(mem_fun(editor, &PublicEditor::copy_playlists), this)));
1517 playlist_items.push_back (SeparatorElem());
1518 playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(editor, &PublicEditor::clear_playlists), this)));
1519 playlist_items.push_back (SeparatorElem());
1521 playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1525 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1527 assert (is_track());
1529 boost::shared_ptr<Playlist> pl (wpl.lock());
1535 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1538 if (get_diskstream()->playlist() == apl) {
1539 // radio button cotnrols mean this function is called for both the
1540 // old and new playlist
1543 get_diskstream()->use_playlist (apl);
1546 if (edit_group() && edit_group()->is_active()) {
1547 //PBD::stacktrace(cerr, 20);
1548 std::string group_string = "."+edit_group()->name()+".";
1550 std::string take_name = apl->name();
1551 std::string::size_type idx = take_name.find(group_string);
1553 if (idx == std::string::npos)
1556 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1558 for (list<Route*>::const_iterator i = edit_group()->route_list().begin(); i != edit_group()->route_list().end(); ++i) {
1559 if ( (*i) == this->route().get()) {
1563 std::string playlist_name = (*i)->name()+group_string+take_name;
1565 Track *track = dynamic_cast<Track *>(*i);
1567 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1571 boost::shared_ptr<Playlist> ipl = session().playlist_by_name(playlist_name);
1573 // No playlist for this track for this take yet, make it
1574 track->diskstream()->use_new_playlist();
1575 track->diskstream()->playlist()->set_name(playlist_name);
1577 track->diskstream()->use_playlist(ipl);
1587 RouteTimeAxisView::show_playlist_selector ()
1589 editor.playlist_selector().show_for (this);
1593 RouteTimeAxisView::map_frozen ()
1599 ENSURE_GUI_THREAD (mem_fun(*this, &RouteTimeAxisView::map_frozen));
1601 switch (track()->freeze_state()) {
1603 playlist_button.set_sensitive (false);
1604 rec_enable_button->set_sensitive (false);
1607 playlist_button.set_sensitive (true);
1608 rec_enable_button->set_sensitive (true);
1614 RouteTimeAxisView::color_handler ()
1616 //case cTimeStretchOutline:
1617 if (timestretch_rect) {
1618 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1620 //case cTimeStretchFill:
1621 if (timestretch_rect) {
1622 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1629 RouteTimeAxisView::toggle_automation_track (Evoral::Parameter param)
1631 RouteAutomationNode* node = automation_track(param);
1636 bool showit = node->menu_item->get_active();
1638 if (showit != node->track->marked_for_display()) {
1640 node->track->set_marked_for_display (true);
1641 node->track->canvas_display->show();
1642 node->track->get_state_node()->add_property ("shown", X_("yes"));
1644 node->track->set_marked_for_display (false);
1645 node->track->hide ();
1646 node->track->get_state_node()->add_property ("shown", X_("no"));
1649 /* now trigger a redisplay */
1652 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1658 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1660 RouteAutomationNode* ran = automation_track(param);
1665 _show_automation.erase(param);
1666 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1668 if (ran->menu_item && !_hidden) {
1669 ran->menu_item->set_active (false);
1672 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1677 RouteTimeAxisView::show_all_automation ()
1681 /* Show our automation */
1683 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1684 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1685 i->second->track->set_marked_for_display (true);
1686 i->second->track->canvas_display->show();
1687 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1688 i->second->menu_item->set_active(true);
1692 /* Show processor automation */
1694 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1695 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1696 if ((*ii)->view == 0) {
1697 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1700 (*ii)->menu_item->set_active (true);
1708 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1712 RouteTimeAxisView::show_existing_automation ()
1716 /* Show our automation */
1718 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1719 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1720 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1721 i->second->track->set_marked_for_display (true);
1722 i->second->track->canvas_display->show();
1723 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1724 i->second->menu_item->set_active(true);
1729 /* Show processor automation */
1731 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1732 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1733 if ((*ii)->view != 0 && (*i)->processor->data().control((*ii)->what)->list()->size() > 0) {
1734 (*ii)->menu_item->set_active (true);
1741 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1745 RouteTimeAxisView::hide_all_automation ()
1749 /* Hide our automation */
1751 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1752 i->second->track->set_marked_for_display (false);
1753 i->second->track->hide ();
1754 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1755 i->second->menu_item->set_active (false);
1758 /* Hide processor automation */
1760 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1761 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1762 (*ii)->menu_item->set_active (false);
1766 _show_automation.clear();
1769 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1774 RouteTimeAxisView::region_view_added (RegionView* rv)
1776 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1777 if(is_audio_track()) {
1778 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1779 boost::shared_ptr<AutomationTimeAxisView> atv;
1781 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1787 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1788 (*i)->add_ghost(rv);
1792 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1794 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1800 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1802 parent.remove_processor_automation_node (this);
1806 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1809 remove_child (pan->view);
1813 RouteTimeAxisView::ProcessorAutomationNode*
1814 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1816 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1818 if ((*i)->processor == processor) {
1820 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1821 if ((*ii)->what == what) {
1832 legalize_for_xml_node (string str)
1834 string::size_type pos;
1835 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1841 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1842 legal.replace (pos, 1, "_");
1851 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1854 ProcessorAutomationNode* pan;
1856 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1857 fatal << _("programming error: ")
1858 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1859 processor->name(), what)
1869 name = processor->describe_parameter (what);
1871 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1875 char state_name[256];
1876 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1878 boost::shared_ptr<AutomationControl> control
1879 = boost::dynamic_pointer_cast<AutomationControl>(processor->data().control(what, true));
1881 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1882 new AutomationTimeAxisView (_session, _route, processor, control,
1883 editor, *this, false, parent_canvas, name, state_name));
1885 pan->view->Hiding.connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1887 if (!pan->view->marked_for_display()) {
1890 pan->menu_item->set_active (true);
1893 add_child (pan->view);
1896 _view->foreach_regionview (mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1899 processor->mark_automation_visible (what, true);
1903 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1906 pan->menu_item->set_active (false);
1909 i->mark_automation_visible (pan->what, false);
1911 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1915 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1917 boost::shared_ptr<Processor> processor (p.lock ());
1922 set<Evoral::Parameter> s;
1923 boost::shared_ptr<AutomationLine> al;
1925 processor->what_has_visible_data (s);
1927 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1929 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1932 add_processor_automation_curve (processor, (*i));
1938 RouteTimeAxisView::add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1940 using namespace Menu_Helpers;
1947 track->Hiding.connect (bind (mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1949 bool hideit = (!show);
1951 if ((node = track->get_state_node()) != 0) {
1952 if ((prop = node->property ("shown")) != 0) {
1953 if (prop->value() == "yes") {
1959 _automation_tracks.insert(std::make_pair(param, new RouteAutomationNode(param, NULL, track)));
1964 _show_automation.insert (param);
1968 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1972 build_display_menu();
1977 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1979 boost::shared_ptr<Processor> processor (p.lock ());
1984 using namespace Menu_Helpers;
1985 ProcessorAutomationInfo *rai;
1986 list<ProcessorAutomationInfo*>::iterator x;
1988 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
1989 std::set<Evoral::Parameter> has_visible_automation;
1991 processor->what_has_visible_data(has_visible_automation);
1993 if (automatable.empty()) {
1997 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
1998 if ((*x)->processor == processor) {
2003 if (x == processor_automation.end()) {
2005 rai = new ProcessorAutomationInfo (processor);
2006 processor_automation.push_back (rai);
2014 /* any older menu was deleted at the top of processors_changed()
2015 when we cleared the subplugin menu.
2018 rai->menu = manage (new Menu);
2019 MenuList& items = rai->menu->items();
2020 rai->menu->set_name ("ArdourContextMenu");
2024 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2026 ProcessorAutomationNode* pan;
2027 CheckMenuItem* mitem;
2029 string name = processor->describe_parameter (*i);
2031 items.push_back (CheckMenuElem (name));
2032 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2034 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2035 mitem->set_active(true);
2038 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2042 pan = new ProcessorAutomationNode (*i, mitem, *this);
2044 rai->lines.push_back (pan);
2048 pan->menu_item = mitem;
2052 mitem->signal_toggled().connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2055 /* add the menu for this processor, because the subplugin
2056 menu is always cleared at the top of processors_changed().
2057 this is the result of some poor design in gtkmm and/or
2061 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2066 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2067 RouteTimeAxisView::ProcessorAutomationNode* pan)
2069 bool showit = pan->menu_item->get_active();
2070 bool redraw = false;
2072 if (pan->view == 0 && showit) {
2073 add_processor_automation_curve (rai->processor, pan->what);
2077 if (pan->view && showit != pan->view->marked_for_display()) {
2080 pan->view->set_marked_for_display (true);
2081 pan->view->canvas_display->show();
2082 pan->view->canvas_background->show();
2084 rai->processor->mark_automation_visible (pan->what, true);
2085 pan->view->set_marked_for_display (false);
2093 if (redraw && !no_redraw) {
2095 /* now trigger a redisplay */
2097 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2103 RouteTimeAxisView::processors_changed ()
2105 using namespace Menu_Helpers;
2107 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2108 (*i)->valid = false;
2111 subplugin_menu.items().clear ();
2113 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2114 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2116 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2118 list<ProcessorAutomationInfo*>::iterator tmp;
2126 processor_automation.erase (i);
2133 /* change in visibility was possible */
2135 _route->gui_changed ("visible_tracks", this);
2138 boost::shared_ptr<AutomationLine>
2139 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2141 ProcessorAutomationNode* pan;
2143 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2149 return boost::shared_ptr<AutomationLine>();
2153 RouteTimeAxisView::reset_processor_automation_curves ()
2155 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2161 RouteTimeAxisView::update_rec_display ()
2163 RouteUI::update_rec_display ();
2164 name_entry.set_sensitive (!_route->record_enabled());
2168 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2170 _view->set_layer_display (d);
2174 boost::shared_ptr<AutomationTimeAxisView>
2175 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2177 AutomationTracks::iterator i = _automation_tracks.find(param);
2178 if (i != _automation_tracks.end())
2179 return i->second->track;
2181 return boost::shared_ptr<AutomationTimeAxisView>();
2185 RouteTimeAxisView::fast_update ()
2187 gm.get_level_meter().update_meters ();
2191 RouteTimeAxisView::hide_meter ()
2194 gm.get_level_meter().hide_meters ();
2198 RouteTimeAxisView::show_meter ()
2204 RouteTimeAxisView::reset_meter ()
2206 if (Config->get_show_track_meters()) {
2207 gm.get_level_meter().setup_meters (height-5);
2214 RouteTimeAxisView::clear_meter ()
2216 gm.get_level_meter().clear_meters ();
2220 RouteTimeAxisView::meter_changed (void *src)
2222 ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::meter_changed), src));
2227 RouteTimeAxisView::io_changed (IOChange change, void *src)
2233 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu) {
2234 using namespace Menu_Helpers;
2236 if(!_underlay_streams.empty()) {
2237 MenuList& parent_items = parent_menu->items();
2238 Menu* gs_menu = manage (new Menu);
2239 gs_menu->set_name ("ArdourContextMenu");
2240 MenuList& gs_items = gs_menu->items();
2242 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2244 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2245 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2246 bind(mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2252 RouteTimeAxisView::set_underlay_state()
2254 if(!underlay_xml_node) {
2258 XMLNodeList nlist = underlay_xml_node->children();
2259 XMLNodeConstIterator niter;
2260 XMLNode *child_node;
2262 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2263 child_node = *niter;
2265 if(child_node->name() != "Underlay") {
2269 XMLProperty* prop = child_node->property ("id");
2271 PBD::ID id(prop->value());
2273 RouteTimeAxisView* v = editor.get_route_view_by_id(id);
2276 add_underlay(v->view(), false);
2285 RouteTimeAxisView::add_underlay(StreamView* v, bool update_xml)
2291 RouteTimeAxisView& other = v->trackview();
2293 if(find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2294 if(find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2295 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2299 _underlay_streams.push_back(v);
2300 other._underlay_mirrors.push_back(this);
2302 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::add_ghost));
2305 if(!underlay_xml_node) {
2307 underlay_xml_node = xml_node->add_child("Underlays");
2310 XMLNode* node = underlay_xml_node->add_child("Underlay");
2311 XMLProperty* prop = node->add_property("id");
2312 prop->set_value(v->trackview().route()->id().to_s());
2318 RouteTimeAxisView::remove_underlay(StreamView* v)
2324 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2325 RouteTimeAxisView& other = v->trackview();
2327 if(it != _underlay_streams.end()) {
2328 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2330 if(gm == other._underlay_mirrors.end()) {
2331 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2335 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2337 _underlay_streams.erase(it);
2338 other._underlay_mirrors.erase(gm);
2340 if(underlay_xml_node) {
2341 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());