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>
35 #include <gtkmm2ext/gtk_ui.h>
36 #include <gtkmm2ext/selector.h>
37 #include <gtkmm2ext/stop_signal.h>
38 #include <gtkmm2ext/bindable_button.h>
39 #include <gtkmm2ext/utils.h>
41 #include <ardour/audioplaylist.h>
42 #include <ardour/audio_diskstream.h>
43 #include <ardour/insert.h>
44 #include <ardour/location.h>
45 #include <ardour/panner.h>
46 #include <ardour/playlist.h>
47 #include <ardour/session.h>
48 #include <ardour/session_playlist.h>
49 #include <ardour/utils.h>
51 #include "ardour_ui.h"
52 #include "audio_time_axis.h"
53 #include "automation_gain_line.h"
54 #include "automation_pan_line.h"
55 #include "canvas_impl.h"
56 #include "crossfade_view.h"
58 #include "gain_automation_time_axis.h"
60 #include "pan_automation_time_axis.h"
61 #include "playlist_selector.h"
62 #include "plugin_selector.h"
63 #include "plugin_ui.h"
65 #include "public_editor.h"
66 #include "audio_region_view.h"
67 #include "simplerect.h"
68 #include "audio_streamview.h"
71 #include <ardour/audio_track.h>
75 using namespace ARDOUR;
78 using namespace Editing;
81 AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
83 , RouteTimeAxisView(ed, sess, rt, canvas)
85 // Make sure things are sane...
86 assert(!is_track() || is_audio_track());
88 subplugin_menu.set_name ("ArdourContextMenu");
92 pan_automation_item = 0;
93 gain_automation_item = 0;
95 _view = new AudioStreamView (*this);
97 add_gain_automation_child ();
98 add_pan_automation_child ();
100 ignore_toggle = false;
102 mute_button->set_active (false);
103 solo_button->set_active (false);
105 if (is_audio_track())
106 controls_ebox.set_name ("AudioTimeAxisViewControlsBaseUnselected");
108 controls_ebox.set_name ("AudioBusControlsBaseUnselected");
110 /* map current state of the route */
112 redirects_changed (0);
113 reset_redirect_automation_curves ();
117 set_state (*xml_node);
119 _route->panner().Changed.connect (mem_fun(*this, &AudioTimeAxisView::update_pans));
121 if (is_audio_track()) {
123 controls_ebox.set_name ("AudioTrackControlsBaseUnselected");
124 controls_base_selected_name = "AudioTrackControlsBaseSelected";
125 controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
127 /* ask for notifications of any new RegionViews */
128 _view->RegionViewAdded.connect (mem_fun(*this, &AudioTimeAxisView::region_view_added));
133 controls_ebox.set_name ("AudioBusControlsBaseUnselected");
134 controls_base_selected_name = "AudioBusControlsBaseSelected";
135 controls_base_unselected_name = "AudioBusControlsBaseUnselected";
139 AudioTimeAxisView::~AudioTimeAxisView ()
144 AudioTimeAxisView::audio_view()
146 return dynamic_cast<AudioStreamView*>(_view);
150 AudioTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
153 xml_node->add_property ("shown_editor", "yes");
155 return TimeAxisView::show_at (y, nth, parent);
159 AudioTimeAxisView::hide ()
162 xml_node->add_property ("shown_editor", "no");
164 TimeAxisView::hide ();
168 AudioTimeAxisView::set_state (const XMLNode& node)
170 const XMLProperty *prop;
172 TimeAxisView::set_state (node);
174 if ((prop = node.property ("shown_editor")) != 0) {
175 if (prop->value() == "no") {
176 _marked_for_display = false;
178 _marked_for_display = true;
181 _marked_for_display = true;
184 XMLNodeList nlist = node.children();
185 XMLNodeConstIterator niter;
189 show_gain_automation = false;
190 show_pan_automation = false;
192 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
195 if (child_node->name() == "gain") {
196 XMLProperty *prop=child_node->property ("shown");
199 if (prop->value() == "yes") {
200 show_gain_automation = true;
206 if (child_node->name() == "pan") {
207 XMLProperty *prop=child_node->property ("shown");
210 if (prop->value() == "yes") {
211 show_pan_automation = true;
220 AudioTimeAxisView::build_automation_action_menu ()
222 using namespace Menu_Helpers;
224 RouteTimeAxisView::build_automation_action_menu ();
226 MenuList& automation_items = automation_action_menu->items();
228 automation_items.push_back (SeparatorElem());
230 automation_items.push_back (CheckMenuElem (_("Fader"),
231 mem_fun(*this, &AudioTimeAxisView::toggle_gain_track)));
232 gain_automation_item = static_cast<CheckMenuItem*> (&automation_items.back());
233 gain_automation_item->set_active(show_gain_automation);
235 automation_items.push_back (CheckMenuElem (_("Pan"),
236 mem_fun(*this, &AudioTimeAxisView::toggle_pan_track)));
237 pan_automation_item = static_cast<CheckMenuItem*> (&automation_items.back());
238 pan_automation_item->set_active(show_pan_automation);
243 AudioTimeAxisView::append_extra_display_menu_items ()
245 using namespace Menu_Helpers;
247 MenuList& items = display_menu->items();
250 items.push_back (MenuElem (_("Hide all crossfades"), mem_fun(*this, &AudioTimeAxisView::hide_all_xfades)));
251 items.push_back (MenuElem (_("Show all crossfades"), mem_fun(*this, &AudioTimeAxisView::show_all_xfades)));
254 Menu *waveform_menu = manage(new Menu);
255 MenuList& waveform_items = waveform_menu->items();
256 waveform_menu->set_name ("ArdourContextMenu");
258 waveform_items.push_back (CheckMenuElem (_("Show waveforms"), mem_fun(*this, &AudioTimeAxisView::toggle_waveforms)));
259 waveform_item = static_cast<CheckMenuItem *> (&waveform_items.back());
260 ignore_toggle = true;
261 waveform_item->set_active (editor.show_waveforms());
262 ignore_toggle = false;
264 RadioMenuItem::Group group;
266 waveform_items.push_back (RadioMenuElem (group, _("Traditional"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Traditional)));
267 traditional_item = static_cast<RadioMenuItem *> (&waveform_items.back());
269 waveform_items.push_back (RadioMenuElem (group, _("Rectified"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Rectified)));
270 rectified_item = static_cast<RadioMenuItem *> (&waveform_items.back());
272 items.push_back (MenuElem (_("Waveform"), *waveform_menu));
276 AudioTimeAxisView::toggle_waveforms ()
278 AudioStreamView* asv = audio_view();
281 if (asv && waveform_item && !ignore_toggle) {
282 asv->set_show_waveforms (waveform_item->get_active());
287 AudioTimeAxisView::set_show_waveforms (bool yn)
289 AudioStreamView* asv = audio_view();
293 waveform_item->set_active (yn);
295 asv->set_show_waveforms (yn);
300 AudioTimeAxisView::set_show_waveforms_recording (bool yn)
302 AudioStreamView* asv = audio_view();
305 asv->set_show_waveforms_recording (yn);
310 AudioTimeAxisView::set_waveform_shape (WaveformShape shape)
312 AudioStreamView* asv = audio_view();
315 asv->set_waveform_shape (shape);
322 AudioTimeAxisView::add_gain_automation_child ()
325 AutomationLine* line;
327 gain_track = new GainAutomationTimeAxisView (_session,
333 _route->gain_automation_curve());
335 line = new AutomationGainLine ("automation gain",
338 *gain_track->canvas_display,
339 _route->gain_automation_curve());
341 line->set_line_color (color_map[cAutomationLine]);
344 gain_track->add_line (*line);
346 add_child (gain_track);
348 gain_track->Hiding.connect (mem_fun(*this, &AudioTimeAxisView::gain_hidden));
354 if ((node = gain_track->get_state_node()) != 0) {
355 if ((prop = node->property ("shown")) != 0) {
356 if (prop->value() == "yes") {
368 AudioTimeAxisView::add_pan_automation_child ()
372 pan_track = new PanAutomationTimeAxisView (_session, _route, editor, *this, parent_canvas, _("pan"));
376 add_child (pan_track);
378 pan_track->Hiding.connect (mem_fun(*this, &AudioTimeAxisView::pan_hidden));
385 if ((node = pan_track->get_state_node()) != 0) {
386 if ((prop = node->property ("shown")) != 0) {
387 if (prop->value() == "yes") {
399 AudioTimeAxisView::update_pans ()
403 pan_track->clear_lines ();
405 /* we don't draw lines for "greater than stereo" panning.
408 if (_route->n_outputs() > 2) {
412 for (p = _route->panner().begin(); p != _route->panner().end(); ++p) {
414 AutomationLine* line;
416 line = new AutomationPanLine ("automation pan", _session, *pan_track,
417 *pan_track->canvas_display,
420 if (p == _route->panner().begin()) {
421 /* first line is a nice orange */
422 line->set_line_color (color_map[cLeftPanAutomationLine]);
424 /* second line is a nice blue */
425 line->set_line_color (color_map[cRightPanAutomationLine]);
428 pan_track->add_line (*line);
433 AudioTimeAxisView::toggle_gain_track ()
436 bool showit = gain_automation_item->get_active();
438 if (showit != gain_track->marked_for_display()) {
440 gain_track->set_marked_for_display (true);
441 gain_track->canvas_display->show();
442 gain_track->get_state_node()->add_property ("shown", X_("yes"));
444 gain_track->set_marked_for_display (false);
446 gain_track->get_state_node()->add_property ("shown", X_("no"));
449 /* now trigger a redisplay */
452 _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */
458 AudioTimeAxisView::gain_hidden ()
460 gain_track->get_state_node()->add_property (X_("shown"), X_("no"));
462 if (gain_automation_item && !_hidden) {
463 gain_automation_item->set_active (false);
466 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
470 AudioTimeAxisView::toggle_pan_track ()
472 bool showit = pan_automation_item->get_active();
474 if (showit != pan_track->marked_for_display()) {
476 pan_track->set_marked_for_display (true);
477 pan_track->canvas_display->show();
478 pan_track->get_state_node()->add_property ("shown", X_("yes"));
480 pan_track->set_marked_for_display (false);
482 pan_track->get_state_node()->add_property ("shown", X_("no"));
485 /* now trigger a redisplay */
488 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
494 AudioTimeAxisView::pan_hidden ()
496 pan_track->get_state_node()->add_property ("shown", "no");
498 if (pan_automation_item && !_hidden) {
499 pan_automation_item->set_active (false);
502 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
506 AudioTimeAxisView::show_all_automation ()
510 pan_automation_item->set_active (true);
511 gain_automation_item->set_active (true);
513 RouteTimeAxisView::show_all_automation ();
517 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
521 AudioTimeAxisView::show_existing_automation ()
525 pan_automation_item->set_active (true);
526 gain_automation_item->set_active (true);
528 RouteTimeAxisView::show_existing_automation ();
532 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
536 AudioTimeAxisView::hide_all_automation ()
540 pan_automation_item->set_active (false);
541 gain_automation_item->set_active (false);
543 RouteTimeAxisView::hide_all_automation();
546 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
550 AudioTimeAxisView::show_all_xfades ()
552 AudioStreamView* asv = audio_view();
555 asv->show_all_xfades ();
560 AudioTimeAxisView::hide_all_xfades ()
562 AudioStreamView* asv = audio_view();
565 asv->hide_all_xfades ();
570 AudioTimeAxisView::hide_dependent_views (TimeAxisViewItem& tavi)
572 AudioStreamView* asv = audio_view();
575 if (asv && (rv = dynamic_cast<AudioRegionView*>(&tavi)) != 0) {
576 asv->hide_xfades_involving (*rv);
581 AudioTimeAxisView::reveal_dependent_views (TimeAxisViewItem& tavi)
583 AudioStreamView* asv = audio_view();
586 if (asv && (rv = dynamic_cast<AudioRegionView*>(&tavi)) != 0) {
587 asv->reveal_xfades_involving (*rv);
592 AudioTimeAxisView::route_active_changed ()
594 RouteTimeAxisView::route_active_changed ();
596 if (is_audio_track()) {
597 if (_route->active()) {
598 controls_ebox.set_name ("AudioTrackControlsBaseUnselected");
599 controls_base_selected_name = "AudioTrackControlsBaseSelected";
600 controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
602 controls_ebox.set_name ("AudioTrackControlsBaseInactiveUnselected");
603 controls_base_selected_name = "AudioTrackControlsBaseInactiveSelected";
604 controls_base_unselected_name = "AudioTrackControlsBaseInactiveUnselected";
607 if (_route->active()) {
608 controls_ebox.set_name ("BusControlsBaseUnselected");
609 controls_base_selected_name = "BusControlsBaseSelected";
610 controls_base_unselected_name = "BusControlsBaseUnselected";
612 controls_ebox.set_name ("BusControlsBaseInactiveUnselected");
613 controls_base_selected_name = "BusControlsBaseInactiveSelected";
614 controls_base_unselected_name = "BusControlsBaseInactiveUnselected";
620 AudioTimeAxisView::get_child_xml_node (const string & childname)
622 return RouteUI::get_child_xml_node (childname);