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"
34 #include "pbd/enumwriter.h"
36 #include <gtkmm/menu.h>
37 #include <gtkmm/menuitem.h>
38 #include <gtkmm2ext/gtk_ui.h>
39 #include <gtkmm2ext/selector.h>
40 #include <gtkmm2ext/stop_signal.h>
41 #include <gtkmm2ext/bindable_button.h>
42 #include <gtkmm2ext/utils.h>
44 #include "ardour/amp.h"
45 #include "ardour/audioplaylist.h"
46 #include "ardour/diskstream.h"
47 #include "ardour/event_type_map.h"
48 #include "ardour/ladspa_plugin.h"
49 #include "ardour/location.h"
50 #include "ardour/panner.h"
51 #include "ardour/playlist.h"
52 #include "ardour/playlist.h"
53 #include "ardour/processor.h"
54 #include "ardour/profile.h"
55 #include "ardour/route_group.h"
56 #include "ardour/session.h"
57 #include "ardour/session_playlist.h"
58 #include "ardour/debug.h"
59 #include "ardour/utils.h"
60 #include "evoral/Parameter.hpp"
62 #include "ardour_ui.h"
63 #include "route_time_axis.h"
64 #include "automation_time_axis.h"
65 #include "canvas_impl.h"
66 #include "crossfade_view.h"
68 #include "gui_thread.h"
70 #include "playlist_selector.h"
71 #include "point_selection.h"
73 #include "public_editor.h"
74 #include "region_view.h"
75 #include "rgb_macros.h"
76 #include "selection.h"
77 #include "simplerect.h"
78 #include "streamview.h"
80 #include "route_group_menu.h"
82 #include "ardour/track.h"
86 using namespace ARDOUR;
88 using namespace Gtkmm2ext;
90 using namespace Editing;
93 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
96 RouteTimeAxisView::setup_slider_pix ()
98 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
99 throw failed_constructor ();
103 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
106 , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
107 , parent_canvas (canvas)
108 , button_table (3, 3)
109 , route_group_button (_("g"))
110 , playlist_button (_("p"))
111 , size_button (_("h"))
112 , automation_button (_("a"))
113 , visual_button (_("v"))
114 , gm (sess, slider, true, 115)
118 gm.set_controls (_route, _route->shared_peak_meter(), _route->amp());
119 gm.get_level_meter().set_no_show_all();
120 gm.get_level_meter().setup_meters(50);
124 playlist_action_menu = 0;
125 automation_action_menu = 0;
129 if (!_route->is_hidden()) {
130 _marked_for_display = true;
133 timestretch_rect = 0;
135 destructive_track_mode_item = 0;
136 normal_track_mode_item = 0;
137 non_layered_track_mode_item = 0;
139 ignore_toggle = false;
141 route_group_button.set_name ("TrackGroupButton");
142 playlist_button.set_name ("TrackPlaylistButton");
143 automation_button.set_name ("TrackAutomationButton");
144 size_button.set_name ("TrackSizeButton");
145 visual_button.set_name ("TrackVisualButton");
146 hide_button.set_name ("TrackRemoveButton");
148 route_group_button.unset_flags (Gtk::CAN_FOCUS);
149 playlist_button.unset_flags (Gtk::CAN_FOCUS);
150 automation_button.unset_flags (Gtk::CAN_FOCUS);
151 size_button.unset_flags (Gtk::CAN_FOCUS);
152 visual_button.unset_flags (Gtk::CAN_FOCUS);
153 hide_button.unset_flags (Gtk::CAN_FOCUS);
155 hide_button.add (*(manage (new Image (::get_icon("hide")))));
156 hide_button.show_all ();
158 route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::edit_click), false);
159 playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
160 automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
161 size_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::size_click), false);
162 visual_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::visual_click));
163 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::hide_click));
165 solo_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::solo_press), false);
166 solo_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::solo_release), false);
167 mute_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::mute_press), false);
168 mute_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::mute_release), false);
174 rec_enable_button->remove ();
176 switch (track()->mode()) {
178 case ARDOUR::NonLayered:
179 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
181 case ARDOUR::Destructive:
182 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
185 rec_enable_button->show_all ();
187 rec_enable_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::rec_enable_press), false);
188 rec_enable_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::rec_enable_release), false);
189 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
190 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
192 rec_enable_button->set_sensitive (_session.writable());
195 controls_hbox.pack_start(gm.get_level_meter(), false, false);
196 _route->meter_change.connect (sigc::mem_fun(*this, &RouteTimeAxisView::meter_changed));
197 _route->input()->changed.connect (sigc::mem_fun(*this, &RouteTimeAxisView::io_changed));
198 _route->output()->changed.connect (sigc::mem_fun(*this, &RouteTimeAxisView::io_changed));
200 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
201 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
203 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
204 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
206 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
207 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
208 ARDOUR_UI::instance()->tooltips().set_tip(route_group_button, _("Route Group"));
209 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
210 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
211 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
212 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
213 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
219 /* old school - when we used to put an extra row of buttons in place */
221 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
222 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
223 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
224 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
228 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
231 if (is_track() && track()->mode() == ARDOUR::Normal) {
232 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
237 _route->mute_changed.connect (sigc::mem_fun(*this, &RouteUI::mute_changed));
238 _route->solo_changed.connect (sigc::mem_fun(*this, &RouteUI::solo_changed));
239 _route->processors_changed.connect (sigc::mem_fun(*this, &RouteTimeAxisView::processors_changed));
240 _route->NameChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::route_name_changed));
241 _route->solo_isolated_changed.connect (sigc::mem_fun(*this, &RouteUI::solo_changed));
246 track()->TrackModeChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::track_mode_changed));
247 track()->FreezeChange.connect (sigc::mem_fun(*this, &RouteTimeAxisView::map_frozen));
248 track()->DiskstreamChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
249 get_diskstream()->SpeedChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::speed_changed));
251 /* pick up the correct freeze state */
256 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
257 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
259 route_group_menu = new RouteGroupMenu (
261 (RouteGroup::Property) (RouteGroup::Mute | RouteGroup::Solo | RouteGroup::Edit)
264 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
266 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
267 gm.get_gain_slider().set_name ("TrackGainFader");
270 RouteTimeAxisView::~RouteTimeAxisView ()
272 GoingAway (); /* EMIT_SIGNAL */
274 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
278 delete playlist_menu;
281 delete playlist_action_menu;
282 playlist_action_menu = 0;
287 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
291 _automation_tracks.clear ();
293 delete route_group_menu;
297 RouteTimeAxisView::post_construct ()
299 /* map current state of the route */
301 update_diskstream_display ();
303 subplugin_menu.items().clear ();
304 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
305 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
306 reset_processor_automation_curves ();
310 RouteTimeAxisView::edit_click (GdkEventButton *ev)
312 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
313 if (_route->route_group()) {
314 _route->route_group()->remove (_route);
319 route_group_menu->rebuild (_route->route_group ());
320 route_group_menu->popup (ev->button, ev->time);
326 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
331 if (_route->route_group()) {
332 _route->route_group()->remove (_route);
338 RouteTimeAxisView::playlist_changed ()
344 RouteTimeAxisView::label_view ()
346 string x = _route->name();
348 if (x != name_entry.get_text()) {
349 name_entry.set_text (x);
352 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
356 RouteTimeAxisView::route_name_changed ()
362 RouteTimeAxisView::take_name_changed (void *src)
371 RouteTimeAxisView::playlist_click ()
373 // always build a new action menu
375 delete playlist_action_menu;
377 playlist_action_menu = new Menu;
378 playlist_action_menu->set_name ("ArdourContextMenu");
380 build_playlist_menu (playlist_action_menu);
382 conditionally_add_to_selection ();
383 playlist_action_menu->popup (1, gtk_get_current_event_time());
387 RouteTimeAxisView::automation_click ()
389 conditionally_add_to_selection ();
390 build_automation_action_menu ();
391 automation_action_menu->popup (1, gtk_get_current_event_time());
395 RouteTimeAxisView::set_state (const XMLNode& node, int version)
397 TimeAxisView::set_state (node, version);
399 XMLNodeList kids = node.children();
400 XMLNodeConstIterator iter;
401 const XMLProperty* prop;
403 if (_view && (prop = node.property ("layer-display"))) {
404 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
407 for (iter = kids.begin(); iter != kids.end(); ++iter) {
408 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
409 if ((prop = (*iter)->property ("automation-id")) != 0) {
411 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
412 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
413 create_automation_child(param, show);
415 warning << "Automation child has no ID" << endmsg;
424 RouteTimeAxisView::build_automation_action_menu ()
426 using namespace Menu_Helpers;
428 automation_action_menu = manage (new Menu);
429 MenuList& automation_items = automation_action_menu->items();
430 automation_action_menu->set_name ("ArdourContextMenu");
432 automation_items.push_back (MenuElem (_("Show all automation"),
433 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
435 automation_items.push_back (MenuElem (_("Show existing automation"),
436 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
438 automation_items.push_back (MenuElem (_("Hide all automation"),
439 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
441 if (subplugin_menu.get_attach_widget())
442 subplugin_menu.detach();
444 automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
445 automation_items.back().set_sensitive (!subplugin_menu.items().empty());
447 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
448 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
450 automation_items.push_back (SeparatorElem());
452 delete i->second->menu_item;
454 automation_items.push_back(CheckMenuElem (_route->describe_parameter(i->second->param),
455 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
457 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&automation_items.back());
459 i->second->menu_item->set_active(show_automation(i->second->param));
460 //i->second->menu_item->set_active(false);
465 RouteTimeAxisView::build_display_menu ()
467 using namespace Menu_Helpers;
469 /* get the size menu ready */
475 TimeAxisView::build_display_menu ();
477 /* now fill it with our stuff */
479 MenuList& items = display_menu->items();
480 display_menu->set_name ("ArdourContextMenu");
482 items.push_back (MenuElem (_("Height"), *size_menu));
483 items.push_back (MenuElem (_("Color"), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
485 items.push_back (SeparatorElem());
487 if (!Profile->get_sae()) {
488 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
489 /* rebuild this every time */
490 build_automation_action_menu ();
491 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
492 items.push_back (SeparatorElem());
495 // Hook for derived classes to add type specific stuff
496 append_extra_display_menu_items ();
497 items.push_back (SeparatorElem());
501 Menu *layers_menu = manage(new Menu);
502 MenuList &layers_items = layers_menu->items();
503 layers_menu->set_name("ArdourContextMenu");
505 RadioMenuItem::Group layers_group;
507 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
508 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
509 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
510 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
512 items.push_back (MenuElem (_("Layers"), *layers_menu));
514 Menu* alignment_menu = manage (new Menu);
515 MenuList& alignment_items = alignment_menu->items();
516 alignment_menu->set_name ("ArdourContextMenu");
518 RadioMenuItem::Group align_group;
520 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
521 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
522 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
523 if (get_diskstream()->alignment_style() == ExistingMaterial)
524 align_existing_item->set_active();
526 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
527 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
528 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
529 if (get_diskstream()->alignment_style() == CaptureTime)
530 align_capture_item->set_active();
532 if (!Profile->get_sae()) {
533 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
534 get_diskstream()->AlignmentStyleChanged.connect (
535 sigc::mem_fun(*this, &RouteTimeAxisView::align_style_changed));
537 RadioMenuItem::Group mode_group;
538 items.push_back (RadioMenuElem (mode_group, _("Normal mode"), sigc::bind (
539 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
541 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
543 items.push_back (RadioMenuElem (mode_group, _("Tape mode"), sigc::bind (
544 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
545 ARDOUR::Destructive)));
546 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
548 items.push_back (RadioMenuElem (mode_group, _("No layering mode"),
549 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
550 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
554 switch (track()->mode()) {
555 case ARDOUR::Destructive:
556 destructive_track_mode_item->set_active ();
559 normal_track_mode_item->set_active ();
561 case ARDOUR::NonLayered:
562 non_layered_track_mode_item->set_active ();
567 get_diskstream()->AlignmentStyleChanged.connect (
568 sigc::mem_fun(*this, &RouteTimeAxisView::align_style_changed));
570 mode_menu = build_mode_menu();
572 items.push_back (MenuElem (_("Mode"), *mode_menu));
574 color_mode_menu = build_color_mode_menu();
576 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
578 items.push_back (SeparatorElem());
581 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
582 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
583 route_active_menu_item->set_active (_route->active());
585 items.push_back (SeparatorElem());
586 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &RouteTimeAxisView::hide_click)));
587 if (!Profile->get_sae()) {
588 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
590 items.push_front (SeparatorElem());
591 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
595 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
598 item_2->set_active ();
603 RouteTimeAxisView::set_track_mode (TrackMode mode)
606 RadioMenuItem* other_item;
607 RadioMenuItem* other_item_2;
611 item = normal_track_mode_item;
612 other_item = non_layered_track_mode_item;
613 other_item_2 = destructive_track_mode_item;
615 case ARDOUR::NonLayered:
616 item = non_layered_track_mode_item;
617 other_item = normal_track_mode_item;
618 other_item_2 = destructive_track_mode_item;
620 case ARDOUR::Destructive:
621 item = destructive_track_mode_item;
622 other_item = normal_track_mode_item;
623 other_item_2 = non_layered_track_mode_item;
626 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
631 if (item && other_item && other_item_2 && item->get_active() && track()->mode() != mode) {
632 _set_track_mode (track().get(), mode, other_item, other_item_2);
637 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
641 if (!track->can_use_mode (mode, needs_bounce)) {
645 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
648 cerr << "would bounce this one\n";
653 track->set_mode (mode);
655 rec_enable_button->remove ();
658 case ARDOUR::NonLayered:
660 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
662 case ARDOUR::Destructive:
663 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
667 rec_enable_button->show_all ();
671 RouteTimeAxisView::track_mode_changed ()
675 switch (track()->mode()) {
677 item = normal_track_mode_item;
679 case ARDOUR::NonLayered:
680 item = non_layered_track_mode_item;
682 case ARDOUR::Destructive:
683 item = destructive_track_mode_item;
686 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
695 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
701 TimeAxisView::show_timestretch (start, end);
711 /* check that the time selection was made in our route, or our route group.
712 remember that route_group() == 0 implies the route is *not* in a edit group.
715 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
716 /* this doesn't apply to us */
720 /* ignore it if our edit group is not active */
722 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
727 if (timestretch_rect == 0) {
728 timestretch_rect = new SimpleRect (*canvas_display ());
729 timestretch_rect->property_x1() = 0.0;
730 timestretch_rect->property_y1() = 0.0;
731 timestretch_rect->property_x2() = 0.0;
732 timestretch_rect->property_y2() = 0.0;
733 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
734 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
737 timestretch_rect->show ();
738 timestretch_rect->raise_to_top ();
740 x1 = start / _editor.get_current_zoom();
741 x2 = (end - 1) / _editor.get_current_zoom();
742 y2 = current_height() - 2;
744 timestretch_rect->property_x1() = x1;
745 timestretch_rect->property_y1() = 1.0;
746 timestretch_rect->property_x2() = x2;
747 timestretch_rect->property_y2() = y2;
751 RouteTimeAxisView::hide_timestretch ()
753 TimeAxisView::hide_timestretch ();
755 if (timestretch_rect) {
756 timestretch_rect->hide ();
761 RouteTimeAxisView::show_selection (TimeSelection& ts)
765 /* ignore it if our edit group is not active or if the selection was started
766 in some other track or route group (remember that route_group() == 0 means
767 that the track is not in an route group).
770 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
771 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
777 TimeAxisView::show_selection (ts);
781 RouteTimeAxisView::set_height (uint32_t h)
784 bool height_changed = (height == 0) || (h != height);
785 gm.get_level_meter().setup_meters (gmlen);
787 TimeAxisView::set_height (h);
792 _view->set_height ((double) current_height());
796 snprintf (buf, sizeof (buf), "%u", height);
797 xml_node->add_property ("height", buf);
799 if (height >= hNormal) {
804 gm.get_gain_slider().show();
806 if (!_route || _route->is_control()) {
811 if (rec_enable_button)
812 rec_enable_button->show();
814 route_group_button.show();
816 visual_button.show();
818 automation_button.show();
820 if (is_track() && track()->mode() == ARDOUR::Normal) {
821 playlist_button.show();
824 } else if (height >= hSmaller) {
830 gm.get_gain_slider().hide();
832 if (!_route || _route->is_control()) {
837 if (rec_enable_button)
838 rec_enable_button->show();
840 route_group_button.hide ();
842 visual_button.hide ();
844 automation_button.hide ();
846 if (is_track() && track()->mode() == ARDOUR::Normal) {
847 playlist_button.hide ();
853 /* don't allow name_entry to be hidden while
854 it has focus, otherwise the GUI becomes unusable.
857 if (name_entry.has_focus()) {
858 if (name_entry.get_text() != _route->name()) {
859 name_entry_changed ();
861 controls_ebox.grab_focus ();
867 gm.get_gain_slider().hide();
870 if (rec_enable_button)
871 rec_enable_button->hide();
873 route_group_button.hide ();
875 visual_button.hide ();
877 automation_button.hide ();
878 playlist_button.hide ();
879 name_label.set_text (_route->name());
882 if (height_changed) {
883 /* only emit the signal if the height really changed */
884 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
889 RouteTimeAxisView::select_track_color ()
891 if (RouteUI::choose_color ()) {
894 _view->apply_color (_color, StreamView::RegionColor);
900 RouteTimeAxisView::reset_samples_per_unit ()
902 set_samples_per_unit (_editor.get_current_zoom());
906 RouteTimeAxisView::set_samples_per_unit (double spu)
910 if (get_diskstream() != 0) {
911 speed = get_diskstream()->speed();
915 _view->set_samples_per_unit (spu * speed);
918 TimeAxisView::set_samples_per_unit (spu * speed);
922 RouteTimeAxisView::align_style_changed ()
924 switch (get_diskstream()->alignment_style()) {
925 case ExistingMaterial:
926 if (!align_existing_item->get_active()) {
927 align_existing_item->set_active();
931 if (!align_capture_item->get_active()) {
932 align_capture_item->set_active();
939 RouteTimeAxisView::set_align_style (AlignStyle style)
944 case ExistingMaterial:
945 item = align_existing_item;
948 item = align_capture_item;
951 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
956 if (item->get_active()) {
957 get_diskstream()->set_align_style (style);
962 RouteTimeAxisView::rename_current_playlist ()
964 ArdourPrompter prompter (true);
967 boost::shared_ptr<Diskstream> ds = get_diskstream();
968 if (!ds || ds->destructive())
971 boost::shared_ptr<Playlist> pl = ds->playlist();
975 prompter.set_prompt (_("Name for playlist"));
976 prompter.set_initial_text (pl->name());
977 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
978 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
980 switch (prompter.run ()) {
981 case Gtk::RESPONSE_ACCEPT:
982 prompter.get_result (name);
994 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
996 std::string ret (basename);
998 std::string const group_string = "." + route_group()->name() + ".";
1000 // iterate through all playlists
1002 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
1003 std::string tmp = (*i)->name();
1005 std::string::size_type idx = tmp.find(group_string);
1006 // find those which belong to this group
1007 if (idx != string::npos) {
1008 tmp = tmp.substr(idx + group_string.length());
1010 // and find the largest current number
1011 int x = atoi(tmp.c_str());
1012 if (x > maxnumber) {
1021 snprintf (buf, sizeof(buf), "%d", maxnumber);
1023 ret = this->name() + "." + route_group()->name () + "." + buf;
1029 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1033 boost::shared_ptr<Diskstream> ds = get_diskstream();
1034 if (!ds || ds->destructive())
1037 boost::shared_ptr<const Playlist> pl = ds->playlist();
1043 if (route_group() && route_group()->is_active()) {
1044 name = resolve_new_group_playlist_name(name, playlists_before_op);
1047 while (_session.playlists->by_name(name)) {
1048 name = Playlist::bump_name (name, _session);
1051 // TODO: The prompter "new" button should be de-activated if the user
1052 // specifies a playlist name which already exists in the session.
1056 ArdourPrompter prompter (true);
1058 prompter.set_prompt (_("Name for Playlist"));
1059 prompter.set_initial_text (name);
1060 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1061 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1062 prompter.show_all ();
1064 switch (prompter.run ()) {
1065 case Gtk::RESPONSE_ACCEPT:
1066 prompter.get_result (name);
1074 if (name.length()) {
1075 ds->use_copy_playlist ();
1076 ds->playlist()->set_name (name);
1081 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1085 boost::shared_ptr<Diskstream> ds = get_diskstream();
1086 if (!ds || ds->destructive())
1089 boost::shared_ptr<const Playlist> pl = ds->playlist();
1095 if (route_group() && route_group()->is_active()) {
1096 name = resolve_new_group_playlist_name(name,playlists_before_op);
1099 while (_session.playlists->by_name(name)) {
1100 name = Playlist::bump_name (name, _session);
1106 ArdourPrompter prompter (true);
1108 prompter.set_prompt (_("Name for Playlist"));
1109 prompter.set_initial_text (name);
1110 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1111 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1113 switch (prompter.run ()) {
1114 case Gtk::RESPONSE_ACCEPT:
1115 prompter.get_result (name);
1123 if (name.length()) {
1124 ds->use_new_playlist ();
1125 ds->playlist()->set_name (name);
1130 RouteTimeAxisView::clear_playlist ()
1132 boost::shared_ptr<Diskstream> ds = get_diskstream();
1133 if (!ds || ds->destructive())
1136 boost::shared_ptr<Playlist> pl = ds->playlist();
1140 _editor.clear_playlist (pl);
1144 RouteTimeAxisView::speed_changed ()
1146 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1150 RouteTimeAxisView::diskstream_changed ()
1152 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::update_diskstream_display, this));
1156 RouteTimeAxisView::update_diskstream_display ()
1158 if (!get_diskstream()) // bus
1165 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1167 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1169 /* special case: select/deselect all tracks */
1170 if (_editor.get_selection().selected (this)) {
1171 _editor.get_selection().clear_tracks ();
1173 _editor.select_all_tracks ();
1179 switch (ArdourKeyboard::selection_type (ev->state)) {
1180 case Selection::Toggle:
1181 _editor.get_selection().toggle (this);
1184 case Selection::Set:
1185 _editor.get_selection().set (this);
1188 case Selection::Extend:
1189 _editor.extend_selection_to_track (*this);
1192 case Selection::Add:
1193 _editor.get_selection().add (this);
1199 RouteTimeAxisView::set_selected_points (PointSelection& points)
1201 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1202 (*i)->set_selected_points (points);
1207 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1210 _view->set_selected_regionviews (regions);
1214 /** Add the selectable things that we have to a list.
1215 * @param results List to add things to.
1218 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1222 if (get_diskstream() != 0) {
1223 speed = get_diskstream()->speed();
1226 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1227 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1229 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1230 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1233 /* pick up visible automation tracks */
1235 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1236 if (!(*i)->hidden()) {
1237 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1243 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1246 _view->get_inverted_selectables (sel, results);
1249 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1250 if (!(*i)->hidden()) {
1251 (*i)->get_inverted_selectables (sel, results);
1259 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1261 return (_show_automation.find(param) != _show_automation.end());
1264 /** Retuns 0 if track for \a param doesn't exist.
1266 RouteTimeAxisView::RouteAutomationNode*
1267 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1269 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1271 if (i != _automation_tracks.end()) {
1278 /** Shorthand for GainAutomation, etc.
1280 RouteTimeAxisView::RouteAutomationNode*
1281 RouteTimeAxisView::automation_track (AutomationType type)
1283 return automation_track (Evoral::Parameter(type));
1287 RouteTimeAxisView::route_group () const
1289 return _route->route_group();
1293 RouteTimeAxisView::name() const
1295 return _route->name();
1298 boost::shared_ptr<Playlist>
1299 RouteTimeAxisView::playlist () const
1301 boost::shared_ptr<Diskstream> ds;
1303 if ((ds = get_diskstream()) != 0) {
1304 return ds->playlist();
1306 return boost::shared_ptr<Playlist> ();
1311 RouteTimeAxisView::name_entry_changed ()
1315 x = name_entry.get_text ();
1317 if (x == _route->name()) {
1321 strip_whitespace_edges(x);
1323 if (x.length() == 0) {
1324 name_entry.set_text (_route->name());
1328 if (!_session.route_name_unique (x)) {
1329 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1330 name_entry.set_text (_route->name());
1331 } else if (_session.route_name_internal (x)) {
1332 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1333 name_entry.set_text (_route->name());
1335 _route->set_name (x);
1340 RouteTimeAxisView::visual_click ()
1342 popup_display_menu (0);
1346 RouteTimeAxisView::hide_click ()
1348 // LAME fix for hide_button refresh fix
1349 hide_button.set_sensitive(false);
1351 _editor.hide_track_in_display (*this);
1353 hide_button.set_sensitive(true);
1356 boost::shared_ptr<Region>
1357 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, 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 (pos, point, dir);
1366 return boost::shared_ptr<Region> ();
1370 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1372 boost::shared_ptr<Diskstream> stream;
1373 boost::shared_ptr<Playlist> playlist;
1375 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1376 return playlist->find_next_region_boundary (pos, dir);
1383 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1385 boost::shared_ptr<Playlist> what_we_got;
1386 boost::shared_ptr<Diskstream> ds = get_diskstream();
1387 boost::shared_ptr<Playlist> playlist;
1391 /* route is a bus, not a track */
1395 playlist = ds->playlist();
1397 TimeSelection time (selection.time);
1398 float speed = ds->speed();
1399 if (speed != 1.0f) {
1400 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1401 (*i).start = session_frame_to_track_frame((*i).start, speed);
1402 (*i).end = session_frame_to_track_frame((*i).end, speed);
1406 XMLNode &before = playlist->get_state();
1409 if ((what_we_got = playlist->cut (time)) != 0) {
1410 _editor.get_cut_buffer().add (what_we_got);
1411 _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1416 if ((what_we_got = playlist->copy (time)) != 0) {
1417 _editor.get_cut_buffer().add (what_we_got);
1422 if ((what_we_got = playlist->cut (time)) != 0) {
1423 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1424 what_we_got->release ();
1434 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1440 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1441 PlaylistSelection::iterator p;
1443 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1445 if (p == selection.playlists.end()) {
1449 if (get_diskstream()->speed() != 1.0f) {
1450 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1453 XMLNode &before = playlist->get_state();
1454 playlist->paste (*p, pos, times);
1455 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1461 TimeAxisView::Children
1462 RouteTimeAxisView::get_child_list()
1464 TimeAxisView::Children redirect_children;
1466 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1467 if (!(*i)->hidden()) {
1468 redirect_children.push_back(*i);
1471 return redirect_children;
1476 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1478 using namespace Menu_Helpers;
1480 if (!menu || !is_track()) {
1484 MenuList& playlist_items = menu->items();
1485 menu->set_name ("ArdourContextMenu");
1486 playlist_items.clear();
1488 delete playlist_menu;
1490 playlist_menu = new Menu;
1491 playlist_menu->set_name ("ArdourContextMenu");
1493 vector<boost::shared_ptr<Playlist> > playlists;
1494 boost::shared_ptr<Diskstream> ds = get_diskstream();
1495 RadioMenuItem::Group playlist_group;
1497 _session.playlists->get (playlists);
1499 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1501 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1502 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist),
1503 boost::weak_ptr<Playlist> (*i))));
1505 if (ds->playlist()->id() == (*i)->id()) {
1506 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1508 } else if (ds->playlist()->id() == (*i)->id()) {
1509 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist),
1510 boost::weak_ptr<Playlist>(*i))));
1511 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1516 playlist_items.push_back (SeparatorElem());
1517 playlist_items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1518 playlist_items.push_back (SeparatorElem());
1520 if (!route_group() || !route_group()->is_active()) {
1521 playlist_items.push_back (MenuElem (_("New"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1522 playlist_items.push_back (MenuElem (_("New Copy"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1525 // Use a label which tells the user what is happening
1526 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1527 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1531 playlist_items.push_back (SeparatorElem());
1532 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1533 playlist_items.push_back (SeparatorElem());
1535 playlist_items.push_back (MenuElem(_("Select from all ..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1539 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1541 assert (is_track());
1543 boost::shared_ptr<Playlist> pl (wpl.lock());
1549 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1552 if (get_diskstream()->playlist() == apl) {
1553 // radio button cotnrols mean this function is called for both the
1554 // old and new playlist
1557 get_diskstream()->use_playlist (apl);
1560 if (route_group() && route_group()->is_active()) {
1561 //PBD::stacktrace(cerr, 20);
1562 std::string group_string = "."+route_group()->name()+".";
1564 std::string take_name = apl->name();
1565 std::string::size_type idx = take_name.find(group_string);
1567 if (idx == std::string::npos)
1570 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1572 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1574 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1575 if ( (*i) == this->route()) {
1579 std::string playlist_name = (*i)->name()+group_string+take_name;
1581 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1583 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1587 boost::shared_ptr<Playlist> ipl = session().playlists->by_name(playlist_name);
1589 // No playlist for this track for this take yet, make it
1590 track->diskstream()->use_new_playlist();
1591 track->diskstream()->playlist()->set_name(playlist_name);
1593 track->diskstream()->use_playlist(ipl);
1601 RouteTimeAxisView::show_playlist_selector ()
1603 _editor.playlist_selector().show_for (this);
1607 RouteTimeAxisView::map_frozen ()
1613 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1615 switch (track()->freeze_state()) {
1617 playlist_button.set_sensitive (false);
1618 rec_enable_button->set_sensitive (false);
1621 playlist_button.set_sensitive (true);
1622 rec_enable_button->set_sensitive (true);
1628 RouteTimeAxisView::color_handler ()
1630 //case cTimeStretchOutline:
1631 if (timestretch_rect) {
1632 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1634 //case cTimeStretchFill:
1635 if (timestretch_rect) {
1636 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1643 RouteTimeAxisView::toggle_automation_track (Evoral::Parameter param)
1645 RouteAutomationNode* node = automation_track(param);
1650 bool showit = node->menu_item->get_active();
1652 if (showit != node->track->marked_for_display()) {
1654 node->track->set_marked_for_display (true);
1655 node->track->canvas_display()->show();
1656 node->track->get_state_node()->add_property ("shown", X_("yes"));
1658 node->track->set_marked_for_display (false);
1659 node->track->hide ();
1660 node->track->get_state_node()->add_property ("shown", X_("no"));
1663 /* now trigger a redisplay */
1666 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1672 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1674 RouteAutomationNode* ran = automation_track(param);
1679 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1680 _show_automation.erase(param);
1681 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1683 if (ran->menu_item && !_hidden) {
1684 ran->menu_item->set_active (false);
1687 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1692 RouteTimeAxisView::show_all_automation ()
1696 /* Show our automation */
1698 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1699 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1700 i->second->track->set_marked_for_display (true);
1701 i->second->track->canvas_display()->show();
1702 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1703 i->second->menu_item->set_active(true);
1707 /* Show processor automation */
1709 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1710 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1711 if ((*ii)->view == 0) {
1712 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1715 (*ii)->menu_item->set_active (true);
1723 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1727 RouteTimeAxisView::show_existing_automation ()
1731 /* Show our automation */
1733 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1734 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1735 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1736 i->second->track->set_marked_for_display (true);
1737 i->second->track->canvas_display()->show();
1738 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1739 i->second->menu_item->set_active(true);
1744 /* Show processor automation */
1746 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1747 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1748 if ((*ii)->view != 0 && (*i)->processor->data().control((*ii)->what)->list()->size() > 0) {
1749 (*ii)->menu_item->set_active (true);
1756 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1760 RouteTimeAxisView::hide_all_automation ()
1764 /* Hide our automation */
1766 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1767 i->second->track->set_marked_for_display (false);
1768 i->second->track->hide ();
1769 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1770 i->second->menu_item->set_active (false);
1773 /* Hide processor automation */
1775 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1776 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1777 (*ii)->menu_item->set_active (false);
1781 _show_automation.clear();
1784 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1789 RouteTimeAxisView::region_view_added (RegionView* rv)
1791 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1792 if(is_audio_track()) {
1793 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1794 boost::shared_ptr<AutomationTimeAxisView> atv;
1796 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1802 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1803 (*i)->add_ghost(rv);
1807 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1809 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1815 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1817 parent.remove_processor_automation_node (this);
1821 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1824 remove_child (pan->view);
1828 RouteTimeAxisView::ProcessorAutomationNode*
1829 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1831 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1833 if ((*i)->processor == processor) {
1835 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1836 if ((*ii)->what == what) {
1847 legalize_for_xml_node (string str)
1849 string::size_type pos;
1850 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1856 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1857 legal.replace (pos, 1, "_");
1866 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1869 ProcessorAutomationNode* pan;
1871 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1872 error << _("programming error: ")
1873 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1874 processor->name(), what)
1884 name = processor->describe_parameter (what);
1886 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1890 char state_name[256];
1891 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1893 boost::shared_ptr<AutomationControl> control
1894 = boost::dynamic_pointer_cast<AutomationControl>(processor->data().control(what, true));
1896 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1897 new AutomationTimeAxisView (_session, _route, processor, control,
1898 _editor, *this, false, parent_canvas, name, state_name));
1900 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1902 if (!pan->view->marked_for_display()) {
1905 pan->menu_item->set_active (true);
1908 add_child (pan->view);
1911 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1914 processor->mark_automation_visible (what, true);
1918 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1921 pan->menu_item->set_active (false);
1924 i->mark_automation_visible (pan->what, false);
1926 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1930 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1932 boost::shared_ptr<Processor> processor (p.lock ());
1937 set<Evoral::Parameter> s;
1938 boost::shared_ptr<AutomationLine> al;
1940 processor->what_has_visible_data (s);
1942 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1944 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1947 add_processor_automation_curve (processor, (*i));
1953 RouteTimeAxisView::add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1955 using namespace Menu_Helpers;
1962 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1964 bool hideit = (!show);
1966 if ((node = track->get_state_node()) != 0) {
1967 if ((prop = node->property ("shown")) != 0) {
1968 if (string_is_affirmative (prop->value())) {
1974 _automation_tracks.insert(std::make_pair(param, new RouteAutomationNode(param, NULL, track)));
1979 _show_automation.insert (param);
1983 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1987 build_display_menu();
1992 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1994 boost::shared_ptr<Processor> processor (p.lock ());
1996 if (!processor || !processor->display_to_user ()) {
2000 using namespace Menu_Helpers;
2001 ProcessorAutomationInfo *rai;
2002 list<ProcessorAutomationInfo*>::iterator x;
2004 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2005 std::set<Evoral::Parameter> has_visible_automation;
2007 processor->what_has_visible_data(has_visible_automation);
2009 if (automatable.empty()) {
2013 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2014 if ((*x)->processor == processor) {
2019 if (x == processor_automation.end()) {
2021 rai = new ProcessorAutomationInfo (processor);
2022 processor_automation.push_back (rai);
2030 /* any older menu was deleted at the top of processors_changed()
2031 when we cleared the subplugin menu.
2034 rai->menu = manage (new Menu);
2035 MenuList& items = rai->menu->items();
2036 rai->menu->set_name ("ArdourContextMenu");
2040 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2042 ProcessorAutomationNode* pan;
2043 CheckMenuItem* mitem;
2045 string name = processor->describe_parameter (*i);
2047 items.push_back (CheckMenuElem (name));
2048 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2050 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2051 mitem->set_active(true);
2054 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2058 pan = new ProcessorAutomationNode (*i, mitem, *this);
2060 rai->lines.push_back (pan);
2064 pan->menu_item = mitem;
2068 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2071 /* add the menu for this processor, because the subplugin
2072 menu is always cleared at the top of processors_changed().
2073 this is the result of some poor design in gtkmm and/or
2077 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2082 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2083 RouteTimeAxisView::ProcessorAutomationNode* pan)
2085 bool showit = pan->menu_item->get_active();
2086 bool redraw = false;
2088 if (pan->view == 0 && showit) {
2089 add_processor_automation_curve (rai->processor, pan->what);
2093 if (pan->view && showit != pan->view->marked_for_display()) {
2096 pan->view->set_marked_for_display (true);
2097 pan->view->canvas_display()->show();
2098 pan->view->canvas_background()->show();
2100 rai->processor->mark_automation_visible (pan->what, true);
2101 pan->view->set_marked_for_display (false);
2109 if (redraw && !no_redraw) {
2111 /* now trigger a redisplay */
2113 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2119 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2121 if (c.type == RouteProcessorChange::MeterPointChange) {
2122 /* nothing to do if only the meter point has changed */
2126 using namespace Menu_Helpers;
2128 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2129 (*i)->valid = false;
2132 subplugin_menu.items().clear ();
2134 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2135 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2137 bool deleted_processor_automation = false;
2139 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2141 list<ProcessorAutomationInfo*>::iterator tmp;
2149 processor_automation.erase (i);
2150 deleted_processor_automation = true;
2157 if (deleted_processor_automation) {
2158 _route->gui_changed ("visible_tracks", this);
2162 boost::shared_ptr<AutomationLine>
2163 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2165 ProcessorAutomationNode* pan;
2167 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2173 return boost::shared_ptr<AutomationLine>();
2177 RouteTimeAxisView::reset_processor_automation_curves ()
2179 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2185 RouteTimeAxisView::update_rec_display ()
2187 RouteUI::update_rec_display ();
2188 name_entry.set_sensitive (!_route->record_enabled());
2192 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2195 _view->set_layer_display (d);
2199 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2203 RouteTimeAxisView::layer_display () const
2206 return _view->layer_display ();
2209 /* we don't know, since we don't have a _view, so just return something */
2215 boost::shared_ptr<AutomationTimeAxisView>
2216 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2218 AutomationTracks::iterator i = _automation_tracks.find(param);
2219 if (i != _automation_tracks.end())
2220 return i->second->track;
2222 return boost::shared_ptr<AutomationTimeAxisView>();
2226 RouteTimeAxisView::fast_update ()
2228 gm.get_level_meter().update_meters ();
2232 RouteTimeAxisView::hide_meter ()
2235 gm.get_level_meter().hide_meters ();
2239 RouteTimeAxisView::show_meter ()
2245 RouteTimeAxisView::reset_meter ()
2247 if (Config->get_show_track_meters()) {
2248 gm.get_level_meter().setup_meters (height-5);
2255 RouteTimeAxisView::clear_meter ()
2257 gm.get_level_meter().clear_meters ();
2261 RouteTimeAxisView::meter_changed (void *src)
2263 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed, src)
2268 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2274 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu) {
2275 using namespace Menu_Helpers;
2277 if(!_underlay_streams.empty()) {
2278 MenuList& parent_items = parent_menu->items();
2279 Menu* gs_menu = manage (new Menu);
2280 gs_menu->set_name ("ArdourContextMenu");
2281 MenuList& gs_items = gs_menu->items();
2283 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2285 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2286 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2287 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2293 RouteTimeAxisView::set_underlay_state()
2295 if(!underlay_xml_node) {
2299 XMLNodeList nlist = underlay_xml_node->children();
2300 XMLNodeConstIterator niter;
2301 XMLNode *child_node;
2303 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2304 child_node = *niter;
2306 if(child_node->name() != "Underlay") {
2310 XMLProperty* prop = child_node->property ("id");
2312 PBD::ID id (prop->value());
2314 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2317 add_underlay(v->view(), false);
2326 RouteTimeAxisView::add_underlay(StreamView* v, bool update_xml)
2332 RouteTimeAxisView& other = v->trackview();
2334 if(find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2335 if(find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2336 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2340 _underlay_streams.push_back(v);
2341 other._underlay_mirrors.push_back(this);
2343 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2346 if(!underlay_xml_node) {
2348 underlay_xml_node = xml_node->add_child("Underlays");
2351 XMLNode* node = underlay_xml_node->add_child("Underlay");
2352 XMLProperty* prop = node->add_property("id");
2353 prop->set_value(v->trackview().route()->id().to_s());
2359 RouteTimeAxisView::remove_underlay(StreamView* v)
2365 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2366 RouteTimeAxisView& other = v->trackview();
2368 if(it != _underlay_streams.end()) {
2369 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2371 if(gm == other._underlay_mirrors.end()) {
2372 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2376 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2378 _underlay_streams.erase(it);
2379 other._underlay_mirrors.erase(gm);
2381 if(underlay_xml_node) {
2382 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2388 RouteTimeAxisView::set_button_names ()
2390 rec_enable_button_label.set_text (_("r"));
2392 if (Config->get_solo_control_is_listen_control()) {
2393 switch (Config->get_listen_position()) {
2394 case AfterFaderListen:
2395 solo_button_label.set_text (_("A"));
2397 case PreFaderListen:
2398 solo_button_label.set_text (_("P"));
2402 solo_button_label.set_text (_("s"));
2405 mute_button_label.set_text (_("m"));