2 Copyright (C) 2000 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.
26 #include <sigc++/bind.h>
28 #include <pbd/error.h>
29 #include <pbd/stl_delete.h>
30 #include <pbd/whitespace.h>
32 #include <gtkmm2ext/gtk_ui.h>
33 #include <gtkmm2ext/selector.h>
34 #include <gtkmm2ext/stop_signal.h>
35 #include <gtkmm2ext/bindable_button.h>
36 #include <gtkmm2ext/utils.h>
38 #include <ardour/midi_playlist.h>
39 #include <ardour/midi_diskstream.h>
40 #include <ardour/processor.h>
41 #include <ardour/ladspa_plugin.h>
42 #include <ardour/location.h>
43 #include <ardour/playlist.h>
44 #include <ardour/session.h>
45 #include <ardour/session_playlist.h>
46 #include <ardour/utils.h>
48 #include "ardour_ui.h"
49 #include "midi_time_axis.h"
50 #include "automation_time_axis.h"
51 #include "automation_midi_cc_line.h"
52 #include "canvas_impl.h"
53 #include "crossfade_view.h"
55 #include "gui_thread.h"
57 #include "playlist_selector.h"
58 #include "plugin_selector.h"
59 #include "plugin_ui.h"
60 #include "point_selection.h"
62 #include "public_editor.h"
63 #include "plugin_automation_line.h"
64 #include "processor_automation_time_axis.h"
65 #include "midi_controller_time_axis.h"
66 #include "region_view.h"
67 #include "rgb_macros.h"
68 #include "selection.h"
69 #include "simplerect.h"
70 #include "midi_streamview.h"
73 #include <ardour/midi_track.h>
77 using namespace ARDOUR;
80 using namespace Editing;
83 MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
84 : AxisView(sess), // FIXME: won't compile without this, why??
85 RouteTimeAxisView(ed, sess, rt, canvas)
87 subplugin_menu.set_name ("ArdourContextMenu");
89 _view = new MidiStreamView (*this);
91 ignore_toggle = false;
93 mute_button->set_active (false);
94 solo_button->set_active (false);
97 controls_ebox.set_name ("MidiTimeAxisViewControlsBaseUnselected");
99 controls_ebox.set_name ("MidiBusControlsBaseUnselected");
101 /* map current state of the route */
103 processors_changed ();
107 set_state (*xml_node);
109 _route->processors_changed.connect (mem_fun(*this, &MidiTimeAxisView::processors_changed));
113 controls_ebox.set_name ("MidiTrackControlsBaseUnselected");
114 controls_base_selected_name = "MidiTrackControlsBaseSelected";
115 controls_base_unselected_name = "MidiTrackControlsBaseUnselected";
117 /* ask for notifications of any new RegionViews */
118 _view->RegionViewAdded.connect (mem_fun(*this, &MidiTimeAxisView::region_view_added));
121 } /*else { // no MIDI busses yet
123 controls_ebox.set_name ("MidiBusControlsBaseUnselected");
124 controls_base_selected_name = "MidiBusControlsBaseSelected";
125 controls_base_unselected_name = "MidiBusControlsBaseUnselected";
129 MidiTimeAxisView::~MidiTimeAxisView ()
134 MidiTimeAxisView::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 MidiTimeAxisView::hide ()
146 xml_node->add_property ("shown_editor", "no");
148 TimeAxisView::hide ();
152 MidiTimeAxisView::build_automation_action_menu ()
154 using namespace Menu_Helpers;
156 RouteTimeAxisView::build_automation_action_menu ();
158 MenuList& automation_items = automation_action_menu->items();
160 automation_items.push_back (SeparatorElem());
162 automation_items.push_back (MenuElem (_("Controller..."),
163 mem_fun(*this, &MidiTimeAxisView::add_controller_track)));
166 /** Prompt for a controller with a dialog and add an automation track for it
169 MidiTimeAxisView::add_controller_track()
171 /* TODO: fancy controller selection dialog here... */
173 ParamID param(MidiCCAutomation, 7);
174 create_automation_child(param);
178 MidiTimeAxisView::create_automation_child (ParamID param)
180 if (param.type() == MidiCCAutomation) {
182 /* FIXME: this all probably leaks */
184 ARDOUR::AutomationList* al = _route->automation_list(param);
187 al = new ARDOUR::AutomationList(param, 0, 127, 64);
189 _route->add_automation_parameter(al);
191 MidiControllerTimeAxisView* track = new MidiControllerTimeAxisView (_session,
196 _route->describe_parameter(param),
200 AutomationMidiCCLine* line = new AutomationMidiCCLine (param.to_string(),
202 *track->canvas_display,
205 line->set_line_color (Config->canvasvar_AutomationLine.get());
207 track->add_line(*line);
209 add_automation_child(param, track);
212 error << "MidiTimeAxisView: unknown automation child " << param.to_string() << endmsg;
217 MidiTimeAxisView::route_active_changed ()
219 RouteUI::route_active_changed ();
222 if (_route->active()) {
223 controls_ebox.set_name ("MidiTrackControlsBaseUnselected");
224 controls_base_selected_name = "MidiTrackControlsBaseSelected";
225 controls_base_unselected_name = "MidiTrackControlsBaseUnselected";
227 controls_ebox.set_name ("MidiTrackControlsBaseInactiveUnselected");
228 controls_base_selected_name = "MidiTrackControlsBaseInactiveSelected";
229 controls_base_unselected_name = "MidiTrackControlsBaseInactiveUnselected";
235 if (_route->active()) {
236 controls_ebox.set_name ("BusControlsBaseUnselected");
237 controls_base_selected_name = "BusControlsBaseSelected";
238 controls_base_unselected_name = "BusControlsBaseUnselected";
240 controls_ebox.set_name ("BusControlsBaseInactiveUnselected");
241 controls_base_selected_name = "BusControlsBaseInactiveSelected";
242 controls_base_unselected_name = "BusControlsBaseInactiveUnselected";