Fix DSP load sorting with inactive plugins
[ardour.git] / gtk2_ardour / route_time_axis.h
1 /*
2  * Copyright (C) 2006-2008 Sampo Savolainen <v2@iki.fi>
3  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
4  * Copyright (C) 2006-2017 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2007 Doug McLain <doug@nostar.net>
6  * Copyright (C) 2008-2012 Carl Hetherington <carl@carlh.net>
7  * Copyright (C) 2014-2015 Ben Loftis <ben@harrisonconsoles.com>
8  * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 #ifndef __ardour_route_time_axis_h__
26 #define __ardour_route_time_axis_h__
27
28 #include <list>
29 #include <set>
30
31 #include <gtkmm/table.h>
32 #include <gtkmm/button.h>
33 #include <gtkmm/box.h>
34 #include <gtkmm/menu.h>
35 #include <gtkmm/menuitem.h>
36 #include <gtkmm/radiomenuitem.h>
37 #include <gtkmm/checkmenuitem.h>
38 #include <gtkmm/adjustment.h>
39
40 #include "widgets/ardour_button.h"
41
42 #include "ardour/playlist.h"
43 #include "ardour/types.h"
44
45 #include "ardour_dialog.h"
46 #include "route_ui.h"
47 #include "enums.h"
48 #include "stripable_time_axis.h"
49 #include "gain_meter.h"
50
51 namespace ARDOUR {
52         class Session;
53         class Region;
54         class RouteGroup;
55         class IOProcessor;
56         class Processor;
57         class Location;
58         class Playlist;
59 }
60
61 namespace ArdourCanvas {
62         class Rectangle;
63 }
64
65 class PublicEditor;
66 class RegionView;
67 class StreamView;
68 class Selection;
69 class RegionSelection;
70 class Selectable;
71 class AutomationTimeAxisView;
72 class AutomationLine;
73 class ProcessorAutomationLine;
74 class TimeSelection;
75 class RouteGroupMenu;
76 class ItemCounts;
77
78 class RouteTimeAxisView : public RouteUI, public StripableTimeAxisView
79 {
80 public:
81         RouteTimeAxisView (PublicEditor&, ARDOUR::Session*, ArdourCanvas::Canvas& canvas);
82         virtual ~RouteTimeAxisView ();
83
84         std::string name()  const;
85         Gdk::Color color () const;
86         bool marked_for_display () const;
87         bool set_marked_for_display (bool);
88
89         boost::shared_ptr<ARDOUR::Stripable> stripable() const { return RouteUI::stripable(); }
90
91         void set_route (boost::shared_ptr<ARDOUR::Route>);
92
93         void show_selection (TimeSelection&);
94         void set_button_names ();
95
96         void set_samples_per_pixel (double);
97         void set_height (uint32_t h, TrackHeightMode m = OnlySelf);
98         void show_timestretch (samplepos_t start, samplepos_t end, int layers, int layer);
99         void hide_timestretch ();
100         void selection_click (GdkEventButton*);
101         void set_selected_points (PointSelection&);
102         void set_selected_regionviews (RegionSelection&);
103         void get_selectables (ARDOUR::samplepos_t start, ARDOUR::samplepos_t end, double top, double bot, std::list<Selectable *>&, bool within = false);
104         void get_inverted_selectables (Selection&, std::list<Selectable*>&);
105         void set_layer_display (LayerDisplay d, bool apply_to_selection = false);
106         LayerDisplay layer_display () const;
107
108         boost::shared_ptr<ARDOUR::Region> find_next_region (samplepos_t pos, ARDOUR::RegionPoint, int32_t dir);
109         samplepos_t find_next_region_boundary (samplepos_t pos, int32_t dir);
110
111         /* Editing operations */
112         void cut_copy_clear (Selection&, Editing::CutCopyOp);
113         bool paste (ARDOUR::samplepos_t, const Selection&, PasteContext& ctx, const int32_t sub_num);
114         RegionView* combine_regions ();
115         void uncombine_regions ();
116         void uncombine_region (RegionView*);
117         void toggle_automation_track (const Evoral::Parameter& param);
118         void fade_range (TimeSelection&);
119
120         /* The editor calls these when mapping an operation across multiple tracks */
121         void use_new_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &, bool copy);
122         void clear_playlist ();
123
124         /* group playlist name resolving */
125         std::string resolve_new_group_playlist_name(std::string &, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
126
127         void build_playlist_menu ();
128
129         void add_underlay (StreamView*, bool update_xml = true);
130         void remove_underlay (StreamView*);
131         void build_underlay_menu(Gtk::Menu*);
132
133         int set_state (const XMLNode&, int version);
134
135         virtual Gtk::CheckMenuItem* automation_child_menu_item (Evoral::Parameter);
136
137         StreamView*         view() const { return _view; }
138         ARDOUR::RouteGroup* route_group() const;
139         boost::shared_ptr<ARDOUR::Playlist> playlist() const;
140
141         void fast_update ();
142         void hide_meter ();
143         void show_meter ();
144         void reset_meter ();
145         void clear_meter ();
146         void io_changed (ARDOUR::IOChange, void *);
147         void meter_changed ();
148         void effective_gain_display () { gm.effective_gain_display(); }
149
150         std::string state_id() const;
151
152 protected:
153         friend class StreamView;
154
155         struct ProcessorAutomationNode {
156                 Evoral::Parameter                         what;
157                 Gtk::CheckMenuItem*                       menu_item;
158                 boost::shared_ptr<AutomationTimeAxisView> view;
159                 RouteTimeAxisView&                        parent;
160
161                 ProcessorAutomationNode (Evoral::Parameter w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
162                     : what (w), menu_item (mitem), parent (p) {}
163
164                 ~ProcessorAutomationNode ();
165         };
166
167         struct ProcessorAutomationInfo {
168                 boost::shared_ptr<ARDOUR::Processor> processor;
169                 bool                                  valid;
170                 Gtk::Menu*                            menu;
171                 std::vector<ProcessorAutomationNode*> lines;
172
173                 ProcessorAutomationInfo (boost::shared_ptr<ARDOUR::Processor> i)
174                     : processor (i), valid (true), menu (0) {}
175
176                 ~ProcessorAutomationInfo ();
177         };
178
179
180         void update_diskstream_display ();
181
182         bool route_group_click  (GdkEventButton *);
183
184         virtual void processors_changed (ARDOUR::RouteProcessorChange);
185
186         virtual void add_processor_to_subplugin_menu (boost::weak_ptr<ARDOUR::Processor>);
187         void remove_processor_automation_node (ProcessorAutomationNode* pan);
188
189         void processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo*,
190                                          RouteTimeAxisView::ProcessorAutomationNode*);
191
192         void processor_automation_track_hidden (ProcessorAutomationNode*,
193                                                boost::shared_ptr<ARDOUR::Processor>);
194
195
196         ProcessorAutomationNode*
197         find_processor_automation_node (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
198
199         boost::shared_ptr<AutomationLine>
200         find_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
201
202         void add_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> r, Evoral::Parameter);
203         void add_existing_processor_automation_curves (boost::weak_ptr<ARDOUR::Processor>);
204
205
206         void reset_processor_automation_curves ();
207
208         void take_name_changed (void *src);
209         void route_property_changed (const PBD::PropertyChange&);
210         bool name_entry_changed (std::string const&);
211
212         virtual void toggle_channel_selector () {}
213
214         void blink_rec_display (bool onoff);
215
216         virtual void label_view ();
217
218         virtual void build_automation_action_menu (bool);
219         virtual void append_extra_display_menu_items () {}
220         void         build_display_menu ();
221
222         void set_align_choice (Gtk::RadioMenuItem*, ARDOUR::AlignChoice, bool apply_to_selection = false);
223
224         bool         playlist_click (GdkEventButton *);
225         void         show_playlist_selector ();
226         void         playlist_changed ();
227
228         void rename_current_playlist ();
229
230         bool         automation_click (GdkEventButton *);
231
232         virtual void show_all_automation (bool apply_to_selection = false);
233         virtual void show_existing_automation (bool apply_to_selection = false);
234         virtual void hide_all_automation (bool apply_to_selection = false);
235
236         void timestretch (samplepos_t start, samplepos_t end);
237         void speed_changed ();
238         void map_frozen ();
239         void color_handler ();
240         void region_view_added (RegionView*);
241         void create_gain_automation_child (const Evoral::Parameter &, bool);
242         void create_trim_automation_child (const Evoral::Parameter &, bool);
243         void create_mute_automation_child (const Evoral::Parameter &, bool);
244         void setup_processor_menu_and_curves ();
245         void route_color_changed ();
246         bool can_edit_name() const;
247
248         StreamView*           _view;
249
250         Gtk::HBox   other_button_hbox;
251         Gtk::Table  button_table;
252         ArdourWidgets::ArdourButton route_group_button;
253         ArdourWidgets::ArdourButton playlist_button;
254         ArdourWidgets::ArdourButton automation_button;
255         ArdourWidgets::ArdourButton number_label;
256
257         Gtk::Menu           subplugin_menu;
258         Gtk::Menu*          automation_action_menu;
259         Gtk::MenuItem*      plugins_submenu_item;
260         RouteGroupMenu*     route_group_menu;
261         Gtk::Menu*          playlist_action_menu;
262         Gtk::MenuItem*      playlist_item;
263
264         void use_playlist (Gtk::RadioMenuItem *item, boost::weak_ptr<ARDOUR::Playlist> wpl);
265
266         ArdourCanvas::Rectangle* timestretch_rect;
267
268         /** Information about all automatable processor parameters that apply to
269          *  this route.  The Amp processor is not included in this list.
270          */
271         std::list<ProcessorAutomationInfo*> processor_automation;
272
273         typedef std::vector<boost::shared_ptr<AutomationLine> > ProcessorAutomationCurves;
274         ProcessorAutomationCurves processor_automation_curves;
275         /** parameter -> menu item map for the plugin automation menu */
276         ParameterMenuMap _subplugin_menu_map;
277
278         void post_construct ();
279
280         GainMeterBase gm;
281
282         XMLNode* underlay_xml_node;
283         bool set_underlay_state();
284
285         typedef std::list<StreamView*> UnderlayList;
286         UnderlayList _underlay_streams;
287         typedef std::list<RouteTimeAxisView*> UnderlayMirrorList;
288         UnderlayMirrorList _underlay_mirrors;
289
290         bool _ignore_set_layer_display;
291
292 protected:
293         void update_pan_track_visibility ();
294
295         /** Ensure that we have the appropriate automation lanes for panners.
296          *
297          *  @param show true to show any new views that we create, otherwise false.
298          */
299         void ensure_pan_views (bool show = true);
300
301         std::list<boost::shared_ptr<AutomationTimeAxisView> > pan_tracks;
302         Gtk::CheckMenuItem* pan_automation_item;
303
304 private:
305
306         void remove_child (boost::shared_ptr<TimeAxisView>);
307         void update_playlist_tip ();
308         void parameter_changed (std::string const & p);
309         void update_track_number_visibility();
310
311         void drop_instrument_ref ();
312         void reread_midnam ();
313         PBD::ScopedConnectionList midnam_connection;
314 };
315
316 #endif /* __ardour_route_time_axis_h__ */