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>
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.
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.
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.
29 #include "gtk2ardour-config.h"
34 #include <sigc++/bind.h>
36 #include <boost/foreach.hpp>
38 #include <glibmm/threads.h>
40 #include <gtkmm/accelmap.h>
41 #include <gtkmm/offscreenwindow.h>
42 #include <gtkmm/stock.h>
44 #include "pbd/convert.h"
45 #include "pbd/stacktrace.h"
46 #include "pbd/unwind.h"
48 #include "ardour/amp.h"
49 #include "ardour/debug.h"
50 #include "ardour/audio_track.h"
51 #include "ardour/midi_track.h"
52 #include "ardour/plugin_manager.h"
53 #include "ardour/route_group.h"
54 #include "ardour/selection.h"
55 #include "ardour/session.h"
56 #include "ardour/vca.h"
57 #include "ardour/vca_manager.h"
59 #include "gtkmm2ext/gtk_ui.h"
60 #include "gtkmm2ext/keyboard.h"
61 #include "gtkmm2ext/utils.h"
62 #include "gtkmm2ext/window_title.h"
63 #include "gtkmm2ext/doi.h"
65 #include "widgets/tearoff.h"
67 #include "foldback_strip.h"
70 #include "mixer_strip.h"
71 #include "monitor_section.h"
72 #include "plugin_selector.h"
73 #include "public_editor.h"
74 #include "mouse_cursors.h"
75 #include "ardour_ui.h"
77 #include "route_sorter.h"
79 #include "gui_thread.h"
80 #include "mixer_group_tabs.h"
81 #include "route_sorter.h"
83 #include "ui_config.h"
84 #include "vca_master_strip.h"
88 using namespace ARDOUR;
89 using namespace ARDOUR_UI_UTILS;
93 using namespace Gtkmm2ext;
99 Mixer_UI* Mixer_UI::_instance = 0;
102 Mixer_UI::instance ()
105 _instance = new Mixer_UI;
111 Mixer_UI::Mixer_UI ()
112 : Tabbable (_content, _("Mixer"))
113 , no_track_list_redisplay (false)
114 , in_group_row_change (false)
116 , _plugin_selector (0)
118 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
119 , _spill_scroll_position (0)
120 , ignore_reorder (false)
121 , _in_group_rebuild_or_clear (false)
122 , _route_deletion_in_progress (false)
124 , _strip_selection_change_without_scroll (false)
125 , _selection (*this, *this)
129 _content.set_data ("ardour-bindings", bindings);
131 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
133 scroller.set_can_default (true);
134 // set_default (scroller);
136 scroller_base.set_flags (Gtk::CAN_FOCUS);
137 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
138 scroller_base.set_name ("MixerWindow");
139 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
141 /* set up drag-n-drop */
142 vector<TargetEntry> target_table;
143 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
144 scroller_base.drag_dest_set (target_table);
145 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
147 /* create a button to add VCA strips ... will get packed in redisplay_track_list() */
148 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
150 add_vca_button.add (*w);
151 add_vca_button.set_can_focus(false);
152 add_vca_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
154 /* create a button to add mixer strips */
155 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
158 add_button.set_can_focus(false);
159 add_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
161 /* add as last item of strip packer */
162 strip_packer.pack_end (scroller_base, true, true);
163 strip_packer.pack_end (add_button, false, false);
166 /* create a drop-shadow at the end of the mixer strips */
167 mb_shadow.set_size_request( 4, -1 );
168 mb_shadow.set_name("EditorWindow");
170 strip_packer.pack_end (mb_shadow, false, false);
173 _group_tabs = new MixerGroupTabs (this);
174 strip_group_box.set_spacing (0);
175 strip_group_box.set_border_width (0);
176 strip_group_box.pack_start (*_group_tabs, PACK_SHRINK);
177 strip_group_box.pack_start (strip_packer);
178 strip_group_box.show_all ();
179 strip_group_box.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
181 scroller.add (strip_group_box);
182 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
184 setup_track_display ();
186 group_model = ListStore::create (group_columns);
187 group_display.set_model (group_model);
188 group_display.append_column (_("Show"), group_columns.visible);
189 group_display.append_column (_("Group"), group_columns.text);
190 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
191 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
192 group_display.get_column (0)->set_expand(false);
193 group_display.get_column (1)->set_expand(true);
194 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
195 group_display.set_name ("EditGroupList");
196 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
197 group_display.set_reorderable (true);
198 group_display.set_headers_visible (true);
199 group_display.set_rules_hint (true);
200 group_display.set_can_focus(false);
202 /* name is directly editable */
204 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
205 name_cell->property_editable() = true;
206 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
208 /* use checkbox for the active column */
210 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
211 active_cell->property_activatable() = true;
212 active_cell->property_radio() = false;
214 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
215 /* We use this to notice drag-and-drop reorders of the group list */
216 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
217 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
219 group_display_scroller.add (group_display);
220 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
223 group_display_vbox.pack_start (group_display_scroller, true, true);
225 group_display_frame.set_name ("BaseFrame");
226 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
227 group_display_frame.add (group_display_vbox);
229 list<TargetEntry> target_list;
230 target_list.push_back (TargetEntry ("PluginPresetPtr"));
232 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
233 favorite_plugins_display.set_model (favorite_plugins_model);
234 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
235 favorite_plugins_display.set_name ("EditGroupList");
236 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
237 favorite_plugins_display.set_reorderable (false);
238 favorite_plugins_display.set_headers_visible (true);
239 favorite_plugins_display.set_rules_hint (true);
240 favorite_plugins_display.set_can_focus (false);
241 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
242 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
243 favorite_plugins_display.add_drop_targets (target_list);
244 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
245 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
246 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
247 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
248 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
249 if (UIConfiguration::instance().get_use_tooltips()) {
250 favorite_plugins_display.set_tooltip_column (0);
252 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
254 favorite_plugins_scroller.add (favorite_plugins_display);
255 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
257 favorite_plugins_frame.set_name ("BaseFrame");
258 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
259 favorite_plugins_frame.add (favorite_plugins_vbox);
261 favorite_plugins_vbox.pack_start (favorite_plugins_scroller, true, true);
262 favorite_plugins_vbox.pack_start (favorite_plugins_tag_combo, false, false);
263 favorite_plugins_tag_combo.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::tag_combo_changed));
265 rhs_pane1.add (favorite_plugins_frame);
266 rhs_pane1.add (track_display_frame);
268 rhs_pane2.add (rhs_pane1);
269 rhs_pane2.add (group_display_frame);
271 list_vpacker.pack_start (rhs_pane2, true, true);
273 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
274 vca_vpacker.pack_start (vca_label_bar, false, false);
276 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
277 vca_scroller_base.set_name (X_("MixerWindow"));
278 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
280 vca_hpacker.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_vca_scroll_event), false);
281 vca_scroller.add (vca_hpacker);
282 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
283 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
285 vca_vpacker.pack_start (vca_scroller, true, true);
287 inner_pane.add (scroller);
288 inner_pane.add (vca_vpacker);
290 global_hpacker.pack_start (inner_pane, true, true);
291 global_hpacker.pack_start (out_packer, false, false);
293 list_hpane.set_check_divider_position (true);
294 list_hpane.add (list_vpacker);
295 list_hpane.add (global_hpacker);
296 list_hpane.set_child_minsize (list_vpacker, 30);
298 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
301 if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) {
304 rhs_pane1.set_divider (0, fract);
306 if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
309 rhs_pane2.set_divider (0, fract);
311 if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
314 list_hpane.set_divider (0, fract);
316 if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
319 inner_pane.set_divider (0, fract);
321 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
322 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
323 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
324 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
326 _content.pack_start (list_hpane, true, true);
331 _content.set_name ("MixerWindow");
333 global_hpacker.show();
335 scroller_base.show();
336 scroller_hpacker.show();
337 mixer_scroller_vpacker.show();
339 group_display_button_label.show();
340 group_display_scroller.show();
341 favorite_plugins_scroller.show();
342 group_display_vbox.show();
343 group_display_frame.show();
344 favorite_plugins_frame.show();
352 vca_label_bar.show();
354 vca_scroller_base.show();
357 group_display.show();
358 favorite_plugins_display.show();
361 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
363 _monitor_section.tearoff().set_state (*mnode);
366 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
367 VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
371 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
373 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
374 _plugin_selector = new PluginSelector (PluginManager::instance ());
376 #error implement deferred Plugin-Favorite list
379 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
380 PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
381 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
384 Mixer_UI::~Mixer_UI ()
386 monitor_section_detached ();
389 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
391 if (foldback_strip) {
392 delete foldback_strip;
396 delete _plugin_selector;
400 struct MixerStripSorter {
401 bool operator() (const MixerStrip* ms_a, const MixerStrip* ms_b)
403 boost::shared_ptr<ARDOUR::Stripable> const& a = ms_a->stripable ();
404 boost::shared_ptr<ARDOUR::Stripable> const& b = ms_b->stripable ();
405 return ARDOUR::Stripable::Sorter(true)(a, b);
417 Mixer_UI::tag_combo_changed ()
419 refill_favorite_plugins();
423 Mixer_UI::use_own_window (bool and_fill_it)
425 bool new_window = !own_window();
427 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
429 if (win && new_window) {
430 win->set_name ("MixerWindow");
431 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
432 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
433 win->set_data ("ardour-bindings", bindings);
435 if (!win->get_focus()) {
436 /* set focus widget to something, anything */
437 win->set_focus (scroller);
445 Mixer_UI::show_window ()
447 Tabbable::show_window ();
449 /* show/hide group tabs as required */
450 parameter_changed ("show-group-tabs");
452 /* now reset each strips width so the right widgets are shown */
454 TreeModel::Children rows = track_model->children();
455 TreeModel::Children::iterator ri;
457 for (ri = rows.begin(); ri != rows.end(); ++ri) {
458 AxisView* av = (*ri)[stripable_columns.strip];
459 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
463 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
464 /* Fix visibility of mixer strip stuff */
465 ms->parameter_changed (X_("mixer-element-visibility"));
468 /* force focus into main area */
469 scroller_base.grab_focus ();
473 Mixer_UI::remove_master (VCAMasterStrip* vms)
475 if (_session && _session->deletion_in_progress()) {
476 /* its all being taken care of */
480 TreeModel::Children rows = track_model->children();
481 TreeModel::Children::iterator ri;
483 for (ri = rows.begin(); ri != rows.end(); ++ri) {
484 if ((*ri)[stripable_columns.strip] == vms) {
485 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
486 track_model->erase (ri);
493 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
495 using namespace Menu_Helpers;
497 if (Keyboard::is_context_menu_event (ev)) {
498 ARDOUR_UI::instance()->add_route ();
506 Mixer_UI::new_masters_created ()
508 ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane")->set_active (true);
512 Mixer_UI::add_masters (VCAList& vlist)
516 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
517 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
524 Mixer_UI::add_routes (RouteList& rlist)
528 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
536 Mixer_UI::add_stripables (StripableList& slist)
538 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
539 bool from_scratch = (track_model->children().size() == 0);
540 uint32_t nroutes = 0;
542 slist.sort (Stripable::Sorter());
544 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
545 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
553 // XXX what does this special case do?
554 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
563 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
565 track_display.set_model (Glib::RefPtr<ListStore>());
567 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
569 boost::shared_ptr<Route> route;
570 boost::shared_ptr<VCA> vca;
572 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
574 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
576 TreeModel::Row row = *(track_model->append());
578 row[stripable_columns.text] = vca->name();
579 row[stripable_columns.visible] = vms->marked_for_display ();
580 row[stripable_columns.strip] = vms;
581 row[stripable_columns.stripable] = vca;
583 vms->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::vca_button_release_event), vms));
585 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
587 if (route->is_auditioner()) {
591 if (route->is_monitor()) {
593 out_packer.pack_end (_monitor_section.tearoff(), false, false);
594 _monitor_section.set_session (_session);
595 _monitor_section.tearoff().show_all ();
597 _monitor_section.tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
598 _monitor_section.tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
600 if (_monitor_section.tearoff().torn_off()) {
601 monitor_section_detached ();
603 monitor_section_attached ();
606 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
608 /* no regular strip shown for control out */
612 if (route->is_foldbackbus ()) {
613 if (foldback_strip) {
614 foldback_strip->set_route (route);
616 foldback_strip = new FoldbackStrip (*this, _session, route);
617 out_packer.pack_end (*foldback_strip, false, false);
618 foldback_strip->set_packed (true);
624 strip = new MixerStrip (*this, _session, route);
625 strips.push_back (strip);
627 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
629 if (strip->width_owner() != strip) {
630 strip->set_width_enum (_strip_width, this);
635 if (route->is_master()) {
637 out_packer.pack_start (*strip, false, false);
638 strip->set_packed (true);
642 TreeModel::Row row = *(track_model->insert (insert_iter));
644 row[stripable_columns.text] = route->name();
645 row[stripable_columns.visible] = strip->marked_for_display();
646 row[stripable_columns.stripable] = route;
647 row[stripable_columns.strip] = strip;
650 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
651 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
654 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
655 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
658 } catch (const std::exception& e) {
659 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
662 track_display.set_model (track_model);
664 /* catch up on selection state, which we left to the editor to set */
665 sync_treeview_from_presentation_info (PropertyChange (Properties::selected));
668 sync_presentation_info_from_treeview ();
671 redisplay_track_list ();
675 Mixer_UI::deselect_all_strip_processors ()
677 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
678 (*i)->deselect_all_processors();
683 Mixer_UI::select_none ()
685 _selection.clear_routes();
686 deselect_all_strip_processors();
690 Mixer_UI::select_next_strip ()
692 deselect_all_strip_processors();
693 _session->selection().select_next_stripable (true, false);
697 Mixer_UI::select_prev_strip ()
699 deselect_all_strip_processors();
700 _session->selection().select_prev_stripable (true, false);
704 Mixer_UI::delete_processors ()
706 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
707 (*i)->delete_processors();
713 Mixer_UI::remove_strip (MixerStrip* strip)
715 if (_session && _session->deletion_in_progress()) {
716 /* its all being taken care of */
720 TreeModel::Children rows = track_model->children();
721 TreeModel::Children::iterator ri;
722 list<MixerStrip *>::iterator i;
724 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
728 PBD::Unwinder<bool> uwi (ignore_reorder, true);
730 for (ri = rows.begin(); ri != rows.end(); ++ri) {
731 if ((*ri)[stripable_columns.strip] == strip) {
732 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
733 track_model->erase (ri);
740 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
742 if (what_changed.contains (Properties::selected)) {
743 _selection.presentation_info_changed (what_changed);
747 soh.add (Properties::selected);
748 soh.add (Properties::order);
749 soh.add (Properties::hidden);
751 if (what_changed.contains (soh)) {
752 sync_treeview_from_presentation_info (what_changed);
757 Mixer_UI::sync_presentation_info_from_treeview ()
759 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
763 TreeModel::Children rows = track_model->children();
769 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
771 TreeModel::Children::iterator ri;
774 PresentationInfo::order_t master_key = _session->master_order_key ();
775 PresentationInfo::order_t order = 0;
777 PresentationInfo::ChangeSuspender cs;
779 for (ri = rows.begin(); ri != rows.end(); ++ri) {
780 bool visible = (*ri)[stripable_columns.visible];
781 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
783 #ifndef NDEBUG // these should not exist in the mixer's treeview
788 if (stripable->is_monitor() || stripable->is_auditioner()) {
792 if (stripable->is_master()) {
798 stripable->presentation_info().set_hidden (!visible);
800 // leave master where it is.
801 if (order == master_key) {
805 if (order != stripable->presentation_info().order()) {
806 stripable->set_presentation_order (order);
812 change |= _session->ensure_stripable_sort_order ();
815 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
816 _session->set_dirty();
821 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
823 if (!_session || _session->deletion_in_progress()) {
827 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
829 /* we could get here after either a change in the Mixer or Editor sort
830 * order, but either way, the mixer order keys reflect the intended
831 * order for the GUI, so reorder the treeview model to match it.
834 vector<int> neworder;
835 TreeModel::Children rows = track_model->children();
836 uint32_t old_order = 0;
837 bool changed = false;
843 TreeOrderKeys sorted;
844 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
845 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
846 sorted.push_back (TreeOrderKey (old_order, stripable));
849 TreeOrderKeySorter cmp;
851 sort (sorted.begin(), sorted.end(), cmp);
852 neworder.assign (sorted.size(), 0);
856 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
858 neworder[n] = sr->old_display_order;
860 if (sr->old_display_order != n) {
866 Unwinder<bool> uw (ignore_reorder, true);
867 track_model->reorder (neworder);
870 if (what_changed.contains (Properties::selected)) {
872 PresentationInfo::ChangeSuspender cs;
874 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
875 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
876 if (stripable && stripable->is_selected()) {
879 _selection.remove (*i);
883 if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) {
884 move_stripable_into_view ((*_selection.axes.begin())->stripable());
887 TreeModel::Children rows = track_model->children();
888 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
889 AxisView* av = (*i)[stripable_columns.strip];
890 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
894 if (vms->vca() && vms->vca()->is_selected()) {
895 _selection.add (vms);
897 _selection.remove (vms);
902 redisplay_track_list ();
907 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
909 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
910 if ((*i)->route() == r) {
919 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
921 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
922 if ((*i)->stripable() == s) {
931 Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
933 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
934 if ((*i)->stripable() == s) {
939 TreeModel::Children rows = track_model->children();
940 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
941 AxisView* av = (*i)[stripable_columns.strip];
942 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
943 if (vms && vms->stripable () == s) {
952 Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
954 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
955 if ((*i)->control() == c) {
964 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
966 /* Selecting a mixer-strip may also select grouped-tracks, and
967 * presentation_info_changed() being emitted and
968 * _selection.axes.begin() is being moved into view. This may
969 * effectively move the track that was clicked-on out of view.
971 * So here only the track that is actually clicked-on is moved into
972 * view (in case it's partially visible)
974 PBD::Unwinder<bool> uw (_strip_selection_change_without_scroll, true);
975 move_stripable_into_view (strip->stripable());
977 if (ev->button == 1) {
978 if (_selection.selected (strip)) {
979 /* primary-click: toggle selection state of strip */
980 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
981 _selection.remove (strip, true);
982 } else if (_selection.axes.size() > 1) {
983 /* de-select others */
984 _selection.set (strip);
986 PublicEditor& pe = PublicEditor::instance();
987 TimeAxisView* tav = pe.time_axis_view_from_stripable (strip->stripable());
989 pe.set_selected_mixer_strip (*tav);
992 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
993 _selection.add (strip, true);
994 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
996 /* extend selection */
998 vector<MixerStrip*> tmp;
999 bool accumulate = false;
1000 bool found_another = false;
1002 strips.sort (MixerStripSorter());
1004 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1005 MixerStrip* ms = *i;
1009 /* hit clicked strip, start accumulating till we hit the first
1018 } else if (_selection.selected (ms)) {
1019 /* hit selected strip. if currently accumulating others,
1020 we're done. if not accumulating others, start doing so.
1022 found_another = true;
1036 tmp.push_back (strip);
1038 if (found_another) {
1039 PresentationInfo::ChangeSuspender cs;
1040 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
1041 _selection.add (*i, true);
1044 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
1047 _selection.set (strip);
1056 Mixer_UI::vca_button_release_event (GdkEventButton *ev, VCAMasterStrip *strip)
1058 _selection.set (strip);
1063 Mixer_UI::set_session (Session* sess)
1065 SessionHandlePtr::set_session (sess);
1066 _monitor_section.set_session (sess);
1068 if (_plugin_selector) {
1069 _plugin_selector->set_session (_session);
1072 _group_tabs->set_session (sess);
1075 _selection.clear ();
1079 refill_favorite_plugins();
1082 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1083 set_state (*node, 0);
1087 initial_track_display ();
1089 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1090 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1091 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1092 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1093 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1094 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1095 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1097 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1098 _session->vca_manager().VCACreated.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::new_masters_created, this), gui_context());
1100 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1102 route_groups_changed ();
1108 /* catch up on selection state, etc. */
1111 sc.add (Properties::selected);
1112 _selection.presentation_info_changed (sc);
1118 Mixer_UI::session_going_away ()
1120 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1122 _in_group_rebuild_or_clear = true;
1123 group_model->clear ();
1124 _in_group_rebuild_or_clear = false;
1126 _selection.clear ();
1127 track_model->clear ();
1129 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1133 _monitor_section.tearoff().hide_visible ();
1135 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1137 if (foldback_strip) {
1138 delete foldback_strip;
1143 monitor_section_detached ();
1149 SessionHandlePtr::session_going_away ();
1156 Mixer_UI::track_visibility_changed (std::string const & path)
1158 if (_session && _session->deletion_in_progress()) {
1164 if ((iter = track_model->get_iter (path))) {
1166 AxisView* av = (*iter)[stripable_columns.strip];
1167 bool visible = (*iter)[stripable_columns.visible];
1169 if (av->set_marked_for_display (!visible)) {
1170 update_track_visibility ();
1176 Mixer_UI::update_track_visibility ()
1178 TreeModel::Children rows = track_model->children();
1179 TreeModel::Children::iterator i;
1182 Unwinder<bool> uw (no_track_list_redisplay, true);
1184 for (i = rows.begin(); i != rows.end(); ++i) {
1185 AxisView* av = (*i)[stripable_columns.strip];
1186 (*i)[stripable_columns.visible] = av->marked_for_display ();
1189 /* force presentation catch up with visibility changes
1192 sync_presentation_info_from_treeview ();
1195 redisplay_track_list ();
1199 Mixer_UI::show_strip (MixerStrip* ms)
1201 TreeModel::Children rows = track_model->children();
1202 TreeModel::Children::iterator i;
1204 for (i = rows.begin(); i != rows.end(); ++i) {
1206 AxisView* av = (*i)[stripable_columns.strip];
1207 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1209 (*i)[stripable_columns.visible] = true;
1210 av->set_marked_for_display (true);
1211 update_track_visibility ();
1218 Mixer_UI::hide_strip (MixerStrip* ms)
1220 TreeModel::Children rows = track_model->children();
1221 TreeModel::Children::iterator i;
1223 for (i = rows.begin(); i != rows.end(); ++i) {
1225 AxisView* av = (*i)[stripable_columns.strip];
1226 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1228 (*i)[stripable_columns.visible] = false;
1229 av->set_marked_for_display (false);
1230 update_track_visibility ();
1237 Mixer_UI::start_updating ()
1239 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1244 Mixer_UI::stop_updating ()
1246 fast_screen_update_connection.disconnect();
1251 Mixer_UI::fast_update_strips ()
1253 if (_content.is_mapped () && _session) {
1254 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1255 (*i)->fast_update ();
1261 Mixer_UI::set_all_strips_visibility (bool yn)
1263 TreeModel::Children rows = track_model->children();
1264 TreeModel::Children::iterator i;
1267 Unwinder<bool> uw (no_track_list_redisplay, true);
1269 for (i = rows.begin(); i != rows.end(); ++i) {
1271 AxisView* av = (*i)[stripable_columns.strip];
1272 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1278 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1282 (*i)[stripable_columns.visible] = yn;
1286 redisplay_track_list ();
1291 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1293 TreeModel::Children rows = track_model->children();
1294 TreeModel::Children::iterator i;
1297 Unwinder<bool> uw (no_track_list_redisplay, true);
1299 for (i = rows.begin(); i != rows.end(); ++i) {
1301 AxisView* av = (*i)[stripable_columns.strip];
1302 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1308 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1312 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1313 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1317 (*i)[stripable_columns.visible] = yn;
1321 if (at) { /* track */
1322 (*i)[stripable_columns.visible] = yn;
1327 if (!at && !mt) { /* bus */
1328 (*i)[stripable_columns.visible] = yn;
1333 if (mt) { /* midi-track */
1334 (*i)[stripable_columns.visible] = yn;
1341 redisplay_track_list ();
1345 Mixer_UI::hide_all_routes ()
1347 set_all_strips_visibility (false);
1351 Mixer_UI::show_all_routes ()
1353 set_all_strips_visibility (true);
1357 Mixer_UI::show_all_audiobus ()
1359 set_all_audio_midi_visibility (2, true);
1362 Mixer_UI::hide_all_audiobus ()
1364 set_all_audio_midi_visibility (2, false);
1368 Mixer_UI::show_all_audiotracks()
1370 set_all_audio_midi_visibility (1, true);
1373 Mixer_UI::hide_all_audiotracks ()
1375 set_all_audio_midi_visibility (1, false);
1379 Mixer_UI::show_all_miditracks()
1381 set_all_audio_midi_visibility (3, true);
1384 Mixer_UI::hide_all_miditracks ()
1386 set_all_audio_midi_visibility (3, false);
1390 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1392 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1393 sync_presentation_info_from_treeview ();
1397 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1399 /* this happens as the second step of a DnD within the treeview as well
1400 as when a row/route is actually deleted.
1402 if it was a deletion then we have to force a redisplay because
1403 order keys may not have changed.
1406 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1407 sync_presentation_info_from_treeview ();
1409 if (_route_deletion_in_progress) {
1410 redisplay_track_list ();
1415 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1417 TreeModel::Children rows = track_model->children();
1418 std::list<boost::shared_ptr<VCA> > vcas;
1419 vcas.push_back (vca);
1421 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1422 AxisView* av = (*i)[stripable_columns.strip];
1423 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1424 if (vms && vms->vca()->slaved_to (vca)) {
1425 vcas.push_back (vms->vca());
1429 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1431 AxisView* av = (*i)[stripable_columns.strip];
1432 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1433 bool const visible = (*i)[stripable_columns.visible];
1436 /* we're in the middle of changing a row, don't worry */
1440 if (!strip->route()) {
1441 /* non-route element */
1445 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1449 bool slaved = false;
1450 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1451 if (strip->route()->slaved_to (*m)) {
1457 if (slaved && visible) {
1459 if (strip->packed()) {
1460 strip_packer.reorder_child (*strip, -1); /* put at end */
1462 strip_packer.pack_start (*strip, false, false);
1463 strip->set_packed (true);
1468 if (strip->packed()) {
1469 strip_packer.remove (*strip);
1470 strip->set_packed (false);
1477 Mixer_UI::redisplay_track_list ()
1479 if (no_track_list_redisplay) {
1483 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1485 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1487 if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) {
1488 _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value();
1490 spill_redisplay (sv);
1495 TreeModel::Children rows = track_model->children();
1496 TreeModel::Children::iterator i;
1497 uint32_t n_masters = 0;
1499 container_clear (vca_hpacker);
1501 vca_hpacker.pack_end (vca_scroller_base, true, true);
1502 vca_hpacker.pack_end (add_vca_button, false, false);
1504 add_vca_button.show ();
1505 vca_scroller_base.show();
1507 for (i = rows.begin(); i != rows.end(); ++i) {
1509 AxisView* s = (*i)[stripable_columns.strip];
1510 bool const visible = (*i)[stripable_columns.visible];
1511 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1514 /* we're in the middle of changing a row, don't worry */
1518 VCAMasterStrip* vms;
1520 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1522 vca_hpacker.pack_start (*vms, false, false);
1529 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1537 if (strip->packed()) {
1538 strip_packer.reorder_child (*strip, -1); /* put at end */
1540 strip_packer.pack_start (*strip, false, false);
1541 strip->set_packed (true);
1546 if (stripable->is_master() || stripable->is_monitor()) {
1547 /* do nothing, these cannot be hidden */
1549 if (strip->packed()) {
1550 strip_packer.remove (*strip);
1551 strip->set_packed (false);
1557 /* update visibility of VCA assign buttons */
1559 if (n_masters == 0) {
1560 //show/hide the channelstrip VCA assign buttons on channelstrips:
1561 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1563 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleVCAPane");
1565 act->set_sensitive (false);
1568 //remove the VCA packer, but don't change our prior setting for show/hide:
1569 vca_vpacker.hide ();
1571 //show/hide the channelstrip VCA assign buttons on channelstrips:
1572 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1574 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
1575 act->set_sensitive (true);
1577 //if we were showing VCAs before, show them now:
1578 showhide_vcas (act->get_active ());
1581 _group_tabs->set_dirty ();
1583 if (_spill_scroll_position > 0 && scroller.get_hscrollbar()) {
1584 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1585 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), _spill_scroll_position)));
1587 _spill_scroll_position = 0;
1592 Mixer_UI::strip_width_changed ()
1594 _group_tabs->set_dirty ();
1597 TreeModel::Children rows = track_model->children();
1598 TreeModel::Children::iterator i;
1601 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1602 AxisView* av = (*i)[stripable_columns.strip];
1603 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1609 bool visible = (*i)[stripable_columns.visible];
1612 strip->queue_draw();
1619 struct PresentationInfoMixerSorter
1621 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1622 if (a->is_master()) {
1623 /* master after everything else */
1625 } else if (b->is_master()) {
1626 /* everything else before master */
1629 return a->presentation_info().order () < b->presentation_info().order ();
1634 Mixer_UI::initial_track_display ()
1638 _session->get_stripables (sl);
1639 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1641 boost::shared_ptr<ARDOUR::Stripable> _current_foldback = *(fb.begin());
1642 sl.push_back (_current_foldback);
1645 sl.sort (PresentationInfoMixerSorter());
1648 /* These are also used inside ::add_stripables() but we need
1649 * them here because we're going to clear the track_model also.
1651 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1652 Unwinder<bool> uw2 (ignore_reorder, true);
1654 track_model->clear ();
1655 add_stripables (sl);
1658 sync_treeview_from_presentation_info (Properties::order);
1662 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1664 if (Keyboard::is_context_menu_event (ev)) {
1665 if (track_menu == 0) {
1666 build_track_menu ();
1668 track_menu->popup (ev->button, ev->time);
1671 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1672 TreeModel::Path path;
1673 TreeViewColumn* column;
1675 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1676 TreeIter iter = track_model->get_iter (path);
1677 if ((*iter)[stripable_columns.visible]) {
1678 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1679 move_stripable_into_view (s);
1688 Mixer_UI::move_vca_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1690 if (!vca_scroller.get_hscrollbar()) {
1696 Gtk::Allocation alloc;
1698 TreeModel::Children rows = track_model->children();
1699 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1700 AxisView* av = (*i)[stripable_columns.strip];
1701 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1702 if (vms && vms->stripable () == s) {
1705 vms->translate_coordinates (vca_hpacker, 0, 0, x0, y);
1706 alloc = vms->get_allocation ();
1715 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
1717 if (x0 < adj->get_value()) {
1718 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1719 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1720 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1721 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1726 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1728 if (!scroller.get_hscrollbar()) {
1731 if (s->presentation_info().special ()) {
1734 if (s->presentation_info().flag_match (PresentationInfo::VCA)) {
1735 move_vca_into_view (s);
1744 Gtk::Allocation alloc;
1745 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1746 if ((*i)->route() == s) {
1749 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1750 alloc = (*i)->get_allocation ();
1758 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1760 if (x0 < adj->get_value()) {
1761 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1762 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1763 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1764 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1769 Mixer_UI::build_track_menu ()
1771 using namespace Menu_Helpers;
1772 using namespace Gtk;
1774 track_menu = new Menu;
1775 track_menu->set_name ("ArdourContextMenu");
1776 MenuList& items = track_menu->items();
1778 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1779 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1780 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1781 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1782 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1783 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1784 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1785 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1790 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1792 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1796 boost::shared_ptr<Stripable> s = ws.lock ();
1802 TreeModel::Children rows = track_model->children();
1803 TreeModel::Children::iterator i;
1805 for (i = rows.begin(); i != rows.end(); ++i) {
1806 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1810 if (what_changed.contains (ARDOUR::Properties::name)) {
1811 (*i)[stripable_columns.text] = s->name();
1814 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1815 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1816 redisplay_track_list ();
1823 if (s->is_master ()) {
1827 error << _("track display list item for renamed strip not found!") << endmsg;
1831 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1833 TreeModel::Path path;
1834 TreeViewColumn* column;
1838 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1839 if (ev->button == 3) {
1840 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1845 TreeIter iter = group_model->get_iter (path);
1847 if (ev->button == 3) {
1848 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1853 RouteGroup* group = (*iter)[group_columns.group];
1855 if (Keyboard::is_context_menu_event (ev)) {
1856 _group_tabs->get_menu(group)->popup (1, ev->time);
1860 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1862 if (Keyboard::is_edit_event (ev)) {
1864 // edit_route_group (group);
1866 group_display.queue_draw();
1875 bool visible = (*iter)[group_columns.visible];
1876 (*iter)[group_columns.visible] = !visible;
1878 group_display.queue_draw();
1891 Mixer_UI::activate_all_route_groups ()
1893 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1897 Mixer_UI::disable_all_route_groups ()
1899 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1903 Mixer_UI::route_groups_changed ()
1905 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1907 _in_group_rebuild_or_clear = true;
1909 /* just rebuild the while thing */
1911 group_model->clear ();
1914 /* this is currently not used,
1915 * Mixer_UI::group_display_button_press() has a case for it,
1916 * and a commented edit_route_group() but that's n/a since 2011.
1918 * This code is left as reminder that
1919 * row[group_columns.group] = 0 has special meaning.
1923 row = *(group_model->append());
1924 row[group_columns.visible] = true;
1925 row[group_columns.text] = (_("-all-"));
1926 row[group_columns.group] = 0;
1930 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1932 _group_tabs->set_dirty ();
1933 _in_group_rebuild_or_clear = false;
1937 Mixer_UI::new_route_group ()
1939 _group_tabs->run_new_group_dialog (0, false);
1943 Mixer_UI::remove_selected_route_group ()
1945 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1946 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1952 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1955 /* selection mode is single, so rows.begin() is it */
1957 if ((iter = group_model->get_iter (*i))) {
1959 RouteGroup* rg = (*iter)[group_columns.group];
1962 _session->remove_route_group (*rg);
1968 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1970 if (in_group_row_change) {
1974 /* force an update of any mixer strips that are using this group,
1975 otherwise mix group names don't change in mixer strips
1978 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1979 if ((*i)->route_group() == group) {
1980 (*i)->route_group_changed();
1984 TreeModel::iterator i;
1985 TreeModel::Children rows = group_model->children();
1986 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1988 in_group_row_change = true;
1990 for (i = rows.begin(); i != rows.end(); ++i) {
1991 if ((*i)[group_columns.group] == group) {
1992 (*i)[group_columns.visible] = !group->is_hidden ();
1993 (*i)[group_columns.text] = group->name ();
1998 in_group_row_change = false;
2000 if (change.contains (Properties::name)) {
2001 _group_tabs->set_dirty ();
2004 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
2005 if ((*j)->route_group() == group) {
2006 if (group->is_hidden ()) {
2016 Mixer_UI::toggle_mixer_list ()
2018 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2019 showhide_mixer_list (act->get_active());
2023 Mixer_UI::showhide_mixer_list (bool yn)
2026 list_vpacker.show ();
2028 list_vpacker.hide ();
2033 Mixer_UI::toggle_monitor_section ()
2035 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2036 showhide_monitor_section (act->get_active());
2041 Mixer_UI::showhide_monitor_section (bool yn)
2043 if (monitor_section().tearoff().torn_off()) {
2048 monitor_section().tearoff().show();
2050 monitor_section().tearoff().hide();
2055 Mixer_UI::toggle_vcas ()
2057 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2058 showhide_vcas (act->get_active());
2062 Mixer_UI::showhide_vcas (bool yn)
2073 Mixer_UI::toggle_mixbuses ()
2075 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2076 showhide_mixbuses (act->get_active());
2080 Mixer_UI::showhide_mixbuses (bool on)
2092 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
2097 if ((iter = group_model->get_iter (path))) {
2099 if ((group = (*iter)[group_columns.group]) == 0) {
2103 if (new_text != group->name()) {
2104 group->set_name (new_text);
2110 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
2114 if (in_group_row_change) {
2118 if ((group = (*iter)[group_columns.group]) == 0) {
2122 std::string name = (*iter)[group_columns.text];
2124 if (name != group->name()) {
2125 group->set_name (name);
2128 bool hidden = !(*iter)[group_columns.visible];
2130 if (hidden != group->is_hidden ()) {
2131 group->set_hidden (hidden, this);
2135 /** Called when a group model row is deleted, but also when the model is
2136 * reordered by a user drag-and-drop; the latter is what we are
2137 * interested in here.
2140 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
2142 if (_in_group_rebuild_or_clear) {
2146 /* Re-write the session's route group list so that the new order is preserved */
2148 list<RouteGroup*> new_list;
2150 Gtk::TreeModel::Children children = group_model->children();
2151 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
2152 RouteGroup* g = (*i)[group_columns.group];
2154 new_list.push_back (g);
2158 _session->reorder_route_groups (new_list);
2163 Mixer_UI::add_route_group (RouteGroup* group)
2165 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
2168 in_group_row_change = true;
2170 TreeModel::Row row = *(group_model->append());
2171 row[group_columns.visible] = !group->is_hidden ();
2172 row[group_columns.group] = group;
2173 if (!group->name().empty()) {
2174 row[group_columns.text] = group->name();
2176 row[group_columns.text] = _("unnamed");
2180 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
2183 TreeViewColumn* col = group_display.get_column (0);
2184 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
2185 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
2188 _group_tabs->set_dirty ();
2190 in_group_row_change = false;
2194 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
2196 using namespace Menu_Helpers;
2198 if (Keyboard::is_context_menu_event (ev)) {
2199 ARDOUR_UI::instance()->add_route ();
2207 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
2209 if (data.get_target() != "PluginFavoritePtr") {
2210 context->drag_finish (false, false, time);
2214 const void * d = data.get_data();
2215 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2217 PluginPresetList nfos;
2219 tv->get_object_drag_data (nfos, &source);
2221 Route::ProcessorList pl;
2224 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2225 PluginPresetPtr ppp = (*i);
2226 PluginInfoPtr pip = ppp->_pip;
2227 if (!pip->is_instrument ()) {
2230 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);
2234 context->drag_finish (ok, false, time);
2238 Mixer_UI::set_strip_width (Width w, bool save)
2242 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2243 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2248 struct PluginStateSorter {
2250 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2251 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2252 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2253 if (aiter != _user.end() && biter != _user.end()) {
2254 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2256 if (aiter != _user.end()) {
2259 if (biter != _user.end()) {
2262 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2265 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2267 std::list<std::string> _user;
2271 Mixer_UI::set_state (const XMLNode& node, int version)
2275 Tabbable::set_state (node, version);
2277 if (node.get_property ("narrow-strips", yn)) {
2279 set_strip_width (Narrow);
2281 set_strip_width (Wide);
2285 node.get_property ("show-mixer", _visible);
2288 node.get_property ("maximised", yn);
2290 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Common"), X_("ToggleMaximalMixer"));
2291 bool fs = act && act->get_active();
2293 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2298 node.get_property ("show-mixer-list", yn);
2300 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixerList"));
2301 /* do it twice to force the change */
2302 act->set_active (!yn);
2303 act->set_active (yn);
2307 node.get_property ("monitor-section-visible", yn);
2309 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection"));
2310 /* do it twice to force the change */
2311 act->set_active (!yn);
2312 act->set_active (yn);
2316 node.get_property ("show-vca-pane", yn);
2318 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleVCAPane"));
2319 /* do it twice to force the change */
2320 act->set_active (!yn);
2321 act->set_active (yn);
2326 node.get_property ("show-mixbus-pane", yn);
2328 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixbusPane"));
2329 /* do it twice to force the change */
2330 act->set_active (!yn);
2331 act->set_active (yn);
2335 //check for the user's plugin_order file
2336 XMLNode plugin_order_new(X_("PO"));
2337 if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) {
2338 store_current_favorite_order ();
2339 std::list<string> order;
2340 const XMLNodeList& kids = plugin_order_new.children("PluginInfo");
2341 XMLNodeConstIterator i;
2342 for (i = kids.begin(); i != kids.end(); ++i) {
2343 std::string unique_id;
2344 if ((*i)->get_property ("unique-id", unique_id)) {
2345 order.push_back (unique_id);
2346 if ((*i)->get_property ("expanded", yn)) {
2347 favorite_ui_state[unique_id] = yn;
2351 PluginStateSorter cmp (order);
2352 favorite_order.sort (cmp);
2353 sync_treeview_from_favorite_order ();
2356 //if there is no user file, then use an existing one from instant.xml
2357 //NOTE: if you are loading an old session, this might come from the session's instant.xml
2358 //Todo: in the next major version, we should probably stop doing the instant.xml check, and just use the new file
2359 XMLNode* plugin_order;
2360 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2361 store_current_favorite_order ();
2362 std::list<string> order;
2363 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2364 XMLNodeConstIterator i;
2365 for (i = kids.begin(); i != kids.end(); ++i) {
2366 std::string unique_id;
2367 if ((*i)->get_property ("unique-id", unique_id)) {
2368 order.push_back (unique_id);
2369 if ((*i)->get_property ("expanded", yn)) {
2370 favorite_ui_state[unique_id] = yn;
2375 PluginStateSorter cmp (order);
2376 favorite_order.sort (cmp);
2377 sync_treeview_from_favorite_order ();
2385 Mixer_UI::save_plugin_order_file ()
2387 //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order )
2389 //NOTE: this replaces the old code that stores info in instant.xml
2390 //why? because instant.xml prefers the per-session settings, and we want this to be a global pref
2392 store_current_favorite_order ();
2393 XMLNode plugin_order ("PluginOrder");
2395 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2396 XMLNode* p = new XMLNode ("PluginInfo");
2397 p->set_property ("sort", cnt);
2398 p->set_property ("unique-id", (*i)->unique_id);
2399 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2400 p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2402 plugin_order.add_child_nocopy (*p);
2404 PluginManager::instance().save_plugin_order_file( plugin_order );
2408 Mixer_UI::get_state ()
2410 XMLNode* node = new XMLNode (X_("Mixer"));
2412 node->add_child_nocopy (Tabbable::get_state());
2414 node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider());
2415 node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider());
2416 node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider());
2417 node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider());
2419 node->set_property ("narrow-strips", (_strip_width == Narrow));
2420 node->set_property ("show-mixer", _visible);
2421 node->set_property ("maximised", _maximised);
2423 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2424 node->set_property ("show-mixer-list", act->get_active ());
2426 act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2427 node->set_property ("monitor-section-visible", act->get_active ());
2429 act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2430 node->set_property ("show-vca-pane", act->get_active ());
2433 act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2434 node->set_property ("show-mixbus-pane", act->get_active ());
2441 Mixer_UI::scroll_left ()
2443 if (!scroller.get_hscrollbar()) return;
2444 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2445 int sc_w = scroller.get_width();
2446 int sp_w = strip_packer.get_width();
2450 int lp = adj->get_value();
2452 using namespace Gtk::Box_Helpers;
2453 const BoxList& strips = strip_packer.children();
2454 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2455 if (i->get_widget() == & add_button) {
2459 if (i->get_widget() == &mb_shadow) {
2463 lm += i->get_widget()->get_width ();
2465 lm -= i->get_widget()->get_width ();
2469 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2473 Mixer_UI::scroll_right ()
2475 if (!scroller.get_hscrollbar()) return;
2476 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2477 int sc_w = scroller.get_width();
2478 int sp_w = strip_packer.get_width();
2482 int lp = adj->get_value();
2484 using namespace Gtk::Box_Helpers;
2485 const BoxList& strips = strip_packer.children();
2486 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2487 if (i->get_widget() == & add_button) {
2491 if (i->get_widget() == &mb_shadow) {
2495 lm += i->get_widget()->get_width ();
2500 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2504 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2506 switch (ev->direction) {
2507 case GDK_SCROLL_LEFT:
2511 if (ev->state & Keyboard::TertiaryModifier) {
2517 case GDK_SCROLL_RIGHT:
2521 case GDK_SCROLL_DOWN:
2522 if (ev->state & Keyboard::TertiaryModifier) {
2533 Mixer_UI::vca_scroll_left ()
2535 if (!vca_scroller.get_hscrollbar()) return;
2536 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2537 int sc_w = vca_scroller.get_width();
2538 int sp_w = strip_packer.get_width();
2542 int lp = adj->get_value();
2544 using namespace Gtk::Box_Helpers;
2545 const BoxList& strips = vca_hpacker.children();
2546 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2547 if (i->get_widget() == &add_vca_button) {
2550 lm += i->get_widget()->get_width ();
2552 lm -= i->get_widget()->get_width ();
2556 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2560 Mixer_UI::vca_scroll_right ()
2562 if (!vca_scroller.get_hscrollbar()) return;
2563 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2564 int sc_w = vca_scroller.get_width();
2565 int sp_w = strip_packer.get_width();
2569 int lp = adj->get_value();
2571 using namespace Gtk::Box_Helpers;
2572 const BoxList& strips = vca_hpacker.children();
2573 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2574 if (i->get_widget() == &add_vca_button) {
2577 lm += i->get_widget()->get_width ();
2582 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2586 Mixer_UI::on_vca_scroll_event (GdkEventScroll* ev)
2588 switch (ev->direction) {
2589 case GDK_SCROLL_LEFT:
2593 if (ev->state & Keyboard::TertiaryModifier) {
2599 case GDK_SCROLL_RIGHT:
2600 vca_scroll_right ();
2603 case GDK_SCROLL_DOWN:
2604 if (ev->state & Keyboard::TertiaryModifier) {
2605 vca_scroll_right ();
2615 Mixer_UI::parameter_changed (string const & p)
2617 if (p == "show-group-tabs") {
2618 bool const s = _session->config.get_show_group_tabs ();
2620 _group_tabs->show ();
2622 _group_tabs->hide ();
2624 } else if (p == "default-narrow_ms") {
2625 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2626 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2627 (*i)->set_width_enum (s ? Narrow : Wide, this);
2633 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2635 g->set_active (a, this);
2639 Mixer_UI::plugin_selector()
2641 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2642 if (!_plugin_selector)
2643 _plugin_selector = new PluginSelector (PluginManager::instance());
2646 return _plugin_selector;
2650 Mixer_UI::setup_track_display ()
2652 track_model = ListStore::create (stripable_columns);
2653 track_display.set_model (track_model);
2654 track_display.append_column (_("Show"), stripable_columns.visible);
2655 track_display.append_column (_("Strips"), stripable_columns.text);
2656 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2657 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2658 track_display.get_column (0)->set_expand(false);
2659 track_display.get_column (1)->set_expand(true);
2660 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2661 track_display.set_name (X_("EditGroupList"));
2662 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2663 track_display.set_reorderable (true);
2664 track_display.set_headers_visible (true);
2665 track_display.set_can_focus(false);
2667 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2668 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2670 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2671 track_list_visible_cell->property_activatable() = true;
2672 track_list_visible_cell->property_radio() = false;
2673 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2675 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2677 track_display_scroller.add (track_display);
2678 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2680 VBox* v = manage (new VBox);
2682 v->pack_start (track_display_scroller, true, true);
2684 track_display_frame.set_name("BaseFrame");
2685 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2686 track_display_frame.add (*v);
2688 track_display_scroller.show();
2689 track_display_frame.show();
2690 track_display.show();
2694 Mixer_UI::new_track_or_bus ()
2696 ARDOUR_UI::instance()->add_route ();
2700 Mixer_UI::update_title ()
2702 if (!own_window()) {
2709 if (_session->snap_name() != _session->name()) {
2710 n = _session->snap_name ();
2712 n = _session->name ();
2715 if (_session->dirty ()) {
2719 WindowTitle title (n);
2720 title += S_("Window|Mixer");
2721 title += Glib::get_application_name ();
2722 own_window()->set_title (title.get_string());
2726 WindowTitle title (S_("Window|Mixer"));
2727 title += Glib::get_application_name ();
2728 own_window()->set_title (title.get_string());
2733 Mixer_UI::strip_by_x (int x)
2735 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2738 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2739 x2 = x1 + (*i)->get_width();
2741 if (x >= x1 && x <= x2) {
2750 Mixer_UI::set_axis_targets_for_operation ()
2752 _axis_targets.clear ();
2754 if (!_selection.empty()) {
2755 _axis_targets = _selection.axes;
2759 // removed "implicit" selections of strips, after discussion on IRC
2764 Mixer_UI::monitor_section_going_away ()
2766 XMLNode* ui_node = Config->extra_xml(X_("UI"));
2768 /* immediate state save.
2770 * Tearoff settings are otherwise only stored during
2771 * save_ardour_state(). The mon-section may or may not
2772 * exist at that point.
2776 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
2778 tearoff_node->remove_nodes_and_delete (X_("monitor-section"));
2779 XMLNode* t = new XMLNode (X_("monitor-section"));
2780 _monitor_section.tearoff().add_state (*t);
2781 tearoff_node->add_child_nocopy (*t);
2785 monitor_section_detached ();
2786 out_packer.remove (_monitor_section.tearoff());
2790 Mixer_UI::toggle_midi_input_active (bool flip_others)
2792 boost::shared_ptr<RouteList> rl (new RouteList);
2795 set_axis_targets_for_operation ();
2797 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2798 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2802 onoff = !mt->input_active();
2806 _session->set_exclusive_input_active (rl, onoff, flip_others);
2810 Mixer_UI::maximise_mixer_space ()
2812 if (!own_window()) {
2820 _window->fullscreen ();
2825 Mixer_UI::restore_mixer_space ()
2827 if (!own_window()) {
2835 own_window()->unfullscreen();
2840 Mixer_UI::monitor_section_attached ()
2842 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2843 act->set_sensitive (true);
2844 showhide_monitor_section (act->get_active ());
2848 Mixer_UI::monitor_section_detached ()
2850 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleMonitorSection");
2851 act->set_sensitive (false);
2855 Mixer_UI::store_current_favorite_order ()
2857 typedef Gtk::TreeModel::Children type_children;
2858 type_children children = favorite_plugins_model->children();
2859 favorite_order.clear();
2860 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2862 Gtk::TreeModel::Row row = *iter;
2863 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2864 favorite_order.push_back (ppp->_pip);
2865 std::string name = row[favorite_plugins_columns.name];
2866 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2871 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2873 Gtk::TreeModel::Row row = *iter;
2874 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2876 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2880 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2882 PluginManager& manager (PluginManager::instance());
2883 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2885 /* not a Favorite? skip it */
2886 if (manager.get_status (*i) != PluginManager::Favorite) {
2890 /* Check the tag combo selection, and skip this plugin if it doesn't match the selected tag(s) */
2891 string test = favorite_plugins_tag_combo.get_active_text();
2892 if (test != _("Show All")) {
2893 vector<string> tags = manager.get_tags(*i);
2895 //does the selected tag match any of the tags in the plugin?
2896 vector<string>::iterator tt = find (tags.begin(), tags.end(), test);
2897 if (tt == tags.end()) {
2902 result.push_back (*i);
2906 struct PluginCustomSorter {
2908 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2909 PluginInfoList::const_iterator aiter = _user.begin();
2910 PluginInfoList::const_iterator biter = _user.begin();
2911 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2912 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2914 if (aiter != _user.end() && biter != _user.end()) {
2915 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2917 if (aiter != _user.end()) {
2920 if (biter != _user.end()) {
2923 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2925 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2927 PluginInfoList _user;
2931 Mixer_UI::refill_favorite_plugins ()
2933 PluginInfoList plugs;
2934 PluginManager& mgr (PluginManager::instance());
2937 refiller (plugs, mgr.lv2_plugin_info ());
2939 #ifdef WINDOWS_VST_SUPPORT
2940 refiller (plugs, mgr.windows_vst_plugin_info ());
2942 #ifdef LXVST_SUPPORT
2943 refiller (plugs, mgr.lxvst_plugin_info ());
2945 #ifdef MACVST_SUPPORT
2946 refiller (plugs, mgr.mac_vst_plugin_info ());
2948 #ifdef AUDIOUNIT_SUPPORT
2949 refiller (plugs, mgr.au_plugin_info ());
2951 refiller (plugs, mgr.ladspa_plugin_info ());
2952 refiller (plugs, mgr.lua_plugin_info ());
2954 store_current_favorite_order ();
2956 PluginCustomSorter cmp (favorite_order);
2959 favorite_order = plugs;
2961 sync_treeview_from_favorite_order ();
2965 Mixer_UI::plugin_list_changed ()
2967 refill_favorite_plugins();
2972 Mixer_UI::refill_tag_combo ()
2974 PluginManager& mgr (PluginManager::instance());
2976 std::vector<std::string> tags = mgr.get_all_tags (PluginManager::OnlyFavorites);
2978 favorite_plugins_tag_combo.clear();
2979 favorite_plugins_tag_combo.append_text (_("Show All"));
2981 for (vector<string>::iterator t = tags.begin (); t != tags.end (); ++t) {
2982 favorite_plugins_tag_combo.append_text (*t);
2985 favorite_plugins_tag_combo.set_active_text (_("Show All"));
2989 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2992 if (!(iter = favorite_plugins_model->get_iter (path))) {
2995 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2999 PluginInfoPtr pip = ppp->_pip;
3000 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3001 if (favorite_ui_state[pip->unique_id]) {
3002 favorite_plugins_display.expand_row (path, true);
3008 Mixer_UI::sync_treeview_from_favorite_order ()
3010 favorite_plugins_model->clear ();
3011 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
3012 PluginInfoPtr pip = (*i);
3014 TreeModel::Row newrow = *(favorite_plugins_model->append());
3015 newrow[favorite_plugins_columns.name] = (*i)->name;
3016 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
3021 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
3022 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
3026 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
3027 child_row[favorite_plugins_columns.name] = (*j).label;
3028 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
3030 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3031 if (favorite_ui_state[pip->unique_id]) {
3032 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
3039 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
3041 using namespace Gtk::Menu_Helpers;
3043 Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu ();
3044 MenuList& items = m->items ();
3046 if (_selection.axes.empty()) {
3047 items.push_back (MenuElem (_("No Track/Bus is selected.")));
3049 items.push_back (MenuElem (_("Add at the top"),
3050 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
3051 items.push_back (MenuElem (_("Add Pre-Fader"),
3052 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
3053 items.push_back (MenuElem (_("Add Post-Fader"),
3054 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
3055 items.push_back (MenuElem (_("Add at the end"),
3056 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
3059 items.push_back (SeparatorElem());
3061 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
3063 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3064 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
3065 // we cannot currently delete AU presets
3066 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
3067 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
3071 m->popup (ev->button, ev->time);
3075 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
3077 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
3078 TreeModel::Path path;
3079 TreeViewColumn* column;
3081 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
3082 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3084 selection->unselect_all();
3085 selection->select(path);
3088 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3090 popup_note_context_menu (ev);
3098 Mixer_UI::selected_plugin ()
3100 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3102 return PluginPresetPtr();
3104 Gtk::TreeModel::iterator iter = selection->get_selected();
3106 return PluginPresetPtr();
3108 return (*iter)[favorite_plugins_columns.plugin];
3112 Mixer_UI::add_selected_processor (ProcessorPosition pos)
3114 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3116 add_favorite_processor (ppp, pos);
3121 Mixer_UI::delete_selected_preset ()
3126 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3127 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
3130 PluginPtr plugin = ppp->_pip->load (*_session);
3131 plugin->get_presets();
3132 plugin->remove_preset (ppp->_preset.label);
3136 Mixer_UI::remove_selected_from_favorites ()
3138 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3142 PluginManager::PluginStatusType status = PluginManager::Normal;
3143 PluginManager& manager (PluginManager::instance());
3145 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3146 manager.save_statuses ();
3150 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
3153 if (!(iter = favorite_plugins_model->get_iter (path))) {
3156 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3157 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
3161 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
3163 if (!_session || _selection.axes.empty()) {
3167 PluginInfoPtr pip = ppp->_pip;
3168 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
3169 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
3175 PluginPtr p = pip->load (*_session);
3181 if (ppp->_preset.valid) {
3182 p->load_preset (ppp->_preset);
3185 Route::ProcessorStreams err;
3186 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
3190 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
3193 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
3200 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
3204 if (!np->display_to_user()) {
3207 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
3208 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
3213 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
3217 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
3224 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
3226 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
3230 // only allow to re-order top-level items
3232 if (TreePath::get_from_selection_data (data, src)) {
3233 if (src.up() && src.up()) {
3238 // don't allow to drop as child-rows.
3239 Gtk::TreeModel::Path _dest = dest; // un const
3240 const bool is_child = _dest.up (); // explicit bool for clang
3241 if (!is_child || _dest.empty ()) {
3248 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
3250 if (data.get_target() != "PluginPresetPtr") {
3253 if (data.get_length() != sizeof (PluginPresetPtr)) {
3256 const void *d = data.get_data();
3257 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
3259 PluginManager::PluginStatusType status = PluginManager::Favorite;
3260 PluginManager& manager (PluginManager::instance());
3262 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3263 manager.save_statuses ();
3267 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
3269 /* call protected MixerActor:: method */
3274 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
3276 /* call protected MixerActor:: method */
3281 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
3283 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
3286 show_spill_change (s); /* EMIT SIGNAL */
3288 _group_tabs->hide ();
3290 _group_tabs->show ();
3292 redisplay_track_list ();
3297 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
3299 return s == spilled_strip.lock();
3303 Mixer_UI::register_actions ()
3305 Glib::RefPtr<ActionGroup> group = ActionManager::create_action_group (bindings, X_("Mixer"));
3307 ActionManager::register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
3308 ActionManager::register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
3309 ActionManager::register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
3310 ActionManager::register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
3311 ActionManager::register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
3312 ActionManager::register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
3315 ActionManager::register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
3316 ActionManager::register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
3317 ActionManager::register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
3318 ActionManager::register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
3319 ActionManager::register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
3320 ActionManager::register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
3321 ActionManager::register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
3322 ActionManager::register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
3324 ActionManager::register_action (group, "select-next-stripable", _("Select Next Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_next_strip));
3325 ActionManager::register_action (group, "select-prev-stripable", _("Scroll Previous Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_prev_strip));
3327 ActionManager::register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
3328 ActionManager::register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
3330 ActionManager::register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
3331 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
3333 ActionManager::register_toggle_action (group, X_("ToggleMixerList"), _("Mixer: Show Mixer List"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixer_list));
3335 ActionManager::register_toggle_action (group, X_("ToggleVCAPane"), _("Mixer: Show VCAs"), sigc::mem_fun (*this, &Mixer_UI::toggle_vcas));
3338 ActionManager::register_toggle_action (group, X_("ToggleMixbusPane"), _("Mixer: Show Mixbusses"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixbuses));
3341 ActionManager::register_toggle_action (group, X_("ToggleMonitorSection"), _("Mixer: Show Monitor Section"), sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_section));
3345 Mixer_UI::load_bindings ()
3347 bindings = Bindings::get_bindings (X_("Mixer"));
3350 template<class T> void
3351 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
3353 boost::shared_ptr<ControlList> cl (new ControlList);
3354 boost::shared_ptr<AutomationControl> ac;
3356 bool have_val = false;
3358 set_axis_targets_for_operation ();
3360 BOOST_FOREACH(AxisView* r, _axis_targets) {
3361 boost::shared_ptr<Stripable> s = r->stripable();
3363 ac = (s.get()->*get_control)();
3367 val = !ac->get_value();
3374 _session->set_controls (cl, val, Controllable::UseGroup);
3378 Mixer_UI::solo_action ()
3380 control_action (&Stripable::solo_control);
3384 Mixer_UI::mute_action ()
3386 control_action (&Stripable::mute_control);
3390 Mixer_UI::rec_enable_action ()
3392 control_action (&Stripable::rec_enable_control);
3395 AutomationControlSet
3396 Mixer_UI::selected_gaincontrols ()
3398 set_axis_targets_for_operation ();
3399 AutomationControlSet rv;
3400 BOOST_FOREACH(AxisView* r, _axis_targets) {
3401 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3403 boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
3404 ControlList cl (ac->grouped_controls());
3405 for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
3415 Mixer_UI::step_gain_up_action ()
3417 AutomationControlSet acs = selected_gaincontrols ();
3418 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3419 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3421 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
3426 Mixer_UI::step_gain_down_action ()
3428 AutomationControlSet acs = selected_gaincontrols ();
3429 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3430 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3432 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
3437 Mixer_UI::unity_gain_action ()
3439 set_axis_targets_for_operation ();
3441 BOOST_FOREACH(AxisView* r, _axis_targets) {
3442 boost::shared_ptr<Stripable> s = r->stripable();
3444 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3446 ac->set_value (1.0, Controllable::UseGroup);
3453 Mixer_UI::copy_processors ()
3455 set_axis_targets_for_operation ();
3457 BOOST_FOREACH(AxisView* r, _axis_targets) {
3458 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3460 ms->copy_processors ();
3465 Mixer_UI::cut_processors ()
3467 set_axis_targets_for_operation ();
3469 BOOST_FOREACH(AxisView* r, _axis_targets) {
3470 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3472 ms->cut_processors ();
3477 Mixer_UI::paste_processors ()
3479 set_axis_targets_for_operation ();
3481 BOOST_FOREACH(AxisView* r, _axis_targets) {
3482 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3484 ms->paste_processors ();
3489 Mixer_UI::select_all_processors ()
3491 set_axis_targets_for_operation ();
3493 BOOST_FOREACH(AxisView* r, _axis_targets) {
3494 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3496 ms->select_all_processors ();
3501 Mixer_UI::toggle_processors ()
3503 set_axis_targets_for_operation ();
3505 BOOST_FOREACH(AxisView* r, _axis_targets) {
3506 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3508 ms->toggle_processors ();
3513 Mixer_UI::ab_plugins ()
3515 set_axis_targets_for_operation ();
3517 BOOST_FOREACH(AxisView* r, _axis_targets) {
3518 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3526 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3528 set_axis_targets_for_operation ();
3529 BOOST_FOREACH(AxisView* r, _axis_targets) {
3530 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3532 ms->vca_assign (vca);
3538 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3540 set_axis_targets_for_operation ();
3541 BOOST_FOREACH(AxisView* r, _axis_targets) {
3542 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3544 ms->vca_unassign (vca);
3550 Mixer_UI::screenshot (std::string const& filename)
3556 int height = strip_packer.get_height();
3557 bool with_vca = vca_vpacker.is_visible ();
3558 MixerStrip* master = strip_by_route (_session->master_out ());
3560 Gtk::OffscreenWindow osw;
3565 /* unpack widgets, add to OffscreenWindow */
3567 strip_group_box.remove (strip_packer);
3568 b.pack_start (strip_packer, false, false);
3569 /* hide extra elements inside strip_packer */
3571 scroller_base.hide ();
3577 /* work around Gtk::ScrolledWindow */
3578 Gtk::Viewport* viewport = (Gtk::Viewport*) vca_scroller.get_child();
3579 viewport->remove (); // << vca_hpacker
3580 b.pack_start (vca_hpacker, false, false);
3581 /* hide some growing widgets */
3582 add_vca_button.hide ();
3583 vca_scroller_base.hide();
3587 out_packer.remove (*master);
3588 b.pack_start (*master, false, false);
3589 master->hide_master_spacer (true);
3592 /* prepare the OffscreenWindow for rendering */
3593 osw.set_size_request (-1, height);
3595 osw.queue_resize ();
3597 osw.get_window()->process_updates (true);
3599 /* create screenshot */
3600 Glib::RefPtr<Gdk::Pixbuf> pb = osw.get_pixbuf ();
3601 pb->save (filename, "png");
3603 /* unpack elements before destorying the Box & OffscreenWindow */
3604 list<Gtk::Widget*> children = b.get_children();
3605 for (list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
3610 /* now re-pack the widgets into the main mixer window */
3612 scroller_base.show ();
3616 strip_group_box.pack_start (strip_packer);
3618 add_vca_button.show ();
3619 vca_scroller_base.show();
3620 vca_scroller.add (vca_hpacker);
3623 master->hide_master_spacer (false);
3624 out_packer.pack_start (*master, false, false);