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"
79 #include "ardour/track.h"
83 using namespace ARDOUR;
85 using namespace Gtkmm2ext;
87 using namespace Editing;
91 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
94 RouteTimeAxisView::setup_slider_pix ()
96 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
97 throw failed_constructor ();
101 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
103 RouteUI(rt, sess, _("m"), _("s"), _("r")), // mute, solo, and record
104 TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas),
105 parent_canvas (canvas),
107 edit_group_button (_("g")), // group
108 playlist_button (_("p")),
109 size_button (_("h")), // height
110 automation_button (_("a")),
111 visual_button (_("v")),
112 gm (sess, slider, true)
114 gm.set_controls (_route, _route->shared_peak_meter(), _route->gain_control(), _route->amp());
115 gm.get_level_meter().set_no_show_all();
116 gm.get_level_meter().setup_meters(50);
120 playlist_action_menu = 0;
121 automation_action_menu = 0;
124 if (!_route->is_hidden()) {
125 _marked_for_display = true;
128 timestretch_rect = 0;
130 destructive_track_mode_item = 0;
131 normal_track_mode_item = 0;
132 non_layered_track_mode_item = 0;
134 ignore_toggle = false;
136 edit_group_button.set_name ("TrackGroupButton");
137 playlist_button.set_name ("TrackPlaylistButton");
138 automation_button.set_name ("TrackAutomationButton");
139 size_button.set_name ("TrackSizeButton");
140 visual_button.set_name ("TrackVisualButton");
141 hide_button.set_name ("TrackRemoveButton");
143 edit_group_button.unset_flags (Gtk::CAN_FOCUS);
144 playlist_button.unset_flags (Gtk::CAN_FOCUS);
145 automation_button.unset_flags (Gtk::CAN_FOCUS);
146 size_button.unset_flags (Gtk::CAN_FOCUS);
147 visual_button.unset_flags (Gtk::CAN_FOCUS);
148 hide_button.unset_flags (Gtk::CAN_FOCUS);
150 hide_button.add (*(manage (new Image (::get_icon("hide")))));
151 hide_button.show_all ();
153 edit_group_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::edit_click), false);
154 playlist_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::playlist_click));
155 automation_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::automation_click));
156 size_button.signal_button_release_event().connect (mem_fun(*this, &RouteTimeAxisView::size_click), false);
157 visual_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::visual_click));
158 hide_button.signal_clicked().connect (mem_fun(*this, &RouteTimeAxisView::hide_click));
160 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
161 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
162 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
163 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
169 rec_enable_button->remove ();
171 switch (track()->mode()) {
173 case ARDOUR::NonLayered:
174 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
176 case ARDOUR::Destructive:
177 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
180 rec_enable_button->show_all ();
182 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
183 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
184 controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
185 ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record"));
189 controls_hbox.pack_start(gm.get_level_meter(), false, false);
190 _route->meter_change.connect (mem_fun(*this, &RouteTimeAxisView::meter_changed));
191 _route->input()->changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
192 _route->output()->changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed));
194 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
195 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
197 controls_table.attach (edit_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
198 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
200 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
201 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
202 ARDOUR_UI::instance()->tooltips().set_tip(edit_group_button,_("Edit Group"));
203 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
204 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
205 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
206 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
207 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
213 /* old school - when we used to put an extra row of buttons in place */
215 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
216 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
217 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
218 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
222 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
225 if (is_track() && track()->mode() == ARDOUR::Normal) {
226 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
231 _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
232 _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
233 _route->processors_changed.connect (mem_fun(*this, &RouteTimeAxisView::processors_changed));
234 _route->NameChanged.connect (mem_fun(*this, &RouteTimeAxisView::route_name_changed));
235 _route->solo_isolated_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
240 track()->TrackModeChanged.connect (mem_fun(*this, &RouteTimeAxisView::track_mode_changed));
241 track()->FreezeChange.connect (mem_fun(*this, &RouteTimeAxisView::map_frozen));
242 track()->DiskstreamChanged.connect (mem_fun(*this, &RouteTimeAxisView::diskstream_changed));
243 get_diskstream()->SpeedChanged.connect (mem_fun(*this, &RouteTimeAxisView::speed_changed));
245 /* pick up the correct freeze state */
250 _editor.ZoomChanged.connect (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
251 ColorsChanged.connect (mem_fun (*this, &RouteTimeAxisView::color_handler));
253 gm.get_gain_slider().signal_scroll_event().connect(mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
254 gm.get_gain_slider().set_name ("TrackGainFader");
257 RouteTimeAxisView::~RouteTimeAxisView ()
259 GoingAway (); /* EMIT_SIGNAL */
261 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
265 delete playlist_menu;
268 delete playlist_action_menu;
269 playlist_action_menu = 0;
274 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
278 _automation_tracks.clear ();
282 RouteTimeAxisView::post_construct ()
284 /* map current state of the route */
286 update_diskstream_display ();
288 subplugin_menu.items().clear ();
289 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
290 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
291 reset_processor_automation_curves ();
295 RouteTimeAxisView::set_playlist (boost::shared_ptr<Playlist> newplaylist)
297 boost::shared_ptr<Playlist> pl = playlist();
300 modified_connection.disconnect ();
301 modified_connection = pl->Modified.connect (mem_fun(*this, &RouteTimeAxisView::playlist_modified));
305 RouteTimeAxisView::playlist_modified ()
310 RouteTimeAxisView::edit_click (GdkEventButton *ev)
312 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
313 _route->set_edit_group (0, this);
317 using namespace Menu_Helpers;
319 MenuList& items = edit_group_menu.items ();
320 RadioMenuItem::Group group;
323 items.push_back (RadioMenuElem (group, _("No group"),
324 bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), (RouteGroup *) 0)));
326 if (_route->edit_group() == 0) {
327 static_cast<RadioMenuItem*>(&items.back())->set_active ();
330 _session.foreach_edit_group (bind (mem_fun (*this, &RouteTimeAxisView::add_edit_group_menu_item), &group));
331 edit_group_menu.popup (ev->button, ev->time);
337 RouteTimeAxisView::add_edit_group_menu_item (RouteGroup *eg, RadioMenuItem::Group* group)
339 using namespace Menu_Helpers;
341 MenuList &items = edit_group_menu.items();
343 items.push_back (RadioMenuElem (*group, eg->name(), bind (mem_fun(*this, &RouteTimeAxisView::set_edit_group_from_menu), eg)));
344 if (_route->edit_group() == eg) {
345 static_cast<RadioMenuItem*>(&items.back())->set_active ();
350 RouteTimeAxisView::set_edit_group_from_menu (RouteGroup *eg)
352 _route->set_edit_group (eg, this);
356 RouteTimeAxisView::playlist_changed ()
361 set_playlist (get_diskstream()->playlist());
366 RouteTimeAxisView::label_view ()
368 string x = _route->name();
370 if (x != name_entry.get_text()) {
371 name_entry.set_text (x);
374 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
378 RouteTimeAxisView::route_name_changed ()
380 _editor.route_name_changed (this);
385 RouteTimeAxisView::take_name_changed (void *src)
394 RouteTimeAxisView::playlist_click ()
396 // always build a new action menu
398 delete playlist_action_menu;
400 playlist_action_menu = new Menu;
401 playlist_action_menu->set_name ("ArdourContextMenu");
403 build_playlist_menu (playlist_action_menu);
405 conditionally_add_to_selection ();
406 playlist_action_menu->popup (1, gtk_get_current_event_time());
410 RouteTimeAxisView::automation_click ()
412 conditionally_add_to_selection ();
413 build_automation_action_menu ();
414 automation_action_menu->popup (1, gtk_get_current_event_time());
418 RouteTimeAxisView::set_state (const XMLNode& node)
420 TimeAxisView::set_state (node);
422 XMLNodeList kids = node.children();
423 XMLNodeConstIterator iter;
424 const XMLProperty* prop;
426 for (iter = kids.begin(); iter != kids.end(); ++iter) {
427 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
428 if ((prop = (*iter)->property ("automation-id")) != 0) {
430 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
431 bool show = ((prop = (*iter)->property ("shown")) != 0) && prop->value() == "yes";
432 create_automation_child(param, show);
434 warning << "Automation child has no ID" << endmsg;
443 RouteTimeAxisView::build_automation_action_menu ()
445 using namespace Menu_Helpers;
447 automation_action_menu = manage (new Menu);
448 MenuList& automation_items = automation_action_menu->items();
449 automation_action_menu->set_name ("ArdourContextMenu");
451 automation_items.push_back (MenuElem (_("Show all automation"),
452 mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
454 automation_items.push_back (MenuElem (_("Show existing automation"),
455 mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
457 automation_items.push_back (MenuElem (_("Hide all automation"),
458 mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
460 if (subplugin_menu.get_attach_widget())
461 subplugin_menu.detach();
463 automation_items.push_back (MenuElem (_("Plugins"), subplugin_menu));
465 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
466 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
468 automation_items.push_back (SeparatorElem());
470 delete i->second->menu_item;
472 automation_items.push_back(CheckMenuElem (_route->describe_parameter(i->second->param),
473 bind (mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
475 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&automation_items.back());
477 i->second->menu_item->set_active(show_automation(i->second->param));
478 //i->second->menu_item->set_active(false);
483 RouteTimeAxisView::build_display_menu ()
485 using namespace Menu_Helpers;
487 /* get the size menu ready */
493 TimeAxisView::build_display_menu ();
495 /* now fill it with our stuff */
497 MenuList& items = display_menu->items();
498 display_menu->set_name ("ArdourContextMenu");
500 items.push_back (MenuElem (_("Height"), *size_menu));
501 items.push_back (MenuElem (_("Color"), mem_fun(*this, &RouteTimeAxisView::select_track_color)));
503 items.push_back (SeparatorElem());
505 if (!Profile->get_sae()) {
506 build_remote_control_menu ();
507 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
508 /* rebuild this every time */
509 build_automation_action_menu ();
510 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
511 items.push_back (SeparatorElem());
514 // Hook for derived classes to add type specific stuff
515 append_extra_display_menu_items ();
516 items.push_back (SeparatorElem());
520 Menu *layers_menu = manage(new Menu);
521 MenuList &layers_items = layers_menu->items();
522 layers_menu->set_name("ArdourContextMenu");
524 RadioMenuItem::Group layers_group;
526 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
527 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
528 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
529 bind (mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
531 items.push_back (MenuElem (_("Layers"), *layers_menu));
533 Menu* alignment_menu = manage (new Menu);
534 MenuList& alignment_items = alignment_menu->items();
535 alignment_menu->set_name ("ArdourContextMenu");
537 RadioMenuItem::Group align_group;
539 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
540 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
541 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
542 if (get_diskstream()->alignment_style() == ExistingMaterial)
543 align_existing_item->set_active();
545 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
546 bind (mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
547 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
548 if (get_diskstream()->alignment_style() == CaptureTime)
549 align_capture_item->set_active();
551 if (!Profile->get_sae()) {
552 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
553 get_diskstream()->AlignmentStyleChanged.connect (
554 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
556 RadioMenuItem::Group mode_group;
557 items.push_back (RadioMenuElem (mode_group, _("Normal mode"), bind (
558 mem_fun (*this, &RouteTimeAxisView::set_track_mode),
560 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
562 items.push_back (RadioMenuElem (mode_group, _("Tape mode"), bind (
563 mem_fun (*this, &RouteTimeAxisView::set_track_mode),
564 ARDOUR::Destructive)));
565 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
567 items.push_back (RadioMenuElem (mode_group, _("No layering mode"),
568 bind (mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
569 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
573 switch (track()->mode()) {
574 case ARDOUR::Destructive:
575 destructive_track_mode_item->set_active ();
578 normal_track_mode_item->set_active ();
580 case ARDOUR::NonLayered:
581 non_layered_track_mode_item->set_active ();
586 get_diskstream()->AlignmentStyleChanged.connect (
587 mem_fun(*this, &RouteTimeAxisView::align_style_changed));
589 mode_menu = build_mode_menu();
591 items.push_back (MenuElem (_("Mode"), *mode_menu));
593 color_mode_menu = build_color_mode_menu();
595 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
597 items.push_back (SeparatorElem());
600 items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
601 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
602 route_active_menu_item->set_active (_route->active());
604 items.push_back (SeparatorElem());
605 items.push_back (MenuElem (_("Hide"), mem_fun(*this, &RouteTimeAxisView::hide_click)));
606 if (!Profile->get_sae()) {
607 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
609 items.push_front (SeparatorElem());
610 items.push_front (MenuElem (_("Delete"), mem_fun(*this, &RouteUI::remove_this_route)));
614 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
617 item_2->set_active ();
622 RouteTimeAxisView::set_track_mode (TrackMode mode)
625 RadioMenuItem* other_item;
626 RadioMenuItem* other_item_2;
630 item = normal_track_mode_item;
631 other_item = non_layered_track_mode_item;
632 other_item_2 = destructive_track_mode_item;
634 case ARDOUR::NonLayered:
635 item = non_layered_track_mode_item;
636 other_item = normal_track_mode_item;
637 other_item_2 = destructive_track_mode_item;
639 case ARDOUR::Destructive:
640 item = destructive_track_mode_item;
641 other_item = normal_track_mode_item;
642 other_item_2 = non_layered_track_mode_item;
645 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
650 if (item && other_item && other_item_2 && item->get_active() && track()->mode() != mode) {
651 _set_track_mode (track().get(), mode, other_item, other_item_2);
656 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
660 if (!track->can_use_mode (mode, needs_bounce)) {
664 Glib::signal_idle().connect (bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
667 cerr << "would bounce this one\n";
672 track->set_mode (mode);
674 rec_enable_button->remove ();
677 case ARDOUR::NonLayered:
679 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
681 case ARDOUR::Destructive:
682 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
686 rec_enable_button->show_all ();
690 RouteTimeAxisView::track_mode_changed ()
694 switch (track()->mode()) {
696 item = normal_track_mode_item;
698 case ARDOUR::NonLayered:
699 item = non_layered_track_mode_item;
701 case ARDOUR::Destructive:
702 item = destructive_track_mode_item;
705 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
714 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
720 TimeAxisView::show_timestretch (start, end);
730 /* check that the time selection was made in our route, or our edit group.
731 remember that edit_group() == 0 implies the route is *not* in a edit group.
734 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->edit_group()))) {
735 /* this doesn't apply to us */
739 /* ignore it if our edit group is not active */
741 if ((ts.track != this) && _route->edit_group() && !_route->edit_group()->is_active()) {
746 if (timestretch_rect == 0) {
747 timestretch_rect = new SimpleRect (*canvas_display ());
748 timestretch_rect->property_x1() = 0.0;
749 timestretch_rect->property_y1() = 0.0;
750 timestretch_rect->property_x2() = 0.0;
751 timestretch_rect->property_y2() = 0.0;
752 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
753 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
756 timestretch_rect->show ();
757 timestretch_rect->raise_to_top ();
759 x1 = start / _editor.get_current_zoom();
760 x2 = (end - 1) / _editor.get_current_zoom();
761 y2 = current_height() - 2;
763 timestretch_rect->property_x1() = x1;
764 timestretch_rect->property_y1() = 1.0;
765 timestretch_rect->property_x2() = x2;
766 timestretch_rect->property_y2() = y2;
770 RouteTimeAxisView::hide_timestretch ()
772 TimeAxisView::hide_timestretch ();
774 if (timestretch_rect) {
775 timestretch_rect->hide ();
780 RouteTimeAxisView::show_selection (TimeSelection& ts)
784 /* ignore it if our edit group is not active or if the selection was started
785 in some other track or edit group (remember that edit_group() == 0 means
786 that the track is not in an edit group).
789 if (((ts.track != this && !is_child (ts.track)) && _route->edit_group() && !_route->edit_group()->is_active()) ||
790 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->edit_group())))) {
796 TimeAxisView::show_selection (ts);
800 RouteTimeAxisView::set_height (uint32_t h)
803 bool height_changed = (height == 0) || (h != height);
804 gm.get_level_meter().setup_meters (gmlen);
806 TimeAxisView::set_height (h);
811 _view->set_height ((double) current_height());
815 snprintf (buf, sizeof (buf), "%u", height);
816 xml_node->add_property ("height", buf);
818 if (height >= hNormal) {
823 gm.get_gain_slider().show();
826 if (rec_enable_button)
827 rec_enable_button->show();
829 edit_group_button.show();
831 visual_button.show();
833 automation_button.show();
835 if (is_track() && track()->mode() == ARDOUR::Normal) {
836 playlist_button.show();
839 } else if (height >= hSmaller) {
845 gm.get_gain_slider().hide();
848 if (rec_enable_button)
849 rec_enable_button->show();
851 edit_group_button.hide ();
853 visual_button.hide ();
855 automation_button.hide ();
857 if (is_track() && track()->mode() == ARDOUR::Normal) {
858 playlist_button.hide ();
864 /* don't allow name_entry to be hidden while
865 it has focus, otherwise the GUI becomes unusable.
868 if (name_entry.has_focus()) {
869 if (name_entry.get_text() != _route->name()) {
870 name_entry_changed ();
872 controls_ebox.grab_focus ();
878 gm.get_gain_slider().hide();
881 if (rec_enable_button)
882 rec_enable_button->hide();
884 edit_group_button.hide ();
886 visual_button.hide ();
888 automation_button.hide ();
889 playlist_button.hide ();
890 name_label.set_text (_route->name());
893 if (height_changed) {
894 /* only emit the signal if the height really changed */
895 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
900 RouteTimeAxisView::select_track_color ()
902 if (RouteUI::choose_color ()) {
905 _view->apply_color (_color, StreamView::RegionColor);
911 RouteTimeAxisView::reset_samples_per_unit ()
913 set_samples_per_unit (_editor.get_current_zoom());
917 RouteTimeAxisView::set_samples_per_unit (double spu)
921 if (get_diskstream() != 0) {
922 speed = get_diskstream()->speed();
926 _view->set_samples_per_unit (spu * speed);
929 TimeAxisView::set_samples_per_unit (spu * speed);
933 RouteTimeAxisView::align_style_changed ()
935 switch (get_diskstream()->alignment_style()) {
936 case ExistingMaterial:
937 if (!align_existing_item->get_active()) {
938 align_existing_item->set_active();
942 if (!align_capture_item->get_active()) {
943 align_capture_item->set_active();
950 RouteTimeAxisView::set_align_style (AlignStyle style)
955 case ExistingMaterial:
956 item = align_existing_item;
959 item = align_capture_item;
962 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
967 if (item->get_active()) {
968 get_diskstream()->set_align_style (style);
973 RouteTimeAxisView::rename_current_playlist ()
975 ArdourPrompter prompter (true);
978 boost::shared_ptr<Diskstream> ds = get_diskstream();
979 if (!ds || ds->destructive())
982 boost::shared_ptr<Playlist> pl = ds->playlist();
986 prompter.set_prompt (_("Name for playlist"));
987 prompter.set_initial_text (pl->name());
988 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
989 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
991 switch (prompter.run ()) {
992 case Gtk::RESPONSE_ACCEPT:
993 prompter.get_result (name);
1005 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
1007 std::string ret(basename);
1009 std::string group_string = "."+edit_group()->name()+".";
1011 // iterate through all playlists
1013 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
1014 std::string tmp = (*i)->name();
1016 std::string::size_type idx = tmp.find(group_string);
1017 // find those which belong to this group
1018 if (idx != string::npos) {
1019 tmp = tmp.substr(idx + group_string.length());
1021 // and find the largest current number
1022 int x = atoi(tmp.c_str());
1023 if (x > maxnumber) {
1032 snprintf (buf, sizeof(buf), "%d", maxnumber);
1034 ret = this->name()+"."+edit_group()->name()+"."+buf;
1040 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1044 boost::shared_ptr<Diskstream> ds = get_diskstream();
1045 if (!ds || ds->destructive())
1048 boost::shared_ptr<const Playlist> pl = ds->playlist();
1054 if (edit_group() && edit_group()->is_active()) {
1055 name = resolve_new_group_playlist_name(name, playlists_before_op);
1058 while (_session.playlist_by_name(name)) {
1059 name = Playlist::bump_name (name, _session);
1062 // TODO: The prompter "new" button should be de-activated if the user
1063 // specifies a playlist name which already exists in the session.
1067 ArdourPrompter prompter (true);
1069 prompter.set_prompt (_("Name for Playlist"));
1070 prompter.set_initial_text (name);
1071 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1072 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1073 prompter.show_all ();
1075 switch (prompter.run ()) {
1076 case Gtk::RESPONSE_ACCEPT:
1077 prompter.get_result (name);
1085 if (name.length()) {
1086 ds->use_copy_playlist ();
1087 ds->playlist()->set_name (name);
1092 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1096 boost::shared_ptr<Diskstream> ds = get_diskstream();
1097 if (!ds || ds->destructive())
1100 boost::shared_ptr<const Playlist> pl = ds->playlist();
1106 if (edit_group() && edit_group()->is_active()) {
1107 name = resolve_new_group_playlist_name(name,playlists_before_op);
1110 while (_session.playlist_by_name(name)) {
1111 name = Playlist::bump_name (name, _session);
1117 ArdourPrompter prompter (true);
1119 prompter.set_prompt (_("Name for Playlist"));
1120 prompter.set_initial_text (name);
1121 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1122 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1124 switch (prompter.run ()) {
1125 case Gtk::RESPONSE_ACCEPT:
1126 prompter.get_result (name);
1134 if (name.length()) {
1135 ds->use_new_playlist ();
1136 ds->playlist()->set_name (name);
1141 RouteTimeAxisView::clear_playlist ()
1143 boost::shared_ptr<Diskstream> ds = get_diskstream();
1144 if (!ds || ds->destructive())
1147 boost::shared_ptr<Playlist> pl = ds->playlist();
1151 _editor.clear_playlist (pl);
1155 RouteTimeAxisView::speed_changed ()
1157 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
1161 RouteTimeAxisView::diskstream_changed ()
1163 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &RouteTimeAxisView::update_diskstream_display));
1167 RouteTimeAxisView::update_diskstream_display ()
1169 if (!get_diskstream()) // bus
1172 set_playlist (get_diskstream()->playlist());
1177 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1179 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1181 /* special case: select/deselect all tracks */
1182 if (_editor.get_selection().selected (this)) {
1183 _editor.get_selection().clear_tracks ();
1185 _editor.select_all_tracks ();
1191 PublicEditor::TrackViewList* tracks = _editor.get_valid_views (this, _route->edit_group());
1193 switch (Keyboard::selection_type (ev->state)) {
1194 case Selection::Toggle:
1195 _editor.get_selection().toggle (*tracks);
1198 case Selection::Set:
1199 _editor.get_selection().set (*tracks);
1202 case Selection::Extend:
1203 if (tracks->size() > 1) {
1204 /* add each one, do not "extend" */
1205 _editor.get_selection().add (*tracks);
1207 /* extend to the single track */
1208 _editor.extend_selection_to_track (*tracks->front());
1212 case Selection::Add:
1213 _editor.get_selection().add (*tracks);
1221 RouteTimeAxisView::set_selected_points (PointSelection& points)
1223 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1224 (*i)->set_selected_points (points);
1229 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1232 _view->set_selected_regionviews (regions);
1236 /** Add the selectable things that we have to a list.
1237 * @param results List to add things to.
1240 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1244 if (get_diskstream() != 0) {
1245 speed = get_diskstream()->speed();
1248 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1249 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1251 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1252 _view->get_selectables (start_adjusted, end_adjusted, results);
1255 /* pick up visible automation tracks */
1257 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1258 if (!(*i)->hidden()) {
1259 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1265 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1268 _view->get_inverted_selectables (sel, results);
1271 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1272 if (!(*i)->hidden()) {
1273 (*i)->get_inverted_selectables (sel, results);
1281 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1283 return (_show_automation.find(param) != _show_automation.end());
1286 /** Retuns 0 if track for \a param doesn't exist.
1288 RouteTimeAxisView::RouteAutomationNode*
1289 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1291 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1293 if (i != _automation_tracks.end()) {
1300 /** Shorthand for GainAutomation, etc.
1302 RouteTimeAxisView::RouteAutomationNode*
1303 RouteTimeAxisView::automation_track (AutomationType type)
1305 return automation_track (Evoral::Parameter(type));
1309 RouteTimeAxisView::edit_group() const
1311 return _route->edit_group();
1315 RouteTimeAxisView::name() const
1317 return _route->name();
1320 boost::shared_ptr<Playlist>
1321 RouteTimeAxisView::playlist () const
1323 boost::shared_ptr<Diskstream> ds;
1325 if ((ds = get_diskstream()) != 0) {
1326 return ds->playlist();
1328 return boost::shared_ptr<Playlist> ();
1333 RouteTimeAxisView::name_entry_changed ()
1337 x = name_entry.get_text ();
1339 if (x == _route->name()) {
1343 strip_whitespace_edges(x);
1345 if (x.length() == 0) {
1346 name_entry.set_text (_route->name());
1350 if (!_session.route_name_unique (x)) {
1351 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1352 name_entry.set_text (_route->name());
1353 } else if (_session.route_name_internal (x)) {
1354 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1355 name_entry.set_text (_route->name());
1357 _route->set_name (x);
1362 RouteTimeAxisView::visual_click ()
1364 popup_display_menu (0);
1368 RouteTimeAxisView::hide_click ()
1370 // LAME fix for hide_button refresh fix
1371 hide_button.set_sensitive(false);
1373 _editor.hide_track_in_display (*this);
1375 hide_button.set_sensitive(true);
1378 boost::shared_ptr<Region>
1379 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1381 boost::shared_ptr<Diskstream> stream;
1382 boost::shared_ptr<Playlist> playlist;
1384 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1385 return playlist->find_next_region (pos, point, dir);
1388 return boost::shared_ptr<Region> ();
1392 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1394 boost::shared_ptr<Diskstream> stream;
1395 boost::shared_ptr<Playlist> playlist;
1397 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1398 return playlist->find_next_region_boundary (pos, dir);
1405 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1407 boost::shared_ptr<Playlist> what_we_got;
1408 boost::shared_ptr<Diskstream> ds = get_diskstream();
1409 boost::shared_ptr<Playlist> playlist;
1413 /* route is a bus, not a track */
1417 playlist = ds->playlist();
1419 TimeSelection time (selection.time);
1420 float speed = ds->speed();
1421 if (speed != 1.0f) {
1422 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1423 (*i).start = session_frame_to_track_frame((*i).start, speed);
1424 (*i).end = session_frame_to_track_frame((*i).end, speed);
1428 XMLNode &before = playlist->get_state();
1431 if ((what_we_got = playlist->cut (time)) != 0) {
1432 _editor.get_cut_buffer().add (what_we_got);
1433 _session.add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1438 if ((what_we_got = playlist->copy (time)) != 0) {
1439 _editor.get_cut_buffer().add (what_we_got);
1444 if ((what_we_got = playlist->cut (time)) != 0) {
1445 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1446 what_we_got->release ();
1456 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1462 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1463 PlaylistSelection::iterator p;
1465 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1467 if (p == selection.playlists.end()) {
1471 if (get_diskstream()->speed() != 1.0f)
1472 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1474 XMLNode &before = playlist->get_state();
1475 playlist->paste (*p, pos, times);
1476 _session.add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1482 TimeAxisView::Children
1483 RouteTimeAxisView::get_child_list()
1485 TimeAxisView::Children redirect_children;
1487 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1488 if (!(*i)->hidden()) {
1489 redirect_children.push_back(*i);
1492 return redirect_children;
1497 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1499 using namespace Menu_Helpers;
1501 if (!menu || !is_track()) {
1505 MenuList& playlist_items = menu->items();
1506 menu->set_name ("ArdourContextMenu");
1507 playlist_items.clear();
1509 delete playlist_menu;
1511 playlist_menu = new Menu;
1512 playlist_menu->set_name ("ArdourContextMenu");
1514 vector<boost::shared_ptr<Playlist> > playlists;
1515 boost::shared_ptr<Diskstream> ds = get_diskstream();
1516 RadioMenuItem::Group playlist_group;
1518 _session.get_playlists (playlists);
1520 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1522 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1523 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1524 boost::weak_ptr<Playlist> (*i))));
1526 if (ds->playlist()->id() == (*i)->id()) {
1527 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1529 } else if (ds->playlist()->id() == (*i)->id()) {
1530 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), bind (mem_fun (*this, &RouteTimeAxisView::use_playlist),
1531 boost::weak_ptr<Playlist>(*i))));
1532 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1537 playlist_items.push_back (SeparatorElem());
1538 playlist_items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1539 playlist_items.push_back (SeparatorElem());
1541 if (!edit_group() || !edit_group()->is_active()) {
1542 playlist_items.push_back (MenuElem (_("New"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
1543 playlist_items.push_back (MenuElem (_("New Copy"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1546 // Use a label which tells the user what is happening
1547 playlist_items.push_back (MenuElem (_("New Take"), bind(mem_fun(_editor, &PublicEditor::new_playlists), this)));
1548 playlist_items.push_back (MenuElem (_("Copy Take"), bind(mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1552 playlist_items.push_back (SeparatorElem());
1553 playlist_items.push_back (MenuElem (_("Clear Current"), bind(mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1554 playlist_items.push_back (SeparatorElem());
1556 playlist_items.push_back (MenuElem(_("Select from all ..."), mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1560 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1562 assert (is_track());
1564 boost::shared_ptr<Playlist> pl (wpl.lock());
1570 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1573 if (get_diskstream()->playlist() == apl) {
1574 // radio button cotnrols mean this function is called for both the
1575 // old and new playlist
1578 get_diskstream()->use_playlist (apl);
1581 if (edit_group() && edit_group()->is_active()) {
1582 //PBD::stacktrace(cerr, 20);
1583 std::string group_string = "."+edit_group()->name()+".";
1585 std::string take_name = apl->name();
1586 std::string::size_type idx = take_name.find(group_string);
1588 if (idx == std::string::npos)
1591 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1593 for (list<Route*>::const_iterator i = edit_group()->route_list().begin(); i != edit_group()->route_list().end(); ++i) {
1594 if ( (*i) == this->route().get()) {
1598 std::string playlist_name = (*i)->name()+group_string+take_name;
1600 Track *track = dynamic_cast<Track *>(*i);
1602 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1606 boost::shared_ptr<Playlist> ipl = session().playlist_by_name(playlist_name);
1608 // No playlist for this track for this take yet, make it
1609 track->diskstream()->use_new_playlist();
1610 track->diskstream()->playlist()->set_name(playlist_name);
1612 track->diskstream()->use_playlist(ipl);
1622 RouteTimeAxisView::show_playlist_selector ()
1624 _editor.playlist_selector().show_for (this);
1628 RouteTimeAxisView::map_frozen ()
1634 ENSURE_GUI_THREAD (mem_fun(*this, &RouteTimeAxisView::map_frozen));
1636 switch (track()->freeze_state()) {
1638 playlist_button.set_sensitive (false);
1639 rec_enable_button->set_sensitive (false);
1642 playlist_button.set_sensitive (true);
1643 rec_enable_button->set_sensitive (true);
1649 RouteTimeAxisView::color_handler ()
1651 //case cTimeStretchOutline:
1652 if (timestretch_rect) {
1653 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1655 //case cTimeStretchFill:
1656 if (timestretch_rect) {
1657 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1664 RouteTimeAxisView::toggle_automation_track (Evoral::Parameter param)
1666 RouteAutomationNode* node = automation_track(param);
1671 bool showit = node->menu_item->get_active();
1673 if (showit != node->track->marked_for_display()) {
1675 node->track->set_marked_for_display (true);
1676 node->track->canvas_display()->show();
1677 node->track->get_state_node()->add_property ("shown", X_("yes"));
1679 node->track->set_marked_for_display (false);
1680 node->track->hide ();
1681 node->track->get_state_node()->add_property ("shown", X_("no"));
1684 /* now trigger a redisplay */
1687 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1693 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1695 RouteAutomationNode* ran = automation_track(param);
1700 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1701 _show_automation.erase(param);
1702 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1704 if (ran->menu_item && !_hidden) {
1705 ran->menu_item->set_active (false);
1708 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1713 RouteTimeAxisView::show_all_automation ()
1717 /* Show our automation */
1719 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1720 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1721 i->second->track->set_marked_for_display (true);
1722 i->second->track->canvas_display()->show();
1723 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1724 i->second->menu_item->set_active(true);
1728 /* Show processor automation */
1730 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1731 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1732 if ((*ii)->view == 0) {
1733 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1736 (*ii)->menu_item->set_active (true);
1744 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1748 RouteTimeAxisView::show_existing_automation ()
1752 /* Show our automation */
1754 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1755 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1756 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1757 i->second->track->set_marked_for_display (true);
1758 i->second->track->canvas_display()->show();
1759 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1760 i->second->menu_item->set_active(true);
1765 /* Show processor automation */
1767 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1768 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1769 if ((*ii)->view != 0 && (*i)->processor->data().control((*ii)->what)->list()->size() > 0) {
1770 (*ii)->menu_item->set_active (true);
1777 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1781 RouteTimeAxisView::hide_all_automation ()
1785 /* Hide our automation */
1787 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1788 i->second->track->set_marked_for_display (false);
1789 i->second->track->hide ();
1790 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1791 i->second->menu_item->set_active (false);
1794 /* Hide processor automation */
1796 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1797 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1798 (*ii)->menu_item->set_active (false);
1802 _show_automation.clear();
1805 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1810 RouteTimeAxisView::region_view_added (RegionView* rv)
1812 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1813 if(is_audio_track()) {
1814 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1815 boost::shared_ptr<AutomationTimeAxisView> atv;
1817 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1823 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1824 (*i)->add_ghost(rv);
1828 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1830 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1836 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1838 parent.remove_processor_automation_node (this);
1842 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1845 remove_child (pan->view);
1849 RouteTimeAxisView::ProcessorAutomationNode*
1850 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1852 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1854 if ((*i)->processor == processor) {
1856 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1857 if ((*ii)->what == what) {
1868 legalize_for_xml_node (string str)
1870 string::size_type pos;
1871 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1877 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1878 legal.replace (pos, 1, "_");
1887 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1890 ProcessorAutomationNode* pan;
1892 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1893 fatal << _("programming error: ")
1894 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1895 processor->name(), what)
1905 name = processor->describe_parameter (what);
1907 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1911 char state_name[256];
1912 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1914 boost::shared_ptr<AutomationControl> control
1915 = boost::dynamic_pointer_cast<AutomationControl>(processor->data().control(what, true));
1917 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1918 new AutomationTimeAxisView (_session, _route, processor, control,
1919 _editor, *this, false, parent_canvas, name, state_name));
1921 pan->view->Hiding.connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1923 if (!pan->view->marked_for_display()) {
1926 pan->menu_item->set_active (true);
1929 add_child (pan->view);
1932 _view->foreach_regionview (mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1935 processor->mark_automation_visible (what, true);
1939 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1942 pan->menu_item->set_active (false);
1945 i->mark_automation_visible (pan->what, false);
1947 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1951 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1953 boost::shared_ptr<Processor> processor (p.lock ());
1958 set<Evoral::Parameter> s;
1959 boost::shared_ptr<AutomationLine> al;
1961 processor->what_has_visible_data (s);
1963 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1965 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1968 add_processor_automation_curve (processor, (*i));
1974 RouteTimeAxisView::add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1976 using namespace Menu_Helpers;
1983 track->Hiding.connect (bind (mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1985 bool hideit = (!show);
1987 if ((node = track->get_state_node()) != 0) {
1988 if ((prop = node->property ("shown")) != 0) {
1989 if (prop->value() == "yes") {
1995 _automation_tracks.insert(std::make_pair(param, new RouteAutomationNode(param, NULL, track)));
2000 _show_automation.insert (param);
2004 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2008 build_display_menu();
2013 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
2015 boost::shared_ptr<Processor> processor (p.lock ());
2020 using namespace Menu_Helpers;
2021 ProcessorAutomationInfo *rai;
2022 list<ProcessorAutomationInfo*>::iterator x;
2024 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2025 std::set<Evoral::Parameter> has_visible_automation;
2027 processor->what_has_visible_data(has_visible_automation);
2029 if (automatable.empty()) {
2033 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2034 if ((*x)->processor == processor) {
2039 if (x == processor_automation.end()) {
2041 rai = new ProcessorAutomationInfo (processor);
2042 processor_automation.push_back (rai);
2050 /* any older menu was deleted at the top of processors_changed()
2051 when we cleared the subplugin menu.
2054 rai->menu = manage (new Menu);
2055 MenuList& items = rai->menu->items();
2056 rai->menu->set_name ("ArdourContextMenu");
2060 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2062 ProcessorAutomationNode* pan;
2063 CheckMenuItem* mitem;
2065 string name = processor->describe_parameter (*i);
2067 items.push_back (CheckMenuElem (name));
2068 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2070 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2071 mitem->set_active(true);
2074 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2078 pan = new ProcessorAutomationNode (*i, mitem, *this);
2080 rai->lines.push_back (pan);
2084 pan->menu_item = mitem;
2088 mitem->signal_toggled().connect (bind (mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2091 /* add the menu for this processor, because the subplugin
2092 menu is always cleared at the top of processors_changed().
2093 this is the result of some poor design in gtkmm and/or
2097 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2102 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2103 RouteTimeAxisView::ProcessorAutomationNode* pan)
2105 bool showit = pan->menu_item->get_active();
2106 bool redraw = false;
2108 if (pan->view == 0 && showit) {
2109 add_processor_automation_curve (rai->processor, pan->what);
2113 if (pan->view && showit != pan->view->marked_for_display()) {
2116 pan->view->set_marked_for_display (true);
2117 pan->view->canvas_display()->show();
2118 pan->view->canvas_background()->show();
2120 rai->processor->mark_automation_visible (pan->what, true);
2121 pan->view->set_marked_for_display (false);
2129 if (redraw && !no_redraw) {
2131 /* now trigger a redisplay */
2133 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2139 RouteTimeAxisView::processors_changed ()
2141 using namespace Menu_Helpers;
2143 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2144 (*i)->valid = false;
2147 subplugin_menu.items().clear ();
2149 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2150 _route->foreach_processor (mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2152 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2154 list<ProcessorAutomationInfo*>::iterator tmp;
2162 processor_automation.erase (i);
2169 /* change in visibility was possible */
2171 _route->gui_changed ("visible_tracks", this);
2174 boost::shared_ptr<AutomationLine>
2175 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2177 ProcessorAutomationNode* pan;
2179 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2185 return boost::shared_ptr<AutomationLine>();
2189 RouteTimeAxisView::reset_processor_automation_curves ()
2191 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2197 RouteTimeAxisView::update_rec_display ()
2199 RouteUI::update_rec_display ();
2200 name_entry.set_sensitive (!_route->record_enabled());
2204 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2207 _view->set_layer_display (d);
2212 RouteTimeAxisView::layer_display () const
2215 return _view->layer_display ();
2218 /* we don't know, since we don't have a _view, so just return something */
2224 boost::shared_ptr<AutomationTimeAxisView>
2225 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2227 AutomationTracks::iterator i = _automation_tracks.find(param);
2228 if (i != _automation_tracks.end())
2229 return i->second->track;
2231 return boost::shared_ptr<AutomationTimeAxisView>();
2235 RouteTimeAxisView::fast_update ()
2237 gm.get_level_meter().update_meters ();
2241 RouteTimeAxisView::hide_meter ()
2244 gm.get_level_meter().hide_meters ();
2248 RouteTimeAxisView::show_meter ()
2254 RouteTimeAxisView::reset_meter ()
2256 if (Config->get_show_track_meters()) {
2257 gm.get_level_meter().setup_meters (height-5);
2264 RouteTimeAxisView::clear_meter ()
2266 gm.get_level_meter().clear_meters ();
2270 RouteTimeAxisView::meter_changed (void *src)
2272 ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::meter_changed), src));
2277 RouteTimeAxisView::io_changed (IOChange change, void *src)
2283 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu) {
2284 using namespace Menu_Helpers;
2286 if(!_underlay_streams.empty()) {
2287 MenuList& parent_items = parent_menu->items();
2288 Menu* gs_menu = manage (new Menu);
2289 gs_menu->set_name ("ArdourContextMenu");
2290 MenuList& gs_items = gs_menu->items();
2292 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2294 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2295 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2296 bind(mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2302 RouteTimeAxisView::set_underlay_state()
2304 if(!underlay_xml_node) {
2308 XMLNodeList nlist = underlay_xml_node->children();
2309 XMLNodeConstIterator niter;
2310 XMLNode *child_node;
2312 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2313 child_node = *niter;
2315 if(child_node->name() != "Underlay") {
2319 XMLProperty* prop = child_node->property ("id");
2321 PBD::ID id (prop->value());
2323 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2326 add_underlay(v->view(), false);
2335 RouteTimeAxisView::add_underlay(StreamView* v, bool update_xml)
2341 RouteTimeAxisView& other = v->trackview();
2343 if(find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2344 if(find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2345 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2349 _underlay_streams.push_back(v);
2350 other._underlay_mirrors.push_back(this);
2352 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::add_ghost));
2355 if(!underlay_xml_node) {
2357 underlay_xml_node = xml_node->add_child("Underlays");
2360 XMLNode* node = underlay_xml_node->add_child("Underlay");
2361 XMLProperty* prop = node->add_property("id");
2362 prop->set_value(v->trackview().route()->id().to_s());
2368 RouteTimeAxisView::remove_underlay(StreamView* v)
2374 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2375 RouteTimeAxisView& other = v->trackview();
2377 if(it != _underlay_streams.end()) {
2378 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2380 if(gm == other._underlay_mirrors.end()) {
2381 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2385 v->foreach_regionview(mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2387 _underlay_streams.erase(it);
2388 other._underlay_mirrors.erase(gm);
2390 if(underlay_xml_node) {
2391 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());