1 /*
2 * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3 * Copyright (C) 2005-2018 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2006-2007 Doug McLain <doug@nostar.net>
5 * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2007-2012 David Robillard <d@drobilla.net>
7 * Copyright (C) 2007-2016 Tim Mayberry <mojofunk@gmail.com>
8 * Copyright (C) 2013-2015 Nick Mainsbridge <mainsbridge@gmail.com>
9 * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
10 * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
11 * Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 */
27
28 #ifdef WAF_BUILD
29 #include "gtk2ardour-config.h"
30 #endif
31
32 #include <algorithm>
33 #include <map>
34 #include <sigc++/bind.h>
35
36 #include <boost/foreach.hpp>
37
38 #include <glibmm/threads.h>
39
40 #include <gtkmm/accelmap.h>
41 #include <gtkmm/offscreenwindow.h>
42 #include <gtkmm/stock.h>
43
44 #include "pbd/convert.h"
45 #include "pbd/unwind.h"
46
47 #include "ardour/amp.h"
48 #include "ardour/debug.h"
49 #include "ardour/audio_port.h"
50 #include "ardour/audio_track.h"
51 #include "ardour/midi_track.h"
52 #include "ardour/monitor_control.h"
53 #include "ardour/panner_shell.h"
54 #include "ardour/plugin_manager.h"
55 #include "ardour/route_group.h"
56 #include "ardour/selection.h"
57 #include "ardour/session.h"
58 #include "ardour/vca.h"
59 #include "ardour/vca_manager.h"
60
61 #include "gtkmm2ext/gtk_ui.h"
62 #include "gtkmm2ext/keyboard.h"
63 #include "gtkmm2ext/utils.h"
64 #include "gtkmm2ext/window_title.h"
65 #include "gtkmm2ext/doi.h"
66
67 #include "widgets/tearoff.h"
68
69 #include "foldback_strip.h"
70 #include "keyboard.h"
71 #include "mixer_ui.h"
72 #include "mixer_strip.h"
73 #include "monitor_section.h"
74 #include "plugin_selector.h"
75 #include "public_editor.h"
76 #include "mouse_cursors.h"
77 #include "ardour_ui.h"
78 #include "utils.h"
79 #include "route_sorter.h"
80 #include "actions.h"
81 #include "gui_thread.h"
82 #include "mixer_group_tabs.h"
83 #include "plugin_utils.h"
84 #include "route_sorter.h"
85 #include "timers.h"
86 #include "ui_config.h"
87 #include "vca_master_strip.h"
88
89 #include "pbd/i18n.h"
90
91 #define PX_SCALE(px) std::max ((float)px, rintf ((float)px* UIConfiguration::instance ().get_ui_scale ()))
92
93 using namespace ARDOUR;
94 using namespace ARDOUR_UI_UTILS;
95 using namespace ARDOUR_PLUGIN_UTILS;
96 using namespace PBD;
97 using namespace Gtk;
98 using namespace Glib;
99 using namespace Gtkmm2ext;
100 using namespace std;
101
102 using PBD::atoi;
103 using PBD::Unwinder;
104
105 Mixer_UI* Mixer_UI::_instance = 0;
106
107 Mixer_UI*
instance()108 Mixer_UI::instance ()
109 {
110 if (!_instance) {
111 _instance = new Mixer_UI;
112 }
113
114 return _instance;
115 }
116
Mixer_UI()117 Mixer_UI::Mixer_UI ()
118 : Tabbable (_content, _("Mixer"), X_("mixer"))
119 , plugin_search_clear_button (Stock::CLEAR)
120 , no_track_list_redisplay (false)
121 , in_group_row_change (false)
122 , track_menu (0)
123 , _plugin_selector (0)
124 , foldback_strip (0)
125 , _show_foldback_strip (true)
126 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
127 , _spill_scroll_position (0)
128 , ignore_track_reorder (false)
129 , ignore_plugin_refill (false)
130 , ignore_plugin_reorder (false)
131 , _in_group_rebuild_or_clear (false)
132 , _route_deletion_in_progress (false)
133 , _maximised (false)
134 , _strip_selection_change_without_scroll (false)
135 , _selection (*this, *this)
136 {
137 load_bindings ();
138 register_actions ();
139 Glib::RefPtr<ToggleAction> fb_act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
140 fb_act->set_sensitive (false);
141
142 _content.set_data ("ardour-bindings", bindings);
143
144 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
145 Route::FanOut.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::fan_out, this, _1, false, true), gui_context());
146
147 scroller.set_can_default (true);
148 // set_default (scroller);
149
150 scroller_base.set_flags (Gtk::CAN_FOCUS);
151 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
152 scroller_base.set_name ("MixerWindow");
153 scroller_base.signal_button_press_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_event));
154 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_event));
155
156 /* set up drag-n-drop */
157 vector<TargetEntry> target_table;
158 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
159 scroller_base.drag_dest_set (target_table);
160 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
161
162 /* add as last item of strip packer */
163 strip_packer.pack_end (scroller_base, true, true);
164 scroller_base.set_size_request (PX_SCALE (20), -1);
165 scroller_base.signal_expose_event().connect (sigc::bind (sigc::ptr_fun(&ArdourWidgets::ArdourIcon::expose), &scroller_base, ArdourWidgets::ArdourIcon::ShadedPlusSign));
166
167 #ifdef MIXBUS
168 /* create a drop-shadow at the end of the mixer strips */
169 mb_shadow.set_size_request( 4, -1 );
170 mb_shadow.set_name("EditorWindow");
171 mb_shadow.show();
172 strip_packer.pack_end (mb_shadow, false, false);
173 #endif
174
175 _group_tabs = new MixerGroupTabs (this);
176 strip_group_box.set_spacing (0);
177 strip_group_box.set_border_width (0);
178 strip_group_box.pack_start (*_group_tabs, PACK_SHRINK);
179 strip_group_box.pack_start (strip_packer);
180 strip_group_box.show_all ();
181 strip_group_box.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
182
183 scroller.add (strip_group_box);
184 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
185
186 setup_track_display ();
187
188 group_model = ListStore::create (group_columns);
189 group_display.set_model (group_model);
190 group_display.append_column (_("Show"), group_columns.visible);
191 group_display.append_column (_("Group"), group_columns.text);
192 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
193 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
194 group_display.get_column (0)->set_expand(false);
195 group_display.get_column (1)->set_expand(true);
196 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
197 group_display.set_name ("EditGroupList");
198 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
199 group_display.set_reorderable (true);
200 group_display.set_headers_visible (true);
201 group_display.set_rules_hint (true);
202 group_display.set_can_focus(false);
203
204 /* name is directly editable */
205
206 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
207 name_cell->property_editable() = true;
208 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
209
210 /* use checkbox for the active column */
211
212 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
213 active_cell->property_activatable() = true;
214 active_cell->property_radio() = false;
215
216 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
217 /* We use this to notice drag-and-drop reorders of the group list */
218 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
219 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
220
221 group_display_scroller.add (group_display);
222 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
223
224
225 group_display_vbox.pack_start (group_display_scroller, true, true);
226
227 group_display_frame.set_name ("BaseFrame");
228 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
229 group_display_frame.add (group_display_vbox);
230
231 list<TargetEntry> target_list;
232 target_list.push_back (TargetEntry ("PluginPresetPtr"));
233
234 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
235 favorite_plugins_display.set_model (favorite_plugins_model);
236 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
237 favorite_plugins_display.set_name ("EditGroupList");
238 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
239 favorite_plugins_display.set_reorderable (false);
240 favorite_plugins_display.set_headers_visible (false);
241 favorite_plugins_display.set_rules_hint (true);
242 favorite_plugins_display.set_can_focus (false);
243 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
244 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
245 favorite_plugins_display.add_drop_targets (target_list);
246 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
247 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
248 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
249 favorite_plugins_display.signal_motion.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drag_motion));
250 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
251 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
252 if (UIConfiguration::instance().get_use_tooltips()) {
253 favorite_plugins_display.set_tooltip_column (0);
254 }
255 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
256 favorite_plugins_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::favorite_plugins_deleted));
257
258 favorite_plugins_mode_combo.append_text (_("Favorite Plugins"));
259 favorite_plugins_mode_combo.append_text (_("Recent Plugins"));
260 favorite_plugins_mode_combo.append_text (_("Top-10 Plugins"));
261 favorite_plugins_mode_combo.set_active_text (_("Favorite Plugins"));
262 favorite_plugins_mode_combo.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_list_mode_changed));
263
264 plugin_search_entry.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_search_entry_changed));
265 plugin_search_clear_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_search_clear_button_clicked));
266
267 favorite_plugins_scroller.add (favorite_plugins_display);
268 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
269
270 favorite_plugins_search_hbox.pack_start (plugin_search_entry, true, true);
271 favorite_plugins_search_hbox.pack_start (plugin_search_clear_button, false, false);
272
273 favorite_plugins_frame.set_name ("BaseFrame");
274 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
275 favorite_plugins_frame.add (favorite_plugins_vbox);
276
277 favorite_plugins_vbox.pack_start (favorite_plugins_mode_combo, false, false);
278 favorite_plugins_vbox.pack_start (favorite_plugins_scroller, true, true);
279 favorite_plugins_vbox.pack_start (favorite_plugins_search_hbox, false, false);
280
281 rhs_pane1.add (favorite_plugins_frame);
282 rhs_pane1.add (track_display_frame);
283
284 rhs_pane2.add (rhs_pane1);
285 rhs_pane2.add (group_display_frame);
286
287 list_vpacker.pack_start (rhs_pane2, true, true);
288
289 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
290 vca_vpacker.pack_start (vca_label_bar, false, false);
291
292 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
293 vca_scroller_base.set_name (X_("MixerWindow"));
294 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
295
296 vca_hpacker.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_vca_scroll_event), false);
297 vca_scroller.add (vca_hpacker);
298 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
299 vca_scroller.signal_button_press_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_event));
300 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_event));
301
302 vca_vpacker.pack_start (vca_scroller, true, true);
303
304 inner_pane.add (scroller);
305 inner_pane.add (vca_vpacker);
306
307 global_hpacker.pack_start (inner_pane, true, true);
308 global_hpacker.pack_start (out_packer, false, false);
309
310 list_hpane.set_check_divider_position (true);
311 list_hpane.add (list_vpacker);
312 list_hpane.add (global_hpacker);
313 list_hpane.set_child_minsize (list_vpacker, 30);
314
315 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
316 float fract;
317
318 if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) {
319 fract = 0.6f;
320 }
321 rhs_pane1.set_divider (0, fract);
322
323 if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
324 fract = 0.7f;
325 }
326 rhs_pane2.set_divider (0, fract);
327
328 if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
329 fract = 0.2f;
330 }
331 list_hpane.set_divider (0, fract);
332
333 if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
334 fract = 0.8f;
335 }
336 inner_pane.set_divider (0, fract);
337
338 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
339 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
340 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
341 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
342
343 _content.pack_start (list_hpane, true, true);
344
345 update_title ();
346
347 _content.show ();
348 _content.set_name ("MixerWindow");
349
350 global_hpacker.show();
351 scroller.show();
352 scroller_base.show();
353 scroller_hpacker.show();
354 mixer_scroller_vpacker.show();
355 list_vpacker.show();
356 group_display_button_label.show();
357 group_display_scroller.show();
358 favorite_plugins_scroller.show();
359 group_display_vbox.show();
360 group_display_frame.show();
361 favorite_plugins_frame.show();
362 rhs_pane1.show();
363 rhs_pane2.show();
364 strip_packer.show();
365 inner_pane.show();
366 vca_scroller.show();
367 vca_vpacker.show();
368 vca_hpacker.show();
369 vca_label_bar.show();
370 vca_label.show();
371 vca_scroller_base.show();
372 out_packer.show();
373 list_hpane.show();
374 group_display.show();
375 favorite_plugins_display.show();
376
377 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
378 if (mnode) {
379 _monitor_section.tearoff().set_state (*mnode);
380 }
381
382 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
383 VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
384 FoldbackStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_foldback, this, _1), gui_context());
385
386 /* handle escape */
387
388 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
389
390 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
391 _plugin_selector = new PluginSelector (PluginManager::instance ());
392 #else
393 #error implement deferred Plugin-Favorite list
394 #endif
395
396 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
397 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
398
399 PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::maybe_refill_favorite_plugins, this, PLM_Favorite), gui_context());
400 PluginManager::instance ().PluginStatsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::maybe_refill_favorite_plugins, this, PLM_Recent), gui_context());
401 }
402
~Mixer_UI()403 Mixer_UI::~Mixer_UI ()
404 {
405 monitor_section_detached ();
406
407 delete foldback_strip;
408 foldback_strip = 0;
409 delete _plugin_selector;
410 delete track_menu;
411 delete _group_tabs;
412 }
413
414 struct MixerStripSorter {
operator ()MixerStripSorter415 bool operator() (const MixerStrip* ms_a, const MixerStrip* ms_b)
416 {
417 boost::shared_ptr<ARDOUR::Stripable> const& a = ms_a->stripable ();
418 boost::shared_ptr<ARDOUR::Stripable> const& b = ms_b->stripable ();
419 return ARDOUR::Stripable::Sorter(true)(a, b);
420 }
421 };
422
423
424 void
escape()425 Mixer_UI::escape ()
426 {
427 select_none ();
428 }
429
430 Gtk::Window*
use_own_window(bool and_fill_it)431 Mixer_UI::use_own_window (bool and_fill_it)
432 {
433 bool new_window = !own_window();
434
435 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
436
437 if (win && new_window) {
438 win->set_name ("MixerWindow");
439 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
440 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
441 win->set_data ("ardour-bindings", bindings);
442 update_title ();
443 if (!win->get_focus()) {
444 /* set focus widget to something, anything */
445 win->set_focus (scroller);
446 }
447 }
448
449 return win;
450 }
451
452 void
show_window()453 Mixer_UI::show_window ()
454 {
455 Tabbable::show_window ();
456
457 /* show/hide group tabs as required */
458 parameter_changed ("show-group-tabs");
459
460 /* now reset each strips width so the right widgets are shown */
461
462 TreeModel::Children rows = track_model->children();
463 TreeModel::Children::iterator ri;
464
465 for (ri = rows.begin(); ri != rows.end(); ++ri) {
466 AxisView* av = (*ri)[stripable_columns.strip];
467 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
468 if (!ms) {
469 continue;
470 }
471 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
472 /* Fix visibility of mixer strip stuff */
473 ms->parameter_changed (X_("mixer-element-visibility"));
474 }
475
476 /* force focus into main area */
477 scroller_base.grab_focus ();
478 }
479
480 void
remove_master(VCAMasterStrip * vms)481 Mixer_UI::remove_master (VCAMasterStrip* vms)
482 {
483 if (_session && _session->deletion_in_progress()) {
484 /* its all being taken care of */
485 return;
486 }
487
488 TreeModel::Children rows = track_model->children();
489 TreeModel::Children::iterator ri;
490
491 for (ri = rows.begin(); ri != rows.end(); ++ri) {
492 if ((*ri)[stripable_columns.strip] == vms) {
493 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
494 track_model->erase (ri);
495 break;
496 }
497 }
498 }
499
500 bool
masters_scroller_button_release(GdkEventButton * ev)501 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
502 {
503 using namespace Menu_Helpers;
504
505 if (Keyboard::is_context_menu_event (ev)) {
506 ARDOUR_UI::instance()->add_route ();
507 return true;
508 }
509
510 return false;
511 }
512
513 void
new_masters_created()514 Mixer_UI::new_masters_created ()
515 {
516 ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane")->set_active (true);
517 }
518
519 void
add_masters(VCAList & vlist)520 Mixer_UI::add_masters (VCAList& vlist)
521 {
522 StripableList sl;
523
524 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
525 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
526 }
527
528 add_stripables (sl);
529 }
530
531 void
add_routes(RouteList & rlist)532 Mixer_UI::add_routes (RouteList& rlist)
533 {
534 StripableList sl;
535
536 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
537 sl.push_back (*r);
538 }
539
540 add_stripables (sl);
541 }
542
543 void
add_stripables(StripableList & slist)544 Mixer_UI::add_stripables (StripableList& slist)
545 {
546 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
547 bool from_scratch = (track_model->children().size() == 0);
548 uint32_t nroutes = 0;
549
550 slist.sort (Stripable::Sorter());
551
552 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
553 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
554
555 if (!s) {
556 continue;
557 }
558
559 nroutes++;
560
561 // XXX what does this special case do?
562 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
563 insert_iter = it;
564 break;
565 }
566 }
567
568 MixerStrip* strip;
569
570 try {
571 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
572
573 track_display.set_model (Glib::RefPtr<ListStore>());
574
575 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
576
577 boost::shared_ptr<Route> route;
578 boost::shared_ptr<VCA> vca;
579
580 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
581
582 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
583
584 TreeModel::Row row = *(track_model->append());
585
586 row[stripable_columns.text] = vca->name();
587 row[stripable_columns.visible] = vms->marked_for_display ();
588 row[stripable_columns.strip] = vms;
589 row[stripable_columns.stripable] = vca;
590
591 vms->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::vca_button_release_event), vms));
592
593 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
594
595 if (route->is_auditioner()) {
596 continue;
597 }
598
599 if (route->is_monitor()) {
600
601 out_packer.pack_end (_monitor_section.tearoff(), false, false);
602 _monitor_section.set_session (_session);
603 _monitor_section.tearoff().show_all ();
604
605 _monitor_section.tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
606 _monitor_section.tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
607
608 if (_monitor_section.tearoff().torn_off()) {
609 monitor_section_detached ();
610 } else {
611 monitor_section_attached ();
612 }
613
614 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
615
616 /* no regular strip shown for control out */
617
618 continue;
619 }
620 if (route->is_foldbackbus ()) {
621 if (foldback_strip) {
622 // last strip created is shown
623 foldback_strip->set_route (route);
624 } else {
625 foldback_strip = new FoldbackStrip (*this, _session, route);
626 out_packer.pack_start (*foldback_strip, false, false);
627 // change 0 to 1 below for foldback to right of master
628 out_packer.reorder_child (*foldback_strip, 0);
629 }
630 /* config from last run is set before there are any foldback strips
631 * this takes that setting and applies it after at least one foldback
632 * strip exists */
633 bool yn = _show_foldback_strip;
634 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
635 act->set_sensitive (true);
636 act->set_active(!yn);
637 act->set_active(yn);
638 continue;
639 }
640
641 strip = new MixerStrip (*this, _session, route);
642 strips.push_back (strip);
643
644 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
645
646 if (strip->width_owner() != strip) {
647 strip->set_width_enum (_strip_width, this);
648 }
649
650 show_strip (strip);
651
652 if (route->is_master()) {
653
654 out_packer.pack_start (*strip, false, false);
655 strip->set_packed (true);
656
657 } else {
658
659 TreeModel::Row row = *(track_model->insert (insert_iter));
660
661 row[stripable_columns.text] = route->name();
662 row[stripable_columns.visible] = strip->marked_for_display();
663 row[stripable_columns.stripable] = route;
664 row[stripable_columns.strip] = strip;
665 }
666
667 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
668 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
669 }
670
671 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
672 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
673 }
674
675 } catch (const std::exception& e) {
676 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
677 }
678
679 track_display.set_model (track_model);
680
681 /* catch up on selection state, which we left to the editor to set */
682 sync_treeview_from_presentation_info (PropertyChange (Properties::selected));
683
684 if (!from_scratch) {
685 sync_presentation_info_from_treeview ();
686 }
687
688 redisplay_track_list ();
689 }
690
691 void
deselect_all_strip_processors()692 Mixer_UI::deselect_all_strip_processors ()
693 {
694 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
695 (*i)->deselect_all_processors();
696 }
697 if (foldback_strip) {
698 foldback_strip->deselect_all_processors ();
699 }
700 }
701
702 void
select_none()703 Mixer_UI::select_none ()
704 {
705 _selection.clear_routes();
706 deselect_all_strip_processors();
707 }
708
709 void
select_next_strip()710 Mixer_UI::select_next_strip ()
711 {
712 deselect_all_strip_processors();
713 _session->selection().select_next_stripable (true, false);
714 }
715
716 void
select_prev_strip()717 Mixer_UI::select_prev_strip ()
718 {
719 deselect_all_strip_processors();
720 _session->selection().select_prev_stripable (true, false);
721 }
722
723 void
delete_processors()724 Mixer_UI::delete_processors ()
725 {
726 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
727 (*i)->delete_processors();
728 }
729 }
730
731
732 void
remove_strip(MixerStrip * strip)733 Mixer_UI::remove_strip (MixerStrip* strip)
734 {
735 if (_session && _session->deletion_in_progress()) {
736 /* its all being taken care of */
737 return;
738 }
739
740 TreeModel::Children rows = track_model->children();
741 TreeModel::Children::iterator ri;
742 list<MixerStrip *>::iterator i;
743
744 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
745 strips.erase (i);
746 }
747
748 PBD::Unwinder<bool> uwi (ignore_track_reorder, true);
749
750 for (ri = rows.begin(); ri != rows.end(); ++ri) {
751 if ((*ri)[stripable_columns.strip] == strip) {
752 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
753 track_model->erase (ri);
754 break;
755 }
756 }
757 }
758
759 void
remove_foldback(FoldbackStrip * strip)760 Mixer_UI::remove_foldback (FoldbackStrip* strip)
761 {
762 if (_session && _session->deletion_in_progress()) {
763 /* its all being taken care of */
764 return;
765 }
766 assert (strip == foldback_strip);
767 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
768 act->set_sensitive (false);
769 foldback_strip = 0;
770 }
771
772 void
presentation_info_changed(PropertyChange const & what_changed)773 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
774 {
775 if (what_changed.contains (Properties::selected)) {
776 _selection.presentation_info_changed (what_changed);
777 }
778
779 PropertyChange soh;
780 soh.add (Properties::selected);
781 soh.add (Properties::order);
782 soh.add (Properties::hidden);
783
784 if (what_changed.contains (soh)) {
785 sync_treeview_from_presentation_info (what_changed);
786 }
787 }
788
789 void
sync_presentation_info_from_treeview()790 Mixer_UI::sync_presentation_info_from_treeview ()
791 {
792 if (ignore_track_reorder || !_session || _session->deletion_in_progress()) {
793 return;
794 }
795
796 TreeModel::Children rows = track_model->children();
797
798 if (rows.empty()) {
799 return;
800 }
801
802 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
803
804 TreeModel::Children::iterator ri;
805 bool change = false;
806
807 PresentationInfo::order_t master_key = _session->master_order_key ();
808 PresentationInfo::order_t order = 0;
809
810 PresentationInfo::ChangeSuspender cs;
811
812 for (ri = rows.begin(); ri != rows.end(); ++ri) {
813 bool visible = (*ri)[stripable_columns.visible];
814 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
815
816 #ifndef NDEBUG // these should not exist in the mixer's treeview
817 if (!stripable) {
818 assert (0);
819 continue;
820 }
821 if (stripable->is_monitor() || stripable->is_auditioner()) {
822 assert (0);
823 continue;
824 }
825 if (stripable->is_master()) {
826 assert (0);
827 continue;
828 }
829 #endif
830
831 stripable->presentation_info().set_hidden (!visible);
832
833 // leave master where it is.
834 if (order == master_key) {
835 ++order;
836 }
837
838 if (order != stripable->presentation_info().order()) {
839 stripable->set_presentation_order (order);
840 change = true;
841 }
842 ++order;
843 }
844
845 change |= _session->ensure_stripable_sort_order ();
846
847 if (change) {
848 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
849 _session->set_dirty();
850 }
851 }
852
853 void
sync_treeview_from_presentation_info(PropertyChange const & what_changed)854 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
855 {
856 if (!_session || _session->deletion_in_progress()) {
857 return;
858 }
859
860 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
861
862 /* we could get here after either a change in the Mixer or Editor sort
863 * order, but either way, the mixer order keys reflect the intended
864 * order for the GUI, so reorder the treeview model to match it.
865 */
866
867 vector<int> neworder;
868 TreeModel::Children rows = track_model->children();
869 uint32_t old_order = 0;
870 bool changed = false;
871
872 if (rows.empty()) {
873 return;
874 }
875
876 TreeOrderKeys sorted;
877 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
878 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
879 sorted.push_back (TreeOrderKey (old_order, stripable));
880 }
881
882 TreeOrderKeySorter cmp;
883
884 sort (sorted.begin(), sorted.end(), cmp);
885 neworder.assign (sorted.size(), 0);
886
887 uint32_t n = 0;
888
889 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
890
891 neworder[n] = sr->old_display_order;
892
893 if (sr->old_display_order != n) {
894 changed = true;
895 }
896 }
897
898 if (changed) {
899 Unwinder<bool> uw (ignore_track_reorder, true);
900 track_model->reorder (neworder);
901 }
902
903 if (what_changed.contains (Properties::selected)) {
904
905 PresentationInfo::ChangeSuspender cs;
906
907 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
908 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
909 if (stripable && stripable->is_selected()) {
910 _selection.add (*i);
911 } else {
912 _selection.remove (*i);
913 }
914 }
915
916 if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) {
917 move_stripable_into_view ((*_selection.axes.begin())->stripable());
918 }
919
920 TreeModel::Children rows = track_model->children();
921 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
922 AxisView* av = (*i)[stripable_columns.strip];
923 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
924 if (!vms) {
925 continue;
926 }
927 if (vms->vca() && vms->vca()->is_selected()) {
928 _selection.add (vms);
929 } else {
930 _selection.remove (vms);
931 }
932 }
933 }
934
935 redisplay_track_list ();
936 }
937
938 void
fan_out(boost::weak_ptr<Route> wr,bool to_busses,bool group)939 Mixer_UI::fan_out (boost::weak_ptr<Route> wr, bool to_busses, bool group)
940 {
941 boost::shared_ptr<ARDOUR::Route> route = wr.lock ();
942
943 if (!ARDOUR_UI_UTILS::engine_is_running () || ! route) {
944 return;
945 }
946
947 DisplaySuspender ds;
948 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (route->the_instrument ());
949 assert (pi);
950
951 const uint32_t n_outputs = pi->output_streams ().n_audio ();
952 if (route->n_outputs ().n_audio () != n_outputs) {
953 MessageDialog msg (string_compose (
954 _("The Plugin's number of audio outputs ports (%1) does not match the Tracks's number of audio outputs (%2). Cannot fan out."),
955 n_outputs, route->n_outputs ().n_audio ()));
956 msg.run ();
957 return;
958 }
959
960 #define BUSNAME pd.group_name + "(" + route->name () + ")"
961
962 /* count busses and channels/bus */
963 boost::shared_ptr<Plugin> plugin = pi->plugin ();
964 std::map<std::string, uint32_t> busnames;
965 for (uint32_t p = 0; p < n_outputs; ++p) {
966 const Plugin::IOPortDescription& pd (plugin->describe_io_port (DataType::AUDIO, false, p));
967 std::string bn = BUSNAME;
968 busnames[bn]++;
969 }
970
971 if (busnames.size () < 2) {
972 MessageDialog msg (_("Instrument has only 1 output bus. Nothing to fan out."));
973 msg.run ();
974 return;
975 }
976
977 uint32_t outputs = 2;
978 if (_session->master_out ()) {
979 outputs = std::max (outputs, _session->master_out ()->n_inputs ().n_audio ());
980 }
981
982 route->output ()->disconnect (this);
983 route->panner_shell ()->set_bypassed (true);
984
985 boost::shared_ptr<AutomationControl> msac = route->master_send_enable_controllable ();
986 if (msac) {
987 msac->start_touch (msac->session().transport_sample());
988 msac->set_value (0, PBD::Controllable::NoGroup);
989 }
990
991 RouteList to_group;
992 for (uint32_t p = 0; p < n_outputs; ++p) {
993 const Plugin::IOPortDescription& pd (plugin->describe_io_port (DataType::AUDIO, false, p));
994 std::string bn = BUSNAME;
995 boost::shared_ptr<Route> r = _session->route_by_name (bn);
996 if (!r) {
997 try {
998 if (to_busses) {
999 RouteList rl = _session->new_audio_route (busnames[bn], outputs, NULL, 1, bn, PresentationInfo::AudioBus, PresentationInfo::max_order);
1000 r = rl.front ();
1001 assert (r);
1002 } else {
1003 list<boost::shared_ptr<AudioTrack> > tl = _session->new_audio_track (busnames[bn], outputs, NULL, 1, bn, PresentationInfo::max_order, Normal, false);
1004 r = tl.front ();
1005 assert (r);
1006
1007 boost::shared_ptr<ControlList> cl (new ControlList);
1008 cl->push_back (r->monitoring_control ());
1009 _session->set_controls (cl, (double) MonitorInput, Controllable::NoGroup);
1010 }
1011 } catch (...) {
1012 if (!to_group.empty()) {
1013 boost::shared_ptr<RouteList> rl (&to_group);
1014 _session->remove_routes (rl);
1015 }
1016 return;
1017 }
1018 }
1019 to_group.push_back (r);
1020 route->output ()->audio (p)->connect (r->input ()->audio (pd.group_channel).get());
1021 }
1022 #undef BUSNAME
1023
1024 if (group) {
1025 RouteGroup* rg = NULL;
1026 const std::list<RouteGroup*>& rgs (_session->route_groups ());
1027 for (std::list<RouteGroup*>::const_iterator i = rgs.begin (); i != rgs.end (); ++i) {
1028 if ((*i)->name () == pi->name ()) {
1029 rg = *i;
1030 break;
1031 }
1032 }
1033 if (!rg) {
1034 rg = new RouteGroup (*_session, pi->name ());
1035 _session->add_route_group (rg);
1036 rg->set_gain (false);
1037 }
1038
1039 GroupTabs::set_group_color (rg, route->presentation_info().color());
1040 for (RouteList::const_iterator i = to_group.begin(); i != to_group.end(); ++i) {
1041 rg->add (*i);
1042 }
1043 }
1044 }
1045
1046 MixerStrip*
strip_by_route(boost::shared_ptr<Route> r) const1047 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
1048 {
1049 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1050 if ((*i)->route() == r) {
1051 return (*i);
1052 }
1053 }
1054
1055 return 0;
1056 }
1057
1058 MixerStrip*
strip_by_stripable(boost::shared_ptr<Stripable> s) const1059 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
1060 {
1061 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1062 if ((*i)->stripable() == s) {
1063 return (*i);
1064 }
1065 }
1066
1067 return 0;
1068 }
1069
1070 AxisView*
axis_view_by_stripable(boost::shared_ptr<Stripable> s) const1071 Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
1072 {
1073 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1074 if ((*i)->stripable() == s) {
1075 return (*i);
1076 }
1077 }
1078
1079 TreeModel::Children rows = track_model->children();
1080 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1081 AxisView* av = (*i)[stripable_columns.strip];
1082 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1083 if (vms && vms->stripable () == s) {
1084 return av;
1085 }
1086 }
1087
1088 return 0;
1089 }
1090
1091 AxisView*
axis_view_by_control(boost::shared_ptr<AutomationControl> c) const1092 Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
1093 {
1094 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1095 if ((*i)->control() == c) {
1096 return (*i);
1097 }
1098 }
1099
1100 return 0;
1101 }
1102
1103 bool
strip_button_release_event(GdkEventButton * ev,MixerStrip * strip)1104 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
1105 {
1106 /* Selecting a mixer-strip may also select grouped-tracks, and
1107 * presentation_info_changed() being emitted and
1108 * _selection.axes.begin() is being moved into view. This may
1109 * effectively move the track that was clicked-on out of view.
1110 *
1111 * So here only the track that is actually clicked-on is moved into
1112 * view (in case it's partially visible)
1113 */
1114 PBD::Unwinder<bool> uw (_strip_selection_change_without_scroll, true);
1115 move_stripable_into_view (strip->stripable());
1116
1117 if (ev->button == 1) {
1118 if (_selection.selected (strip)) {
1119 /* primary-click: toggle selection state of strip */
1120 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1121 _selection.remove (strip, true);
1122 } else if (_selection.axes.size() > 1) {
1123 /* de-select others */
1124 _selection.set (strip);
1125 }
1126 PublicEditor& pe = PublicEditor::instance();
1127 TimeAxisView* tav = pe.time_axis_view_from_stripable (strip->stripable());
1128 if (tav) {
1129 pe.set_selected_mixer_strip (*tav);
1130 }
1131 } else {
1132 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1133 _selection.add (strip, true);
1134 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
1135
1136 /* extend selection */
1137
1138 vector<MixerStrip*> tmp;
1139 bool accumulate = false;
1140 bool found_another = false;
1141
1142 strips.sort (MixerStripSorter());
1143
1144 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1145 MixerStrip* ms = *i;
1146 assert (ms);
1147
1148 if (ms == strip) {
1149 /* hit clicked strip, start accumulating till we hit the first
1150 selected strip
1151 */
1152 if (accumulate) {
1153 /* done */
1154 break;
1155 } else {
1156 accumulate = true;
1157 }
1158 } else if (_selection.selected (ms)) {
1159 /* hit selected strip. if currently accumulating others,
1160 we're done. if not accumulating others, start doing so.
1161 */
1162 found_another = true;
1163 if (accumulate) {
1164 /* done */
1165 break;
1166 } else {
1167 accumulate = true;
1168 }
1169 } else {
1170 if (accumulate) {
1171 tmp.push_back (ms);
1172 }
1173 }
1174 }
1175
1176 tmp.push_back (strip);
1177
1178 if (found_another) {
1179 PresentationInfo::ChangeSuspender cs;
1180 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
1181 _selection.add (*i, true);
1182 }
1183 } else {
1184 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
1185 }
1186 } else {
1187 _selection.set (strip);
1188 }
1189 }
1190 }
1191
1192 return true;
1193 }
1194
1195 bool
vca_button_release_event(GdkEventButton * ev,VCAMasterStrip * strip)1196 Mixer_UI::vca_button_release_event (GdkEventButton *ev, VCAMasterStrip *strip)
1197 {
1198 _selection.set (strip);
1199 return true;
1200 }
1201
1202 void
set_session(Session * sess)1203 Mixer_UI::set_session (Session* sess)
1204 {
1205 SessionHandlePtr::set_session (sess);
1206 _monitor_section.set_session (sess);
1207
1208 if (_plugin_selector) {
1209 _plugin_selector->set_session (_session);
1210 }
1211
1212 _group_tabs->set_session (sess);
1213
1214 if (!_session) {
1215 favorite_plugins_model->clear ();
1216 _selection.clear ();
1217 return;
1218 }
1219
1220 refill_favorite_plugins();
1221
1222 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1223 set_state (*node, 0);
1224
1225 update_title ();
1226
1227 #if 0
1228 /* skip mapping all session-config vars, we only need one */
1229 boost::function<void (string)> pc (boost::bind (&Mixer_UI::parameter_changed, this, _1));
1230 _session->config.map_parameters (pc);
1231 #else
1232 parameter_changed ("show-group-tabs");
1233 #endif
1234
1235 initial_track_display ();
1236
1237 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1238 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1239 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1240 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1241 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1242 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1243 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1244
1245 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1246 _session->vca_manager().VCACreated.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::new_masters_created, this), gui_context());
1247
1248 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1249
1250 route_groups_changed ();
1251
1252 if (_visible) {
1253 show_window();
1254 }
1255
1256 /* catch up on selection state, etc. */
1257
1258 PropertyChange sc;
1259 sc.add (Properties::selected);
1260 _selection.presentation_info_changed (sc);
1261
1262 start_updating ();
1263 }
1264
1265 void
session_going_away()1266 Mixer_UI::session_going_away ()
1267 {
1268 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1269
1270 _in_group_rebuild_or_clear = true;
1271 group_model->clear ();
1272 _in_group_rebuild_or_clear = false;
1273
1274 _selection.clear ();
1275 track_model->clear ();
1276
1277 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1278 delete (*i);
1279 }
1280
1281 _monitor_section.tearoff().hide_visible ();
1282 StripableList fb;
1283 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1284 if (fb.size()) {
1285 if (foldback_strip) {
1286 delete foldback_strip;
1287 foldback_strip = 0;
1288 }
1289 }
1290
1291 monitor_section_detached ();
1292
1293 strips.clear ();
1294
1295 stop_updating ();
1296
1297 SessionHandlePtr::session_going_away ();
1298
1299 _session = 0;
1300 update_title ();
1301 }
1302
1303 void
track_visibility_changed(std::string const & path)1304 Mixer_UI::track_visibility_changed (std::string const & path)
1305 {
1306 if (_session && _session->deletion_in_progress()) {
1307 return;
1308 }
1309
1310 TreeIter iter;
1311
1312 if ((iter = track_model->get_iter (path))) {
1313
1314 AxisView* av = (*iter)[stripable_columns.strip];
1315 bool visible = (*iter)[stripable_columns.visible];
1316
1317 if (av->set_marked_for_display (!visible)) {
1318 update_track_visibility ();
1319 }
1320 }
1321 }
1322
1323 void
update_track_visibility()1324 Mixer_UI::update_track_visibility ()
1325 {
1326 TreeModel::Children rows = track_model->children();
1327 TreeModel::Children::iterator i;
1328
1329 {
1330 Unwinder<bool> uw (no_track_list_redisplay, true);
1331
1332 for (i = rows.begin(); i != rows.end(); ++i) {
1333 AxisView* av = (*i)[stripable_columns.strip];
1334 (*i)[stripable_columns.visible] = av->marked_for_display ();
1335 }
1336
1337 /* force presentation to catch up with visibility changes */
1338 sync_presentation_info_from_treeview ();
1339 }
1340
1341 redisplay_track_list ();
1342 }
1343
1344 void
show_strip(MixerStrip * ms)1345 Mixer_UI::show_strip (MixerStrip* ms)
1346 {
1347 TreeModel::Children rows = track_model->children();
1348 TreeModel::Children::iterator i;
1349
1350 for (i = rows.begin(); i != rows.end(); ++i) {
1351
1352 AxisView* av = (*i)[stripable_columns.strip];
1353 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1354 if (strip == ms) {
1355 (*i)[stripable_columns.visible] = true;
1356 av->set_marked_for_display (true);
1357 update_track_visibility ();
1358 break;
1359 }
1360 }
1361 }
1362
1363 void
hide_strip(MixerStrip * ms)1364 Mixer_UI::hide_strip (MixerStrip* ms)
1365 {
1366 TreeModel::Children rows = track_model->children();
1367 TreeModel::Children::iterator i;
1368
1369 for (i = rows.begin(); i != rows.end(); ++i) {
1370
1371 AxisView* av = (*i)[stripable_columns.strip];
1372 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1373 if (strip == ms) {
1374 (*i)[stripable_columns.visible] = false;
1375 av->set_marked_for_display (false);
1376 update_track_visibility ();
1377 break;
1378 }
1379 }
1380 }
1381
1382 gint
start_updating()1383 Mixer_UI::start_updating ()
1384 {
1385 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1386 return 0;
1387 }
1388
1389 gint
stop_updating()1390 Mixer_UI::stop_updating ()
1391 {
1392 fast_screen_update_connection.disconnect();
1393 return 0;
1394 }
1395
1396 void
fast_update_strips()1397 Mixer_UI::fast_update_strips ()
1398 {
1399 if (_content.is_mapped () && _session) {
1400 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1401 (*i)->fast_update ();
1402 }
1403 if (foldback_strip) {
1404 foldback_strip->fast_update ();
1405 }
1406 }
1407 }
1408
1409 void
set_all_strips_visibility(bool yn)1410 Mixer_UI::set_all_strips_visibility (bool yn)
1411 {
1412 TreeModel::Children rows = track_model->children();
1413 TreeModel::Children::iterator i;
1414
1415 {
1416 Unwinder<bool> uw (no_track_list_redisplay, true);
1417
1418 for (i = rows.begin(); i != rows.end(); ++i) {
1419
1420 AxisView* av = (*i)[stripable_columns.strip];
1421 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1422
1423 if (!strip) {
1424 continue;
1425 }
1426
1427 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1428 continue;
1429 }
1430
1431 (*i)[stripable_columns.visible] = yn;
1432 }
1433
1434 /* force presentation to catch up with visibility changes */
1435 sync_presentation_info_from_treeview ();
1436 }
1437
1438 redisplay_track_list ();
1439 }
1440
1441 void
set_all_audio_midi_visibility(int tracks,bool yn)1442 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1443 {
1444 TreeModel::Children rows = track_model->children();
1445 TreeModel::Children::iterator i;
1446
1447 {
1448 Unwinder<bool> uw (no_track_list_redisplay, true);
1449
1450 for (i = rows.begin(); i != rows.end(); ++i) {
1451
1452 AxisView* av = (*i)[stripable_columns.strip];
1453 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1454
1455 if (!strip) {
1456 continue;
1457 }
1458
1459 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1460 continue;
1461 }
1462
1463 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1464 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1465
1466 switch (tracks) {
1467 case 0:
1468 (*i)[stripable_columns.visible] = yn;
1469 break;
1470
1471 case 1:
1472 if (at) { /* track */
1473 (*i)[stripable_columns.visible] = yn;
1474 }
1475 break;
1476
1477 case 2:
1478 if (!at && !mt) { /* bus */
1479 (*i)[stripable_columns.visible] = yn;
1480 }
1481 break;
1482
1483 case 3:
1484 if (mt) { /* midi-track */
1485 (*i)[stripable_columns.visible] = yn;
1486 }
1487 break;
1488 }
1489 }
1490
1491 /* force presentation to catch up with visibility changes */
1492 sync_presentation_info_from_treeview ();
1493 }
1494
1495 redisplay_track_list ();
1496 }
1497
1498 void
hide_all_routes()1499 Mixer_UI::hide_all_routes ()
1500 {
1501 set_all_strips_visibility (false);
1502 }
1503
1504 void
show_all_routes()1505 Mixer_UI::show_all_routes ()
1506 {
1507 set_all_strips_visibility (true);
1508 }
1509
1510 void
show_all_audiobus()1511 Mixer_UI::show_all_audiobus ()
1512 {
1513 set_all_audio_midi_visibility (2, true);
1514 }
1515 void
hide_all_audiobus()1516 Mixer_UI::hide_all_audiobus ()
1517 {
1518 set_all_audio_midi_visibility (2, false);
1519 }
1520
1521 void
show_all_audiotracks()1522 Mixer_UI::show_all_audiotracks()
1523 {
1524 set_all_audio_midi_visibility (1, true);
1525 }
1526 void
hide_all_audiotracks()1527 Mixer_UI::hide_all_audiotracks ()
1528 {
1529 set_all_audio_midi_visibility (1, false);
1530 }
1531
1532 void
show_all_miditracks()1533 Mixer_UI::show_all_miditracks()
1534 {
1535 set_all_audio_midi_visibility (3, true);
1536 }
1537 void
hide_all_miditracks()1538 Mixer_UI::hide_all_miditracks ()
1539 {
1540 set_all_audio_midi_visibility (3, false);
1541 }
1542
1543 void
track_list_reorder(const TreeModel::Path &,const TreeModel::iterator &,int *)1544 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1545 {
1546 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1547 sync_presentation_info_from_treeview ();
1548 }
1549
1550 void
track_list_delete(const Gtk::TreeModel::Path &)1551 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1552 {
1553 /* this happens as the second step of a DnD within the treeview as well
1554 as when a row/route is actually deleted.
1555
1556 if it was a deletion then we have to force a redisplay because
1557 order keys may not have changed.
1558 */
1559
1560 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1561 sync_presentation_info_from_treeview ();
1562
1563 if (_route_deletion_in_progress) {
1564 redisplay_track_list ();
1565 }
1566 }
1567
1568 void
spill_redisplay(boost::shared_ptr<Stripable> s)1569 Mixer_UI::spill_redisplay (boost::shared_ptr<Stripable> s)
1570 {
1571
1572 boost::shared_ptr<VCA> vca = boost::dynamic_pointer_cast<VCA> (s);
1573 boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
1574
1575 TreeModel::Children rows = track_model->children();
1576 std::list<boost::shared_ptr<VCA> > vcas;
1577
1578 if (vca) {
1579 vcas.push_back (vca);
1580
1581 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1582 AxisView* av = (*i)[stripable_columns.strip];
1583 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1584 if (vms && vms->vca()->slaved_to (vca)) {
1585 vcas.push_back (vms->vca());
1586 }
1587 }
1588 }
1589
1590 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1591
1592 AxisView* av = (*i)[stripable_columns.strip];
1593 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1594 bool const visible = (*i)[stripable_columns.visible];
1595 bool slaved = false;
1596 bool feeds = false;
1597
1598 if (!strip) {
1599 /* we're in the middle of changing a row, don't worry */
1600 continue;
1601 }
1602
1603 if (!strip->route()) {
1604 /* non-route element */
1605 continue;
1606 }
1607
1608 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1609 continue;
1610 }
1611
1612 if (vca) {
1613 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1614 if (strip->route()->slaved_to (*m)) {
1615 slaved = true;
1616 break;
1617 }
1618 }
1619 }
1620
1621 #ifdef MIXBUS
1622 if (r && r->mixbus()) {
1623 feeds = strip->route()->mb_feeds (r);
1624 } else
1625 #endif
1626 if (r) {
1627 feeds = strip->route()->direct_feeds_according_to_graph (r);
1628 }
1629
1630 bool should_show = visible && (slaved || feeds);
1631 should_show |= (strip->route() == r); //the spilled aux should itself be shown...
1632
1633 if (should_show) {
1634
1635 if (strip->packed()) {
1636 strip_packer.reorder_child (*strip, -1); /* put at end */
1637 } else {
1638 strip_packer.pack_start (*strip, false, false);
1639 strip->set_packed (true);
1640 }
1641
1642 } else {
1643
1644 if (strip->packed()) {
1645 strip_packer.remove (*strip);
1646 strip->set_packed (false);
1647 }
1648 }
1649 }
1650 }
1651
1652 void
redisplay_track_list()1653 Mixer_UI::redisplay_track_list ()
1654 {
1655 if (no_track_list_redisplay) {
1656 return;
1657 }
1658
1659 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1660 if (ss) {
1661 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1662 if (sv) {
1663 if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) {
1664 _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value();
1665 }
1666 spill_redisplay (sv);
1667 return;
1668 } else {
1669 if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) {
1670 _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value();
1671 }
1672 spill_redisplay (ss);
1673 return;
1674 }
1675 }
1676
1677 TreeModel::Children rows = track_model->children();
1678 TreeModel::Children::iterator i;
1679 uint32_t n_masters = 0;
1680
1681 container_clear (vca_hpacker);
1682
1683 vca_hpacker.pack_end (vca_scroller_base, true, true);
1684 vca_scroller_base.set_size_request (PX_SCALE (20), -1);
1685 vca_scroller_base.signal_expose_event().connect (sigc::bind (sigc::ptr_fun(&ArdourWidgets::ArdourIcon::expose), &vca_scroller_base, ArdourWidgets::ArdourIcon::ShadedPlusSign));
1686 vca_scroller_base.show();
1687
1688 for (i = rows.begin(); i != rows.end(); ++i) {
1689
1690 AxisView* s = (*i)[stripable_columns.strip];
1691 bool const visible = (*i)[stripable_columns.visible];
1692 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1693
1694 if (!s) {
1695 /* we're in the middle of changing a row, don't worry */
1696 continue;
1697 }
1698
1699 VCAMasterStrip* vms;
1700
1701 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1702 if (visible) {
1703 vca_hpacker.pack_start (*vms, false, false);
1704 vms->show ();
1705 n_masters++;
1706 }
1707 continue;
1708 }
1709
1710 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1711
1712 if (!strip) {
1713 continue;
1714 }
1715
1716 if (visible) {
1717
1718 if (strip->packed()) {
1719 strip_packer.reorder_child (*strip, -1); /* put at end */
1720 } else {
1721 strip_packer.pack_start (*strip, false, false);
1722 strip->set_packed (true);
1723 }
1724
1725 } else {
1726
1727 if (stripable->is_master() || stripable->is_monitor()) {
1728 /* do nothing, these cannot be hidden */
1729 } else {
1730 if (strip->packed()) {
1731 strip_packer.remove (*strip);
1732 strip->set_packed (false);
1733 }
1734 }
1735 }
1736 }
1737
1738 /* update visibility of VCA assign buttons */
1739
1740 if (n_masters == 0) {
1741 //show/hide the channelstrip VCA assign buttons on channelstrips:
1742 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1743
1744 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleVCAPane");
1745 if (act) {
1746 act->set_sensitive (false);
1747 }
1748
1749 //remove the VCA packer, but don't change our prior setting for show/hide:
1750 vca_vpacker.hide ();
1751 } else {
1752 //show/hide the channelstrip VCA assign buttons on channelstrips:
1753 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1754
1755 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
1756 act->set_sensitive (true);
1757
1758 //if we were showing VCAs before, show them now:
1759 showhide_vcas (act->get_active ());
1760 }
1761
1762 _group_tabs->set_dirty ();
1763
1764 if (_spill_scroll_position > 0 && scroller.get_hscrollbar()) {
1765 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1766 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), _spill_scroll_position)));
1767 }
1768 _spill_scroll_position = 0;
1769
1770 }
1771
1772 void
strip_width_changed()1773 Mixer_UI::strip_width_changed ()
1774 {
1775 _group_tabs->set_dirty ();
1776
1777 #ifdef __APPLE__
1778 TreeModel::Children rows = track_model->children();
1779 TreeModel::Children::iterator i;
1780 long order;
1781
1782 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1783 AxisView* av = (*i)[stripable_columns.strip];
1784 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1785
1786 if (strip == 0) {
1787 continue;
1788 }
1789
1790 bool visible = (*i)[stripable_columns.visible];
1791
1792 if (visible) {
1793 strip->queue_draw();
1794 }
1795 }
1796 #endif
1797
1798 }
1799
1800 struct PresentationInfoMixerSorter
1801 {
operator ()PresentationInfoMixerSorter1802 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1803 if (a->is_master()) {
1804 /* master after everything else */
1805 return false;
1806 } else if (b->is_master()) {
1807 /* everything else before master */
1808 return true;
1809 }
1810 return a->presentation_info().order () < b->presentation_info().order ();
1811 }
1812 };
1813
1814 void
initial_track_display()1815 Mixer_UI::initial_track_display ()
1816 {
1817 StripableList sl;
1818 StripableList fb;
1819 _session->get_stripables (sl);
1820 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1821 if (fb.size()) {
1822 boost::shared_ptr<ARDOUR::Stripable> _current_foldback = *(fb.begin());
1823 sl.push_back (_current_foldback);
1824 }
1825
1826 sl.sort (PresentationInfoMixerSorter());
1827
1828 {
1829 /* These are also used inside ::add_stripables() but we need
1830 * them here because we're going to clear the track_model also.
1831 */
1832 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1833 Unwinder<bool> uw2 (ignore_track_reorder, true);
1834
1835 track_model->clear ();
1836 add_stripables (sl);
1837 }
1838
1839 sync_treeview_from_presentation_info (Properties::order);
1840 }
1841
1842 bool
track_display_button_press(GdkEventButton * ev)1843 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1844 {
1845 if (Keyboard::is_context_menu_event (ev)) {
1846 if (track_menu == 0) {
1847 build_track_menu ();
1848 }
1849 track_menu->popup (ev->button, ev->time);
1850 return true;
1851 }
1852 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1853 TreeModel::Path path;
1854 TreeViewColumn* column;
1855 int cellx, celly;
1856 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1857 TreeIter iter = track_model->get_iter (path);
1858 if ((*iter)[stripable_columns.visible]) {
1859 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1860 move_stripable_into_view (s);
1861 }
1862 }
1863 }
1864
1865 return false;
1866 }
1867
1868 void
move_vca_into_view(boost::shared_ptr<ARDOUR::Stripable> s)1869 Mixer_UI::move_vca_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1870 {
1871 if (!vca_scroller.get_hscrollbar()) {
1872 return;
1873 }
1874
1875 bool found = false;
1876 int x0 = 0;
1877 Gtk::Allocation alloc;
1878
1879 TreeModel::Children rows = track_model->children();
1880 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1881 AxisView* av = (*i)[stripable_columns.strip];
1882 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1883 if (vms && vms->stripable () == s) {
1884 int y;
1885 found = true;
1886 vms->translate_coordinates (vca_hpacker, 0, 0, x0, y);
1887 alloc = vms->get_allocation ();
1888 break;
1889 }
1890 }
1891
1892 if (!found) {
1893 return;
1894 }
1895
1896 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
1897
1898 if (x0 < adj->get_value()) {
1899 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1900 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1901 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1902 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1903 }
1904 }
1905
1906 void
move_stripable_into_view(boost::shared_ptr<ARDOUR::Stripable> s)1907 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1908 {
1909 if (!scroller.get_hscrollbar()) {
1910 return;
1911 }
1912 if (s->presentation_info().special ()) {
1913 return;
1914 }
1915 if (s->presentation_info().flag_match (PresentationInfo::VCA)) {
1916 move_vca_into_view (s);
1917 }
1918 #ifdef MIXBUS
1919 if (s->mixbus ()) {
1920 return;
1921 }
1922 #endif
1923 bool found = false;
1924 int x0 = 0;
1925 Gtk::Allocation alloc;
1926 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1927 if ((*i)->route() == s) {
1928 int y;
1929 found = true;
1930 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1931 alloc = (*i)->get_allocation ();
1932 break;
1933 }
1934 }
1935 if (!found) {
1936 return;
1937 }
1938
1939 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1940
1941 if (x0 < adj->get_value()) {
1942 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1943 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1944 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1945 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1946 }
1947 }
1948
1949 void
build_track_menu()1950 Mixer_UI::build_track_menu ()
1951 {
1952 using namespace Menu_Helpers;
1953 using namespace Gtk;
1954
1955 track_menu = new Menu;
1956 track_menu->set_name ("ArdourContextMenu");
1957 MenuList& items = track_menu->items();
1958
1959 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1960 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1961 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1962 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1963 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1964 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1965 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1966 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1967
1968 }
1969
1970 void
stripable_property_changed(const PropertyChange & what_changed,boost::weak_ptr<Stripable> ws)1971 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1972 {
1973 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1974 return;
1975 }
1976
1977 boost::shared_ptr<Stripable> s = ws.lock ();
1978
1979 if (!s) {
1980 return;
1981 }
1982
1983 TreeModel::Children rows = track_model->children();
1984 TreeModel::Children::iterator i;
1985
1986 for (i = rows.begin(); i != rows.end(); ++i) {
1987 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1988
1989 if (s == ss) {
1990
1991 if (what_changed.contains (ARDOUR::Properties::name)) {
1992 (*i)[stripable_columns.text] = s->name();
1993 }
1994
1995 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1996 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1997 redisplay_track_list ();
1998 }
1999
2000 return;
2001 }
2002 }
2003
2004 if (s->is_master ()) {
2005 return;
2006 }
2007
2008 error << _("track display list item for renamed strip not found!") << endmsg;
2009 }
2010
2011 bool
group_display_button_press(GdkEventButton * ev)2012 Mixer_UI::group_display_button_press (GdkEventButton* ev)
2013 {
2014 TreeModel::Path path;
2015 TreeViewColumn* column;
2016 int cellx;
2017 int celly;
2018
2019 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
2020 if (ev->button == 3) {
2021 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
2022 }
2023 return true;
2024 }
2025
2026 TreeIter iter = group_model->get_iter (path);
2027 if (!iter) {
2028 if (ev->button == 3) {
2029 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
2030 }
2031 return true;
2032 }
2033
2034 RouteGroup* group = (*iter)[group_columns.group];
2035
2036 if (Keyboard::is_context_menu_event (ev)) {
2037 _group_tabs->get_menu(group)->popup (1, ev->time);
2038 return true;
2039 }
2040
2041 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
2042 case 1:
2043 if (Keyboard::is_edit_event (ev)) {
2044 if (group) {
2045 // edit_route_group (group);
2046 #ifdef __APPLE__
2047 group_display.queue_draw();
2048 #endif
2049 return true;
2050 }
2051 }
2052 break;
2053
2054 case 0:
2055 {
2056 bool visible = (*iter)[group_columns.visible];
2057 (*iter)[group_columns.visible] = !visible;
2058 #ifdef __APPLE__
2059 group_display.queue_draw();
2060 #endif
2061 return true;
2062 }
2063
2064 default:
2065 break;
2066 }
2067
2068 return false;
2069 }
2070
2071 void
activate_all_route_groups()2072 Mixer_UI::activate_all_route_groups ()
2073 {
2074 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
2075 }
2076
2077 void
disable_all_route_groups()2078 Mixer_UI::disable_all_route_groups ()
2079 {
2080 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
2081 }
2082
2083 void
route_groups_changed()2084 Mixer_UI::route_groups_changed ()
2085 {
2086 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
2087
2088 _in_group_rebuild_or_clear = true;
2089
2090 /* just rebuild the while thing */
2091
2092 group_model->clear ();
2093
2094 #if 0
2095 /* this is currently not used,
2096 * Mixer_UI::group_display_button_press() has a case for it,
2097 * and a commented edit_route_group() but that's n/a since 2011.
2098 *
2099 * This code is left as reminder that
2100 * row[group_columns.group] = 0 has special meaning.
2101 */
2102 {
2103 TreeModel::Row row;
2104 row = *(group_model->append());
2105 row[group_columns.visible] = true;
2106 row[group_columns.text] = (_("-all-"));
2107 row[group_columns.group] = 0;
2108 }
2109 #endif
2110
2111 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
2112
2113 _group_tabs->set_dirty ();
2114 _in_group_rebuild_or_clear = false;
2115 }
2116
2117 void
new_route_group()2118 Mixer_UI::new_route_group ()
2119 {
2120 _group_tabs->run_new_group_dialog (0, false);
2121 }
2122
2123 void
remove_selected_route_group()2124 Mixer_UI::remove_selected_route_group ()
2125 {
2126 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
2127 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
2128
2129 if (rows.empty()) {
2130 return;
2131 }
2132
2133 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
2134 TreeIter iter;
2135
2136 /* selection mode is single, so rows.begin() is it */
2137
2138 if ((iter = group_model->get_iter (*i))) {
2139
2140 RouteGroup* rg = (*iter)[group_columns.group];
2141
2142 if (rg) {
2143 _session->remove_route_group (*rg);
2144 }
2145 }
2146 }
2147
2148 void
route_group_property_changed(RouteGroup * group,const PropertyChange & change)2149 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
2150 {
2151 if (in_group_row_change) {
2152 return;
2153 }
2154
2155 /* force an update of any mixer strips that are using this group,
2156 otherwise mix group names don't change in mixer strips
2157 */
2158
2159 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
2160 if ((*i)->route_group() == group) {
2161 (*i)->route_group_changed();
2162 }
2163 }
2164
2165 TreeModel::iterator i;
2166 TreeModel::Children rows = group_model->children();
2167 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
2168
2169 in_group_row_change = true;
2170
2171 for (i = rows.begin(); i != rows.end(); ++i) {
2172 if ((*i)[group_columns.group] == group) {
2173 (*i)[group_columns.visible] = !group->is_hidden ();
2174 (*i)[group_columns.text] = group->name ();
2175 break;
2176 }
2177 }
2178
2179 in_group_row_change = false;
2180
2181 if (change.contains (Properties::name)) {
2182 _group_tabs->set_dirty ();
2183 }
2184
2185 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
2186 if ((*j)->route_group() == group) {
2187 if (group->is_hidden ()) {
2188 hide_strip (*j);
2189 } else {
2190 show_strip (*j);
2191 }
2192 }
2193 }
2194 }
2195
2196 void
toggle_mixer_list()2197 Mixer_UI::toggle_mixer_list ()
2198 {
2199 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2200 showhide_mixer_list (act->get_active());
2201 }
2202
2203 void
showhide_mixer_list(bool yn)2204 Mixer_UI::showhide_mixer_list (bool yn)
2205 {
2206 if (yn) {
2207 list_vpacker.show ();
2208 } else {
2209 list_vpacker.hide ();
2210 }
2211 }
2212
2213 void
toggle_monitor_section()2214 Mixer_UI::toggle_monitor_section ()
2215 {
2216 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2217 showhide_monitor_section (act->get_active());
2218 }
2219
2220
2221 void
showhide_monitor_section(bool yn)2222 Mixer_UI::showhide_monitor_section (bool yn)
2223 {
2224 if (monitor_section().tearoff().torn_off()) {
2225 return;
2226 }
2227
2228 if (yn) {
2229 monitor_section().tearoff().show();
2230 } else {
2231 monitor_section().tearoff().hide();
2232 }
2233 }
2234
2235 void
toggle_foldback_strip()2236 Mixer_UI::toggle_foldback_strip ()
2237 {
2238 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
2239 showhide_foldback_strip (act->get_active());
2240 }
2241
2242
2243 void
showhide_foldback_strip(bool yn)2244 Mixer_UI::showhide_foldback_strip (bool yn)
2245 {
2246 _show_foldback_strip = yn;
2247
2248 if (foldback_strip) {
2249 if (yn) {
2250 foldback_strip->show();
2251 } else {
2252 foldback_strip->hide();
2253 }
2254 }
2255 }
2256
2257 void
toggle_vcas()2258 Mixer_UI::toggle_vcas ()
2259 {
2260 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2261 showhide_vcas (act->get_active());
2262 }
2263
2264 void
showhide_vcas(bool yn)2265 Mixer_UI::showhide_vcas (bool yn)
2266 {
2267 if (yn) {
2268 vca_vpacker.show();
2269 } else {
2270 vca_vpacker.hide();
2271 }
2272 }
2273
2274 #ifdef MIXBUS
2275 void
toggle_mixbuses()2276 Mixer_UI::toggle_mixbuses ()
2277 {
2278 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2279 showhide_mixbuses (act->get_active());
2280 }
2281
2282 void
showhide_mixbuses(bool on)2283 Mixer_UI::showhide_mixbuses (bool on)
2284 {
2285 if (on) {
2286 mb_vpacker.show();
2287 } else {
2288 mb_vpacker.hide();
2289 }
2290 }
2291 #endif
2292
2293
2294 void
route_group_name_edit(const std::string & path,const std::string & new_text)2295 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
2296 {
2297 RouteGroup* group;
2298 TreeIter iter;
2299
2300 if ((iter = group_model->get_iter (path))) {
2301
2302 if ((group = (*iter)[group_columns.group]) == 0) {
2303 return;
2304 }
2305
2306 if (new_text != group->name()) {
2307 group->set_name (new_text);
2308 }
2309 }
2310 }
2311
2312 void
route_group_row_change(const Gtk::TreeModel::Path &,const Gtk::TreeModel::iterator & iter)2313 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
2314 {
2315 RouteGroup* group;
2316
2317 if (in_group_row_change) {
2318 return;
2319 }
2320
2321 if ((group = (*iter)[group_columns.group]) == 0) {
2322 return;
2323 }
2324
2325 std::string name = (*iter)[group_columns.text];
2326
2327 if (name != group->name()) {
2328 group->set_name (name);
2329 }
2330
2331 bool hidden = !(*iter)[group_columns.visible];
2332
2333 if (hidden != group->is_hidden ()) {
2334 group->set_hidden (hidden, this);
2335 }
2336 }
2337
2338 /** Called when a group model row is deleted, but also when the model is
2339 * reordered by a user drag-and-drop; the latter is what we are
2340 * interested in here.
2341 */
2342 void
route_group_row_deleted(Gtk::TreeModel::Path const &)2343 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
2344 {
2345 if (_in_group_rebuild_or_clear) {
2346 return;
2347 }
2348
2349 /* Re-write the session's route group list so that the new order is preserved */
2350
2351 list<RouteGroup*> new_list;
2352
2353 Gtk::TreeModel::Children children = group_model->children();
2354 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
2355 RouteGroup* g = (*i)[group_columns.group];
2356 if (g) {
2357 new_list.push_back (g);
2358 }
2359 }
2360
2361 _session->reorder_route_groups (new_list);
2362 }
2363
2364
2365 void
add_route_group(RouteGroup * group)2366 Mixer_UI::add_route_group (RouteGroup* group)
2367 {
2368 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
2369 bool focus = false;
2370
2371 in_group_row_change = true;
2372
2373 TreeModel::Row row = *(group_model->append());
2374 row[group_columns.visible] = !group->is_hidden ();
2375 row[group_columns.group] = group;
2376 if (!group->name().empty()) {
2377 row[group_columns.text] = group->name();
2378 } else {
2379 row[group_columns.text] = _("unnamed");
2380 focus = true;
2381 }
2382
2383 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
2384
2385 if (focus) {
2386 TreeViewColumn* col = group_display.get_column (0);
2387 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
2388 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
2389 }
2390
2391 _group_tabs->set_dirty ();
2392
2393 in_group_row_change = false;
2394 }
2395
2396 bool
strip_scroller_button_event(GdkEventButton * ev)2397 Mixer_UI::strip_scroller_button_event (GdkEventButton* ev)
2398 {
2399 if ((ev->type == GDK_2BUTTON_PRESS && ev->button == 1) || (ev->type == GDK_BUTTON_RELEASE && Keyboard::is_context_menu_event (ev))) {
2400 ARDOUR_UI::instance()->add_route ();
2401 return true;
2402 }
2403 return false;
2404 }
2405
2406 void
scroller_drag_data_received(const Glib::RefPtr<Gdk::DragContext> & context,int x,int y,const Gtk::SelectionData & data,guint info,guint time)2407 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
2408 {
2409 if (data.get_target() != "PluginFavoritePtr") {
2410 context->drag_finish (false, false, time);
2411 return;
2412 }
2413
2414 const void * d = data.get_data();
2415 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2416
2417 PluginPresetList nfos;
2418 TreeView* source;
2419 tv->get_object_drag_data (nfos, &source);
2420
2421 Route::ProcessorList pl;
2422 bool ok = false;
2423
2424 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2425 PluginPresetPtr ppp = (*i);
2426 PluginInfoPtr pip = ppp->_pip;
2427 if (!pip->is_instrument ()) {
2428 continue;
2429 }
2430 ARDOUR_UI::instance()->session_add_midi_route (true, (RouteGroup*) 0, 1, _("MIDI"), Config->get_strict_io (), pip, ppp->_preset.valid ? &ppp->_preset : 0, PresentationInfo::max_order);
2431 ok = true;
2432 }
2433
2434 context->drag_finish (ok, false, time);
2435 }
2436
2437 void
set_strip_width(Width w,bool save)2438 Mixer_UI::set_strip_width (Width w, bool save)
2439 {
2440 _strip_width = w;
2441
2442 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2443 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2444 }
2445 }
2446
2447 int
set_state(const XMLNode & node,int version)2448 Mixer_UI::set_state (const XMLNode& node, int version)
2449 {
2450 bool yn;
2451
2452 Tabbable::set_state (node, version);
2453
2454 if (node.get_property ("narrow-strips", yn)) {
2455 if (yn) {
2456 set_strip_width (Narrow);
2457 } else {
2458 set_strip_width (Wide);
2459 }
2460 }
2461
2462 node.get_property ("show-mixer", _visible);
2463
2464 yn = false;
2465 node.get_property ("maximised", yn);
2466 {
2467 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Common"), X_("ToggleMaximalMixer"));
2468 bool fs = act && act->get_active();
2469 if (yn ^ fs) {
2470 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2471 }
2472 }
2473
2474 yn = true;
2475 node.get_property ("show-mixer-list", yn);
2476 {
2477 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixerList"));
2478 /* do it twice to force the change */
2479 act->set_active (!yn);
2480 act->set_active (yn);
2481 }
2482
2483 yn = true;
2484 node.get_property ("monitor-section-visible", yn);
2485 {
2486 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection"));
2487 /* do it twice to force the change */
2488 act->set_active (!yn);
2489 act->set_active (yn);
2490 }
2491
2492 yn = true;
2493 node.get_property ("foldback-strip-visible", yn);
2494 {
2495 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleFoldbackStrip"));
2496 /* do it twice to force the change */
2497 act->set_active (!yn);
2498 act->set_active (yn);
2499 }
2500
2501 yn = true;
2502 node.get_property ("show-vca-pane", yn);
2503 {
2504 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleVCAPane"));
2505 /* do it twice to force the change */
2506 act->set_active (!yn);
2507 act->set_active (yn);
2508 }
2509
2510 #ifdef MIXBUS
2511 yn = true;
2512 node.get_property ("show-mixbus-pane", yn);
2513 {
2514 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixbusPane"));
2515 /* do it twice to force the change */
2516 act->set_active (!yn);
2517 act->set_active (yn);
2518 }
2519 #endif
2520
2521 XMLNode plugin_order (X_("PO"));
2522 if (PluginManager::instance().load_plugin_order_file (plugin_order)) {
2523 favorite_ui_order.clear ();
2524 const XMLNodeList& kids = plugin_order.children("PluginInfo");
2525 XMLNodeConstIterator i;
2526 for (i = kids.begin(); i != kids.end(); ++i) {
2527 std::string unique_id;
2528 if ((*i)->get_property ("unique-id", unique_id)) {
2529 favorite_ui_order.push_back (unique_id);
2530 if ((*i)->get_property ("expanded", yn)) {
2531 favorite_ui_state[unique_id] = yn;
2532 }
2533 }
2534 }
2535 sync_treeview_from_favorite_order ();
2536 }
2537
2538 return 0;
2539 }
2540
2541 void
favorite_plugins_deleted(const TreeModel::Path &)2542 Mixer_UI::favorite_plugins_deleted (const TreeModel::Path&)
2543 {
2544 if (ignore_plugin_reorder) {
2545 return;
2546 }
2547 /* re-order is implemented by insert; delete */
2548 save_plugin_order_file ();
2549 }
2550
2551 void
save_plugin_order_file()2552 Mixer_UI::save_plugin_order_file ()
2553 {
2554 store_current_favorite_order ();
2555
2556 XMLNode plugin_order ("PluginOrder");
2557 uint32_t cnt = 0;
2558 for (std::list<std::string>::const_iterator i = favorite_ui_order.begin(); i != favorite_ui_order.end(); ++i, ++cnt) {
2559 XMLNode* p = new XMLNode ("PluginInfo");
2560 p->set_property ("sort", cnt);
2561 p->set_property ("unique-id", *i);
2562 if (favorite_ui_state.find (*i) != favorite_ui_state.end ()) {
2563 p->set_property ("expanded", favorite_ui_state[*i]);
2564 }
2565 plugin_order.add_child_nocopy (*p);
2566 }
2567 PluginManager::instance().save_plugin_order_file (plugin_order);
2568 }
2569
2570 XMLNode&
get_state()2571 Mixer_UI::get_state ()
2572 {
2573 XMLNode* node = new XMLNode (X_("Mixer"));
2574
2575 node->add_child_nocopy (Tabbable::get_state());
2576
2577 node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider());
2578 node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider());
2579 node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider());
2580 node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider());
2581
2582 node->set_property ("narrow-strips", (_strip_width == Narrow));
2583 node->set_property ("show-mixer", _visible);
2584 node->set_property ("maximised", _maximised);
2585
2586 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2587 node->set_property ("show-mixer-list", act->get_active ());
2588
2589 act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2590 node->set_property ("monitor-section-visible", act->get_active ());
2591
2592 act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
2593 node->set_property ("foldback-strip-visible", act->get_active ());
2594
2595 act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2596 node->set_property ("show-vca-pane", act->get_active ());
2597
2598 #ifdef MIXBUS
2599 act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2600 node->set_property ("show-mixbus-pane", act->get_active ());
2601 #endif
2602
2603 return *node;
2604 }
2605
2606 void
scroll_left()2607 Mixer_UI::scroll_left ()
2608 {
2609 if (!scroller.get_hscrollbar()) return;
2610 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2611 int sc_w = scroller.get_width();
2612 int sp_w = strip_packer.get_width();
2613 if (sp_w <= sc_w) {
2614 return;
2615 }
2616 int lp = adj->get_value();
2617 int lm = 0;
2618 using namespace Gtk::Box_Helpers;
2619 const BoxList& strips = strip_packer.children();
2620 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2621 if (i->get_widget() == &scroller_base) {
2622 continue;
2623 }
2624 #ifdef MIXBUS
2625 if (i->get_widget() == &mb_shadow) {
2626 continue;
2627 }
2628 #endif
2629 lm += i->get_widget()->get_width ();
2630 if (lm >= lp) {
2631 lm -= i->get_widget()->get_width ();
2632 break;
2633 }
2634 }
2635 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2636 }
2637
2638 void
scroll_right()2639 Mixer_UI::scroll_right ()
2640 {
2641 if (!scroller.get_hscrollbar()) return;
2642 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2643 int sc_w = scroller.get_width();
2644 int sp_w = strip_packer.get_width();
2645 if (sp_w <= sc_w) {
2646 return;
2647 }
2648 int lp = adj->get_value();
2649 int lm = 0;
2650 using namespace Gtk::Box_Helpers;
2651 const BoxList& strips = strip_packer.children();
2652 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2653 if (i->get_widget() == &scroller_base) {
2654 continue;
2655 }
2656 #ifdef MIXBUS
2657 if (i->get_widget() == &mb_shadow) {
2658 continue;
2659 }
2660 #endif
2661 lm += i->get_widget()->get_width ();
2662 if (lm > lp + 1) {
2663 break;
2664 }
2665 }
2666 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2667 }
2668
2669 bool
on_scroll_event(GdkEventScroll * ev)2670 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2671 {
2672 switch (ev->direction) {
2673 case GDK_SCROLL_LEFT:
2674 scroll_left ();
2675 return true;
2676 case GDK_SCROLL_UP:
2677 if (ev->state & Keyboard::TertiaryModifier) {
2678 scroll_left ();
2679 return true;
2680 }
2681 return false;
2682
2683 case GDK_SCROLL_RIGHT:
2684 scroll_right ();
2685 return true;
2686
2687 case GDK_SCROLL_DOWN:
2688 if (ev->state & Keyboard::TertiaryModifier) {
2689 scroll_right ();
2690 return true;
2691 }
2692 return false;
2693 }
2694
2695 return false;
2696 }
2697
2698 void
vca_scroll_left()2699 Mixer_UI::vca_scroll_left ()
2700 {
2701 if (!vca_scroller.get_hscrollbar()) return;
2702 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2703 int sc_w = vca_scroller.get_width();
2704 int sp_w = strip_packer.get_width();
2705 if (sp_w <= sc_w) {
2706 return;
2707 }
2708 int lp = adj->get_value();
2709 int lm = 0;
2710 using namespace Gtk::Box_Helpers;
2711 const BoxList& strips = vca_hpacker.children();
2712 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2713 if (i->get_widget() == &vca_scroller_base) {
2714 continue;
2715 }
2716 lm += i->get_widget()->get_width ();
2717 if (lm >= lp) {
2718 lm -= i->get_widget()->get_width ();
2719 break;
2720 }
2721 }
2722 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2723 }
2724
2725 void
vca_scroll_right()2726 Mixer_UI::vca_scroll_right ()
2727 {
2728 if (!vca_scroller.get_hscrollbar()) return;
2729 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2730 int sc_w = vca_scroller.get_width();
2731 int sp_w = strip_packer.get_width();
2732 if (sp_w <= sc_w) {
2733 return;
2734 }
2735 int lp = adj->get_value();
2736 int lm = 0;
2737 using namespace Gtk::Box_Helpers;
2738 const BoxList& strips = vca_hpacker.children();
2739 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2740 if (i->get_widget() == &vca_scroller_base) {
2741 continue;
2742 }
2743 lm += i->get_widget()->get_width ();
2744 if (lm > lp + 1) {
2745 break;
2746 }
2747 }
2748 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2749 }
2750
2751 bool
on_vca_scroll_event(GdkEventScroll * ev)2752 Mixer_UI::on_vca_scroll_event (GdkEventScroll* ev)
2753 {
2754 switch (ev->direction) {
2755 case GDK_SCROLL_LEFT:
2756 vca_scroll_left ();
2757 return true;
2758 case GDK_SCROLL_UP:
2759 if (ev->state & Keyboard::TertiaryModifier) {
2760 vca_scroll_left ();
2761 return true;
2762 }
2763 return false;
2764
2765 case GDK_SCROLL_RIGHT:
2766 vca_scroll_right ();
2767 return true;
2768
2769 case GDK_SCROLL_DOWN:
2770 if (ev->state & Keyboard::TertiaryModifier) {
2771 vca_scroll_right ();
2772 return true;
2773 }
2774 return false;
2775 }
2776
2777 return false;
2778 }
2779
2780 void
parameter_changed(string const & p)2781 Mixer_UI::parameter_changed (string const & p)
2782 {
2783 if (p == "show-group-tabs") {
2784 bool const s = _session ? _session->config.get_show_group_tabs () : true;
2785 if (s) {
2786 _group_tabs->show ();
2787 } else {
2788 _group_tabs->hide ();
2789 }
2790 } else if (p == "default-narrow_ms") {
2791 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2792 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2793 (*i)->set_width_enum (s ? Narrow : Wide, this);
2794 }
2795 }
2796 }
2797
2798 void
set_route_group_activation(RouteGroup * g,bool a)2799 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2800 {
2801 g->set_active (a, this);
2802 }
2803
2804 PluginSelector*
plugin_selector()2805 Mixer_UI::plugin_selector()
2806 {
2807 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2808 if (!_plugin_selector)
2809 _plugin_selector = new PluginSelector (PluginManager::instance());
2810 #endif
2811
2812 return _plugin_selector;
2813 }
2814
2815 void
setup_track_display()2816 Mixer_UI::setup_track_display ()
2817 {
2818 track_model = ListStore::create (stripable_columns);
2819 track_display.set_model (track_model);
2820 track_display.append_column (_("Show"), stripable_columns.visible);
2821 track_display.append_column (_("Strips"), stripable_columns.text);
2822 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2823 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2824 track_display.get_column (0)->set_expand(false);
2825 track_display.get_column (1)->set_expand(true);
2826 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2827 track_display.set_name (X_("EditGroupList"));
2828 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2829 track_display.set_reorderable (true);
2830 track_display.set_headers_visible (true);
2831 track_display.set_can_focus(false);
2832
2833 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2834 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2835
2836 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2837 track_list_visible_cell->property_activatable() = true;
2838 track_list_visible_cell->property_radio() = false;
2839 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2840
2841 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2842
2843 track_display_scroller.add (track_display);
2844 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2845
2846 track_display_frame.set_name("BaseFrame");
2847 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2848 track_display_frame.add (track_display_scroller);
2849
2850 track_display_scroller.show();
2851 track_display_frame.show();
2852 track_display.show();
2853 }
2854
2855 void
new_track_or_bus()2856 Mixer_UI::new_track_or_bus ()
2857 {
2858 ARDOUR_UI::instance()->add_route ();
2859 }
2860
2861 void
update_title()2862 Mixer_UI::update_title ()
2863 {
2864 if (!own_window()) {
2865 return;
2866 }
2867
2868 if (_session) {
2869 string n;
2870
2871 if (_session->snap_name() != _session->name()) {
2872 n = _session->snap_name ();
2873 } else {
2874 n = _session->name ();
2875 }
2876
2877 if (_session->dirty ()) {
2878 n = "*" + n;
2879 }
2880
2881 WindowTitle title (n);
2882 title += S_("Window|Mixer");
2883 title += Glib::get_application_name ();
2884 own_window()->set_title (title.get_string());
2885
2886 } else {
2887
2888 WindowTitle title (S_("Window|Mixer"));
2889 title += Glib::get_application_name ();
2890 own_window()->set_title (title.get_string());
2891 }
2892 }
2893
2894 MixerStrip*
strip_by_x(int x)2895 Mixer_UI::strip_by_x (int x)
2896 {
2897 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2898 int x1, x2, y;
2899
2900 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2901 x2 = x1 + (*i)->get_width();
2902
2903 if (x >= x1 && x <= x2) {
2904 return (*i);
2905 }
2906 }
2907
2908 return 0;
2909 }
2910
2911 void
set_axis_targets_for_operation()2912 Mixer_UI::set_axis_targets_for_operation ()
2913 {
2914 _axis_targets.clear ();
2915
2916 if (!_selection.empty()) {
2917 _axis_targets = _selection.axes;
2918 return;
2919 }
2920
2921 // removed "implicit" selections of strips, after discussion on IRC
2922
2923 }
2924
2925 void
monitor_section_going_away()2926 Mixer_UI::monitor_section_going_away ()
2927 {
2928 XMLNode* ui_node = Config->extra_xml(X_("UI"));
2929
2930 /* immediate state save.
2931 *
2932 * Tearoff settings are otherwise only stored during
2933 * save_ardour_state(). The mon-section may or may not
2934 * exist at that point.
2935 */
2936
2937 if (ui_node) {
2938 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
2939 if (tearoff_node) {
2940 tearoff_node->remove_nodes_and_delete (X_("monitor-section"));
2941 XMLNode* t = new XMLNode (X_("monitor-section"));
2942 _monitor_section.tearoff().add_state (*t);
2943 tearoff_node->add_child_nocopy (*t);
2944 }
2945 }
2946
2947 monitor_section_detached ();
2948 out_packer.remove (_monitor_section.tearoff());
2949 }
2950
2951 void
toggle_midi_input_active(bool flip_others)2952 Mixer_UI::toggle_midi_input_active (bool flip_others)
2953 {
2954 boost::shared_ptr<RouteList> rl (new RouteList);
2955 bool onoff = false;
2956
2957 set_axis_targets_for_operation ();
2958
2959 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2960 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2961
2962 if (mt) {
2963 rl->push_back (mt);
2964 onoff = !mt->input_active();
2965 }
2966 }
2967
2968 _session->set_exclusive_input_active (rl, onoff, flip_others);
2969 }
2970
2971 void
maximise_mixer_space()2972 Mixer_UI::maximise_mixer_space ()
2973 {
2974 if (!own_window()) {
2975 return;
2976 }
2977
2978 if (_maximised) {
2979 return;
2980 }
2981
2982 _window->fullscreen ();
2983 _maximised = true;
2984 }
2985
2986 void
restore_mixer_space()2987 Mixer_UI::restore_mixer_space ()
2988 {
2989 if (!own_window()) {
2990 return;
2991 }
2992
2993 if (!_maximised) {
2994 return;
2995 }
2996
2997 own_window()->unfullscreen();
2998 _maximised = false;
2999 }
3000
3001 void
monitor_section_attached()3002 Mixer_UI::monitor_section_attached ()
3003 {
3004 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
3005 act->set_sensitive (true);
3006 showhide_monitor_section (act->get_active ());
3007 }
3008
3009 void
monitor_section_detached()3010 Mixer_UI::monitor_section_detached ()
3011 {
3012 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleMonitorSection");
3013 act->set_sensitive (false);
3014 }
3015
3016 Mixer_UI::PluginListMode
plugin_list_mode() const3017 Mixer_UI::plugin_list_mode () const
3018 {
3019 if (favorite_plugins_mode_combo.get_active_text() == _("Top-10 Plugins")) {
3020 return PLM_TopHits;
3021 } else if (favorite_plugins_mode_combo.get_active_text() == _("Recent Plugins")) {
3022 return PLM_Recent;
3023 } else {
3024 return PLM_Favorite;
3025 }
3026 }
3027
3028 void
store_current_favorite_order()3029 Mixer_UI::store_current_favorite_order ()
3030 {
3031 if (plugin_list_mode () != PLM_Favorite || !plugin_search_entry.get_text ().empty()) {
3032 return;
3033 }
3034
3035 typedef Gtk::TreeModel::Children type_children;
3036 type_children children = favorite_plugins_model->children();
3037 favorite_ui_order.clear();
3038 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
3039 {
3040 Gtk::TreeModel::Row row = *iter;
3041 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
3042 favorite_ui_order.push_back ((*ppp->_pip).unique_id);
3043 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
3044 }
3045 }
3046
3047 void
save_favorite_ui_state(const TreeModel::iterator & iter,const TreeModel::Path & path)3048 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
3049 {
3050 Gtk::TreeModel::Row row = *iter;
3051 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
3052 assert (ppp);
3053 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
3054 }
3055
3056 void
plugin_list_mode_changed()3057 Mixer_UI::plugin_list_mode_changed ()
3058 {
3059 if (plugin_list_mode () == PLM_Favorite) {
3060 PBD::Unwinder<bool> uw (ignore_plugin_refill, true);
3061 favorite_plugins_search_hbox.show ();
3062 plugin_search_entry.set_text ("");
3063 } else {
3064 favorite_plugins_search_hbox.hide ();
3065 }
3066 refill_favorite_plugins ();
3067 }
3068
3069 void
plugin_search_entry_changed()3070 Mixer_UI::plugin_search_entry_changed ()
3071 {
3072 if (plugin_list_mode () == PLM_Favorite) {
3073 refill_favorite_plugins ();
3074 }
3075 }
3076
3077 void
plugin_search_clear_button_clicked()3078 Mixer_UI::plugin_search_clear_button_clicked ()
3079 {
3080 plugin_search_entry.set_text ("");
3081 }
3082
3083 void
refiller(PluginInfoList & result,const PluginInfoList & plugs)3084 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
3085 {
3086 PluginManager& manager (PluginManager::instance());
3087 PluginListMode plm = plugin_list_mode ();
3088
3089 std::string searchstr = plugin_search_entry.get_text ();
3090 setup_search_string (searchstr);
3091
3092 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
3093 bool maybe_show = true;
3094
3095 if (plm == PLM_Favorite) {
3096 if (manager.get_status (*i) != PluginManager::Favorite) {
3097 maybe_show = false;
3098 }
3099
3100 if (maybe_show && !searchstr.empty()) {
3101 maybe_show = false;
3102 /* check name */
3103 std::string compstr = (*i)->name;
3104 setup_search_string (compstr);
3105 maybe_show |= match_search_strings (compstr, searchstr);
3106 /* check tags */
3107 manager.get_tags_as_string (*i);
3108 setup_search_string (compstr);
3109 maybe_show |= match_search_strings (compstr, searchstr);
3110 }
3111 } else {
3112 int64_t lru;
3113 uint64_t use_count;
3114 if (!manager.stats (*i, lru, use_count)) {
3115 maybe_show = false;
3116 }
3117 if (plm == PLM_Recent && lru == 0) {
3118 maybe_show = false;
3119 }
3120 }
3121
3122 if (!maybe_show) {
3123 continue;
3124 }
3125 result.push_back (*i);
3126 }
3127 }
3128
3129 void
refill_favorite_plugins()3130 Mixer_UI::refill_favorite_plugins ()
3131 {
3132 if (ignore_plugin_refill) {
3133 return;
3134 }
3135
3136 PluginInfoList plugs;
3137 PluginManager& mgr (PluginManager::instance());
3138
3139 #ifdef WINDOWS_VST_SUPPORT
3140 refiller (plugs, mgr.windows_vst_plugin_info ());
3141 #endif
3142 #ifdef LXVST_SUPPORT
3143 refiller (plugs, mgr.lxvst_plugin_info ());
3144 #endif
3145 #ifdef MACVST_SUPPORT
3146 refiller (plugs, mgr.mac_vst_plugin_info ());
3147 #endif
3148 #ifdef VST3_SUPPORT
3149 refiller (plugs, mgr.vst3_plugin_info ());
3150 #endif
3151 #ifdef AUDIOUNIT_SUPPORT
3152 refiller (plugs, mgr.au_plugin_info ());
3153 #endif
3154 refiller (plugs, mgr.ladspa_plugin_info ());
3155 refiller (plugs, mgr.lv2_plugin_info ());
3156 refiller (plugs, mgr.lua_plugin_info ());
3157
3158 switch (plugin_list_mode ()) {
3159 default:
3160 /* use favorites as-is */
3161 break;
3162 case PLM_TopHits:
3163 {
3164 PluginChartsSorter cmp;
3165 plugs.sort (cmp);
3166 plugs.resize (std::min (plugs.size(), size_t(UIConfiguration::instance().get_max_plugin_chart())));
3167 }
3168 break;
3169 case PLM_Recent:
3170 {
3171 PluginRecentSorter cmp;
3172 plugs.sort (cmp);
3173 plugs.resize (std::min (plugs.size(), size_t(10)));
3174 plugs.resize (std::min (plugs.size(), size_t(UIConfiguration::instance().get_max_plugin_recent())));
3175 }
3176 break;
3177 }
3178 plugin_list = plugs;
3179
3180 sync_treeview_from_favorite_order ();
3181 //store_current_favorite_order ();
3182 }
3183
3184 void
maybe_refill_favorite_plugins(PluginListMode plm)3185 Mixer_UI::maybe_refill_favorite_plugins (PluginListMode plm)
3186 {
3187 switch (plm) {
3188 case PLM_Favorite:
3189 if (plugin_list_mode () == PLM_Favorite) {
3190 refill_favorite_plugins();
3191 }
3192 break;
3193 default:
3194 if (plugin_list_mode () != PLM_Favorite) {
3195 refill_favorite_plugins();
3196 }
3197 break;
3198 }
3199 }
3200
3201 void
sync_treeview_favorite_ui_state(const TreeModel::Path & path,const TreeModel::iterator &)3202 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
3203 {
3204 TreeIter iter;
3205 if (!(iter = favorite_plugins_model->get_iter (path))) {
3206 return;
3207 }
3208 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3209 if (!ppp) {
3210 return;
3211 }
3212 PluginInfoPtr pip = ppp->_pip;
3213 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3214 if (favorite_ui_state[pip->unique_id]) {
3215 favorite_plugins_display.expand_row (path, true);
3216 }
3217 }
3218 }
3219
3220 void
sync_treeview_from_favorite_order()3221 Mixer_UI::sync_treeview_from_favorite_order ()
3222 {
3223 PBD::Unwinder<bool> uw (ignore_plugin_reorder, true);
3224 switch (plugin_list_mode ()) {
3225 case PLM_Favorite:
3226 {
3227 PluginUIOrderSorter cmp (favorite_ui_order);
3228 plugin_list.sort (cmp);
3229 }
3230 break;
3231 case PLM_TopHits:
3232 {
3233 PluginABCSorter cmp;
3234 plugin_list.sort (cmp);
3235 }
3236 case PLM_Recent:
3237 break;
3238 }
3239
3240 favorite_plugins_model->clear ();
3241 for (PluginInfoList::const_iterator i = plugin_list.begin(); i != plugin_list.end(); ++i) {
3242 PluginInfoPtr pip = (*i);
3243
3244 TreeModel::Row newrow = *(favorite_plugins_model->append());
3245 newrow[favorite_plugins_columns.name] = (*i)->name;
3246 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
3247 if (!_session) {
3248 continue;
3249 }
3250
3251 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
3252 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
3253 if (!(*j).user) {
3254 continue;
3255 }
3256 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
3257 child_row[favorite_plugins_columns.name] = (*j).label;
3258 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
3259 }
3260 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3261 if (favorite_ui_state[pip->unique_id]) {
3262 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
3263 }
3264 }
3265 }
3266 }
3267
3268 void
popup_note_context_menu(GdkEventButton * ev)3269 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
3270 {
3271 using namespace Gtk::Menu_Helpers;
3272
3273 Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu ();
3274 MenuList& items = m->items ();
3275
3276 if (_selection.axes.empty()) {
3277 items.push_back (MenuElem (_("No Track/Bus is selected.")));
3278 } else {
3279 items.push_back (MenuElem (_("Add at the top"),
3280 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
3281 items.push_back (MenuElem (_("Add Pre-Fader"),
3282 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
3283 items.push_back (MenuElem (_("Add Post-Fader"),
3284 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
3285 items.push_back (MenuElem (_("Add at the end"),
3286 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
3287 }
3288
3289 items.push_back (SeparatorElem());
3290
3291 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
3292
3293 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3294 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
3295 // we cannot currently delete AU presets
3296 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
3297 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
3298 }
3299 }
3300
3301 m->popup (ev->button, ev->time);
3302 }
3303
3304 bool
plugin_row_button_press(GdkEventButton * ev)3305 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
3306 {
3307 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
3308 TreeModel::Path path;
3309 TreeViewColumn* column;
3310 int cellx, celly;
3311 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
3312 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3313 if (selection) {
3314 selection->unselect_all();
3315 selection->select(path);
3316 }
3317 }
3318 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3319 if (ppp) {
3320 popup_note_context_menu (ev);
3321 }
3322 }
3323 return false;
3324 }
3325
3326
3327 PluginPresetPtr
selected_plugin()3328 Mixer_UI::selected_plugin ()
3329 {
3330 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3331 if (!selection) {
3332 return PluginPresetPtr();
3333 }
3334 Gtk::TreeModel::iterator iter = selection->get_selected();
3335 if (!iter) {
3336 return PluginPresetPtr();
3337 }
3338 return (*iter)[favorite_plugins_columns.plugin];
3339 }
3340
3341 void
add_selected_processor(ProcessorPosition pos)3342 Mixer_UI::add_selected_processor (ProcessorPosition pos)
3343 {
3344 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3345 if (ppp) {
3346 add_favorite_processor (ppp, pos);
3347 }
3348 }
3349
3350 void
delete_selected_preset()3351 Mixer_UI::delete_selected_preset ()
3352 {
3353 if (!_session) {
3354 return;
3355 }
3356 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3357 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
3358 return;
3359 }
3360 PluginPtr plugin = ppp->_pip->load (*_session);
3361 plugin->get_presets();
3362 plugin->remove_preset (ppp->_preset.label);
3363 }
3364
3365 void
remove_selected_from_favorites()3366 Mixer_UI::remove_selected_from_favorites ()
3367 {
3368 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3369 if (!ppp) {
3370 return;
3371 }
3372 PluginManager::PluginStatusType status = PluginManager::Normal;
3373 PluginManager& manager (PluginManager::instance());
3374
3375 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3376 manager.save_statuses ();
3377 }
3378
3379 void
plugin_row_activated(const TreeModel::Path & path,TreeViewColumn * column)3380 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
3381 {
3382 TreeIter iter;
3383 if (!(iter = favorite_plugins_model->get_iter (path))) {
3384 return;
3385 }
3386 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3387 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
3388 }
3389
3390 void
add_favorite_processor(ARDOUR::PluginPresetPtr ppp,ProcessorPosition pos)3391 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
3392 {
3393 if (!_session || _selection.axes.empty()) {
3394 return;
3395 }
3396
3397 PluginInfoPtr pip = ppp->_pip;
3398 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
3399 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
3400
3401 if (!rt) {
3402 continue;
3403 }
3404
3405 PluginPtr p = pip->load (*_session);
3406
3407 if (!p) {
3408 continue;
3409 }
3410
3411 if (ppp->_preset.valid) {
3412 p->load_preset (ppp->_preset);
3413 }
3414
3415 Route::ProcessorStreams err;
3416 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
3417
3418 switch (pos) {
3419 case AddTop:
3420 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
3421 break;
3422 case AddPreFader:
3423 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
3424 break;
3425 case AddPostFader:
3426 {
3427 int idx = 0;
3428 int pos = 0;
3429 for (;;++idx) {
3430 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
3431 if (!np) {
3432 break;
3433 }
3434 if (!np->display_to_user()) {
3435 continue;
3436 }
3437 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
3438 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
3439 break;
3440 }
3441 ++pos;
3442 }
3443 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
3444 }
3445 break;
3446 case AddBottom:
3447 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
3448 break;
3449 }
3450 }
3451 }
3452
3453 bool
row_drop_possible_vfunc(const Gtk::TreeModel::Path & dest,const Gtk::SelectionData & data) const3454 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
3455 {
3456 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
3457 return false;
3458 }
3459
3460 // only allow to re-order top-level items
3461 TreePath src;
3462 if (TreePath::get_from_selection_data (data, src)) {
3463 if (src.up() && src.up()) {
3464 return false;
3465 }
3466 }
3467
3468 // don't allow to drop as child-rows.
3469 Gtk::TreeModel::Path _dest = dest; // un const
3470 const bool is_child = _dest.up (); // explicit bool for clang
3471 if (!is_child || _dest.empty ()) {
3472 return true;
3473 }
3474 return false;
3475 }
3476
3477 bool
plugin_drag_motion(const Glib::RefPtr<Gdk::DragContext> & ctx,int x,int y,guint time)3478 Mixer_UI::plugin_drag_motion (const Glib::RefPtr<Gdk::DragContext>& ctx, int x, int y, guint time)
3479 {
3480 std::string target = favorite_plugins_display.drag_dest_find_target (ctx, favorite_plugins_display.drag_dest_get_target_list());
3481
3482 if (target.empty()) {
3483 ctx->drag_status (Gdk::DragAction (0), time);
3484 return false;
3485 }
3486
3487 if (target == "GTK_TREE_MODEL_ROW") {
3488 if (plugin_list_mode () == PLM_Favorite && plugin_search_entry.get_text ().empty()) {
3489 /* re-order rows */
3490 ctx->drag_status (Gdk::ACTION_MOVE, time);
3491 return true;
3492 }
3493 } else if (target == "PluginPresetPtr") {
3494 ctx->drag_status (Gdk::ACTION_COPY, time);
3495 //favorite_plugins_mode_combo.set_active_text (_("Favorite Plugins"));
3496 return true;
3497 }
3498
3499 ctx->drag_status (Gdk::DragAction (0), time);
3500 return false;
3501 }
3502
3503 void
plugin_drop(const Glib::RefPtr<Gdk::DragContext> &,const Gtk::SelectionData & data)3504 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
3505 {
3506 if (data.get_target() != "PluginPresetPtr") {
3507 return;
3508 }
3509 if (data.get_length() != sizeof (PluginPresetPtr)) {
3510 return;
3511 }
3512
3513 const void *d = data.get_data();
3514 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
3515
3516 PluginManager::PluginStatusType status = PluginManager::Favorite;
3517 PluginManager& manager (PluginManager::instance());
3518
3519 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3520 manager.save_statuses ();
3521 }
3522
3523 void
do_vca_assign(boost::shared_ptr<VCA> vca)3524 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
3525 {
3526 /* call protected MixerActor:: method */
3527 vca_assign (vca);
3528 }
3529
3530 void
do_vca_unassign(boost::shared_ptr<VCA> vca)3531 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
3532 {
3533 /* call protected MixerActor:: method */
3534 vca_unassign (vca);
3535 }
3536
3537 void
show_spill(boost::shared_ptr<Stripable> s)3538 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
3539 {
3540 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
3541 if (ss == s) {
3542 return;
3543 }
3544
3545 spilled_strip = s;
3546 _spill_gone_connection.disconnect ();
3547 show_spill_change (s); /* EMIT SIGNAL */
3548
3549 if (s) {
3550 s->DropReferences.connect (_spill_gone_connection, invalidator (*this), boost::bind (&Mixer_UI::spill_nothing, this), gui_context());
3551 _group_tabs->set_sensitive (false);
3552 } else {
3553 _group_tabs->set_sensitive (true);
3554 }
3555 redisplay_track_list ();
3556 }
3557
3558 void
spill_nothing()3559 Mixer_UI::spill_nothing ()
3560 {
3561 show_spill (boost::shared_ptr<Stripable> ());
3562 }
3563
3564 bool
showing_spill_for(boost::shared_ptr<Stripable> s) const3565 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
3566 {
3567 return s == spilled_strip.lock();
3568 }
3569
3570 void
register_actions()3571 Mixer_UI::register_actions ()
3572 {
3573 Glib::RefPtr<ActionGroup> group = ActionManager::create_action_group (bindings, X_("Mixer"));
3574
3575 ActionManager::register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
3576 ActionManager::register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
3577 ActionManager::register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
3578 ActionManager::register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
3579 ActionManager::register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
3580 ActionManager::register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
3581
3582
3583 ActionManager::register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
3584 ActionManager::register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
3585 ActionManager::register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
3586 ActionManager::register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
3587 ActionManager::register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
3588 ActionManager::register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
3589 ActionManager::register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
3590 ActionManager::register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
3591
3592 ActionManager::register_action (group, "select-next-stripable", _("Select Next Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_next_strip));
3593 ActionManager::register_action (group, "select-prev-stripable", _("Select Previous Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_prev_strip));
3594
3595 ActionManager::register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
3596 ActionManager::register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
3597
3598 ActionManager::register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
3599 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
3600
3601 ActionManager::register_toggle_action (group, X_("ToggleMixerList"), _("Mixer: Show Mixer List"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixer_list));
3602
3603 ActionManager::register_toggle_action (group, X_("ToggleVCAPane"), _("Mixer: Show VCAs"), sigc::mem_fun (*this, &Mixer_UI::toggle_vcas));
3604
3605 #ifdef MIXBUS
3606 ActionManager::register_toggle_action (group, X_("ToggleMixbusPane"), _("Mixer: Show Mixbusses"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixbuses));
3607 #endif
3608
3609 ActionManager::register_toggle_action (group, X_("ToggleMonitorSection"), _("Mixer: Show Monitor Section"), sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_section));
3610
3611 ActionManager::register_toggle_action (group, X_("ToggleFoldbackStrip"), _("Mixer: Show Foldback Strip"), sigc::mem_fun (*this, &Mixer_UI::toggle_foldback_strip));
3612
3613 ActionManager::register_toggle_action (group, X_("toggle-disk-monitor"), _("Toggle Disk Monitoring"), sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_action), MonitorDisk, false, false));
3614 ActionManager::register_toggle_action (group, X_("toggle-input-monitor"), _("Toggle Input Monitoring"), sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_action), MonitorInput, false, false));
3615 }
3616
3617 void
load_bindings()3618 Mixer_UI::load_bindings ()
3619 {
3620 bindings = Bindings::get_bindings (X_("Mixer"));
3621 }
3622
3623 template<class T> void
control_action(boost::shared_ptr<T> (Stripable::* get_control)()const)3624 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
3625 {
3626 boost::shared_ptr<ControlList> cl (new ControlList);
3627 boost::shared_ptr<AutomationControl> ac;
3628 bool val = false;
3629 bool have_val = false;
3630
3631 set_axis_targets_for_operation ();
3632
3633 BOOST_FOREACH(AxisView* r, _axis_targets) {
3634 boost::shared_ptr<Stripable> s = r->stripable();
3635 if (s) {
3636 ac = (s.get()->*get_control)();
3637 if (ac) {
3638 ac->start_touch (_session->audible_sample ());
3639 cl->push_back (ac);
3640 if (!have_val) {
3641 val = !ac->get_value();
3642 have_val = true;
3643 }
3644 }
3645 }
3646 }
3647
3648 _session->set_controls (cl, val, Controllable::UseGroup);
3649 }
3650
3651 void
solo_action()3652 Mixer_UI::solo_action ()
3653 {
3654 control_action (&Stripable::solo_control);
3655 }
3656
3657 void
mute_action()3658 Mixer_UI::mute_action ()
3659 {
3660 control_action (&Stripable::mute_control);
3661 }
3662
3663 void
rec_enable_action()3664 Mixer_UI::rec_enable_action ()
3665 {
3666 control_action (&Stripable::rec_enable_control);
3667 }
3668
3669 AutomationControlSet
selected_gaincontrols()3670 Mixer_UI::selected_gaincontrols ()
3671 {
3672 set_axis_targets_for_operation ();
3673 AutomationControlSet rv;
3674 BOOST_FOREACH(AxisView* r, _axis_targets) {
3675 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3676 if (ms) {
3677 boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
3678 ControlList cl (ac->grouped_controls());
3679 for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
3680 rv.insert (*c);
3681 }
3682 rv.insert (ac);
3683 }
3684 }
3685 return rv;
3686 }
3687
3688 void
step_gain_up_action()3689 Mixer_UI::step_gain_up_action ()
3690 {
3691 AutomationControlSet acs = selected_gaincontrols ();
3692 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3693 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3694 assert (ac);
3695 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
3696 }
3697 }
3698
3699 void
step_gain_down_action()3700 Mixer_UI::step_gain_down_action ()
3701 {
3702 AutomationControlSet acs = selected_gaincontrols ();
3703 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3704 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3705 assert (ac);
3706 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
3707 }
3708 }
3709
3710 void
unity_gain_action()3711 Mixer_UI::unity_gain_action ()
3712 {
3713 set_axis_targets_for_operation ();
3714
3715 BOOST_FOREACH(AxisView* r, _axis_targets) {
3716 boost::shared_ptr<Stripable> s = r->stripable();
3717 if (s) {
3718 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3719 if (ac) {
3720 ac->set_value (1.0, Controllable::UseGroup);
3721 }
3722 }
3723 }
3724 }
3725
3726 void
copy_processors()3727 Mixer_UI::copy_processors ()
3728 {
3729 set_axis_targets_for_operation ();
3730
3731 BOOST_FOREACH(AxisView* r, _axis_targets) {
3732 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3733 if (ms) {
3734 ms->copy_processors ();
3735 }
3736 }
3737 }
3738 void
cut_processors()3739 Mixer_UI::cut_processors ()
3740 {
3741 set_axis_targets_for_operation ();
3742
3743 BOOST_FOREACH(AxisView* r, _axis_targets) {
3744 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3745 if (ms) {
3746 ms->cut_processors ();
3747 }
3748 }
3749 }
3750 void
paste_processors()3751 Mixer_UI::paste_processors ()
3752 {
3753 set_axis_targets_for_operation ();
3754
3755 BOOST_FOREACH(AxisView* r, _axis_targets) {
3756 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3757 if (ms) {
3758 ms->paste_processors ();
3759 }
3760 }
3761 }
3762 void
select_all_processors()3763 Mixer_UI::select_all_processors ()
3764 {
3765 set_axis_targets_for_operation ();
3766
3767 BOOST_FOREACH(AxisView* r, _axis_targets) {
3768 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3769 if (ms) {
3770 ms->select_all_processors ();
3771 }
3772 }
3773 }
3774 void
toggle_processors()3775 Mixer_UI::toggle_processors ()
3776 {
3777 set_axis_targets_for_operation ();
3778
3779 BOOST_FOREACH(AxisView* r, _axis_targets) {
3780 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3781 if (ms) {
3782 ms->toggle_processors ();
3783 }
3784 }
3785 }
3786 void
ab_plugins()3787 Mixer_UI::ab_plugins ()
3788 {
3789 set_axis_targets_for_operation ();
3790
3791 BOOST_FOREACH(AxisView* r, _axis_targets) {
3792 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3793 if (ms) {
3794 ms->ab_plugins ();
3795 }
3796 }
3797 }
3798
3799 void
vca_assign(boost::shared_ptr<VCA> vca)3800 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3801 {
3802 set_axis_targets_for_operation ();
3803 BOOST_FOREACH(AxisView* r, _axis_targets) {
3804 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3805 if (ms) {
3806 ms->vca_assign (vca);
3807 }
3808 }
3809 }
3810
3811 void
vca_unassign(boost::shared_ptr<VCA> vca)3812 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3813 {
3814 set_axis_targets_for_operation ();
3815 BOOST_FOREACH(AxisView* r, _axis_targets) {
3816 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3817 if (ms) {
3818 ms->vca_unassign (vca);
3819 }
3820 }
3821 }
3822
3823 bool
screenshot(std::string const & filename)3824 Mixer_UI::screenshot (std::string const& filename)
3825 {
3826 if (!_session) {
3827 return false;
3828 }
3829
3830 int height = strip_packer.get_height();
3831 bool with_vca = vca_vpacker.is_visible ();
3832 MixerStrip* master = strip_by_route (_session->master_out ());
3833
3834 Gtk::OffscreenWindow osw;
3835 Gtk::HBox b;
3836 osw.add (b);
3837 b.show ();
3838
3839 /* unpack widgets, add to OffscreenWindow */
3840
3841 strip_group_box.remove (strip_packer);
3842 b.pack_start (strip_packer, false, false);
3843 /* hide extra elements inside strip_packer */
3844 scroller_base.hide ();
3845 #ifdef MIXBUS
3846 mb_shadow.hide();
3847 #endif
3848
3849 if (with_vca) {
3850 /* work around Gtk::ScrolledWindow */
3851 Gtk::Viewport* viewport = (Gtk::Viewport*) vca_scroller.get_child();
3852 viewport->remove (); // << vca_hpacker
3853 b.pack_start (vca_hpacker, false, false);
3854 /* hide some growing widgets */
3855 vca_scroller_base.hide();
3856 }
3857
3858 if (master) {
3859 out_packer.remove (*master);
3860 b.pack_start (*master, false, false);
3861 master->hide_master_spacer (true);
3862 }
3863
3864 /* prepare the OffscreenWindow for rendering */
3865 osw.set_size_request (-1, height);
3866 osw.show ();
3867 osw.queue_resize ();
3868 osw.queue_draw ();
3869 osw.get_window()->process_updates (true);
3870
3871 /* create screenshot */
3872 Glib::RefPtr<Gdk::Pixbuf> pb = osw.get_pixbuf ();
3873 pb->save (filename, "png");
3874
3875 /* unpack elements before destorying the Box & OffscreenWindow */
3876 list<Gtk::Widget*> children = b.get_children();
3877 for (list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
3878 b.remove (**child);
3879 }
3880 osw.remove ();
3881
3882 /* now re-pack the widgets into the main mixer window */
3883 scroller_base.show ();
3884 #ifdef MIXBUS
3885 mb_shadow.show();
3886 #endif
3887 strip_group_box.pack_start (strip_packer);
3888 if (with_vca) {
3889 vca_scroller_base.show();
3890 vca_scroller.add (vca_hpacker);
3891 }
3892 if (master) {
3893 master->hide_master_spacer (false);
3894 out_packer.pack_start (*master, false, false);
3895 }
3896 return true;
3897 }
3898
3899 void
toggle_monitor_action(MonitorChoice monitor_choice,bool group_override,bool all)3900 Mixer_UI::toggle_monitor_action (MonitorChoice monitor_choice, bool group_override, bool all)
3901 {
3902 MonitorChoice mc;
3903 boost::shared_ptr<RouteList> rl;
3904
3905 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
3906 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
3907
3908 if (!rt->monitoring_control ()) {
3909 /* skip busses */
3910 continue;
3911 }
3912
3913 if (rt->monitoring_control()->monitoring_choice() & monitor_choice) {
3914 mc = MonitorChoice (rt->monitoring_control()->monitoring_choice() & ~monitor_choice);
3915 } else {
3916 mc = MonitorChoice (rt->monitoring_control()->monitoring_choice() | monitor_choice);
3917 }
3918
3919 if (all) {
3920 /* Primary-Tertiary-click applies change to all routes */
3921 rl = _session->get_routes ();
3922 _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::NoGroup);
3923 } else if (group_override) {
3924 rl.reset (new RouteList);
3925 rl->push_back (rt);
3926 _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::InverseGroup);
3927 } else {
3928 rl.reset (new RouteList);
3929 rl->push_back (rt);
3930 _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::UseGroup);
3931 }
3932
3933 }
3934 }
3935