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.
29 #include <sigc++/bind.h>
31 #include "pbd/error.h"
32 #include "pbd/stl_delete.h"
33 #include "pbd/whitespace.h"
34 #include "pbd/memento_command.h"
35 #include "pbd/enumwriter.h"
36 #include "pbd/stacktrace.h"
38 #include <gtkmm/menu.h>
39 #include <gtkmm/menuitem.h>
40 #include <gtkmm2ext/gtk_ui.h>
41 #include <gtkmm2ext/selector.h>
42 #include <gtkmm2ext/stop_signal.h>
43 #include <gtkmm2ext/bindable_button.h>
44 #include <gtkmm2ext/utils.h>
46 #include "ardour/amp.h"
47 #include "ardour/audioplaylist.h"
48 #include "ardour/diskstream.h"
49 #include "ardour/event_type_map.h"
50 #include "ardour/ladspa_plugin.h"
51 #include "ardour/location.h"
52 #include "ardour/panner.h"
53 #include "ardour/playlist.h"
54 #include "ardour/playlist.h"
55 #include "ardour/processor.h"
56 #include "ardour/profile.h"
57 #include "ardour/route_group.h"
58 #include "ardour/session.h"
59 #include "ardour/session_playlist.h"
60 #include "ardour/debug.h"
61 #include "ardour/utils.h"
62 #include "evoral/Parameter.hpp"
64 #include "ardour_ui.h"
65 #include "route_time_axis.h"
66 #include "automation_time_axis.h"
67 #include "canvas_impl.h"
68 #include "crossfade_view.h"
70 #include "gui_thread.h"
72 #include "playlist_selector.h"
73 #include "point_selection.h"
75 #include "public_editor.h"
76 #include "region_view.h"
77 #include "rgb_macros.h"
78 #include "selection.h"
79 #include "simplerect.h"
80 #include "streamview.h"
82 #include "route_group_menu.h"
84 #include "ardour/track.h"
88 using namespace ARDOUR;
90 using namespace Gtkmm2ext;
92 using namespace Editing;
95 Glib::RefPtr<Gdk::Pixbuf> RouteTimeAxisView::slider;
98 RouteTimeAxisView::setup_slider_pix ()
100 if ((slider = ::get_icon ("fader_belt_h")) == 0) {
101 throw failed_constructor ();
105 RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, boost::shared_ptr<Route> rt, Canvas& canvas)
108 , TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas)
109 , parent_canvas (canvas)
110 , button_table (3, 3)
111 , route_group_button (_("g"))
112 , playlist_button (_("p"))
113 , size_button (_("h"))
114 , automation_button (_("a"))
115 , visual_button (_("v"))
116 , gm (sess, slider, true, 115)
120 gm.set_controls (_route, _route->shared_peak_meter(), _route->amp());
121 gm.get_level_meter().set_no_show_all();
122 gm.get_level_meter().setup_meters(50);
126 playlist_action_menu = 0;
127 automation_action_menu = 0;
131 if (!_route->is_hidden()) {
132 _marked_for_display = true;
135 timestretch_rect = 0;
137 destructive_track_mode_item = 0;
138 normal_track_mode_item = 0;
139 non_layered_track_mode_item = 0;
141 ignore_toggle = false;
143 route_group_button.set_name ("TrackGroupButton");
144 playlist_button.set_name ("TrackPlaylistButton");
145 automation_button.set_name ("TrackAutomationButton");
146 size_button.set_name ("TrackSizeButton");
147 visual_button.set_name ("TrackVisualButton");
148 hide_button.set_name ("TrackRemoveButton");
150 route_group_button.unset_flags (Gtk::CAN_FOCUS);
151 playlist_button.unset_flags (Gtk::CAN_FOCUS);
152 automation_button.unset_flags (Gtk::CAN_FOCUS);
153 size_button.unset_flags (Gtk::CAN_FOCUS);
154 visual_button.unset_flags (Gtk::CAN_FOCUS);
155 hide_button.unset_flags (Gtk::CAN_FOCUS);
157 hide_button.add (*(manage (new Image (::get_icon("hide")))));
158 hide_button.show_all ();
160 route_group_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::edit_click), false);
161 playlist_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click));
162 automation_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click));
163 size_button.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::size_click), false);
164 visual_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::visual_click));
165 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::hide_click));
171 rec_enable_button->remove ();
173 switch (track()->mode()) {
175 case ARDOUR::NonLayered:
176 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
178 case ARDOUR::Destructive:
179 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
182 rec_enable_button->show_all ();
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"));
187 rec_enable_button->set_sensitive (_session->writable());
190 controls_hbox.pack_start(gm.get_level_meter(), false, false);
191 _route->meter_change.connect (*this, ui_bind (&RouteTimeAxisView::meter_changed, this, _1), gui_context());
192 _route->input()->changed.connect (*this, ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
193 _route->output()->changed.connect (*this, ui_bind (&RouteTimeAxisView::io_changed, this, _1, _2), gui_context());
195 controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
196 controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
198 controls_table.attach (route_group_button, 7, 8, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0);
199 controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
201 ARDOUR_UI::instance()->tooltips().set_tip(*solo_button,_("Solo"));
202 ARDOUR_UI::instance()->tooltips().set_tip(*mute_button,_("Mute"));
203 ARDOUR_UI::instance()->tooltips().set_tip(route_group_button, _("Route Group"));
204 ARDOUR_UI::instance()->tooltips().set_tip(size_button,_("Display Height"));
205 ARDOUR_UI::instance()->tooltips().set_tip(playlist_button,_("Playlist"));
206 ARDOUR_UI::instance()->tooltips().set_tip(automation_button, _("Automation"));
207 ARDOUR_UI::instance()->tooltips().set_tip(visual_button, _("Visual options"));
208 ARDOUR_UI::instance()->tooltips().set_tip(hide_button, _("Hide this track"));
214 /* old school - when we used to put an extra row of buttons in place */
216 controls_table.attach (hide_button, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
217 controls_table.attach (visual_button, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
218 controls_table.attach (size_button, 2, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
219 controls_table.attach (automation_button, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
223 controls_table.attach (automation_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
226 if (is_track() && track()->mode() == ARDOUR::Normal) {
227 controls_table.attach (playlist_button, 5, 6, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
232 _route->processors_changed.connect (*this, ui_bind (&RouteTimeAxisView::processors_changed, this, _1), gui_context());
233 _route->NameChanged.connect (*this, boost::bind (&RouteTimeAxisView::route_name_changed, this), gui_context());
237 track()->TrackModeChanged.connect (*this, boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context());
238 track()->FreezeChange.connect (*this, boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context());
239 track()->DiskstreamChanged.connect (*this, boost::bind (&RouteTimeAxisView::diskstream_changed, this), gui_context());
240 get_diskstream()->SpeedChanged.connect (*this, boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context());
242 /* pick up the correct freeze state */
247 _editor.ZoomChanged.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit));
248 ColorsChanged.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler));
250 route_group_menu = new RouteGroupMenu (
252 (RouteGroup::Property) (RouteGroup::Mute | RouteGroup::Solo | RouteGroup::Edit)
255 route_group_menu->GroupSelected.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu));
257 gm.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll), false);
258 gm.get_gain_slider().set_name ("TrackGainFader");
261 RouteTimeAxisView::~RouteTimeAxisView ()
263 CatchDeletion (this);
265 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
269 delete playlist_menu;
272 delete playlist_action_menu;
273 playlist_action_menu = 0;
278 for (AutomationTracks::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
282 _automation_tracks.clear ();
284 delete route_group_menu;
288 RouteTimeAxisView::post_construct ()
290 /* map current state of the route */
292 update_diskstream_display ();
294 subplugin_menu.items().clear ();
295 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
296 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
297 reset_processor_automation_curves ();
301 RouteTimeAxisView::edit_click (GdkEventButton *ev)
303 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
304 if (_route->route_group()) {
305 _route->route_group()->remove (_route);
310 route_group_menu->rebuild (_route->route_group ());
311 route_group_menu->popup (ev->button, ev->time);
317 RouteTimeAxisView::set_route_group_from_menu (RouteGroup *eg)
322 if (_route->route_group()) {
323 _route->route_group()->remove (_route);
329 RouteTimeAxisView::playlist_changed ()
335 RouteTimeAxisView::label_view ()
337 string x = _route->name();
339 if (x != name_entry.get_text()) {
340 name_entry.set_text (x);
343 ARDOUR_UI::instance()->tooltips().set_tip (name_entry, x);
347 RouteTimeAxisView::route_name_changed ()
353 RouteTimeAxisView::take_name_changed (void *src)
362 RouteTimeAxisView::playlist_click ()
364 // always build a new action menu
366 delete playlist_action_menu;
368 playlist_action_menu = new Menu;
369 playlist_action_menu->set_name ("ArdourContextMenu");
371 build_playlist_menu (playlist_action_menu);
373 conditionally_add_to_selection ();
374 playlist_action_menu->popup (1, gtk_get_current_event_time());
378 RouteTimeAxisView::automation_click ()
380 conditionally_add_to_selection ();
381 build_automation_action_menu ();
382 automation_action_menu->popup (1, gtk_get_current_event_time());
386 RouteTimeAxisView::set_state (const XMLNode& node, int version)
388 TimeAxisView::set_state (node, version);
390 XMLNodeList kids = node.children();
391 XMLNodeConstIterator iter;
392 const XMLProperty* prop;
394 if (_view && (prop = node.property ("layer-display"))) {
395 set_layer_display (LayerDisplay (string_2_enum (prop->value(), _view->layer_display ())));
398 for (iter = kids.begin(); iter != kids.end(); ++iter) {
399 if ((*iter)->name() == AutomationTimeAxisView::state_node_name) {
400 if ((prop = (*iter)->property ("automation-id")) != 0) {
402 Evoral::Parameter param = ARDOUR::EventTypeMap::instance().new_parameter(prop->value());
403 bool show = ((prop = (*iter)->property ("shown")) != 0) && string_is_affirmative (prop->value());
404 create_automation_child(param, show);
406 warning << "Automation child has no ID" << endmsg;
415 RouteTimeAxisView::build_automation_action_menu ()
417 using namespace Menu_Helpers;
419 automation_action_menu = manage (new Menu);
420 cerr << "New AAM @ " << automation_action_menu << endl;
421 MenuList& automation_items = automation_action_menu->items();
422 automation_action_menu->set_name ("ArdourContextMenu");
424 automation_items.push_back (MenuElem (_("Show all automation"),
425 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation)));
427 automation_items.push_back (MenuElem (_("Show existing automation"),
428 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation)));
430 automation_items.push_back (MenuElem (_("Hide all automation"),
431 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation)));
433 if (subplugin_menu.gobj()) {
434 /* this will break if the underlying GTK menu has never been set up, hence
435 the if() above. we have to do this
437 if (subplugin_menu.get_attach_widget()) {
438 subplugin_menu.detach();
441 automation_items.push_back (MenuElem (_("Plugins..."), subplugin_menu));
443 automation_items.push_back (MenuElem (_("Plugins")));
445 automation_items.back().set_sensitive (!subplugin_menu.items().empty());
447 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
449 map<string,Menu*> param_menu_map;
451 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
453 string desc = _route->describe_parameter(i->second->param);
454 string::size_type bracket = desc.find_first_of ('[');
456 if (bracket == string::npos) {
458 /* item gets its own entry in the menu */
460 automation_items.push_back (CheckMenuElem (desc, sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
462 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&automation_items.back());
463 i->second->menu_item->set_active (show_automation (i->second->param));
465 automation_items.push_back (SeparatorElem());
469 /* subgroup related items in their own submenu */
471 string first_part = desc.substr (0, bracket);
473 map<string,Menu*>::iterator x;
475 if ((x = param_menu_map.find (first_part)) == param_menu_map.end()) {
476 m = manage (new Menu);
477 m->set_name ("ArdourContextMenu");
478 automation_items.push_back (MenuElem (first_part + "...", *m));
479 param_menu_map.insert (pair<string,Menu*>(first_part, m));
484 MenuList& mi = m->items();
485 mi.push_back (CheckMenuElem (desc, sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::toggle_automation_track), i->second->param)));
487 i->second->menu_item = static_cast<Gtk::CheckMenuItem*>(&mi.back());
488 i->second->menu_item->set_active(show_automation(i->second->param));
494 RouteTimeAxisView::build_display_menu ()
496 using namespace Menu_Helpers;
498 /* get the size menu ready */
504 TimeAxisView::build_display_menu ();
506 /* now fill it with our stuff */
508 MenuList& items = display_menu->items();
509 display_menu->set_name ("ArdourContextMenu");
511 items.push_back (MenuElem (_("Height"), *size_menu));
512 items.push_back (MenuElem (_("Color"), sigc::mem_fun(*this, &RouteTimeAxisView::select_track_color)));
514 items.push_back (SeparatorElem());
516 if (!Profile->get_sae()) {
517 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
518 /* rebuild this every time */
519 cerr << "Build a new AAM, old was " << automation_action_menu << endl;
520 build_automation_action_menu ();
521 cerr << "Attach AAM @ " << automation_action_menu << endl;
522 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
523 cerr << "Attachment is done\n";
524 items.push_back (SeparatorElem());
527 // Hook for derived classes to add type specific stuff
528 append_extra_display_menu_items ();
529 items.push_back (SeparatorElem());
533 Menu *layers_menu = manage(new Menu);
534 MenuList &layers_items = layers_menu->items();
535 layers_menu->set_name("ArdourContextMenu");
537 RadioMenuItem::Group layers_group;
539 layers_items.push_back(RadioMenuElem (layers_group, _("Overlaid"),
540 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Overlaid)));
541 layers_items.push_back(RadioMenuElem (layers_group, _("Stacked"),
542 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display), Stacked)));
544 items.push_back (MenuElem (_("Layers"), *layers_menu));
546 Menu* alignment_menu = manage (new Menu);
547 MenuList& alignment_items = alignment_menu->items();
548 alignment_menu->set_name ("ArdourContextMenu");
550 RadioMenuItem::Group align_group;
552 alignment_items.push_back (RadioMenuElem (align_group, _("Align with existing material"),
553 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial)));
554 align_existing_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
555 if (get_diskstream()->alignment_style() == ExistingMaterial)
556 align_existing_item->set_active();
558 alignment_items.push_back (RadioMenuElem (align_group, _("Align with capture time"),
559 sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime)));
560 align_capture_item = dynamic_cast<RadioMenuItem*>(&alignment_items.back());
561 if (get_diskstream()->alignment_style() == CaptureTime)
562 align_capture_item->set_active();
564 if (!Profile->get_sae()) {
565 items.push_back (MenuElem (_("Alignment"), *alignment_menu));
566 get_diskstream()->AlignmentStyleChanged.connect (route_connections, boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
568 RadioMenuItem::Group mode_group;
569 items.push_back (RadioMenuElem (mode_group, _("Normal mode"), sigc::bind (
570 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
572 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
574 items.push_back (RadioMenuElem (mode_group, _("Tape mode"), sigc::bind (
575 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode),
576 ARDOUR::Destructive)));
577 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
579 items.push_back (RadioMenuElem (mode_group, _("No layering mode"),
580 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode), ARDOUR::NonLayered)));
581 non_layered_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
585 switch (track()->mode()) {
586 case ARDOUR::Destructive:
587 destructive_track_mode_item->set_active ();
590 normal_track_mode_item->set_active ();
592 case ARDOUR::NonLayered:
593 non_layered_track_mode_item->set_active ();
598 get_diskstream()->AlignmentStyleChanged.connect (route_connections, boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context());
600 mode_menu = build_mode_menu();
602 items.push_back (MenuElem (_("Mode"), *mode_menu));
604 color_mode_menu = build_color_mode_menu();
606 items.push_back (MenuElem (_("Color Mode"), *color_mode_menu));
608 items.push_back (SeparatorElem());
611 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active)));
612 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
613 route_active_menu_item->set_active (_route->active());
615 items.push_back (SeparatorElem());
616 items.push_back (MenuElem (_("Hide"), sigc::mem_fun(*this, &RouteTimeAxisView::hide_click)));
617 if (!Profile->get_sae()) {
618 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
620 items.push_front (SeparatorElem());
621 items.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
625 static bool __reset_item (RadioMenuItem* item, RadioMenuItem* item_2)
628 item_2->set_active ();
633 RouteTimeAxisView::set_track_mode (TrackMode mode)
636 RadioMenuItem* other_item;
637 RadioMenuItem* other_item_2;
641 item = normal_track_mode_item;
642 other_item = non_layered_track_mode_item;
643 other_item_2 = destructive_track_mode_item;
645 case ARDOUR::NonLayered:
646 item = non_layered_track_mode_item;
647 other_item = normal_track_mode_item;
648 other_item_2 = destructive_track_mode_item;
650 case ARDOUR::Destructive:
651 item = destructive_track_mode_item;
652 other_item = normal_track_mode_item;
653 other_item_2 = non_layered_track_mode_item;
656 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode) << endmsg;
661 if (item && other_item && other_item_2 && item->get_active() && track()->mode() != mode) {
662 _set_track_mode (track().get(), mode, other_item, other_item_2);
667 RouteTimeAxisView::_set_track_mode (Track* track, TrackMode mode, RadioMenuItem* reset_item, RadioMenuItem* reset_item_2)
671 if (!track->can_use_mode (mode, needs_bounce)) {
675 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item), reset_item, reset_item_2));
678 cerr << "would bounce this one\n";
683 track->set_mode (mode);
685 rec_enable_button->remove ();
688 case ARDOUR::NonLayered:
690 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
692 case ARDOUR::Destructive:
693 rec_enable_button->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
697 rec_enable_button->show_all ();
701 RouteTimeAxisView::track_mode_changed ()
705 switch (track()->mode()) {
707 item = normal_track_mode_item;
709 case ARDOUR::NonLayered:
710 item = non_layered_track_mode_item;
712 case ARDOUR::Destructive:
713 item = destructive_track_mode_item;
716 fatal << string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg;
725 RouteTimeAxisView::show_timestretch (nframes_t start, nframes_t end)
731 TimeAxisView::show_timestretch (start, end);
741 /* check that the time selection was made in our route, or our route group.
742 remember that route_group() == 0 implies the route is *not* in a edit group.
745 if (!(ts.track == this || (ts.group != 0 && ts.group == _route->route_group()))) {
746 /* this doesn't apply to us */
750 /* ignore it if our edit group is not active */
752 if ((ts.track != this) && _route->route_group() && !_route->route_group()->is_active()) {
757 if (timestretch_rect == 0) {
758 timestretch_rect = new SimpleRect (*canvas_display ());
759 timestretch_rect->property_x1() = 0.0;
760 timestretch_rect->property_y1() = 0.0;
761 timestretch_rect->property_x2() = 0.0;
762 timestretch_rect->property_y2() = 0.0;
763 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
764 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
767 timestretch_rect->show ();
768 timestretch_rect->raise_to_top ();
770 x1 = start / _editor.get_current_zoom();
771 x2 = (end - 1) / _editor.get_current_zoom();
772 y2 = current_height() - 2;
774 timestretch_rect->property_x1() = x1;
775 timestretch_rect->property_y1() = 1.0;
776 timestretch_rect->property_x2() = x2;
777 timestretch_rect->property_y2() = y2;
781 RouteTimeAxisView::hide_timestretch ()
783 TimeAxisView::hide_timestretch ();
785 if (timestretch_rect) {
786 timestretch_rect->hide ();
791 RouteTimeAxisView::show_selection (TimeSelection& ts)
795 /* ignore it if our edit group is not active or if the selection was started
796 in some other track or route group (remember that route_group() == 0 means
797 that the track is not in an route group).
800 if (((ts.track != this && !is_child (ts.track)) && _route->route_group() && !_route->route_group()->is_active()) ||
801 (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->route_group())))) {
807 TimeAxisView::show_selection (ts);
811 RouteTimeAxisView::set_height (uint32_t h)
814 bool height_changed = (height == 0) || (h != height);
815 gm.get_level_meter().setup_meters (gmlen);
817 TimeAxisView::set_height (h);
822 _view->set_height ((double) current_height());
826 snprintf (buf, sizeof (buf), "%u", height);
827 xml_node->add_property ("height", buf);
829 if (height >= hNormal) {
834 gm.get_gain_slider().show();
836 if (!_route || _route->is_control()) {
841 if (rec_enable_button)
842 rec_enable_button->show();
844 route_group_button.show();
846 visual_button.show();
848 automation_button.show();
850 if (is_track() && track()->mode() == ARDOUR::Normal) {
851 playlist_button.show();
854 } else if (height >= hSmaller) {
860 gm.get_gain_slider().hide();
862 if (!_route || _route->is_control()) {
867 if (rec_enable_button)
868 rec_enable_button->show();
870 route_group_button.hide ();
872 visual_button.hide ();
874 automation_button.hide ();
876 if (is_track() && track()->mode() == ARDOUR::Normal) {
877 playlist_button.hide ();
883 /* don't allow name_entry to be hidden while
884 it has focus, otherwise the GUI becomes unusable.
887 if (name_entry.has_focus()) {
888 if (name_entry.get_text() != _route->name()) {
889 name_entry_changed ();
891 controls_ebox.grab_focus ();
897 gm.get_gain_slider().hide();
900 if (rec_enable_button)
901 rec_enable_button->hide();
903 route_group_button.hide ();
905 visual_button.hide ();
907 automation_button.hide ();
908 playlist_button.hide ();
909 name_label.set_text (_route->name());
912 if (height_changed) {
913 /* only emit the signal if the height really changed */
914 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
919 RouteTimeAxisView::select_track_color ()
921 if (RouteUI::choose_color ()) {
924 _view->apply_color (_color, StreamView::RegionColor);
930 RouteTimeAxisView::reset_samples_per_unit ()
932 set_samples_per_unit (_editor.get_current_zoom());
936 RouteTimeAxisView::set_samples_per_unit (double spu)
940 if (get_diskstream() != 0) {
941 speed = get_diskstream()->speed();
945 _view->set_samples_per_unit (spu * speed);
948 TimeAxisView::set_samples_per_unit (spu * speed);
952 RouteTimeAxisView::align_style_changed ()
954 switch (get_diskstream()->alignment_style()) {
955 case ExistingMaterial:
956 if (!align_existing_item->get_active()) {
957 align_existing_item->set_active();
961 if (!align_capture_item->get_active()) {
962 align_capture_item->set_active();
969 RouteTimeAxisView::set_align_style (AlignStyle style)
974 case ExistingMaterial:
975 item = align_existing_item;
978 item = align_capture_item;
981 fatal << string_compose (_("programming error: %1 %2"), "illegal align style in RouteTimeAxisView::set_align_style", style) << endmsg;
986 if (item->get_active()) {
987 get_diskstream()->set_align_style (style);
992 RouteTimeAxisView::rename_current_playlist ()
994 ArdourPrompter prompter (true);
997 boost::shared_ptr<Diskstream> ds = get_diskstream();
998 if (!ds || ds->destructive())
1001 boost::shared_ptr<Playlist> pl = ds->playlist();
1005 prompter.set_prompt (_("Name for playlist"));
1006 prompter.set_initial_text (pl->name());
1007 prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1008 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1010 switch (prompter.run ()) {
1011 case Gtk::RESPONSE_ACCEPT:
1012 prompter.get_result (name);
1013 if (name.length()) {
1014 pl->set_name (name);
1024 RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector<boost::shared_ptr<Playlist> > const & playlists)
1026 std::string ret (basename);
1028 std::string const group_string = "." + route_group()->name() + ".";
1030 // iterate through all playlists
1032 for (vector<boost::shared_ptr<Playlist> >::const_iterator i = playlists.begin(); i != playlists.end(); ++i) {
1033 std::string tmp = (*i)->name();
1035 std::string::size_type idx = tmp.find(group_string);
1036 // find those which belong to this group
1037 if (idx != string::npos) {
1038 tmp = tmp.substr(idx + group_string.length());
1040 // and find the largest current number
1041 int x = atoi(tmp.c_str());
1042 if (x > maxnumber) {
1051 snprintf (buf, sizeof(buf), "%d", maxnumber);
1053 ret = this->name() + "." + route_group()->name () + "." + buf;
1059 RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1063 boost::shared_ptr<Diskstream> ds = get_diskstream();
1064 if (!ds || ds->destructive())
1067 boost::shared_ptr<const Playlist> pl = ds->playlist();
1073 if (route_group() && route_group()->is_active()) {
1074 name = resolve_new_group_playlist_name(name, playlists_before_op);
1077 while (_session->playlists->by_name(name)) {
1078 name = Playlist::bump_name (name, *_session);
1081 // TODO: The prompter "new" button should be de-activated if the user
1082 // specifies a playlist name which already exists in the session.
1086 ArdourPrompter prompter (true);
1088 prompter.set_prompt (_("Name for Playlist"));
1089 prompter.set_initial_text (name);
1090 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1091 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1092 prompter.show_all ();
1094 switch (prompter.run ()) {
1095 case Gtk::RESPONSE_ACCEPT:
1096 prompter.get_result (name);
1104 if (name.length()) {
1105 ds->use_copy_playlist ();
1106 ds->playlist()->set_name (name);
1111 RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
1115 boost::shared_ptr<Diskstream> ds = get_diskstream();
1116 if (!ds || ds->destructive())
1119 boost::shared_ptr<const Playlist> pl = ds->playlist();
1125 if (route_group() && route_group()->is_active()) {
1126 name = resolve_new_group_playlist_name(name,playlists_before_op);
1129 while (_session->playlists->by_name(name)) {
1130 name = Playlist::bump_name (name, *_session);
1136 ArdourPrompter prompter (true);
1138 prompter.set_prompt (_("Name for Playlist"));
1139 prompter.set_initial_text (name);
1140 prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
1141 prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
1143 switch (prompter.run ()) {
1144 case Gtk::RESPONSE_ACCEPT:
1145 prompter.get_result (name);
1153 if (name.length()) {
1154 ds->use_new_playlist ();
1155 ds->playlist()->set_name (name);
1160 RouteTimeAxisView::clear_playlist ()
1162 boost::shared_ptr<Diskstream> ds = get_diskstream();
1163 if (!ds || ds->destructive())
1166 boost::shared_ptr<Playlist> pl = ds->playlist();
1170 _editor.clear_playlist (pl);
1174 RouteTimeAxisView::speed_changed ()
1176 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this));
1180 RouteTimeAxisView::diskstream_changed ()
1182 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteTimeAxisView::update_diskstream_display, this));
1186 RouteTimeAxisView::update_diskstream_display ()
1188 if (!get_diskstream()) // bus
1195 RouteTimeAxisView::selection_click (GdkEventButton* ev)
1197 if (Keyboard::modifier_state_equals (ev->state, (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier))) {
1199 /* special case: select/deselect all tracks */
1200 if (_editor.get_selection().selected (this)) {
1201 _editor.get_selection().clear_tracks ();
1203 _editor.select_all_tracks ();
1209 switch (ArdourKeyboard::selection_type (ev->state)) {
1210 case Selection::Toggle:
1211 _editor.get_selection().toggle (this);
1214 case Selection::Set:
1215 _editor.get_selection().set (this);
1218 case Selection::Extend:
1219 _editor.extend_selection_to_track (*this);
1222 case Selection::Add:
1223 _editor.get_selection().add (this);
1229 RouteTimeAxisView::set_selected_points (PointSelection& points)
1231 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1232 (*i)->set_selected_points (points);
1237 RouteTimeAxisView::set_selected_regionviews (RegionSelection& regions)
1240 _view->set_selected_regionviews (regions);
1244 /** Add the selectable things that we have to a list.
1245 * @param results List to add things to.
1248 RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& results)
1252 if (get_diskstream() != 0) {
1253 speed = get_diskstream()->speed();
1256 nframes_t start_adjusted = session_frame_to_track_frame(start, speed);
1257 nframes_t end_adjusted = session_frame_to_track_frame(end, speed);
1259 if ((_view && ((top < 0.0 && bot < 0.0))) || touched (top, bot)) {
1260 _view->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1263 /* pick up visible automation tracks */
1265 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1266 if (!(*i)->hidden()) {
1267 (*i)->get_selectables (start_adjusted, end_adjusted, top, bot, results);
1273 RouteTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
1276 _view->get_inverted_selectables (sel, results);
1279 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1280 if (!(*i)->hidden()) {
1281 (*i)->get_inverted_selectables (sel, results);
1289 RouteTimeAxisView::show_automation(Evoral::Parameter param)
1291 return (_show_automation.find(param) != _show_automation.end());
1294 /** Retuns 0 if track for \a param doesn't exist.
1296 RouteTimeAxisView::RouteAutomationNode*
1297 RouteTimeAxisView::automation_track (Evoral::Parameter param)
1299 map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.find (param);
1301 if (i != _automation_tracks.end()) {
1308 /** Shorthand for GainAutomation, etc.
1310 RouteTimeAxisView::RouteAutomationNode*
1311 RouteTimeAxisView::automation_track (AutomationType type)
1313 return automation_track (Evoral::Parameter(type));
1317 RouteTimeAxisView::route_group () const
1319 return _route->route_group();
1323 RouteTimeAxisView::name() const
1325 return _route->name();
1328 boost::shared_ptr<Playlist>
1329 RouteTimeAxisView::playlist () const
1331 boost::shared_ptr<Diskstream> ds;
1333 if ((ds = get_diskstream()) != 0) {
1334 return ds->playlist();
1336 return boost::shared_ptr<Playlist> ();
1341 RouteTimeAxisView::name_entry_changed ()
1345 x = name_entry.get_text ();
1347 if (x == _route->name()) {
1351 strip_whitespace_edges(x);
1353 if (x.length() == 0) {
1354 name_entry.set_text (_route->name());
1358 if (!_session->route_name_unique (x)) {
1359 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1360 name_entry.set_text (_route->name());
1361 } else if (_session->route_name_internal (x)) {
1362 ARDOUR_UI::instance()->popup_error (_("You cannot create a track with that name as it is reserved for Ardour"));
1363 name_entry.set_text (_route->name());
1365 _route->set_name (x);
1370 RouteTimeAxisView::visual_click ()
1372 popup_display_menu (0);
1376 RouteTimeAxisView::hide_click ()
1378 // LAME fix for hide_button refresh fix
1379 hide_button.set_sensitive(false);
1381 _editor.hide_track_in_display (*this);
1383 hide_button.set_sensitive(true);
1386 boost::shared_ptr<Region>
1387 RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir)
1389 boost::shared_ptr<Diskstream> stream;
1390 boost::shared_ptr<Playlist> playlist;
1392 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1393 return playlist->find_next_region (pos, point, dir);
1396 return boost::shared_ptr<Region> ();
1400 RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir)
1402 boost::shared_ptr<Diskstream> stream;
1403 boost::shared_ptr<Playlist> playlist;
1405 if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) {
1406 return playlist->find_next_region_boundary (pos, dir);
1413 RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op)
1415 boost::shared_ptr<Playlist> what_we_got;
1416 boost::shared_ptr<Diskstream> ds = get_diskstream();
1417 boost::shared_ptr<Playlist> playlist;
1421 /* route is a bus, not a track */
1425 playlist = ds->playlist();
1427 TimeSelection time (selection.time);
1428 float speed = ds->speed();
1429 if (speed != 1.0f) {
1430 for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) {
1431 (*i).start = session_frame_to_track_frame((*i).start, speed);
1432 (*i).end = session_frame_to_track_frame((*i).end, speed);
1436 XMLNode &before = playlist->get_state();
1439 if ((what_we_got = playlist->cut (time)) != 0) {
1440 _editor.get_cut_buffer().add (what_we_got);
1441 _session->add_command( new MementoCommand<Playlist>(*playlist.get(), &before, &playlist->get_state()));
1446 if ((what_we_got = playlist->copy (time)) != 0) {
1447 _editor.get_cut_buffer().add (what_we_got);
1452 if ((what_we_got = playlist->cut (time)) != 0) {
1453 _session->add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1454 what_we_got->release ();
1464 RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size_t nth)
1470 boost::shared_ptr<Playlist> playlist = get_diskstream()->playlist();
1471 PlaylistSelection::iterator p;
1473 for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {}
1475 if (p == selection.playlists.end()) {
1479 if (get_diskstream()->speed() != 1.0f) {
1480 pos = session_frame_to_track_frame(pos, get_diskstream()->speed() );
1483 XMLNode &before = playlist->get_state();
1484 playlist->paste (*p, pos, times);
1485 _session->add_command( new MementoCommand<Playlist>(*playlist, &before, &playlist->get_state()));
1491 TimeAxisView::Children
1492 RouteTimeAxisView::get_child_list()
1494 TimeAxisView::Children redirect_children;
1496 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1497 if (!(*i)->hidden()) {
1498 redirect_children.push_back(*i);
1501 return redirect_children;
1506 RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
1508 using namespace Menu_Helpers;
1510 if (!menu || !is_track()) {
1514 MenuList& playlist_items = menu->items();
1515 menu->set_name ("ArdourContextMenu");
1516 playlist_items.clear();
1518 delete playlist_menu;
1520 playlist_menu = new Menu;
1521 playlist_menu->set_name ("ArdourContextMenu");
1523 vector<boost::shared_ptr<Playlist> > playlists;
1524 boost::shared_ptr<Diskstream> ds = get_diskstream();
1525 RadioMenuItem::Group playlist_group;
1527 _session->playlists->get (playlists);
1529 for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
1531 if ((*i)->get_orig_diskstream_id() == ds->id()) {
1532 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist),
1533 boost::weak_ptr<Playlist> (*i))));
1535 if (ds->playlist()->id() == (*i)->id()) {
1536 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1538 } else if (ds->playlist()->id() == (*i)->id()) {
1539 playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist),
1540 boost::weak_ptr<Playlist>(*i))));
1541 static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
1546 playlist_items.push_back (SeparatorElem());
1547 playlist_items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
1548 playlist_items.push_back (SeparatorElem());
1550 if (!route_group() || !route_group()->is_active()) {
1551 playlist_items.push_back (MenuElem (_("New"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1552 playlist_items.push_back (MenuElem (_("New Copy"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1555 // Use a label which tells the user what is happening
1556 playlist_items.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::new_playlists), this)));
1557 playlist_items.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::copy_playlists), this)));
1561 playlist_items.push_back (SeparatorElem());
1562 playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor, &PublicEditor::clear_playlists), this)));
1563 playlist_items.push_back (SeparatorElem());
1565 playlist_items.push_back (MenuElem(_("Select from all ..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector)));
1569 RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
1571 assert (is_track());
1573 boost::shared_ptr<Playlist> pl (wpl.lock());
1579 boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist> (pl);
1582 if (get_diskstream()->playlist() == apl) {
1583 // radio button cotnrols mean this function is called for both the
1584 // old and new playlist
1587 get_diskstream()->use_playlist (apl);
1590 if (route_group() && route_group()->is_active()) {
1591 //PBD::stacktrace(cerr, 20);
1592 std::string group_string = "."+route_group()->name()+".";
1594 std::string take_name = apl->name();
1595 std::string::size_type idx = take_name.find(group_string);
1597 if (idx == std::string::npos)
1600 take_name = take_name.substr(idx + group_string.length()); // find the bit containing the take number / name
1602 boost::shared_ptr<RouteList> rl (route_group()->route_list());
1604 for (RouteList::const_iterator i = rl->begin(); i != rl->end(); ++i) {
1605 if ( (*i) == this->route()) {
1609 std::string playlist_name = (*i)->name()+group_string+take_name;
1611 boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track>(*i);
1613 std::cerr << "route " << (*i)->name() << " is not a Track" << std::endl;
1617 boost::shared_ptr<Playlist> ipl = session()->playlists->by_name(playlist_name);
1619 // No playlist for this track for this take yet, make it
1620 track->diskstream()->use_new_playlist();
1621 track->diskstream()->playlist()->set_name(playlist_name);
1623 track->diskstream()->use_playlist(ipl);
1631 RouteTimeAxisView::show_playlist_selector ()
1633 _editor.playlist_selector().show_for (this);
1637 RouteTimeAxisView::map_frozen ()
1643 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen)
1645 switch (track()->freeze_state()) {
1647 playlist_button.set_sensitive (false);
1648 rec_enable_button->set_sensitive (false);
1651 playlist_button.set_sensitive (true);
1652 rec_enable_button->set_sensitive (true);
1658 RouteTimeAxisView::color_handler ()
1660 //case cTimeStretchOutline:
1661 if (timestretch_rect) {
1662 timestretch_rect->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline.get();
1664 //case cTimeStretchFill:
1665 if (timestretch_rect) {
1666 timestretch_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill.get();
1673 RouteTimeAxisView::toggle_automation_track (Evoral::Parameter param)
1675 RouteAutomationNode* node = automation_track(param);
1681 bool showit = node->menu_item->get_active();
1683 if (showit != node->track->marked_for_display()) {
1685 node->track->set_marked_for_display (true);
1686 node->track->canvas_display()->show();
1687 node->track->get_state_node()->add_property ("shown", X_("yes"));
1689 node->track->set_marked_for_display (false);
1690 node->track->hide ();
1691 node->track->get_state_node()->add_property ("shown", X_("no"));
1694 /* now trigger a redisplay */
1697 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1703 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param)
1705 RouteAutomationNode* ran = automation_track(param);
1710 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1711 _show_automation.erase(param);
1712 ran->track->get_state_node()->add_property (X_("shown"), X_("no"));
1714 if (ran->menu_item && !_hidden) {
1715 ran->menu_item->set_active (false);
1719 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1725 RouteTimeAxisView::show_all_automation ()
1729 /* Show our automation */
1731 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1732 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1733 i->second->track->set_marked_for_display (true);
1734 i->second->track->canvas_display()->show();
1735 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1736 i->second->menu_item->set_active(true);
1740 /* Show processor automation */
1742 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1743 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1744 if ((*ii)->view == 0) {
1745 add_processor_automation_curve ((*i)->processor, (*ii)->what);
1748 (*ii)->menu_item->set_active (true);
1756 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1760 RouteTimeAxisView::show_existing_automation ()
1764 /* Show our automation */
1766 map<Evoral::Parameter, RouteAutomationNode*>::iterator i;
1767 for (i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1768 if (i->second->track->line() && i->second->track->line()->npoints() > 0) {
1769 i->second->track->set_marked_for_display (true);
1770 i->second->track->canvas_display()->show();
1771 i->second->track->get_state_node()->add_property ("shown", X_("yes"));
1772 i->second->menu_item->set_active(true);
1777 /* Show processor automation */
1779 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1780 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1781 if ((*ii)->view != 0 && (*i)->processor->data().control((*ii)->what)->list()->size() > 0) {
1782 (*ii)->menu_item->set_active (true);
1789 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1793 RouteTimeAxisView::hide_all_automation ()
1797 /* Hide our automation */
1799 for (map<Evoral::Parameter, RouteAutomationNode*>::iterator i = _automation_tracks.begin(); i != _automation_tracks.end(); ++i) {
1800 i->second->track->set_marked_for_display (false);
1801 i->second->track->hide ();
1802 i->second->track->get_state_node()->add_property ("shown", X_("no"));
1803 i->second->menu_item->set_active (false);
1806 /* Hide processor automation */
1808 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1809 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1810 (*ii)->menu_item->set_active (false);
1814 _show_automation.clear();
1817 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1822 RouteTimeAxisView::region_view_added (RegionView* rv)
1824 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1825 if (is_audio_track()) {
1826 for (Children::iterator i = children.begin(); i != children.end(); ++i) {
1827 boost::shared_ptr<AutomationTimeAxisView> atv;
1829 if ((atv = boost::dynamic_pointer_cast<AutomationTimeAxisView> (*i)) != 0) {
1835 for (UnderlayMirrorList::iterator i = _underlay_mirrors.begin(); i != _underlay_mirrors.end(); ++i) {
1836 (*i)->add_ghost(rv);
1840 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1842 for (vector<ProcessorAutomationNode*>::iterator i = lines.begin(); i != lines.end(); ++i) {
1848 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1850 parent.remove_processor_automation_node (this);
1854 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode* pan)
1857 remove_child (pan->view);
1861 RouteTimeAxisView::ProcessorAutomationNode*
1862 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1864 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
1866 if ((*i)->processor == processor) {
1868 for (vector<ProcessorAutomationNode*>::iterator ii = (*i)->lines.begin(); ii != (*i)->lines.end(); ++ii) {
1869 if ((*ii)->what == what) {
1880 legalize_for_xml_node (string str)
1882 string::size_type pos;
1883 string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1889 while ((pos = legal.find_first_not_of (legal_chars, pos)) != string::npos) {
1890 legal.replace (pos, 1, "_");
1899 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
1902 ProcessorAutomationNode* pan;
1904 if ((pan = find_processor_automation_node (processor, what)) == 0) {
1905 error << _("programming error: ")
1906 << string_compose (X_("processor automation curve for %1:%2 not registered with track!"),
1907 processor->name(), what)
1917 name = processor->describe_parameter (what);
1919 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1923 char state_name[256];
1924 snprintf (state_name, sizeof (state_name), "Redirect-%s-%" PRIu32, legalize_for_xml_node (processor->name()).c_str(), what.id());
1926 boost::shared_ptr<AutomationControl> control
1927 = boost::dynamic_pointer_cast<AutomationControl>(processor->data().control(what, true));
1929 pan->view = boost::shared_ptr<AutomationTimeAxisView>(
1930 new AutomationTimeAxisView (_session, _route, processor, control,
1931 _editor, *this, false, parent_canvas, name, state_name));
1933 pan->view->Hiding.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden), pan, processor));
1935 if (!pan->view->marked_for_display()) {
1938 pan->menu_item->set_active (true);
1941 add_child (pan->view);
1944 _view->foreach_regionview (sigc::mem_fun(*pan->view.get(), &TimeAxisView::add_ghost));
1947 processor->mark_automation_visible (what, true);
1951 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode* pan, boost::shared_ptr<Processor> i)
1954 pan->menu_item->set_active (false);
1957 i->mark_automation_visible (pan->what, false);
1959 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
1963 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr<Processor> p)
1965 boost::shared_ptr<Processor> processor (p.lock ());
1970 set<Evoral::Parameter> s;
1971 boost::shared_ptr<AutomationLine> al;
1973 processor->what_has_visible_data (s);
1975 for (set<Evoral::Parameter>::iterator i = s.begin(); i != s.end(); ++i) {
1977 if ((al = find_processor_automation_curve (processor, *i)) != 0) {
1980 add_processor_automation_curve (processor, (*i));
1986 RouteTimeAxisView::add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show)
1988 using namespace Menu_Helpers;
1995 track->Hiding.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden), param));
1997 bool hideit = (!show);
1999 if ((node = track->get_state_node()) != 0) {
2000 if ((prop = node->property ("shown")) != 0) {
2001 if (string_is_affirmative (prop->value())) {
2007 _automation_tracks.insert(std::make_pair(param, new RouteAutomationNode(param, NULL, track)));
2012 _show_automation.insert (param);
2016 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2020 build_display_menu();
2025 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr<Processor> p)
2027 boost::shared_ptr<Processor> processor (p.lock ());
2029 if (!processor || !processor->display_to_user ()) {
2033 using namespace Menu_Helpers;
2034 ProcessorAutomationInfo *rai;
2035 list<ProcessorAutomationInfo*>::iterator x;
2037 const std::set<Evoral::Parameter>& automatable = processor->what_can_be_automated ();
2038 std::set<Evoral::Parameter> has_visible_automation;
2040 processor->what_has_visible_data(has_visible_automation);
2042 if (automatable.empty()) {
2046 for (x = processor_automation.begin(); x != processor_automation.end(); ++x) {
2047 if ((*x)->processor == processor) {
2052 if (x == processor_automation.end()) {
2054 rai = new ProcessorAutomationInfo (processor);
2055 processor_automation.push_back (rai);
2063 /* any older menu was deleted at the top of processors_changed()
2064 when we cleared the subplugin menu.
2067 rai->menu = manage (new Menu);
2068 MenuList& items = rai->menu->items();
2069 rai->menu->set_name ("ArdourContextMenu");
2073 for (std::set<Evoral::Parameter>::const_iterator i = automatable.begin(); i != automatable.end(); ++i) {
2075 ProcessorAutomationNode* pan;
2076 CheckMenuItem* mitem;
2078 string name = processor->describe_parameter (*i);
2080 items.push_back (CheckMenuElem (name));
2081 mitem = dynamic_cast<CheckMenuItem*> (&items.back());
2083 if (has_visible_automation.find((*i)) != has_visible_automation.end()) {
2084 mitem->set_active(true);
2087 if ((pan = find_processor_automation_node (processor, *i)) == 0) {
2091 pan = new ProcessorAutomationNode (*i, mitem, *this);
2093 rai->lines.push_back (pan);
2097 pan->menu_item = mitem;
2101 mitem->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled), rai, pan));
2104 /* add the menu for this processor, because the subplugin
2105 menu is always cleared at the top of processors_changed().
2106 this is the result of some poor design in gtkmm and/or
2110 subplugin_menu.items().push_back (MenuElem (processor->name(), *rai->menu));
2115 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo* rai,
2116 RouteTimeAxisView::ProcessorAutomationNode* pan)
2118 bool showit = pan->menu_item->get_active();
2119 bool redraw = false;
2121 if (pan->view == 0 && showit) {
2122 add_processor_automation_curve (rai->processor, pan->what);
2126 if (pan->view && showit != pan->view->marked_for_display()) {
2129 pan->view->set_marked_for_display (true);
2130 pan->view->canvas_display()->show();
2131 pan->view->canvas_background()->show();
2133 rai->processor->mark_automation_visible (pan->what, true);
2134 pan->view->set_marked_for_display (false);
2142 if (redraw && !no_redraw) {
2144 /* now trigger a redisplay */
2146 _route->gui_changed ("visible_tracks", (void *) 0); /* EMIT_SIGNAL */
2152 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
2154 if (c.type == RouteProcessorChange::MeterPointChange) {
2155 /* nothing to do if only the meter point has changed */
2159 using namespace Menu_Helpers;
2161 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) {
2162 (*i)->valid = false;
2165 subplugin_menu.items().clear ();
2167 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu));
2168 _route->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves));
2170 bool deleted_processor_automation = false;
2172 for (list<ProcessorAutomationInfo*>::iterator i = processor_automation.begin(); i != processor_automation.end(); ) {
2174 list<ProcessorAutomationInfo*>::iterator tmp;
2182 processor_automation.erase (i);
2183 deleted_processor_automation = true;
2190 if (deleted_processor_automation) {
2191 _route->gui_changed ("visible_tracks", this);
2195 boost::shared_ptr<AutomationLine>
2196 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr<Processor> processor, Evoral::Parameter what)
2198 ProcessorAutomationNode* pan;
2200 if ((pan = find_processor_automation_node (processor, what)) != 0) {
2206 return boost::shared_ptr<AutomationLine>();
2210 RouteTimeAxisView::reset_processor_automation_curves ()
2212 for (ProcessorAutomationCurves::iterator i = processor_automation_curves.begin(); i != processor_automation_curves.end(); ++i) {
2218 RouteTimeAxisView::update_rec_display ()
2220 RouteUI::update_rec_display ();
2221 name_entry.set_sensitive (!_route->record_enabled());
2225 RouteTimeAxisView::set_layer_display (LayerDisplay d)
2228 _view->set_layer_display (d);
2232 xml_node->add_property (N_("layer-display"), enum_2_string (d));
2236 RouteTimeAxisView::layer_display () const
2239 return _view->layer_display ();
2242 /* we don't know, since we don't have a _view, so just return something */
2248 boost::shared_ptr<AutomationTimeAxisView>
2249 RouteTimeAxisView::automation_child(Evoral::Parameter param)
2251 AutomationTracks::iterator i = _automation_tracks.find(param);
2252 if (i != _automation_tracks.end()) {
2253 return i->second->track;
2255 return boost::shared_ptr<AutomationTimeAxisView>();
2260 RouteTimeAxisView::fast_update ()
2262 gm.get_level_meter().update_meters ();
2266 RouteTimeAxisView::hide_meter ()
2269 gm.get_level_meter().hide_meters ();
2273 RouteTimeAxisView::show_meter ()
2279 RouteTimeAxisView::reset_meter ()
2281 if (Config->get_show_track_meters()) {
2282 gm.get_level_meter().setup_meters (height-5);
2289 RouteTimeAxisView::clear_meter ()
2291 gm.get_level_meter().clear_meters ();
2295 RouteTimeAxisView::meter_changed (void *src)
2297 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed, src)
2302 RouteTimeAxisView::io_changed (IOChange /*change*/, void */*src*/)
2308 RouteTimeAxisView::build_underlay_menu(Gtk::Menu* parent_menu)
2310 using namespace Menu_Helpers;
2312 if (!_underlay_streams.empty()) {
2313 MenuList& parent_items = parent_menu->items();
2314 Menu* gs_menu = manage (new Menu);
2315 gs_menu->set_name ("ArdourContextMenu");
2316 MenuList& gs_items = gs_menu->items();
2318 parent_items.push_back (MenuElem (_("Underlays"), *gs_menu));
2320 for(UnderlayList::iterator it = _underlay_streams.begin(); it != _underlay_streams.end(); ++it) {
2321 gs_items.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it)->trackview().name()),
2322 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay), *it)));
2328 RouteTimeAxisView::set_underlay_state()
2330 if (!underlay_xml_node) {
2334 XMLNodeList nlist = underlay_xml_node->children();
2335 XMLNodeConstIterator niter;
2336 XMLNode *child_node;
2338 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2339 child_node = *niter;
2341 if (child_node->name() != "Underlay") {
2345 XMLProperty* prop = child_node->property ("id");
2347 PBD::ID id (prop->value());
2349 RouteTimeAxisView* v = _editor.get_route_view_by_id (id);
2352 add_underlay(v->view(), false);
2361 RouteTimeAxisView::add_underlay (StreamView* v, bool update_xml)
2367 RouteTimeAxisView& other = v->trackview();
2369 if (find(_underlay_streams.begin(), _underlay_streams.end(), v) == _underlay_streams.end()) {
2370 if (find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this) != other._underlay_mirrors.end()) {
2371 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2375 _underlay_streams.push_back(v);
2376 other._underlay_mirrors.push_back(this);
2378 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost));
2381 if (!underlay_xml_node) {
2383 underlay_xml_node = xml_node->add_child("Underlays");
2386 XMLNode* node = underlay_xml_node->add_child("Underlay");
2387 XMLProperty* prop = node->add_property("id");
2388 prop->set_value(v->trackview().route()->id().to_s());
2394 RouteTimeAxisView::remove_underlay (StreamView* v)
2400 UnderlayList::iterator it = find(_underlay_streams.begin(), _underlay_streams.end(), v);
2401 RouteTimeAxisView& other = v->trackview();
2403 if (it != _underlay_streams.end()) {
2404 UnderlayMirrorList::iterator gm = find(other._underlay_mirrors.begin(), other._underlay_mirrors.end(), this);
2406 if (gm == other._underlay_mirrors.end()) {
2407 fatal << _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg;
2411 v->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost));
2413 _underlay_streams.erase(it);
2414 other._underlay_mirrors.erase(gm);
2416 if (underlay_xml_node) {
2417 underlay_xml_node->remove_nodes_and_delete("id", v->trackview().route()->id().to_s());
2423 RouteTimeAxisView::set_button_names ()
2425 rec_enable_button_label.set_text (_("r"));
2427 if (Config->get_solo_control_is_listen_control()) {
2428 switch (Config->get_listen_position()) {
2429 case AfterFaderListen:
2430 solo_button_label.set_text (_("A"));
2432 case PreFaderListen:
2433 solo_button_label.set_text (_("P"));
2437 solo_button_label.set_text (_("s"));
2440 mute_button_label.set_text (_("m"));