2 Copyright (C) 2000-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>
36 #include <gtkmm2ext/gtk_ui.h>
37 #include <gtkmm2ext/selector.h>
38 #include <gtkmm2ext/stop_signal.h>
39 #include <gtkmm2ext/bindable_button.h>
40 #include <gtkmm2ext/utils.h>
42 #include <ardour/audioplaylist.h>
43 #include <ardour/audio_diskstream.h>
44 #include <ardour/insert.h>
45 #include <ardour/location.h>
46 #include <ardour/panner.h>
47 #include <ardour/playlist.h>
48 #include <ardour/session.h>
49 #include <ardour/session_playlist.h>
50 #include <ardour/utils.h>
52 #include "ardour_ui.h"
53 #include "audio_time_axis.h"
54 #include "automation_gain_line.h"
55 #include "automation_pan_line.h"
56 #include "canvas_impl.h"
57 #include "crossfade_view.h"
59 #include "gain_automation_time_axis.h"
61 #include "pan_automation_time_axis.h"
62 #include "playlist_selector.h"
64 #include "public_editor.h"
65 #include "audio_region_view.h"
66 #include "simplerect.h"
67 #include "audio_streamview.h"
70 #include <ardour/audio_track.h>
74 using namespace ARDOUR;
77 using namespace Editing;
80 AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
82 , RouteTimeAxisView(ed, sess, rt, canvas)
84 // Make sure things are sane...
85 assert(!is_track() || is_audio_track());
87 subplugin_menu.set_name ("ArdourContextMenu");
91 pan_automation_item = 0;
92 gain_automation_item = 0;
94 _view = new AudioStreamView (*this);
96 add_gain_automation_child ();
97 add_pan_automation_child ();
99 ignore_toggle = false;
101 if (is_audio_track())
102 controls_ebox.set_name ("AudioTimeAxisViewControlsBaseUnselected");
104 controls_ebox.set_name ("AudioBusControlsBaseUnselected");
108 set_state (*xml_node);
110 _route->panner().Changed.connect (mem_fun(*this, &AudioTimeAxisView::update_pans));
112 if (is_audio_track()) {
114 controls_ebox.set_name ("AudioTrackControlsBaseUnselected");
115 controls_base_selected_name = "AudioTrackControlsBaseSelected";
116 controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
118 /* ask for notifications of any new RegionViews */
119 _view->RegionViewAdded.connect (mem_fun(*this, &AudioTimeAxisView::region_view_added));
124 controls_ebox.set_name ("AudioBusControlsBaseUnselected");
125 controls_base_selected_name = "AudioBusControlsBaseSelected";
126 controls_base_unselected_name = "AudioBusControlsBaseUnselected";
130 AudioTimeAxisView::~AudioTimeAxisView ()
135 AudioTimeAxisView::audio_view()
137 return dynamic_cast<AudioStreamView*>(_view);
141 AudioTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
144 xml_node->add_property ("shown_editor", "yes");
146 return TimeAxisView::show_at (y, nth, parent);
150 AudioTimeAxisView::hide ()
153 xml_node->add_property ("shown_editor", "no");
155 TimeAxisView::hide ();
159 AudioTimeAxisView::set_state (const XMLNode& node)
161 const XMLProperty *prop;
163 TimeAxisView::set_state (node);
165 if ((prop = node.property ("shown_editor")) != 0) {
166 if (prop->value() == "no") {
167 _marked_for_display = false;
169 _marked_for_display = true;
172 _marked_for_display = true;
175 XMLNodeList nlist = node.children();
176 XMLNodeConstIterator niter;
180 show_gain_automation = false;
181 show_pan_automation = false;
183 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
186 if (child_node->name() == "gain") {
187 XMLProperty *prop=child_node->property ("shown");
190 if (prop->value() == "yes") {
191 show_gain_automation = true;
197 if (child_node->name() == "pan") {
198 XMLProperty *prop=child_node->property ("shown");
201 if (prop->value() == "yes") {
202 show_pan_automation = true;
211 AudioTimeAxisView::build_automation_action_menu ()
213 using namespace Menu_Helpers;
215 RouteTimeAxisView::build_automation_action_menu ();
217 MenuList& automation_items = automation_action_menu->items();
219 automation_items.push_back (SeparatorElem());
221 automation_items.push_back (CheckMenuElem (_("Fader"),
222 mem_fun(*this, &AudioTimeAxisView::toggle_gain_track)));
223 gain_automation_item = static_cast<CheckMenuItem*> (&automation_items.back());
224 gain_automation_item->set_active(show_gain_automation);
226 automation_items.push_back (CheckMenuElem (_("Pan"),
227 mem_fun(*this, &AudioTimeAxisView::toggle_pan_track)));
228 pan_automation_item = static_cast<CheckMenuItem*> (&automation_items.back());
229 pan_automation_item->set_active(show_pan_automation);
234 AudioTimeAxisView::append_extra_display_menu_items ()
236 using namespace Menu_Helpers;
238 MenuList& items = display_menu->items();
241 items.push_back (MenuElem (_("Hide all crossfades"), mem_fun(*this, &AudioTimeAxisView::hide_all_xfades)));
242 items.push_back (MenuElem (_("Show all crossfades"), mem_fun(*this, &AudioTimeAxisView::show_all_xfades)));
245 Menu *waveform_menu = manage(new Menu);
246 MenuList& waveform_items = waveform_menu->items();
247 waveform_menu->set_name ("ArdourContextMenu");
249 waveform_items.push_back (CheckMenuElem (_("Show waveforms"), mem_fun(*this, &AudioTimeAxisView::toggle_waveforms)));
250 waveform_item = static_cast<CheckMenuItem *> (&waveform_items.back());
251 ignore_toggle = true;
252 waveform_item->set_active (editor.show_waveforms());
253 ignore_toggle = false;
255 RadioMenuItem::Group group;
257 waveform_items.push_back (RadioMenuElem (group, _("Traditional"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Traditional)));
258 traditional_item = static_cast<RadioMenuItem *> (&waveform_items.back());
260 waveform_items.push_back (RadioMenuElem (group, _("Rectified"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Rectified)));
261 rectified_item = static_cast<RadioMenuItem *> (&waveform_items.back());
263 items.push_back (MenuElem (_("Waveform"), *waveform_menu));
267 AudioTimeAxisView::toggle_waveforms ()
269 AudioStreamView* asv = audio_view();
272 if (asv && waveform_item && !ignore_toggle) {
273 asv->set_show_waveforms (waveform_item->get_active());
278 AudioTimeAxisView::set_show_waveforms (bool yn)
280 AudioStreamView* asv = audio_view();
284 waveform_item->set_active (yn);
286 asv->set_show_waveforms (yn);
291 AudioTimeAxisView::set_show_waveforms_recording (bool yn)
293 AudioStreamView* asv = audio_view();
296 asv->set_show_waveforms_recording (yn);
301 AudioTimeAxisView::set_waveform_shape (WaveformShape shape)
303 AudioStreamView* asv = audio_view();
306 asv->set_waveform_shape (shape);
313 AudioTimeAxisView::add_gain_automation_child ()
316 AutomationLine* line;
318 gain_track = new GainAutomationTimeAxisView (_session,
324 _route->gain_automation_curve());
326 line = new AutomationGainLine ("automation gain",
329 *gain_track->canvas_display,
330 _route->gain_automation_curve());
332 line->set_line_color (color_map[cAutomationLine]);
335 gain_track->add_line (*line);
337 add_child (gain_track);
339 gain_track->Hiding.connect (mem_fun(*this, &AudioTimeAxisView::gain_hidden));
345 if ((node = gain_track->get_state_node()) != 0) {
346 if ((prop = node->property ("shown")) != 0) {
347 if (prop->value() == "yes") {
359 AudioTimeAxisView::add_pan_automation_child ()
363 pan_track = new PanAutomationTimeAxisView (_session, _route, editor, *this, parent_canvas, _("pan"));
367 add_child (pan_track);
369 pan_track->Hiding.connect (mem_fun(*this, &AudioTimeAxisView::pan_hidden));
376 if ((node = pan_track->get_state_node()) != 0) {
377 if ((prop = node->property ("shown")) != 0) {
378 if (prop->value() == "yes") {
390 AudioTimeAxisView::update_pans ()
394 pan_track->clear_lines ();
396 /* we don't draw lines for "greater than stereo" panning.
399 if (_route->n_outputs() > 2) {
403 for (p = _route->panner().begin(); p != _route->panner().end(); ++p) {
405 AutomationLine* line;
407 line = new AutomationPanLine ("automation pan", _session, *pan_track,
408 *pan_track->canvas_display,
411 if (p == _route->panner().begin()) {
412 /* first line is a nice orange */
413 line->set_line_color (color_map[cLeftPanAutomationLine]);
415 /* second line is a nice blue */
416 line->set_line_color (color_map[cRightPanAutomationLine]);
419 pan_track->add_line (*line);
424 AudioTimeAxisView::toggle_gain_track ()
427 bool showit = gain_automation_item->get_active();
429 if (showit != gain_track->marked_for_display()) {
431 gain_track->set_marked_for_display (true);
432 gain_track->canvas_display->show();
433 gain_track->get_state_node()->add_property ("shown", X_("yes"));
435 gain_track->set_marked_for_display (false);
437 gain_track->get_state_node()->add_property ("shown", X_("no"));
440 /* now trigger a redisplay */
443 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
449 AudioTimeAxisView::gain_hidden ()
451 gain_track->get_state_node()->add_property (X_("shown"), X_("no"));
453 if (gain_automation_item && !_hidden) {
454 gain_automation_item->set_active (false);
457 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
461 AudioTimeAxisView::toggle_pan_track ()
463 bool showit = pan_automation_item->get_active();
465 if (showit != pan_track->marked_for_display()) {
467 pan_track->set_marked_for_display (true);
468 pan_track->canvas_display->show();
469 pan_track->get_state_node()->add_property ("shown", X_("yes"));
471 pan_track->set_marked_for_display (false);
473 pan_track->get_state_node()->add_property ("shown", X_("no"));
476 /* now trigger a redisplay */
479 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
485 AudioTimeAxisView::pan_hidden ()
487 pan_track->get_state_node()->add_property ("shown", "no");
489 if (pan_automation_item && !_hidden) {
490 pan_automation_item->set_active (false);
493 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
497 AudioTimeAxisView::show_all_automation ()
501 pan_automation_item->set_active (true);
502 gain_automation_item->set_active (true);
504 RouteTimeAxisView::show_all_automation ();
508 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
512 AudioTimeAxisView::show_existing_automation ()
516 pan_automation_item->set_active (true);
517 gain_automation_item->set_active (true);
519 RouteTimeAxisView::show_existing_automation ();
523 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
527 AudioTimeAxisView::hide_all_automation ()
531 pan_automation_item->set_active (false);
532 gain_automation_item->set_active (false);
534 RouteTimeAxisView::hide_all_automation();
537 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
541 AudioTimeAxisView::show_all_xfades ()
543 AudioStreamView* asv = audio_view();
546 asv->show_all_xfades ();
551 AudioTimeAxisView::hide_all_xfades ()
553 AudioStreamView* asv = audio_view();
556 asv->hide_all_xfades ();
561 AudioTimeAxisView::hide_dependent_views (TimeAxisViewItem& tavi)
563 AudioStreamView* asv = audio_view();
566 if (asv && (rv = dynamic_cast<AudioRegionView*>(&tavi)) != 0) {
567 asv->hide_xfades_involving (*rv);
572 AudioTimeAxisView::reveal_dependent_views (TimeAxisViewItem& tavi)
574 AudioStreamView* asv = audio_view();
577 if (asv && (rv = dynamic_cast<AudioRegionView*>(&tavi)) != 0) {
578 asv->reveal_xfades_involving (*rv);
583 AudioTimeAxisView::route_active_changed ()
585 RouteTimeAxisView::route_active_changed ();
587 if (is_audio_track()) {
588 if (_route->active()) {
589 controls_ebox.set_name ("AudioTrackControlsBaseUnselected");
590 controls_base_selected_name = "AudioTrackControlsBaseSelected";
591 controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
593 controls_ebox.set_name ("AudioTrackControlsBaseInactiveUnselected");
594 controls_base_selected_name = "AudioTrackControlsBaseInactiveSelected";
595 controls_base_unselected_name = "AudioTrackControlsBaseInactiveUnselected";
598 if (_route->active()) {
599 controls_ebox.set_name ("BusControlsBaseUnselected");
600 controls_base_selected_name = "BusControlsBaseSelected";
601 controls_base_unselected_name = "BusControlsBaseUnselected";
603 controls_ebox.set_name ("BusControlsBaseInactiveUnselected");
604 controls_base_selected_name = "BusControlsBaseInactiveSelected";
605 controls_base_unselected_name = "BusControlsBaseInactiveUnselected";
611 AudioTimeAxisView::get_child_xml_node (const string & childname)
613 return RouteUI::get_child_xml_node (childname);