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/stateful_diff_command.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/bindable_button.h>
43 #include <gtkmm2ext/utils.h>
45 #include "ardour/amp.h"
46 #include "ardour/audioplaylist.h"
47 #include "ardour/diskstream.h"
48 #include "ardour/event_type_map.h"
49 #include "ardour/ladspa_plugin.h"
50 #include "ardour/location.h"
51 #include "ardour/panner.h"
52 #include "ardour/playlist.h"
53 #include "ardour/playlist.h"
54 #include "ardour/processor.h"
55 #include "ardour/profile.h"
56 #include "ardour/route_group.h"
57 #include "ardour/session.h"
58 #include "ardour/session_playlist.h"
59 #include "ardour/debug.h"
60 #include "ardour/utils.h"
61 #include "evoral/Parameter.hpp"
63 #include "ardour_ui.h"
65 #include "global_signals.h"
66 #include "route_time_axis.h"
67 #include "automation_time_axis.h"
68 #include "canvas_impl.h"
69 #include "crossfade_view.h"
71 #include "gui_thread.h"
73 #include "playlist_selector.h"
74 #include "point_selection.h"
76 #include "public_editor.h"
77 #include "region_view.h"
78 #include "rgb_macros.h"
79 #include "selection.h"
80 #include "simplerect.h"
81 #include "streamview.h"
83 #include "route_group_menu.h"
85 #include "ardour/track.h"
89 using namespace ARDOUR
;
91 using namespace Gtkmm2ext
;
93 using namespace Editing
;
96 Glib::RefPtr
<Gdk::Pixbuf
> RouteTimeAxisView::slider
;
99 RouteTimeAxisView::setup_slider_pix ()
101 if ((slider
= ::get_icon ("fader_belt_h")) == 0) {
102 throw failed_constructor ();
106 RouteTimeAxisView::RouteTimeAxisView (PublicEditor
& ed
, Session
* sess
, boost::shared_ptr
<Route
> rt
, Canvas
& canvas
)
109 , TimeAxisView(sess
,ed
,(TimeAxisView
*) 0, canvas
)
110 , parent_canvas (canvas
)
111 , button_table (3, 3)
112 , route_group_button (_("g"))
113 , playlist_button (_("p"))
114 , automation_button (_("a"))
115 , gm (sess
, slider
, true, 115)
116 , _ignore_track_mode_change (false)
118 gm
.set_controls (_route
, _route
->shared_peak_meter(), _route
->amp());
119 gm
.get_level_meter().set_no_show_all();
120 gm
.get_level_meter().setup_meters(50);
123 playlist_action_menu
= 0;
124 automation_action_menu
= 0;
125 plugins_submenu_item
= 0;
129 if (!_route
->is_hidden()) {
130 _marked_for_display
= true;
134 update_solo_display ();
136 timestretch_rect
= 0;
138 destructive_track_mode_item
= 0;
139 normal_track_mode_item
= 0;
140 non_layered_track_mode_item
= 0;
142 ignore_toggle
= false;
144 route_group_button
.set_name ("TrackGroupButton");
145 playlist_button
.set_name ("TrackPlaylistButton");
146 automation_button
.set_name ("TrackAutomationButton");
148 route_group_button
.unset_flags (Gtk::CAN_FOCUS
);
149 playlist_button
.unset_flags (Gtk::CAN_FOCUS
);
150 automation_button
.unset_flags (Gtk::CAN_FOCUS
);
152 route_group_button
.signal_button_release_event().connect (sigc::mem_fun(*this, &RouteTimeAxisView::route_group_click
), false);
153 playlist_button
.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::playlist_click
));
154 automation_button
.signal_clicked().connect (sigc::mem_fun(*this, &RouteTimeAxisView::automation_click
));
160 rec_enable_button
->remove ();
162 switch (track()->mode()) {
164 case ARDOUR::NonLayered
:
165 rec_enable_button
->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
167 case ARDOUR::Destructive
:
168 rec_enable_button
->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
171 rec_enable_button
->show_all ();
173 controls_table
.attach (*rec_enable_button
, 5, 6, 0, 1, Gtk::FILL
|Gtk::EXPAND
, Gtk::FILL
|Gtk::EXPAND
, 0, 0);
175 if (is_midi_track()) {
176 ARDOUR_UI::instance()->set_tip(*rec_enable_button
, _("Record (Right-click for Step Edit)"));
178 ARDOUR_UI::instance()->set_tip(*rec_enable_button
, _("Record"));
181 rec_enable_button
->set_sensitive (_session
->writable());
184 controls_hbox
.pack_start(gm
.get_level_meter(), false, false);
185 _route
->meter_change
.connect (*this, invalidator (*this), bind (&RouteTimeAxisView::meter_changed
, this), gui_context());
186 _route
->input()->changed
.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed
, this, _1
, _2
), gui_context());
187 _route
->output()->changed
.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::io_changed
, this, _1
, _2
), gui_context());
189 controls_table
.attach (*mute_button
, 6, 7, 0, 1, Gtk::FILL
|Gtk::EXPAND
, Gtk::FILL
|Gtk::EXPAND
, 0, 0);
191 if (!_route
->is_master()) {
192 controls_table
.attach (*solo_button
, 7, 8, 0, 1, Gtk::FILL
|Gtk::EXPAND
, Gtk::FILL
|Gtk::EXPAND
, 0, 0);
195 controls_table
.attach (route_group_button
, 7, 8, 1, 2, Gtk::FILL
|Gtk::EXPAND
, Gtk::FILL
|Gtk::EXPAND
, 0, 0);
196 controls_table
.attach (gm
.get_gain_slider(), 0, 5, 1, 2, Gtk::SHRINK
, Gtk::SHRINK
, 0, 0);
198 ARDOUR_UI::instance()->set_tip(*solo_button
,_("Solo"));
199 ARDOUR_UI::instance()->set_tip(*mute_button
,_("Mute"));
200 ARDOUR_UI::instance()->set_tip(route_group_button
, _("Route Group"));
201 ARDOUR_UI::instance()->set_tip(playlist_button
,_("Playlist"));
202 ARDOUR_UI::instance()->set_tip(automation_button
, _("Automation"));
206 controls_table
.attach (automation_button
, 6, 7, 1, 2, Gtk::FILL
|Gtk::EXPAND
, Gtk::FILL
|Gtk::EXPAND
);
208 if (is_track() && track()->mode() == ARDOUR::Normal
) {
209 controls_table
.attach (playlist_button
, 5, 6, 1, 2, Gtk::FILL
|Gtk::EXPAND
, Gtk::FILL
|Gtk::EXPAND
);
214 _route
->processors_changed
.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::processors_changed
, this, _1
), gui_context());
215 _route
->PropertyChanged
.connect (*this, invalidator (*this), ui_bind (&RouteTimeAxisView::route_property_changed
, this, _1
), gui_context());
219 track()->TrackModeChanged
.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::track_mode_changed
, this), gui_context());
220 track()->FreezeChange
.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::map_frozen
, this), gui_context());
221 track()->SpeedChanged
.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::speed_changed
, this), gui_context());
223 /* pick up the correct freeze state */
228 _editor
.ZoomChanged
.connect (sigc::mem_fun(*this, &RouteTimeAxisView::reset_samples_per_unit
));
229 _editor
.HorizontalPositionChanged
.connect (sigc::mem_fun (*this, &RouteTimeAxisView::horizontal_position_changed
));
230 ColorsChanged
.connect (sigc::mem_fun (*this, &RouteTimeAxisView::color_handler
));
232 PropertyList
* plist
= new PropertyList();
234 plist
->add (ARDOUR::Properties::edit
, true);
235 plist
->add (ARDOUR::Properties::mute
, true);
236 plist
->add (ARDOUR::Properties::solo
, true);
238 route_group_menu
= new RouteGroupMenu (_session
, plist
);
239 route_group_menu
->GroupSelected
.connect (sigc::mem_fun (*this, &RouteTimeAxisView::set_route_group_from_menu
));
241 gm
.get_gain_slider().signal_scroll_event().connect(sigc::mem_fun(*this, &RouteTimeAxisView::controls_ebox_scroll
), false);
242 gm
.get_gain_slider().set_name ("TrackGainFader");
245 RouteTimeAxisView::~RouteTimeAxisView ()
247 CatchDeletion (this);
249 for (list
<ProcessorAutomationInfo
*>::iterator i
= processor_automation
.begin(); i
!= processor_automation
.end(); ++i
) {
253 delete playlist_action_menu
;
254 playlist_action_menu
= 0;
259 _automation_tracks
.clear ();
261 delete route_group_menu
;
265 RouteTimeAxisView::post_construct ()
267 /* map current state of the route */
269 update_diskstream_display ();
271 _subplugin_menu_map
.clear ();
272 subplugin_menu
.items().clear ();
273 _route
->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu
));
274 _route
->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves
));
275 reset_processor_automation_curves ();
279 RouteTimeAxisView::route_group_click (GdkEventButton
*ev
)
281 if (Keyboard::modifier_state_equals (ev
->state
, Keyboard::PrimaryModifier
)) {
282 if (_route
->route_group()) {
283 _route
->route_group()->remove (_route
);
288 route_group_menu
->build (_route
->route_group ());
289 route_group_menu
->menu()->popup (ev
->button
, ev
->time
);
295 RouteTimeAxisView::set_route_group_from_menu (RouteGroup
*eg
)
300 if (_route
->route_group()) {
301 _route
->route_group()->remove (_route
);
307 RouteTimeAxisView::playlist_changed ()
313 RouteTimeAxisView::label_view ()
315 string x
= _route
->name();
317 if (x
!= name_entry
.get_text()) {
318 name_entry
.set_text (x
);
321 if (x
!= name_label
.get_text()) {
322 name_label
.set_text (x
);
325 ARDOUR_UI::instance()->set_tip (name_entry
, x
);
329 RouteTimeAxisView::route_property_changed (const PropertyChange
& what_changed
)
331 if (what_changed
.contains (ARDOUR::Properties::name
)) {
337 RouteTimeAxisView::take_name_changed (void *src
)
345 RouteTimeAxisView::playlist_click ()
347 build_playlist_menu ();
348 conditionally_add_to_selection ();
349 playlist_action_menu
->popup (1, gtk_get_current_event_time());
353 RouteTimeAxisView::automation_click ()
355 conditionally_add_to_selection ();
356 build_automation_action_menu ();
357 automation_action_menu
->popup (1, gtk_get_current_event_time());
361 RouteTimeAxisView::set_state (const XMLNode
& node
, int version
)
363 TimeAxisView::set_state (node
, version
);
365 XMLNodeList kids
= node
.children();
366 XMLNodeConstIterator iter
;
367 const XMLProperty
* prop
;
369 if (_view
&& (prop
= node
.property ("layer-display"))) {
370 set_layer_display (LayerDisplay (string_2_enum (prop
->value(), _view
->layer_display ())));
373 for (iter
= kids
.begin(); iter
!= kids
.end(); ++iter
) {
374 if ((*iter
)->name() == AutomationTimeAxisView::state_node_name
) {
375 if ((prop
= (*iter
)->property ("automation-id")) != 0) {
377 Evoral::Parameter param
= ARDOUR::EventTypeMap::instance().new_parameter(prop
->value());
378 bool show
= ((prop
= (*iter
)->property ("shown")) != 0) && string_is_affirmative (prop
->value());
379 create_automation_child(param
, show
);
381 warning
<< "Automation child has no ID" << endmsg
;
390 RouteTimeAxisView::build_automation_action_menu ()
392 using namespace Menu_Helpers
;
394 /* detach subplugin_menu from automation_action_menu before we delete automation_action_menu,
395 otherwise bad things happen (see comment for similar case in MidiTimeAxisView::build_automation_action_menu)
398 detach_menu (subplugin_menu
);
400 _main_automation_menu_map
.clear ();
401 delete automation_action_menu
;
402 automation_action_menu
= new Menu
;
404 MenuList
& items
= automation_action_menu
->items();
406 automation_action_menu
->set_name ("ArdourContextMenu");
408 items
.push_back (MenuElem (_("Show All Automation"),
409 sigc::mem_fun(*this, &RouteTimeAxisView::show_all_automation
)));
411 items
.push_back (MenuElem (_("Show Existing Automation"),
412 sigc::mem_fun(*this, &RouteTimeAxisView::show_existing_automation
)));
414 items
.push_back (MenuElem (_("Hide All Automation"),
415 sigc::mem_fun(*this, &RouteTimeAxisView::hide_all_automation
)));
417 items
.push_back (SeparatorElem ());
419 /* Attach the plugin submenu. It may have previously been used elsewhere,
420 so it was detached above */
422 items
.push_back (MenuElem (_("Plugins"), subplugin_menu
));
423 items
.back().set_sensitive (!subplugin_menu
.items().empty());
427 RouteTimeAxisView::build_display_menu ()
429 using namespace Menu_Helpers
;
433 TimeAxisView::build_display_menu ();
435 /* now fill it with our stuff */
437 MenuList
& items
= display_menu
->items();
438 display_menu
->set_name ("ArdourContextMenu");
440 items
.push_back (MenuElem (_("Color..."), sigc::mem_fun (*this, &RouteUI::choose_color
)));
443 detach_menu (*_size_menu
);
446 items
.push_back (MenuElem (_("Height"), *_size_menu
));
448 items
.push_back (SeparatorElem());
450 if (!Profile
->get_sae()) {
451 items
.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog
)));
452 items
.back().set_sensitive (_editor
.get_selection().tracks
.size() <= 1);
453 items
.push_back (SeparatorElem());
456 // Hook for derived classes to add type specific stuff
457 append_extra_display_menu_items ();
461 Menu
* layers_menu
= manage (new Menu
);
462 MenuList
&layers_items
= layers_menu
->items();
463 layers_menu
->set_name("ArdourContextMenu");
465 RadioMenuItem::Group layers_group
;
467 /* Find out how many overlaid/stacked tracks we have in the selection */
471 TrackSelection
const & s
= _editor
.get_selection().tracks
;
472 for (TrackSelection::const_iterator i
= s
.begin(); i
!= s
.end(); ++i
) {
473 StreamView
* v
= (*i
)->view ();
478 switch (v
->layer_display ()) {
488 /* We're not connecting to signal_toggled() here; in the case where these two items are
489 set to be in the `inconsistent' state, it seems that one or other will end up active
490 as well as inconsistent (presumably due to the RadioMenuItem::Group). Then when you
491 select the active one, no toggled signal is emitted so nothing happens.
494 layers_items
.push_back (RadioMenuElem (layers_group
, _("Overlaid")));
495 RadioMenuItem
* i
= dynamic_cast<RadioMenuItem
*> (&layers_items
.back ());
496 i
->set_active (overlaid
!= 0 && stacked
== 0);
497 i
->set_inconsistent (overlaid
!= 0 && stacked
!= 0);
498 i
->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display
), Overlaid
, true));
500 layers_items
.push_back (
501 RadioMenuElem (layers_group
, _("Stacked"),
502 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display
), Stacked
, true))
505 i
= dynamic_cast<RadioMenuItem
*> (&layers_items
.back ());
506 i
->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_layer_display
), Stacked
, true));
507 i
->set_active (overlaid
== 0 && stacked
!= 0);
508 i
->set_inconsistent (overlaid
!= 0 && stacked
!= 0);
510 items
.push_back (MenuElem (_("Layers"), *layers_menu
));
512 if (!Profile
->get_sae()) {
514 Menu
* alignment_menu
= manage (new Menu
);
515 MenuList
& alignment_items
= alignment_menu
->items();
516 alignment_menu
->set_name ("ArdourContextMenu");
518 RadioMenuItem::Group align_group
;
520 /* Same verbose hacks as for the layering options above */
524 TrackSelection
const & s
= _editor
.get_selection().tracks
;
525 for (TrackSelection::const_iterator i
= s
.begin(); i
!= s
.end(); ++i
) {
526 RouteTimeAxisView
* r
= dynamic_cast<RouteTimeAxisView
*> (*i
);
527 if (!r
|| !r
->is_track ()) {
531 switch (r
->track()->alignment_style()) {
532 case ExistingMaterial
:
541 alignment_items
.push_back (RadioMenuElem (align_group
, _("Align With Existing Material")));
542 RadioMenuItem
* i
= dynamic_cast<RadioMenuItem
*> (&alignment_items
.back());
543 i
->signal_activate().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style
), ExistingMaterial
, true));
544 i
->set_active (existing
!= 0 && capture
== 0);
545 i
->set_inconsistent (existing
!= 0 && capture
!= 0);
547 alignment_items
.push_back (RadioMenuElem (align_group
, _("Align With Capture Time")));
548 i
= dynamic_cast<RadioMenuItem
*> (&alignment_items
.back());
549 i
->signal_activate().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style
), CaptureTime
, true));
550 i
->set_active (existing
== 0 && capture
!= 0);
551 i
->set_inconsistent (existing
!= 0 && capture
!= 0);
553 items
.push_back (MenuElem (_("Alignment"), *alignment_menu
));
555 Menu
* mode_menu
= manage (new Menu
);
556 MenuList
& mode_items
= mode_menu
->items ();
557 mode_menu
->set_name ("ArdourContextMenu");
559 RadioMenuItem::Group mode_group
;
561 mode_items
.push_back (RadioMenuElem (mode_group
, _("Normal Mode"), sigc::bind (
562 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode
),
564 normal_track_mode_item
= dynamic_cast<RadioMenuItem
*>(&mode_items
.back());
566 mode_items
.push_back (RadioMenuElem (mode_group
, _("Tape Mode"), sigc::bind (
567 sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode
),
568 ARDOUR::Destructive
)));
569 destructive_track_mode_item
= dynamic_cast<RadioMenuItem
*>(&mode_items
.back());
571 mode_items
.push_back (RadioMenuElem (mode_group
, _("Non-Layered Mode"),
572 sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::set_track_mode
), ARDOUR::NonLayered
)));
573 non_layered_track_mode_item
= dynamic_cast<RadioMenuItem
*>(&mode_items
.back());
576 _ignore_track_mode_change
= true;
578 switch (track()->mode()) {
579 case ARDOUR::Destructive
:
580 destructive_track_mode_item
->set_active ();
583 normal_track_mode_item
->set_active ();
585 case ARDOUR::NonLayered
:
586 non_layered_track_mode_item
->set_active ();
590 _ignore_track_mode_change
= false;
592 items
.push_back (MenuElem (_("Mode"), *mode_menu
));
595 color_mode_menu
= build_color_mode_menu();
596 if (color_mode_menu
) {
597 items
.push_back (MenuElem (_("Color Mode"), *color_mode_menu
));
600 items
.push_back (SeparatorElem());
602 build_playlist_menu ();
603 items
.push_back (MenuElem (_("Playlist"), *playlist_action_menu
));
605 route_group_menu
->detach ();
606 route_group_menu
->build (_route
->route_group ());
607 items
.push_back (MenuElem (_("Route Group"), *route_group_menu
->menu ()));
609 build_automation_action_menu ();
610 items
.push_back (MenuElem (_("Automation"), *automation_action_menu
));
612 items
.push_back (SeparatorElem());
615 items
.push_back (CheckMenuElem (_("Active"), sigc::mem_fun(*this, &RouteUI::toggle_route_active
)));
616 route_active_menu_item
= dynamic_cast<CheckMenuItem
*> (&items
.back());
617 route_active_menu_item
->set_active (_route
->active());
619 items
.push_back (SeparatorElem());
620 items
.push_back (MenuElem (_("Hide"), sigc::bind (sigc::mem_fun(_editor
, &PublicEditor::hide_track_in_display
), this, false)));
621 if (!Profile
->get_sae()) {
622 items
.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route
)));
624 items
.push_front (SeparatorElem());
625 items
.push_front (MenuElem (_("Delete"), sigc::mem_fun(*this, &RouteUI::remove_this_route
)));
629 static bool __reset_item (RadioMenuItem
* item
, RadioMenuItem
* item_2
)
632 item_2
->set_active ();
637 RouteTimeAxisView::set_track_mode (TrackMode mode
)
639 if (_ignore_track_mode_change
) {
644 RadioMenuItem
* other_item
;
645 RadioMenuItem
* other_item_2
;
649 item
= normal_track_mode_item
;
650 other_item
= non_layered_track_mode_item
;
651 other_item_2
= destructive_track_mode_item
;
653 case ARDOUR::NonLayered
:
654 item
= non_layered_track_mode_item
;
655 other_item
= normal_track_mode_item
;
656 other_item_2
= destructive_track_mode_item
;
658 case ARDOUR::Destructive
:
659 item
= destructive_track_mode_item
;
660 other_item
= normal_track_mode_item
;
661 other_item_2
= non_layered_track_mode_item
;
664 fatal
<< string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", mode
) << endmsg
;
669 if (item
&& other_item
&& other_item_2
&& track()->mode() != mode
) {
670 _set_track_mode (track().get(), mode
, other_item
, other_item_2
);
675 RouteTimeAxisView::_set_track_mode (Track
* track
, TrackMode mode
, RadioMenuItem
* reset_item
, RadioMenuItem
* reset_item_2
)
679 if (!track
->can_use_mode (mode
, needs_bounce
)) {
683 Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (__reset_item
), reset_item
, reset_item_2
));
686 cerr
<< "would bounce this one\n";
687 /* XXX: radio menu item becomes inconsistent with track state in this case */
692 track
->set_mode (mode
);
694 rec_enable_button
->remove ();
697 case ARDOUR::NonLayered
:
699 rec_enable_button
->add (*(manage (new Image (::get_icon (X_("record_normal_red"))))));
701 case ARDOUR::Destructive
:
702 rec_enable_button
->add (*(manage (new Image (::get_icon (X_("record_tape_red"))))));
706 rec_enable_button
->show_all ();
710 RouteTimeAxisView::track_mode_changed ()
714 switch (track()->mode()) {
716 item
= normal_track_mode_item
;
718 case ARDOUR::NonLayered
:
719 item
= non_layered_track_mode_item
;
721 case ARDOUR::Destructive
:
722 item
= destructive_track_mode_item
;
725 fatal
<< string_compose (_("programming error: %1 %2"), "illegal track mode in RouteTimeAxisView::set_track_mode", track()->mode()) << endmsg
;
734 RouteTimeAxisView::show_timestretch (framepos_t start
, framepos_t end
)
740 TimeAxisView::show_timestretch (start
, end
);
750 /* check that the time selection was made in our route, or our route group.
751 remember that route_group() == 0 implies the route is *not* in a edit group.
754 if (!(ts
.track
== this || (ts
.group
!= 0 && ts
.group
== _route
->route_group()))) {
755 /* this doesn't apply to us */
759 /* ignore it if our edit group is not active */
761 if ((ts
.track
!= this) && _route
->route_group() && !_route
->route_group()->is_active()) {
766 if (timestretch_rect
== 0) {
767 timestretch_rect
= new SimpleRect (*canvas_display ());
768 timestretch_rect
->property_x1() = 0.0;
769 timestretch_rect
->property_y1() = 0.0;
770 timestretch_rect
->property_x2() = 0.0;
771 timestretch_rect
->property_y2() = 0.0;
772 timestretch_rect
->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill
.get();
773 timestretch_rect
->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline
.get();
776 timestretch_rect
->show ();
777 timestretch_rect
->raise_to_top ();
779 x1
= start
/ _editor
.get_current_zoom();
780 x2
= (end
- 1) / _editor
.get_current_zoom();
781 y2
= current_height() - 2;
783 timestretch_rect
->property_x1() = x1
;
784 timestretch_rect
->property_y1() = 1.0;
785 timestretch_rect
->property_x2() = x2
;
786 timestretch_rect
->property_y2() = y2
;
790 RouteTimeAxisView::hide_timestretch ()
792 TimeAxisView::hide_timestretch ();
794 if (timestretch_rect
) {
795 timestretch_rect
->hide ();
800 RouteTimeAxisView::show_selection (TimeSelection
& ts
)
804 /* ignore it if our edit group is not active or if the selection was started
805 in some other track or route group (remember that route_group() == 0 means
806 that the track is not in an route group).
809 if (((ts
.track
!= this && !is_child (ts
.track
)) && _route
->route_group() && !_route
->route_group()->is_active()) ||
810 (!(ts
.track
== this || is_child (ts
.track
) || (ts
.group
!= 0 && ts
.group
== _route
->route_group())))) {
816 TimeAxisView::show_selection (ts
);
820 RouteTimeAxisView::set_height (uint32_t h
)
823 bool height_changed
= (height
== 0) || (h
!= height
);
824 gm
.get_level_meter().setup_meters (gmlen
);
826 TimeAxisView::set_height (h
);
831 _view
->set_height ((double) current_height());
835 snprintf (buf
, sizeof (buf
), "%u", height
);
836 xml_node
->add_property ("height", buf
);
838 if (height
>= preset_height (HeightNormal
)) {
843 gm
.get_gain_slider().show();
845 if (!_route
|| _route
->is_monitor()) {
850 if (rec_enable_button
)
851 rec_enable_button
->show();
853 route_group_button
.show();
854 automation_button
.show();
856 if (is_track() && track()->mode() == ARDOUR::Normal
) {
857 playlist_button
.show();
860 } else if (height
>= preset_height (HeightSmaller
)) {
866 gm
.get_gain_slider().hide();
868 if (!_route
|| _route
->is_monitor()) {
873 if (rec_enable_button
)
874 rec_enable_button
->show();
876 route_group_button
.hide ();
877 automation_button
.hide ();
879 if (is_track() && track()->mode() == ARDOUR::Normal
) {
880 playlist_button
.hide ();
886 /* don't allow name_entry to be hidden while
887 it has focus, otherwise the GUI becomes unusable.
890 if (name_entry
.has_focus()) {
891 if (name_entry
.get_text() != _route
->name()) {
892 name_entry_changed ();
894 controls_ebox
.grab_focus ();
900 gm
.get_gain_slider().hide();
903 if (rec_enable_button
)
904 rec_enable_button
->hide();
906 route_group_button
.hide ();
907 automation_button
.hide ();
908 playlist_button
.hide ();
909 name_label
.set_text (_route
->name());
912 if (height_changed
&& !no_redraw
) {
913 /* only emit the signal if the height really changed */
914 _route
->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
919 RouteTimeAxisView::set_color (Gdk::Color
const & c
)
921 RouteUI::set_color (c
);
924 _view
->apply_color (_color
, StreamView::RegionColor
);
929 RouteTimeAxisView::reset_samples_per_unit ()
931 set_samples_per_unit (_editor
.get_current_zoom());
935 RouteTimeAxisView::horizontal_position_changed ()
938 _view
->horizontal_position_changed ();
943 RouteTimeAxisView::set_samples_per_unit (double spu
)
948 speed
= track()->speed();
952 _view
->set_samples_per_unit (spu
* speed
);
955 TimeAxisView::set_samples_per_unit (spu
* speed
);
959 RouteTimeAxisView::set_align_style (AlignStyle style
, bool apply_to_selection
)
961 if (apply_to_selection
) {
962 _editor
.get_selection().tracks
.foreach_route_time_axis (boost::bind (&RouteTimeAxisView::set_align_style
, _1
, style
, false));
965 track()->set_align_style (style
);
971 RouteTimeAxisView::rename_current_playlist ()
973 ArdourPrompter
prompter (true);
976 boost::shared_ptr
<Track
> tr
= track();
977 if (!tr
|| tr
->destructive()) {
981 boost::shared_ptr
<Playlist
> pl
= tr
->playlist();
986 prompter
.set_title (_("Rename Playlist"));
987 prompter
.set_prompt (_("New name for playlist:"));
988 prompter
.set_initial_text (pl
->name());
989 prompter
.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT
);
990 prompter
.set_response_sensitive (Gtk::RESPONSE_ACCEPT
, false);
992 switch (prompter
.run ()) {
993 case Gtk::RESPONSE_ACCEPT
:
994 prompter
.get_result (name
);
1006 RouteTimeAxisView::resolve_new_group_playlist_name(std::string
&basename
, vector
<boost::shared_ptr
<Playlist
> > const & playlists
)
1008 std::string
ret (basename
);
1010 std::string
const group_string
= "." + route_group()->name() + ".";
1012 // iterate through all playlists
1014 for (vector
<boost::shared_ptr
<Playlist
> >::const_iterator i
= playlists
.begin(); i
!= playlists
.end(); ++i
) {
1015 std::string tmp
= (*i
)->name();
1017 std::string::size_type idx
= tmp
.find(group_string
);
1018 // find those which belong to this group
1019 if (idx
!= string::npos
) {
1020 tmp
= tmp
.substr(idx
+ group_string
.length());
1022 // and find the largest current number
1023 int x
= atoi(tmp
.c_str());
1024 if (x
> maxnumber
) {
1033 snprintf (buf
, sizeof(buf
), "%d", maxnumber
);
1035 ret
= this->name() + "." + route_group()->name () + "." + buf
;
1041 RouteTimeAxisView::use_copy_playlist (bool prompt
, vector
<boost::shared_ptr
<Playlist
> > const & playlists_before_op
)
1045 boost::shared_ptr
<Track
> tr
= track ();
1046 if (!tr
|| tr
->destructive()) {
1050 boost::shared_ptr
<const Playlist
> pl
= tr
->playlist();
1057 if (route_group() && route_group()->is_active()) {
1058 name
= resolve_new_group_playlist_name(name
, playlists_before_op
);
1061 while (_session
->playlists
->by_name(name
)) {
1062 name
= Playlist::bump_name (name
, *_session
);
1065 // TODO: The prompter "new" button should be de-activated if the user
1066 // specifies a playlist name which already exists in the session.
1070 ArdourPrompter
prompter (true);
1072 prompter
.set_title (_("New Copy Playlist"));
1073 prompter
.set_prompt (_("Name for new playlist:"));
1074 prompter
.set_initial_text (name
);
1075 prompter
.add_button (Gtk::Stock::NEW
, Gtk::RESPONSE_ACCEPT
);
1076 prompter
.set_response_sensitive (Gtk::RESPONSE_ACCEPT
, true);
1077 prompter
.show_all ();
1079 switch (prompter
.run ()) {
1080 case Gtk::RESPONSE_ACCEPT
:
1081 prompter
.get_result (name
);
1089 if (name
.length()) {
1090 tr
->use_copy_playlist ();
1091 tr
->playlist()->set_name (name
);
1096 RouteTimeAxisView::use_new_playlist (bool prompt
, vector
<boost::shared_ptr
<Playlist
> > const & playlists_before_op
)
1100 boost::shared_ptr
<Track
> tr
= track ();
1101 if (!tr
|| tr
->destructive()) {
1105 boost::shared_ptr
<const Playlist
> pl
= tr
->playlist();
1112 if (route_group() && route_group()->is_active()) {
1113 name
= resolve_new_group_playlist_name(name
,playlists_before_op
);
1116 while (_session
->playlists
->by_name(name
)) {
1117 name
= Playlist::bump_name (name
, *_session
);
1123 ArdourPrompter
prompter (true);
1125 prompter
.set_title (_("New Playlist"));
1126 prompter
.set_prompt (_("Name for new playlist:"));
1127 prompter
.set_initial_text (name
);
1128 prompter
.add_button (Gtk::Stock::NEW
, Gtk::RESPONSE_ACCEPT
);
1129 prompter
.set_response_sensitive (Gtk::RESPONSE_ACCEPT
, true);
1131 switch (prompter
.run ()) {
1132 case Gtk::RESPONSE_ACCEPT
:
1133 prompter
.get_result (name
);
1141 if (name
.length()) {
1142 tr
->use_new_playlist ();
1143 tr
->playlist()->set_name (name
);
1148 RouteTimeAxisView::clear_playlist ()
1150 boost::shared_ptr
<Track
> tr
= track ();
1151 if (!tr
|| tr
->destructive()) {
1155 boost::shared_ptr
<Playlist
> pl
= tr
->playlist();
1160 _editor
.clear_playlist (pl
);
1164 RouteTimeAxisView::speed_changed ()
1166 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::reset_samples_per_unit
, this));
1170 RouteTimeAxisView::update_diskstream_display ()
1180 RouteTimeAxisView::selection_click (GdkEventButton
* ev
)
1182 if (Keyboard::modifier_state_equals (ev
->state
, (Keyboard::TertiaryModifier
|Keyboard::PrimaryModifier
))) {
1184 /* special case: select/deselect all tracks */
1185 if (_editor
.get_selection().selected (this)) {
1186 _editor
.get_selection().clear_tracks ();
1188 _editor
.select_all_tracks ();
1194 switch (ArdourKeyboard::selection_type (ev
->state
)) {
1195 case Selection::Toggle
:
1196 _editor
.get_selection().toggle (this);
1199 case Selection::Set
:
1200 _editor
.get_selection().set (this);
1203 case Selection::Extend
:
1204 _editor
.extend_selection_to_track (*this);
1207 case Selection::Add
:
1208 _editor
.get_selection().add (this);
1214 RouteTimeAxisView::set_selected_points (PointSelection
& points
)
1216 for (Children::iterator i
= children
.begin(); i
!= children
.end(); ++i
) {
1217 (*i
)->set_selected_points (points
);
1222 RouteTimeAxisView::set_selected_regionviews (RegionSelection
& regions
)
1225 _view
->set_selected_regionviews (regions
);
1229 /** Add the selectable things that we have to a list.
1230 * @param results List to add things to.
1233 RouteTimeAxisView::get_selectables (framepos_t start
, framepos_t end
, double top
, double bot
, list
<Selectable
*>& results
)
1238 speed
= track()->speed();
1241 framepos_t
const start_adjusted
= session_frame_to_track_frame(start
, speed
);
1242 framepos_t
const end_adjusted
= session_frame_to_track_frame(end
, speed
);
1244 if ((_view
&& ((top
< 0.0 && bot
< 0.0))) || touched (top
, bot
)) {
1245 _view
->get_selectables (start_adjusted
, end_adjusted
, top
, bot
, results
);
1248 /* pick up visible automation tracks */
1250 for (Children::iterator i
= children
.begin(); i
!= children
.end(); ++i
) {
1251 if (!(*i
)->hidden()) {
1252 (*i
)->get_selectables (start_adjusted
, end_adjusted
, top
, bot
, results
);
1258 RouteTimeAxisView::get_inverted_selectables (Selection
& sel
, list
<Selectable
*>& results
)
1261 _view
->get_inverted_selectables (sel
, results
);
1264 for (Children::iterator i
= children
.begin(); i
!= children
.end(); ++i
) {
1265 if (!(*i
)->hidden()) {
1266 (*i
)->get_inverted_selectables (sel
, results
);
1274 RouteTimeAxisView::route_group () const
1276 return _route
->route_group();
1280 RouteTimeAxisView::name() const
1282 return _route
->name();
1285 boost::shared_ptr
<Playlist
>
1286 RouteTimeAxisView::playlist () const
1288 boost::shared_ptr
<Track
> tr
;
1290 if ((tr
= track()) != 0) {
1291 return tr
->playlist();
1293 return boost::shared_ptr
<Playlist
> ();
1298 RouteTimeAxisView::name_entry_changed ()
1302 x
= name_entry
.get_text ();
1304 if (x
== _route
->name()) {
1308 strip_whitespace_edges(x
);
1310 if (x
.length() == 0) {
1311 name_entry
.set_text (_route
->name());
1315 if (!_session
->route_name_unique (x
)) {
1316 ARDOUR_UI::instance()->popup_error (_("A track already exists with that name"));
1317 name_entry
.set_text (_route
->name());
1318 } else if (_session
->route_name_internal (x
)) {
1319 ARDOUR_UI::instance()->popup_error (string_compose (_("You cannot create a track with that name as it is reserved for %1"),
1321 name_entry
.set_text (_route
->name());
1323 _route
->set_name (x
);
1327 boost::shared_ptr
<Region
>
1328 RouteTimeAxisView::find_next_region (framepos_t pos
, RegionPoint point
, int32_t dir
)
1330 boost::shared_ptr
<Playlist
> pl
= playlist ();
1333 return pl
->find_next_region (pos
, point
, dir
);
1336 return boost::shared_ptr
<Region
> ();
1340 RouteTimeAxisView::find_next_region_boundary (framepos_t pos
, int32_t dir
)
1342 boost::shared_ptr
<Playlist
> pl
= playlist ();
1345 return pl
->find_next_region_boundary (pos
, dir
);
1352 RouteTimeAxisView::cut_copy_clear (Selection
& selection
, CutCopyOp op
)
1354 boost::shared_ptr
<Playlist
> what_we_got
;
1355 boost::shared_ptr
<Track
> tr
= track ();
1356 boost::shared_ptr
<Playlist
> playlist
;
1359 /* route is a bus, not a track */
1363 playlist
= tr
->playlist();
1365 TimeSelection
time (selection
.time
);
1366 float const speed
= tr
->speed();
1367 if (speed
!= 1.0f
) {
1368 for (TimeSelection::iterator i
= time
.begin(); i
!= time
.end(); ++i
) {
1369 (*i
).start
= session_frame_to_track_frame((*i
).start
, speed
);
1370 (*i
).end
= session_frame_to_track_frame((*i
).end
, speed
);
1374 playlist
->clear_changes ();
1375 playlist
->clear_owned_changes ();
1379 if ((what_we_got
= playlist
->cut (time
)) != 0) {
1380 _editor
.get_cut_buffer().add (what_we_got
);
1382 vector
<Command
*> cmds
;
1383 playlist
->rdiff (cmds
);
1384 _session
->add_commands (cmds
);
1386 _session
->add_command (new StatefulDiffCommand (playlist
));
1390 if ((what_we_got
= playlist
->copy (time
)) != 0) {
1391 _editor
.get_cut_buffer().add (what_we_got
);
1396 if ((what_we_got
= playlist
->cut (time
)) != 0) {
1398 vector
<Command
*> cmds
;
1399 playlist
->rdiff (cmds
);
1400 _session
->add_commands (cmds
);
1401 _session
->add_command (new StatefulDiffCommand (playlist
));
1402 what_we_got
->release ();
1409 RouteTimeAxisView::paste (framepos_t pos
, float times
, Selection
& selection
, size_t nth
)
1415 boost::shared_ptr
<Playlist
> pl
= playlist ();
1416 PlaylistSelection::iterator p
;
1418 for (p
= selection
.playlists
.begin(); p
!= selection
.playlists
.end() && nth
; ++p
, --nth
) {}
1420 if (p
== selection
.playlists
.end()) {
1424 DEBUG_TRACE (DEBUG::CutNPaste
, string_compose ("paste to %1\n", pos
));
1426 if (track()->speed() != 1.0f
) {
1427 pos
= session_frame_to_track_frame (pos
, track()->speed());
1428 DEBUG_TRACE (DEBUG::CutNPaste
, string_compose ("modified paste to %1\n", pos
));
1431 pl
->clear_changes ();
1432 pl
->paste (*p
, pos
, times
);
1433 _session
->add_command (new StatefulDiffCommand (pl
));
1439 struct PlaylistSorter
{
1440 bool operator() (boost::shared_ptr
<Playlist
> a
, boost::shared_ptr
<Playlist
> b
) const {
1441 return a
->sort_id() < b
->sort_id();
1446 RouteTimeAxisView::build_playlist_menu ()
1448 using namespace Menu_Helpers
;
1454 delete playlist_action_menu
;
1455 playlist_action_menu
= new Menu
;
1456 playlist_action_menu
->set_name ("ArdourContextMenu");
1458 MenuList
& playlist_items
= playlist_action_menu
->items();
1459 playlist_action_menu
->set_name ("ArdourContextMenu");
1460 playlist_items
.clear();
1462 vector
<boost::shared_ptr
<Playlist
> > playlists
, playlists_tr
;
1463 boost::shared_ptr
<Track
> tr
= track();
1464 RadioMenuItem::Group playlist_group
;
1466 _session
->playlists
->get (playlists
);
1468 /* find the playlists for this diskstream */
1469 for (vector
<boost::shared_ptr
<Playlist
> >::iterator i
= playlists
.begin(); i
!= playlists
.end(); ++i
) {
1470 if (((*i
)->get_orig_diskstream_id() == tr
->diskstream_id()) || (tr
->playlist()->id() == (*i
)->id())) {
1471 playlists_tr
.push_back(*i
);
1475 /* sort the playlists */
1477 sort (playlists_tr
.begin(), playlists_tr
.end(), cmp
);
1479 /* add the playlists to the menu */
1480 for (vector
<boost::shared_ptr
<Playlist
> >::iterator i
= playlists_tr
.begin(); i
!= playlists_tr
.end(); ++i
) {
1481 playlist_items
.push_back (RadioMenuElem (playlist_group
, (*i
)->name()));
1482 RadioMenuItem
*item
= static_cast<RadioMenuItem
*>(&playlist_items
.back());
1483 item
->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist
), item
, boost::weak_ptr
<Playlist
> (*i
)));
1485 if (tr
->playlist()->id() == (*i
)->id()) {
1491 playlist_items
.push_back (SeparatorElem());
1492 playlist_items
.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist
)));
1493 playlist_items
.push_back (SeparatorElem());
1495 if (!route_group() || !route_group()->is_active()) {
1496 playlist_items
.push_back (MenuElem (_("New..."), sigc::bind(sigc::mem_fun(_editor
, &PublicEditor::new_playlists
), this)));
1497 playlist_items
.push_back (MenuElem (_("New Copy..."), sigc::bind(sigc::mem_fun(_editor
, &PublicEditor::copy_playlists
), this)));
1500 // Use a label which tells the user what is happening
1501 playlist_items
.push_back (MenuElem (_("New Take"), sigc::bind(sigc::mem_fun(_editor
, &PublicEditor::new_playlists
), this)));
1502 playlist_items
.push_back (MenuElem (_("Copy Take"), sigc::bind(sigc::mem_fun(_editor
, &PublicEditor::copy_playlists
), this)));
1506 playlist_items
.push_back (SeparatorElem());
1507 playlist_items
.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(_editor
, &PublicEditor::clear_playlists
), this)));
1508 playlist_items
.push_back (SeparatorElem());
1510 playlist_items
.push_back (MenuElem(_("Select from all..."), sigc::mem_fun(*this, &RouteTimeAxisView::show_playlist_selector
)));
1514 RouteTimeAxisView::use_playlist (RadioMenuItem
*item
, boost::weak_ptr
<Playlist
> wpl
)
1516 assert (is_track());
1518 // exit if we were triggered by deactivating the old playlist
1519 if (!item
->get_active()) {
1523 boost::shared_ptr
<Playlist
> pl (wpl
.lock());
1529 boost::shared_ptr
<AudioPlaylist
> apl
= boost::dynamic_pointer_cast
<AudioPlaylist
> (pl
);
1532 if (track()->playlist() == apl
) {
1533 // exit when use_playlist is called by the creation of the playlist menu
1534 // or the playlist choice is unchanged
1537 track()->use_playlist (apl
);
1539 if (route_group() && route_group()->is_active()) {
1540 std::string group_string
= "."+route_group()->name()+".";
1542 std::string take_name
= apl
->name();
1543 std::string::size_type idx
= take_name
.find(group_string
);
1545 if (idx
== std::string::npos
)
1548 take_name
= take_name
.substr(idx
+ group_string
.length()); // find the bit containing the take number / name
1550 boost::shared_ptr
<RouteList
> rl (route_group()->route_list());
1552 for (RouteList::const_iterator i
= rl
->begin(); i
!= rl
->end(); ++i
) {
1553 if ( (*i
) == this->route()) {
1557 std::string playlist_name
= (*i
)->name()+group_string
+take_name
;
1559 boost::shared_ptr
<Track
> track
= boost::dynamic_pointer_cast
<Track
>(*i
);
1561 std::cerr
<< "route " << (*i
)->name() << " is not a Track" << std::endl
;
1565 boost::shared_ptr
<Playlist
> ipl
= session()->playlists
->by_name(playlist_name
);
1567 // No playlist for this track for this take yet, make it
1568 track
->use_new_playlist();
1569 track
->playlist()->set_name(playlist_name
);
1571 track
->use_playlist(ipl
);
1579 RouteTimeAxisView::show_playlist_selector ()
1581 _editor
.playlist_selector().show_for (this);
1585 RouteTimeAxisView::map_frozen ()
1591 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::map_frozen
)
1593 switch (track()->freeze_state()) {
1595 playlist_button
.set_sensitive (false);
1596 rec_enable_button
->set_sensitive (false);
1599 playlist_button
.set_sensitive (true);
1600 rec_enable_button
->set_sensitive (true);
1606 RouteTimeAxisView::color_handler ()
1608 //case cTimeStretchOutline:
1609 if (timestretch_rect
) {
1610 timestretch_rect
->property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchOutline
.get();
1612 //case cTimeStretchFill:
1613 if (timestretch_rect
) {
1614 timestretch_rect
->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_TimeStretchFill
.get();
1620 /** Toggle an automation track for a fully-specified Parameter (type,channel,id)
1621 * Will add track if necessary.
1624 RouteTimeAxisView::toggle_automation_track (const Evoral::Parameter
& param
)
1626 boost::shared_ptr
<AutomationTimeAxisView
> track
= automation_child (param
);
1627 Gtk::CheckMenuItem
* menu
= automation_child_menu_item (param
);
1630 /* it doesn't exist yet, so we don't care about the button state: just add it */
1631 create_automation_child (param
, true);
1634 bool yn
= menu
->get_active();
1635 if (track
->set_visibility (menu
->get_active()) && yn
) {
1637 /* we made it visible, now trigger a redisplay. if it was hidden, then automation_track_hidden()
1638 will have done that for us.
1642 _route
->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
1649 RouteTimeAxisView::automation_track_hidden (Evoral::Parameter param
)
1651 boost::shared_ptr
<AutomationTimeAxisView
> track
= automation_child (param
);
1657 Gtk::CheckMenuItem
* menu
= automation_child_menu_item (param
);
1659 // if Evoral::Parameter::operator< doesn't obey strict weak ordering, we may crash here....
1660 track
->get_state_node()->add_property (X_("shown"), X_("no"));
1662 if (menu
&& !_hidden
) {
1663 ignore_toggle
= true;
1664 menu
->set_active (false);
1665 ignore_toggle
= false;
1668 if (_route
&& !no_redraw
) {
1669 _route
->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1675 RouteTimeAxisView::show_all_automation ()
1679 /* Show our automation */
1681 for (AutomationTracks::iterator i
= _automation_tracks
.begin(); i
!= _automation_tracks
.end(); ++i
) {
1682 i
->second
->set_marked_for_display (true);
1683 i
->second
->canvas_display()->show();
1684 i
->second
->get_state_node()->add_property ("shown", X_("yes"));
1686 Gtk::CheckMenuItem
* menu
= automation_child_menu_item (i
->first
);
1689 menu
->set_active(true);
1694 /* Show processor automation */
1696 for (list
<ProcessorAutomationInfo
*>::iterator i
= processor_automation
.begin(); i
!= processor_automation
.end(); ++i
) {
1697 for (vector
<ProcessorAutomationNode
*>::iterator ii
= (*i
)->lines
.begin(); ii
!= (*i
)->lines
.end(); ++ii
) {
1698 if ((*ii
)->view
== 0) {
1699 add_processor_automation_curve ((*i
)->processor
, (*ii
)->what
);
1702 (*ii
)->menu_item
->set_active (true);
1710 _route
->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1714 RouteTimeAxisView::show_existing_automation ()
1718 /* Show our automation */
1720 for (AutomationTracks::iterator i
= _automation_tracks
.begin(); i
!= _automation_tracks
.end(); ++i
) {
1721 if (i
->second
->has_automation()) {
1722 i
->second
->set_marked_for_display (true);
1723 i
->second
->canvas_display()->show();
1724 i
->second
->get_state_node()->add_property ("shown", X_("yes"));
1726 Gtk::CheckMenuItem
* menu
= automation_child_menu_item (i
->first
);
1728 menu
->set_active(true);
1734 /* Show processor automation */
1736 for (list
<ProcessorAutomationInfo
*>::iterator i
= processor_automation
.begin(); i
!= processor_automation
.end(); ++i
) {
1737 for (vector
<ProcessorAutomationNode
*>::iterator ii
= (*i
)->lines
.begin(); ii
!= (*i
)->lines
.end(); ++ii
) {
1738 if ((*ii
)->view
!= 0 && (*i
)->processor
->control((*ii
)->what
)->list()->size() > 0) {
1739 (*ii
)->menu_item
->set_active (true);
1746 _route
->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1750 RouteTimeAxisView::hide_all_automation ()
1754 /* Hide our automation */
1756 for (AutomationTracks::iterator i
= _automation_tracks
.begin(); i
!= _automation_tracks
.end(); ++i
) {
1757 i
->second
->set_marked_for_display (false);
1759 i
->second
->get_state_node()->add_property ("shown", X_("no"));
1761 Gtk::CheckMenuItem
* menu
= automation_child_menu_item (i
->first
);
1764 menu
->set_active (false);
1768 /* Hide processor automation */
1770 for (list
<ProcessorAutomationInfo
*>::iterator i
= processor_automation
.begin(); i
!= processor_automation
.end(); ++i
) {
1771 for (vector
<ProcessorAutomationNode
*>::iterator ii
= (*i
)->lines
.begin(); ii
!= (*i
)->lines
.end(); ++ii
) {
1772 (*ii
)->menu_item
->set_active (false);
1777 _route
->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1782 RouteTimeAxisView::region_view_added (RegionView
* rv
)
1784 /* XXX need to find out if automation children have automationstreamviews. If yes, no ghosts */
1785 for (Children::iterator i
= children
.begin(); i
!= children
.end(); ++i
) {
1786 boost::shared_ptr
<AutomationTimeAxisView
> atv
;
1788 if ((atv
= boost::dynamic_pointer_cast
<AutomationTimeAxisView
> (*i
)) != 0) {
1793 for (UnderlayMirrorList::iterator i
= _underlay_mirrors
.begin(); i
!= _underlay_mirrors
.end(); ++i
) {
1794 (*i
)->add_ghost(rv
);
1798 RouteTimeAxisView::ProcessorAutomationInfo::~ProcessorAutomationInfo ()
1800 for (vector
<ProcessorAutomationNode
*>::iterator i
= lines
.begin(); i
!= lines
.end(); ++i
) {
1806 RouteTimeAxisView::ProcessorAutomationNode::~ProcessorAutomationNode ()
1808 parent
.remove_processor_automation_node (this);
1812 RouteTimeAxisView::remove_processor_automation_node (ProcessorAutomationNode
* pan
)
1815 remove_child (pan
->view
);
1819 RouteTimeAxisView::ProcessorAutomationNode
*
1820 RouteTimeAxisView::find_processor_automation_node (boost::shared_ptr
<Processor
> processor
, Evoral::Parameter what
)
1822 for (list
<ProcessorAutomationInfo
*>::iterator i
= processor_automation
.begin(); i
!= processor_automation
.end(); ++i
) {
1824 if ((*i
)->processor
== processor
) {
1826 for (vector
<ProcessorAutomationNode
*>::iterator ii
= (*i
)->lines
.begin(); ii
!= (*i
)->lines
.end(); ++ii
) {
1827 if ((*ii
)->what
== what
) {
1838 legalize_for_xml_node (string str
)
1840 string::size_type pos
;
1841 string legal_chars
= "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=:";
1847 while ((pos
= legal
.find_first_not_of (legal_chars
, pos
)) != string::npos
) {
1848 legal
.replace (pos
, 1, "_");
1857 RouteTimeAxisView::add_processor_automation_curve (boost::shared_ptr
<Processor
> processor
, Evoral::Parameter what
)
1860 ProcessorAutomationNode
* pan
;
1862 if ((pan
= find_processor_automation_node (processor
, what
)) == 0) {
1863 /* session state may never have been saved with new plugin */
1864 error
<< _("programming error: ")
1865 << string_compose (X_("processor automation curve for %1:%2/%3/%4 not registered with track!"),
1866 processor
->name(), what
.type(), (int) what
.channel(), what
.id() )
1876 name
= processor
->describe_parameter (what
);
1878 /* create a string that is a legal XML node name that can be used to refer to this redirect+port combination */
1882 char state_name
[256];
1883 snprintf (state_name
, sizeof (state_name
), "%s-%" PRIu32
, legalize_for_xml_node (processor
->name()).c_str(), what
.id());
1885 boost::shared_ptr
<AutomationControl
> control
1886 = boost::dynamic_pointer_cast
<AutomationControl
>(processor
->control(what
, true));
1888 pan
->view
= boost::shared_ptr
<AutomationTimeAxisView
>(
1889 new AutomationTimeAxisView (_session
, _route
, processor
, control
, control
->parameter (),
1890 _editor
, *this, false, parent_canvas
, name
, state_name
));
1892 pan
->view
->Hiding
.connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_automation_track_hidden
), pan
, processor
));
1894 if (!pan
->view
->marked_for_display()) {
1897 pan
->menu_item
->set_active (true);
1900 add_child (pan
->view
);
1903 _view
->foreach_regionview (sigc::mem_fun(*pan
->view
.get(), &TimeAxisView::add_ghost
));
1906 processor
->mark_automation_visible (what
, true);
1910 RouteTimeAxisView::processor_automation_track_hidden (RouteTimeAxisView::ProcessorAutomationNode
* pan
, boost::shared_ptr
<Processor
> i
)
1913 pan
->menu_item
->set_active (false);
1916 i
->mark_automation_visible (pan
->what
, false);
1919 _route
->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1924 RouteTimeAxisView::add_existing_processor_automation_curves (boost::weak_ptr
<Processor
> p
)
1926 boost::shared_ptr
<Processor
> processor (p
.lock ());
1931 set
<Evoral::Parameter
> s
;
1932 boost::shared_ptr
<AutomationLine
> al
;
1934 processor
->what_has_visible_data (s
);
1936 for (set
<Evoral::Parameter
>::iterator i
= s
.begin(); i
!= s
.end(); ++i
) {
1938 if ((al
= find_processor_automation_curve (processor
, *i
)) != 0) {
1941 add_processor_automation_curve (processor
, (*i
));
1947 RouteTimeAxisView::add_automation_child (Evoral::Parameter param
, boost::shared_ptr
<AutomationTimeAxisView
> track
, bool show
)
1949 using namespace Menu_Helpers
;
1956 track
->Hiding
.connect (sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::automation_track_hidden
), param
));
1958 bool hideit
= (!show
);
1960 if ((node
= track
->get_state_node()) != 0) {
1961 if ((prop
= node
->property ("shown")) != 0) {
1962 if (string_is_affirmative (prop
->value())) {
1968 _automation_tracks
[param
] = track
;
1970 track
->set_visibility (!hideit
);
1973 _route
->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
1976 if (!EventTypeMap::instance().is_midi_parameter(param
)) {
1977 /* MIDI-related parameters are always in the menu, there's no
1978 reason to rebuild the menu just because we added a automation
1979 lane for one of them. But if we add a non-MIDI automation
1980 lane, then we need to invalidate the display menu.
1982 delete display_menu
;
1988 RouteTimeAxisView::add_processor_to_subplugin_menu (boost::weak_ptr
<Processor
> p
)
1990 boost::shared_ptr
<Processor
> processor (p
.lock ());
1992 if (!processor
|| !processor
->display_to_user ()) {
1996 using namespace Menu_Helpers
;
1997 ProcessorAutomationInfo
*rai
;
1998 list
<ProcessorAutomationInfo
*>::iterator x
;
2000 const std::set
<Evoral::Parameter
>& automatable
= processor
->what_can_be_automated ();
2001 std::set
<Evoral::Parameter
> has_visible_automation
;
2003 processor
->what_has_visible_data(has_visible_automation
);
2005 if (automatable
.empty()) {
2009 for (x
= processor_automation
.begin(); x
!= processor_automation
.end(); ++x
) {
2010 if ((*x
)->processor
== processor
) {
2015 if (x
== processor_automation
.end()) {
2017 rai
= new ProcessorAutomationInfo (processor
);
2018 processor_automation
.push_back (rai
);
2026 /* any older menu was deleted at the top of processors_changed()
2027 when we cleared the subplugin menu.
2030 rai
->menu
= manage (new Menu
);
2031 MenuList
& items
= rai
->menu
->items();
2032 rai
->menu
->set_name ("ArdourContextMenu");
2036 for (std::set
<Evoral::Parameter
>::const_iterator i
= automatable
.begin(); i
!= automatable
.end(); ++i
) {
2038 ProcessorAutomationNode
* pan
;
2039 CheckMenuItem
* mitem
;
2041 string name
= processor
->describe_parameter (*i
);
2043 items
.push_back (CheckMenuElem (name
));
2044 mitem
= dynamic_cast<CheckMenuItem
*> (&items
.back());
2046 _subplugin_menu_map
[*i
] = mitem
;
2048 if (has_visible_automation
.find((*i
)) != has_visible_automation
.end()) {
2049 mitem
->set_active(true);
2052 if ((pan
= find_processor_automation_node (processor
, *i
)) == 0) {
2056 pan
= new ProcessorAutomationNode (*i
, mitem
, *this);
2058 rai
->lines
.push_back (pan
);
2062 pan
->menu_item
= mitem
;
2066 mitem
->signal_toggled().connect (sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::processor_menu_item_toggled
), rai
, pan
));
2069 /* add the menu for this processor, because the subplugin
2070 menu is always cleared at the top of processors_changed().
2071 this is the result of some poor design in gtkmm and/or
2075 subplugin_menu
.items().push_back (MenuElem (processor
->name(), *rai
->menu
));
2080 RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo
* rai
,
2081 RouteTimeAxisView::ProcessorAutomationNode
* pan
)
2083 bool showit
= pan
->menu_item
->get_active();
2084 bool redraw
= false;
2086 if (pan
->view
== 0 && showit
) {
2087 add_processor_automation_curve (rai
->processor
, pan
->what
);
2091 if (pan
->view
&& showit
!= pan
->view
->marked_for_display()) {
2094 pan
->view
->set_marked_for_display (true);
2095 pan
->view
->canvas_display()->show();
2096 pan
->view
->canvas_background()->show();
2098 rai
->processor
->mark_automation_visible (pan
->what
, true);
2099 pan
->view
->set_marked_for_display (false);
2107 if (redraw
&& !no_redraw
) {
2108 _route
->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
2114 RouteTimeAxisView::processors_changed (RouteProcessorChange c
)
2116 if (c
.type
== RouteProcessorChange::MeterPointChange
) {
2117 /* nothing to do if only the meter point has changed */
2121 using namespace Menu_Helpers
;
2123 for (list
<ProcessorAutomationInfo
*>::iterator i
= processor_automation
.begin(); i
!= processor_automation
.end(); ++i
) {
2124 (*i
)->valid
= false;
2127 _subplugin_menu_map
.clear ();
2128 subplugin_menu
.items().clear ();
2130 _route
->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_processor_to_subplugin_menu
));
2131 _route
->foreach_processor (sigc::mem_fun (*this, &RouteTimeAxisView::add_existing_processor_automation_curves
));
2133 bool deleted_processor_automation
= false;
2135 for (list
<ProcessorAutomationInfo
*>::iterator i
= processor_automation
.begin(); i
!= processor_automation
.end(); ) {
2137 list
<ProcessorAutomationInfo
*>::iterator tmp
;
2145 processor_automation
.erase (i
);
2146 deleted_processor_automation
= true;
2153 if (deleted_processor_automation
&& !no_redraw
) {
2154 _route
->gui_changed ("track_height", this);
2158 boost::shared_ptr
<AutomationLine
>
2159 RouteTimeAxisView::find_processor_automation_curve (boost::shared_ptr
<Processor
> processor
, Evoral::Parameter what
)
2161 ProcessorAutomationNode
* pan
;
2163 if ((pan
= find_processor_automation_node (processor
, what
)) != 0) {
2169 return boost::shared_ptr
<AutomationLine
>();
2173 RouteTimeAxisView::reset_processor_automation_curves ()
2175 for (ProcessorAutomationCurves::iterator i
= processor_automation_curves
.begin(); i
!= processor_automation_curves
.end(); ++i
) {
2181 RouteTimeAxisView::update_rec_display ()
2183 RouteUI::update_rec_display ();
2184 name_entry
.set_sensitive (!_route
->record_enabled());
2188 RouteTimeAxisView::set_layer_display (LayerDisplay d
, bool apply_to_selection
)
2190 if (apply_to_selection
) {
2191 _editor
.get_selection().tracks
.foreach_route_time_axis (boost::bind (&RouteTimeAxisView::set_layer_display
, _1
, d
, false));
2195 _view
->set_layer_display (d
);
2199 xml_node
->add_property (N_("layer-display"), enum_2_string (d
));
2204 RouteTimeAxisView::layer_display () const
2207 return _view
->layer_display ();
2210 /* we don't know, since we don't have a _view, so just return something */
2216 boost::shared_ptr
<AutomationTimeAxisView
>
2217 RouteTimeAxisView::automation_child(Evoral::Parameter param
)
2219 AutomationTracks::iterator i
= _automation_tracks
.find(param
);
2220 if (i
!= _automation_tracks
.end()) {
2223 return boost::shared_ptr
<AutomationTimeAxisView
>();
2228 RouteTimeAxisView::fast_update ()
2230 gm
.get_level_meter().update_meters ();
2234 RouteTimeAxisView::hide_meter ()
2237 gm
.get_level_meter().hide_meters ();
2241 RouteTimeAxisView::show_meter ()
2247 RouteTimeAxisView::reset_meter ()
2249 if (Config
->get_show_track_meters()) {
2250 gm
.get_level_meter().setup_meters (height
-5);
2257 RouteTimeAxisView::clear_meter ()
2259 gm
.get_level_meter().clear_meters ();
2263 RouteTimeAxisView::meter_changed ()
2265 ENSURE_GUI_THREAD (*this, &RouteTimeAxisView::meter_changed
)
2270 RouteTimeAxisView::io_changed (IOChange
/*change*/, void */
*src*/
)
2276 RouteTimeAxisView::build_underlay_menu(Gtk::Menu
* parent_menu
)
2278 using namespace Menu_Helpers
;
2280 if (!_underlay_streams
.empty()) {
2281 MenuList
& parent_items
= parent_menu
->items();
2282 Menu
* gs_menu
= manage (new Menu
);
2283 gs_menu
->set_name ("ArdourContextMenu");
2284 MenuList
& gs_items
= gs_menu
->items();
2286 parent_items
.push_back (MenuElem (_("Underlays"), *gs_menu
));
2288 for(UnderlayList::iterator it
= _underlay_streams
.begin(); it
!= _underlay_streams
.end(); ++it
) {
2289 gs_items
.push_back(MenuElem(string_compose(_("Remove \"%1\""), (*it
)->trackview().name()),
2290 sigc::bind(sigc::mem_fun(*this, &RouteTimeAxisView::remove_underlay
), *it
)));
2296 RouteTimeAxisView::set_underlay_state()
2298 if (!underlay_xml_node
) {
2302 XMLNodeList nlist
= underlay_xml_node
->children();
2303 XMLNodeConstIterator niter
;
2304 XMLNode
*child_node
;
2306 for (niter
= nlist
.begin(); niter
!= nlist
.end(); ++niter
) {
2307 child_node
= *niter
;
2309 if (child_node
->name() != "Underlay") {
2313 XMLProperty
* prop
= child_node
->property ("id");
2315 PBD::ID
id (prop
->value());
2317 RouteTimeAxisView
* v
= _editor
.get_route_view_by_route_id (id
);
2320 add_underlay(v
->view(), false);
2329 RouteTimeAxisView::add_underlay (StreamView
* v
, bool update_xml
)
2335 RouteTimeAxisView
& other
= v
->trackview();
2337 if (find(_underlay_streams
.begin(), _underlay_streams
.end(), v
) == _underlay_streams
.end()) {
2338 if (find(other
._underlay_mirrors
.begin(), other
._underlay_mirrors
.end(), this) != other
._underlay_mirrors
.end()) {
2339 fatal
<< _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg
;
2343 _underlay_streams
.push_back(v
);
2344 other
._underlay_mirrors
.push_back(this);
2346 v
->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::add_ghost
));
2349 if (!underlay_xml_node
) {
2351 underlay_xml_node
= xml_node
->add_child("Underlays");
2354 XMLNode
* node
= underlay_xml_node
->add_child("Underlay");
2355 XMLProperty
* prop
= node
->add_property("id");
2356 prop
->set_value(v
->trackview().route()->id().to_s());
2362 RouteTimeAxisView::remove_underlay (StreamView
* v
)
2368 UnderlayList::iterator it
= find(_underlay_streams
.begin(), _underlay_streams
.end(), v
);
2369 RouteTimeAxisView
& other
= v
->trackview();
2371 if (it
!= _underlay_streams
.end()) {
2372 UnderlayMirrorList::iterator gm
= find(other
._underlay_mirrors
.begin(), other
._underlay_mirrors
.end(), this);
2374 if (gm
== other
._underlay_mirrors
.end()) {
2375 fatal
<< _("programming error: underlay reference pointer pairs are inconsistent!") << endmsg
;
2379 v
->foreach_regionview(sigc::mem_fun(*this, &RouteTimeAxisView::remove_ghost
));
2381 _underlay_streams
.erase(it
);
2382 other
._underlay_mirrors
.erase(gm
);
2384 if (underlay_xml_node
) {
2385 underlay_xml_node
->remove_nodes_and_delete("id", v
->trackview().route()->id().to_s());
2391 RouteTimeAxisView::set_button_names ()
2393 rec_enable_button_label
.set_text (_("r"));
2395 if (_route
&& _route
->solo_safe()) {
2396 solo_button_label
.set_text (X_("!"));
2398 if (Config
->get_solo_control_is_listen_control()) {
2399 switch (Config
->get_listen_position()) {
2400 case AfterFaderListen
:
2401 solo_button_label
.set_text (_("A"));
2403 case PreFaderListen
:
2404 solo_button_label
.set_text (_("P"));
2408 solo_button_label
.set_text (_("s"));
2411 mute_button_label
.set_text (_("m"));
2415 RouteTimeAxisView::automation_child_menu_item (Evoral::Parameter param
)
2417 ParameterMenuMap::iterator i
= _main_automation_menu_map
.find (param
);
2418 if (i
!= _main_automation_menu_map
.end()) {
2422 i
= _subplugin_menu_map
.find (param
);
2423 if (i
!= _subplugin_menu_map
.end()) {
2431 RouteTimeAxisView::create_gain_automation_child (const Evoral::Parameter
& param
, bool show
)
2433 boost::shared_ptr
<AutomationControl
> c
= _route
->gain_control();
2435 error
<< "Route has no gain automation, unable to add automation track view." << endmsg
;
2439 gain_track
.reset (new AutomationTimeAxisView (_session
,
2440 _route
, _route
->amp(), c
, param
,
2445 _route
->amp()->describe_parameter(param
)));
2447 add_automation_child (Evoral::Parameter(GainAutomation
), gain_track
, show
);