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/audioplaylist.h"
44 #include "ardour/diskstream.h"
45 #include "ardour/event_type_map.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/playlist.h"
51 #include "ardour/processor.h"
52 #include "ardour/profile.h"
53 #include "ardour/route_group.h"
54 #include "ardour/session.h"
55 #include "ardour/session_playlist.h"
56 #include "ardour/utils.h"
57 #include "evoral/Parameter.hpp"
59 #include "ardour_ui.h"
60 #include "route_time_axis.h"
61 #include "automation_time_axis.h"
62 #include "canvas_impl.h"
63 #include "crossfade_view.h"
65 #include "gui_thread.h"
67 #include "playlist_selector.h"
68 #include "point_selection.h"
70 #include "public_editor.h"
71 #include "region_view.h"
72 #include "rgb_macros.h"
73 #include "selection.h"
74 #include "simplerect.h"
75 #include "streamview.h"
78 #include "ardour/track.h"
82 using namespace ARDOUR;
84 using namespace Gtkmm2ext;
86 using namespace Editing;
90 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
93 RouteTimeAxisView::setup_slider_pix ()
95 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
96 throw failed_constructor ();
100 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
102 RouteUI(rt, sess, _("m"), _("s"), _("r")), // mute, solo, and record
103 TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas),
104 parent_canvas (canvas),
106 edit_group_button (_("g")), // group
107 playlist_button (_("p")),
108 size_button (_("h")), // height
109 automation_button (_("a")),
110 visual_button (_("v")),
111 gm (sess, slider, true)
114 gm.get_level_meter().set_no_show_all();
115 gm.get_level_meter().setup_meters(50);
119 playlist_action_menu = 0;
120 automation_action_menu = 0;
123 if (!_route->is_hidden()) {
124 _marked_for_display = true;
127 timestretch_rect = 0;
129 destructive_track_mode_item = 0;
130 normal_track_mode_item = 0;
131 non_layered_track_mode_item = 0;
133 ignore_toggle = false;
135 edit_group_button.set_name ("TrackGroupButton");
136 playlist_button.set_name ("TrackPlaylistButton");
137 automation_button.set_name ("TrackAutomationButton");
138 size_button.set_name ("TrackSizeButton");
139 visual_button.set_name ("TrackVisualButton");
140 hide_button.set_name ("TrackRemoveButton");
142 edit_group_button.unset_flags (Gtk::CAN_FOCUS);
143 playlist_button.unset_flags (Gtk::CAN_FOCUS);
144 automation_button.unset_flags (Gtk::CAN_FOCUS);
145 size_button.unset_flags (Gtk::CAN_FOCUS);
146 visual_button.unset_flags (Gtk::CAN_FOCUS);
147 hide_button.unset_flags (Gtk::CAN_FOCUS);
149 hide_button.add (*(manage (new Image (::get_icon("hide")))));
150 hide_button.show_all ();
152 edit_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
153 playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
154 automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
155 size_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::size_click), false);
156 visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click));
157 hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click));
159 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
160 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
161 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
162 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
168 rec_enable_button->remove ();
170 switch (track()->mode()) {
172 case ARDOUR::NonLayered:
173 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
175 case ARDOUR::Destructive:
176 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
179 rec_enable_button->show_all ();
181 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
182 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
183 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
184 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
188 controls_hbox.pack_start(gm.get_level_meter(), false, false);
189 _route->meter_change.connect (mem_fun(*this, &RouteTimeAxisView::meter_changed));
190 _route->input_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
191 _route->output_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
193 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
194 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
196 controls_table.attach (edit_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
197 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
199 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
200 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
201 ARDOUR_UI::instance()->tooltips().set_tip(edit_group_button,_("Edit Group"));
202 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
203 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
204 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
205 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
206 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
212 /* old school - when we used to put an extra row of buttons in place */
214 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
215 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
216 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
217 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
221 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
224 if (is_track() && track()->mode() == ARDOUR::Normal) {
225 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
230 _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
231 _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
232 _route->processors_changed.connect (mem_fun(*this, &RouteTimeAxisView::processors_changed));
233 _route->NameChanged.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
234 _route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
239 track()->TrackModeChanged.connect (mem_fun(*this, &RouteTimeAxisView::track_mode_changed));
240 track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
241 track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
242 get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed));
244 /* pick up the correct freeze state */
249 _editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
250 ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
252 gm.get_gain_slider().signal_scroll_event().connect(mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
253 gm.get_gain_slider().set_name ("TrackGainFader");
256 RouteTimeAxisView::~RouteTimeAxisView ()
258 GoingAway (); /* EMIT_SIGNAL */
260 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
264 delete playlist_menu;
267 delete playlist_action_menu;
268 playlist_action_menu = 0;
273 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
277 _automation_tracks.clear ();
281 RouteTimeAxisView::post_construct ()
283 /* map current state of the route */
285 update_diskstream_display ();
287 subplugin_menu.items().clear ();
288 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
289 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
290 reset_processor_automation_curves ();
294 RouteTimeAxisView::set_playlist (boost::shared_ptr<Playlist> newplaylist)
296 boost::shared_ptr<Playlist> pl = playlist();
299 modified_connection.disconnect ();
300 modified_connection = pl->Modified.connect (mem_fun(*this, &RouteTimeAxisView::playlist_modified));
304 RouteTimeAxisView::playlist_modified ()
309 RouteTimeAxisView::edit_click (GdkEventButton *ev)
311 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
312 _route->set_edit_group (0, this);
316 using namespace Menu_Helpers;
318 MenuList& items = edit_group_menu.items ();
319 RadioMenuItem::Group group;
322 items.push_back (RadioMenuElem (group, _("No group"),
323 bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), (RouteGroup *) 0)));
325 if (_route->edit_group() == 0) {
326 static_cast<RadioMenuItem*>(&items.back())->set_active ();
329 _session.foreach_edit_group (bind (mem_fun (*this, &RouteTimeAxisView::add_edit_group_menu_item), &group));
330 edit_group_menu.popup (ev->button, ev->time);
336 RouteTimeAxisView::add_edit_group_menu_item (RouteGroup *eg, RadioMenuItem::Group* group)
338 using namespace Menu_Helpers;
340 MenuList &items = edit_group_menu.items();
342 items.push_back (RadioMenuElem (*group, eg->name(), bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), eg)));
343 if (_route->edit_group() == eg) {
344 static_cast<RadioMenuItem*>(&items.back())->set_active ();
349 RouteTimeAxisView::set_edit_group_from_menu (RouteGroup *eg)
351 _route->set_edit_group (eg, this);
355 RouteTimeAxisView::playlist_changed ()
360 set_playlist (get_diskstream()->playlist());
365 RouteTimeAxisView::label_view ()
367 string x = _route->name();
369 if (x != name_entry.get_text()) {
370 name_entry.set_text (x);
373 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
377 RouteTimeAxisView::route_name_changed ()
379 _editor.route_name_changed (this);
384 RouteTimeAxisView::take_name_changed (void *src)
393 RouteTimeAxisView::playlist_click ()
395 // always build a new action menu
397 delete playlist_action_menu;
399 playlist_action_menu = new Menu;
400 playlist_action_menu->set_name ("ArdourContextMenu");
402 build_playlist_menu (playlist_action_menu);
404 conditionally_add_to_selection ();
405 playlist_action_menu->popup (1, gtk_get_current_event_time());
409 RouteTimeAxisView::automation_click ()
411 conditionally_add_to_selection ();
412 build_automation_action_menu ();
413 automation_action_menu->popup (1, gtk_get_current_event_time());
417 RouteTimeAxisView::set_state (const XMLNode& node)
419 TimeAxisView::set_state (node);
421 XMLNodeList kids = node.children();
422 XMLNodeConstIterator iter;
423 const XMLProperty* prop;
425 for (iter = kids.begin(); iter != kids.end(); ++iter) {
426 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
427 if ((prop = (*iter)->property ("automation-id")) != 0) {
429 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
430 bool show = ((prop = (*iter)->property ("shown")) != 0) && prop->value() == "yes";
431 create_automation_child(param, show);
433 warning << "Automation child has no ID" << endmsg;
442 RouteTimeAxisView::build_automation_action_menu ()
444 using namespace Menu_Helpers;
446 automation_action_menu = manage (new Menu);
447 MenuList& automation_items = automation_action_menu->items();
448 automation_action_menu->set_name ("ArdourContextMenu");
450 automation_items.push_back (MenuElem (_("Show all automation"),
451 mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
453 automation_items.push_back (MenuElem (_("Show existing automation"),
454 mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
456 automation_items.push_back (MenuElem (_("Hide all automation"),
457 mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
459 if (subplugin_menu.get_attach_widget())
460 subplugin_menu.detach();
462 automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
464 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
465 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
467 automation_items.push_back (SeparatorElem());
469 delete i->second->menu_item;
471 automation_items.push_back(CheckMenuElem (_route->describe_parameter(i->second->param),
472 bind (mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
474 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&automation_items.back());
476 i->second->menu_item->set_active(show_automation(i->second->param));
477 //i->second->menu_item->set_active(false);
482 RouteTimeAxisView::build_display_menu ()
484 using namespace Menu_Helpers;
486 /* get the size menu ready */
492 TimeAxisView::build_display_menu ();
494 /* now fill it with our stuff */
496 MenuList& items = display_menu->items();
497 display_menu->set_name ("ArdourContextMenu");
499 items.push_back (MenuElem (_("Height"), *size_menu));
500 items.push_back (MenuElem (_("Color"), mem_fun(*this, &RouteTimeAxisView::select_track_color)));
502 items.push_back (SeparatorElem());
504 if (!Profile->get_sae()) {
505 build_remote_control_menu ();
506 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
507 /* rebuild this every time */
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 (
553 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
555 RadioMenuItem::Group mode_group;
556 items.push_back (RadioMenuElem (mode_group, _("Normal mode"), bind (
557 mem_fun (*this, &RouteTimeAxisView::set_track_mode),
559 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
561 items.push_back (RadioMenuElem (mode_group, _("Tape mode"), bind (
562 mem_fun (*this, &RouteTimeAxisView::set_track_mode),
563 ARDOUR::Destructive)));
564 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
566 items.push_back (RadioMenuElem (mode_group, _("No layering mode"),
567 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
568 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
572 switch (track()->mode()) {
573 case ARDOUR::Destructive:
574 destructive_track_mode_item->set_active ();
577 normal_track_mode_item->set_active ();
579 case ARDOUR::NonLayered:
580 non_layered_track_mode_item->set_active ();
585 get_diskstream()->AlignmentStyleChanged.connect (
586 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
588 mode_menu = build_mode_menu();
590 items.push_back (MenuElem (_("Mode"), *mode_menu));
592 color_mode_menu = build_color_mode_menu();
594 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
596 items.push_back (SeparatorElem());
599 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
600 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
601 route_active_menu_item->set_active (_route->active());
603 items.push_back (SeparatorElem());
604 items.push_back (MenuElem (_("Hide"), mem_fun(*this, &RouteTimeAxisView::hide_click)));
605 if (!Profile->get_sae()) {
606 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
608 items.push_front (SeparatorElem());
609 items.push_front (MenuElem (_("Delete"), mem_fun(*this, &RouteUI::remove_this_route)));
613 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
616 item_2->set_active ();
621 RouteTimeAxisView::set_track_mode (TrackMode mode)
624 RadioMenuItem* other_item;
625 RadioMenuItem* other_item_2;
629 item = normal_track_mode_item;
630 other_item = non_layered_track_mode_item;
631 other_item_2 = destructive_track_mode_item;
633 case ARDOUR::NonLayered:
634 item = non_layered_track_mode_item;
635 other_item = normal_track_mode_item;
636 other_item_2 = destructive_track_mode_item;
638 case ARDOUR::Destructive:
639 item = destructive_track_mode_item;
640 other_item = normal_track_mode_item;
641 other_item_2 = non_layered_track_mode_item;
644 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
649 if (item && other_item && other_item_2 && item->get_active() && track()->mode() != mode) {
650 _set_track_mode (track().get(), mode, other_item, other_item_2);
655 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
659 if (!track->can_use_mode (mode, needs_bounce)) {
663 Glib::signal_idle().connect (bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
666 cerr << "would bounce this one\n";
671 track->set_mode (mode);
673 rec_enable_button->remove ();
676 case ARDOUR::NonLayered:
678 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
680 case ARDOUR::Destructive:
681 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
685 rec_enable_button->show_all ();
689 RouteTimeAxisView::track_mode_changed ()
693 switch (track()->mode()) {
695 item = normal_track_mode_item;
697 case ARDOUR::NonLayered:
698 item = non_layered_track_mode_item;
700 case ARDOUR::Destructive:
701 item = destructive_track_mode_item;
704 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
713 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
719 TimeAxisView::show_timestretch (start, end);
729 /* check that the time selection was made in our route, or our edit group.
730 remember that edit_group() == 0 implies the route is *not* in a edit group.
733 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->edit_group()))) {
734 /* this doesn't apply to us */
738 /* ignore it if our edit group is not active */
740 if ((ts.track != this) && _route->edit_group() && !_route->edit_group()->is_active()) {
745 if (timestretch_rect == 0) {
746 timestretch_rect = new SimpleRect (*canvas_display ());
747 timestretch_rect->property_x1() = 0.0;
748 timestretch_rect->property_y1() = 0.0;
749 timestretch_rect->property_x2() = 0.0;
750 timestretch_rect->property_y2() = 0.0;
751 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
752 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
755 timestretch_rect->show ();
756 timestretch_rect->raise_to_top ();
758 x1 = start / _editor.get_current_zoom();
759 x2 = (end - 1) / _editor.get_current_zoom();
760 y2 = current_height() - 2;
762 timestretch_rect->property_x1() = x1;
763 timestretch_rect->property_y1() = 1.0;
764 timestretch_rect->property_x2() = x2;
765 timestretch_rect->property_y2() = y2;
769 RouteTimeAxisView::hide_timestretch ()
771 TimeAxisView::hide_timestretch ();
773 if (timestretch_rect) {
774 timestretch_rect->hide ();
779 RouteTimeAxisView::show_selection (TimeSelection& ts)
783 /* ignore it if our edit group is not active or if the selection was started
784 in some other track or edit group (remember that edit_group() == 0 means
785 that the track is not in an edit group).
788 if (((ts.track != this && !is_child (ts.track)) && _route->edit_group() && !_route->edit_group()->is_active()) ||
789 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->edit_group())))) {
795 TimeAxisView::show_selection (ts);
799 RouteTimeAxisView::set_height (uint32_t h)
802 bool height_changed = (height == 0) || (h != height);
803 gm.get_level_meter().setup_meters (gmlen);
805 TimeAxisView::set_height (h);
810 _view->set_height ((double) current_height());
814 snprintf (buf, sizeof (buf), "%u", height);
815 xml_node->add_property ("height", buf);
817 if (height >= hNormal) {
822 gm.get_gain_slider().show();
825 if (rec_enable_button)
826 rec_enable_button->show();
828 edit_group_button.show();
830 visual_button.show();
832 automation_button.show();
834 if (is_track() && track()->mode() == ARDOUR::Normal) {
835 playlist_button.show();
838 } else if (height >= hSmaller) {
844 gm.get_gain_slider().hide();
847 if (rec_enable_button)
848 rec_enable_button->show();
850 edit_group_button.hide ();
852 visual_button.hide ();
854 automation_button.hide ();
856 if (is_track() && track()->mode() == ARDOUR::Normal) {
857 playlist_button.hide ();
863 /* don't allow name_entry to be hidden while
864 it has focus, otherwise the GUI becomes unusable.
867 if (name_entry.has_focus()) {
868 if (name_entry.get_text() != _route->name()) {
869 name_entry_changed ();
871 controls_ebox.grab_focus ();
877 gm.get_gain_slider().hide();
880 if (rec_enable_button)
881 rec_enable_button->hide();
883 edit_group_button.hide ();
885 visual_button.hide ();
887 automation_button.hide ();
888 playlist_button.hide ();
889 name_label.set_text (_route->name());
892 if (height_changed) {
893 /* only emit the signal if the height really changed */
894 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
899 RouteTimeAxisView::select_track_color ()
901 if (RouteUI::choose_color ()) {
904 _view->apply_color (_color, StreamView::RegionColor);
910 RouteTimeAxisView::reset_samples_per_unit ()
912 set_samples_per_unit (_editor.get_current_zoom());
916 RouteTimeAxisView::set_samples_per_unit (double spu)
920 if (get_diskstream() != 0) {
921 speed = get_diskstream()->speed();
925 _view->set_samples_per_unit (spu * speed);
928 TimeAxisView::set_samples_per_unit (spu * speed);
932 RouteTimeAxisView::align_style_changed ()
934 switch (get_diskstream()->alignment_style()) {
935 case ExistingMaterial:
936 if (!align_existing_item->get_active()) {
937 align_existing_item->set_active();
941 if (!align_capture_item->get_active()) {
942 align_capture_item->set_active();
949 RouteTimeAxisView::set_align_style (AlignStyle style)
954 case ExistingMaterial:
955 item = align_existing_item;
958 item = align_capture_item;
961 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
966 if (item->get_active()) {
967 get_diskstream()->set_align_style (style);
972 RouteTimeAxisView::rename_current_playlist ()
974 ArdourPrompter prompter (true);
977 boost::shared_ptr<Diskstream> ds = get_diskstream();
978 if (!ds || ds->destructive())
981 boost::shared_ptr<Playlist> pl = ds->playlist();
985 prompter.set_prompt (_("Name for playlist"));
986 prompter.set_initial_text (pl->name());
987 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
988 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
990 switch (prompter.run ()) {
991 case Gtk::RESPONSE_ACCEPT:
992 prompter.get_result (name);
1004 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
1006 std::string ret(basename);
1008 std::string group_string = "."+edit_group()->name()+".";
1010 // iterate through all playlists
1012 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
1013 std::string tmp = (*i)->name();
1015 std::string::size_type idx = tmp.find(group_string);
1016 // find those which belong to this group
1017 if (idx != string::npos) {
1018 tmp = tmp.substr(idx + group_string.length());
1020 // and find the largest current number
1021 int x = atoi(tmp.c_str());
1022 if (x > maxnumber) {
1031 snprintf (buf, sizeof(buf), "%d", maxnumber);
1033 ret = this->name()+"."+edit_group()->name()+"."+buf;
1039 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1043 boost::shared_ptr<Diskstream> ds = get_diskstream();
1044 if (!ds || ds->destructive())
1047 boost::shared_ptr<const Playlist> pl = ds->playlist();
1053 if (edit_group() && edit_group()->is_active()) {
1054 name = resolve_new_group_playlist_name(name, playlists_before_op);
1057 while (_session.playlist_by_name(name)) {
1058 name = Playlist::bump_name (name, _session);
1061 // TODO: The prompter "new" button should be de-activated if the user
1062 // specifies a playlist name which already exists in the session.
1066 ArdourPrompter prompter (true);
1068 prompter.set_prompt (_("Name for Playlist"));
1069 prompter.set_initial_text (name);
1070 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1071 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1072 prompter.show_all ();
1074 switch (prompter.run ()) {
1075 case Gtk::RESPONSE_ACCEPT:
1076 prompter.get_result (name);
1084 if (name.length()) {
1085 ds->use_copy_playlist ();
1086 ds->playlist()->set_name (name);
1091 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1095 boost::shared_ptr<Diskstream> ds = get_diskstream();
1096 if (!ds || ds->destructive())
1099 boost::shared_ptr<const Playlist> pl = ds->playlist();
1105 if (edit_group() && edit_group()->is_active()) {
1106 name = resolve_new_group_playlist_name(name,playlists_before_op);
1109 while (_session.playlist_by_name(name)) {
1110 name = Playlist::bump_name (name, _session);
1116 ArdourPrompter prompter (true);
1118 prompter.set_prompt (_("Name for Playlist"));
1119 prompter.set_initial_text (name);
1120 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1121 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1123 switch (prompter.run ()) {
1124 case Gtk::RESPONSE_ACCEPT:
1125 prompter.get_result (name);
1133 if (name.length()) {
1134 ds->use_new_playlist ();
1135 ds->playlist()->set_name (name);
1140 RouteTimeAxisView::clear_playlist ()
1142 boost::shared_ptr<Diskstream> ds = get_diskstream();
1143 if (!ds || ds->destructive())
1146 boost::shared_ptr<Playlist> pl = ds->playlist();
1150 _editor.clear_playlist (pl);
1154 RouteTimeAxisView::speed_changed ()
1156 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
1160 RouteTimeAxisView::diskstream_changed ()
1162 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::update_diskstream_display));
1166 RouteTimeAxisView::update_diskstream_display ()
1168 if (!get_diskstream()) // bus
1171 set_playlist (get_diskstream()->playlist());
1176 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1178 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1180 /* special case: select/deselect all tracks */
1181 if (_editor.get_selection().selected (this)) {
1182 _editor.get_selection().clear_tracks ();
1184 _editor.select_all_tracks ();
1190 PublicEditor::TrackViewList* tracks = _editor.get_valid_views (this, _route->edit_group());
1192 switch (Keyboard::selection_type (ev->state)) {
1193 case Selection::Toggle:
1194 _editor.get_selection().toggle (*tracks);
1197 case Selection::Set:
1198 _editor.get_selection().set (*tracks);
1201 case Selection::Extend:
1202 if (tracks->size() > 1) {
1203 /* add each one, do not "extend" */
1204 _editor.get_selection().add (*tracks);
1206 /* extend to the single track */
1207 _editor.extend_selection_to_track (*tracks->front());
1211 case Selection::Add:
1212 _editor.get_selection().add (*tracks);
1220 RouteTimeAxisView::set_selected_points (PointSelection& points)
1222 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1223 (*i)->set_selected_points (points);
1228 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1231 _view->set_selected_regionviews (regions);
1235 /** Add the selectable things that we have to a list.
1236 * @param results List to add things to.
1239 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1243 if (get_diskstream() != 0) {
1244 speed = get_diskstream()->speed();
1247 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1248 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1250 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1251 _view->get_selectables (start_adjusted, end_adjusted, results);
1254 /* pick up visible automation tracks */
1256 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1257 if (!(*i)->hidden()) {
1258 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1264 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1267 _view->get_inverted_selectables (sel, results);
1270 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1271 if (!(*i)->hidden()) {
1272 (*i)->get_inverted_selectables (sel, results);
1280 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1282 return (_show_automation.find(param) != _show_automation.end());
1285 /** Retuns 0 if track for \a param doesn't exist.
1287 RouteTimeAxisView::RouteAutomationNode*
1288 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1290 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1292 if (i != _automation_tracks.end()) {
1299 /** Shorthand for GainAutomation, etc.
1301 RouteTimeAxisView::RouteAutomationNode*
1302 RouteTimeAxisView::automation_track (AutomationType type)
1304 return automation_track (Evoral::Parameter(type));
1308 RouteTimeAxisView::edit_group() const
1310 return _route->edit_group();
1314 RouteTimeAxisView::name() const
1316 return _route->name();
1319 boost::shared_ptr<Playlist>
1320 RouteTimeAxisView::playlist () const
1322 boost::shared_ptr<Diskstream> ds;
1324 if ((ds = get_diskstream()) != 0) {
1325 return ds->playlist();
1327 return boost::shared_ptr<Playlist> ();
1332 RouteTimeAxisView::name_entry_changed ()
1336 x = name_entry.get_text ();
1338 if (x == _route->name()) {
1342 strip_whitespace_edges(x);
1344 if (x.length() == 0) {
1345 name_entry.set_text (_route->name());
1349 if (!_session.route_name_unique (x)) {
1350 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1351 name_entry.set_text (_route->name());
1352 } else if (_session.route_name_internal (x)) {
1353 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1354 name_entry.set_text (_route->name());
1356 _route->set_name (x);
1361 RouteTimeAxisView::visual_click ()
1363 popup_display_menu (0);
1367 RouteTimeAxisView::hide_click ()
1369 // LAME fix for hide_button refresh fix
1370 hide_button.set_sensitive(false);
1372 _editor.hide_track_in_display (*this);
1374 hide_button.set_sensitive(true);
1377 boost::shared_ptr<Region>
1378 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1380 boost::shared_ptr<Diskstream> stream;
1381 boost::shared_ptr<Playlist> playlist;
1383 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1384 return playlist->find_next_region (pos, point, dir);
1387 return boost::shared_ptr<Region> ();
1391 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1393 boost::shared_ptr<Diskstream> stream;
1394 boost::shared_ptr<Playlist> playlist;
1396 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1397 return playlist->find_next_region_boundary (pos, dir);
1404 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1406 boost::shared_ptr<Playlist> what_we_got;
1407 boost::shared_ptr<Diskstream> ds = get_diskstream();
1408 boost::shared_ptr<Playlist> playlist;
1412 /* route is a bus, not a track */
1416 playlist = ds->playlist();
1418 TimeSelection time (selection.time);
1419 float speed = ds->speed();
1420 if (speed != 1.0f) {
1421 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1422 (*i).start = session_frame_to_track_frame((*i).start, speed);
1423 (*i).end = session_frame_to_track_frame((*i).end, speed);
1427 XMLNode &before = playlist->get_state();
1430 if ((what_we_got = playlist->cut (time)) != 0) {
1431 _editor.get_cut_buffer().add (what_we_got);
1432 _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1437 if ((what_we_got = playlist->copy (time)) != 0) {
1438 _editor.get_cut_buffer().add (what_we_got);
1443 if ((what_we_got = playlist->cut (time)) != 0) {
1444 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1445 what_we_got->release ();
1455 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1461 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1462 PlaylistSelection::iterator p;
1464 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1466 if (p == selection.playlists.end()) {
1470 if (get_diskstream()->speed() != 1.0f)
1471 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1473 XMLNode &before = playlist->get_state();
1474 playlist->paste (*p, pos, times);
1475 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1481 TimeAxisView::Children
1482 RouteTimeAxisView::get_child_list()
1484 TimeAxisView::Children redirect_children;
1486 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1487 if (!(*i)->hidden()) {
1488 redirect_children.push_back(*i);
1491 return redirect_children;
1496 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1498 using namespace Menu_Helpers;
1500 if (!menu || !is_track()) {
1504 MenuList& playlist_items = menu->items();
1505 menu->set_name ("ArdourContextMenu");
1506 playlist_items.clear();
1508 delete playlist_menu;
1510 playlist_menu = new Menu;
1511 playlist_menu->set_name ("ArdourContextMenu");
1513 vector<boost::shared_ptr<Playlist> > playlists;
1514 boost::shared_ptr<Diskstream> ds = get_diskstream();
1515 RadioMenuItem::Group playlist_group;
1517 _session.get_playlists (playlists);
1519 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1521 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1522 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1523 boost::weak_ptr<Playlist> (*i))));
1525 if (ds->playlist()->id() == (*i)->id()) {
1526 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1528 } else if (ds->playlist()->id() == (*i)->id()) {
1529 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1530 boost::weak_ptr<Playlist>(*i))));
1531 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1536 playlist_items.push_back (SeparatorElem());
1537 playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1538 playlist_items.push_back (SeparatorElem());
1540 if (!edit_group() || !edit_group()->is_active()) {
1541 playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
1542 playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1545 // Use a label which tells the user what is happening
1546 playlist_items.push_back (MenuElem (_("New Take"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
1547 playlist_items.push_back (MenuElem (_("Copy Take"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1551 playlist_items.push_back (SeparatorElem());
1552 playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1553 playlist_items.push_back (SeparatorElem());
1555 playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1559 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1561 assert (is_track());
1563 boost::shared_ptr<Playlist> pl (wpl.lock());
1569 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1572 if (get_diskstream()->playlist() == apl) {
1573 // radio button cotnrols mean this function is called for both the
1574 // old and new playlist
1577 get_diskstream()->use_playlist (apl);
1580 if (edit_group() && edit_group()->is_active()) {
1581 //PBD::stacktrace(cerr, 20);
1582 std::string group_string = "."+edit_group()->name()+".";
1584 std::string take_name = apl->name();
1585 std::string::size_type idx = take_name.find(group_string);
1587 if (idx == std::string::npos)
1590 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1592 for (list<Route*>::const_iterator i = edit_group()->route_list().begin(); i != edit_group()->route_list().end(); ++i) {
1593 if ( (*i) == this->route().get()) {
1597 std::string playlist_name = (*i)->name()+group_string+take_name;
1599 Track *track = dynamic_cast<Track *>(*i);
1601 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1605 boost::shared_ptr<Playlist> ipl = session().playlist_by_name(playlist_name);
1607 // No playlist for this track for this take yet, make it
1608 track->diskstream()->use_new_playlist();
1609 track->diskstream()->playlist()->set_name(playlist_name);
1611 track->diskstream()->use_playlist(ipl);
1621 RouteTimeAxisView::show_playlist_selector ()
1623 _editor.playlist_selector().show_for (this);
1627 RouteTimeAxisView::map_frozen ()
1633 ENSURE_GUI_THREAD (mem_fun(*this, &RouteTimeAxisView::map_frozen));
1635 switch (track()->freeze_state()) {
1637 playlist_button.set_sensitive (false);
1638 rec_enable_button->set_sensitive (false);
1641 playlist_button.set_sensitive (true);
1642 rec_enable_button->set_sensitive (true);
1648 RouteTimeAxisView::color_handler ()
1650 //case cTimeStretchOutline:
1651 if (timestretch_rect) {
1652 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1654 //case cTimeStretchFill:
1655 if (timestretch_rect) {
1656 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1663 RouteTimeAxisView::toggle_automation_track (Evoral::Parameter param)
1665 RouteAutomationNode* node = automation_track(param);
1670 bool showit = node->menu_item->get_active();
1672 if (showit != node->track->marked_for_display()) {
1674 node->track->set_marked_for_display (true);
1675 node->track->canvas_display()->show();
1676 node->track->get_state_node()->add_property ("shown", X_("yes"));
1678 node->track->set_marked_for_display (false);
1679 node->track->hide ();
1680 node->track->get_state_node()->add_property ("shown", X_("no"));
1683 /* now trigger a redisplay */
1686 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1692 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1694 RouteAutomationNode* ran = automation_track(param);
1699 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1700 _show_automation.erase(param);
1701 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1703 if (ran->menu_item && !_hidden) {
1704 ran->menu_item->set_active (false);
1707 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1712 RouteTimeAxisView::show_all_automation ()
1716 /* Show our automation */
1718 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1719 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1720 i->second->track->set_marked_for_display (true);
1721 i->second->track->canvas_display()->show();
1722 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1723 i->second->menu_item->set_active(true);
1727 /* Show processor automation */
1729 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1730 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1731 if ((*ii)->view == 0) {
1732 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1735 (*ii)->menu_item->set_active (true);
1743 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1747 RouteTimeAxisView::show_existing_automation ()
1751 /* Show our automation */
1753 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1754 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1755 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1756 i->second->track->set_marked_for_display (true);
1757 i->second->track->canvas_display()->show();
1758 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1759 i->second->menu_item->set_active(true);
1764 /* Show processor automation */
1766 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1767 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1768 if ((*ii)->view != 0 && (*i)->processor->data().control((*ii)->what)->list()->size() > 0) {
1769 (*ii)->menu_item->set_active (true);
1776 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1780 RouteTimeAxisView::hide_all_automation ()
1784 /* Hide our automation */
1786 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1787 i->second->track->set_marked_for_display (false);
1788 i->second->track->hide ();
1789 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1790 i->second->menu_item->set_active (false);
1793 /* Hide processor automation */
1795 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1796 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1797 (*ii)->menu_item->set_active (false);
1801 _show_automation.clear();
1804 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1809 RouteTimeAxisView::region_view_added (RegionView* rv)
1811 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1812 if(is_audio_track()) {
1813 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1814 boost::shared_ptr<AutomationTimeAxisView> atv;
1816 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1822 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1823 (*i)->add_ghost(rv);
1827 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1829 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1835 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1837 parent.remove_processor_automation_node (this);
1841 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1844 remove_child (pan->view);
1848 RouteTimeAxisView::ProcessorAutomationNode*
1849 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1851 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1853 if ((*i)->processor == processor) {
1855 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1856 if ((*ii)->what == what) {
1867 legalize_for_xml_node (string str)
1869 string::size_type pos;
1870 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1876 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1877 legal.replace (pos, 1, "_");
1886 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1889 ProcessorAutomationNode* pan;
1891 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1892 fatal << _("programming error: ")
1893 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1894 processor->name(), what)
1904 name = processor->describe_parameter (what);
1906 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1910 char state_name[256];
1911 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1913 boost::shared_ptr<AutomationControl> control
1914 = boost::dynamic_pointer_cast<AutomationControl>(processor->data().control(what, true));
1916 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1917 new AutomationTimeAxisView (_session, _route, processor, control,
1918 _editor, *this, false, parent_canvas, name, state_name));
1920 pan->view->Hiding.connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1922 if (!pan->view->marked_for_display()) {
1925 pan->menu_item->set_active (true);
1928 add_child (pan->view);
1931 _view->foreach_regionview (mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1934 processor->mark_automation_visible (what, true);
1938 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1941 pan->menu_item->set_active (false);
1944 i->mark_automation_visible (pan->what, false);
1946 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1950 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1952 boost::shared_ptr<Processor> processor (p.lock ());
1957 set<Evoral::Parameter> s;
1958 boost::shared_ptr<AutomationLine> al;
1960 processor->what_has_visible_data (s);
1962 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1964 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1967 add_processor_automation_curve (processor, (*i));
1973 RouteTimeAxisView::add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1975 using namespace Menu_Helpers;
1982 track->Hiding.connect (bind (mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1984 bool hideit = (!show);
1986 if ((node = track->get_state_node()) != 0) {
1987 if ((prop = node->property ("shown")) != 0) {
1988 if (prop->value() == "yes") {
1994 _automation_tracks.insert(std::make_pair(param, new RouteAutomationNode(param, NULL, track)));
1999 _show_automation.insert (param);
2003 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2007 build_display_menu();
2012 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
2014 boost::shared_ptr<Processor> processor (p.lock ());
2019 using namespace Menu_Helpers;
2020 ProcessorAutomationInfo *rai;
2021 list<ProcessorAutomationInfo*>::iterator x;
2023 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2024 std::set<Evoral::Parameter> has_visible_automation;
2026 processor->what_has_visible_data(has_visible_automation);
2028 if (automatable.empty()) {
2032 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2033 if ((*x)->processor == processor) {
2038 if (x == processor_automation.end()) {
2040 rai = new ProcessorAutomationInfo (processor);
2041 processor_automation.push_back (rai);
2049 /* any older menu was deleted at the top of processors_changed()
2050 when we cleared the subplugin menu.
2053 rai->menu = manage (new Menu);
2054 MenuList& items = rai->menu->items();
2055 rai->menu->set_name ("ArdourContextMenu");
2059 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2061 ProcessorAutomationNode* pan;
2062 CheckMenuItem* mitem;
2064 string name = processor->describe_parameter (*i);
2066 items.push_back (CheckMenuElem (name));
2067 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2069 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2070 mitem->set_active(true);
2073 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2077 pan = new ProcessorAutomationNode (*i, mitem, *this);
2079 rai->lines.push_back (pan);
2083 pan->menu_item = mitem;
2087 mitem->signal_toggled().connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2090 /* add the menu for this processor, because the subplugin
2091 menu is always cleared at the top of processors_changed().
2092 this is the result of some poor design in gtkmm and/or
2096 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2101 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2102 RouteTimeAxisView::ProcessorAutomationNode* pan)
2104 bool showit = pan->menu_item->get_active();
2105 bool redraw = false;
2107 if (pan->view == 0 && showit) {
2108 add_processor_automation_curve (rai->processor, pan->what);
2112 if (pan->view && showit != pan->view->marked_for_display()) {
2115 pan->view->set_marked_for_display (true);
2116 pan->view->canvas_display()->show();
2117 pan->view->canvas_background()->show();
2119 rai->processor->mark_automation_visible (pan->what, true);
2120 pan->view->set_marked_for_display (false);
2128 if (redraw && !no_redraw) {
2130 /* now trigger a redisplay */
2132 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2138 RouteTimeAxisView::processors_changed ()
2140 using namespace Menu_Helpers;
2142 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2143 (*i)->valid = false;
2146 subplugin_menu.items().clear ();
2148 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2149 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2151 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2153 list<ProcessorAutomationInfo*>::iterator tmp;
2161 processor_automation.erase (i);
2168 /* change in visibility was possible */
2170 _route->gui_changed ("visible_tracks", this);
2173 boost::shared_ptr<AutomationLine>
2174 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2176 ProcessorAutomationNode* pan;
2178 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2184 return boost::shared_ptr<AutomationLine>();
2188 RouteTimeAxisView::reset_processor_automation_curves ()
2190 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2196 RouteTimeAxisView::update_rec_display ()
2198 RouteUI::update_rec_display ();
2199 name_entry.set_sensitive (!_route->record_enabled());
2203 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2206 _view->set_layer_display (d);
2211 RouteTimeAxisView::layer_display () const
2214 return _view->layer_display ();
2217 /* we don't know, since we don't have a _view, so just return something */
2223 boost::shared_ptr<AutomationTimeAxisView>
2224 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2226 AutomationTracks::iterator i = _automation_tracks.find(param);
2227 if (i != _automation_tracks.end())
2228 return i->second->track;
2230 return boost::shared_ptr<AutomationTimeAxisView>();
2234 RouteTimeAxisView::fast_update ()
2236 gm.get_level_meter().update_meters ();
2240 RouteTimeAxisView::hide_meter ()
2243 gm.get_level_meter().hide_meters ();
2247 RouteTimeAxisView::show_meter ()
2253 RouteTimeAxisView::reset_meter ()
2255 if (Config->get_show_track_meters()) {
2256 gm.get_level_meter().setup_meters (height-5);
2263 RouteTimeAxisView::clear_meter ()
2265 gm.get_level_meter().clear_meters ();
2269 RouteTimeAxisView::meter_changed (void *src)
2271 ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::meter_changed), src));
2276 RouteTimeAxisView::io_changed (IOChange change, void *src)
2282 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu) {
2283 using namespace Menu_Helpers;
2285 if(!_underlay_streams.empty()) {
2286 MenuList& parent_items = parent_menu->items();
2287 Menu* gs_menu = manage (new Menu);
2288 gs_menu->set_name ("ArdourContextMenu");
2289 MenuList& gs_items = gs_menu->items();
2291 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2293 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2294 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2295 bind(mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2301 RouteTimeAxisView::set_underlay_state()
2303 if(!underlay_xml_node) {
2307 XMLNodeList nlist = underlay_xml_node->children();
2308 XMLNodeConstIterator niter;
2309 XMLNode *child_node;
2311 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2312 child_node = *niter;
2314 if(child_node->name() != "Underlay") {
2318 XMLProperty* prop = child_node->property ("id");
2320 PBD::ID id (prop->value());
2322 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2325 add_underlay(v->view(), false);
2334 RouteTimeAxisView::add_underlay(StreamView* v, bool update_xml)
2340 RouteTimeAxisView& other = v->trackview();
2342 if(find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2343 if(find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2344 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2348 _underlay_streams.push_back(v);
2349 other._underlay_mirrors.push_back(this);
2351 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::add_ghost));
2354 if(!underlay_xml_node) {
2356 underlay_xml_node = xml_node->add_child("Underlays");
2359 XMLNode* node = underlay_xml_node->add_child("Underlay");
2360 XMLProperty* prop = node->add_property("id");
2361 prop->set_value(v->trackview().route()->id().to_s());
2367 RouteTimeAxisView::remove_underlay(StreamView* v)
2373 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2374 RouteTimeAxisView& other = v->trackview();
2376 if(it != _underlay_streams.end()) {
2377 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2379 if(gm == other._underlay_mirrors.end()) {
2380 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2384 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2386 _underlay_streams.erase(it);
2387 other._underlay_mirrors.erase(gm);
2389 if(underlay_xml_node) {
2390 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());