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"
63 #include "plugin_selector.h"
64 #include "plugin_ui.h"
66 #include "public_editor.h"
67 #include "audio_region_view.h"
68 #include "simplerect.h"
69 #include "audio_streamview.h"
72 #include <ardour/audio_track.h>
76 using namespace ARDOUR;
79 using namespace Editing;
82 AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
84 , RouteTimeAxisView(ed, sess, rt, canvas)
86 // Make sure things are sane...
87 assert(!is_track() || is_audio_track());
89 subplugin_menu.set_name ("ArdourContextMenu");
93 pan_automation_item = 0;
94 gain_automation_item = 0;
96 _view = new AudioStreamView (*this);
98 add_gain_automation_child ();
99 add_pan_automation_child ();
101 ignore_toggle = false;
103 mute_button->set_active (false);
104 solo_button->set_active (false);
106 if (is_audio_track())
107 controls_ebox.set_name ("AudioTimeAxisViewControlsBaseUnselected");
109 controls_ebox.set_name ("AudioBusControlsBaseUnselected");
111 /* map current state of the route */
113 redirects_changed (0);
114 reset_redirect_automation_curves ();
118 set_state (*xml_node);
120 _route->panner().Changed.connect (mem_fun(*this, &AudioTimeAxisView::update_pans));
122 if (is_audio_track()) {
124 controls_ebox.set_name ("AudioTrackControlsBaseUnselected");
125 controls_base_selected_name = "AudioTrackControlsBaseSelected";
126 controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
128 /* ask for notifications of any new RegionViews */
129 _view->RegionViewAdded.connect (mem_fun(*this, &AudioTimeAxisView::region_view_added));
134 controls_ebox.set_name ("AudioBusControlsBaseUnselected");
135 controls_base_selected_name = "AudioBusControlsBaseSelected";
136 controls_base_unselected_name = "AudioBusControlsBaseUnselected";
140 AudioTimeAxisView::~AudioTimeAxisView ()
145 AudioTimeAxisView::audio_view()
147 return dynamic_cast<AudioStreamView*>(_view);
151 AudioTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
154 xml_node->add_property ("shown_editor", "yes");
156 return TimeAxisView::show_at (y, nth, parent);
160 AudioTimeAxisView::hide ()
163 xml_node->add_property ("shown_editor", "no");
165 TimeAxisView::hide ();
169 AudioTimeAxisView::set_state (const XMLNode& node)
171 const XMLProperty *prop;
173 TimeAxisView::set_state (node);
175 if ((prop = node.property ("shown_editor")) != 0) {
176 if (prop->value() == "no") {
177 _marked_for_display = false;
179 _marked_for_display = true;
182 _marked_for_display = true;
185 XMLNodeList nlist = node.children();
186 XMLNodeConstIterator niter;
190 show_gain_automation = false;
191 show_pan_automation = false;
193 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
196 if (child_node->name() == "gain") {
197 XMLProperty *prop=child_node->property ("shown");
200 if (prop->value() == "yes") {
201 show_gain_automation = true;
207 if (child_node->name() == "pan") {
208 XMLProperty *prop=child_node->property ("shown");
211 if (prop->value() == "yes") {
212 show_pan_automation = true;
221 AudioTimeAxisView::build_automation_action_menu ()
223 using namespace Menu_Helpers;
225 RouteTimeAxisView::build_automation_action_menu ();
227 MenuList& automation_items = automation_action_menu->items();
229 automation_items.push_back (SeparatorElem());
231 automation_items.push_back (CheckMenuElem (_("Fader"),
232 mem_fun(*this, &AudioTimeAxisView::toggle_gain_track)));
233 gain_automation_item = static_cast<CheckMenuItem*> (&automation_items.back());
234 gain_automation_item->set_active(show_gain_automation);
236 automation_items.push_back (CheckMenuElem (_("Pan"),
237 mem_fun(*this, &AudioTimeAxisView::toggle_pan_track)));
238 pan_automation_item = static_cast<CheckMenuItem*> (&automation_items.back());
239 pan_automation_item->set_active(show_pan_automation);
244 AudioTimeAxisView::append_extra_display_menu_items ()
246 using namespace Menu_Helpers;
248 MenuList& items = display_menu->items();
251 items.push_back (MenuElem (_("Hide all crossfades"), mem_fun(*this, &AudioTimeAxisView::hide_all_xfades)));
252 items.push_back (MenuElem (_("Show all crossfades"), mem_fun(*this, &AudioTimeAxisView::show_all_xfades)));
255 Menu *waveform_menu = manage(new Menu);
256 MenuList& waveform_items = waveform_menu->items();
257 waveform_menu->set_name ("ArdourContextMenu");
259 waveform_items.push_back (CheckMenuElem (_("Show waveforms"), mem_fun(*this, &AudioTimeAxisView::toggle_waveforms)));
260 waveform_item = static_cast<CheckMenuItem *> (&waveform_items.back());
261 ignore_toggle = true;
262 waveform_item->set_active (editor.show_waveforms());
263 ignore_toggle = false;
265 RadioMenuItem::Group group;
267 waveform_items.push_back (RadioMenuElem (group, _("Traditional"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Traditional)));
268 traditional_item = static_cast<RadioMenuItem *> (&waveform_items.back());
270 waveform_items.push_back (RadioMenuElem (group, _("Rectified"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Rectified)));
271 rectified_item = static_cast<RadioMenuItem *> (&waveform_items.back());
273 items.push_back (MenuElem (_("Waveform"), *waveform_menu));
277 AudioTimeAxisView::toggle_waveforms ()
279 AudioStreamView* asv = audio_view();
282 if (asv && waveform_item && !ignore_toggle) {
283 asv->set_show_waveforms (waveform_item->get_active());
288 AudioTimeAxisView::set_show_waveforms (bool yn)
290 AudioStreamView* asv = audio_view();
294 waveform_item->set_active (yn);
296 asv->set_show_waveforms (yn);
301 AudioTimeAxisView::set_show_waveforms_recording (bool yn)
303 AudioStreamView* asv = audio_view();
306 asv->set_show_waveforms_recording (yn);
311 AudioTimeAxisView::set_waveform_shape (WaveformShape shape)
313 AudioStreamView* asv = audio_view();
316 asv->set_waveform_shape (shape);
323 AudioTimeAxisView::add_gain_automation_child ()
326 AutomationLine* line;
328 gain_track = new GainAutomationTimeAxisView (_session,
334 _route->gain_automation_curve());
336 line = new AutomationGainLine ("automation gain",
339 *gain_track->canvas_display,
340 _route->gain_automation_curve());
342 line->set_line_color (color_map[cAutomationLine]);
345 gain_track->add_line (*line);
347 add_child (gain_track);
349 gain_track->Hiding.connect (mem_fun(*this, &AudioTimeAxisView::gain_hidden));
355 if ((node = gain_track->get_state_node()) != 0) {
356 if ((prop = node->property ("shown")) != 0) {
357 if (prop->value() == "yes") {
369 AudioTimeAxisView::add_pan_automation_child ()
373 pan_track = new PanAutomationTimeAxisView (_session, _route, editor, *this, parent_canvas, _("pan"));
377 add_child (pan_track);
379 pan_track->Hiding.connect (mem_fun(*this, &AudioTimeAxisView::pan_hidden));
386 if ((node = pan_track->get_state_node()) != 0) {
387 if ((prop = node->property ("shown")) != 0) {
388 if (prop->value() == "yes") {
400 AudioTimeAxisView::update_pans ()
404 pan_track->clear_lines ();
406 /* we don't draw lines for "greater than stereo" panning.
409 if (_route->n_outputs() > 2) {
413 for (p = _route->panner().begin(); p != _route->panner().end(); ++p) {
415 AutomationLine* line;
417 line = new AutomationPanLine ("automation pan", _session, *pan_track,
418 *pan_track->canvas_display,
421 if (p == _route->panner().begin()) {
422 /* first line is a nice orange */
423 line->set_line_color (color_map[cLeftPanAutomationLine]);
425 /* second line is a nice blue */
426 line->set_line_color (color_map[cRightPanAutomationLine]);
429 pan_track->add_line (*line);
434 AudioTimeAxisView::toggle_gain_track ()
437 bool showit = gain_automation_item->get_active();
439 if (showit != gain_track->marked_for_display()) {
441 gain_track->set_marked_for_display (true);
442 gain_track->canvas_display->show();
443 gain_track->get_state_node()->add_property ("shown", X_("yes"));
445 gain_track->set_marked_for_display (false);
447 gain_track->get_state_node()->add_property ("shown", X_("no"));
450 /* now trigger a redisplay */
453 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
459 AudioTimeAxisView::gain_hidden ()
461 gain_track->get_state_node()->add_property (X_("shown"), X_("no"));
463 if (gain_automation_item && !_hidden) {
464 gain_automation_item->set_active (false);
467 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
471 AudioTimeAxisView::toggle_pan_track ()
473 bool showit = pan_automation_item->get_active();
475 if (showit != pan_track->marked_for_display()) {
477 pan_track->set_marked_for_display (true);
478 pan_track->canvas_display->show();
479 pan_track->get_state_node()->add_property ("shown", X_("yes"));
481 pan_track->set_marked_for_display (false);
483 pan_track->get_state_node()->add_property ("shown", X_("no"));
486 /* now trigger a redisplay */
489 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
495 AudioTimeAxisView::pan_hidden ()
497 pan_track->get_state_node()->add_property ("shown", "no");
499 if (pan_automation_item && !_hidden) {
500 pan_automation_item->set_active (false);
503 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
507 AudioTimeAxisView::show_all_automation ()
511 pan_automation_item->set_active (true);
512 gain_automation_item->set_active (true);
514 RouteTimeAxisView::show_all_automation ();
518 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
522 AudioTimeAxisView::show_existing_automation ()
526 pan_automation_item->set_active (true);
527 gain_automation_item->set_active (true);
529 RouteTimeAxisView::show_existing_automation ();
533 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
537 AudioTimeAxisView::hide_all_automation ()
541 pan_automation_item->set_active (false);
542 gain_automation_item->set_active (false);
544 RouteTimeAxisView::hide_all_automation();
547 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
551 AudioTimeAxisView::show_all_xfades ()
553 AudioStreamView* asv = audio_view();
556 asv->show_all_xfades ();
561 AudioTimeAxisView::hide_all_xfades ()
563 AudioStreamView* asv = audio_view();
566 asv->hide_all_xfades ();
571 AudioTimeAxisView::hide_dependent_views (TimeAxisViewItem& tavi)
573 AudioStreamView* asv = audio_view();
576 if (asv && (rv = dynamic_cast<AudioRegionView*>(&tavi)) != 0) {
577 asv->hide_xfades_involving (*rv);
582 AudioTimeAxisView::reveal_dependent_views (TimeAxisViewItem& tavi)
584 AudioStreamView* asv = audio_view();
587 if (asv && (rv = dynamic_cast<AudioRegionView*>(&tavi)) != 0) {
588 asv->reveal_xfades_involving (*rv);
593 AudioTimeAxisView::route_active_changed ()
595 RouteTimeAxisView::route_active_changed ();
597 if (is_audio_track()) {
598 if (_route->active()) {
599 controls_ebox.set_name ("AudioTrackControlsBaseUnselected");
600 controls_base_selected_name = "AudioTrackControlsBaseSelected";
601 controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
603 controls_ebox.set_name ("AudioTrackControlsBaseInactiveUnselected");
604 controls_base_selected_name = "AudioTrackControlsBaseInactiveSelected";
605 controls_base_unselected_name = "AudioTrackControlsBaseInactiveUnselected";
608 if (_route->active()) {
609 controls_ebox.set_name ("BusControlsBaseUnselected");
610 controls_base_selected_name = "BusControlsBaseSelected";
611 controls_base_unselected_name = "BusControlsBaseUnselected";
613 controls_ebox.set_name ("BusControlsBaseInactiveUnselected");
614 controls_base_selected_name = "BusControlsBaseInactiveSelected";
615 controls_base_unselected_name = "BusControlsBaseInactiveUnselected";
621 AudioTimeAxisView::get_child_xml_node (const string & childname)
623 return RouteUI::get_child_xml_node (childname);