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/utils.h"
59 #include "evoral/Parameter.hpp"
61 #include "ardour_ui.h"
62 #include "route_time_axis.h"
63 #include "automation_time_axis.h"
64 #include "canvas_impl.h"
65 #include "crossfade_view.h"
67 #include "gui_thread.h"
69 #include "playlist_selector.h"
70 #include "point_selection.h"
72 #include "public_editor.h"
73 #include "region_view.h"
74 #include "rgb_macros.h"
75 #include "selection.h"
76 #include "simplerect.h"
77 #include "streamview.h"
79 #include "route_group_menu.h"
81 #include "ardour/track.h"
85 using namespace ARDOUR;
87 using namespace Gtkmm2ext;
89 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)
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;
128 if (!_route->is_hidden()) {
129 _marked_for_display = true;
132 timestretch_rect = 0;
134 destructive_track_mode_item = 0;
135 normal_track_mode_item = 0;
136 non_layered_track_mode_item = 0;
138 ignore_toggle = false;
140 route_group_button.set_name ("TrackGroupButton");
141 playlist_button.set_name ("TrackPlaylistButton");
142 automation_button.set_name ("TrackAutomationButton");
143 size_button.set_name ("TrackSizeButton");
144 visual_button.set_name ("TrackVisualButton");
145 hide_button.set_name ("TrackRemoveButton");
147 route_group_button.unset_flags (Gtk::CAN_FOCUS);
148 playlist_button.unset_flags (Gtk::CAN_FOCUS);
149 automation_button.unset_flags (Gtk::CAN_FOCUS);
150 size_button.unset_flags (Gtk::CAN_FOCUS);
151 visual_button.unset_flags (Gtk::CAN_FOCUS);
152 hide_button.unset_flags (Gtk::CAN_FOCUS);
154 hide_button.add (*(manage (new Image (::get_icon("hide")))));
155 hide_button.show_all ();
157 route_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
158 playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
159 automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
160 size_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::size_click), false);
161 visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click));
162 hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click));
164 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
165 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
166 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
167 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
173 rec_enable_button->remove ();
175 switch (track()->mode()) {
177 case ARDOUR::NonLayered:
178 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
180 case ARDOUR::Destructive:
181 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
184 rec_enable_button->show_all ();
186 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
187 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release), false);
188 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
189 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
191 rec_enable_button->set_sensitive (_session.writable());
194 controls_hbox.pack_start(gm.get_level_meter(), false, false);
195 _route->meter_change.connect (mem_fun(*this, &RouteTimeAxisView::meter_changed));
196 _route->input()->changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
197 _route->output()->changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
199 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
200 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
202 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
203 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
205 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
206 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
207 ARDOUR_UI::instance()->tooltips().set_tip(route_group_button, _("Route Group"));
208 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
209 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
210 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
211 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
212 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
218 /* old school - when we used to put an extra row of buttons in place */
220 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
221 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
222 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
223 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
227 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
230 if (is_track() && track()->mode() == ARDOUR::Normal) {
231 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
236 _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
237 _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
238 _route->processors_changed.connect (mem_fun(*this, &RouteTimeAxisView::processors_changed));
239 _route->NameChanged.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
240 _route->solo_isolated_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
245 track()->TrackModeChanged.connect (mem_fun(*this, &RouteTimeAxisView::track_mode_changed));
246 track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
247 track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
248 get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed));
250 /* pick up the correct freeze state */
255 _editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
256 ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
258 route_group_menu = new RouteGroupMenu (
260 (RouteGroup::Property) (RouteGroup::Mute | RouteGroup::Solo | RouteGroup::Edit)
263 route_group_menu->GroupSelected.connect (mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
265 gm.get_gain_slider().signal_scroll_event().connect(mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
266 gm.get_gain_slider().set_name ("TrackGainFader");
269 RouteTimeAxisView::~RouteTimeAxisView ()
271 GoingAway (); /* EMIT_SIGNAL */
273 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
277 delete playlist_menu;
280 delete playlist_action_menu;
281 playlist_action_menu = 0;
286 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
290 _automation_tracks.clear ();
292 delete route_group_menu;
296 RouteTimeAxisView::post_construct ()
298 /* map current state of the route */
300 update_diskstream_display ();
302 subplugin_menu.items().clear ();
303 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
304 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
305 reset_processor_automation_curves ();
309 RouteTimeAxisView::edit_click (GdkEventButton *ev)
311 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
312 _route->set_route_group (0, this);
316 route_group_menu->rebuild (_route->route_group ());
317 route_group_menu->popup (ev->button, ev->time);
323 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
325 _route->set_route_group (eg, this);
329 RouteTimeAxisView::playlist_changed ()
335 RouteTimeAxisView::label_view ()
337 string x = _route->name();
339 if (x != name_entry.get_text()) {
340 name_entry.set_text (x);
343 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
347 RouteTimeAxisView::route_name_changed ()
353 RouteTimeAxisView::take_name_changed (void *src)
362 RouteTimeAxisView::playlist_click ()
364 // always build a new action menu
366 delete playlist_action_menu;
368 playlist_action_menu = new Menu;
369 playlist_action_menu->set_name ("ArdourContextMenu");
371 build_playlist_menu (playlist_action_menu);
373 conditionally_add_to_selection ();
374 playlist_action_menu->popup (1, gtk_get_current_event_time());
378 RouteTimeAxisView::automation_click ()
380 conditionally_add_to_selection ();
381 build_automation_action_menu ();
382 automation_action_menu->popup (1, gtk_get_current_event_time());
386 RouteTimeAxisView::set_state (const XMLNode& node)
388 TimeAxisView::set_state (node);
390 XMLNodeList kids = node.children();
391 XMLNodeConstIterator iter;
392 const XMLProperty* prop;
394 if (_view && (prop = node.property ("layer-display"))) {
395 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
398 for (iter = kids.begin(); iter != kids.end(); ++iter) {
399 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
400 if ((prop = (*iter)->property ("automation-id")) != 0) {
402 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
403 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
404 create_automation_child(param, show);
406 warning << "Automation child has no ID" << endmsg;
415 RouteTimeAxisView::build_automation_action_menu ()
417 using namespace Menu_Helpers;
419 automation_action_menu = manage (new Menu);
420 MenuList& automation_items = automation_action_menu->items();
421 automation_action_menu->set_name ("ArdourContextMenu");
423 automation_items.push_back (MenuElem (_("Show all automation"),
424 mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
426 automation_items.push_back (MenuElem (_("Show existing automation"),
427 mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
429 automation_items.push_back (MenuElem (_("Hide all automation"),
430 mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
432 if (subplugin_menu.get_attach_widget())
433 subplugin_menu.detach();
435 automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
436 automation_items.back().set_sensitive (!subplugin_menu.items().empty());
438 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
439 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
441 automation_items.push_back (SeparatorElem());
443 delete i->second->menu_item;
445 automation_items.push_back(CheckMenuElem (_route->describe_parameter(i->second->param),
446 bind (mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
448 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&automation_items.back());
450 i->second->menu_item->set_active(show_automation(i->second->param));
451 //i->second->menu_item->set_active(false);
456 RouteTimeAxisView::build_display_menu ()
458 using namespace Menu_Helpers;
460 /* get the size menu ready */
466 TimeAxisView::build_display_menu ();
468 /* now fill it with our stuff */
470 MenuList& items = display_menu->items();
471 display_menu->set_name ("ArdourContextMenu");
473 items.push_back (MenuElem (_("Height"), *size_menu));
474 items.push_back (MenuElem (_("Color"), mem_fun(*this, &RouteTimeAxisView::select_track_color)));
476 items.push_back (SeparatorElem());
478 if (!Profile->get_sae()) {
479 items.push_back (MenuElem (_("Remote Control ID..."), mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
480 /* rebuild this every time */
481 build_automation_action_menu ();
482 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
483 items.push_back (SeparatorElem());
486 // Hook for derived classes to add type specific stuff
487 append_extra_display_menu_items ();
488 items.push_back (SeparatorElem());
492 Menu *layers_menu = manage(new Menu);
493 MenuList &layers_items = layers_menu->items();
494 layers_menu->set_name("ArdourContextMenu");
496 RadioMenuItem::Group layers_group;
498 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
499 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
500 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
501 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
503 items.push_back (MenuElem (_("Layers"), *layers_menu));
505 Menu* alignment_menu = manage (new Menu);
506 MenuList& alignment_items = alignment_menu->items();
507 alignment_menu->set_name ("ArdourContextMenu");
509 RadioMenuItem::Group align_group;
511 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
512 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
513 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
514 if (get_diskstream()->alignment_style() == ExistingMaterial)
515 align_existing_item->set_active();
517 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
518 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
519 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
520 if (get_diskstream()->alignment_style() == CaptureTime)
521 align_capture_item->set_active();
523 if (!Profile->get_sae()) {
524 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
525 get_diskstream()->AlignmentStyleChanged.connect (
526 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
528 RadioMenuItem::Group mode_group;
529 items.push_back (RadioMenuElem (mode_group, _("Normal mode"), bind (
530 mem_fun (*this, &RouteTimeAxisView::set_track_mode),
532 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
534 items.push_back (RadioMenuElem (mode_group, _("Tape mode"), bind (
535 mem_fun (*this, &RouteTimeAxisView::set_track_mode),
536 ARDOUR::Destructive)));
537 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
539 items.push_back (RadioMenuElem (mode_group, _("No layering mode"),
540 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
541 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
545 switch (track()->mode()) {
546 case ARDOUR::Destructive:
547 destructive_track_mode_item->set_active ();
550 normal_track_mode_item->set_active ();
552 case ARDOUR::NonLayered:
553 non_layered_track_mode_item->set_active ();
558 get_diskstream()->AlignmentStyleChanged.connect (
559 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
561 mode_menu = build_mode_menu();
563 items.push_back (MenuElem (_("Mode"), *mode_menu));
565 color_mode_menu = build_color_mode_menu();
567 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
569 items.push_back (SeparatorElem());
572 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
573 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
574 route_active_menu_item->set_active (_route->active());
576 items.push_back (SeparatorElem());
577 items.push_back (MenuElem (_("Hide"), mem_fun(*this, &RouteTimeAxisView::hide_click)));
578 if (!Profile->get_sae()) {
579 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
581 items.push_front (SeparatorElem());
582 items.push_front (MenuElem (_("Delete"), mem_fun(*this, &RouteUI::remove_this_route)));
586 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
589 item_2->set_active ();
594 RouteTimeAxisView::set_track_mode (TrackMode mode)
597 RadioMenuItem* other_item;
598 RadioMenuItem* other_item_2;
602 item = normal_track_mode_item;
603 other_item = non_layered_track_mode_item;
604 other_item_2 = destructive_track_mode_item;
606 case ARDOUR::NonLayered:
607 item = non_layered_track_mode_item;
608 other_item = normal_track_mode_item;
609 other_item_2 = destructive_track_mode_item;
611 case ARDOUR::Destructive:
612 item = destructive_track_mode_item;
613 other_item = normal_track_mode_item;
614 other_item_2 = non_layered_track_mode_item;
617 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
622 if (item && other_item && other_item_2 && item->get_active() && track()->mode() != mode) {
623 _set_track_mode (track().get(), mode, other_item, other_item_2);
628 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
632 if (!track->can_use_mode (mode, needs_bounce)) {
636 Glib::signal_idle().connect (bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
639 cerr << "would bounce this one\n";
644 track->set_mode (mode);
646 rec_enable_button->remove ();
649 case ARDOUR::NonLayered:
651 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
653 case ARDOUR::Destructive:
654 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
658 rec_enable_button->show_all ();
662 RouteTimeAxisView::track_mode_changed ()
666 switch (track()->mode()) {
668 item = normal_track_mode_item;
670 case ARDOUR::NonLayered:
671 item = non_layered_track_mode_item;
673 case ARDOUR::Destructive:
674 item = destructive_track_mode_item;
677 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
686 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
692 TimeAxisView::show_timestretch (start, end);
702 /* check that the time selection was made in our route, or our route group.
703 remember that route_group() == 0 implies the route is *not* in a edit group.
706 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
707 /* this doesn't apply to us */
711 /* ignore it if our edit group is not active */
713 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
718 if (timestretch_rect == 0) {
719 timestretch_rect = new SimpleRect (*canvas_display ());
720 timestretch_rect->property_x1() = 0.0;
721 timestretch_rect->property_y1() = 0.0;
722 timestretch_rect->property_x2() = 0.0;
723 timestretch_rect->property_y2() = 0.0;
724 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
725 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
728 timestretch_rect->show ();
729 timestretch_rect->raise_to_top ();
731 x1 = start / _editor.get_current_zoom();
732 x2 = (end - 1) / _editor.get_current_zoom();
733 y2 = current_height() - 2;
735 timestretch_rect->property_x1() = x1;
736 timestretch_rect->property_y1() = 1.0;
737 timestretch_rect->property_x2() = x2;
738 timestretch_rect->property_y2() = y2;
742 RouteTimeAxisView::hide_timestretch ()
744 TimeAxisView::hide_timestretch ();
746 if (timestretch_rect) {
747 timestretch_rect->hide ();
752 RouteTimeAxisView::show_selection (TimeSelection& ts)
756 /* ignore it if our edit group is not active or if the selection was started
757 in some other track or route group (remember that route_group() == 0 means
758 that the track is not in an route group).
761 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
762 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
768 TimeAxisView::show_selection (ts);
772 RouteTimeAxisView::set_height (uint32_t h)
775 bool height_changed = (height == 0) || (h != height);
776 gm.get_level_meter().setup_meters (gmlen);
778 TimeAxisView::set_height (h);
783 _view->set_height ((double) current_height());
787 snprintf (buf, sizeof (buf), "%u", height);
788 xml_node->add_property ("height", buf);
790 if (height >= hNormal) {
795 gm.get_gain_slider().show();
797 if (!_route || _route->is_control()) {
802 if (rec_enable_button)
803 rec_enable_button->show();
805 route_group_button.show();
807 visual_button.show();
809 automation_button.show();
811 if (is_track() && track()->mode() == ARDOUR::Normal) {
812 playlist_button.show();
815 } else if (height >= hSmaller) {
821 gm.get_gain_slider().hide();
823 if (!_route || _route->is_control()) {
828 if (rec_enable_button)
829 rec_enable_button->show();
831 route_group_button.hide ();
833 visual_button.hide ();
835 automation_button.hide ();
837 if (is_track() && track()->mode() == ARDOUR::Normal) {
838 playlist_button.hide ();
844 /* don't allow name_entry to be hidden while
845 it has focus, otherwise the GUI becomes unusable.
848 if (name_entry.has_focus()) {
849 if (name_entry.get_text() != _route->name()) {
850 name_entry_changed ();
852 controls_ebox.grab_focus ();
858 gm.get_gain_slider().hide();
861 if (rec_enable_button)
862 rec_enable_button->hide();
864 route_group_button.hide ();
866 visual_button.hide ();
868 automation_button.hide ();
869 playlist_button.hide ();
870 name_label.set_text (_route->name());
873 if (height_changed) {
874 /* only emit the signal if the height really changed */
875 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
880 RouteTimeAxisView::select_track_color ()
882 if (RouteUI::choose_color ()) {
885 _view->apply_color (_color, StreamView::RegionColor);
891 RouteTimeAxisView::reset_samples_per_unit ()
893 set_samples_per_unit (_editor.get_current_zoom());
897 RouteTimeAxisView::set_samples_per_unit (double spu)
901 if (get_diskstream() != 0) {
902 speed = get_diskstream()->speed();
906 _view->set_samples_per_unit (spu * speed);
909 TimeAxisView::set_samples_per_unit (spu * speed);
913 RouteTimeAxisView::align_style_changed ()
915 switch (get_diskstream()->alignment_style()) {
916 case ExistingMaterial:
917 if (!align_existing_item->get_active()) {
918 align_existing_item->set_active();
922 if (!align_capture_item->get_active()) {
923 align_capture_item->set_active();
930 RouteTimeAxisView::set_align_style (AlignStyle style)
935 case ExistingMaterial:
936 item = align_existing_item;
939 item = align_capture_item;
942 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
947 if (item->get_active()) {
948 get_diskstream()->set_align_style (style);
953 RouteTimeAxisView::rename_current_playlist ()
955 ArdourPrompter prompter (true);
958 boost::shared_ptr<Diskstream> ds = get_diskstream();
959 if (!ds || ds->destructive())
962 boost::shared_ptr<Playlist> pl = ds->playlist();
966 prompter.set_prompt (_("Name for playlist"));
967 prompter.set_initial_text (pl->name());
968 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
969 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
971 switch (prompter.run ()) {
972 case Gtk::RESPONSE_ACCEPT:
973 prompter.get_result (name);
985 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
987 std::string ret (basename);
989 std::string const group_string = "." + route_group()->name() + ".";
991 // iterate through all playlists
993 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
994 std::string tmp = (*i)->name();
996 std::string::size_type idx = tmp.find(group_string);
997 // find those which belong to this group
998 if (idx != string::npos) {
999 tmp = tmp.substr(idx + group_string.length());
1001 // and find the largest current number
1002 int x = atoi(tmp.c_str());
1003 if (x > maxnumber) {
1012 snprintf (buf, sizeof(buf), "%d", maxnumber);
1014 ret = this->name() + "." + route_group()->name () + "." + buf;
1020 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1024 boost::shared_ptr<Diskstream> ds = get_diskstream();
1025 if (!ds || ds->destructive())
1028 boost::shared_ptr<const Playlist> pl = ds->playlist();
1034 if (route_group() && route_group()->is_active()) {
1035 name = resolve_new_group_playlist_name(name, playlists_before_op);
1038 while (_session.playlist_by_name(name)) {
1039 name = Playlist::bump_name (name, _session);
1042 // TODO: The prompter "new" button should be de-activated if the user
1043 // specifies a playlist name which already exists in the session.
1047 ArdourPrompter prompter (true);
1049 prompter.set_prompt (_("Name for Playlist"));
1050 prompter.set_initial_text (name);
1051 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1052 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1053 prompter.show_all ();
1055 switch (prompter.run ()) {
1056 case Gtk::RESPONSE_ACCEPT:
1057 prompter.get_result (name);
1065 if (name.length()) {
1066 ds->use_copy_playlist ();
1067 ds->playlist()->set_name (name);
1072 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1076 boost::shared_ptr<Diskstream> ds = get_diskstream();
1077 if (!ds || ds->destructive())
1080 boost::shared_ptr<const Playlist> pl = ds->playlist();
1086 if (route_group() && route_group()->is_active()) {
1087 name = resolve_new_group_playlist_name(name,playlists_before_op);
1090 while (_session.playlist_by_name(name)) {
1091 name = Playlist::bump_name (name, _session);
1097 ArdourPrompter prompter (true);
1099 prompter.set_prompt (_("Name for Playlist"));
1100 prompter.set_initial_text (name);
1101 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1102 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1104 switch (prompter.run ()) {
1105 case Gtk::RESPONSE_ACCEPT:
1106 prompter.get_result (name);
1114 if (name.length()) {
1115 ds->use_new_playlist ();
1116 ds->playlist()->set_name (name);
1121 RouteTimeAxisView::clear_playlist ()
1123 boost::shared_ptr<Diskstream> ds = get_diskstream();
1124 if (!ds || ds->destructive())
1127 boost::shared_ptr<Playlist> pl = ds->playlist();
1131 _editor.clear_playlist (pl);
1135 RouteTimeAxisView::speed_changed ()
1137 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
1141 RouteTimeAxisView::diskstream_changed ()
1143 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::update_diskstream_display));
1147 RouteTimeAxisView::update_diskstream_display ()
1149 if (!get_diskstream()) // bus
1156 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1158 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1160 /* special case: select/deselect all tracks */
1161 if (_editor.get_selection().selected (this)) {
1162 _editor.get_selection().clear_tracks ();
1164 _editor.select_all_tracks ();
1170 PublicEditor::TrackViewList* tracks = _editor.get_valid_views (this, _route->route_group());
1172 switch (Keyboard::selection_type (ev->state)) {
1173 case Selection::Toggle:
1174 _editor.get_selection().toggle (*tracks);
1177 case Selection::Set:
1178 _editor.get_selection().set (*tracks);
1181 case Selection::Extend:
1182 if (tracks->size() > 1) {
1183 /* add each one, do not "extend" */
1184 _editor.get_selection().add (*tracks);
1186 /* extend to the single track */
1187 _editor.extend_selection_to_track (*tracks->front());
1191 case Selection::Add:
1192 _editor.get_selection().add (*tracks);
1200 RouteTimeAxisView::set_selected_points (PointSelection& points)
1202 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1203 (*i)->set_selected_points (points);
1208 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1211 _view->set_selected_regionviews (regions);
1215 /** Add the selectable things that we have to a list.
1216 * @param results List to add things to.
1219 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1223 if (get_diskstream() != 0) {
1224 speed = get_diskstream()->speed();
1227 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1228 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1230 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1231 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1234 /* pick up visible automation tracks */
1236 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1237 if (!(*i)->hidden()) {
1238 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1244 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1247 _view->get_inverted_selectables (sel, results);
1250 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1251 if (!(*i)->hidden()) {
1252 (*i)->get_inverted_selectables (sel, results);
1260 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1262 return (_show_automation.find(param) != _show_automation.end());
1265 /** Retuns 0 if track for \a param doesn't exist.
1267 RouteTimeAxisView::RouteAutomationNode*
1268 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1270 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1272 if (i != _automation_tracks.end()) {
1279 /** Shorthand for GainAutomation, etc.
1281 RouteTimeAxisView::RouteAutomationNode*
1282 RouteTimeAxisView::automation_track (AutomationType type)
1284 return automation_track (Evoral::Parameter(type));
1288 RouteTimeAxisView::route_group () const
1290 return _route->route_group();
1294 RouteTimeAxisView::name() const
1296 return _route->name();
1299 boost::shared_ptr<Playlist>
1300 RouteTimeAxisView::playlist () const
1302 boost::shared_ptr<Diskstream> ds;
1304 if ((ds = get_diskstream()) != 0) {
1305 return ds->playlist();
1307 return boost::shared_ptr<Playlist> ();
1312 RouteTimeAxisView::name_entry_changed ()
1316 x = name_entry.get_text ();
1318 if (x == _route->name()) {
1322 strip_whitespace_edges(x);
1324 if (x.length() == 0) {
1325 name_entry.set_text (_route->name());
1329 if (!_session.route_name_unique (x)) {
1330 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1331 name_entry.set_text (_route->name());
1332 } else if (_session.route_name_internal (x)) {
1333 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1334 name_entry.set_text (_route->name());
1336 _route->set_name (x);
1341 RouteTimeAxisView::visual_click ()
1343 popup_display_menu (0);
1347 RouteTimeAxisView::hide_click ()
1349 // LAME fix for hide_button refresh fix
1350 hide_button.set_sensitive(false);
1352 _editor.hide_track_in_display (*this);
1354 hide_button.set_sensitive(true);
1357 boost::shared_ptr<Region>
1358 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1360 boost::shared_ptr<Diskstream> stream;
1361 boost::shared_ptr<Playlist> playlist;
1363 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1364 return playlist->find_next_region (pos, point, dir);
1367 return boost::shared_ptr<Region> ();
1371 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1373 boost::shared_ptr<Diskstream> stream;
1374 boost::shared_ptr<Playlist> playlist;
1376 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1377 return playlist->find_next_region_boundary (pos, dir);
1384 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1386 boost::shared_ptr<Playlist> what_we_got;
1387 boost::shared_ptr<Diskstream> ds = get_diskstream();
1388 boost::shared_ptr<Playlist> playlist;
1392 /* route is a bus, not a track */
1396 playlist = ds->playlist();
1398 TimeSelection time (selection.time);
1399 float speed = ds->speed();
1400 if (speed != 1.0f) {
1401 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1402 (*i).start = session_frame_to_track_frame((*i).start, speed);
1403 (*i).end = session_frame_to_track_frame((*i).end, speed);
1407 XMLNode &before = playlist->get_state();
1410 if ((what_we_got = playlist->cut (time)) != 0) {
1411 _editor.get_cut_buffer().add (what_we_got);
1412 _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1417 if ((what_we_got = playlist->copy (time)) != 0) {
1418 _editor.get_cut_buffer().add (what_we_got);
1423 if ((what_we_got = playlist->cut (time)) != 0) {
1424 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1425 what_we_got->release ();
1435 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1441 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1442 PlaylistSelection::iterator p;
1444 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1446 if (p == selection.playlists.end()) {
1450 if (get_diskstream()->speed() != 1.0f) {
1451 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1454 XMLNode &before = playlist->get_state();
1455 playlist->paste (*p, pos, times);
1456 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1462 TimeAxisView::Children
1463 RouteTimeAxisView::get_child_list()
1465 TimeAxisView::Children redirect_children;
1467 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1468 if (!(*i)->hidden()) {
1469 redirect_children.push_back(*i);
1472 return redirect_children;
1477 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1479 using namespace Menu_Helpers;
1481 if (!menu || !is_track()) {
1485 MenuList& playlist_items = menu->items();
1486 menu->set_name ("ArdourContextMenu");
1487 playlist_items.clear();
1489 delete playlist_menu;
1491 playlist_menu = new Menu;
1492 playlist_menu->set_name ("ArdourContextMenu");
1494 vector<boost::shared_ptr<Playlist> > playlists;
1495 boost::shared_ptr<Diskstream> ds = get_diskstream();
1496 RadioMenuItem::Group playlist_group;
1498 _session.get_playlists (playlists);
1500 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1502 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1503 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1504 boost::weak_ptr<Playlist> (*i))));
1506 if (ds->playlist()->id() == (*i)->id()) {
1507 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1509 } else if (ds->playlist()->id() == (*i)->id()) {
1510 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1511 boost::weak_ptr<Playlist>(*i))));
1512 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1517 playlist_items.push_back (SeparatorElem());
1518 playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1519 playlist_items.push_back (SeparatorElem());
1521 if (!route_group() || !route_group()->is_active()) {
1522 playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
1523 playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1526 // Use a label which tells the user what is happening
1527 playlist_items.push_back (MenuElem (_("New Take"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
1528 playlist_items.push_back (MenuElem (_("Copy Take"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1532 playlist_items.push_back (SeparatorElem());
1533 playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1534 playlist_items.push_back (SeparatorElem());
1536 playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1540 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1542 assert (is_track());
1544 boost::shared_ptr<Playlist> pl (wpl.lock());
1550 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1553 if (get_diskstream()->playlist() == apl) {
1554 // radio button cotnrols mean this function is called for both the
1555 // old and new playlist
1558 get_diskstream()->use_playlist (apl);
1561 if (route_group() && route_group()->is_active()) {
1562 //PBD::stacktrace(cerr, 20);
1563 std::string group_string = "."+route_group()->name()+".";
1565 std::string take_name = apl->name();
1566 std::string::size_type idx = take_name.find(group_string);
1568 if (idx == std::string::npos)
1571 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1573 for (list<Route*>::const_iterator i = route_group()->route_list().begin(); i != route_group()->route_list().end(); ++i) {
1574 if ( (*i) == this->route().get()) {
1578 std::string playlist_name = (*i)->name()+group_string+take_name;
1580 Track *track = dynamic_cast<Track *>(*i);
1582 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1586 boost::shared_ptr<Playlist> ipl = session().playlist_by_name(playlist_name);
1588 // No playlist for this track for this take yet, make it
1589 track->diskstream()->use_new_playlist();
1590 track->diskstream()->playlist()->set_name(playlist_name);
1592 track->diskstream()->use_playlist(ipl);
1602 RouteTimeAxisView::show_playlist_selector ()
1604 _editor.playlist_selector().show_for (this);
1608 RouteTimeAxisView::map_frozen ()
1614 ENSURE_GUI_THREAD (mem_fun(*this, &RouteTimeAxisView::map_frozen));
1616 switch (track()->freeze_state()) {
1618 playlist_button.set_sensitive (false);
1619 rec_enable_button->set_sensitive (false);
1622 playlist_button.set_sensitive (true);
1623 rec_enable_button->set_sensitive (true);
1629 RouteTimeAxisView::color_handler ()
1631 //case cTimeStretchOutline:
1632 if (timestretch_rect) {
1633 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1635 //case cTimeStretchFill:
1636 if (timestretch_rect) {
1637 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1644 RouteTimeAxisView::toggle_automation_track (Evoral::Parameter param)
1646 RouteAutomationNode* node = automation_track(param);
1651 bool showit = node->menu_item->get_active();
1653 if (showit != node->track->marked_for_display()) {
1655 node->track->set_marked_for_display (true);
1656 node->track->canvas_display()->show();
1657 node->track->get_state_node()->add_property ("shown", X_("yes"));
1659 node->track->set_marked_for_display (false);
1660 node->track->hide ();
1661 node->track->get_state_node()->add_property ("shown", X_("no"));
1664 /* now trigger a redisplay */
1667 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1673 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1675 RouteAutomationNode* ran = automation_track(param);
1680 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1681 _show_automation.erase(param);
1682 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1684 if (ran->menu_item && !_hidden) {
1685 ran->menu_item->set_active (false);
1688 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1693 RouteTimeAxisView::show_all_automation ()
1697 /* Show our automation */
1699 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1700 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1701 i->second->track->set_marked_for_display (true);
1702 i->second->track->canvas_display()->show();
1703 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1704 i->second->menu_item->set_active(true);
1708 /* Show processor automation */
1710 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1711 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1712 if ((*ii)->view == 0) {
1713 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1716 (*ii)->menu_item->set_active (true);
1724 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1728 RouteTimeAxisView::show_existing_automation ()
1732 /* Show our automation */
1734 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1735 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1736 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1737 i->second->track->set_marked_for_display (true);
1738 i->second->track->canvas_display()->show();
1739 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1740 i->second->menu_item->set_active(true);
1745 /* Show processor automation */
1747 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1748 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1749 if ((*ii)->view != 0 && (*i)->processor->data().control((*ii)->what)->list()->size() > 0) {
1750 (*ii)->menu_item->set_active (true);
1757 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1761 RouteTimeAxisView::hide_all_automation ()
1765 /* Hide our automation */
1767 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1768 i->second->track->set_marked_for_display (false);
1769 i->second->track->hide ();
1770 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1771 i->second->menu_item->set_active (false);
1774 /* Hide processor automation */
1776 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1777 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1778 (*ii)->menu_item->set_active (false);
1782 _show_automation.clear();
1785 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1790 RouteTimeAxisView::region_view_added (RegionView* rv)
1792 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1793 if(is_audio_track()) {
1794 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1795 boost::shared_ptr<AutomationTimeAxisView> atv;
1797 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1803 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1804 (*i)->add_ghost(rv);
1808 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1810 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1816 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1818 parent.remove_processor_automation_node (this);
1822 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1825 remove_child (pan->view);
1829 RouteTimeAxisView::ProcessorAutomationNode*
1830 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1832 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1834 if ((*i)->processor == processor) {
1836 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1837 if ((*ii)->what == what) {
1848 legalize_for_xml_node (string str)
1850 string::size_type pos;
1851 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1857 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1858 legal.replace (pos, 1, "_");
1867 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1870 ProcessorAutomationNode* pan;
1872 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1873 fatal << _("programming error: ")
1874 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1875 processor->name(), what)
1885 name = processor->describe_parameter (what);
1887 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1891 char state_name[256];
1892 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1894 boost::shared_ptr<AutomationControl> control
1895 = boost::dynamic_pointer_cast<AutomationControl>(processor->data().control(what, true));
1897 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1898 new AutomationTimeAxisView (_session, _route, processor, control,
1899 _editor, *this, false, parent_canvas, name, state_name));
1901 pan->view->Hiding.connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1903 if (!pan->view->marked_for_display()) {
1906 pan->menu_item->set_active (true);
1909 add_child (pan->view);
1912 _view->foreach_regionview (mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1915 processor->mark_automation_visible (what, true);
1919 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1922 pan->menu_item->set_active (false);
1925 i->mark_automation_visible (pan->what, false);
1927 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1931 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1933 boost::shared_ptr<Processor> processor (p.lock ());
1938 set<Evoral::Parameter> s;
1939 boost::shared_ptr<AutomationLine> al;
1941 processor->what_has_visible_data (s);
1943 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1945 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1948 add_processor_automation_curve (processor, (*i));
1954 RouteTimeAxisView::add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1956 using namespace Menu_Helpers;
1963 track->Hiding.connect (bind (mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1965 bool hideit = (!show);
1967 if ((node = track->get_state_node()) != 0) {
1968 if ((prop = node->property ("shown")) != 0) {
1969 if (string_is_affirmative (prop->value())) {
1975 _automation_tracks.insert(std::make_pair(param, new RouteAutomationNode(param, NULL, track)));
1980 _show_automation.insert (param);
1984 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1988 build_display_menu();
1993 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
1995 boost::shared_ptr<Processor> processor (p.lock ());
2000 if (!processor->visible ()) {
2004 using namespace Menu_Helpers;
2005 ProcessorAutomationInfo *rai;
2006 list<ProcessorAutomationInfo*>::iterator x;
2008 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2009 std::set<Evoral::Parameter> has_visible_automation;
2011 processor->what_has_visible_data(has_visible_automation);
2013 if (automatable.empty()) {
2017 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2018 if ((*x)->processor == processor) {
2023 if (x == processor_automation.end()) {
2025 rai = new ProcessorAutomationInfo (processor);
2026 processor_automation.push_back (rai);
2034 /* any older menu was deleted at the top of processors_changed()
2035 when we cleared the subplugin menu.
2038 rai->menu = manage (new Menu);
2039 MenuList& items = rai->menu->items();
2040 rai->menu->set_name ("ArdourContextMenu");
2044 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2046 ProcessorAutomationNode* pan;
2047 CheckMenuItem* mitem;
2049 string name = processor->describe_parameter (*i);
2051 items.push_back (CheckMenuElem (name));
2052 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2054 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2055 mitem->set_active(true);
2058 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2062 pan = new ProcessorAutomationNode (*i, mitem, *this);
2064 rai->lines.push_back (pan);
2068 pan->menu_item = mitem;
2072 mitem->signal_toggled().connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2075 /* add the menu for this processor, because the subplugin
2076 menu is always cleared at the top of processors_changed().
2077 this is the result of some poor design in gtkmm and/or
2081 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2086 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2087 RouteTimeAxisView::ProcessorAutomationNode* pan)
2089 bool showit = pan->menu_item->get_active();
2090 bool redraw = false;
2092 if (pan->view == 0 && showit) {
2093 add_processor_automation_curve (rai->processor, pan->what);
2097 if (pan->view && showit != pan->view->marked_for_display()) {
2100 pan->view->set_marked_for_display (true);
2101 pan->view->canvas_display()->show();
2102 pan->view->canvas_background()->show();
2104 rai->processor->mark_automation_visible (pan->what, true);
2105 pan->view->set_marked_for_display (false);
2113 if (redraw && !no_redraw) {
2115 /* now trigger a redisplay */
2117 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2123 RouteTimeAxisView::processors_changed ()
2125 using namespace Menu_Helpers;
2127 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2128 (*i)->valid = false;
2131 subplugin_menu.items().clear ();
2133 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2134 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2136 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2138 list<ProcessorAutomationInfo*>::iterator tmp;
2146 processor_automation.erase (i);
2153 /* change in visibility was possible */
2155 _route->gui_changed ("visible_tracks", this);
2158 boost::shared_ptr<AutomationLine>
2159 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2161 ProcessorAutomationNode* pan;
2163 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2169 return boost::shared_ptr<AutomationLine>();
2173 RouteTimeAxisView::reset_processor_automation_curves ()
2175 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2181 RouteTimeAxisView::update_rec_display ()
2183 RouteUI::update_rec_display ();
2184 name_entry.set_sensitive (!_route->record_enabled());
2188 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2191 _view->set_layer_display (d);
2195 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2199 RouteTimeAxisView::layer_display () const
2202 return _view->layer_display ();
2205 /* we don't know, since we don't have a _view, so just return something */
2211 boost::shared_ptr<AutomationTimeAxisView>
2212 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2214 AutomationTracks::iterator i = _automation_tracks.find(param);
2215 if (i != _automation_tracks.end())
2216 return i->second->track;
2218 return boost::shared_ptr<AutomationTimeAxisView>();
2222 RouteTimeAxisView::fast_update ()
2224 gm.get_level_meter().update_meters ();
2228 RouteTimeAxisView::hide_meter ()
2231 gm.get_level_meter().hide_meters ();
2235 RouteTimeAxisView::show_meter ()
2241 RouteTimeAxisView::reset_meter ()
2243 if (Config->get_show_track_meters()) {
2244 gm.get_level_meter().setup_meters (height-5);
2251 RouteTimeAxisView::clear_meter ()
2253 gm.get_level_meter().clear_meters ();
2257 RouteTimeAxisView::meter_changed (void *src)
2259 ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::meter_changed), src));
2264 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2270 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu) {
2271 using namespace Menu_Helpers;
2273 if(!_underlay_streams.empty()) {
2274 MenuList& parent_items = parent_menu->items();
2275 Menu* gs_menu = manage (new Menu);
2276 gs_menu->set_name ("ArdourContextMenu");
2277 MenuList& gs_items = gs_menu->items();
2279 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2281 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2282 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2283 bind(mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2289 RouteTimeAxisView::set_underlay_state()
2291 if(!underlay_xml_node) {
2295 XMLNodeList nlist = underlay_xml_node->children();
2296 XMLNodeConstIterator niter;
2297 XMLNode *child_node;
2299 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2300 child_node = *niter;
2302 if(child_node->name() != "Underlay") {
2306 XMLProperty* prop = child_node->property ("id");
2308 PBD::ID id (prop->value());
2310 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2313 add_underlay(v->view(), false);
2322 RouteTimeAxisView::add_underlay(StreamView* v, bool update_xml)
2328 RouteTimeAxisView& other = v->trackview();
2330 if(find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2331 if(find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2332 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2336 _underlay_streams.push_back(v);
2337 other._underlay_mirrors.push_back(this);
2339 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::add_ghost));
2342 if(!underlay_xml_node) {
2344 underlay_xml_node = xml_node->add_child("Underlays");
2347 XMLNode* node = underlay_xml_node->add_child("Underlay");
2348 XMLProperty* prop = node->add_property("id");
2349 prop->set_value(v->trackview().route()->id().to_s());
2355 RouteTimeAxisView::remove_underlay(StreamView* v)
2361 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2362 RouteTimeAxisView& other = v->trackview();
2364 if(it != _underlay_streams.end()) {
2365 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2367 if(gm == other._underlay_mirrors.end()) {
2368 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2372 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2374 _underlay_streams.erase(it);
2375 other._underlay_mirrors.erase(gm);
2377 if(underlay_xml_node) {
2378 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2384 RouteTimeAxisView::set_button_names ()
2386 rec_enable_button_label.set_text (_("r"));
2388 if (Config->get_solo_control_is_listen_control()) {
2389 switch (Config->get_listen_position()) {
2390 case AfterFaderListen:
2391 solo_button_label.set_text (_("A"));
2393 case PreFaderListen:
2394 solo_button_label.set_text (_("P"));
2398 solo_button_label.set_text (_("s"));
2401 mute_button_label.set_text (_("m"));