ardour
audio_time_axis.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2000-2006 Paul Davis
3 
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.
8 
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.
13 
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.
17 
18 */
19 
20 #include <cstdlib>
21 #include <cmath>
22 #include <cassert>
23 
24 #include <algorithm>
25 #include <string>
26 #include <vector>
27 
28 #include <sigc++/bind.h>
29 
30 #include "pbd/error.h"
31 #include "pbd/stl_delete.h"
32 #include "pbd/memento_command.h"
33 
34 #include "gtkmm2ext/gtk_ui.h"
35 #include "gtkmm2ext/selector.h"
37 #include "gtkmm2ext/utils.h"
38 
39 #include "ardour/event_type_map.h"
40 #include "ardour/pannable.h"
41 #include "ardour/panner.h"
42 #include "ardour/panner_shell.h"
43 
44 #include "ardour_button.h"
45 #include "ardour_ui.h"
46 #include "audio_time_axis.h"
47 #include "automation_line.h"
48 #include "enums.h"
49 #include "gui_thread.h"
50 #include "automation_time_axis.h"
51 #include "keyboard.h"
52 #include "playlist_selector.h"
53 #include "prompter.h"
54 #include "public_editor.h"
55 #include "audio_region_view.h"
56 #include "audio_streamview.h"
57 #include "utils.h"
58 
59 #include "i18n.h"
60 
61 using namespace std;
62 using namespace ARDOUR;
63 using namespace ARDOUR_UI_UTILS;
64 using namespace PBD;
65 using namespace Gtk;
66 using namespace Editing;
67 
68 AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session* sess, ArdourCanvas::Canvas& canvas)
69  : AxisView(sess)
70  , RouteTimeAxisView(ed, sess, canvas)
71 {
72 }
73 
74 void
76 {
77  _route = rt;
78 
79  /* RouteTimeAxisView::set_route() sets up some things in the View,
80  so it must be created before RouteTimeAxis::set_route() is
81  called.
82  */
83  _view = new AudioStreamView (*this);
84 
86 
88 
89  // Make sure things are sane...
90  assert(!is_track() || is_audio_track());
91 
92  subplugin_menu.set_name ("ArdourContextMenu");
93 
94  ignore_toggle = false;
95 
96  if (is_audio_track()) {
97  controls_ebox.set_name ("AudioTrackControlsBaseUnselected");
98  time_axis_frame.set_name ("AudioTrackControlsBaseUnselected");
99  } else { // bus
100  controls_ebox.set_name ("AudioBusControlsBaseUnselected");
101  time_axis_frame.set_name ("AudioBusControlsBaseUnselected");
102  }
103 
104  /* if set_state above didn't create a gain automation child, we need to make one */
105  if (automation_child (GainAutomation) == 0) {
107  }
108 
109  if (automation_child (TrimAutomation) == 0) {
111  }
112 
113  /* if set_state above didn't create a mute automation child, we need to make one */
114  if (automation_child (MuteAutomation) == 0) {
116  }
117 
118  if (_route->panner_shell()) {
119  _route->panner_shell()->Changed.connect (*this, invalidator (*this),
120  boost::bind (&AudioTimeAxisView::ensure_pan_views, this, false), gui_context());
121  }
122 
123  /* map current state of the route */
124 
127  ensure_pan_views (false);
129 
130  if (is_audio_track()) {
131 
132  /* ask for notifications of any new RegionViews */
133  _view->RegionViewAdded.connect (sigc::mem_fun(*this, &AudioTimeAxisView::region_view_added));
134 
135  if (!_editor.have_idled()) {
136  /* first idle will do what we need */
137  } else {
138  first_idle ();
139  }
140 
141  } else {
142  post_construct ();
143  }
144 }
145 
147 {
148 }
149 
150 void
152 {
153  _view->attach ();
154  post_construct ();
155 }
156 
159 {
160  return dynamic_cast<AudioStreamView*>(_view);
161 }
162 
163 guint32
164 AudioTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
165 {
166  set_gui_property ("visible", true);
167  return TimeAxisView::show_at (y, nth, parent);
168 }
169 
170 void
172 {
173  set_gui_property ("visible", false);
175 }
176 
177 void
179 {
180  if (param.type() == NullAutomation) {
181  return;
182  }
183 
184  AutomationTracks::iterator existing = _automation_tracks.find (param);
185 
186  if (existing != _automation_tracks.end()) {
187 
188  /* automation track created because we had existing data for
189  * the processor, but visibility may need to be controlled
190  * since it will have been set visible by default.
191  */
192 
193  existing->second->set_marked_for_display (show);
194 
195  if (!no_redraw) {
196  request_redraw ();
197  }
198 
199  return;
200  }
201 
202  if (param.type() == GainAutomation) {
203 
204  create_gain_automation_child (param, show);
205 
206  } else if (param.type() == TrimAutomation) {
207 
208  create_trim_automation_child (param, show);
209 
210  } else if (param.type() == PanWidthAutomation ||
211  param.type() == PanElevationAutomation ||
212  param.type() == PanAzimuthAutomation) {
213 
214  ensure_pan_views (show);
215 
216  } else if (param.type() == PluginAutomation) {
217 
218  /* handled elsewhere */
219 
220  } else if (param.type() == MuteAutomation) {
221 
222  create_mute_automation_child (param, show);
223 
224 
225  } else {
226  error << "AudioTimeAxisView: unknown automation child " << EventTypeMap::instance().to_symbol(param) << endmsg;
227  }
228 }
229 
230 void
231 AudioTimeAxisView::show_all_automation (bool apply_to_selection)
232 {
233  if (apply_to_selection) {
235  } else {
236 
237  no_redraw = true;
238 
240 
241  no_redraw = false;
242  request_redraw ();
243  }
244 }
245 
246 void
248 {
249  if (apply_to_selection) {
251  } else {
252  no_redraw = true;
253 
255 
256  no_redraw = false;
257 
258  request_redraw ();
259  }
260 }
261 
262 void
263 AudioTimeAxisView::hide_all_automation (bool apply_to_selection)
264 {
265  if (apply_to_selection) {
267  } else {
268  no_redraw = true;
269 
271 
272  no_redraw = false;
273  request_redraw ();
274  }
275 }
276 
277 void
279 {
281 }
282 
283 
290 void
292 {
293  if (is_audio_track()) {
294  if (_route->active()) {
295  controls_base_selected_name = "AudioTrackControlsBaseSelected";
296  controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
297  } else {
298  controls_base_selected_name = "AudioTrackControlsBaseInactiveSelected";
299  controls_base_unselected_name = "AudioTrackControlsBaseInactiveUnselected";
300  }
301  } else {
302  if (_route->active()) {
303  controls_base_selected_name = "BusControlsBaseSelected";
304  controls_base_unselected_name = "BusControlsBaseUnselected";
305  } else {
306  controls_base_selected_name = "BusControlsBaseInactiveSelected";
307  controls_base_unselected_name = "BusControlsBaseInactiveUnselected";
308  }
309  }
310 
311  if (get_selected()) {
314  } else {
317  }
318 }
319 
320 void
322 {
324 }
Gdk::Color color() const
Definition: route_ui.cc:2138
void create_trim_automation_child(const Evoral::Parameter &, bool)
virtual guint32 show_at(double y, int &nth, Gtk::VBox *parent)
void set_route(boost::shared_ptr< ARDOUR::Route >)
Gtk::Menu subplugin_menu
bool is_audio_track() const
Definition: route_ui.cc:1744
sigc::signal< void, RegionView * > RegionViewAdded
Definition: streamview.h:122
StreamView * _view
virtual bool have_idled() const =0
Definition: ardour_ui.h:130
friend class AudioStreamView
Representation of the interface of the Editor class.
Definition: Beats.hpp:239
LIBPBD_API Transmitter error
std::ostream & endmsg(std::ostream &ostr)
Definition: transmitter.h:71
Gtk::Frame time_axis_frame
void show_existing_automation(bool apply_to_selection=false)
AudioTimeAxisView(PublicEditor &, ARDOUR::Session *, ArdourCanvas::Canvas &canvas)
#define invalidator(x)
Definition: gui_thread.h:40
guint32 show_at(double y, int &nth, Gtk::VBox *parent)
void build_automation_action_menu(bool)
bool ignore_toggle
Definition: route_ui.h:94
virtual void show_existing_automation(bool apply_to_selection=false)
std::string controls_base_selected_name
void create_gain_automation_child(const Evoral::Parameter &, bool)
boost::shared_ptr< ARDOUR::Route > _route
Definition: route_ui.h:87
uint32_t gdk_color_to_rgba(Gdk::Color const &)
Definition: utils.cc:285
void attach()
Definition: streamview.cc:100
virtual void show_all_automation(bool apply_to_selection=false)
Definition: amp.h:29
void request_redraw()
Definition: route_ui.cc:2100
#define gui_context()
Definition: gui_thread.h:36
void region_view_added(RegionView *)
virtual Selection & get_selection() const =0
bool get_selected() const
Definition: selectable.h:40
void ensure_pan_views(bool show=true)
boost::shared_ptr< PannerShell > panner_shell() const
Definition: route.cc:4036
AutomationTracks _automation_tracks
bool is_track() const
Definition: route_ui.cc:1732
void set_route(boost::shared_ptr< ARDOUR::Route >)
virtual ~AudioTimeAxisView()
bool active() const
Definition: route.h:95
void processors_changed(ARDOUR::RouteProcessorChange)
virtual void build_automation_action_menu(bool)
AudioStreamView * audio_view()
void create_mute_automation_child(const Evoral::Parameter &, bool)
virtual void hide()
void reset_processor_automation_curves()
TrackSelection tracks
Definition: selection.h:81
boost::shared_ptr< AutomationTimeAxisView > automation_child(Evoral::Parameter param)
uint32_t type() const
Definition: Parameter.hpp:47
Definition: debug.h:30
void show_all_automation(bool apply_to_selection=false)
void foreach_audio_time_axis(Function f)
std::string controls_base_unselected_name
void set_gui_property(const std::string &property_name, const T &value)
Definition: axis_view.h:66
void hide_all_automation(bool apply_to_selection=false)
PublicEditor & _editor
void apply_color(uint32_t, ColorTarget t)
Definition: streamview.cc:354
Gtk::EventBox controls_ebox
void create_automation_child(const Evoral::Parameter &param, bool show)
virtual void hide_all_automation(bool apply_to_selection=false)