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_line.h"
52 #include "add_midi_cc_track_dialog.h"
53 #include "canvas_impl.h"
54 #include "crossfade_view.h"
56 #include "gui_thread.h"
58 #include "playlist_selector.h"
59 #include "plugin_selector.h"
60 #include "plugin_ui.h"
61 #include "point_selection.h"
63 #include "public_editor.h"
64 #include "region_view.h"
65 #include "rgb_macros.h"
66 #include "selection.h"
67 #include "simplerect.h"
68 #include "midi_streamview.h"
71 #include <ardour/midi_track.h>
75 using namespace ARDOUR;
78 using namespace Editing;
81 MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas)
82 : AxisView(sess), // FIXME: won't compile without this, why??
83 RouteTimeAxisView(ed, sess, rt, canvas)
85 subplugin_menu.set_name ("ArdourContextMenu");
87 _view = new MidiStreamView (*this);
89 ignore_toggle = false;
91 mute_button->set_active (false);
92 solo_button->set_active (false);
95 controls_ebox.set_name ("MidiTimeAxisViewControlsBaseUnselected");
97 controls_ebox.set_name ("MidiBusControlsBaseUnselected");
99 /* map current state of the route */
101 processors_changed ();
105 set_state (*xml_node);
107 _route->processors_changed.connect (mem_fun(*this, &MidiTimeAxisView::processors_changed));
111 controls_ebox.set_name ("MidiTrackControlsBaseUnselected");
112 controls_base_selected_name = "MidiTrackControlsBaseSelected";
113 controls_base_unselected_name = "MidiTrackControlsBaseUnselected";
115 /* ask for notifications of any new RegionViews */
116 _view->RegionViewAdded.connect (mem_fun(*this, &MidiTimeAxisView::region_view_added));
119 } /*else { // no MIDI busses yet
121 controls_ebox.set_name ("MidiBusControlsBaseUnselected");
122 controls_base_selected_name = "MidiBusControlsBaseSelected";
123 controls_base_unselected_name = "MidiBusControlsBaseUnselected";
127 MidiTimeAxisView::~MidiTimeAxisView ()
132 MidiTimeAxisView::midi_view()
134 return dynamic_cast<MidiStreamView*>(_view);
138 MidiTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
141 xml_node->add_property ("shown_editor", "yes");
143 return TimeAxisView::show_at (y, nth, parent);
147 MidiTimeAxisView::hide ()
150 xml_node->add_property ("shown_editor", "no");
152 TimeAxisView::hide ();
156 MidiTimeAxisView::build_automation_action_menu ()
158 using namespace Menu_Helpers;
160 RouteTimeAxisView::build_automation_action_menu ();
162 MenuList& automation_items = automation_action_menu->items();
164 automation_items.push_back (SeparatorElem());
166 automation_items.push_back (MenuElem (_("Controller..."),
167 mem_fun(*this, &MidiTimeAxisView::add_controller_track)));
170 /** Prompt for a controller with a dialog and add an automation track for it
173 MidiTimeAxisView::add_controller_track()
179 AddMidiCCTrackDialog dialog;
180 dialog.set_transient_for(editor);
181 response = dialog.run();
183 if (response == Gtk::RESPONSE_ACCEPT)
184 param = dialog.parameter();
187 if (response == Gtk::RESPONSE_ACCEPT)
188 create_automation_child(param, true);
192 MidiTimeAxisView::create_automation_child (Parameter param, bool show)
194 if (param.type() == MidiCCAutomation) {
196 /* FIXME: this all probably leaks */
198 boost::shared_ptr<AutomationControl> c = _route->control(param);
201 boost::shared_ptr<AutomationList> al(new ARDOUR::AutomationList(param, 0, 127, 64));
202 c = boost::shared_ptr<AutomationControl>(new MidiTrack::MidiControl(midi_track(), al));
203 _route->add_control(c);
206 boost::shared_ptr<AutomationTimeAxisView> track(new AutomationTimeAxisView (_session,
211 _route->describe_parameter(param)));
213 add_automation_child(param, track, show);
216 error << "MidiTimeAxisView: unknown automation child " << param.to_string() << endmsg;
221 MidiTimeAxisView::route_active_changed ()
223 RouteUI::route_active_changed ();
226 if (_route->active()) {
227 controls_ebox.set_name ("MidiTrackControlsBaseUnselected");
228 controls_base_selected_name = "MidiTrackControlsBaseSelected";
229 controls_base_unselected_name = "MidiTrackControlsBaseUnselected";
231 controls_ebox.set_name ("MidiTrackControlsBaseInactiveUnselected");
232 controls_base_selected_name = "MidiTrackControlsBaseInactiveSelected";
233 controls_base_unselected_name = "MidiTrackControlsBaseInactiveUnselected";
239 if (_route->active()) {
240 controls_ebox.set_name ("BusControlsBaseUnselected");
241 controls_base_selected_name = "BusControlsBaseSelected";
242 controls_base_unselected_name = "BusControlsBaseUnselected";
244 controls_ebox.set_name ("BusControlsBaseInactiveUnselected");
245 controls_base_selected_name = "BusControlsBaseInactiveSelected";
246 controls_base_unselected_name = "BusControlsBaseInactiveUnselected";