2 * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3 * Copyright (C) 2005-2018 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2006-2007 Doug McLain <doug@nostar.net>
5 * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2007-2012 David Robillard <d@drobilla.net>
7 * Copyright (C) 2007-2016 Tim Mayberry <mojofunk@gmail.com>
8 * Copyright (C) 2013-2015 Nick Mainsbridge <mainsbridge@gmail.com>
9 * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
10 * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
11 * Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "gtk2ardour-config.h"
34 #include <sigc++/bind.h>
36 #include <boost/foreach.hpp>
38 #include <glibmm/threads.h>
40 #include <gtkmm/accelmap.h>
41 #include <gtkmm/offscreenwindow.h>
42 #include <gtkmm/stock.h>
44 #include "pbd/convert.h"
45 #include "pbd/stacktrace.h"
46 #include "pbd/unwind.h"
48 #include "ardour/amp.h"
49 #include "ardour/debug.h"
50 #include "ardour/audio_track.h"
51 #include "ardour/midi_track.h"
52 #include "ardour/plugin_manager.h"
53 #include "ardour/route_group.h"
54 #include "ardour/selection.h"
55 #include "ardour/session.h"
56 #include "ardour/vca.h"
57 #include "ardour/vca_manager.h"
59 #include "gtkmm2ext/gtk_ui.h"
60 #include "gtkmm2ext/keyboard.h"
61 #include "gtkmm2ext/utils.h"
62 #include "gtkmm2ext/window_title.h"
63 #include "gtkmm2ext/doi.h"
65 #include "widgets/tearoff.h"
67 #include "foldback_strip.h"
70 #include "mixer_strip.h"
71 #include "monitor_section.h"
72 #include "plugin_selector.h"
73 #include "public_editor.h"
74 #include "mouse_cursors.h"
75 #include "ardour_ui.h"
77 #include "route_sorter.h"
79 #include "gui_thread.h"
80 #include "mixer_group_tabs.h"
81 #include "route_sorter.h"
83 #include "ui_config.h"
84 #include "vca_master_strip.h"
88 using namespace ARDOUR;
89 using namespace ARDOUR_UI_UTILS;
93 using namespace Gtkmm2ext;
99 Mixer_UI* Mixer_UI::_instance = 0;
102 Mixer_UI::instance ()
105 _instance = new Mixer_UI;
111 Mixer_UI::Mixer_UI ()
112 : Tabbable (_content, _("Mixer"))
113 , no_track_list_redisplay (false)
114 , in_group_row_change (false)
116 , _plugin_selector (0)
118 , _show_foldback_strip (true)
119 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
120 , _spill_scroll_position (0)
121 , ignore_reorder (false)
122 , _in_group_rebuild_or_clear (false)
123 , _route_deletion_in_progress (false)
125 , _strip_selection_change_without_scroll (false)
126 , _selection (*this, *this)
130 Glib::RefPtr<ToggleAction> fb_act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
131 fb_act->set_sensitive (false);
133 _content.set_data ("ardour-bindings", bindings);
135 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
137 scroller.set_can_default (true);
138 // set_default (scroller);
140 scroller_base.set_flags (Gtk::CAN_FOCUS);
141 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
142 scroller_base.set_name ("MixerWindow");
143 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
145 /* set up drag-n-drop */
146 vector<TargetEntry> target_table;
147 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
148 scroller_base.drag_dest_set (target_table);
149 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
151 /* create a button to add VCA strips ... will get packed in redisplay_track_list() */
152 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
154 add_vca_button.add (*w);
155 add_vca_button.set_can_focus(false);
156 add_vca_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
158 /* create a button to add mixer strips */
159 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
162 add_button.set_can_focus(false);
163 add_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
165 /* add as last item of strip packer */
166 strip_packer.pack_end (scroller_base, true, true);
167 strip_packer.pack_end (add_button, false, false);
170 /* create a drop-shadow at the end of the mixer strips */
171 mb_shadow.set_size_request( 4, -1 );
172 mb_shadow.set_name("EditorWindow");
174 strip_packer.pack_end (mb_shadow, false, false);
177 _group_tabs = new MixerGroupTabs (this);
178 strip_group_box.set_spacing (0);
179 strip_group_box.set_border_width (0);
180 strip_group_box.pack_start (*_group_tabs, PACK_SHRINK);
181 strip_group_box.pack_start (strip_packer);
182 strip_group_box.show_all ();
183 strip_group_box.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
185 scroller.add (strip_group_box);
186 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
188 setup_track_display ();
190 group_model = ListStore::create (group_columns);
191 group_display.set_model (group_model);
192 group_display.append_column (_("Show"), group_columns.visible);
193 group_display.append_column (_("Group"), group_columns.text);
194 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
195 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
196 group_display.get_column (0)->set_expand(false);
197 group_display.get_column (1)->set_expand(true);
198 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
199 group_display.set_name ("EditGroupList");
200 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
201 group_display.set_reorderable (true);
202 group_display.set_headers_visible (true);
203 group_display.set_rules_hint (true);
204 group_display.set_can_focus(false);
206 /* name is directly editable */
208 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
209 name_cell->property_editable() = true;
210 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
212 /* use checkbox for the active column */
214 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
215 active_cell->property_activatable() = true;
216 active_cell->property_radio() = false;
218 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
219 /* We use this to notice drag-and-drop reorders of the group list */
220 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
221 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
223 group_display_scroller.add (group_display);
224 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
227 group_display_vbox.pack_start (group_display_scroller, true, true);
229 group_display_frame.set_name ("BaseFrame");
230 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
231 group_display_frame.add (group_display_vbox);
233 list<TargetEntry> target_list;
234 target_list.push_back (TargetEntry ("PluginPresetPtr"));
236 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
237 favorite_plugins_display.set_model (favorite_plugins_model);
238 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
239 favorite_plugins_display.set_name ("EditGroupList");
240 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
241 favorite_plugins_display.set_reorderable (false);
242 favorite_plugins_display.set_headers_visible (true);
243 favorite_plugins_display.set_rules_hint (true);
244 favorite_plugins_display.set_can_focus (false);
245 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
246 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
247 favorite_plugins_display.add_drop_targets (target_list);
248 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
249 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
250 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
251 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
252 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
253 if (UIConfiguration::instance().get_use_tooltips()) {
254 favorite_plugins_display.set_tooltip_column (0);
256 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
258 favorite_plugins_scroller.add (favorite_plugins_display);
259 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
261 favorite_plugins_frame.set_name ("BaseFrame");
262 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
263 favorite_plugins_frame.add (favorite_plugins_vbox);
265 favorite_plugins_vbox.pack_start (favorite_plugins_scroller, true, true);
266 favorite_plugins_vbox.pack_start (favorite_plugins_tag_combo, false, false);
267 favorite_plugins_tag_combo.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::tag_combo_changed));
269 rhs_pane1.add (favorite_plugins_frame);
270 rhs_pane1.add (track_display_frame);
272 rhs_pane2.add (rhs_pane1);
273 rhs_pane2.add (group_display_frame);
275 list_vpacker.pack_start (rhs_pane2, true, true);
277 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
278 vca_vpacker.pack_start (vca_label_bar, false, false);
280 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
281 vca_scroller_base.set_name (X_("MixerWindow"));
282 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
284 vca_hpacker.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_vca_scroll_event), false);
285 vca_scroller.add (vca_hpacker);
286 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
287 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
289 vca_vpacker.pack_start (vca_scroller, true, true);
291 inner_pane.add (scroller);
292 inner_pane.add (vca_vpacker);
294 global_hpacker.pack_start (inner_pane, true, true);
295 global_hpacker.pack_start (out_packer, false, false);
297 list_hpane.set_check_divider_position (true);
298 list_hpane.add (list_vpacker);
299 list_hpane.add (global_hpacker);
300 list_hpane.set_child_minsize (list_vpacker, 30);
302 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
305 if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) {
308 rhs_pane1.set_divider (0, fract);
310 if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
313 rhs_pane2.set_divider (0, fract);
315 if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
318 list_hpane.set_divider (0, fract);
320 if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
323 inner_pane.set_divider (0, fract);
325 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
326 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
327 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
328 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
330 _content.pack_start (list_hpane, true, true);
335 _content.set_name ("MixerWindow");
337 global_hpacker.show();
339 scroller_base.show();
340 scroller_hpacker.show();
341 mixer_scroller_vpacker.show();
343 group_display_button_label.show();
344 group_display_scroller.show();
345 favorite_plugins_scroller.show();
346 group_display_vbox.show();
347 group_display_frame.show();
348 favorite_plugins_frame.show();
356 vca_label_bar.show();
358 vca_scroller_base.show();
361 group_display.show();
362 favorite_plugins_display.show();
365 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
367 _monitor_section.tearoff().set_state (*mnode);
370 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
371 VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
372 FoldbackStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_foldback, this, _1), gui_context());
376 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
378 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
379 _plugin_selector = new PluginSelector (PluginManager::instance ());
381 #error implement deferred Plugin-Favorite list
384 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
385 PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
386 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
389 Mixer_UI::~Mixer_UI ()
391 monitor_section_detached ();
393 delete foldback_strip;
395 delete _plugin_selector;
399 struct MixerStripSorter {
400 bool operator() (const MixerStrip* ms_a, const MixerStrip* ms_b)
402 boost::shared_ptr<ARDOUR::Stripable> const& a = ms_a->stripable ();
403 boost::shared_ptr<ARDOUR::Stripable> const& b = ms_b->stripable ();
404 return ARDOUR::Stripable::Sorter(true)(a, b);
416 Mixer_UI::tag_combo_changed ()
418 refill_favorite_plugins();
422 Mixer_UI::use_own_window (bool and_fill_it)
424 bool new_window = !own_window();
426 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
428 if (win && new_window) {
429 win->set_name ("MixerWindow");
430 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
431 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
432 win->set_data ("ardour-bindings", bindings);
434 if (!win->get_focus()) {
435 /* set focus widget to something, anything */
436 win->set_focus (scroller);
444 Mixer_UI::show_window ()
446 Tabbable::show_window ();
448 /* show/hide group tabs as required */
449 parameter_changed ("show-group-tabs");
451 /* now reset each strips width so the right widgets are shown */
453 TreeModel::Children rows = track_model->children();
454 TreeModel::Children::iterator ri;
456 for (ri = rows.begin(); ri != rows.end(); ++ri) {
457 AxisView* av = (*ri)[stripable_columns.strip];
458 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
462 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
463 /* Fix visibility of mixer strip stuff */
464 ms->parameter_changed (X_("mixer-element-visibility"));
467 /* force focus into main area */
468 scroller_base.grab_focus ();
472 Mixer_UI::remove_master (VCAMasterStrip* vms)
474 if (_session && _session->deletion_in_progress()) {
475 /* its all being taken care of */
479 TreeModel::Children rows = track_model->children();
480 TreeModel::Children::iterator ri;
482 for (ri = rows.begin(); ri != rows.end(); ++ri) {
483 if ((*ri)[stripable_columns.strip] == vms) {
484 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
485 track_model->erase (ri);
492 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
494 using namespace Menu_Helpers;
496 if (Keyboard::is_context_menu_event (ev)) {
497 ARDOUR_UI::instance()->add_route ();
505 Mixer_UI::new_masters_created ()
507 ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane")->set_active (true);
511 Mixer_UI::add_masters (VCAList& vlist)
515 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
516 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
523 Mixer_UI::add_routes (RouteList& rlist)
527 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
535 Mixer_UI::add_stripables (StripableList& slist)
537 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
538 bool from_scratch = (track_model->children().size() == 0);
539 uint32_t nroutes = 0;
541 slist.sort (Stripable::Sorter());
543 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
544 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
552 // XXX what does this special case do?
553 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
562 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
564 track_display.set_model (Glib::RefPtr<ListStore>());
566 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
568 boost::shared_ptr<Route> route;
569 boost::shared_ptr<VCA> vca;
571 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
573 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
575 TreeModel::Row row = *(track_model->append());
577 row[stripable_columns.text] = vca->name();
578 row[stripable_columns.visible] = vms->marked_for_display ();
579 row[stripable_columns.strip] = vms;
580 row[stripable_columns.stripable] = vca;
582 vms->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::vca_button_release_event), vms));
584 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
586 if (route->is_auditioner()) {
590 if (route->is_monitor()) {
592 out_packer.pack_end (_monitor_section.tearoff(), false, false);
593 _monitor_section.set_session (_session);
594 _monitor_section.tearoff().show_all ();
596 _monitor_section.tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
597 _monitor_section.tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
599 if (_monitor_section.tearoff().torn_off()) {
600 monitor_section_detached ();
602 monitor_section_attached ();
605 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
607 /* no regular strip shown for control out */
611 if (route->is_foldbackbus ()) {
612 if (foldback_strip) {
613 // last strip created is shown
614 foldback_strip->set_route (route);
616 foldback_strip = new FoldbackStrip (*this, _session, route);
617 out_packer.pack_start (*foldback_strip, false, false);
618 // change 0 to 1 below for foldback to right of master
619 out_packer.reorder_child (*foldback_strip, 0);
620 foldback_strip->set_packed (true);
622 /* config from last run is set before there are any foldback strips
623 * this takes that setting and applies it after at least one foldback
625 bool yn = _show_foldback_strip;
626 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
627 act->set_sensitive (true);
628 act->set_active(!yn);
633 strip = new MixerStrip (*this, _session, route);
634 strips.push_back (strip);
636 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
638 if (strip->width_owner() != strip) {
639 strip->set_width_enum (_strip_width, this);
644 if (route->is_master()) {
646 out_packer.pack_start (*strip, false, false);
647 strip->set_packed (true);
651 TreeModel::Row row = *(track_model->insert (insert_iter));
653 row[stripable_columns.text] = route->name();
654 row[stripable_columns.visible] = strip->marked_for_display();
655 row[stripable_columns.stripable] = route;
656 row[stripable_columns.strip] = strip;
659 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
660 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
663 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
664 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
667 } catch (const std::exception& e) {
668 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
671 track_display.set_model (track_model);
673 /* catch up on selection state, which we left to the editor to set */
674 sync_treeview_from_presentation_info (PropertyChange (Properties::selected));
677 sync_presentation_info_from_treeview ();
680 redisplay_track_list ();
684 Mixer_UI::deselect_all_strip_processors ()
686 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
687 (*i)->deselect_all_processors();
692 Mixer_UI::select_none ()
694 _selection.clear_routes();
695 deselect_all_strip_processors();
699 Mixer_UI::select_next_strip ()
701 deselect_all_strip_processors();
702 _session->selection().select_next_stripable (true, false);
706 Mixer_UI::select_prev_strip ()
708 deselect_all_strip_processors();
709 _session->selection().select_prev_stripable (true, false);
713 Mixer_UI::delete_processors ()
715 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
716 (*i)->delete_processors();
722 Mixer_UI::remove_strip (MixerStrip* strip)
724 if (_session && _session->deletion_in_progress()) {
725 /* its all being taken care of */
729 TreeModel::Children rows = track_model->children();
730 TreeModel::Children::iterator ri;
731 list<MixerStrip *>::iterator i;
733 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
737 PBD::Unwinder<bool> uwi (ignore_reorder, true);
739 for (ri = rows.begin(); ri != rows.end(); ++ri) {
740 if ((*ri)[stripable_columns.strip] == strip) {
741 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
742 track_model->erase (ri);
749 Mixer_UI::remove_foldback (FoldbackStrip* strip)
751 if (_session && _session->deletion_in_progress()) {
752 /* its all being taken care of */
755 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
756 act->set_sensitive (false);
757 if (foldback_strip) {
758 foldback_strip->destroy_();
764 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
766 if (what_changed.contains (Properties::selected)) {
767 _selection.presentation_info_changed (what_changed);
771 soh.add (Properties::selected);
772 soh.add (Properties::order);
773 soh.add (Properties::hidden);
775 if (what_changed.contains (soh)) {
776 sync_treeview_from_presentation_info (what_changed);
781 Mixer_UI::sync_presentation_info_from_treeview ()
783 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
787 TreeModel::Children rows = track_model->children();
793 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
795 TreeModel::Children::iterator ri;
798 PresentationInfo::order_t master_key = _session->master_order_key ();
799 PresentationInfo::order_t order = 0;
801 PresentationInfo::ChangeSuspender cs;
803 for (ri = rows.begin(); ri != rows.end(); ++ri) {
804 bool visible = (*ri)[stripable_columns.visible];
805 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
807 #ifndef NDEBUG // these should not exist in the mixer's treeview
812 if (stripable->is_monitor() || stripable->is_auditioner()) {
816 if (stripable->is_master()) {
822 stripable->presentation_info().set_hidden (!visible);
824 // leave master where it is.
825 if (order == master_key) {
829 if (order != stripable->presentation_info().order()) {
830 stripable->set_presentation_order (order);
836 change |= _session->ensure_stripable_sort_order ();
839 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
840 _session->set_dirty();
845 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
847 if (!_session || _session->deletion_in_progress()) {
851 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
853 /* we could get here after either a change in the Mixer or Editor sort
854 * order, but either way, the mixer order keys reflect the intended
855 * order for the GUI, so reorder the treeview model to match it.
858 vector<int> neworder;
859 TreeModel::Children rows = track_model->children();
860 uint32_t old_order = 0;
861 bool changed = false;
867 TreeOrderKeys sorted;
868 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
869 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
870 sorted.push_back (TreeOrderKey (old_order, stripable));
873 TreeOrderKeySorter cmp;
875 sort (sorted.begin(), sorted.end(), cmp);
876 neworder.assign (sorted.size(), 0);
880 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
882 neworder[n] = sr->old_display_order;
884 if (sr->old_display_order != n) {
890 Unwinder<bool> uw (ignore_reorder, true);
891 track_model->reorder (neworder);
894 if (what_changed.contains (Properties::selected)) {
896 PresentationInfo::ChangeSuspender cs;
898 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
899 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
900 if (stripable && stripable->is_selected()) {
903 _selection.remove (*i);
907 if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) {
908 move_stripable_into_view ((*_selection.axes.begin())->stripable());
911 TreeModel::Children rows = track_model->children();
912 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
913 AxisView* av = (*i)[stripable_columns.strip];
914 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
918 if (vms->vca() && vms->vca()->is_selected()) {
919 _selection.add (vms);
921 _selection.remove (vms);
926 redisplay_track_list ();
931 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
933 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
934 if ((*i)->route() == r) {
943 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
945 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
946 if ((*i)->stripable() == s) {
955 Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
957 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
958 if ((*i)->stripable() == s) {
963 TreeModel::Children rows = track_model->children();
964 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
965 AxisView* av = (*i)[stripable_columns.strip];
966 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
967 if (vms && vms->stripable () == s) {
976 Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
978 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
979 if ((*i)->control() == c) {
988 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
990 /* Selecting a mixer-strip may also select grouped-tracks, and
991 * presentation_info_changed() being emitted and
992 * _selection.axes.begin() is being moved into view. This may
993 * effectively move the track that was clicked-on out of view.
995 * So here only the track that is actually clicked-on is moved into
996 * view (in case it's partially visible)
998 PBD::Unwinder<bool> uw (_strip_selection_change_without_scroll, true);
999 move_stripable_into_view (strip->stripable());
1001 if (ev->button == 1) {
1002 if (_selection.selected (strip)) {
1003 /* primary-click: toggle selection state of strip */
1004 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1005 _selection.remove (strip, true);
1006 } else if (_selection.axes.size() > 1) {
1007 /* de-select others */
1008 _selection.set (strip);
1010 PublicEditor& pe = PublicEditor::instance();
1011 TimeAxisView* tav = pe.time_axis_view_from_stripable (strip->stripable());
1013 pe.set_selected_mixer_strip (*tav);
1016 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1017 _selection.add (strip, true);
1018 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
1020 /* extend selection */
1022 vector<MixerStrip*> tmp;
1023 bool accumulate = false;
1024 bool found_another = false;
1026 strips.sort (MixerStripSorter());
1028 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1029 MixerStrip* ms = *i;
1033 /* hit clicked strip, start accumulating till we hit the first
1042 } else if (_selection.selected (ms)) {
1043 /* hit selected strip. if currently accumulating others,
1044 we're done. if not accumulating others, start doing so.
1046 found_another = true;
1060 tmp.push_back (strip);
1062 if (found_another) {
1063 PresentationInfo::ChangeSuspender cs;
1064 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
1065 _selection.add (*i, true);
1068 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
1071 _selection.set (strip);
1080 Mixer_UI::vca_button_release_event (GdkEventButton *ev, VCAMasterStrip *strip)
1082 _selection.set (strip);
1087 Mixer_UI::set_session (Session* sess)
1089 SessionHandlePtr::set_session (sess);
1090 _monitor_section.set_session (sess);
1092 if (_plugin_selector) {
1093 _plugin_selector->set_session (_session);
1096 _group_tabs->set_session (sess);
1099 _selection.clear ();
1103 refill_favorite_plugins();
1106 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1107 set_state (*node, 0);
1111 initial_track_display ();
1113 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1114 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1115 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1116 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1117 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1118 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1119 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1121 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1122 _session->vca_manager().VCACreated.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::new_masters_created, this), gui_context());
1124 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1126 route_groups_changed ();
1132 /* catch up on selection state, etc. */
1135 sc.add (Properties::selected);
1136 _selection.presentation_info_changed (sc);
1142 Mixer_UI::session_going_away ()
1144 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1146 _in_group_rebuild_or_clear = true;
1147 group_model->clear ();
1148 _in_group_rebuild_or_clear = false;
1150 _selection.clear ();
1151 track_model->clear ();
1153 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1157 _monitor_section.tearoff().hide_visible ();
1159 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1161 if (foldback_strip) {
1162 delete foldback_strip;
1167 monitor_section_detached ();
1173 SessionHandlePtr::session_going_away ();
1180 Mixer_UI::track_visibility_changed (std::string const & path)
1182 if (_session && _session->deletion_in_progress()) {
1188 if ((iter = track_model->get_iter (path))) {
1190 AxisView* av = (*iter)[stripable_columns.strip];
1191 bool visible = (*iter)[stripable_columns.visible];
1193 if (av->set_marked_for_display (!visible)) {
1194 update_track_visibility ();
1200 Mixer_UI::update_track_visibility ()
1202 TreeModel::Children rows = track_model->children();
1203 TreeModel::Children::iterator i;
1206 Unwinder<bool> uw (no_track_list_redisplay, true);
1208 for (i = rows.begin(); i != rows.end(); ++i) {
1209 AxisView* av = (*i)[stripable_columns.strip];
1210 (*i)[stripable_columns.visible] = av->marked_for_display ();
1213 /* force presentation to catch up with visibility changes */
1214 sync_presentation_info_from_treeview ();
1217 redisplay_track_list ();
1221 Mixer_UI::show_strip (MixerStrip* ms)
1223 TreeModel::Children rows = track_model->children();
1224 TreeModel::Children::iterator i;
1226 for (i = rows.begin(); i != rows.end(); ++i) {
1228 AxisView* av = (*i)[stripable_columns.strip];
1229 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1231 (*i)[stripable_columns.visible] = true;
1232 av->set_marked_for_display (true);
1233 update_track_visibility ();
1240 Mixer_UI::hide_strip (MixerStrip* ms)
1242 TreeModel::Children rows = track_model->children();
1243 TreeModel::Children::iterator i;
1245 for (i = rows.begin(); i != rows.end(); ++i) {
1247 AxisView* av = (*i)[stripable_columns.strip];
1248 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1250 (*i)[stripable_columns.visible] = false;
1251 av->set_marked_for_display (false);
1252 update_track_visibility ();
1259 Mixer_UI::start_updating ()
1261 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1266 Mixer_UI::stop_updating ()
1268 fast_screen_update_connection.disconnect();
1273 Mixer_UI::fast_update_strips ()
1275 if (_content.is_mapped () && _session) {
1276 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1277 (*i)->fast_update ();
1283 Mixer_UI::set_all_strips_visibility (bool yn)
1285 TreeModel::Children rows = track_model->children();
1286 TreeModel::Children::iterator i;
1289 Unwinder<bool> uw (no_track_list_redisplay, true);
1291 for (i = rows.begin(); i != rows.end(); ++i) {
1293 AxisView* av = (*i)[stripable_columns.strip];
1294 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1300 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1304 (*i)[stripable_columns.visible] = yn;
1307 /* force presentation to catch up with visibility changes */
1308 sync_presentation_info_from_treeview ();
1311 redisplay_track_list ();
1315 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1317 TreeModel::Children rows = track_model->children();
1318 TreeModel::Children::iterator i;
1321 Unwinder<bool> uw (no_track_list_redisplay, true);
1323 for (i = rows.begin(); i != rows.end(); ++i) {
1325 AxisView* av = (*i)[stripable_columns.strip];
1326 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1332 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1336 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1337 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1341 (*i)[stripable_columns.visible] = yn;
1345 if (at) { /* track */
1346 (*i)[stripable_columns.visible] = yn;
1351 if (!at && !mt) { /* bus */
1352 (*i)[stripable_columns.visible] = yn;
1357 if (mt) { /* midi-track */
1358 (*i)[stripable_columns.visible] = yn;
1364 /* force presentation to catch up with visibility changes */
1365 sync_presentation_info_from_treeview ();
1368 redisplay_track_list ();
1372 Mixer_UI::hide_all_routes ()
1374 set_all_strips_visibility (false);
1378 Mixer_UI::show_all_routes ()
1380 set_all_strips_visibility (true);
1384 Mixer_UI::show_all_audiobus ()
1386 set_all_audio_midi_visibility (2, true);
1389 Mixer_UI::hide_all_audiobus ()
1391 set_all_audio_midi_visibility (2, false);
1395 Mixer_UI::show_all_audiotracks()
1397 set_all_audio_midi_visibility (1, true);
1400 Mixer_UI::hide_all_audiotracks ()
1402 set_all_audio_midi_visibility (1, false);
1406 Mixer_UI::show_all_miditracks()
1408 set_all_audio_midi_visibility (3, true);
1411 Mixer_UI::hide_all_miditracks ()
1413 set_all_audio_midi_visibility (3, false);
1417 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1419 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1420 sync_presentation_info_from_treeview ();
1424 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1426 /* this happens as the second step of a DnD within the treeview as well
1427 as when a row/route is actually deleted.
1429 if it was a deletion then we have to force a redisplay because
1430 order keys may not have changed.
1433 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1434 sync_presentation_info_from_treeview ();
1436 if (_route_deletion_in_progress) {
1437 redisplay_track_list ();
1442 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1444 TreeModel::Children rows = track_model->children();
1445 std::list<boost::shared_ptr<VCA> > vcas;
1446 vcas.push_back (vca);
1448 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1449 AxisView* av = (*i)[stripable_columns.strip];
1450 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1451 if (vms && vms->vca()->slaved_to (vca)) {
1452 vcas.push_back (vms->vca());
1456 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1458 AxisView* av = (*i)[stripable_columns.strip];
1459 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1460 bool const visible = (*i)[stripable_columns.visible];
1463 /* we're in the middle of changing a row, don't worry */
1467 if (!strip->route()) {
1468 /* non-route element */
1472 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1476 bool slaved = false;
1477 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1478 if (strip->route()->slaved_to (*m)) {
1484 if (slaved && visible) {
1486 if (strip->packed()) {
1487 strip_packer.reorder_child (*strip, -1); /* put at end */
1489 strip_packer.pack_start (*strip, false, false);
1490 strip->set_packed (true);
1495 if (strip->packed()) {
1496 strip_packer.remove (*strip);
1497 strip->set_packed (false);
1504 Mixer_UI::redisplay_track_list ()
1506 if (no_track_list_redisplay) {
1510 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1512 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1514 if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) {
1515 _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value();
1517 spill_redisplay (sv);
1522 TreeModel::Children rows = track_model->children();
1523 TreeModel::Children::iterator i;
1524 uint32_t n_masters = 0;
1526 container_clear (vca_hpacker);
1528 vca_hpacker.pack_end (vca_scroller_base, true, true);
1529 vca_hpacker.pack_end (add_vca_button, false, false);
1531 add_vca_button.show ();
1532 vca_scroller_base.show();
1534 for (i = rows.begin(); i != rows.end(); ++i) {
1536 AxisView* s = (*i)[stripable_columns.strip];
1537 bool const visible = (*i)[stripable_columns.visible];
1538 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1541 /* we're in the middle of changing a row, don't worry */
1545 VCAMasterStrip* vms;
1547 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1549 vca_hpacker.pack_start (*vms, false, false);
1556 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1564 if (strip->packed()) {
1565 strip_packer.reorder_child (*strip, -1); /* put at end */
1567 strip_packer.pack_start (*strip, false, false);
1568 strip->set_packed (true);
1573 if (stripable->is_master() || stripable->is_monitor()) {
1574 /* do nothing, these cannot be hidden */
1576 if (strip->packed()) {
1577 strip_packer.remove (*strip);
1578 strip->set_packed (false);
1584 /* update visibility of VCA assign buttons */
1586 if (n_masters == 0) {
1587 //show/hide the channelstrip VCA assign buttons on channelstrips:
1588 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1590 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleVCAPane");
1592 act->set_sensitive (false);
1595 //remove the VCA packer, but don't change our prior setting for show/hide:
1596 vca_vpacker.hide ();
1598 //show/hide the channelstrip VCA assign buttons on channelstrips:
1599 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1601 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
1602 act->set_sensitive (true);
1604 //if we were showing VCAs before, show them now:
1605 showhide_vcas (act->get_active ());
1608 _group_tabs->set_dirty ();
1610 if (_spill_scroll_position > 0 && scroller.get_hscrollbar()) {
1611 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1612 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), _spill_scroll_position)));
1614 _spill_scroll_position = 0;
1619 Mixer_UI::strip_width_changed ()
1621 _group_tabs->set_dirty ();
1624 TreeModel::Children rows = track_model->children();
1625 TreeModel::Children::iterator i;
1628 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1629 AxisView* av = (*i)[stripable_columns.strip];
1630 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1636 bool visible = (*i)[stripable_columns.visible];
1639 strip->queue_draw();
1646 struct PresentationInfoMixerSorter
1648 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1649 if (a->is_master()) {
1650 /* master after everything else */
1652 } else if (b->is_master()) {
1653 /* everything else before master */
1656 return a->presentation_info().order () < b->presentation_info().order ();
1661 Mixer_UI::initial_track_display ()
1665 _session->get_stripables (sl);
1666 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1668 boost::shared_ptr<ARDOUR::Stripable> _current_foldback = *(fb.begin());
1669 sl.push_back (_current_foldback);
1672 sl.sort (PresentationInfoMixerSorter());
1675 /* These are also used inside ::add_stripables() but we need
1676 * them here because we're going to clear the track_model also.
1678 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1679 Unwinder<bool> uw2 (ignore_reorder, true);
1681 track_model->clear ();
1682 add_stripables (sl);
1685 sync_treeview_from_presentation_info (Properties::order);
1689 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1691 if (Keyboard::is_context_menu_event (ev)) {
1692 if (track_menu == 0) {
1693 build_track_menu ();
1695 track_menu->popup (ev->button, ev->time);
1698 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1699 TreeModel::Path path;
1700 TreeViewColumn* column;
1702 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1703 TreeIter iter = track_model->get_iter (path);
1704 if ((*iter)[stripable_columns.visible]) {
1705 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1706 move_stripable_into_view (s);
1715 Mixer_UI::move_vca_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1717 if (!vca_scroller.get_hscrollbar()) {
1723 Gtk::Allocation alloc;
1725 TreeModel::Children rows = track_model->children();
1726 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1727 AxisView* av = (*i)[stripable_columns.strip];
1728 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1729 if (vms && vms->stripable () == s) {
1732 vms->translate_coordinates (vca_hpacker, 0, 0, x0, y);
1733 alloc = vms->get_allocation ();
1742 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
1744 if (x0 < adj->get_value()) {
1745 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1746 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1747 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1748 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1753 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1755 if (!scroller.get_hscrollbar()) {
1758 if (s->presentation_info().special ()) {
1761 if (s->presentation_info().flag_match (PresentationInfo::VCA)) {
1762 move_vca_into_view (s);
1771 Gtk::Allocation alloc;
1772 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1773 if ((*i)->route() == s) {
1776 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1777 alloc = (*i)->get_allocation ();
1785 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1787 if (x0 < adj->get_value()) {
1788 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1789 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1790 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1791 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1796 Mixer_UI::build_track_menu ()
1798 using namespace Menu_Helpers;
1799 using namespace Gtk;
1801 track_menu = new Menu;
1802 track_menu->set_name ("ArdourContextMenu");
1803 MenuList& items = track_menu->items();
1805 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1806 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1807 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1808 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1809 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1810 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1811 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1812 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1817 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1819 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1823 boost::shared_ptr<Stripable> s = ws.lock ();
1829 TreeModel::Children rows = track_model->children();
1830 TreeModel::Children::iterator i;
1832 for (i = rows.begin(); i != rows.end(); ++i) {
1833 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1837 if (what_changed.contains (ARDOUR::Properties::name)) {
1838 (*i)[stripable_columns.text] = s->name();
1841 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1842 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1843 redisplay_track_list ();
1850 if (s->is_master ()) {
1854 error << _("track display list item for renamed strip not found!") << endmsg;
1858 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1860 TreeModel::Path path;
1861 TreeViewColumn* column;
1865 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1866 if (ev->button == 3) {
1867 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1872 TreeIter iter = group_model->get_iter (path);
1874 if (ev->button == 3) {
1875 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1880 RouteGroup* group = (*iter)[group_columns.group];
1882 if (Keyboard::is_context_menu_event (ev)) {
1883 _group_tabs->get_menu(group)->popup (1, ev->time);
1887 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1889 if (Keyboard::is_edit_event (ev)) {
1891 // edit_route_group (group);
1893 group_display.queue_draw();
1902 bool visible = (*iter)[group_columns.visible];
1903 (*iter)[group_columns.visible] = !visible;
1905 group_display.queue_draw();
1918 Mixer_UI::activate_all_route_groups ()
1920 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1924 Mixer_UI::disable_all_route_groups ()
1926 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1930 Mixer_UI::route_groups_changed ()
1932 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1934 _in_group_rebuild_or_clear = true;
1936 /* just rebuild the while thing */
1938 group_model->clear ();
1941 /* this is currently not used,
1942 * Mixer_UI::group_display_button_press() has a case for it,
1943 * and a commented edit_route_group() but that's n/a since 2011.
1945 * This code is left as reminder that
1946 * row[group_columns.group] = 0 has special meaning.
1950 row = *(group_model->append());
1951 row[group_columns.visible] = true;
1952 row[group_columns.text] = (_("-all-"));
1953 row[group_columns.group] = 0;
1957 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1959 _group_tabs->set_dirty ();
1960 _in_group_rebuild_or_clear = false;
1964 Mixer_UI::new_route_group ()
1966 _group_tabs->run_new_group_dialog (0, false);
1970 Mixer_UI::remove_selected_route_group ()
1972 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1973 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1979 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1982 /* selection mode is single, so rows.begin() is it */
1984 if ((iter = group_model->get_iter (*i))) {
1986 RouteGroup* rg = (*iter)[group_columns.group];
1989 _session->remove_route_group (*rg);
1995 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1997 if (in_group_row_change) {
2001 /* force an update of any mixer strips that are using this group,
2002 otherwise mix group names don't change in mixer strips
2005 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
2006 if ((*i)->route_group() == group) {
2007 (*i)->route_group_changed();
2011 TreeModel::iterator i;
2012 TreeModel::Children rows = group_model->children();
2013 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
2015 in_group_row_change = true;
2017 for (i = rows.begin(); i != rows.end(); ++i) {
2018 if ((*i)[group_columns.group] == group) {
2019 (*i)[group_columns.visible] = !group->is_hidden ();
2020 (*i)[group_columns.text] = group->name ();
2025 in_group_row_change = false;
2027 if (change.contains (Properties::name)) {
2028 _group_tabs->set_dirty ();
2031 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
2032 if ((*j)->route_group() == group) {
2033 if (group->is_hidden ()) {
2043 Mixer_UI::toggle_mixer_list ()
2045 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2046 showhide_mixer_list (act->get_active());
2050 Mixer_UI::showhide_mixer_list (bool yn)
2053 list_vpacker.show ();
2055 list_vpacker.hide ();
2060 Mixer_UI::toggle_monitor_section ()
2062 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2063 showhide_monitor_section (act->get_active());
2068 Mixer_UI::showhide_monitor_section (bool yn)
2070 if (monitor_section().tearoff().torn_off()) {
2075 monitor_section().tearoff().show();
2077 monitor_section().tearoff().hide();
2082 Mixer_UI::toggle_foldback_strip ()
2084 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
2085 showhide_foldback_strip (act->get_active());
2090 Mixer_UI::showhide_foldback_strip (bool yn)
2092 _show_foldback_strip = yn;
2094 if (foldback_strip) {
2096 foldback_strip->show();
2098 foldback_strip->hide();
2104 Mixer_UI::toggle_vcas ()
2106 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2107 showhide_vcas (act->get_active());
2111 Mixer_UI::showhide_vcas (bool yn)
2122 Mixer_UI::toggle_mixbuses ()
2124 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2125 showhide_mixbuses (act->get_active());
2129 Mixer_UI::showhide_mixbuses (bool on)
2141 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
2146 if ((iter = group_model->get_iter (path))) {
2148 if ((group = (*iter)[group_columns.group]) == 0) {
2152 if (new_text != group->name()) {
2153 group->set_name (new_text);
2159 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
2163 if (in_group_row_change) {
2167 if ((group = (*iter)[group_columns.group]) == 0) {
2171 std::string name = (*iter)[group_columns.text];
2173 if (name != group->name()) {
2174 group->set_name (name);
2177 bool hidden = !(*iter)[group_columns.visible];
2179 if (hidden != group->is_hidden ()) {
2180 group->set_hidden (hidden, this);
2184 /** Called when a group model row is deleted, but also when the model is
2185 * reordered by a user drag-and-drop; the latter is what we are
2186 * interested in here.
2189 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
2191 if (_in_group_rebuild_or_clear) {
2195 /* Re-write the session's route group list so that the new order is preserved */
2197 list<RouteGroup*> new_list;
2199 Gtk::TreeModel::Children children = group_model->children();
2200 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
2201 RouteGroup* g = (*i)[group_columns.group];
2203 new_list.push_back (g);
2207 _session->reorder_route_groups (new_list);
2212 Mixer_UI::add_route_group (RouteGroup* group)
2214 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
2217 in_group_row_change = true;
2219 TreeModel::Row row = *(group_model->append());
2220 row[group_columns.visible] = !group->is_hidden ();
2221 row[group_columns.group] = group;
2222 if (!group->name().empty()) {
2223 row[group_columns.text] = group->name();
2225 row[group_columns.text] = _("unnamed");
2229 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
2232 TreeViewColumn* col = group_display.get_column (0);
2233 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
2234 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
2237 _group_tabs->set_dirty ();
2239 in_group_row_change = false;
2243 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
2245 using namespace Menu_Helpers;
2247 if (Keyboard::is_context_menu_event (ev)) {
2248 ARDOUR_UI::instance()->add_route ();
2256 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
2258 if (data.get_target() != "PluginFavoritePtr") {
2259 context->drag_finish (false, false, time);
2263 const void * d = data.get_data();
2264 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2266 PluginPresetList nfos;
2268 tv->get_object_drag_data (nfos, &source);
2270 Route::ProcessorList pl;
2273 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2274 PluginPresetPtr ppp = (*i);
2275 PluginInfoPtr pip = ppp->_pip;
2276 if (!pip->is_instrument ()) {
2279 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);
2283 context->drag_finish (ok, false, time);
2287 Mixer_UI::set_strip_width (Width w, bool save)
2291 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2292 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2297 struct PluginStateSorter {
2299 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2300 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2301 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2302 if (aiter != _user.end() && biter != _user.end()) {
2303 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2305 if (aiter != _user.end()) {
2308 if (biter != _user.end()) {
2311 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2314 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2316 std::list<std::string> _user;
2320 Mixer_UI::set_state (const XMLNode& node, int version)
2324 Tabbable::set_state (node, version);
2326 if (node.get_property ("narrow-strips", yn)) {
2328 set_strip_width (Narrow);
2330 set_strip_width (Wide);
2334 node.get_property ("show-mixer", _visible);
2337 node.get_property ("maximised", yn);
2339 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Common"), X_("ToggleMaximalMixer"));
2340 bool fs = act && act->get_active();
2342 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2347 node.get_property ("show-mixer-list", yn);
2349 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixerList"));
2350 /* do it twice to force the change */
2351 act->set_active (!yn);
2352 act->set_active (yn);
2356 node.get_property ("monitor-section-visible", yn);
2358 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection"));
2359 /* do it twice to force the change */
2360 act->set_active (!yn);
2361 act->set_active (yn);
2365 node.get_property ("foldback-strip-visible", yn);
2367 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleFoldbackStrip"));
2368 /* do it twice to force the change */
2369 act->set_active (!yn);
2370 act->set_active (yn);
2374 node.get_property ("show-vca-pane", yn);
2376 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleVCAPane"));
2377 /* do it twice to force the change */
2378 act->set_active (!yn);
2379 act->set_active (yn);
2384 node.get_property ("show-mixbus-pane", yn);
2386 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixbusPane"));
2387 /* do it twice to force the change */
2388 act->set_active (!yn);
2389 act->set_active (yn);
2393 //check for the user's plugin_order file
2394 XMLNode plugin_order_new(X_("PO"));
2395 if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) {
2396 store_current_favorite_order ();
2397 std::list<string> order;
2398 const XMLNodeList& kids = plugin_order_new.children("PluginInfo");
2399 XMLNodeConstIterator i;
2400 for (i = kids.begin(); i != kids.end(); ++i) {
2401 std::string unique_id;
2402 if ((*i)->get_property ("unique-id", unique_id)) {
2403 order.push_back (unique_id);
2404 if ((*i)->get_property ("expanded", yn)) {
2405 favorite_ui_state[unique_id] = yn;
2409 PluginStateSorter cmp (order);
2410 favorite_order.sort (cmp);
2411 sync_treeview_from_favorite_order ();
2414 //if there is no user file, then use an existing one from instant.xml
2415 //NOTE: if you are loading an old session, this might come from the session's instant.xml
2416 //Todo: in the next major version, we should probably stop doing the instant.xml check, and just use the new file
2417 XMLNode* plugin_order;
2418 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2419 store_current_favorite_order ();
2420 std::list<string> order;
2421 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2422 XMLNodeConstIterator i;
2423 for (i = kids.begin(); i != kids.end(); ++i) {
2424 std::string unique_id;
2425 if ((*i)->get_property ("unique-id", unique_id)) {
2426 order.push_back (unique_id);
2427 if ((*i)->get_property ("expanded", yn)) {
2428 favorite_ui_state[unique_id] = yn;
2433 PluginStateSorter cmp (order);
2434 favorite_order.sort (cmp);
2435 sync_treeview_from_favorite_order ();
2443 Mixer_UI::save_plugin_order_file ()
2445 //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order )
2447 //NOTE: this replaces the old code that stores info in instant.xml
2448 //why? because instant.xml prefers the per-session settings, and we want this to be a global pref
2450 store_current_favorite_order ();
2451 XMLNode plugin_order ("PluginOrder");
2453 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2454 XMLNode* p = new XMLNode ("PluginInfo");
2455 p->set_property ("sort", cnt);
2456 p->set_property ("unique-id", (*i)->unique_id);
2457 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2458 p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2460 plugin_order.add_child_nocopy (*p);
2462 PluginManager::instance().save_plugin_order_file( plugin_order );
2466 Mixer_UI::get_state ()
2468 XMLNode* node = new XMLNode (X_("Mixer"));
2470 node->add_child_nocopy (Tabbable::get_state());
2472 node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider());
2473 node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider());
2474 node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider());
2475 node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider());
2477 node->set_property ("narrow-strips", (_strip_width == Narrow));
2478 node->set_property ("show-mixer", _visible);
2479 node->set_property ("maximised", _maximised);
2481 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2482 node->set_property ("show-mixer-list", act->get_active ());
2484 act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2485 node->set_property ("monitor-section-visible", act->get_active ());
2487 act = ActionManager::get_toggle_action ("Mixer", "ToggleFoldbackStrip");
2488 node->set_property ("foldback-strip-visible", act->get_active ());
2490 act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2491 node->set_property ("show-vca-pane", act->get_active ());
2494 act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2495 node->set_property ("show-mixbus-pane", act->get_active ());
2502 Mixer_UI::scroll_left ()
2504 if (!scroller.get_hscrollbar()) return;
2505 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2506 int sc_w = scroller.get_width();
2507 int sp_w = strip_packer.get_width();
2511 int lp = adj->get_value();
2513 using namespace Gtk::Box_Helpers;
2514 const BoxList& strips = strip_packer.children();
2515 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2516 if (i->get_widget() == & add_button) {
2520 if (i->get_widget() == &mb_shadow) {
2524 lm += i->get_widget()->get_width ();
2526 lm -= i->get_widget()->get_width ();
2530 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2534 Mixer_UI::scroll_right ()
2536 if (!scroller.get_hscrollbar()) return;
2537 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2538 int sc_w = scroller.get_width();
2539 int sp_w = strip_packer.get_width();
2543 int lp = adj->get_value();
2545 using namespace Gtk::Box_Helpers;
2546 const BoxList& strips = strip_packer.children();
2547 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2548 if (i->get_widget() == & add_button) {
2552 if (i->get_widget() == &mb_shadow) {
2556 lm += i->get_widget()->get_width ();
2561 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2565 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2567 switch (ev->direction) {
2568 case GDK_SCROLL_LEFT:
2572 if (ev->state & Keyboard::TertiaryModifier) {
2578 case GDK_SCROLL_RIGHT:
2582 case GDK_SCROLL_DOWN:
2583 if (ev->state & Keyboard::TertiaryModifier) {
2594 Mixer_UI::vca_scroll_left ()
2596 if (!vca_scroller.get_hscrollbar()) return;
2597 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2598 int sc_w = vca_scroller.get_width();
2599 int sp_w = strip_packer.get_width();
2603 int lp = adj->get_value();
2605 using namespace Gtk::Box_Helpers;
2606 const BoxList& strips = vca_hpacker.children();
2607 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2608 if (i->get_widget() == &add_vca_button) {
2611 lm += i->get_widget()->get_width ();
2613 lm -= i->get_widget()->get_width ();
2617 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2621 Mixer_UI::vca_scroll_right ()
2623 if (!vca_scroller.get_hscrollbar()) return;
2624 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2625 int sc_w = vca_scroller.get_width();
2626 int sp_w = strip_packer.get_width();
2630 int lp = adj->get_value();
2632 using namespace Gtk::Box_Helpers;
2633 const BoxList& strips = vca_hpacker.children();
2634 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2635 if (i->get_widget() == &add_vca_button) {
2638 lm += i->get_widget()->get_width ();
2643 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2647 Mixer_UI::on_vca_scroll_event (GdkEventScroll* ev)
2649 switch (ev->direction) {
2650 case GDK_SCROLL_LEFT:
2654 if (ev->state & Keyboard::TertiaryModifier) {
2660 case GDK_SCROLL_RIGHT:
2661 vca_scroll_right ();
2664 case GDK_SCROLL_DOWN:
2665 if (ev->state & Keyboard::TertiaryModifier) {
2666 vca_scroll_right ();
2676 Mixer_UI::parameter_changed (string const & p)
2678 if (p == "show-group-tabs") {
2679 bool const s = _session->config.get_show_group_tabs ();
2681 _group_tabs->show ();
2683 _group_tabs->hide ();
2685 } else if (p == "default-narrow_ms") {
2686 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2687 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2688 (*i)->set_width_enum (s ? Narrow : Wide, this);
2694 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2696 g->set_active (a, this);
2700 Mixer_UI::plugin_selector()
2702 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2703 if (!_plugin_selector)
2704 _plugin_selector = new PluginSelector (PluginManager::instance());
2707 return _plugin_selector;
2711 Mixer_UI::setup_track_display ()
2713 track_model = ListStore::create (stripable_columns);
2714 track_display.set_model (track_model);
2715 track_display.append_column (_("Show"), stripable_columns.visible);
2716 track_display.append_column (_("Strips"), stripable_columns.text);
2717 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2718 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2719 track_display.get_column (0)->set_expand(false);
2720 track_display.get_column (1)->set_expand(true);
2721 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2722 track_display.set_name (X_("EditGroupList"));
2723 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2724 track_display.set_reorderable (true);
2725 track_display.set_headers_visible (true);
2726 track_display.set_can_focus(false);
2728 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2729 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2731 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2732 track_list_visible_cell->property_activatable() = true;
2733 track_list_visible_cell->property_radio() = false;
2734 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2736 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2738 track_display_scroller.add (track_display);
2739 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2741 VBox* v = manage (new VBox);
2743 v->pack_start (track_display_scroller, true, true);
2745 track_display_frame.set_name("BaseFrame");
2746 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2747 track_display_frame.add (*v);
2749 track_display_scroller.show();
2750 track_display_frame.show();
2751 track_display.show();
2755 Mixer_UI::new_track_or_bus ()
2757 ARDOUR_UI::instance()->add_route ();
2761 Mixer_UI::update_title ()
2763 if (!own_window()) {
2770 if (_session->snap_name() != _session->name()) {
2771 n = _session->snap_name ();
2773 n = _session->name ();
2776 if (_session->dirty ()) {
2780 WindowTitle title (n);
2781 title += S_("Window|Mixer");
2782 title += Glib::get_application_name ();
2783 own_window()->set_title (title.get_string());
2787 WindowTitle title (S_("Window|Mixer"));
2788 title += Glib::get_application_name ();
2789 own_window()->set_title (title.get_string());
2794 Mixer_UI::strip_by_x (int x)
2796 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2799 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2800 x2 = x1 + (*i)->get_width();
2802 if (x >= x1 && x <= x2) {
2811 Mixer_UI::set_axis_targets_for_operation ()
2813 _axis_targets.clear ();
2815 if (!_selection.empty()) {
2816 _axis_targets = _selection.axes;
2820 // removed "implicit" selections of strips, after discussion on IRC
2825 Mixer_UI::monitor_section_going_away ()
2827 XMLNode* ui_node = Config->extra_xml(X_("UI"));
2829 /* immediate state save.
2831 * Tearoff settings are otherwise only stored during
2832 * save_ardour_state(). The mon-section may or may not
2833 * exist at that point.
2837 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
2839 tearoff_node->remove_nodes_and_delete (X_("monitor-section"));
2840 XMLNode* t = new XMLNode (X_("monitor-section"));
2841 _monitor_section.tearoff().add_state (*t);
2842 tearoff_node->add_child_nocopy (*t);
2846 monitor_section_detached ();
2847 out_packer.remove (_monitor_section.tearoff());
2851 Mixer_UI::toggle_midi_input_active (bool flip_others)
2853 boost::shared_ptr<RouteList> rl (new RouteList);
2856 set_axis_targets_for_operation ();
2858 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2859 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2863 onoff = !mt->input_active();
2867 _session->set_exclusive_input_active (rl, onoff, flip_others);
2871 Mixer_UI::maximise_mixer_space ()
2873 if (!own_window()) {
2881 _window->fullscreen ();
2886 Mixer_UI::restore_mixer_space ()
2888 if (!own_window()) {
2896 own_window()->unfullscreen();
2901 Mixer_UI::monitor_section_attached ()
2903 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2904 act->set_sensitive (true);
2905 showhide_monitor_section (act->get_active ());
2909 Mixer_UI::monitor_section_detached ()
2911 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleMonitorSection");
2912 act->set_sensitive (false);
2916 Mixer_UI::store_current_favorite_order ()
2918 typedef Gtk::TreeModel::Children type_children;
2919 type_children children = favorite_plugins_model->children();
2920 favorite_order.clear();
2921 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2923 Gtk::TreeModel::Row row = *iter;
2924 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2925 favorite_order.push_back (ppp->_pip);
2926 std::string name = row[favorite_plugins_columns.name];
2927 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2932 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2934 Gtk::TreeModel::Row row = *iter;
2935 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2937 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2941 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2943 PluginManager& manager (PluginManager::instance());
2944 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2946 /* not a Favorite? skip it */
2947 if (manager.get_status (*i) != PluginManager::Favorite) {
2951 /* Check the tag combo selection, and skip this plugin if it doesn't match the selected tag(s) */
2952 string test = favorite_plugins_tag_combo.get_active_text();
2953 if (test != _("Show All")) {
2954 vector<string> tags = manager.get_tags(*i);
2956 //does the selected tag match any of the tags in the plugin?
2957 vector<string>::iterator tt = find (tags.begin(), tags.end(), test);
2958 if (tt == tags.end()) {
2963 result.push_back (*i);
2967 struct PluginCustomSorter {
2969 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2970 PluginInfoList::const_iterator aiter = _user.begin();
2971 PluginInfoList::const_iterator biter = _user.begin();
2972 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2973 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2975 if (aiter != _user.end() && biter != _user.end()) {
2976 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2978 if (aiter != _user.end()) {
2981 if (biter != _user.end()) {
2984 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2986 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2988 PluginInfoList _user;
2992 Mixer_UI::refill_favorite_plugins ()
2994 PluginInfoList plugs;
2995 PluginManager& mgr (PluginManager::instance());
2998 refiller (plugs, mgr.lv2_plugin_info ());
3000 #ifdef WINDOWS_VST_SUPPORT
3001 refiller (plugs, mgr.windows_vst_plugin_info ());
3003 #ifdef LXVST_SUPPORT
3004 refiller (plugs, mgr.lxvst_plugin_info ());
3006 #ifdef MACVST_SUPPORT
3007 refiller (plugs, mgr.mac_vst_plugin_info ());
3009 #ifdef AUDIOUNIT_SUPPORT
3010 refiller (plugs, mgr.au_plugin_info ());
3012 refiller (plugs, mgr.ladspa_plugin_info ());
3013 refiller (plugs, mgr.lua_plugin_info ());
3015 store_current_favorite_order ();
3017 PluginCustomSorter cmp (favorite_order);
3020 favorite_order = plugs;
3022 sync_treeview_from_favorite_order ();
3026 Mixer_UI::plugin_list_changed ()
3028 refill_favorite_plugins();
3033 Mixer_UI::refill_tag_combo ()
3035 PluginManager& mgr (PluginManager::instance());
3037 std::vector<std::string> tags = mgr.get_all_tags (PluginManager::OnlyFavorites);
3039 favorite_plugins_tag_combo.clear();
3040 favorite_plugins_tag_combo.append_text (_("Show All"));
3042 for (vector<string>::iterator t = tags.begin (); t != tags.end (); ++t) {
3043 favorite_plugins_tag_combo.append_text (*t);
3046 favorite_plugins_tag_combo.set_active_text (_("Show All"));
3050 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
3053 if (!(iter = favorite_plugins_model->get_iter (path))) {
3056 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3060 PluginInfoPtr pip = ppp->_pip;
3061 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3062 if (favorite_ui_state[pip->unique_id]) {
3063 favorite_plugins_display.expand_row (path, true);
3069 Mixer_UI::sync_treeview_from_favorite_order ()
3071 favorite_plugins_model->clear ();
3072 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
3073 PluginInfoPtr pip = (*i);
3075 TreeModel::Row newrow = *(favorite_plugins_model->append());
3076 newrow[favorite_plugins_columns.name] = (*i)->name;
3077 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
3082 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
3083 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
3087 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
3088 child_row[favorite_plugins_columns.name] = (*j).label;
3089 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
3091 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3092 if (favorite_ui_state[pip->unique_id]) {
3093 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
3100 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
3102 using namespace Gtk::Menu_Helpers;
3104 Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu ();
3105 MenuList& items = m->items ();
3107 if (_selection.axes.empty()) {
3108 items.push_back (MenuElem (_("No Track/Bus is selected.")));
3110 items.push_back (MenuElem (_("Add at the top"),
3111 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
3112 items.push_back (MenuElem (_("Add Pre-Fader"),
3113 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
3114 items.push_back (MenuElem (_("Add Post-Fader"),
3115 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
3116 items.push_back (MenuElem (_("Add at the end"),
3117 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
3120 items.push_back (SeparatorElem());
3122 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
3124 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3125 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
3126 // we cannot currently delete AU presets
3127 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
3128 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
3132 m->popup (ev->button, ev->time);
3136 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
3138 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
3139 TreeModel::Path path;
3140 TreeViewColumn* column;
3142 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
3143 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3145 selection->unselect_all();
3146 selection->select(path);
3149 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3151 popup_note_context_menu (ev);
3159 Mixer_UI::selected_plugin ()
3161 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3163 return PluginPresetPtr();
3165 Gtk::TreeModel::iterator iter = selection->get_selected();
3167 return PluginPresetPtr();
3169 return (*iter)[favorite_plugins_columns.plugin];
3173 Mixer_UI::add_selected_processor (ProcessorPosition pos)
3175 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3177 add_favorite_processor (ppp, pos);
3182 Mixer_UI::delete_selected_preset ()
3187 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3188 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
3191 PluginPtr plugin = ppp->_pip->load (*_session);
3192 plugin->get_presets();
3193 plugin->remove_preset (ppp->_preset.label);
3197 Mixer_UI::remove_selected_from_favorites ()
3199 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3203 PluginManager::PluginStatusType status = PluginManager::Normal;
3204 PluginManager& manager (PluginManager::instance());
3206 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3207 manager.save_statuses ();
3211 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
3214 if (!(iter = favorite_plugins_model->get_iter (path))) {
3217 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3218 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
3222 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
3224 if (!_session || _selection.axes.empty()) {
3228 PluginInfoPtr pip = ppp->_pip;
3229 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
3230 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
3236 PluginPtr p = pip->load (*_session);
3242 if (ppp->_preset.valid) {
3243 p->load_preset (ppp->_preset);
3246 Route::ProcessorStreams err;
3247 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
3251 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
3254 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
3261 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
3265 if (!np->display_to_user()) {
3268 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
3269 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
3274 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
3278 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
3285 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
3287 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
3291 // only allow to re-order top-level items
3293 if (TreePath::get_from_selection_data (data, src)) {
3294 if (src.up() && src.up()) {
3299 // don't allow to drop as child-rows.
3300 Gtk::TreeModel::Path _dest = dest; // un const
3301 const bool is_child = _dest.up (); // explicit bool for clang
3302 if (!is_child || _dest.empty ()) {
3309 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
3311 if (data.get_target() != "PluginPresetPtr") {
3314 if (data.get_length() != sizeof (PluginPresetPtr)) {
3317 const void *d = data.get_data();
3318 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
3320 PluginManager::PluginStatusType status = PluginManager::Favorite;
3321 PluginManager& manager (PluginManager::instance());
3323 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3324 manager.save_statuses ();
3328 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
3330 /* call protected MixerActor:: method */
3335 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
3337 /* call protected MixerActor:: method */
3342 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
3344 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
3347 show_spill_change (s); /* EMIT SIGNAL */
3349 _group_tabs->hide ();
3351 _group_tabs->show ();
3353 redisplay_track_list ();
3358 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
3360 return s == spilled_strip.lock();
3364 Mixer_UI::register_actions ()
3366 Glib::RefPtr<ActionGroup> group = ActionManager::create_action_group (bindings, X_("Mixer"));
3368 ActionManager::register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
3369 ActionManager::register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
3370 ActionManager::register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
3371 ActionManager::register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
3372 ActionManager::register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
3373 ActionManager::register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
3376 ActionManager::register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
3377 ActionManager::register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
3378 ActionManager::register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
3379 ActionManager::register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
3380 ActionManager::register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
3381 ActionManager::register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
3382 ActionManager::register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
3383 ActionManager::register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
3385 ActionManager::register_action (group, "select-next-stripable", _("Select Next Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_next_strip));
3386 ActionManager::register_action (group, "select-prev-stripable", _("Scroll Previous Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_prev_strip));
3388 ActionManager::register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
3389 ActionManager::register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
3391 ActionManager::register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
3392 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
3394 ActionManager::register_toggle_action (group, X_("ToggleMixerList"), _("Mixer: Show Mixer List"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixer_list));
3396 ActionManager::register_toggle_action (group, X_("ToggleVCAPane"), _("Mixer: Show VCAs"), sigc::mem_fun (*this, &Mixer_UI::toggle_vcas));
3399 ActionManager::register_toggle_action (group, X_("ToggleMixbusPane"), _("Mixer: Show Mixbusses"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixbuses));
3402 ActionManager::register_toggle_action (group, X_("ToggleMonitorSection"), _("Mixer: Show Monitor Section"), sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_section));
3404 ActionManager::register_toggle_action (group, X_("ToggleFoldbackStrip"), _("Mixer: Show Foldback Strip"), sigc::mem_fun (*this, &Mixer_UI::toggle_foldback_strip));
3409 Mixer_UI::load_bindings ()
3411 bindings = Bindings::get_bindings (X_("Mixer"));
3414 template<class T> void
3415 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
3417 boost::shared_ptr<ControlList> cl (new ControlList);
3418 boost::shared_ptr<AutomationControl> ac;
3420 bool have_val = false;
3422 set_axis_targets_for_operation ();
3424 BOOST_FOREACH(AxisView* r, _axis_targets) {
3425 boost::shared_ptr<Stripable> s = r->stripable();
3427 ac = (s.get()->*get_control)();
3429 ac->start_touch (_session->audible_sample ());
3432 val = !ac->get_value();
3439 _session->set_controls (cl, val, Controllable::UseGroup);
3443 Mixer_UI::solo_action ()
3445 control_action (&Stripable::solo_control);
3449 Mixer_UI::mute_action ()
3451 control_action (&Stripable::mute_control);
3455 Mixer_UI::rec_enable_action ()
3457 control_action (&Stripable::rec_enable_control);
3460 AutomationControlSet
3461 Mixer_UI::selected_gaincontrols ()
3463 set_axis_targets_for_operation ();
3464 AutomationControlSet rv;
3465 BOOST_FOREACH(AxisView* r, _axis_targets) {
3466 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3468 boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
3469 ControlList cl (ac->grouped_controls());
3470 for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
3480 Mixer_UI::step_gain_up_action ()
3482 AutomationControlSet acs = selected_gaincontrols ();
3483 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3484 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3486 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
3491 Mixer_UI::step_gain_down_action ()
3493 AutomationControlSet acs = selected_gaincontrols ();
3494 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3495 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3497 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
3502 Mixer_UI::unity_gain_action ()
3504 set_axis_targets_for_operation ();
3506 BOOST_FOREACH(AxisView* r, _axis_targets) {
3507 boost::shared_ptr<Stripable> s = r->stripable();
3509 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3511 ac->set_value (1.0, Controllable::UseGroup);
3518 Mixer_UI::copy_processors ()
3520 set_axis_targets_for_operation ();
3522 BOOST_FOREACH(AxisView* r, _axis_targets) {
3523 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3525 ms->copy_processors ();
3530 Mixer_UI::cut_processors ()
3532 set_axis_targets_for_operation ();
3534 BOOST_FOREACH(AxisView* r, _axis_targets) {
3535 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3537 ms->cut_processors ();
3542 Mixer_UI::paste_processors ()
3544 set_axis_targets_for_operation ();
3546 BOOST_FOREACH(AxisView* r, _axis_targets) {
3547 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3549 ms->paste_processors ();
3554 Mixer_UI::select_all_processors ()
3556 set_axis_targets_for_operation ();
3558 BOOST_FOREACH(AxisView* r, _axis_targets) {
3559 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3561 ms->select_all_processors ();
3566 Mixer_UI::toggle_processors ()
3568 set_axis_targets_for_operation ();
3570 BOOST_FOREACH(AxisView* r, _axis_targets) {
3571 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3573 ms->toggle_processors ();
3578 Mixer_UI::ab_plugins ()
3580 set_axis_targets_for_operation ();
3582 BOOST_FOREACH(AxisView* r, _axis_targets) {
3583 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3591 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3593 set_axis_targets_for_operation ();
3594 BOOST_FOREACH(AxisView* r, _axis_targets) {
3595 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3597 ms->vca_assign (vca);
3603 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3605 set_axis_targets_for_operation ();
3606 BOOST_FOREACH(AxisView* r, _axis_targets) {
3607 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3609 ms->vca_unassign (vca);
3615 Mixer_UI::screenshot (std::string const& filename)
3621 int height = strip_packer.get_height();
3622 bool with_vca = vca_vpacker.is_visible ();
3623 MixerStrip* master = strip_by_route (_session->master_out ());
3625 Gtk::OffscreenWindow osw;
3630 /* unpack widgets, add to OffscreenWindow */
3632 strip_group_box.remove (strip_packer);
3633 b.pack_start (strip_packer, false, false);
3634 /* hide extra elements inside strip_packer */
3636 scroller_base.hide ();
3642 /* work around Gtk::ScrolledWindow */
3643 Gtk::Viewport* viewport = (Gtk::Viewport*) vca_scroller.get_child();
3644 viewport->remove (); // << vca_hpacker
3645 b.pack_start (vca_hpacker, false, false);
3646 /* hide some growing widgets */
3647 add_vca_button.hide ();
3648 vca_scroller_base.hide();
3652 out_packer.remove (*master);
3653 b.pack_start (*master, false, false);
3654 master->hide_master_spacer (true);
3657 /* prepare the OffscreenWindow for rendering */
3658 osw.set_size_request (-1, height);
3660 osw.queue_resize ();
3662 osw.get_window()->process_updates (true);
3664 /* create screenshot */
3665 Glib::RefPtr<Gdk::Pixbuf> pb = osw.get_pixbuf ();
3666 pb->save (filename, "png");
3668 /* unpack elements before destorying the Box & OffscreenWindow */
3669 list<Gtk::Widget*> children = b.get_children();
3670 for (list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
3675 /* now re-pack the widgets into the main mixer window */
3677 scroller_base.show ();
3681 strip_group_box.pack_start (strip_packer);
3683 add_vca_button.show ();
3684 vca_scroller_base.show();
3685 vca_scroller.add (vca_hpacker);
3688 master->hide_master_spacer (false);
3689 out_packer.pack_start (*master, false, false);