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/monitor_control.h"
53 #include "ardour/plugin_manager.h"
54 #include "ardour/route_group.h"
55 #include "ardour/selection.h"
56 #include "ardour/session.h"
57 #include "ardour/vca.h"
58 #include "ardour/vca_manager.h"
60 #include "gtkmm2ext/gtk_ui.h"
61 #include "gtkmm2ext/keyboard.h"
62 #include "gtkmm2ext/utils.h"
63 #include "gtkmm2ext/window_title.h"
64 #include "gtkmm2ext/doi.h"
66 #include "widgets/tearoff.h"
68 #include "foldback_strip.h"
71 #include "mixer_strip.h"
72 #include "monitor_section.h"
73 #include "plugin_selector.h"
74 #include "public_editor.h"
75 #include "mouse_cursors.h"
76 #include "ardour_ui.h"
78 #include "route_sorter.h"
80 #include "gui_thread.h"
81 #include "mixer_group_tabs.h"
82 #include "route_sorter.h"
84 #include "ui_config.h"
85 #include "vca_master_strip.h"
89 using namespace ARDOUR;
90 using namespace ARDOUR_UI_UTILS;
94 using namespace Gtkmm2ext;
100 Mixer_UI* Mixer_UI::_instance = 0;
103 Mixer_UI::instance ()
106 _instance = new Mixer_UI;
112 Mixer_UI::Mixer_UI ()
113 : Tabbable (_content, _("Mixer"))
114 , no_track_list_redisplay (false)
115 , in_group_row_change (false)
117 , _plugin_selector (0)
119 , _show_foldback_strip (true)
120 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
121 , _spill_scroll_position (0)
122 , ignore_reorder (false)
123 , _in_group_rebuild_or_clear (false)
124 , _route_deletion_in_progress (false)
126 , _strip_selection_change_without_scroll (false)
127 , _selection (*this, *this)
131 Glib::RefPtr<ToggleAction> fb_act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
132 fb_act->set_sensitive (false);
134 _content.set_data ("ardour-bindings", bindings);
136 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
138 scroller.set_can_default (true);
139 // set_default (scroller);
141 scroller_base.set_flags (Gtk::CAN_FOCUS);
142 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
143 scroller_base.set_name ("MixerWindow");
144 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
146 /* set up drag-n-drop */
147 vector<TargetEntry> target_table;
148 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
149 scroller_base.drag_dest_set (target_table);
150 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
152 /* create a button to add VCA strips ... will get packed in redisplay_track_list() */
153 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
155 add_vca_button.add (*w);
156 add_vca_button.set_can_focus(false);
157 add_vca_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
159 /* create a button to add mixer strips */
160 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
163 add_button.set_can_focus(false);
164 add_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
166 /* add as last item of strip packer */
167 strip_packer.pack_end (scroller_base, true, true);
168 strip_packer.pack_end (add_button, false, false);
171 /* create a drop-shadow at the end of the mixer strips */
172 mb_shadow.set_size_request( 4, -1 );
173 mb_shadow.set_name("EditorWindow");
175 strip_packer.pack_end (mb_shadow, false, false);
178 _group_tabs = new MixerGroupTabs (this);
179 strip_group_box.set_spacing (0);
180 strip_group_box.set_border_width (0);
181 strip_group_box.pack_start (*_group_tabs, PACK_SHRINK);
182 strip_group_box.pack_start (strip_packer);
183 strip_group_box.show_all ();
184 strip_group_box.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
186 scroller.add (strip_group_box);
187 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
189 setup_track_display ();
191 group_model = ListStore::create (group_columns);
192 group_display.set_model (group_model);
193 group_display.append_column (_("Show"), group_columns.visible);
194 group_display.append_column (_("Group"), group_columns.text);
195 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
196 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
197 group_display.get_column (0)->set_expand(false);
198 group_display.get_column (1)->set_expand(true);
199 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
200 group_display.set_name ("EditGroupList");
201 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
202 group_display.set_reorderable (true);
203 group_display.set_headers_visible (true);
204 group_display.set_rules_hint (true);
205 group_display.set_can_focus(false);
207 /* name is directly editable */
209 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
210 name_cell->property_editable() = true;
211 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
213 /* use checkbox for the active column */
215 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
216 active_cell->property_activatable() = true;
217 active_cell->property_radio() = false;
219 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
220 /* We use this to notice drag-and-drop reorders of the group list */
221 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
222 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
224 group_display_scroller.add (group_display);
225 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
228 group_display_vbox.pack_start (group_display_scroller, true, true);
230 group_display_frame.set_name ("BaseFrame");
231 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
232 group_display_frame.add (group_display_vbox);
234 list<TargetEntry> target_list;
235 target_list.push_back (TargetEntry ("PluginPresetPtr"));
237 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
238 favorite_plugins_display.set_model (favorite_plugins_model);
239 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
240 favorite_plugins_display.set_name ("EditGroupList");
241 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
242 favorite_plugins_display.set_reorderable (false);
243 favorite_plugins_display.set_headers_visible (true);
244 favorite_plugins_display.set_rules_hint (true);
245 favorite_plugins_display.set_can_focus (false);
246 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
247 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
248 favorite_plugins_display.add_drop_targets (target_list);
249 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
250 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
251 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
252 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
253 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
254 if (UIConfiguration::instance().get_use_tooltips()) {
255 favorite_plugins_display.set_tooltip_column (0);
257 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
259 favorite_plugins_scroller.add (favorite_plugins_display);
260 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
262 favorite_plugins_frame.set_name ("BaseFrame");
263 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
264 favorite_plugins_frame.add (favorite_plugins_vbox);
266 favorite_plugins_vbox.pack_start (favorite_plugins_scroller, true, true);
267 favorite_plugins_vbox.pack_start (favorite_plugins_tag_combo, false, false);
268 favorite_plugins_tag_combo.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::tag_combo_changed));
270 rhs_pane1.add (favorite_plugins_frame);
271 rhs_pane1.add (track_display_frame);
273 rhs_pane2.add (rhs_pane1);
274 rhs_pane2.add (group_display_frame);
276 list_vpacker.pack_start (rhs_pane2, true, true);
278 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
279 vca_vpacker.pack_start (vca_label_bar, false, false);
281 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
282 vca_scroller_base.set_name (X_("MixerWindow"));
283 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
285 vca_hpacker.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_vca_scroll_event), false);
286 vca_scroller.add (vca_hpacker);
287 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
288 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
290 vca_vpacker.pack_start (vca_scroller, true, true);
292 inner_pane.add (scroller);
293 inner_pane.add (vca_vpacker);
295 global_hpacker.pack_start (inner_pane, true, true);
296 global_hpacker.pack_start (out_packer, false, false);
298 list_hpane.set_check_divider_position (true);
299 list_hpane.add (list_vpacker);
300 list_hpane.add (global_hpacker);
301 list_hpane.set_child_minsize (list_vpacker, 30);
303 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
306 if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) {
309 rhs_pane1.set_divider (0, fract);
311 if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
314 rhs_pane2.set_divider (0, fract);
316 if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
319 list_hpane.set_divider (0, fract);
321 if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
324 inner_pane.set_divider (0, fract);
326 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
327 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
328 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
329 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
331 _content.pack_start (list_hpane, true, true);
336 _content.set_name ("MixerWindow");
338 global_hpacker.show();
340 scroller_base.show();
341 scroller_hpacker.show();
342 mixer_scroller_vpacker.show();
344 group_display_button_label.show();
345 group_display_scroller.show();
346 favorite_plugins_scroller.show();
347 group_display_vbox.show();
348 group_display_frame.show();
349 favorite_plugins_frame.show();
357 vca_label_bar.show();
359 vca_scroller_base.show();
362 group_display.show();
363 favorite_plugins_display.show();
366 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
368 _monitor_section.tearoff().set_state (*mnode);
371 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
372 VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
373 FoldbackStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_foldback, this, _1), gui_context());
377 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
379 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
380 _plugin_selector = new PluginSelector (PluginManager::instance ());
382 #error implement deferred Plugin-Favorite list
385 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
386 PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
387 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
390 Mixer_UI::~Mixer_UI ()
392 monitor_section_detached ();
394 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 // last strip created is shown
615 foldback_strip->set_route (route);
617 foldback_strip = new FoldbackStrip (*this, _session, route);
618 out_packer.pack_start (*foldback_strip, false, false);
619 // change 0 to 1 below for foldback to right of master
620 out_packer.reorder_child (*foldback_strip, 0);
621 foldback_strip->set_packed (true);
623 /* config from last run is set before there are any foldback strips
624 * this takes that setting and applies it after at least one foldback
626 bool yn = _show_foldback_strip;
627 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
628 act->set_sensitive (true);
629 act->set_active(!yn);
634 strip = new MixerStrip (*this, _session, route);
635 strips.push_back (strip);
637 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
639 if (strip->width_owner() != strip) {
640 strip->set_width_enum (_strip_width, this);
645 if (route->is_master()) {
647 out_packer.pack_start (*strip, false, false);
648 strip->set_packed (true);
652 TreeModel::Row row = *(track_model->insert (insert_iter));
654 row[stripable_columns.text] = route->name();
655 row[stripable_columns.visible] = strip->marked_for_display();
656 row[stripable_columns.stripable] = route;
657 row[stripable_columns.strip] = strip;
660 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
661 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
664 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
665 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
668 } catch (const std::exception& e) {
669 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
672 track_display.set_model (track_model);
674 /* catch up on selection state, which we left to the editor to set */
675 sync_treeview_from_presentation_info (PropertyChange (Properties::selected));
678 sync_presentation_info_from_treeview ();
681 redisplay_track_list ();
685 Mixer_UI::deselect_all_strip_processors ()
687 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
688 (*i)->deselect_all_processors();
693 Mixer_UI::select_none ()
695 _selection.clear_routes();
696 deselect_all_strip_processors();
700 Mixer_UI::select_next_strip ()
702 deselect_all_strip_processors();
703 _session->selection().select_next_stripable (true, false);
707 Mixer_UI::select_prev_strip ()
709 deselect_all_strip_processors();
710 _session->selection().select_prev_stripable (true, false);
714 Mixer_UI::delete_processors ()
716 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
717 (*i)->delete_processors();
723 Mixer_UI::remove_strip (MixerStrip* strip)
725 if (_session && _session->deletion_in_progress()) {
726 /* its all being taken care of */
730 TreeModel::Children rows = track_model->children();
731 TreeModel::Children::iterator ri;
732 list<MixerStrip *>::iterator i;
734 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
738 PBD::Unwinder<bool> uwi (ignore_reorder, true);
740 for (ri = rows.begin(); ri != rows.end(); ++ri) {
741 if ((*ri)[stripable_columns.strip] == strip) {
742 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
743 track_model->erase (ri);
750 Mixer_UI::remove_foldback (FoldbackStrip* strip)
752 if (_session && _session->deletion_in_progress()) {
753 /* its all being taken care of */
756 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
757 act->set_sensitive (false);
758 if (foldback_strip) {
759 foldback_strip->destroy_();
765 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
767 if (what_changed.contains (Properties::selected)) {
768 _selection.presentation_info_changed (what_changed);
772 soh.add (Properties::selected);
773 soh.add (Properties::order);
774 soh.add (Properties::hidden);
776 if (what_changed.contains (soh)) {
777 sync_treeview_from_presentation_info (what_changed);
782 Mixer_UI::sync_presentation_info_from_treeview ()
784 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
788 TreeModel::Children rows = track_model->children();
794 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
796 TreeModel::Children::iterator ri;
799 PresentationInfo::order_t master_key = _session->master_order_key ();
800 PresentationInfo::order_t order = 0;
802 PresentationInfo::ChangeSuspender cs;
804 for (ri = rows.begin(); ri != rows.end(); ++ri) {
805 bool visible = (*ri)[stripable_columns.visible];
806 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
808 #ifndef NDEBUG // these should not exist in the mixer's treeview
813 if (stripable->is_monitor() || stripable->is_auditioner()) {
817 if (stripable->is_master()) {
823 stripable->presentation_info().set_hidden (!visible);
825 // leave master where it is.
826 if (order == master_key) {
830 if (order != stripable->presentation_info().order()) {
831 stripable->set_presentation_order (order);
837 change |= _session->ensure_stripable_sort_order ();
840 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
841 _session->set_dirty();
846 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
848 if (!_session || _session->deletion_in_progress()) {
852 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
854 /* we could get here after either a change in the Mixer or Editor sort
855 * order, but either way, the mixer order keys reflect the intended
856 * order for the GUI, so reorder the treeview model to match it.
859 vector<int> neworder;
860 TreeModel::Children rows = track_model->children();
861 uint32_t old_order = 0;
862 bool changed = false;
868 TreeOrderKeys sorted;
869 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
870 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
871 sorted.push_back (TreeOrderKey (old_order, stripable));
874 TreeOrderKeySorter cmp;
876 sort (sorted.begin(), sorted.end(), cmp);
877 neworder.assign (sorted.size(), 0);
881 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
883 neworder[n] = sr->old_display_order;
885 if (sr->old_display_order != n) {
891 Unwinder<bool> uw (ignore_reorder, true);
892 track_model->reorder (neworder);
895 if (what_changed.contains (Properties::selected)) {
897 PresentationInfo::ChangeSuspender cs;
899 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
900 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
901 if (stripable && stripable->is_selected()) {
904 _selection.remove (*i);
908 if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) {
909 move_stripable_into_view ((*_selection.axes.begin())->stripable());
912 TreeModel::Children rows = track_model->children();
913 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
914 AxisView* av = (*i)[stripable_columns.strip];
915 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
919 if (vms->vca() && vms->vca()->is_selected()) {
920 _selection.add (vms);
922 _selection.remove (vms);
927 redisplay_track_list ();
932 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
934 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
935 if ((*i)->route() == r) {
944 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
946 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
947 if ((*i)->stripable() == s) {
956 Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
958 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
959 if ((*i)->stripable() == s) {
964 TreeModel::Children rows = track_model->children();
965 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
966 AxisView* av = (*i)[stripable_columns.strip];
967 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
968 if (vms && vms->stripable () == s) {
977 Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
979 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
980 if ((*i)->control() == c) {
989 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
991 /* Selecting a mixer-strip may also select grouped-tracks, and
992 * presentation_info_changed() being emitted and
993 * _selection.axes.begin() is being moved into view. This may
994 * effectively move the track that was clicked-on out of view.
996 * So here only the track that is actually clicked-on is moved into
997 * view (in case it's partially visible)
999 PBD::Unwinder<bool> uw (_strip_selection_change_without_scroll, true);
1000 move_stripable_into_view (strip->stripable());
1002 if (ev->button == 1) {
1003 if (_selection.selected (strip)) {
1004 /* primary-click: toggle selection state of strip */
1005 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1006 _selection.remove (strip, true);
1007 } else if (_selection.axes.size() > 1) {
1008 /* de-select others */
1009 _selection.set (strip);
1011 PublicEditor& pe = PublicEditor::instance();
1012 TimeAxisView* tav = pe.time_axis_view_from_stripable (strip->stripable());
1014 pe.set_selected_mixer_strip (*tav);
1017 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1018 _selection.add (strip, true);
1019 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
1021 /* extend selection */
1023 vector<MixerStrip*> tmp;
1024 bool accumulate = false;
1025 bool found_another = false;
1027 strips.sort (MixerStripSorter());
1029 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1030 MixerStrip* ms = *i;
1034 /* hit clicked strip, start accumulating till we hit the first
1043 } else if (_selection.selected (ms)) {
1044 /* hit selected strip. if currently accumulating others,
1045 we're done. if not accumulating others, start doing so.
1047 found_another = true;
1061 tmp.push_back (strip);
1063 if (found_another) {
1064 PresentationInfo::ChangeSuspender cs;
1065 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
1066 _selection.add (*i, true);
1069 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
1072 _selection.set (strip);
1081 Mixer_UI::vca_button_release_event (GdkEventButton *ev, VCAMasterStrip *strip)
1083 _selection.set (strip);
1088 Mixer_UI::set_session (Session* sess)
1090 SessionHandlePtr::set_session (sess);
1091 _monitor_section.set_session (sess);
1093 if (_plugin_selector) {
1094 _plugin_selector->set_session (_session);
1097 _group_tabs->set_session (sess);
1100 _selection.clear ();
1104 refill_favorite_plugins();
1107 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1108 set_state (*node, 0);
1112 initial_track_display ();
1114 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1115 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1116 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1117 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1118 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1119 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1120 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1122 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1123 _session->vca_manager().VCACreated.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::new_masters_created, this), gui_context());
1125 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1127 route_groups_changed ();
1133 /* catch up on selection state, etc. */
1136 sc.add (Properties::selected);
1137 _selection.presentation_info_changed (sc);
1143 Mixer_UI::session_going_away ()
1145 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1147 _in_group_rebuild_or_clear = true;
1148 group_model->clear ();
1149 _in_group_rebuild_or_clear = false;
1151 _selection.clear ();
1152 track_model->clear ();
1154 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1158 _monitor_section.tearoff().hide_visible ();
1160 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1162 if (foldback_strip) {
1163 delete foldback_strip;
1168 monitor_section_detached ();
1174 SessionHandlePtr::session_going_away ();
1181 Mixer_UI::track_visibility_changed (std::string const & path)
1183 if (_session && _session->deletion_in_progress()) {
1189 if ((iter = track_model->get_iter (path))) {
1191 AxisView* av = (*iter)[stripable_columns.strip];
1192 bool visible = (*iter)[stripable_columns.visible];
1194 if (av->set_marked_for_display (!visible)) {
1195 update_track_visibility ();
1201 Mixer_UI::update_track_visibility ()
1203 TreeModel::Children rows = track_model->children();
1204 TreeModel::Children::iterator i;
1207 Unwinder<bool> uw (no_track_list_redisplay, true);
1209 for (i = rows.begin(); i != rows.end(); ++i) {
1210 AxisView* av = (*i)[stripable_columns.strip];
1211 (*i)[stripable_columns.visible] = av->marked_for_display ();
1214 /* force presentation to catch up with visibility changes */
1215 sync_presentation_info_from_treeview ();
1218 redisplay_track_list ();
1222 Mixer_UI::show_strip (MixerStrip* ms)
1224 TreeModel::Children rows = track_model->children();
1225 TreeModel::Children::iterator i;
1227 for (i = rows.begin(); i != rows.end(); ++i) {
1229 AxisView* av = (*i)[stripable_columns.strip];
1230 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1232 (*i)[stripable_columns.visible] = true;
1233 av->set_marked_for_display (true);
1234 update_track_visibility ();
1241 Mixer_UI::hide_strip (MixerStrip* ms)
1243 TreeModel::Children rows = track_model->children();
1244 TreeModel::Children::iterator i;
1246 for (i = rows.begin(); i != rows.end(); ++i) {
1248 AxisView* av = (*i)[stripable_columns.strip];
1249 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1251 (*i)[stripable_columns.visible] = false;
1252 av->set_marked_for_display (false);
1253 update_track_visibility ();
1260 Mixer_UI::start_updating ()
1262 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1267 Mixer_UI::stop_updating ()
1269 fast_screen_update_connection.disconnect();
1274 Mixer_UI::fast_update_strips ()
1276 if (_content.is_mapped () && _session) {
1277 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1278 (*i)->fast_update ();
1284 Mixer_UI::set_all_strips_visibility (bool yn)
1286 TreeModel::Children rows = track_model->children();
1287 TreeModel::Children::iterator i;
1290 Unwinder<bool> uw (no_track_list_redisplay, true);
1292 for (i = rows.begin(); i != rows.end(); ++i) {
1294 AxisView* av = (*i)[stripable_columns.strip];
1295 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1301 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1305 (*i)[stripable_columns.visible] = yn;
1308 /* force presentation to catch up with visibility changes */
1309 sync_presentation_info_from_treeview ();
1312 redisplay_track_list ();
1316 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1318 TreeModel::Children rows = track_model->children();
1319 TreeModel::Children::iterator i;
1322 Unwinder<bool> uw (no_track_list_redisplay, true);
1324 for (i = rows.begin(); i != rows.end(); ++i) {
1326 AxisView* av = (*i)[stripable_columns.strip];
1327 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1333 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1337 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1338 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1342 (*i)[stripable_columns.visible] = yn;
1346 if (at) { /* track */
1347 (*i)[stripable_columns.visible] = yn;
1352 if (!at && !mt) { /* bus */
1353 (*i)[stripable_columns.visible] = yn;
1358 if (mt) { /* midi-track */
1359 (*i)[stripable_columns.visible] = yn;
1365 /* force presentation to catch up with visibility changes */
1366 sync_presentation_info_from_treeview ();
1369 redisplay_track_list ();
1373 Mixer_UI::hide_all_routes ()
1375 set_all_strips_visibility (false);
1379 Mixer_UI::show_all_routes ()
1381 set_all_strips_visibility (true);
1385 Mixer_UI::show_all_audiobus ()
1387 set_all_audio_midi_visibility (2, true);
1390 Mixer_UI::hide_all_audiobus ()
1392 set_all_audio_midi_visibility (2, false);
1396 Mixer_UI::show_all_audiotracks()
1398 set_all_audio_midi_visibility (1, true);
1401 Mixer_UI::hide_all_audiotracks ()
1403 set_all_audio_midi_visibility (1, false);
1407 Mixer_UI::show_all_miditracks()
1409 set_all_audio_midi_visibility (3, true);
1412 Mixer_UI::hide_all_miditracks ()
1414 set_all_audio_midi_visibility (3, false);
1418 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1420 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1421 sync_presentation_info_from_treeview ();
1425 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1427 /* this happens as the second step of a DnD within the treeview as well
1428 as when a row/route is actually deleted.
1430 if it was a deletion then we have to force a redisplay because
1431 order keys may not have changed.
1434 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1435 sync_presentation_info_from_treeview ();
1437 if (_route_deletion_in_progress) {
1438 redisplay_track_list ();
1443 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1445 TreeModel::Children rows = track_model->children();
1446 std::list<boost::shared_ptr<VCA> > vcas;
1447 vcas.push_back (vca);
1449 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1450 AxisView* av = (*i)[stripable_columns.strip];
1451 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1452 if (vms && vms->vca()->slaved_to (vca)) {
1453 vcas.push_back (vms->vca());
1457 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1459 AxisView* av = (*i)[stripable_columns.strip];
1460 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1461 bool const visible = (*i)[stripable_columns.visible];
1464 /* we're in the middle of changing a row, don't worry */
1468 if (!strip->route()) {
1469 /* non-route element */
1473 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1477 bool slaved = false;
1478 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1479 if (strip->route()->slaved_to (*m)) {
1485 if (slaved && visible) {
1487 if (strip->packed()) {
1488 strip_packer.reorder_child (*strip, -1); /* put at end */
1490 strip_packer.pack_start (*strip, false, false);
1491 strip->set_packed (true);
1496 if (strip->packed()) {
1497 strip_packer.remove (*strip);
1498 strip->set_packed (false);
1505 Mixer_UI::redisplay_track_list ()
1507 if (no_track_list_redisplay) {
1511 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1513 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1515 if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) {
1516 _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value();
1518 spill_redisplay (sv);
1523 TreeModel::Children rows = track_model->children();
1524 TreeModel::Children::iterator i;
1525 uint32_t n_masters = 0;
1527 container_clear (vca_hpacker);
1529 vca_hpacker.pack_end (vca_scroller_base, true, true);
1530 vca_hpacker.pack_end (add_vca_button, false, false);
1532 add_vca_button.show ();
1533 vca_scroller_base.show();
1535 for (i = rows.begin(); i != rows.end(); ++i) {
1537 AxisView* s = (*i)[stripable_columns.strip];
1538 bool const visible = (*i)[stripable_columns.visible];
1539 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1542 /* we're in the middle of changing a row, don't worry */
1546 VCAMasterStrip* vms;
1548 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1550 vca_hpacker.pack_start (*vms, false, false);
1557 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1565 if (strip->packed()) {
1566 strip_packer.reorder_child (*strip, -1); /* put at end */
1568 strip_packer.pack_start (*strip, false, false);
1569 strip->set_packed (true);
1574 if (stripable->is_master() || stripable->is_monitor()) {
1575 /* do nothing, these cannot be hidden */
1577 if (strip->packed()) {
1578 strip_packer.remove (*strip);
1579 strip->set_packed (false);
1585 /* update visibility of VCA assign buttons */
1587 if (n_masters == 0) {
1588 //show/hide the channelstrip VCA assign buttons on channelstrips:
1589 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1591 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleVCAPane");
1593 act->set_sensitive (false);
1596 //remove the VCA packer, but don't change our prior setting for show/hide:
1597 vca_vpacker.hide ();
1599 //show/hide the channelstrip VCA assign buttons on channelstrips:
1600 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1602 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
1603 act->set_sensitive (true);
1605 //if we were showing VCAs before, show them now:
1606 showhide_vcas (act->get_active ());
1609 _group_tabs->set_dirty ();
1611 if (_spill_scroll_position > 0 && scroller.get_hscrollbar()) {
1612 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1613 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), _spill_scroll_position)));
1615 _spill_scroll_position = 0;
1620 Mixer_UI::strip_width_changed ()
1622 _group_tabs->set_dirty ();
1625 TreeModel::Children rows = track_model->children();
1626 TreeModel::Children::iterator i;
1629 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1630 AxisView* av = (*i)[stripable_columns.strip];
1631 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1637 bool visible = (*i)[stripable_columns.visible];
1640 strip->queue_draw();
1647 struct PresentationInfoMixerSorter
1649 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1650 if (a->is_master()) {
1651 /* master after everything else */
1653 } else if (b->is_master()) {
1654 /* everything else before master */
1657 return a->presentation_info().order () < b->presentation_info().order ();
1662 Mixer_UI::initial_track_display ()
1666 _session->get_stripables (sl);
1667 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1669 boost::shared_ptr<ARDOUR::Stripable> _current_foldback = *(fb.begin());
1670 sl.push_back (_current_foldback);
1673 sl.sort (PresentationInfoMixerSorter());
1676 /* These are also used inside ::add_stripables() but we need
1677 * them here because we're going to clear the track_model also.
1679 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1680 Unwinder<bool> uw2 (ignore_reorder, true);
1682 track_model->clear ();
1683 add_stripables (sl);
1686 sync_treeview_from_presentation_info (Properties::order);
1690 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1692 if (Keyboard::is_context_menu_event (ev)) {
1693 if (track_menu == 0) {
1694 build_track_menu ();
1696 track_menu->popup (ev->button, ev->time);
1699 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1700 TreeModel::Path path;
1701 TreeViewColumn* column;
1703 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1704 TreeIter iter = track_model->get_iter (path);
1705 if ((*iter)[stripable_columns.visible]) {
1706 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1707 move_stripable_into_view (s);
1716 Mixer_UI::move_vca_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1718 if (!vca_scroller.get_hscrollbar()) {
1724 Gtk::Allocation alloc;
1726 TreeModel::Children rows = track_model->children();
1727 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1728 AxisView* av = (*i)[stripable_columns.strip];
1729 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1730 if (vms && vms->stripable () == s) {
1733 vms->translate_coordinates (vca_hpacker, 0, 0, x0, y);
1734 alloc = vms->get_allocation ();
1743 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
1745 if (x0 < adj->get_value()) {
1746 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1747 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1748 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1749 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1754 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1756 if (!scroller.get_hscrollbar()) {
1759 if (s->presentation_info().special ()) {
1762 if (s->presentation_info().flag_match (PresentationInfo::VCA)) {
1763 move_vca_into_view (s);
1772 Gtk::Allocation alloc;
1773 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1774 if ((*i)->route() == s) {
1777 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1778 alloc = (*i)->get_allocation ();
1786 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1788 if (x0 < adj->get_value()) {
1789 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1790 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1791 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1792 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1797 Mixer_UI::build_track_menu ()
1799 using namespace Menu_Helpers;
1800 using namespace Gtk;
1802 track_menu = new Menu;
1803 track_menu->set_name ("ArdourContextMenu");
1804 MenuList& items = track_menu->items();
1806 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1807 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1808 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1809 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1810 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1811 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1812 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1813 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1818 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1820 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1824 boost::shared_ptr<Stripable> s = ws.lock ();
1830 TreeModel::Children rows = track_model->children();
1831 TreeModel::Children::iterator i;
1833 for (i = rows.begin(); i != rows.end(); ++i) {
1834 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1838 if (what_changed.contains (ARDOUR::Properties::name)) {
1839 (*i)[stripable_columns.text] = s->name();
1842 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1843 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1844 redisplay_track_list ();
1851 if (s->is_master ()) {
1855 error << _("track display list item for renamed strip not found!") << endmsg;
1859 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1861 TreeModel::Path path;
1862 TreeViewColumn* column;
1866 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1867 if (ev->button == 3) {
1868 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1873 TreeIter iter = group_model->get_iter (path);
1875 if (ev->button == 3) {
1876 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1881 RouteGroup* group = (*iter)[group_columns.group];
1883 if (Keyboard::is_context_menu_event (ev)) {
1884 _group_tabs->get_menu(group)->popup (1, ev->time);
1888 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1890 if (Keyboard::is_edit_event (ev)) {
1892 // edit_route_group (group);
1894 group_display.queue_draw();
1903 bool visible = (*iter)[group_columns.visible];
1904 (*iter)[group_columns.visible] = !visible;
1906 group_display.queue_draw();
1919 Mixer_UI::activate_all_route_groups ()
1921 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1925 Mixer_UI::disable_all_route_groups ()
1927 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1931 Mixer_UI::route_groups_changed ()
1933 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1935 _in_group_rebuild_or_clear = true;
1937 /* just rebuild the while thing */
1939 group_model->clear ();
1942 /* this is currently not used,
1943 * Mixer_UI::group_display_button_press() has a case for it,
1944 * and a commented edit_route_group() but that's n/a since 2011.
1946 * This code is left as reminder that
1947 * row[group_columns.group] = 0 has special meaning.
1951 row = *(group_model->append());
1952 row[group_columns.visible] = true;
1953 row[group_columns.text] = (_("-all-"));
1954 row[group_columns.group] = 0;
1958 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1960 _group_tabs->set_dirty ();
1961 _in_group_rebuild_or_clear = false;
1965 Mixer_UI::new_route_group ()
1967 _group_tabs->run_new_group_dialog (0, false);
1971 Mixer_UI::remove_selected_route_group ()
1973 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1974 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1980 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1983 /* selection mode is single, so rows.begin() is it */
1985 if ((iter = group_model->get_iter (*i))) {
1987 RouteGroup* rg = (*iter)[group_columns.group];
1990 _session->remove_route_group (*rg);
1996 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1998 if (in_group_row_change) {
2002 /* force an update of any mixer strips that are using this group,
2003 otherwise mix group names don't change in mixer strips
2006 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
2007 if ((*i)->route_group() == group) {
2008 (*i)->route_group_changed();
2012 TreeModel::iterator i;
2013 TreeModel::Children rows = group_model->children();
2014 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
2016 in_group_row_change = true;
2018 for (i = rows.begin(); i != rows.end(); ++i) {
2019 if ((*i)[group_columns.group] == group) {
2020 (*i)[group_columns.visible] = !group->is_hidden ();
2021 (*i)[group_columns.text] = group->name ();
2026 in_group_row_change = false;
2028 if (change.contains (Properties::name)) {
2029 _group_tabs->set_dirty ();
2032 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
2033 if ((*j)->route_group() == group) {
2034 if (group->is_hidden ()) {
2044 Mixer_UI::toggle_mixer_list ()
2046 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2047 showhide_mixer_list (act->get_active());
2051 Mixer_UI::showhide_mixer_list (bool yn)
2054 list_vpacker.show ();
2056 list_vpacker.hide ();
2061 Mixer_UI::toggle_monitor_section ()
2063 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2064 showhide_monitor_section (act->get_active());
2069 Mixer_UI::showhide_monitor_section (bool yn)
2071 if (monitor_section().tearoff().torn_off()) {
2076 monitor_section().tearoff().show();
2078 monitor_section().tearoff().hide();
2083 Mixer_UI::toggle_foldback_strip ()
2085 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
2086 showhide_foldback_strip (act->get_active());
2091 Mixer_UI::showhide_foldback_strip (bool yn)
2093 _show_foldback_strip = yn;
2095 if (foldback_strip) {
2097 foldback_strip->show();
2099 foldback_strip->hide();
2105 Mixer_UI::toggle_vcas ()
2107 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2108 showhide_vcas (act->get_active());
2112 Mixer_UI::showhide_vcas (bool yn)
2123 Mixer_UI::toggle_mixbuses ()
2125 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2126 showhide_mixbuses (act->get_active());
2130 Mixer_UI::showhide_mixbuses (bool on)
2142 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
2147 if ((iter = group_model->get_iter (path))) {
2149 if ((group = (*iter)[group_columns.group]) == 0) {
2153 if (new_text != group->name()) {
2154 group->set_name (new_text);
2160 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
2164 if (in_group_row_change) {
2168 if ((group = (*iter)[group_columns.group]) == 0) {
2172 std::string name = (*iter)[group_columns.text];
2174 if (name != group->name()) {
2175 group->set_name (name);
2178 bool hidden = !(*iter)[group_columns.visible];
2180 if (hidden != group->is_hidden ()) {
2181 group->set_hidden (hidden, this);
2185 /** Called when a group model row is deleted, but also when the model is
2186 * reordered by a user drag-and-drop; the latter is what we are
2187 * interested in here.
2190 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
2192 if (_in_group_rebuild_or_clear) {
2196 /* Re-write the session's route group list so that the new order is preserved */
2198 list<RouteGroup*> new_list;
2200 Gtk::TreeModel::Children children = group_model->children();
2201 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
2202 RouteGroup* g = (*i)[group_columns.group];
2204 new_list.push_back (g);
2208 _session->reorder_route_groups (new_list);
2213 Mixer_UI::add_route_group (RouteGroup* group)
2215 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
2218 in_group_row_change = true;
2220 TreeModel::Row row = *(group_model->append());
2221 row[group_columns.visible] = !group->is_hidden ();
2222 row[group_columns.group] = group;
2223 if (!group->name().empty()) {
2224 row[group_columns.text] = group->name();
2226 row[group_columns.text] = _("unnamed");
2230 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
2233 TreeViewColumn* col = group_display.get_column (0);
2234 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
2235 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
2238 _group_tabs->set_dirty ();
2240 in_group_row_change = false;
2244 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
2246 using namespace Menu_Helpers;
2248 if (Keyboard::is_context_menu_event (ev)) {
2249 ARDOUR_UI::instance()->add_route ();
2257 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
2259 if (data.get_target() != "PluginFavoritePtr") {
2260 context->drag_finish (false, false, time);
2264 const void * d = data.get_data();
2265 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2267 PluginPresetList nfos;
2269 tv->get_object_drag_data (nfos, &source);
2271 Route::ProcessorList pl;
2274 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2275 PluginPresetPtr ppp = (*i);
2276 PluginInfoPtr pip = ppp->_pip;
2277 if (!pip->is_instrument ()) {
2280 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);
2284 context->drag_finish (ok, false, time);
2288 Mixer_UI::set_strip_width (Width w, bool save)
2292 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2293 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2298 struct PluginStateSorter {
2300 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2301 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2302 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2303 if (aiter != _user.end() && biter != _user.end()) {
2304 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2306 if (aiter != _user.end()) {
2309 if (biter != _user.end()) {
2312 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2315 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2317 std::list<std::string> _user;
2321 Mixer_UI::set_state (const XMLNode& node, int version)
2325 Tabbable::set_state (node, version);
2327 if (node.get_property ("narrow-strips", yn)) {
2329 set_strip_width (Narrow);
2331 set_strip_width (Wide);
2335 node.get_property ("show-mixer", _visible);
2338 node.get_property ("maximised", yn);
2340 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Common"), X_("ToggleMaximalMixer"));
2341 bool fs = act && act->get_active();
2343 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2348 node.get_property ("show-mixer-list", yn);
2350 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixerList"));
2351 /* do it twice to force the change */
2352 act->set_active (!yn);
2353 act->set_active (yn);
2357 node.get_property ("monitor-section-visible", yn);
2359 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection"));
2360 /* do it twice to force the change */
2361 act->set_active (!yn);
2362 act->set_active (yn);
2366 node.get_property ("foldback-strip-visible", yn);
2368 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleFoldbackStrip"));
2369 /* do it twice to force the change */
2370 act->set_active (!yn);
2371 act->set_active (yn);
2375 node.get_property ("show-vca-pane", yn);
2377 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleVCAPane"));
2378 /* do it twice to force the change */
2379 act->set_active (!yn);
2380 act->set_active (yn);
2385 node.get_property ("show-mixbus-pane", yn);
2387 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixbusPane"));
2388 /* do it twice to force the change */
2389 act->set_active (!yn);
2390 act->set_active (yn);
2394 //check for the user's plugin_order file
2395 XMLNode plugin_order_new(X_("PO"));
2396 if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) {
2397 store_current_favorite_order ();
2398 std::list<string> order;
2399 const XMLNodeList& kids = plugin_order_new.children("PluginInfo");
2400 XMLNodeConstIterator i;
2401 for (i = kids.begin(); i != kids.end(); ++i) {
2402 std::string unique_id;
2403 if ((*i)->get_property ("unique-id", unique_id)) {
2404 order.push_back (unique_id);
2405 if ((*i)->get_property ("expanded", yn)) {
2406 favorite_ui_state[unique_id] = yn;
2410 PluginStateSorter cmp (order);
2411 favorite_order.sort (cmp);
2412 sync_treeview_from_favorite_order ();
2415 //if there is no user file, then use an existing one from instant.xml
2416 //NOTE: if you are loading an old session, this might come from the session's instant.xml
2417 //Todo: in the next major version, we should probably stop doing the instant.xml check, and just use the new file
2418 XMLNode* plugin_order;
2419 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2420 store_current_favorite_order ();
2421 std::list<string> order;
2422 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2423 XMLNodeConstIterator i;
2424 for (i = kids.begin(); i != kids.end(); ++i) {
2425 std::string unique_id;
2426 if ((*i)->get_property ("unique-id", unique_id)) {
2427 order.push_back (unique_id);
2428 if ((*i)->get_property ("expanded", yn)) {
2429 favorite_ui_state[unique_id] = yn;
2434 PluginStateSorter cmp (order);
2435 favorite_order.sort (cmp);
2436 sync_treeview_from_favorite_order ();
2444 Mixer_UI::save_plugin_order_file ()
2446 //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order )
2448 //NOTE: this replaces the old code that stores info in instant.xml
2449 //why? because instant.xml prefers the per-session settings, and we want this to be a global pref
2451 store_current_favorite_order ();
2452 XMLNode plugin_order ("PluginOrder");
2454 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2455 XMLNode* p = new XMLNode ("PluginInfo");
2456 p->set_property ("sort", cnt);
2457 p->set_property ("unique-id", (*i)->unique_id);
2458 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2459 p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2461 plugin_order.add_child_nocopy (*p);
2463 PluginManager::instance().save_plugin_order_file( plugin_order );
2467 Mixer_UI::get_state ()
2469 XMLNode* node = new XMLNode (X_("Mixer"));
2471 node->add_child_nocopy (Tabbable::get_state());
2473 node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider());
2474 node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider());
2475 node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider());
2476 node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider());
2478 node->set_property ("narrow-strips", (_strip_width == Narrow));
2479 node->set_property ("show-mixer", _visible);
2480 node->set_property ("maximised", _maximised);
2482 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2483 node->set_property ("show-mixer-list", act->get_active ());
2485 act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2486 node->set_property ("monitor-section-visible", act->get_active ());
2488 act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
2489 node->set_property ("foldback-strip-visible", act->get_active ());
2491 act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2492 node->set_property ("show-vca-pane", act->get_active ());
2495 act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2496 node->set_property ("show-mixbus-pane", act->get_active ());
2503 Mixer_UI::scroll_left ()
2505 if (!scroller.get_hscrollbar()) return;
2506 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2507 int sc_w = scroller.get_width();
2508 int sp_w = strip_packer.get_width();
2512 int lp = adj->get_value();
2514 using namespace Gtk::Box_Helpers;
2515 const BoxList& strips = strip_packer.children();
2516 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2517 if (i->get_widget() == & add_button) {
2521 if (i->get_widget() == &mb_shadow) {
2525 lm += i->get_widget()->get_width ();
2527 lm -= i->get_widget()->get_width ();
2531 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2535 Mixer_UI::scroll_right ()
2537 if (!scroller.get_hscrollbar()) return;
2538 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2539 int sc_w = scroller.get_width();
2540 int sp_w = strip_packer.get_width();
2544 int lp = adj->get_value();
2546 using namespace Gtk::Box_Helpers;
2547 const BoxList& strips = strip_packer.children();
2548 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2549 if (i->get_widget() == & add_button) {
2553 if (i->get_widget() == &mb_shadow) {
2557 lm += i->get_widget()->get_width ();
2562 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2566 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2568 switch (ev->direction) {
2569 case GDK_SCROLL_LEFT:
2573 if (ev->state & Keyboard::TertiaryModifier) {
2579 case GDK_SCROLL_RIGHT:
2583 case GDK_SCROLL_DOWN:
2584 if (ev->state & Keyboard::TertiaryModifier) {
2595 Mixer_UI::vca_scroll_left ()
2597 if (!vca_scroller.get_hscrollbar()) return;
2598 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2599 int sc_w = vca_scroller.get_width();
2600 int sp_w = strip_packer.get_width();
2604 int lp = adj->get_value();
2606 using namespace Gtk::Box_Helpers;
2607 const BoxList& strips = vca_hpacker.children();
2608 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2609 if (i->get_widget() == &add_vca_button) {
2612 lm += i->get_widget()->get_width ();
2614 lm -= i->get_widget()->get_width ();
2618 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2622 Mixer_UI::vca_scroll_right ()
2624 if (!vca_scroller.get_hscrollbar()) return;
2625 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2626 int sc_w = vca_scroller.get_width();
2627 int sp_w = strip_packer.get_width();
2631 int lp = adj->get_value();
2633 using namespace Gtk::Box_Helpers;
2634 const BoxList& strips = vca_hpacker.children();
2635 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2636 if (i->get_widget() == &add_vca_button) {
2639 lm += i->get_widget()->get_width ();
2644 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2648 Mixer_UI::on_vca_scroll_event (GdkEventScroll* ev)
2650 switch (ev->direction) {
2651 case GDK_SCROLL_LEFT:
2655 if (ev->state & Keyboard::TertiaryModifier) {
2661 case GDK_SCROLL_RIGHT:
2662 vca_scroll_right ();
2665 case GDK_SCROLL_DOWN:
2666 if (ev->state & Keyboard::TertiaryModifier) {
2667 vca_scroll_right ();
2677 Mixer_UI::parameter_changed (string const & p)
2679 if (p == "show-group-tabs") {
2680 bool const s = _session->config.get_show_group_tabs ();
2682 _group_tabs->show ();
2684 _group_tabs->hide ();
2686 } else if (p == "default-narrow_ms") {
2687 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2688 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2689 (*i)->set_width_enum (s ? Narrow : Wide, this);
2695 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2697 g->set_active (a, this);
2701 Mixer_UI::plugin_selector()
2703 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2704 if (!_plugin_selector)
2705 _plugin_selector = new PluginSelector (PluginManager::instance());
2708 return _plugin_selector;
2712 Mixer_UI::setup_track_display ()
2714 track_model = ListStore::create (stripable_columns);
2715 track_display.set_model (track_model);
2716 track_display.append_column (_("Show"), stripable_columns.visible);
2717 track_display.append_column (_("Strips"), stripable_columns.text);
2718 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2719 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2720 track_display.get_column (0)->set_expand(false);
2721 track_display.get_column (1)->set_expand(true);
2722 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2723 track_display.set_name (X_("EditGroupList"));
2724 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2725 track_display.set_reorderable (true);
2726 track_display.set_headers_visible (true);
2727 track_display.set_can_focus(false);
2729 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2730 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2732 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2733 track_list_visible_cell->property_activatable() = true;
2734 track_list_visible_cell->property_radio() = false;
2735 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2737 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2739 track_display_scroller.add (track_display);
2740 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2742 VBox* v = manage (new VBox);
2744 v->pack_start (track_display_scroller, true, true);
2746 track_display_frame.set_name("BaseFrame");
2747 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2748 track_display_frame.add (*v);
2750 track_display_scroller.show();
2751 track_display_frame.show();
2752 track_display.show();
2756 Mixer_UI::new_track_or_bus ()
2758 ARDOUR_UI::instance()->add_route ();
2762 Mixer_UI::update_title ()
2764 if (!own_window()) {
2771 if (_session->snap_name() != _session->name()) {
2772 n = _session->snap_name ();
2774 n = _session->name ();
2777 if (_session->dirty ()) {
2781 WindowTitle title (n);
2782 title += S_("Window|Mixer");
2783 title += Glib::get_application_name ();
2784 own_window()->set_title (title.get_string());
2788 WindowTitle title (S_("Window|Mixer"));
2789 title += Glib::get_application_name ();
2790 own_window()->set_title (title.get_string());
2795 Mixer_UI::strip_by_x (int x)
2797 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2800 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2801 x2 = x1 + (*i)->get_width();
2803 if (x >= x1 && x <= x2) {
2812 Mixer_UI::set_axis_targets_for_operation ()
2814 _axis_targets.clear ();
2816 if (!_selection.empty()) {
2817 _axis_targets = _selection.axes;
2821 // removed "implicit" selections of strips, after discussion on IRC
2826 Mixer_UI::monitor_section_going_away ()
2828 XMLNode* ui_node = Config->extra_xml(X_("UI"));
2830 /* immediate state save.
2832 * Tearoff settings are otherwise only stored during
2833 * save_ardour_state(). The mon-section may or may not
2834 * exist at that point.
2838 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
2840 tearoff_node->remove_nodes_and_delete (X_("monitor-section"));
2841 XMLNode* t = new XMLNode (X_("monitor-section"));
2842 _monitor_section.tearoff().add_state (*t);
2843 tearoff_node->add_child_nocopy (*t);
2847 monitor_section_detached ();
2848 out_packer.remove (_monitor_section.tearoff());
2852 Mixer_UI::toggle_midi_input_active (bool flip_others)
2854 boost::shared_ptr<RouteList> rl (new RouteList);
2857 set_axis_targets_for_operation ();
2859 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2860 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2864 onoff = !mt->input_active();
2868 _session->set_exclusive_input_active (rl, onoff, flip_others);
2872 Mixer_UI::maximise_mixer_space ()
2874 if (!own_window()) {
2882 _window->fullscreen ();
2887 Mixer_UI::restore_mixer_space ()
2889 if (!own_window()) {
2897 own_window()->unfullscreen();
2902 Mixer_UI::monitor_section_attached ()
2904 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2905 act->set_sensitive (true);
2906 showhide_monitor_section (act->get_active ());
2910 Mixer_UI::monitor_section_detached ()
2912 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleMonitorSection");
2913 act->set_sensitive (false);
2917 Mixer_UI::store_current_favorite_order ()
2919 typedef Gtk::TreeModel::Children type_children;
2920 type_children children = favorite_plugins_model->children();
2921 favorite_order.clear();
2922 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2924 Gtk::TreeModel::Row row = *iter;
2925 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2926 favorite_order.push_back (ppp->_pip);
2927 std::string name = row[favorite_plugins_columns.name];
2928 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2933 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2935 Gtk::TreeModel::Row row = *iter;
2936 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2938 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2942 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2944 PluginManager& manager (PluginManager::instance());
2945 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2947 /* not a Favorite? skip it */
2948 if (manager.get_status (*i) != PluginManager::Favorite) {
2952 /* Check the tag combo selection, and skip this plugin if it doesn't match the selected tag(s) */
2953 string test = favorite_plugins_tag_combo.get_active_text();
2954 if (test != _("Show All")) {
2955 vector<string> tags = manager.get_tags(*i);
2957 //does the selected tag match any of the tags in the plugin?
2958 vector<string>::iterator tt = find (tags.begin(), tags.end(), test);
2959 if (tt == tags.end()) {
2964 result.push_back (*i);
2968 struct PluginCustomSorter {
2970 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2971 PluginInfoList::const_iterator aiter = _user.begin();
2972 PluginInfoList::const_iterator biter = _user.begin();
2973 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2974 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2976 if (aiter != _user.end() && biter != _user.end()) {
2977 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2979 if (aiter != _user.end()) {
2982 if (biter != _user.end()) {
2985 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2987 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2989 PluginInfoList _user;
2993 Mixer_UI::refill_favorite_plugins ()
2995 PluginInfoList plugs;
2996 PluginManager& mgr (PluginManager::instance());
2999 refiller (plugs, mgr.lv2_plugin_info ());
3001 #ifdef WINDOWS_VST_SUPPORT
3002 refiller (plugs, mgr.windows_vst_plugin_info ());
3004 #ifdef LXVST_SUPPORT
3005 refiller (plugs, mgr.lxvst_plugin_info ());
3007 #ifdef MACVST_SUPPORT
3008 refiller (plugs, mgr.mac_vst_plugin_info ());
3010 #ifdef AUDIOUNIT_SUPPORT
3011 refiller (plugs, mgr.au_plugin_info ());
3013 refiller (plugs, mgr.ladspa_plugin_info ());
3014 refiller (plugs, mgr.lua_plugin_info ());
3016 store_current_favorite_order ();
3018 PluginCustomSorter cmp (favorite_order);
3021 favorite_order = plugs;
3023 sync_treeview_from_favorite_order ();
3027 Mixer_UI::plugin_list_changed ()
3029 refill_favorite_plugins();
3034 Mixer_UI::refill_tag_combo ()
3036 PluginManager& mgr (PluginManager::instance());
3038 std::vector<std::string> tags = mgr.get_all_tags (PluginManager::OnlyFavorites);
3040 favorite_plugins_tag_combo.clear();
3041 favorite_plugins_tag_combo.append_text (_("Show All"));
3043 for (vector<string>::iterator t = tags.begin (); t != tags.end (); ++t) {
3044 favorite_plugins_tag_combo.append_text (*t);
3047 favorite_plugins_tag_combo.set_active_text (_("Show All"));
3051 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
3054 if (!(iter = favorite_plugins_model->get_iter (path))) {
3057 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3061 PluginInfoPtr pip = ppp->_pip;
3062 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3063 if (favorite_ui_state[pip->unique_id]) {
3064 favorite_plugins_display.expand_row (path, true);
3070 Mixer_UI::sync_treeview_from_favorite_order ()
3072 favorite_plugins_model->clear ();
3073 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
3074 PluginInfoPtr pip = (*i);
3076 TreeModel::Row newrow = *(favorite_plugins_model->append());
3077 newrow[favorite_plugins_columns.name] = (*i)->name;
3078 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
3083 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
3084 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
3088 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
3089 child_row[favorite_plugins_columns.name] = (*j).label;
3090 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
3092 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3093 if (favorite_ui_state[pip->unique_id]) {
3094 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
3101 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
3103 using namespace Gtk::Menu_Helpers;
3105 Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu ();
3106 MenuList& items = m->items ();
3108 if (_selection.axes.empty()) {
3109 items.push_back (MenuElem (_("No Track/Bus is selected.")));
3111 items.push_back (MenuElem (_("Add at the top"),
3112 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
3113 items.push_back (MenuElem (_("Add Pre-Fader"),
3114 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
3115 items.push_back (MenuElem (_("Add Post-Fader"),
3116 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
3117 items.push_back (MenuElem (_("Add at the end"),
3118 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
3121 items.push_back (SeparatorElem());
3123 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
3125 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3126 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
3127 // we cannot currently delete AU presets
3128 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
3129 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
3133 m->popup (ev->button, ev->time);
3137 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
3139 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
3140 TreeModel::Path path;
3141 TreeViewColumn* column;
3143 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
3144 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3146 selection->unselect_all();
3147 selection->select(path);
3150 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3152 popup_note_context_menu (ev);
3160 Mixer_UI::selected_plugin ()
3162 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3164 return PluginPresetPtr();
3166 Gtk::TreeModel::iterator iter = selection->get_selected();
3168 return PluginPresetPtr();
3170 return (*iter)[favorite_plugins_columns.plugin];
3174 Mixer_UI::add_selected_processor (ProcessorPosition pos)
3176 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3178 add_favorite_processor (ppp, pos);
3183 Mixer_UI::delete_selected_preset ()
3188 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3189 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
3192 PluginPtr plugin = ppp->_pip->load (*_session);
3193 plugin->get_presets();
3194 plugin->remove_preset (ppp->_preset.label);
3198 Mixer_UI::remove_selected_from_favorites ()
3200 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3204 PluginManager::PluginStatusType status = PluginManager::Normal;
3205 PluginManager& manager (PluginManager::instance());
3207 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3208 manager.save_statuses ();
3212 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
3215 if (!(iter = favorite_plugins_model->get_iter (path))) {
3218 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3219 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
3223 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
3225 if (!_session || _selection.axes.empty()) {
3229 PluginInfoPtr pip = ppp->_pip;
3230 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
3231 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
3237 PluginPtr p = pip->load (*_session);
3243 if (ppp->_preset.valid) {
3244 p->load_preset (ppp->_preset);
3247 Route::ProcessorStreams err;
3248 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
3252 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
3255 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
3262 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
3266 if (!np->display_to_user()) {
3269 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
3270 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
3275 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
3279 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
3286 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
3288 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
3292 // only allow to re-order top-level items
3294 if (TreePath::get_from_selection_data (data, src)) {
3295 if (src.up() && src.up()) {
3300 // don't allow to drop as child-rows.
3301 Gtk::TreeModel::Path _dest = dest; // un const
3302 const bool is_child = _dest.up (); // explicit bool for clang
3303 if (!is_child || _dest.empty ()) {
3310 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
3312 if (data.get_target() != "PluginPresetPtr") {
3315 if (data.get_length() != sizeof (PluginPresetPtr)) {
3318 const void *d = data.get_data();
3319 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
3321 PluginManager::PluginStatusType status = PluginManager::Favorite;
3322 PluginManager& manager (PluginManager::instance());
3324 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3325 manager.save_statuses ();
3329 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
3331 /* call protected MixerActor:: method */
3336 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
3338 /* call protected MixerActor:: method */
3343 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
3345 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
3348 show_spill_change (s); /* EMIT SIGNAL */
3350 _group_tabs->hide ();
3352 _group_tabs->show ();
3354 redisplay_track_list ();
3359 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
3361 return s == spilled_strip.lock();
3365 Mixer_UI::register_actions ()
3367 Glib::RefPtr<ActionGroup> group = ActionManager::create_action_group (bindings, X_("Mixer"));
3369 ActionManager::register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
3370 ActionManager::register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
3371 ActionManager::register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
3372 ActionManager::register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
3373 ActionManager::register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
3374 ActionManager::register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
3377 ActionManager::register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
3378 ActionManager::register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
3379 ActionManager::register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
3380 ActionManager::register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
3381 ActionManager::register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
3382 ActionManager::register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
3383 ActionManager::register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
3384 ActionManager::register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
3386 ActionManager::register_action (group, "select-next-stripable", _("Select Next Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_next_strip));
3387 ActionManager::register_action (group, "select-prev-stripable", _("Scroll Previous Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_prev_strip));
3389 ActionManager::register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
3390 ActionManager::register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
3392 ActionManager::register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
3393 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
3395 ActionManager::register_toggle_action (group, X_("ToggleMixerList"), _("Mixer: Show Mixer List"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixer_list));
3397 ActionManager::register_toggle_action (group, X_("ToggleVCAPane"), _("Mixer: Show VCAs"), sigc::mem_fun (*this, &Mixer_UI::toggle_vcas));
3400 ActionManager::register_toggle_action (group, X_("ToggleMixbusPane"), _("Mixer: Show Mixbusses"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixbuses));
3403 ActionManager::register_toggle_action (group, X_("ToggleMonitorSection"), _("Mixer: Show Monitor Section"), sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_section));
3405 ActionManager::register_toggle_action (group, X_("ToggleFoldbackStrip"), _("Mixer: Show Foldback Strip"), sigc::mem_fun (*this, &Mixer_UI::toggle_foldback_strip));
3407 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));
3408 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));
3412 Mixer_UI::load_bindings ()
3414 bindings = Bindings::get_bindings (X_("Mixer"));
3417 template<class T> void
3418 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
3420 boost::shared_ptr<ControlList> cl (new ControlList);
3421 boost::shared_ptr<AutomationControl> ac;
3423 bool have_val = false;
3425 set_axis_targets_for_operation ();
3427 BOOST_FOREACH(AxisView* r, _axis_targets) {
3428 boost::shared_ptr<Stripable> s = r->stripable();
3430 ac = (s.get()->*get_control)();
3432 ac->start_touch (_session->audible_sample ());
3435 val = !ac->get_value();
3442 _session->set_controls (cl, val, Controllable::UseGroup);
3446 Mixer_UI::solo_action ()
3448 control_action (&Stripable::solo_control);
3452 Mixer_UI::mute_action ()
3454 control_action (&Stripable::mute_control);
3458 Mixer_UI::rec_enable_action ()
3460 control_action (&Stripable::rec_enable_control);
3463 AutomationControlSet
3464 Mixer_UI::selected_gaincontrols ()
3466 set_axis_targets_for_operation ();
3467 AutomationControlSet rv;
3468 BOOST_FOREACH(AxisView* r, _axis_targets) {
3469 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3471 boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
3472 ControlList cl (ac->grouped_controls());
3473 for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
3483 Mixer_UI::step_gain_up_action ()
3485 AutomationControlSet acs = selected_gaincontrols ();
3486 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3487 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3489 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
3494 Mixer_UI::step_gain_down_action ()
3496 AutomationControlSet acs = selected_gaincontrols ();
3497 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3498 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3500 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
3505 Mixer_UI::unity_gain_action ()
3507 set_axis_targets_for_operation ();
3509 BOOST_FOREACH(AxisView* r, _axis_targets) {
3510 boost::shared_ptr<Stripable> s = r->stripable();
3512 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3514 ac->set_value (1.0, Controllable::UseGroup);
3521 Mixer_UI::copy_processors ()
3523 set_axis_targets_for_operation ();
3525 BOOST_FOREACH(AxisView* r, _axis_targets) {
3526 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3528 ms->copy_processors ();
3533 Mixer_UI::cut_processors ()
3535 set_axis_targets_for_operation ();
3537 BOOST_FOREACH(AxisView* r, _axis_targets) {
3538 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3540 ms->cut_processors ();
3545 Mixer_UI::paste_processors ()
3547 set_axis_targets_for_operation ();
3549 BOOST_FOREACH(AxisView* r, _axis_targets) {
3550 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3552 ms->paste_processors ();
3557 Mixer_UI::select_all_processors ()
3559 set_axis_targets_for_operation ();
3561 BOOST_FOREACH(AxisView* r, _axis_targets) {
3562 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3564 ms->select_all_processors ();
3569 Mixer_UI::toggle_processors ()
3571 set_axis_targets_for_operation ();
3573 BOOST_FOREACH(AxisView* r, _axis_targets) {
3574 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3576 ms->toggle_processors ();
3581 Mixer_UI::ab_plugins ()
3583 set_axis_targets_for_operation ();
3585 BOOST_FOREACH(AxisView* r, _axis_targets) {
3586 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3594 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3596 set_axis_targets_for_operation ();
3597 BOOST_FOREACH(AxisView* r, _axis_targets) {
3598 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3600 ms->vca_assign (vca);
3606 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3608 set_axis_targets_for_operation ();
3609 BOOST_FOREACH(AxisView* r, _axis_targets) {
3610 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3612 ms->vca_unassign (vca);
3618 Mixer_UI::screenshot (std::string const& filename)
3624 int height = strip_packer.get_height();
3625 bool with_vca = vca_vpacker.is_visible ();
3626 MixerStrip* master = strip_by_route (_session->master_out ());
3628 Gtk::OffscreenWindow osw;
3633 /* unpack widgets, add to OffscreenWindow */
3635 strip_group_box.remove (strip_packer);
3636 b.pack_start (strip_packer, false, false);
3637 /* hide extra elements inside strip_packer */
3639 scroller_base.hide ();
3645 /* work around Gtk::ScrolledWindow */
3646 Gtk::Viewport* viewport = (Gtk::Viewport*) vca_scroller.get_child();
3647 viewport->remove (); // << vca_hpacker
3648 b.pack_start (vca_hpacker, false, false);
3649 /* hide some growing widgets */
3650 add_vca_button.hide ();
3651 vca_scroller_base.hide();
3655 out_packer.remove (*master);
3656 b.pack_start (*master, false, false);
3657 master->hide_master_spacer (true);
3660 /* prepare the OffscreenWindow for rendering */
3661 osw.set_size_request (-1, height);
3663 osw.queue_resize ();
3665 osw.get_window()->process_updates (true);
3667 /* create screenshot */
3668 Glib::RefPtr<Gdk::Pixbuf> pb = osw.get_pixbuf ();
3669 pb->save (filename, "png");
3671 /* unpack elements before destorying the Box & OffscreenWindow */
3672 list<Gtk::Widget*> children = b.get_children();
3673 for (list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
3678 /* now re-pack the widgets into the main mixer window */
3680 scroller_base.show ();
3684 strip_group_box.pack_start (strip_packer);
3686 add_vca_button.show ();
3687 vca_scroller_base.show();
3688 vca_scroller.add (vca_hpacker);
3691 master->hide_master_spacer (false);
3692 out_packer.pack_start (*master, false, false);
3698 Mixer_UI::toggle_monitor_action (MonitorChoice monitor_choice, bool group_override, bool all)
3701 boost::shared_ptr<RouteList> rl;
3703 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
3704 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
3706 if (rt->monitoring_control()->monitoring_choice() & monitor_choice) {
3707 mc = MonitorChoice (rt->monitoring_control()->monitoring_choice() & ~monitor_choice);
3709 mc = MonitorChoice (rt->monitoring_control()->monitoring_choice() | monitor_choice);
3713 /* Primary-Tertiary-click applies change to all routes */
3714 rl = _session->get_routes ();
3715 _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::NoGroup);
3716 } else if (group_override) {
3717 rl.reset (new RouteList);
3719 _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::InverseGroup);
3721 rl.reset (new RouteList);
3723 _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::UseGroup);