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.
28 #include <sigc++/bind.h>
30 #include <pbd/error.h>
31 #include <pbd/stl_delete.h>
32 #include <pbd/memento_command.h>
34 #include <gtkmm2ext/gtk_ui.h>
35 #include <gtkmm2ext/selector.h>
36 #include <gtkmm2ext/stop_signal.h>
37 #include <gtkmm2ext/bindable_button.h>
38 #include <gtkmm2ext/utils.h>
40 #include <ardour/audioplaylist.h>
41 #include <ardour/audio_diskstream.h>
42 #include <ardour/processor.h>
43 #include <ardour/location.h>
44 #include <ardour/panner.h>
45 #include <ardour/playlist.h>
46 #include <ardour/session.h>
47 #include <ardour/session_playlist.h>
48 #include <ardour/utils.h>
50 #include "ardour_ui.h"
51 #include "audio_time_axis.h"
52 #include "automation_line.h"
53 #include "canvas_impl.h"
54 #include "crossfade_view.h"
56 #include "automation_time_axis.h"
58 #include "playlist_selector.h"
60 #include "public_editor.h"
61 #include "audio_region_view.h"
62 #include "simplerect.h"
63 #include "audio_streamview.h"
66 #include <ardour/audio_track.h>
70 using namespace ARDOUR;
73 using namespace Editing;
76 AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
78 , RouteTimeAxisView(ed, sess, rt, canvas)
80 // Make sure things are sane...
81 assert(!is_track() || is_audio_track());
83 subplugin_menu.set_name ("ArdourContextMenu");
86 _view = new AudioStreamView (*this);
88 create_automation_child (GainAutomation, false);
90 ignore_toggle = false;
92 mute_button->set_active (false);
93 solo_button->set_active (false);
96 controls_ebox.set_name ("AudioTimeAxisViewControlsBaseUnselected");
98 controls_ebox.set_name ("AudioBusControlsBaseUnselected");
100 /* map current state of the route */
102 processors_changed ();
103 reset_processor_automation_curves ();
107 set_state (*xml_node);
109 _route->panner().Changed.connect (bind (mem_fun(*this, &AudioTimeAxisView::update_pans), false));
111 update_control_names ();
113 if (is_audio_track()) {
115 /* ask for notifications of any new RegionViews */
116 _view->RegionViewAdded.connect (mem_fun(*this, &AudioTimeAxisView::region_view_added));
123 AudioTimeAxisView::~AudioTimeAxisView ()
128 AudioTimeAxisView::audio_view()
130 return dynamic_cast<AudioStreamView*>(_view);
134 AudioTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
137 xml_node->add_property ("shown_editor", "yes");
139 return TimeAxisView::show_at (y, nth, parent);
143 AudioTimeAxisView::hide ()
146 xml_node->add_property ("shown_editor", "no");
148 TimeAxisView::hide ();
152 AudioTimeAxisView::append_extra_display_menu_items ()
154 using namespace Menu_Helpers;
156 MenuList& items = display_menu->items();
159 items.push_back (MenuElem (_("Hide all crossfades"), mem_fun(*this, &AudioTimeAxisView::hide_all_xfades)));
160 items.push_back (MenuElem (_("Show all crossfades"), mem_fun(*this, &AudioTimeAxisView::show_all_xfades)));
163 Menu *waveform_menu = manage(new Menu);
164 MenuList& waveform_items = waveform_menu->items();
165 waveform_menu->set_name ("ArdourContextMenu");
167 waveform_items.push_back (CheckMenuElem (_("Show waveforms"), mem_fun(*this, &AudioTimeAxisView::toggle_waveforms)));
168 waveform_item = static_cast<CheckMenuItem *> (&waveform_items.back());
169 ignore_toggle = true;
170 waveform_item->set_active (editor.show_waveforms());
171 ignore_toggle = false;
173 waveform_items.push_back (SeparatorElem());
175 RadioMenuItem::Group group;
177 waveform_items.push_back (RadioMenuElem (group, _("Traditional"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Traditional)));
178 traditional_item = static_cast<RadioMenuItem *> (&waveform_items.back());
180 waveform_items.push_back (RadioMenuElem (group, _("Rectified"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Rectified)));
181 rectified_item = static_cast<RadioMenuItem *> (&waveform_items.back());
183 waveform_items.push_back (SeparatorElem());
185 RadioMenuItem::Group group2;
187 waveform_items.push_back (RadioMenuElem (group2, _("Linear"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_scale), LinearWaveform)));
188 linearscale_item = static_cast<RadioMenuItem *> (&waveform_items.back());
190 waveform_items.push_back (RadioMenuElem (group2, _("Logarithmic"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_scale), LogWaveform)));
191 logscale_item = static_cast<RadioMenuItem *> (&waveform_items.back());
193 // setting initial item state
194 AudioStreamView* asv = audio_view();
196 ignore_toggle = true;
197 if (asv->get_waveform_shape() == Rectified)
198 rectified_item->set_active(true);
199 else traditional_item->set_active(true);
201 if (asv->get_waveform_scale() == LogWaveform)
202 logscale_item->set_active(true);
203 else linearscale_item->set_active(true);
204 ignore_toggle = false;
207 items.push_back (MenuElem (_("Waveform"), *waveform_menu));
212 AudioTimeAxisView::build_mode_menu()
214 using namespace Menu_Helpers;
216 Menu* mode_menu = manage (new Menu);
217 MenuList& items = mode_menu->items();
218 mode_menu->set_name ("ArdourContextMenu");
220 RadioMenuItem::Group mode_group;
221 items.push_back (RadioMenuElem (mode_group, _("Normal"),
222 bind (mem_fun (*this, &AudioTimeAxisView::set_track_mode), ARDOUR::Normal)));
223 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
224 items.push_back (RadioMenuElem (mode_group, _("Tape"),
225 bind (mem_fun (*this, &AudioTimeAxisView::set_track_mode), ARDOUR::Destructive)));
226 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
228 switch (track()->mode()) {
229 case ARDOUR::Destructive:
230 destructive_track_mode_item->set_active ();
233 normal_track_mode_item->set_active ();
241 AudioTimeAxisView::toggle_waveforms ()
243 AudioStreamView* asv = audio_view();
246 if (asv && waveform_item && !ignore_toggle) {
247 asv->set_show_waveforms (waveform_item->get_active());
252 AudioTimeAxisView::set_show_waveforms (bool yn)
254 AudioStreamView* asv = audio_view();
258 waveform_item->set_active (yn);
260 asv->set_show_waveforms (yn);
265 AudioTimeAxisView::set_show_waveforms_recording (bool yn)
267 AudioStreamView* asv = audio_view();
270 asv->set_show_waveforms_recording (yn);
275 AudioTimeAxisView::set_waveform_shape (WaveformShape shape)
277 AudioStreamView* asv = audio_view();
279 if (asv && !ignore_toggle) {
280 asv->set_waveform_shape (shape);
287 AudioTimeAxisView::set_waveform_scale (WaveformScale scale)
289 AudioStreamView* asv = audio_view();
291 if (asv && !ignore_toggle) {
292 asv->set_waveform_scale (scale);
299 AudioTimeAxisView::create_automation_child (Parameter param, bool show)
301 if (param.type() == GainAutomation) {
303 boost::shared_ptr<AutomationControl> c = _route->gain_control();
305 error << "Route has no gain automation, unable to add automation track view." << endmsg;
309 boost::shared_ptr<AutomationTimeAxisView> gain_track(new AutomationTimeAxisView (_session,
315 _route->describe_parameter(param)));
317 add_automation_child(Parameter(GainAutomation), gain_track, show);
319 } else if (param.type() == PanAutomation) {
325 error << "AudioTimeAxisView: unknown automation child " << param.to_string() << endmsg;
330 AudioTimeAxisView::update_pans (bool show)
335 for (p = _route->panner().begin(); p != _route->panner().end(); ++p) {
336 boost::shared_ptr<AutomationControl> pan_control = (*p)->pan_control();
338 if (pan_control->parameter().type() == NullAutomation) {
339 error << "Pan control has NULL automation type!" << endmsg;
343 boost::shared_ptr<AutomationTimeAxisView> pan_track(new AutomationTimeAxisView (_session,
344 _route, _route/*FIXME*/, pan_control,
349 _route->describe_parameter(pan_control->parameter())));
350 add_automation_child(Parameter(PanAutomation, i), pan_track, show);
356 AudioTimeAxisView::show_all_automation ()
360 RouteTimeAxisView::show_all_automation ();
364 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
368 AudioTimeAxisView::show_existing_automation ()
372 RouteTimeAxisView::show_existing_automation ();
376 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
380 AudioTimeAxisView::hide_all_automation ()
384 RouteTimeAxisView::hide_all_automation();
387 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
391 AudioTimeAxisView::show_all_xfades ()
393 AudioStreamView* asv = audio_view();
396 asv->show_all_xfades ();
401 AudioTimeAxisView::hide_all_xfades ()
403 AudioStreamView* asv = audio_view();
406 asv->hide_all_xfades ();
411 AudioTimeAxisView::hide_dependent_views (TimeAxisViewItem& tavi)
413 AudioStreamView* asv = audio_view();
416 if (asv && (rv = dynamic_cast<AudioRegionView*>(&tavi)) != 0) {
417 asv->hide_xfades_involving (*rv);
422 AudioTimeAxisView::reveal_dependent_views (TimeAxisViewItem& tavi)
424 AudioStreamView* asv = audio_view();
427 if (asv && (rv = dynamic_cast<AudioRegionView*>(&tavi)) != 0) {
428 asv->reveal_xfades_involving (*rv);
433 AudioTimeAxisView::route_active_changed ()
435 RouteTimeAxisView::route_active_changed ();
436 update_control_names ();
441 * Set up the names of the controls so that they are coloured
442 * correctly depending on whether this route is inactive or
447 AudioTimeAxisView::update_control_names ()
449 if (is_audio_track()) {
450 if (_route->active()) {
451 controls_ebox.set_name ("AudioTrackControlsBaseUnselected");
452 controls_base_selected_name = "AudioTrackControlsBaseSelected";
453 controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
455 controls_ebox.set_name ("AudioTrackControlsBaseInactiveUnselected");
456 controls_base_selected_name = "AudioTrackControlsBaseInactiveSelected";
457 controls_base_unselected_name = "AudioTrackControlsBaseInactiveUnselected";
460 if (_route->active()) {
461 controls_ebox.set_name ("BusControlsBaseUnselected");
462 controls_base_selected_name = "BusControlsBaseSelected";
463 controls_base_unselected_name = "BusControlsBaseUnselected";
465 controls_ebox.set_name ("BusControlsBaseInactiveUnselected");
466 controls_base_selected_name = "BusControlsBaseInactiveSelected";
467 controls_base_unselected_name = "BusControlsBaseInactiveUnselected";