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/profile.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_line.h"
54 #include "canvas_impl.h"
55 #include "crossfade_view.h"
57 #include "automation_time_axis.h"
59 #include "playlist_selector.h"
61 #include "public_editor.h"
62 #include "audio_region_view.h"
63 #include "simplerect.h"
64 #include "audio_streamview.h"
67 #include <ardour/audio_track.h>
71 using namespace ARDOUR;
74 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));
118 if (!editor.have_idled()) {
119 /* first idle will do what we need */
129 AudioTimeAxisView::~AudioTimeAxisView ()
134 AudioTimeAxisView::first_idle ()
141 AudioTimeAxisView::audio_view()
143 return dynamic_cast<AudioStreamView*>(_view);
147 AudioTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
150 xml_node->add_property ("shown_editor", "yes");
152 return TimeAxisView::show_at (y, nth, parent);
156 AudioTimeAxisView::hide ()
159 xml_node->add_property ("shown_editor", "no");
161 TimeAxisView::hide ();
165 AudioTimeAxisView::append_extra_display_menu_items ()
167 using namespace Menu_Helpers;
169 MenuList& items = display_menu->items();
172 if (!Profile->get_sae()) {
173 items.push_back (MenuElem (_("Hide all crossfades"), mem_fun(*this, &AudioTimeAxisView::hide_all_xfades)));
174 items.push_back (MenuElem (_("Show all crossfades"), mem_fun(*this, &AudioTimeAxisView::show_all_xfades)));
178 Menu *waveform_menu = manage(new Menu);
179 MenuList& waveform_items = waveform_menu->items();
180 waveform_menu->set_name ("ArdourContextMenu");
182 waveform_items.push_back (CheckMenuElem (_("Show waveforms"), mem_fun(*this, &AudioTimeAxisView::toggle_waveforms)));
183 waveform_item = static_cast<CheckMenuItem *> (&waveform_items.back());
184 ignore_toggle = true;
185 waveform_item->set_active (editor.show_waveforms());
186 ignore_toggle = false;
188 waveform_items.push_back (SeparatorElem());
190 RadioMenuItem::Group group;
192 waveform_items.push_back (RadioMenuElem (group, _("Traditional"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Traditional)));
193 traditional_item = static_cast<RadioMenuItem *> (&waveform_items.back());
195 if (!Profile->get_sae()) {
196 waveform_items.push_back (RadioMenuElem (group, _("Rectified"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_shape), Rectified)));
197 rectified_item = static_cast<RadioMenuItem *> (&waveform_items.back());
202 waveform_items.push_back (SeparatorElem());
204 RadioMenuItem::Group group2;
206 waveform_items.push_back (RadioMenuElem (group2, _("Linear"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_scale), LinearWaveform)));
207 linearscale_item = static_cast<RadioMenuItem *> (&waveform_items.back());
209 waveform_items.push_back (RadioMenuElem (group2, _("Logarithmic"), bind (mem_fun(*this, &AudioTimeAxisView::set_waveform_scale), LogWaveform)));
210 logscale_item = static_cast<RadioMenuItem *> (&waveform_items.back());
212 // setting initial item state
213 AudioStreamView* asv = audio_view();
215 ignore_toggle = true;
216 if (asv->get_waveform_shape() == Rectified && rectified_item) {
217 rectified_item->set_active(true);
219 traditional_item->set_active(true);
222 if (asv->get_waveform_scale() == LogWaveform)
223 logscale_item->set_active(true);
224 else linearscale_item->set_active(true);
225 ignore_toggle = false;
228 items.push_back (MenuElem (_("Waveform"), *waveform_menu));
233 AudioTimeAxisView::build_mode_menu()
235 using namespace Menu_Helpers;
237 Menu* mode_menu = manage (new Menu);
238 MenuList& items = mode_menu->items();
239 mode_menu->set_name ("ArdourContextMenu");
241 RadioMenuItem::Group mode_group;
242 items.push_back (RadioMenuElem (mode_group, _("Normal"),
243 bind (mem_fun (*this, &AudioTimeAxisView::set_track_mode), ARDOUR::Normal)));
244 normal_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
245 items.push_back (RadioMenuElem (mode_group, _("Tape"),
246 bind (mem_fun (*this, &AudioTimeAxisView::set_track_mode), ARDOUR::Destructive)));
247 destructive_track_mode_item = dynamic_cast<RadioMenuItem*>(&items.back());
249 switch (track()->mode()) {
250 case ARDOUR::Destructive:
251 destructive_track_mode_item->set_active ();
254 normal_track_mode_item->set_active ();
262 AudioTimeAxisView::toggle_waveforms ()
264 AudioStreamView* asv = audio_view();
267 if (asv && waveform_item && !ignore_toggle) {
268 asv->set_show_waveforms (waveform_item->get_active());
273 AudioTimeAxisView::set_show_waveforms (bool yn)
275 AudioStreamView* asv = audio_view();
279 waveform_item->set_active (yn);
281 asv->set_show_waveforms (yn);
286 AudioTimeAxisView::set_show_waveforms_recording (bool yn)
288 AudioStreamView* asv = audio_view();
291 asv->set_show_waveforms_recording (yn);
296 AudioTimeAxisView::set_waveform_shape (WaveformShape shape)
298 AudioStreamView* asv = audio_view();
300 if (asv && !ignore_toggle) {
301 asv->set_waveform_shape (shape);
308 AudioTimeAxisView::set_waveform_scale (WaveformScale scale)
310 AudioStreamView* asv = audio_view();
312 if (asv && !ignore_toggle) {
313 asv->set_waveform_scale (scale);
320 AudioTimeAxisView::create_automation_child (Parameter param, bool show)
322 if (param.type() == GainAutomation) {
324 boost::shared_ptr<AutomationControl> c = _route->gain_control();
326 error << "Route has no gain automation, unable to add automation track view." << endmsg;
330 boost::shared_ptr<AutomationTimeAxisView> gain_track(new AutomationTimeAxisView (_session,
336 _route->describe_parameter(param)));
338 add_automation_child(Parameter(GainAutomation), gain_track, show);
340 } else if (param.type() == PanAutomation) {
346 error << "AudioTimeAxisView: unknown automation child " << param.to_string() << endmsg;
351 AudioTimeAxisView::update_pans (bool show)
356 for (p = _route->panner().begin(); p != _route->panner().end(); ++p) {
357 boost::shared_ptr<AutomationControl> pan_control = (*p)->pan_control();
359 if (pan_control->parameter().type() == NullAutomation) {
360 error << "Pan control has NULL automation type!" << endmsg;
364 boost::shared_ptr<AutomationTimeAxisView> pan_track(new AutomationTimeAxisView (_session,
365 _route, _route/*FIXME*/, pan_control,
370 _route->describe_parameter(pan_control->parameter())));
371 add_automation_child(Parameter(PanAutomation, i), pan_track, show);
377 AudioTimeAxisView::show_all_automation ()
381 RouteTimeAxisView::show_all_automation ();
385 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
389 AudioTimeAxisView::show_existing_automation ()
393 RouteTimeAxisView::show_existing_automation ();
397 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
401 AudioTimeAxisView::hide_all_automation ()
405 RouteTimeAxisView::hide_all_automation();
408 _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */
412 AudioTimeAxisView::show_all_xfades ()
414 AudioStreamView* asv = audio_view();
417 asv->show_all_xfades ();
422 AudioTimeAxisView::hide_all_xfades ()
424 AudioStreamView* asv = audio_view();
427 asv->hide_all_xfades ();
432 AudioTimeAxisView::hide_dependent_views (TimeAxisViewItem& tavi)
434 AudioStreamView* asv = audio_view();
437 if (asv && (rv = dynamic_cast<AudioRegionView*>(&tavi)) != 0) {
438 asv->hide_xfades_involving (*rv);
443 AudioTimeAxisView::reveal_dependent_views (TimeAxisViewItem& tavi)
445 AudioStreamView* asv = audio_view();
448 if (asv && (rv = dynamic_cast<AudioRegionView*>(&tavi)) != 0) {
449 asv->reveal_xfades_involving (*rv);
454 AudioTimeAxisView::route_active_changed ()
456 RouteTimeAxisView::route_active_changed ();
457 update_control_names ();
462 * Set up the names of the controls so that they are coloured
463 * correctly depending on whether this route is inactive or
468 AudioTimeAxisView::update_control_names ()
470 if (is_audio_track()) {
471 if (_route->active()) {
472 controls_base_selected_name = "AudioTrackControlsBaseSelected";
473 controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
475 controls_base_selected_name = "AudioTrackControlsBaseInactiveSelected";
476 controls_base_unselected_name = "AudioTrackControlsBaseInactiveUnselected";
479 if (_route->active()) {
480 controls_base_selected_name = "BusControlsBaseSelected";
481 controls_base_unselected_name = "BusControlsBaseUnselected";
483 controls_base_selected_name = "BusControlsBaseInactiveSelected";
484 controls_base_unselected_name = "BusControlsBaseInactiveUnselected";
488 if (get_selected()) {
489 controls_ebox.set_name (controls_base_selected_name);
491 controls_ebox.set_name (controls_base_unselected_name);