2 Copyright (C) 2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <sigc++/bind.h>
30 #include "pbd/error.h"
31 #include "pbd/stl_delete.h"
32 #include "pbd/whitespace.h"
33 #include "pbd/memento_command.h"
35 #include <gtkmm/menu.h>
36 #include <gtkmm/menuitem.h>
37 #include <gtkmm2ext/gtk_ui.h>
38 #include <gtkmm2ext/selector.h>
39 #include <gtkmm2ext/stop_signal.h>
40 #include <gtkmm2ext/bindable_button.h>
41 #include <gtkmm2ext/utils.h>
43 #include "ardour/amp.h"
44 #include "ardour/audioplaylist.h"
45 #include "ardour/diskstream.h"
46 #include "ardour/event_type_map.h"
47 #include "ardour/ladspa_plugin.h"
48 #include "ardour/location.h"
49 #include "ardour/panner.h"
50 #include "ardour/playlist.h"
51 #include "ardour/playlist.h"
52 #include "ardour/processor.h"
53 #include "ardour/profile.h"
54 #include "ardour/route_group.h"
55 #include "ardour/session.h"
56 #include "ardour/session_playlist.h"
57 #include "ardour/utils.h"
58 #include "evoral/Parameter.hpp"
60 #include "ardour_ui.h"
61 #include "route_time_axis.h"
62 #include "automation_time_axis.h"
63 #include "canvas_impl.h"
64 #include "crossfade_view.h"
66 #include "gui_thread.h"
68 #include "playlist_selector.h"
69 #include "point_selection.h"
71 #include "public_editor.h"
72 #include "region_view.h"
73 #include "rgb_macros.h"
74 #include "selection.h"
75 #include "simplerect.h"
76 #include "streamview.h"
78 #include "route_group_menu.h"
80 #include "ardour/track.h"
84 using namespace ARDOUR;
86 using namespace Gtkmm2ext;
88 using namespace Editing;
92 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
95 RouteTimeAxisView::setup_slider_pix ()
97 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
98 throw failed_constructor ();
102 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
105 , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
106 , parent_canvas (canvas)
107 , button_table (3, 3)
108 , route_group_button (_("g"))
109 , playlist_button (_("p"))
110 , size_button (_("h"))
111 , automation_button (_("a"))
112 , visual_button (_("v"))
113 , gm (sess, slider, true)
117 gm.set_controls (_route, _route->shared_peak_meter(), _route->gain_control(), _route->amp());
118 gm.get_level_meter().set_no_show_all();
119 gm.get_level_meter().setup_meters(50);
123 playlist_action_menu = 0;
124 automation_action_menu = 0;
127 if (!_route->is_hidden()) {
128 _marked_for_display = true;
131 timestretch_rect = 0;
133 destructive_track_mode_item = 0;
134 normal_track_mode_item = 0;
135 non_layered_track_mode_item = 0;
137 ignore_toggle = false;
139 route_group_button.set_name ("TrackGroupButton");
140 playlist_button.set_name ("TrackPlaylistButton");
141 automation_button.set_name ("TrackAutomationButton");
142 size_button.set_name ("TrackSizeButton");
143 visual_button.set_name ("TrackVisualButton");
144 hide_button.set_name ("TrackRemoveButton");
146 route_group_button.unset_flags (Gtk::CAN_FOCUS);
147 playlist_button.unset_flags (Gtk::CAN_FOCUS);
148 automation_button.unset_flags (Gtk::CAN_FOCUS);
149 size_button.unset_flags (Gtk::CAN_FOCUS);
150 visual_button.unset_flags (Gtk::CAN_FOCUS);
151 hide_button.unset_flags (Gtk::CAN_FOCUS);
153 hide_button.add (*(manage (new Image (::get_icon("hide")))));
154 hide_button.show_all ();
156 route_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
157 playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
158 automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
159 size_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::size_click), false);
160 visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click));
161 hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click));
163 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
164 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
165 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
166 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
172 rec_enable_button->remove ();
174 switch (track()->mode()) {
176 case ARDOUR::NonLayered:
177 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
179 case ARDOUR::Destructive:
180 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
183 rec_enable_button->show_all ();
185 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
186 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
187 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
188 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
192 controls_hbox.pack_start(gm.get_level_meter(), false, false);
193 _route->meter_change.connect (mem_fun(*this, &RouteTimeAxisView::meter_changed));
194 _route->input()->changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
195 _route->output()->changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
197 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
198 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
200 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
201 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
203 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
204 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
205 ARDOUR_UI::instance()->tooltips().set_tip(route_group_button, _("Route Group"));
206 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
207 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
208 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
209 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
210 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
216 /* old school - when we used to put an extra row of buttons in place */
218 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
219 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
220 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
221 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
225 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
228 if (is_track() && track()->mode() == ARDOUR::Normal) {
229 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
234 _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
235 _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
236 _route->processors_changed.connect (mem_fun(*this, &RouteTimeAxisView::processors_changed));
237 _route->NameChanged.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
238 _route->solo_isolated_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
243 track()->TrackModeChanged.connect (mem_fun(*this, &RouteTimeAxisView::track_mode_changed));
244 track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
245 track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
246 get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed));
248 /* pick up the correct freeze state */
253 _editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
254 ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
256 route_group_menu = new RouteGroupMenu (_session);
257 route_group_menu->GroupSelected.connect (mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
259 gm.get_gain_slider().signal_scroll_event().connect(mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
260 gm.get_gain_slider().set_name ("TrackGainFader");
263 RouteTimeAxisView::~RouteTimeAxisView ()
265 GoingAway (); /* EMIT_SIGNAL */
267 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
271 delete playlist_menu;
274 delete playlist_action_menu;
275 playlist_action_menu = 0;
280 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
284 _automation_tracks.clear ();
286 delete route_group_menu;
290 RouteTimeAxisView::post_construct ()
292 /* map current state of the route */
294 update_diskstream_display ();
296 subplugin_menu.items().clear ();
297 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
298 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
299 reset_processor_automation_curves ();
303 RouteTimeAxisView::set_playlist (boost::shared_ptr<Playlist> newplaylist)
305 boost::shared_ptr<Playlist> pl = playlist();
308 modified_connection.disconnect ();
309 modified_connection = pl->Modified.connect (mem_fun(*this, &RouteTimeAxisView::playlist_modified));
313 RouteTimeAxisView::playlist_modified ()
318 RouteTimeAxisView::edit_click (GdkEventButton *ev)
320 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
321 _route->set_route_group (0, this);
325 route_group_menu->rebuild (_route->route_group ());
326 route_group_menu->popup (ev->button, ev->time);
332 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
334 _route->set_route_group (eg, this);
338 RouteTimeAxisView::playlist_changed ()
343 set_playlist (get_diskstream()->playlist());
348 RouteTimeAxisView::label_view ()
350 string x = _route->name();
352 if (x != name_entry.get_text()) {
353 name_entry.set_text (x);
356 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
360 RouteTimeAxisView::route_name_changed ()
362 _editor.route_name_changed (this);
367 RouteTimeAxisView::take_name_changed (void *src)
376 RouteTimeAxisView::playlist_click ()
378 // always build a new action menu
380 delete playlist_action_menu;
382 playlist_action_menu = new Menu;
383 playlist_action_menu->set_name ("ArdourContextMenu");
385 build_playlist_menu (playlist_action_menu);
387 conditionally_add_to_selection ();
388 playlist_action_menu->popup (1, gtk_get_current_event_time());
392 RouteTimeAxisView::automation_click ()
394 conditionally_add_to_selection ();
395 build_automation_action_menu ();
396 automation_action_menu->popup (1, gtk_get_current_event_time());
400 RouteTimeAxisView::set_state (const XMLNode& node)
402 TimeAxisView::set_state (node);
404 XMLNodeList kids = node.children();
405 XMLNodeConstIterator iter;
406 const XMLProperty* prop;
408 for (iter = kids.begin(); iter != kids.end(); ++iter) {
409 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
410 if ((prop = (*iter)->property ("automation-id")) != 0) {
412 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
413 bool show = ((prop = (*iter)->property ("shown")) != 0) && prop->value() == "yes";
414 create_automation_child(param, show);
416 warning << "Automation child has no ID" << endmsg;
425 RouteTimeAxisView::build_automation_action_menu ()
427 using namespace Menu_Helpers;
429 automation_action_menu = manage (new Menu);
430 MenuList& automation_items = automation_action_menu->items();
431 automation_action_menu->set_name ("ArdourContextMenu");
433 automation_items.push_back (MenuElem (_("Show all automation"),
434 mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
436 automation_items.push_back (MenuElem (_("Show existing automation"),
437 mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
439 automation_items.push_back (MenuElem (_("Hide all automation"),
440 mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
442 if (subplugin_menu.get_attach_widget())
443 subplugin_menu.detach();
445 automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
446 automation_items.back().set_sensitive (!subplugin_menu.items().empty());
448 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
449 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
451 automation_items.push_back (SeparatorElem());
453 delete i->second->menu_item;
455 automation_items.push_back(CheckMenuElem (_route->describe_parameter(i->second->param),
456 bind (mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
458 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&automation_items.back());
460 i->second->menu_item->set_active(show_automation(i->second->param));
461 //i->second->menu_item->set_active(false);
466 RouteTimeAxisView::build_display_menu ()
468 using namespace Menu_Helpers;
470 /* get the size menu ready */
476 TimeAxisView::build_display_menu ();
478 /* now fill it with our stuff */
480 MenuList& items = display_menu->items();
481 display_menu->set_name ("ArdourContextMenu");
483 items.push_back (MenuElem (_("Height"), *size_menu));
484 items.push_back (MenuElem (_("Color"), mem_fun(*this, &RouteTimeAxisView::select_track_color)));
486 items.push_back (SeparatorElem());
488 if (!Profile->get_sae()) {
489 build_remote_control_menu ();
490 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
491 /* rebuild this every time */
492 build_automation_action_menu ();
493 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
494 items.push_back (SeparatorElem());
497 // Hook for derived classes to add type specific stuff
498 append_extra_display_menu_items ();
499 items.push_back (SeparatorElem());
503 Menu *layers_menu = manage(new Menu);
504 MenuList &layers_items = layers_menu->items();
505 layers_menu->set_name("ArdourContextMenu");
507 RadioMenuItem::Group layers_group;
509 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
510 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
511 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
512 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
514 items.push_back (MenuElem (_("Layers"), *layers_menu));
516 Menu* alignment_menu = manage (new Menu);
517 MenuList& alignment_items = alignment_menu->items();
518 alignment_menu->set_name ("ArdourContextMenu");
520 RadioMenuItem::Group align_group;
522 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
523 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
524 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
525 if (get_diskstream()->alignment_style() == ExistingMaterial)
526 align_existing_item->set_active();
528 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
529 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
530 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
531 if (get_diskstream()->alignment_style() == CaptureTime)
532 align_capture_item->set_active();
534 if (!Profile->get_sae()) {
535 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
536 get_diskstream()->AlignmentStyleChanged.connect (
537 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
539 RadioMenuItem::Group mode_group;
540 items.push_back (RadioMenuElem (mode_group, _("Normal mode"), bind (
541 mem_fun (*this, &RouteTimeAxisView::set_track_mode),
543 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
545 items.push_back (RadioMenuElem (mode_group, _("Tape mode"), bind (
546 mem_fun (*this, &RouteTimeAxisView::set_track_mode),
547 ARDOUR::Destructive)));
548 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
550 items.push_back (RadioMenuElem (mode_group, _("No layering mode"),
551 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
552 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
556 switch (track()->mode()) {
557 case ARDOUR::Destructive:
558 destructive_track_mode_item->set_active ();
561 normal_track_mode_item->set_active ();
563 case ARDOUR::NonLayered:
564 non_layered_track_mode_item->set_active ();
569 get_diskstream()->AlignmentStyleChanged.connect (
570 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
572 mode_menu = build_mode_menu();
574 items.push_back (MenuElem (_("Mode"), *mode_menu));
576 color_mode_menu = build_color_mode_menu();
578 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
580 items.push_back (SeparatorElem());
583 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
584 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
585 route_active_menu_item->set_active (_route->active());
587 items.push_back (SeparatorElem());
588 items.push_back (MenuElem (_("Hide"), mem_fun(*this, &RouteTimeAxisView::hide_click)));
589 if (!Profile->get_sae()) {
590 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
592 items.push_front (SeparatorElem());
593 items.push_front (MenuElem (_("Delete"), mem_fun(*this, &RouteUI::remove_this_route)));
597 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
600 item_2->set_active ();
605 RouteTimeAxisView::set_track_mode (TrackMode mode)
608 RadioMenuItem* other_item;
609 RadioMenuItem* other_item_2;
613 item = normal_track_mode_item;
614 other_item = non_layered_track_mode_item;
615 other_item_2 = destructive_track_mode_item;
617 case ARDOUR::NonLayered:
618 item = non_layered_track_mode_item;
619 other_item = normal_track_mode_item;
620 other_item_2 = destructive_track_mode_item;
622 case ARDOUR::Destructive:
623 item = destructive_track_mode_item;
624 other_item = normal_track_mode_item;
625 other_item_2 = non_layered_track_mode_item;
628 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
633 if (item && other_item && other_item_2 && item->get_active() && track()->mode() != mode) {
634 _set_track_mode (track().get(), mode, other_item, other_item_2);
639 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
643 if (!track->can_use_mode (mode, needs_bounce)) {
647 Glib::signal_idle().connect (bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
650 cerr << "would bounce this one\n";
655 track->set_mode (mode);
657 rec_enable_button->remove ();
660 case ARDOUR::NonLayered:
662 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
664 case ARDOUR::Destructive:
665 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
669 rec_enable_button->show_all ();
673 RouteTimeAxisView::track_mode_changed ()
677 switch (track()->mode()) {
679 item = normal_track_mode_item;
681 case ARDOUR::NonLayered:
682 item = non_layered_track_mode_item;
684 case ARDOUR::Destructive:
685 item = destructive_track_mode_item;
688 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
697 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
703 TimeAxisView::show_timestretch (start, end);
713 /* check that the time selection was made in our route, or our route group.
714 remember that route_group() == 0 implies the route is *not* in a edit group.
717 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
718 /* this doesn't apply to us */
722 /* ignore it if our edit group is not active */
724 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
729 if (timestretch_rect == 0) {
730 timestretch_rect = new SimpleRect (*canvas_display ());
731 timestretch_rect->property_x1() = 0.0;
732 timestretch_rect->property_y1() = 0.0;
733 timestretch_rect->property_x2() = 0.0;
734 timestretch_rect->property_y2() = 0.0;
735 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
736 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
739 timestretch_rect->show ();
740 timestretch_rect->raise_to_top ();
742 x1 = start / _editor.get_current_zoom();
743 x2 = (end - 1) / _editor.get_current_zoom();
744 y2 = current_height() - 2;
746 timestretch_rect->property_x1() = x1;
747 timestretch_rect->property_y1() = 1.0;
748 timestretch_rect->property_x2() = x2;
749 timestretch_rect->property_y2() = y2;
753 RouteTimeAxisView::hide_timestretch ()
755 TimeAxisView::hide_timestretch ();
757 if (timestretch_rect) {
758 timestretch_rect->hide ();
763 RouteTimeAxisView::show_selection (TimeSelection& ts)
767 /* ignore it if our edit group is not active or if the selection was started
768 in some other track or route group (remember that route_group() == 0 means
769 that the track is not in an route group).
772 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
773 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
779 TimeAxisView::show_selection (ts);
783 RouteTimeAxisView::set_height (uint32_t h)
786 bool height_changed = (height == 0) || (h != height);
787 gm.get_level_meter().setup_meters (gmlen);
789 TimeAxisView::set_height (h);
794 _view->set_height ((double) current_height());
798 snprintf (buf, sizeof (buf), "%u", height);
799 xml_node->add_property ("height", buf);
801 if (height >= hNormal) {
806 gm.get_gain_slider().show();
808 if (!_route || _route->is_master()) {
813 if (rec_enable_button)
814 rec_enable_button->show();
816 route_group_button.show();
818 visual_button.show();
820 automation_button.show();
822 if (is_track() && track()->mode() == ARDOUR::Normal) {
823 playlist_button.show();
826 } else if (height >= hSmaller) {
832 gm.get_gain_slider().hide();
834 if (!_route || _route->is_master()) {
839 if (rec_enable_button)
840 rec_enable_button->show();
842 route_group_button.hide ();
844 visual_button.hide ();
846 automation_button.hide ();
848 if (is_track() && track()->mode() == ARDOUR::Normal) {
849 playlist_button.hide ();
855 /* don't allow name_entry to be hidden while
856 it has focus, otherwise the GUI becomes unusable.
859 if (name_entry.has_focus()) {
860 if (name_entry.get_text() != _route->name()) {
861 name_entry_changed ();
863 controls_ebox.grab_focus ();
869 gm.get_gain_slider().hide();
872 if (rec_enable_button)
873 rec_enable_button->hide();
875 route_group_button.hide ();
877 visual_button.hide ();
879 automation_button.hide ();
880 playlist_button.hide ();
881 name_label.set_text (_route->name());
884 if (height_changed) {
885 /* only emit the signal if the height really changed */
886 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
891 RouteTimeAxisView::select_track_color ()
893 if (RouteUI::choose_color ()) {
896 _view->apply_color (_color, StreamView::RegionColor);
902 RouteTimeAxisView::reset_samples_per_unit ()
904 set_samples_per_unit (_editor.get_current_zoom());
908 RouteTimeAxisView::set_samples_per_unit (double spu)
912 if (get_diskstream() != 0) {
913 speed = get_diskstream()->speed();
917 _view->set_samples_per_unit (spu * speed);
920 TimeAxisView::set_samples_per_unit (spu * speed);
924 RouteTimeAxisView::align_style_changed ()
926 switch (get_diskstream()->alignment_style()) {
927 case ExistingMaterial:
928 if (!align_existing_item->get_active()) {
929 align_existing_item->set_active();
933 if (!align_capture_item->get_active()) {
934 align_capture_item->set_active();
941 RouteTimeAxisView::set_align_style (AlignStyle style)
946 case ExistingMaterial:
947 item = align_existing_item;
950 item = align_capture_item;
953 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
958 if (item->get_active()) {
959 get_diskstream()->set_align_style (style);
964 RouteTimeAxisView::rename_current_playlist ()
966 ArdourPrompter prompter (true);
969 boost::shared_ptr<Diskstream> ds = get_diskstream();
970 if (!ds || ds->destructive())
973 boost::shared_ptr<Playlist> pl = ds->playlist();
977 prompter.set_prompt (_("Name for playlist"));
978 prompter.set_initial_text (pl->name());
979 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
980 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
982 switch (prompter.run ()) {
983 case Gtk::RESPONSE_ACCEPT:
984 prompter.get_result (name);
996 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
998 std::string ret (basename);
1000 std::string const group_string = "." + route_group()->name() + ".";
1002 // iterate through all playlists
1004 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
1005 std::string tmp = (*i)->name();
1007 std::string::size_type idx = tmp.find(group_string);
1008 // find those which belong to this group
1009 if (idx != string::npos) {
1010 tmp = tmp.substr(idx + group_string.length());
1012 // and find the largest current number
1013 int x = atoi(tmp.c_str());
1014 if (x > maxnumber) {
1023 snprintf (buf, sizeof(buf), "%d", maxnumber);
1025 ret = this->name() + "." + route_group()->name () + "." + buf;
1031 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1035 boost::shared_ptr<Diskstream> ds = get_diskstream();
1036 if (!ds || ds->destructive())
1039 boost::shared_ptr<const Playlist> pl = ds->playlist();
1045 if (route_group() && route_group()->is_active()) {
1046 name = resolve_new_group_playlist_name(name, playlists_before_op);
1049 while (_session.playlist_by_name(name)) {
1050 name = Playlist::bump_name (name, _session);
1053 // TODO: The prompter "new" button should be de-activated if the user
1054 // specifies a playlist name which already exists in the session.
1058 ArdourPrompter prompter (true);
1060 prompter.set_prompt (_("Name for Playlist"));
1061 prompter.set_initial_text (name);
1062 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1063 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1064 prompter.show_all ();
1066 switch (prompter.run ()) {
1067 case Gtk::RESPONSE_ACCEPT:
1068 prompter.get_result (name);
1076 if (name.length()) {
1077 ds->use_copy_playlist ();
1078 ds->playlist()->set_name (name);
1083 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1087 boost::shared_ptr<Diskstream> ds = get_diskstream();
1088 if (!ds || ds->destructive())
1091 boost::shared_ptr<const Playlist> pl = ds->playlist();
1097 if (route_group() && route_group()->is_active()) {
1098 name = resolve_new_group_playlist_name(name,playlists_before_op);
1101 while (_session.playlist_by_name(name)) {
1102 name = Playlist::bump_name (name, _session);
1108 ArdourPrompter prompter (true);
1110 prompter.set_prompt (_("Name for Playlist"));
1111 prompter.set_initial_text (name);
1112 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1113 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1115 switch (prompter.run ()) {
1116 case Gtk::RESPONSE_ACCEPT:
1117 prompter.get_result (name);
1125 if (name.length()) {
1126 ds->use_new_playlist ();
1127 ds->playlist()->set_name (name);
1132 RouteTimeAxisView::clear_playlist ()
1134 boost::shared_ptr<Diskstream> ds = get_diskstream();
1135 if (!ds || ds->destructive())
1138 boost::shared_ptr<Playlist> pl = ds->playlist();
1142 _editor.clear_playlist (pl);
1146 RouteTimeAxisView::speed_changed ()
1148 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
1152 RouteTimeAxisView::diskstream_changed ()
1154 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::update_diskstream_display));
1158 RouteTimeAxisView::update_diskstream_display ()
1160 if (!get_diskstream()) // bus
1163 set_playlist (get_diskstream()->playlist());
1168 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1170 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1172 /* special case: select/deselect all tracks */
1173 if (_editor.get_selection().selected (this)) {
1174 _editor.get_selection().clear_tracks ();
1176 _editor.select_all_tracks ();
1182 PublicEditor::TrackViewList* tracks = _editor.get_valid_views (this, _route->route_group());
1184 switch (Keyboard::selection_type (ev->state)) {
1185 case Selection::Toggle:
1186 _editor.get_selection().toggle (*tracks);
1189 case Selection::Set:
1190 _editor.get_selection().set (*tracks);
1193 case Selection::Extend:
1194 if (tracks->size() > 1) {
1195 /* add each one, do not "extend" */
1196 _editor.get_selection().add (*tracks);
1198 /* extend to the single track */
1199 _editor.extend_selection_to_track (*tracks->front());
1203 case Selection::Add:
1204 _editor.get_selection().add (*tracks);
1212 RouteTimeAxisView::set_selected_points (PointSelection& points)
1214 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1215 (*i)->set_selected_points (points);
1220 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1223 _view->set_selected_regionviews (regions);
1227 /** Add the selectable things that we have to a list.
1228 * @param results List to add things to.
1231 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1235 if (get_diskstream() != 0) {
1236 speed = get_diskstream()->speed();
1239 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1240 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1242 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1243 _view->get_selectables (start_adjusted, end_adjusted, results);
1246 /* pick up visible automation tracks */
1248 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1249 if (!(*i)->hidden()) {
1250 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1256 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1259 _view->get_inverted_selectables (sel, results);
1262 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1263 if (!(*i)->hidden()) {
1264 (*i)->get_inverted_selectables (sel, results);
1272 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1274 return (_show_automation.find(param) != _show_automation.end());
1277 /** Retuns 0 if track for \a param doesn't exist.
1279 RouteTimeAxisView::RouteAutomationNode*
1280 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1282 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1284 if (i != _automation_tracks.end()) {
1291 /** Shorthand for GainAutomation, etc.
1293 RouteTimeAxisView::RouteAutomationNode*
1294 RouteTimeAxisView::automation_track (AutomationType type)
1296 return automation_track (Evoral::Parameter(type));
1300 RouteTimeAxisView::route_group () const
1302 return _route->route_group();
1306 RouteTimeAxisView::name() const
1308 return _route->name();
1311 boost::shared_ptr<Playlist>
1312 RouteTimeAxisView::playlist () const
1314 boost::shared_ptr<Diskstream> ds;
1316 if ((ds = get_diskstream()) != 0) {
1317 return ds->playlist();
1319 return boost::shared_ptr<Playlist> ();
1324 RouteTimeAxisView::name_entry_changed ()
1328 x = name_entry.get_text ();
1330 if (x == _route->name()) {
1334 strip_whitespace_edges(x);
1336 if (x.length() == 0) {
1337 name_entry.set_text (_route->name());
1341 if (!_session.route_name_unique (x)) {
1342 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1343 name_entry.set_text (_route->name());
1344 } else if (_session.route_name_internal (x)) {
1345 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1346 name_entry.set_text (_route->name());
1348 _route->set_name (x);
1353 RouteTimeAxisView::visual_click ()
1355 popup_display_menu (0);
1359 RouteTimeAxisView::hide_click ()
1361 // LAME fix for hide_button refresh fix
1362 hide_button.set_sensitive(false);
1364 _editor.hide_track_in_display (*this);
1366 hide_button.set_sensitive(true);
1369 boost::shared_ptr<Region>
1370 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, 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 (pos, point, dir);
1379 return boost::shared_ptr<Region> ();
1383 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1385 boost::shared_ptr<Diskstream> stream;
1386 boost::shared_ptr<Playlist> playlist;
1388 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1389 return playlist->find_next_region_boundary (pos, dir);
1396 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1398 boost::shared_ptr<Playlist> what_we_got;
1399 boost::shared_ptr<Diskstream> ds = get_diskstream();
1400 boost::shared_ptr<Playlist> playlist;
1404 /* route is a bus, not a track */
1408 playlist = ds->playlist();
1410 TimeSelection time (selection.time);
1411 float speed = ds->speed();
1412 if (speed != 1.0f) {
1413 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1414 (*i).start = session_frame_to_track_frame((*i).start, speed);
1415 (*i).end = session_frame_to_track_frame((*i).end, speed);
1419 XMLNode &before = playlist->get_state();
1422 if ((what_we_got = playlist->cut (time)) != 0) {
1423 _editor.get_cut_buffer().add (what_we_got);
1424 _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1429 if ((what_we_got = playlist->copy (time)) != 0) {
1430 _editor.get_cut_buffer().add (what_we_got);
1435 if ((what_we_got = playlist->cut (time)) != 0) {
1436 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1437 what_we_got->release ();
1447 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1453 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1454 PlaylistSelection::iterator p;
1456 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1458 if (p == selection.playlists.end()) {
1462 if (get_diskstream()->speed() != 1.0f)
1463 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1465 XMLNode &before = playlist->get_state();
1466 playlist->paste (*p, pos, times);
1467 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1473 TimeAxisView::Children
1474 RouteTimeAxisView::get_child_list()
1476 TimeAxisView::Children redirect_children;
1478 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1479 if (!(*i)->hidden()) {
1480 redirect_children.push_back(*i);
1483 return redirect_children;
1488 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1490 using namespace Menu_Helpers;
1492 if (!menu || !is_track()) {
1496 MenuList& playlist_items = menu->items();
1497 menu->set_name ("ArdourContextMenu");
1498 playlist_items.clear();
1500 delete playlist_menu;
1502 playlist_menu = new Menu;
1503 playlist_menu->set_name ("ArdourContextMenu");
1505 vector<boost::shared_ptr<Playlist> > playlists;
1506 boost::shared_ptr<Diskstream> ds = get_diskstream();
1507 RadioMenuItem::Group playlist_group;
1509 _session.get_playlists (playlists);
1511 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1513 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1514 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1515 boost::weak_ptr<Playlist> (*i))));
1517 if (ds->playlist()->id() == (*i)->id()) {
1518 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1520 } else if (ds->playlist()->id() == (*i)->id()) {
1521 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1522 boost::weak_ptr<Playlist>(*i))));
1523 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1528 playlist_items.push_back (SeparatorElem());
1529 playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1530 playlist_items.push_back (SeparatorElem());
1532 if (!route_group() || !route_group()->is_active()) {
1533 playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
1534 playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1537 // Use a label which tells the user what is happening
1538 playlist_items.push_back (MenuElem (_("New Take"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
1539 playlist_items.push_back (MenuElem (_("Copy Take"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1543 playlist_items.push_back (SeparatorElem());
1544 playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1545 playlist_items.push_back (SeparatorElem());
1547 playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1551 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1553 assert (is_track());
1555 boost::shared_ptr<Playlist> pl (wpl.lock());
1561 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1564 if (get_diskstream()->playlist() == apl) {
1565 // radio button cotnrols mean this function is called for both the
1566 // old and new playlist
1569 get_diskstream()->use_playlist (apl);
1572 if (route_group() && route_group()->is_active()) {
1573 //PBD::stacktrace(cerr, 20);
1574 std::string group_string = "."+route_group()->name()+".";
1576 std::string take_name = apl->name();
1577 std::string::size_type idx = take_name.find(group_string);
1579 if (idx == std::string::npos)
1582 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1584 for (list<Route*>::const_iterator i = route_group()->route_list().begin(); i != route_group()->route_list().end(); ++i) {
1585 if ( (*i) == this->route().get()) {
1589 std::string playlist_name = (*i)->name()+group_string+take_name;
1591 Track *track = dynamic_cast<Track *>(*i);
1593 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1597 boost::shared_ptr<Playlist> ipl = session().playlist_by_name(playlist_name);
1599 // No playlist for this track for this take yet, make it
1600 track->diskstream()->use_new_playlist();
1601 track->diskstream()->playlist()->set_name(playlist_name);
1603 track->diskstream()->use_playlist(ipl);
1613 RouteTimeAxisView::show_playlist_selector ()
1615 _editor.playlist_selector().show_for (this);
1619 RouteTimeAxisView::map_frozen ()
1625 ENSURE_GUI_THREAD (mem_fun(*this, &RouteTimeAxisView::map_frozen));
1627 switch (track()->freeze_state()) {
1629 playlist_button.set_sensitive (false);
1630 rec_enable_button->set_sensitive (false);
1633 playlist_button.set_sensitive (true);
1634 rec_enable_button->set_sensitive (true);
1640 RouteTimeAxisView::color_handler ()
1642 //case cTimeStretchOutline:
1643 if (timestretch_rect) {
1644 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1646 //case cTimeStretchFill:
1647 if (timestretch_rect) {
1648 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1655 RouteTimeAxisView::toggle_automation_track (Evoral::Parameter param)
1657 RouteAutomationNode* node = automation_track(param);
1662 bool showit = node->menu_item->get_active();
1664 if (showit != node->track->marked_for_display()) {
1666 node->track->set_marked_for_display (true);
1667 node->track->canvas_display()->show();
1668 node->track->get_state_node()->add_property ("shown", X_("yes"));
1670 node->track->set_marked_for_display (false);
1671 node->track->hide ();
1672 node->track->get_state_node()->add_property ("shown", X_("no"));
1675 /* now trigger a redisplay */
1678 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1684 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1686 RouteAutomationNode* ran = automation_track(param);
1691 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1692 _show_automation.erase(param);
1693 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1695 if (ran->menu_item && !_hidden) {
1696 ran->menu_item->set_active (false);
1699 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1704 RouteTimeAxisView::show_all_automation ()
1708 /* Show our automation */
1710 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1711 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1712 i->second->track->set_marked_for_display (true);
1713 i->second->track->canvas_display()->show();
1714 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1715 i->second->menu_item->set_active(true);
1719 /* Show processor automation */
1721 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1722 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1723 if ((*ii)->view == 0) {
1724 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1727 (*ii)->menu_item->set_active (true);
1735 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1739 RouteTimeAxisView::show_existing_automation ()
1743 /* Show our automation */
1745 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1746 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1747 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1748 i->second->track->set_marked_for_display (true);
1749 i->second->track->canvas_display()->show();
1750 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1751 i->second->menu_item->set_active(true);
1756 /* Show processor automation */
1758 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1759 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1760 if ((*ii)->view != 0 && (*i)->processor->data().control((*ii)->what)->list()->size() > 0) {
1761 (*ii)->menu_item->set_active (true);
1768 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1772 RouteTimeAxisView::hide_all_automation ()
1776 /* Hide our automation */
1778 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1779 i->second->track->set_marked_for_display (false);
1780 i->second->track->hide ();
1781 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1782 i->second->menu_item->set_active (false);
1785 /* Hide processor automation */
1787 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1788 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1789 (*ii)->menu_item->set_active (false);
1793 _show_automation.clear();
1796 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1801 RouteTimeAxisView::region_view_added (RegionView* rv)
1803 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1804 if(is_audio_track()) {
1805 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1806 boost::shared_ptr<AutomationTimeAxisView> atv;
1808 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1814 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1815 (*i)->add_ghost(rv);
1819 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1821 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1827 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1829 parent.remove_processor_automation_node (this);
1833 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1836 remove_child (pan->view);
1840 RouteTimeAxisView::ProcessorAutomationNode*
1841 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1843 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1845 if ((*i)->processor == processor) {
1847 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1848 if ((*ii)->what == what) {
1859 legalize_for_xml_node (string str)
1861 string::size_type pos;
1862 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1868 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1869 legal.replace (pos, 1, "_");
1878 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1881 ProcessorAutomationNode* pan;
1883 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1884 fatal << _("programming error: ")
1885 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1886 processor->name(), what)
1896 name = processor->describe_parameter (what);
1898 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1902 char state_name[256];
1903 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1905 boost::shared_ptr<AutomationControl> control
1906 = boost::dynamic_pointer_cast<AutomationControl>(processor->data().control(what, true));
1908 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1909 new AutomationTimeAxisView (_session, _route, processor, control,
1910 _editor, *this, false, parent_canvas, name, state_name));
1912 pan->view->Hiding.connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1914 if (!pan->view->marked_for_display()) {
1917 pan->menu_item->set_active (true);
1920 add_child (pan->view);
1923 _view->foreach_regionview (mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1926 processor->mark_automation_visible (what, true);
1930 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1933 pan->menu_item->set_active (false);
1936 i->mark_automation_visible (pan->what, false);
1938 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1942 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1944 boost::shared_ptr<Processor> processor (p.lock ());
1949 set<Evoral::Parameter> s;
1950 boost::shared_ptr<AutomationLine> al;
1952 processor->what_has_visible_data (s);
1954 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1956 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1959 add_processor_automation_curve (processor, (*i));
1965 RouteTimeAxisView::add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1967 using namespace Menu_Helpers;
1974 track->Hiding.connect (bind (mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1976 bool hideit = (!show);
1978 if ((node = track->get_state_node()) != 0) {
1979 if ((prop = node->property ("shown")) != 0) {
1980 if (prop->value() == "yes") {
1986 _automation_tracks.insert(std::make_pair(param, new RouteAutomationNode(param, NULL, track)));
1991 _show_automation.insert (param);
1995 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1999 build_display_menu();
2004 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
2006 boost::shared_ptr<Processor> processor (p.lock ());
2011 if (!processor->visible ()) {
2015 using namespace Menu_Helpers;
2016 ProcessorAutomationInfo *rai;
2017 list<ProcessorAutomationInfo*>::iterator x;
2019 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2020 std::set<Evoral::Parameter> has_visible_automation;
2022 processor->what_has_visible_data(has_visible_automation);
2024 if (automatable.empty()) {
2028 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2029 if ((*x)->processor == processor) {
2034 if (x == processor_automation.end()) {
2036 rai = new ProcessorAutomationInfo (processor);
2037 processor_automation.push_back (rai);
2045 /* any older menu was deleted at the top of processors_changed()
2046 when we cleared the subplugin menu.
2049 rai->menu = manage (new Menu);
2050 MenuList& items = rai->menu->items();
2051 rai->menu->set_name ("ArdourContextMenu");
2055 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2057 ProcessorAutomationNode* pan;
2058 CheckMenuItem* mitem;
2060 string name = processor->describe_parameter (*i);
2062 items.push_back (CheckMenuElem (name));
2063 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2065 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2066 mitem->set_active(true);
2069 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2073 pan = new ProcessorAutomationNode (*i, mitem, *this);
2075 rai->lines.push_back (pan);
2079 pan->menu_item = mitem;
2083 mitem->signal_toggled().connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2086 /* add the menu for this processor, because the subplugin
2087 menu is always cleared at the top of processors_changed().
2088 this is the result of some poor design in gtkmm and/or
2092 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2097 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2098 RouteTimeAxisView::ProcessorAutomationNode* pan)
2100 bool showit = pan->menu_item->get_active();
2101 bool redraw = false;
2103 if (pan->view == 0 && showit) {
2104 add_processor_automation_curve (rai->processor, pan->what);
2108 if (pan->view && showit != pan->view->marked_for_display()) {
2111 pan->view->set_marked_for_display (true);
2112 pan->view->canvas_display()->show();
2113 pan->view->canvas_background()->show();
2115 rai->processor->mark_automation_visible (pan->what, true);
2116 pan->view->set_marked_for_display (false);
2124 if (redraw && !no_redraw) {
2126 /* now trigger a redisplay */
2128 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2134 RouteTimeAxisView::processors_changed ()
2136 using namespace Menu_Helpers;
2138 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2139 (*i)->valid = false;
2142 subplugin_menu.items().clear ();
2144 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2145 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2147 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2149 list<ProcessorAutomationInfo*>::iterator tmp;
2157 processor_automation.erase (i);
2164 /* change in visibility was possible */
2166 _route->gui_changed ("visible_tracks", this);
2169 boost::shared_ptr<AutomationLine>
2170 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2172 ProcessorAutomationNode* pan;
2174 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2180 return boost::shared_ptr<AutomationLine>();
2184 RouteTimeAxisView::reset_processor_automation_curves ()
2186 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2192 RouteTimeAxisView::update_rec_display ()
2194 RouteUI::update_rec_display ();
2195 name_entry.set_sensitive (!_route->record_enabled());
2199 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2202 _view->set_layer_display (d);
2207 RouteTimeAxisView::layer_display () const
2210 return _view->layer_display ();
2213 /* we don't know, since we don't have a _view, so just return something */
2219 boost::shared_ptr<AutomationTimeAxisView>
2220 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2222 AutomationTracks::iterator i = _automation_tracks.find(param);
2223 if (i != _automation_tracks.end())
2224 return i->second->track;
2226 return boost::shared_ptr<AutomationTimeAxisView>();
2230 RouteTimeAxisView::fast_update ()
2232 gm.get_level_meter().update_meters ();
2236 RouteTimeAxisView::hide_meter ()
2239 gm.get_level_meter().hide_meters ();
2243 RouteTimeAxisView::show_meter ()
2249 RouteTimeAxisView::reset_meter ()
2251 if (Config->get_show_track_meters()) {
2252 gm.get_level_meter().setup_meters (height-5);
2259 RouteTimeAxisView::clear_meter ()
2261 gm.get_level_meter().clear_meters ();
2265 RouteTimeAxisView::meter_changed (void *src)
2267 ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::meter_changed), src));
2272 RouteTimeAxisView::io_changed (IOChange change, void *src)
2278 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu) {
2279 using namespace Menu_Helpers;
2281 if(!_underlay_streams.empty()) {
2282 MenuList& parent_items = parent_menu->items();
2283 Menu* gs_menu = manage (new Menu);
2284 gs_menu->set_name ("ArdourContextMenu");
2285 MenuList& gs_items = gs_menu->items();
2287 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2289 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2290 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2291 bind(mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2297 RouteTimeAxisView::set_underlay_state()
2299 if(!underlay_xml_node) {
2303 XMLNodeList nlist = underlay_xml_node->children();
2304 XMLNodeConstIterator niter;
2305 XMLNode *child_node;
2307 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2308 child_node = *niter;
2310 if(child_node->name() != "Underlay") {
2314 XMLProperty* prop = child_node->property ("id");
2316 PBD::ID id (prop->value());
2318 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2321 add_underlay(v->view(), false);
2330 RouteTimeAxisView::add_underlay(StreamView* v, bool update_xml)
2336 RouteTimeAxisView& other = v->trackview();
2338 if(find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2339 if(find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2340 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2344 _underlay_streams.push_back(v);
2345 other._underlay_mirrors.push_back(this);
2347 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::add_ghost));
2350 if(!underlay_xml_node) {
2352 underlay_xml_node = xml_node->add_child("Underlays");
2355 XMLNode* node = underlay_xml_node->add_child("Underlay");
2356 XMLProperty* prop = node->add_property("id");
2357 prop->set_value(v->trackview().route()->id().to_s());
2363 RouteTimeAxisView::remove_underlay(StreamView* v)
2369 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2370 RouteTimeAxisView& other = v->trackview();
2372 if(it != _underlay_streams.end()) {
2373 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2375 if(gm == other._underlay_mirrors.end()) {
2376 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2380 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2382 _underlay_streams.erase(it);
2383 other._underlay_mirrors.erase(gm);
2385 if(underlay_xml_node) {
2386 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2392 RouteTimeAxisView::set_button_names ()
2394 rec_enable_button_label.set_text (_("r"));
2395 solo_button_label.set_text (_("s"));
2396 mute_button_label.set_text (_("m"));