2 * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3 * Copyright (C) 2005-2018 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2006-2007 Doug McLain <doug@nostar.net>
5 * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2007-2012 David Robillard <d@drobilla.net>
7 * Copyright (C) 2007-2016 Tim Mayberry <mojofunk@gmail.com>
8 * Copyright (C) 2013-2015 Nick Mainsbridge <mainsbridge@gmail.com>
9 * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
10 * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
11 * Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "gtk2ardour-config.h"
34 #include <sigc++/bind.h>
36 #include <boost/foreach.hpp>
38 #include <glibmm/threads.h>
40 #include <gtkmm/accelmap.h>
41 #include <gtkmm/offscreenwindow.h>
42 #include <gtkmm/stock.h>
44 #include "pbd/convert.h"
45 #include "pbd/stacktrace.h"
46 #include "pbd/unwind.h"
48 #include "ardour/amp.h"
49 #include "ardour/debug.h"
50 #include "ardour/audio_track.h"
51 #include "ardour/midi_track.h"
52 #include "ardour/plugin_manager.h"
53 #include "ardour/route_group.h"
54 #include "ardour/selection.h"
55 #include "ardour/session.h"
56 #include "ardour/vca.h"
57 #include "ardour/vca_manager.h"
59 #include "gtkmm2ext/gtk_ui.h"
60 #include "gtkmm2ext/keyboard.h"
61 #include "gtkmm2ext/utils.h"
62 #include "gtkmm2ext/window_title.h"
63 #include "gtkmm2ext/doi.h"
65 #include "widgets/tearoff.h"
67 #include "foldback_strip.h"
70 #include "mixer_strip.h"
71 #include "monitor_section.h"
72 #include "plugin_selector.h"
73 #include "public_editor.h"
74 #include "mouse_cursors.h"
75 #include "ardour_ui.h"
77 #include "route_sorter.h"
79 #include "gui_thread.h"
80 #include "mixer_group_tabs.h"
81 #include "route_sorter.h"
83 #include "ui_config.h"
84 #include "vca_master_strip.h"
88 using namespace ARDOUR;
89 using namespace ARDOUR_UI_UTILS;
93 using namespace Gtkmm2ext;
99 Mixer_UI* Mixer_UI::_instance = 0;
102 Mixer_UI::instance ()
105 _instance = new Mixer_UI;
111 Mixer_UI::Mixer_UI ()
112 : Tabbable (_content, _("Mixer"))
113 , no_track_list_redisplay (false)
114 , in_group_row_change (false)
116 , _plugin_selector (0)
118 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
119 , _spill_scroll_position (0)
120 , ignore_reorder (false)
121 , _in_group_rebuild_or_clear (false)
122 , _route_deletion_in_progress (false)
124 , _strip_selection_change_without_scroll (false)
125 , _selection (*this, *this)
129 _content.set_data ("ardour-bindings", bindings);
131 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
133 scroller.set_can_default (true);
134 // set_default (scroller);
136 scroller_base.set_flags (Gtk::CAN_FOCUS);
137 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
138 scroller_base.set_name ("MixerWindow");
139 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
141 /* set up drag-n-drop */
142 vector<TargetEntry> target_table;
143 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
144 scroller_base.drag_dest_set (target_table);
145 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
147 /* create a button to add VCA strips ... will get packed in redisplay_track_list() */
148 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
150 add_vca_button.add (*w);
151 add_vca_button.set_can_focus(false);
152 add_vca_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
154 /* create a button to add mixer strips */
155 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
158 add_button.set_can_focus(false);
159 add_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
161 /* add as last item of strip packer */
162 strip_packer.pack_end (scroller_base, true, true);
163 strip_packer.pack_end (add_button, false, false);
166 /* create a drop-shadow at the end of the mixer strips */
167 mb_shadow.set_size_request( 4, -1 );
168 mb_shadow.set_name("EditorWindow");
170 strip_packer.pack_end (mb_shadow, false, false);
173 _group_tabs = new MixerGroupTabs (this);
174 strip_group_box.set_spacing (0);
175 strip_group_box.set_border_width (0);
176 strip_group_box.pack_start (*_group_tabs, PACK_SHRINK);
177 strip_group_box.pack_start (strip_packer);
178 strip_group_box.show_all ();
179 strip_group_box.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
181 scroller.add (strip_group_box);
182 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
184 setup_track_display ();
186 group_model = ListStore::create (group_columns);
187 group_display.set_model (group_model);
188 group_display.append_column (_("Show"), group_columns.visible);
189 group_display.append_column (_("Group"), group_columns.text);
190 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
191 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
192 group_display.get_column (0)->set_expand(false);
193 group_display.get_column (1)->set_expand(true);
194 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
195 group_display.set_name ("EditGroupList");
196 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
197 group_display.set_reorderable (true);
198 group_display.set_headers_visible (true);
199 group_display.set_rules_hint (true);
200 group_display.set_can_focus(false);
202 /* name is directly editable */
204 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
205 name_cell->property_editable() = true;
206 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
208 /* use checkbox for the active column */
210 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
211 active_cell->property_activatable() = true;
212 active_cell->property_radio() = false;
214 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
215 /* We use this to notice drag-and-drop reorders of the group list */
216 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
217 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
219 group_display_scroller.add (group_display);
220 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
223 group_display_vbox.pack_start (group_display_scroller, true, true);
225 group_display_frame.set_name ("BaseFrame");
226 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
227 group_display_frame.add (group_display_vbox);
229 list<TargetEntry> target_list;
230 target_list.push_back (TargetEntry ("PluginPresetPtr"));
232 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
233 favorite_plugins_display.set_model (favorite_plugins_model);
234 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
235 favorite_plugins_display.set_name ("EditGroupList");
236 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
237 favorite_plugins_display.set_reorderable (false);
238 favorite_plugins_display.set_headers_visible (true);
239 favorite_plugins_display.set_rules_hint (true);
240 favorite_plugins_display.set_can_focus (false);
241 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
242 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
243 favorite_plugins_display.add_drop_targets (target_list);
244 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
245 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
246 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
247 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
248 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
249 if (UIConfiguration::instance().get_use_tooltips()) {
250 favorite_plugins_display.set_tooltip_column (0);
252 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
254 favorite_plugins_scroller.add (favorite_plugins_display);
255 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
257 favorite_plugins_frame.set_name ("BaseFrame");
258 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
259 favorite_plugins_frame.add (favorite_plugins_vbox);
261 favorite_plugins_vbox.pack_start (favorite_plugins_scroller, true, true);
262 favorite_plugins_vbox.pack_start (favorite_plugins_tag_combo, false, false);
263 favorite_plugins_tag_combo.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::tag_combo_changed));
265 rhs_pane1.add (favorite_plugins_frame);
266 rhs_pane1.add (track_display_frame);
268 rhs_pane2.add (rhs_pane1);
269 rhs_pane2.add (group_display_frame);
271 list_vpacker.pack_start (rhs_pane2, true, true);
273 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
274 vca_vpacker.pack_start (vca_label_bar, false, false);
276 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
277 vca_scroller_base.set_name (X_("MixerWindow"));
278 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
280 vca_hpacker.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_vca_scroll_event), false);
281 vca_scroller.add (vca_hpacker);
282 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
283 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
285 vca_vpacker.pack_start (vca_scroller, true, true);
287 inner_pane.add (scroller);
288 inner_pane.add (vca_vpacker);
290 global_hpacker.pack_start (inner_pane, true, true);
291 global_hpacker.pack_start (out_packer, false, false);
293 list_hpane.set_check_divider_position (true);
294 list_hpane.add (list_vpacker);
295 list_hpane.add (global_hpacker);
296 list_hpane.set_child_minsize (list_vpacker, 30);
298 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
301 if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) {
304 rhs_pane1.set_divider (0, fract);
306 if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
309 rhs_pane2.set_divider (0, fract);
311 if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
314 list_hpane.set_divider (0, fract);
316 if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
319 inner_pane.set_divider (0, fract);
321 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
322 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
323 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
324 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
326 _content.pack_start (list_hpane, true, true);
331 _content.set_name ("MixerWindow");
333 global_hpacker.show();
335 scroller_base.show();
336 scroller_hpacker.show();
337 mixer_scroller_vpacker.show();
339 group_display_button_label.show();
340 group_display_scroller.show();
341 favorite_plugins_scroller.show();
342 group_display_vbox.show();
343 group_display_frame.show();
344 favorite_plugins_frame.show();
352 vca_label_bar.show();
354 vca_scroller_base.show();
357 group_display.show();
358 favorite_plugins_display.show();
361 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
363 _monitor_section.tearoff().set_state (*mnode);
366 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
367 VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
368 FoldbackStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_foldback, this, _1), gui_context());
372 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
374 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
375 _plugin_selector = new PluginSelector (PluginManager::instance ());
377 #error implement deferred Plugin-Favorite list
380 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
381 PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
382 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
385 Mixer_UI::~Mixer_UI ()
387 monitor_section_detached ();
390 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
392 if (foldback_strip) {
393 delete foldback_strip;
397 delete _plugin_selector;
401 struct MixerStripSorter {
402 bool operator() (const MixerStrip* ms_a, const MixerStrip* ms_b)
404 boost::shared_ptr<ARDOUR::Stripable> const& a = ms_a->stripable ();
405 boost::shared_ptr<ARDOUR::Stripable> const& b = ms_b->stripable ();
406 return ARDOUR::Stripable::Sorter(true)(a, b);
418 Mixer_UI::tag_combo_changed ()
420 refill_favorite_plugins();
424 Mixer_UI::use_own_window (bool and_fill_it)
426 bool new_window = !own_window();
428 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
430 if (win && new_window) {
431 win->set_name ("MixerWindow");
432 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
433 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
434 win->set_data ("ardour-bindings", bindings);
436 if (!win->get_focus()) {
437 /* set focus widget to something, anything */
438 win->set_focus (scroller);
446 Mixer_UI::show_window ()
448 Tabbable::show_window ();
450 /* show/hide group tabs as required */
451 parameter_changed ("show-group-tabs");
453 /* now reset each strips width so the right widgets are shown */
455 TreeModel::Children rows = track_model->children();
456 TreeModel::Children::iterator ri;
458 for (ri = rows.begin(); ri != rows.end(); ++ri) {
459 AxisView* av = (*ri)[stripable_columns.strip];
460 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
464 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
465 /* Fix visibility of mixer strip stuff */
466 ms->parameter_changed (X_("mixer-element-visibility"));
469 /* force focus into main area */
470 scroller_base.grab_focus ();
474 Mixer_UI::remove_master (VCAMasterStrip* vms)
476 if (_session && _session->deletion_in_progress()) {
477 /* its all being taken care of */
481 TreeModel::Children rows = track_model->children();
482 TreeModel::Children::iterator ri;
484 for (ri = rows.begin(); ri != rows.end(); ++ri) {
485 if ((*ri)[stripable_columns.strip] == vms) {
486 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
487 track_model->erase (ri);
494 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
496 using namespace Menu_Helpers;
498 if (Keyboard::is_context_menu_event (ev)) {
499 ARDOUR_UI::instance()->add_route ();
507 Mixer_UI::new_masters_created ()
509 ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane")->set_active (true);
513 Mixer_UI::add_masters (VCAList& vlist)
517 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
518 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
525 Mixer_UI::add_routes (RouteList& rlist)
529 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
537 Mixer_UI::add_stripables (StripableList& slist)
539 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
540 bool from_scratch = (track_model->children().size() == 0);
541 uint32_t nroutes = 0;
543 slist.sort (Stripable::Sorter());
545 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
546 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
554 // XXX what does this special case do?
555 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
564 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
566 track_display.set_model (Glib::RefPtr<ListStore>());
568 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
570 boost::shared_ptr<Route> route;
571 boost::shared_ptr<VCA> vca;
573 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
575 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
577 TreeModel::Row row = *(track_model->append());
579 row[stripable_columns.text] = vca->name();
580 row[stripable_columns.visible] = vms->marked_for_display ();
581 row[stripable_columns.strip] = vms;
582 row[stripable_columns.stripable] = vca;
584 vms->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::vca_button_release_event), vms));
586 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
588 if (route->is_auditioner()) {
592 if (route->is_monitor()) {
594 out_packer.pack_end (_monitor_section.tearoff(), false, false);
595 if (foldback_strip) {
596 out_packer.remove (*foldback_strip);
597 out_packer.pack_end (*foldback_strip, false, false);
598 foldback_strip->set_packed (true);
600 _monitor_section.set_session (_session);
601 _monitor_section.tearoff().show_all ();
603 _monitor_section.tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
604 _monitor_section.tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
606 if (_monitor_section.tearoff().torn_off()) {
607 monitor_section_detached ();
609 monitor_section_attached ();
612 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
614 /* no regular strip shown for control out */
618 if (route->is_foldbackbus ()) {
619 if (foldback_strip) {
620 foldback_strip->set_route (route);
622 foldback_strip = new FoldbackStrip (*this, _session, route);
623 out_packer.pack_end (*foldback_strip, false, false);
624 foldback_strip->set_packed (true);
629 strip = new MixerStrip (*this, _session, route);
630 strips.push_back (strip);
632 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
634 if (strip->width_owner() != strip) {
635 strip->set_width_enum (_strip_width, this);
640 if (route->is_master()) {
642 out_packer.pack_start (*strip, false, false);
643 strip->set_packed (true);
647 TreeModel::Row row = *(track_model->insert (insert_iter));
649 row[stripable_columns.text] = route->name();
650 row[stripable_columns.visible] = strip->marked_for_display();
651 row[stripable_columns.stripable] = route;
652 row[stripable_columns.strip] = strip;
655 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
656 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
659 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
660 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
663 } catch (const std::exception& e) {
664 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
667 track_display.set_model (track_model);
669 /* catch up on selection state, which we left to the editor to set */
670 sync_treeview_from_presentation_info (PropertyChange (Properties::selected));
673 sync_presentation_info_from_treeview ();
676 redisplay_track_list ();
680 Mixer_UI::deselect_all_strip_processors ()
682 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
683 (*i)->deselect_all_processors();
688 Mixer_UI::select_none ()
690 _selection.clear_routes();
691 deselect_all_strip_processors();
695 Mixer_UI::select_next_strip ()
697 deselect_all_strip_processors();
698 _session->selection().select_next_stripable (true, false);
702 Mixer_UI::select_prev_strip ()
704 deselect_all_strip_processors();
705 _session->selection().select_prev_stripable (true, false);
709 Mixer_UI::delete_processors ()
711 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
712 (*i)->delete_processors();
718 Mixer_UI::remove_strip (MixerStrip* strip)
720 if (_session && _session->deletion_in_progress()) {
721 /* its all being taken care of */
725 TreeModel::Children rows = track_model->children();
726 TreeModel::Children::iterator ri;
727 list<MixerStrip *>::iterator i;
729 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
733 PBD::Unwinder<bool> uwi (ignore_reorder, true);
735 for (ri = rows.begin(); ri != rows.end(); ++ri) {
736 if ((*ri)[stripable_columns.strip] == strip) {
737 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
738 track_model->erase (ri);
745 Mixer_UI::remove_foldback (FoldbackStrip* strip)
747 if (_session && _session->deletion_in_progress()) {
748 /* its all being taken care of */
751 if (foldback_strip) {
752 foldback_strip->destroy_();
758 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
760 if (what_changed.contains (Properties::selected)) {
761 _selection.presentation_info_changed (what_changed);
765 soh.add (Properties::selected);
766 soh.add (Properties::order);
767 soh.add (Properties::hidden);
769 if (what_changed.contains (soh)) {
770 sync_treeview_from_presentation_info (what_changed);
775 Mixer_UI::sync_presentation_info_from_treeview ()
777 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
781 TreeModel::Children rows = track_model->children();
787 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
789 TreeModel::Children::iterator ri;
792 PresentationInfo::order_t master_key = _session->master_order_key ();
793 PresentationInfo::order_t order = 0;
795 PresentationInfo::ChangeSuspender cs;
797 for (ri = rows.begin(); ri != rows.end(); ++ri) {
798 bool visible = (*ri)[stripable_columns.visible];
799 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
801 #ifndef NDEBUG // these should not exist in the mixer's treeview
806 if (stripable->is_monitor() || stripable->is_auditioner()) {
810 if (stripable->is_master()) {
816 stripable->presentation_info().set_hidden (!visible);
818 // leave master where it is.
819 if (order == master_key) {
823 if (order != stripable->presentation_info().order()) {
824 stripable->set_presentation_order (order);
830 change |= _session->ensure_stripable_sort_order ();
833 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
834 _session->set_dirty();
839 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
841 if (!_session || _session->deletion_in_progress()) {
845 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
847 /* we could get here after either a change in the Mixer or Editor sort
848 * order, but either way, the mixer order keys reflect the intended
849 * order for the GUI, so reorder the treeview model to match it.
852 vector<int> neworder;
853 TreeModel::Children rows = track_model->children();
854 uint32_t old_order = 0;
855 bool changed = false;
861 TreeOrderKeys sorted;
862 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
863 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
864 sorted.push_back (TreeOrderKey (old_order, stripable));
867 TreeOrderKeySorter cmp;
869 sort (sorted.begin(), sorted.end(), cmp);
870 neworder.assign (sorted.size(), 0);
874 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
876 neworder[n] = sr->old_display_order;
878 if (sr->old_display_order != n) {
884 Unwinder<bool> uw (ignore_reorder, true);
885 track_model->reorder (neworder);
888 if (what_changed.contains (Properties::selected)) {
890 PresentationInfo::ChangeSuspender cs;
892 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
893 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
894 if (stripable && stripable->is_selected()) {
897 _selection.remove (*i);
901 if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) {
902 move_stripable_into_view ((*_selection.axes.begin())->stripable());
905 TreeModel::Children rows = track_model->children();
906 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
907 AxisView* av = (*i)[stripable_columns.strip];
908 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
912 if (vms->vca() && vms->vca()->is_selected()) {
913 _selection.add (vms);
915 _selection.remove (vms);
920 redisplay_track_list ();
925 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
927 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
928 if ((*i)->route() == r) {
937 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
939 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
940 if ((*i)->stripable() == s) {
949 Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
951 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
952 if ((*i)->stripable() == s) {
957 TreeModel::Children rows = track_model->children();
958 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
959 AxisView* av = (*i)[stripable_columns.strip];
960 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
961 if (vms && vms->stripable () == s) {
970 Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
972 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
973 if ((*i)->control() == c) {
982 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
984 /* Selecting a mixer-strip may also select grouped-tracks, and
985 * presentation_info_changed() being emitted and
986 * _selection.axes.begin() is being moved into view. This may
987 * effectively move the track that was clicked-on out of view.
989 * So here only the track that is actually clicked-on is moved into
990 * view (in case it's partially visible)
992 PBD::Unwinder<bool> uw (_strip_selection_change_without_scroll, true);
993 move_stripable_into_view (strip->stripable());
995 if (ev->button == 1) {
996 if (_selection.selected (strip)) {
997 /* primary-click: toggle selection state of strip */
998 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
999 _selection.remove (strip, true);
1000 } else if (_selection.axes.size() > 1) {
1001 /* de-select others */
1002 _selection.set (strip);
1004 PublicEditor& pe = PublicEditor::instance();
1005 TimeAxisView* tav = pe.time_axis_view_from_stripable (strip->stripable());
1007 pe.set_selected_mixer_strip (*tav);
1010 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1011 _selection.add (strip, true);
1012 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
1014 /* extend selection */
1016 vector<MixerStrip*> tmp;
1017 bool accumulate = false;
1018 bool found_another = false;
1020 strips.sort (MixerStripSorter());
1022 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1023 MixerStrip* ms = *i;
1027 /* hit clicked strip, start accumulating till we hit the first
1036 } else if (_selection.selected (ms)) {
1037 /* hit selected strip. if currently accumulating others,
1038 we're done. if not accumulating others, start doing so.
1040 found_another = true;
1054 tmp.push_back (strip);
1056 if (found_another) {
1057 PresentationInfo::ChangeSuspender cs;
1058 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
1059 _selection.add (*i, true);
1062 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
1065 _selection.set (strip);
1074 Mixer_UI::vca_button_release_event (GdkEventButton *ev, VCAMasterStrip *strip)
1076 _selection.set (strip);
1081 Mixer_UI::set_session (Session* sess)
1083 SessionHandlePtr::set_session (sess);
1084 _monitor_section.set_session (sess);
1086 if (_plugin_selector) {
1087 _plugin_selector->set_session (_session);
1090 _group_tabs->set_session (sess);
1093 _selection.clear ();
1097 refill_favorite_plugins();
1100 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1101 set_state (*node, 0);
1105 initial_track_display ();
1107 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1108 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1109 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1110 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1111 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1112 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1113 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1115 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1116 _session->vca_manager().VCACreated.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::new_masters_created, this), gui_context());
1118 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1120 route_groups_changed ();
1126 /* catch up on selection state, etc. */
1129 sc.add (Properties::selected);
1130 _selection.presentation_info_changed (sc);
1136 Mixer_UI::session_going_away ()
1138 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1140 _in_group_rebuild_or_clear = true;
1141 group_model->clear ();
1142 _in_group_rebuild_or_clear = false;
1144 _selection.clear ();
1145 track_model->clear ();
1147 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1151 _monitor_section.tearoff().hide_visible ();
1153 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1155 if (foldback_strip) {
1156 delete foldback_strip;
1161 monitor_section_detached ();
1167 SessionHandlePtr::session_going_away ();
1174 Mixer_UI::track_visibility_changed (std::string const & path)
1176 if (_session && _session->deletion_in_progress()) {
1182 if ((iter = track_model->get_iter (path))) {
1184 AxisView* av = (*iter)[stripable_columns.strip];
1185 bool visible = (*iter)[stripable_columns.visible];
1187 if (av->set_marked_for_display (!visible)) {
1188 update_track_visibility ();
1194 Mixer_UI::update_track_visibility ()
1196 TreeModel::Children rows = track_model->children();
1197 TreeModel::Children::iterator i;
1200 Unwinder<bool> uw (no_track_list_redisplay, true);
1202 for (i = rows.begin(); i != rows.end(); ++i) {
1203 AxisView* av = (*i)[stripable_columns.strip];
1204 (*i)[stripable_columns.visible] = av->marked_for_display ();
1207 /* force presentation to catch up with visibility changes */
1208 sync_presentation_info_from_treeview ();
1211 redisplay_track_list ();
1215 Mixer_UI::show_strip (MixerStrip* ms)
1217 TreeModel::Children rows = track_model->children();
1218 TreeModel::Children::iterator i;
1220 for (i = rows.begin(); i != rows.end(); ++i) {
1222 AxisView* av = (*i)[stripable_columns.strip];
1223 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1225 (*i)[stripable_columns.visible] = true;
1226 av->set_marked_for_display (true);
1227 update_track_visibility ();
1234 Mixer_UI::hide_strip (MixerStrip* ms)
1236 TreeModel::Children rows = track_model->children();
1237 TreeModel::Children::iterator i;
1239 for (i = rows.begin(); i != rows.end(); ++i) {
1241 AxisView* av = (*i)[stripable_columns.strip];
1242 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1244 (*i)[stripable_columns.visible] = false;
1245 av->set_marked_for_display (false);
1246 update_track_visibility ();
1253 Mixer_UI::start_updating ()
1255 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1260 Mixer_UI::stop_updating ()
1262 fast_screen_update_connection.disconnect();
1267 Mixer_UI::fast_update_strips ()
1269 if (_content.is_mapped () && _session) {
1270 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1271 (*i)->fast_update ();
1277 Mixer_UI::set_all_strips_visibility (bool yn)
1279 TreeModel::Children rows = track_model->children();
1280 TreeModel::Children::iterator i;
1283 Unwinder<bool> uw (no_track_list_redisplay, true);
1285 for (i = rows.begin(); i != rows.end(); ++i) {
1287 AxisView* av = (*i)[stripable_columns.strip];
1288 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1294 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1298 (*i)[stripable_columns.visible] = yn;
1301 /* force presentation to catch up with visibility changes */
1302 sync_presentation_info_from_treeview ();
1305 redisplay_track_list ();
1309 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1311 TreeModel::Children rows = track_model->children();
1312 TreeModel::Children::iterator i;
1315 Unwinder<bool> uw (no_track_list_redisplay, true);
1317 for (i = rows.begin(); i != rows.end(); ++i) {
1319 AxisView* av = (*i)[stripable_columns.strip];
1320 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1326 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1330 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1331 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1335 (*i)[stripable_columns.visible] = yn;
1339 if (at) { /* track */
1340 (*i)[stripable_columns.visible] = yn;
1345 if (!at && !mt) { /* bus */
1346 (*i)[stripable_columns.visible] = yn;
1351 if (mt) { /* midi-track */
1352 (*i)[stripable_columns.visible] = yn;
1358 /* force presentation to catch up with visibility changes */
1359 sync_presentation_info_from_treeview ();
1362 redisplay_track_list ();
1366 Mixer_UI::hide_all_routes ()
1368 set_all_strips_visibility (false);
1372 Mixer_UI::show_all_routes ()
1374 set_all_strips_visibility (true);
1378 Mixer_UI::show_all_audiobus ()
1380 set_all_audio_midi_visibility (2, true);
1383 Mixer_UI::hide_all_audiobus ()
1385 set_all_audio_midi_visibility (2, false);
1389 Mixer_UI::show_all_audiotracks()
1391 set_all_audio_midi_visibility (1, true);
1394 Mixer_UI::hide_all_audiotracks ()
1396 set_all_audio_midi_visibility (1, false);
1400 Mixer_UI::show_all_miditracks()
1402 set_all_audio_midi_visibility (3, true);
1405 Mixer_UI::hide_all_miditracks ()
1407 set_all_audio_midi_visibility (3, false);
1411 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1413 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1414 sync_presentation_info_from_treeview ();
1418 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1420 /* this happens as the second step of a DnD within the treeview as well
1421 as when a row/route is actually deleted.
1423 if it was a deletion then we have to force a redisplay because
1424 order keys may not have changed.
1427 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1428 sync_presentation_info_from_treeview ();
1430 if (_route_deletion_in_progress) {
1431 redisplay_track_list ();
1436 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1438 TreeModel::Children rows = track_model->children();
1439 std::list<boost::shared_ptr<VCA> > vcas;
1440 vcas.push_back (vca);
1442 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1443 AxisView* av = (*i)[stripable_columns.strip];
1444 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1445 if (vms && vms->vca()->slaved_to (vca)) {
1446 vcas.push_back (vms->vca());
1450 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1452 AxisView* av = (*i)[stripable_columns.strip];
1453 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1454 bool const visible = (*i)[stripable_columns.visible];
1457 /* we're in the middle of changing a row, don't worry */
1461 if (!strip->route()) {
1462 /* non-route element */
1466 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1470 bool slaved = false;
1471 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1472 if (strip->route()->slaved_to (*m)) {
1478 if (slaved && visible) {
1480 if (strip->packed()) {
1481 strip_packer.reorder_child (*strip, -1); /* put at end */
1483 strip_packer.pack_start (*strip, false, false);
1484 strip->set_packed (true);
1489 if (strip->packed()) {
1490 strip_packer.remove (*strip);
1491 strip->set_packed (false);
1498 Mixer_UI::redisplay_track_list ()
1500 if (no_track_list_redisplay) {
1504 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1506 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1508 if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) {
1509 _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value();
1511 spill_redisplay (sv);
1516 TreeModel::Children rows = track_model->children();
1517 TreeModel::Children::iterator i;
1518 uint32_t n_masters = 0;
1520 container_clear (vca_hpacker);
1522 vca_hpacker.pack_end (vca_scroller_base, true, true);
1523 vca_hpacker.pack_end (add_vca_button, false, false);
1525 add_vca_button.show ();
1526 vca_scroller_base.show();
1528 for (i = rows.begin(); i != rows.end(); ++i) {
1530 AxisView* s = (*i)[stripable_columns.strip];
1531 bool const visible = (*i)[stripable_columns.visible];
1532 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1535 /* we're in the middle of changing a row, don't worry */
1539 VCAMasterStrip* vms;
1541 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1543 vca_hpacker.pack_start (*vms, false, false);
1550 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1558 if (strip->packed()) {
1559 strip_packer.reorder_child (*strip, -1); /* put at end */
1561 strip_packer.pack_start (*strip, false, false);
1562 strip->set_packed (true);
1567 if (stripable->is_master() || stripable->is_monitor()) {
1568 /* do nothing, these cannot be hidden */
1570 if (strip->packed()) {
1571 strip_packer.remove (*strip);
1572 strip->set_packed (false);
1578 /* update visibility of VCA assign buttons */
1580 if (n_masters == 0) {
1581 //show/hide the channelstrip VCA assign buttons on channelstrips:
1582 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1584 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleVCAPane");
1586 act->set_sensitive (false);
1589 //remove the VCA packer, but don't change our prior setting for show/hide:
1590 vca_vpacker.hide ();
1592 //show/hide the channelstrip VCA assign buttons on channelstrips:
1593 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1595 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
1596 act->set_sensitive (true);
1598 //if we were showing VCAs before, show them now:
1599 showhide_vcas (act->get_active ());
1602 _group_tabs->set_dirty ();
1604 if (_spill_scroll_position > 0 && scroller.get_hscrollbar()) {
1605 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1606 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), _spill_scroll_position)));
1608 _spill_scroll_position = 0;
1613 Mixer_UI::strip_width_changed ()
1615 _group_tabs->set_dirty ();
1618 TreeModel::Children rows = track_model->children();
1619 TreeModel::Children::iterator i;
1622 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1623 AxisView* av = (*i)[stripable_columns.strip];
1624 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1630 bool visible = (*i)[stripable_columns.visible];
1633 strip->queue_draw();
1640 struct PresentationInfoMixerSorter
1642 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1643 if (a->is_master()) {
1644 /* master after everything else */
1646 } else if (b->is_master()) {
1647 /* everything else before master */
1650 return a->presentation_info().order () < b->presentation_info().order ();
1655 Mixer_UI::initial_track_display ()
1659 _session->get_stripables (sl);
1660 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1662 boost::shared_ptr<ARDOUR::Stripable> _current_foldback = *(fb.begin());
1663 sl.push_back (_current_foldback);
1666 sl.sort (PresentationInfoMixerSorter());
1669 /* These are also used inside ::add_stripables() but we need
1670 * them here because we're going to clear the track_model also.
1672 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1673 Unwinder<bool> uw2 (ignore_reorder, true);
1675 track_model->clear ();
1676 add_stripables (sl);
1679 sync_treeview_from_presentation_info (Properties::order);
1683 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1685 if (Keyboard::is_context_menu_event (ev)) {
1686 if (track_menu == 0) {
1687 build_track_menu ();
1689 track_menu->popup (ev->button, ev->time);
1692 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1693 TreeModel::Path path;
1694 TreeViewColumn* column;
1696 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1697 TreeIter iter = track_model->get_iter (path);
1698 if ((*iter)[stripable_columns.visible]) {
1699 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1700 move_stripable_into_view (s);
1709 Mixer_UI::move_vca_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1711 if (!vca_scroller.get_hscrollbar()) {
1717 Gtk::Allocation alloc;
1719 TreeModel::Children rows = track_model->children();
1720 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1721 AxisView* av = (*i)[stripable_columns.strip];
1722 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1723 if (vms && vms->stripable () == s) {
1726 vms->translate_coordinates (vca_hpacker, 0, 0, x0, y);
1727 alloc = vms->get_allocation ();
1736 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
1738 if (x0 < adj->get_value()) {
1739 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1740 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1741 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1742 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1747 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1749 if (!scroller.get_hscrollbar()) {
1752 if (s->presentation_info().special ()) {
1755 if (s->presentation_info().flag_match (PresentationInfo::VCA)) {
1756 move_vca_into_view (s);
1765 Gtk::Allocation alloc;
1766 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1767 if ((*i)->route() == s) {
1770 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1771 alloc = (*i)->get_allocation ();
1779 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1781 if (x0 < adj->get_value()) {
1782 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1783 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1784 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1785 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1790 Mixer_UI::build_track_menu ()
1792 using namespace Menu_Helpers;
1793 using namespace Gtk;
1795 track_menu = new Menu;
1796 track_menu->set_name ("ArdourContextMenu");
1797 MenuList& items = track_menu->items();
1799 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1800 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1801 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1802 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1803 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1804 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1805 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1806 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1811 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1813 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1817 boost::shared_ptr<Stripable> s = ws.lock ();
1823 TreeModel::Children rows = track_model->children();
1824 TreeModel::Children::iterator i;
1826 for (i = rows.begin(); i != rows.end(); ++i) {
1827 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1831 if (what_changed.contains (ARDOUR::Properties::name)) {
1832 (*i)[stripable_columns.text] = s->name();
1835 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1836 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1837 redisplay_track_list ();
1844 if (s->is_master ()) {
1848 error << _("track display list item for renamed strip not found!") << endmsg;
1852 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1854 TreeModel::Path path;
1855 TreeViewColumn* column;
1859 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1860 if (ev->button == 3) {
1861 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1866 TreeIter iter = group_model->get_iter (path);
1868 if (ev->button == 3) {
1869 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1874 RouteGroup* group = (*iter)[group_columns.group];
1876 if (Keyboard::is_context_menu_event (ev)) {
1877 _group_tabs->get_menu(group)->popup (1, ev->time);
1881 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1883 if (Keyboard::is_edit_event (ev)) {
1885 // edit_route_group (group);
1887 group_display.queue_draw();
1896 bool visible = (*iter)[group_columns.visible];
1897 (*iter)[group_columns.visible] = !visible;
1899 group_display.queue_draw();
1912 Mixer_UI::activate_all_route_groups ()
1914 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1918 Mixer_UI::disable_all_route_groups ()
1920 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1924 Mixer_UI::route_groups_changed ()
1926 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1928 _in_group_rebuild_or_clear = true;
1930 /* just rebuild the while thing */
1932 group_model->clear ();
1935 /* this is currently not used,
1936 * Mixer_UI::group_display_button_press() has a case for it,
1937 * and a commented edit_route_group() but that's n/a since 2011.
1939 * This code is left as reminder that
1940 * row[group_columns.group] = 0 has special meaning.
1944 row = *(group_model->append());
1945 row[group_columns.visible] = true;
1946 row[group_columns.text] = (_("-all-"));
1947 row[group_columns.group] = 0;
1951 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1953 _group_tabs->set_dirty ();
1954 _in_group_rebuild_or_clear = false;
1958 Mixer_UI::new_route_group ()
1960 _group_tabs->run_new_group_dialog (0, false);
1964 Mixer_UI::remove_selected_route_group ()
1966 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1967 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1973 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1976 /* selection mode is single, so rows.begin() is it */
1978 if ((iter = group_model->get_iter (*i))) {
1980 RouteGroup* rg = (*iter)[group_columns.group];
1983 _session->remove_route_group (*rg);
1989 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1991 if (in_group_row_change) {
1995 /* force an update of any mixer strips that are using this group,
1996 otherwise mix group names don't change in mixer strips
1999 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
2000 if ((*i)->route_group() == group) {
2001 (*i)->route_group_changed();
2005 TreeModel::iterator i;
2006 TreeModel::Children rows = group_model->children();
2007 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
2009 in_group_row_change = true;
2011 for (i = rows.begin(); i != rows.end(); ++i) {
2012 if ((*i)[group_columns.group] == group) {
2013 (*i)[group_columns.visible] = !group->is_hidden ();
2014 (*i)[group_columns.text] = group->name ();
2019 in_group_row_change = false;
2021 if (change.contains (Properties::name)) {
2022 _group_tabs->set_dirty ();
2025 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
2026 if ((*j)->route_group() == group) {
2027 if (group->is_hidden ()) {
2037 Mixer_UI::toggle_mixer_list ()
2039 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2040 showhide_mixer_list (act->get_active());
2044 Mixer_UI::showhide_mixer_list (bool yn)
2047 list_vpacker.show ();
2049 list_vpacker.hide ();
2054 Mixer_UI::toggle_monitor_section ()
2056 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2057 showhide_monitor_section (act->get_active());
2062 Mixer_UI::showhide_monitor_section (bool yn)
2064 if (monitor_section().tearoff().torn_off()) {
2069 monitor_section().tearoff().show();
2071 monitor_section().tearoff().hide();
2076 Mixer_UI::toggle_vcas ()
2078 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2079 showhide_vcas (act->get_active());
2083 Mixer_UI::showhide_vcas (bool yn)
2094 Mixer_UI::toggle_mixbuses ()
2096 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2097 showhide_mixbuses (act->get_active());
2101 Mixer_UI::showhide_mixbuses (bool on)
2113 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
2118 if ((iter = group_model->get_iter (path))) {
2120 if ((group = (*iter)[group_columns.group]) == 0) {
2124 if (new_text != group->name()) {
2125 group->set_name (new_text);
2131 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
2135 if (in_group_row_change) {
2139 if ((group = (*iter)[group_columns.group]) == 0) {
2143 std::string name = (*iter)[group_columns.text];
2145 if (name != group->name()) {
2146 group->set_name (name);
2149 bool hidden = !(*iter)[group_columns.visible];
2151 if (hidden != group->is_hidden ()) {
2152 group->set_hidden (hidden, this);
2156 /** Called when a group model row is deleted, but also when the model is
2157 * reordered by a user drag-and-drop; the latter is what we are
2158 * interested in here.
2161 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
2163 if (_in_group_rebuild_or_clear) {
2167 /* Re-write the session's route group list so that the new order is preserved */
2169 list<RouteGroup*> new_list;
2171 Gtk::TreeModel::Children children = group_model->children();
2172 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
2173 RouteGroup* g = (*i)[group_columns.group];
2175 new_list.push_back (g);
2179 _session->reorder_route_groups (new_list);
2184 Mixer_UI::add_route_group (RouteGroup* group)
2186 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
2189 in_group_row_change = true;
2191 TreeModel::Row row = *(group_model->append());
2192 row[group_columns.visible] = !group->is_hidden ();
2193 row[group_columns.group] = group;
2194 if (!group->name().empty()) {
2195 row[group_columns.text] = group->name();
2197 row[group_columns.text] = _("unnamed");
2201 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
2204 TreeViewColumn* col = group_display.get_column (0);
2205 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
2206 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
2209 _group_tabs->set_dirty ();
2211 in_group_row_change = false;
2215 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
2217 using namespace Menu_Helpers;
2219 if (Keyboard::is_context_menu_event (ev)) {
2220 ARDOUR_UI::instance()->add_route ();
2228 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
2230 if (data.get_target() != "PluginFavoritePtr") {
2231 context->drag_finish (false, false, time);
2235 const void * d = data.get_data();
2236 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2238 PluginPresetList nfos;
2240 tv->get_object_drag_data (nfos, &source);
2242 Route::ProcessorList pl;
2245 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2246 PluginPresetPtr ppp = (*i);
2247 PluginInfoPtr pip = ppp->_pip;
2248 if (!pip->is_instrument ()) {
2251 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);
2255 context->drag_finish (ok, false, time);
2259 Mixer_UI::set_strip_width (Width w, bool save)
2263 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2264 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2269 struct PluginStateSorter {
2271 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2272 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2273 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2274 if (aiter != _user.end() && biter != _user.end()) {
2275 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2277 if (aiter != _user.end()) {
2280 if (biter != _user.end()) {
2283 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2286 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2288 std::list<std::string> _user;
2292 Mixer_UI::set_state (const XMLNode& node, int version)
2296 Tabbable::set_state (node, version);
2298 if (node.get_property ("narrow-strips", yn)) {
2300 set_strip_width (Narrow);
2302 set_strip_width (Wide);
2306 node.get_property ("show-mixer", _visible);
2309 node.get_property ("maximised", yn);
2311 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Common"), X_("ToggleMaximalMixer"));
2312 bool fs = act && act->get_active();
2314 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2319 node.get_property ("show-mixer-list", yn);
2321 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixerList"));
2322 /* do it twice to force the change */
2323 act->set_active (!yn);
2324 act->set_active (yn);
2328 node.get_property ("monitor-section-visible", yn);
2330 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection"));
2331 /* do it twice to force the change */
2332 act->set_active (!yn);
2333 act->set_active (yn);
2337 node.get_property ("show-vca-pane", yn);
2339 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleVCAPane"));
2340 /* do it twice to force the change */
2341 act->set_active (!yn);
2342 act->set_active (yn);
2347 node.get_property ("show-mixbus-pane", yn);
2349 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixbusPane"));
2350 /* do it twice to force the change */
2351 act->set_active (!yn);
2352 act->set_active (yn);
2356 //check for the user's plugin_order file
2357 XMLNode plugin_order_new(X_("PO"));
2358 if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) {
2359 store_current_favorite_order ();
2360 std::list<string> order;
2361 const XMLNodeList& kids = plugin_order_new.children("PluginInfo");
2362 XMLNodeConstIterator i;
2363 for (i = kids.begin(); i != kids.end(); ++i) {
2364 std::string unique_id;
2365 if ((*i)->get_property ("unique-id", unique_id)) {
2366 order.push_back (unique_id);
2367 if ((*i)->get_property ("expanded", yn)) {
2368 favorite_ui_state[unique_id] = yn;
2372 PluginStateSorter cmp (order);
2373 favorite_order.sort (cmp);
2374 sync_treeview_from_favorite_order ();
2377 //if there is no user file, then use an existing one from instant.xml
2378 //NOTE: if you are loading an old session, this might come from the session's instant.xml
2379 //Todo: in the next major version, we should probably stop doing the instant.xml check, and just use the new file
2380 XMLNode* plugin_order;
2381 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2382 store_current_favorite_order ();
2383 std::list<string> order;
2384 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2385 XMLNodeConstIterator i;
2386 for (i = kids.begin(); i != kids.end(); ++i) {
2387 std::string unique_id;
2388 if ((*i)->get_property ("unique-id", unique_id)) {
2389 order.push_back (unique_id);
2390 if ((*i)->get_property ("expanded", yn)) {
2391 favorite_ui_state[unique_id] = yn;
2396 PluginStateSorter cmp (order);
2397 favorite_order.sort (cmp);
2398 sync_treeview_from_favorite_order ();
2406 Mixer_UI::save_plugin_order_file ()
2408 //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order )
2410 //NOTE: this replaces the old code that stores info in instant.xml
2411 //why? because instant.xml prefers the per-session settings, and we want this to be a global pref
2413 store_current_favorite_order ();
2414 XMLNode plugin_order ("PluginOrder");
2416 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2417 XMLNode* p = new XMLNode ("PluginInfo");
2418 p->set_property ("sort", cnt);
2419 p->set_property ("unique-id", (*i)->unique_id);
2420 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2421 p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2423 plugin_order.add_child_nocopy (*p);
2425 PluginManager::instance().save_plugin_order_file( plugin_order );
2429 Mixer_UI::get_state ()
2431 XMLNode* node = new XMLNode (X_("Mixer"));
2433 node->add_child_nocopy (Tabbable::get_state());
2435 node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider());
2436 node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider());
2437 node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider());
2438 node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider());
2440 node->set_property ("narrow-strips", (_strip_width == Narrow));
2441 node->set_property ("show-mixer", _visible);
2442 node->set_property ("maximised", _maximised);
2444 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2445 node->set_property ("show-mixer-list", act->get_active ());
2447 act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2448 node->set_property ("monitor-section-visible", act->get_active ());
2450 act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2451 node->set_property ("show-vca-pane", act->get_active ());
2454 act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2455 node->set_property ("show-mixbus-pane", act->get_active ());
2462 Mixer_UI::scroll_left ()
2464 if (!scroller.get_hscrollbar()) return;
2465 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2466 int sc_w = scroller.get_width();
2467 int sp_w = strip_packer.get_width();
2471 int lp = adj->get_value();
2473 using namespace Gtk::Box_Helpers;
2474 const BoxList& strips = strip_packer.children();
2475 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2476 if (i->get_widget() == & add_button) {
2480 if (i->get_widget() == &mb_shadow) {
2484 lm += i->get_widget()->get_width ();
2486 lm -= i->get_widget()->get_width ();
2490 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2494 Mixer_UI::scroll_right ()
2496 if (!scroller.get_hscrollbar()) return;
2497 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2498 int sc_w = scroller.get_width();
2499 int sp_w = strip_packer.get_width();
2503 int lp = adj->get_value();
2505 using namespace Gtk::Box_Helpers;
2506 const BoxList& strips = strip_packer.children();
2507 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2508 if (i->get_widget() == & add_button) {
2512 if (i->get_widget() == &mb_shadow) {
2516 lm += i->get_widget()->get_width ();
2521 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2525 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2527 switch (ev->direction) {
2528 case GDK_SCROLL_LEFT:
2532 if (ev->state & Keyboard::TertiaryModifier) {
2538 case GDK_SCROLL_RIGHT:
2542 case GDK_SCROLL_DOWN:
2543 if (ev->state & Keyboard::TertiaryModifier) {
2554 Mixer_UI::vca_scroll_left ()
2556 if (!vca_scroller.get_hscrollbar()) return;
2557 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2558 int sc_w = vca_scroller.get_width();
2559 int sp_w = strip_packer.get_width();
2563 int lp = adj->get_value();
2565 using namespace Gtk::Box_Helpers;
2566 const BoxList& strips = vca_hpacker.children();
2567 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2568 if (i->get_widget() == &add_vca_button) {
2571 lm += i->get_widget()->get_width ();
2573 lm -= i->get_widget()->get_width ();
2577 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2581 Mixer_UI::vca_scroll_right ()
2583 if (!vca_scroller.get_hscrollbar()) return;
2584 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2585 int sc_w = vca_scroller.get_width();
2586 int sp_w = strip_packer.get_width();
2590 int lp = adj->get_value();
2592 using namespace Gtk::Box_Helpers;
2593 const BoxList& strips = vca_hpacker.children();
2594 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2595 if (i->get_widget() == &add_vca_button) {
2598 lm += i->get_widget()->get_width ();
2603 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2607 Mixer_UI::on_vca_scroll_event (GdkEventScroll* ev)
2609 switch (ev->direction) {
2610 case GDK_SCROLL_LEFT:
2614 if (ev->state & Keyboard::TertiaryModifier) {
2620 case GDK_SCROLL_RIGHT:
2621 vca_scroll_right ();
2624 case GDK_SCROLL_DOWN:
2625 if (ev->state & Keyboard::TertiaryModifier) {
2626 vca_scroll_right ();
2636 Mixer_UI::parameter_changed (string const & p)
2638 if (p == "show-group-tabs") {
2639 bool const s = _session->config.get_show_group_tabs ();
2641 _group_tabs->show ();
2643 _group_tabs->hide ();
2645 } else if (p == "default-narrow_ms") {
2646 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2647 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2648 (*i)->set_width_enum (s ? Narrow : Wide, this);
2654 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2656 g->set_active (a, this);
2660 Mixer_UI::plugin_selector()
2662 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2663 if (!_plugin_selector)
2664 _plugin_selector = new PluginSelector (PluginManager::instance());
2667 return _plugin_selector;
2671 Mixer_UI::setup_track_display ()
2673 track_model = ListStore::create (stripable_columns);
2674 track_display.set_model (track_model);
2675 track_display.append_column (_("Show"), stripable_columns.visible);
2676 track_display.append_column (_("Strips"), stripable_columns.text);
2677 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2678 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2679 track_display.get_column (0)->set_expand(false);
2680 track_display.get_column (1)->set_expand(true);
2681 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2682 track_display.set_name (X_("EditGroupList"));
2683 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2684 track_display.set_reorderable (true);
2685 track_display.set_headers_visible (true);
2686 track_display.set_can_focus(false);
2688 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2689 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2691 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2692 track_list_visible_cell->property_activatable() = true;
2693 track_list_visible_cell->property_radio() = false;
2694 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2696 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2698 track_display_scroller.add (track_display);
2699 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2701 VBox* v = manage (new VBox);
2703 v->pack_start (track_display_scroller, true, true);
2705 track_display_frame.set_name("BaseFrame");
2706 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2707 track_display_frame.add (*v);
2709 track_display_scroller.show();
2710 track_display_frame.show();
2711 track_display.show();
2715 Mixer_UI::new_track_or_bus ()
2717 ARDOUR_UI::instance()->add_route ();
2721 Mixer_UI::update_title ()
2723 if (!own_window()) {
2730 if (_session->snap_name() != _session->name()) {
2731 n = _session->snap_name ();
2733 n = _session->name ();
2736 if (_session->dirty ()) {
2740 WindowTitle title (n);
2741 title += S_("Window|Mixer");
2742 title += Glib::get_application_name ();
2743 own_window()->set_title (title.get_string());
2747 WindowTitle title (S_("Window|Mixer"));
2748 title += Glib::get_application_name ();
2749 own_window()->set_title (title.get_string());
2754 Mixer_UI::strip_by_x (int x)
2756 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2759 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2760 x2 = x1 + (*i)->get_width();
2762 if (x >= x1 && x <= x2) {
2771 Mixer_UI::set_axis_targets_for_operation ()
2773 _axis_targets.clear ();
2775 if (!_selection.empty()) {
2776 _axis_targets = _selection.axes;
2780 // removed "implicit" selections of strips, after discussion on IRC
2785 Mixer_UI::monitor_section_going_away ()
2787 XMLNode* ui_node = Config->extra_xml(X_("UI"));
2789 /* immediate state save.
2791 * Tearoff settings are otherwise only stored during
2792 * save_ardour_state(). The mon-section may or may not
2793 * exist at that point.
2797 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
2799 tearoff_node->remove_nodes_and_delete (X_("monitor-section"));
2800 XMLNode* t = new XMLNode (X_("monitor-section"));
2801 _monitor_section.tearoff().add_state (*t);
2802 tearoff_node->add_child_nocopy (*t);
2806 monitor_section_detached ();
2807 out_packer.remove (_monitor_section.tearoff());
2811 Mixer_UI::toggle_midi_input_active (bool flip_others)
2813 boost::shared_ptr<RouteList> rl (new RouteList);
2816 set_axis_targets_for_operation ();
2818 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2819 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2823 onoff = !mt->input_active();
2827 _session->set_exclusive_input_active (rl, onoff, flip_others);
2831 Mixer_UI::maximise_mixer_space ()
2833 if (!own_window()) {
2841 _window->fullscreen ();
2846 Mixer_UI::restore_mixer_space ()
2848 if (!own_window()) {
2856 own_window()->unfullscreen();
2861 Mixer_UI::monitor_section_attached ()
2863 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2864 act->set_sensitive (true);
2865 showhide_monitor_section (act->get_active ());
2869 Mixer_UI::monitor_section_detached ()
2871 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleMonitorSection");
2872 act->set_sensitive (false);
2876 Mixer_UI::store_current_favorite_order ()
2878 typedef Gtk::TreeModel::Children type_children;
2879 type_children children = favorite_plugins_model->children();
2880 favorite_order.clear();
2881 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2883 Gtk::TreeModel::Row row = *iter;
2884 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2885 favorite_order.push_back (ppp->_pip);
2886 std::string name = row[favorite_plugins_columns.name];
2887 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2892 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2894 Gtk::TreeModel::Row row = *iter;
2895 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2897 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2901 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2903 PluginManager& manager (PluginManager::instance());
2904 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2906 /* not a Favorite? skip it */
2907 if (manager.get_status (*i) != PluginManager::Favorite) {
2911 /* Check the tag combo selection, and skip this plugin if it doesn't match the selected tag(s) */
2912 string test = favorite_plugins_tag_combo.get_active_text();
2913 if (test != _("Show All")) {
2914 vector<string> tags = manager.get_tags(*i);
2916 //does the selected tag match any of the tags in the plugin?
2917 vector<string>::iterator tt = find (tags.begin(), tags.end(), test);
2918 if (tt == tags.end()) {
2923 result.push_back (*i);
2927 struct PluginCustomSorter {
2929 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2930 PluginInfoList::const_iterator aiter = _user.begin();
2931 PluginInfoList::const_iterator biter = _user.begin();
2932 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2933 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2935 if (aiter != _user.end() && biter != _user.end()) {
2936 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2938 if (aiter != _user.end()) {
2941 if (biter != _user.end()) {
2944 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2946 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2948 PluginInfoList _user;
2952 Mixer_UI::refill_favorite_plugins ()
2954 PluginInfoList plugs;
2955 PluginManager& mgr (PluginManager::instance());
2958 refiller (plugs, mgr.lv2_plugin_info ());
2960 #ifdef WINDOWS_VST_SUPPORT
2961 refiller (plugs, mgr.windows_vst_plugin_info ());
2963 #ifdef LXVST_SUPPORT
2964 refiller (plugs, mgr.lxvst_plugin_info ());
2966 #ifdef MACVST_SUPPORT
2967 refiller (plugs, mgr.mac_vst_plugin_info ());
2969 #ifdef AUDIOUNIT_SUPPORT
2970 refiller (plugs, mgr.au_plugin_info ());
2972 refiller (plugs, mgr.ladspa_plugin_info ());
2973 refiller (plugs, mgr.lua_plugin_info ());
2975 store_current_favorite_order ();
2977 PluginCustomSorter cmp (favorite_order);
2980 favorite_order = plugs;
2982 sync_treeview_from_favorite_order ();
2986 Mixer_UI::plugin_list_changed ()
2988 refill_favorite_plugins();
2993 Mixer_UI::refill_tag_combo ()
2995 PluginManager& mgr (PluginManager::instance());
2997 std::vector<std::string> tags = mgr.get_all_tags (PluginManager::OnlyFavorites);
2999 favorite_plugins_tag_combo.clear();
3000 favorite_plugins_tag_combo.append_text (_("Show All"));
3002 for (vector<string>::iterator t = tags.begin (); t != tags.end (); ++t) {
3003 favorite_plugins_tag_combo.append_text (*t);
3006 favorite_plugins_tag_combo.set_active_text (_("Show All"));
3010 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
3013 if (!(iter = favorite_plugins_model->get_iter (path))) {
3016 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3020 PluginInfoPtr pip = ppp->_pip;
3021 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3022 if (favorite_ui_state[pip->unique_id]) {
3023 favorite_plugins_display.expand_row (path, true);
3029 Mixer_UI::sync_treeview_from_favorite_order ()
3031 favorite_plugins_model->clear ();
3032 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
3033 PluginInfoPtr pip = (*i);
3035 TreeModel::Row newrow = *(favorite_plugins_model->append());
3036 newrow[favorite_plugins_columns.name] = (*i)->name;
3037 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
3042 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
3043 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
3047 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
3048 child_row[favorite_plugins_columns.name] = (*j).label;
3049 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
3051 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3052 if (favorite_ui_state[pip->unique_id]) {
3053 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
3060 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
3062 using namespace Gtk::Menu_Helpers;
3064 Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu ();
3065 MenuList& items = m->items ();
3067 if (_selection.axes.empty()) {
3068 items.push_back (MenuElem (_("No Track/Bus is selected.")));
3070 items.push_back (MenuElem (_("Add at the top"),
3071 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
3072 items.push_back (MenuElem (_("Add Pre-Fader"),
3073 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
3074 items.push_back (MenuElem (_("Add Post-Fader"),
3075 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
3076 items.push_back (MenuElem (_("Add at the end"),
3077 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
3080 items.push_back (SeparatorElem());
3082 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
3084 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3085 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
3086 // we cannot currently delete AU presets
3087 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
3088 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
3092 m->popup (ev->button, ev->time);
3096 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
3098 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
3099 TreeModel::Path path;
3100 TreeViewColumn* column;
3102 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
3103 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3105 selection->unselect_all();
3106 selection->select(path);
3109 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3111 popup_note_context_menu (ev);
3119 Mixer_UI::selected_plugin ()
3121 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3123 return PluginPresetPtr();
3125 Gtk::TreeModel::iterator iter = selection->get_selected();
3127 return PluginPresetPtr();
3129 return (*iter)[favorite_plugins_columns.plugin];
3133 Mixer_UI::add_selected_processor (ProcessorPosition pos)
3135 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3137 add_favorite_processor (ppp, pos);
3142 Mixer_UI::delete_selected_preset ()
3147 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3148 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
3151 PluginPtr plugin = ppp->_pip->load (*_session);
3152 plugin->get_presets();
3153 plugin->remove_preset (ppp->_preset.label);
3157 Mixer_UI::remove_selected_from_favorites ()
3159 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3163 PluginManager::PluginStatusType status = PluginManager::Normal;
3164 PluginManager& manager (PluginManager::instance());
3166 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3167 manager.save_statuses ();
3171 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
3174 if (!(iter = favorite_plugins_model->get_iter (path))) {
3177 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3178 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
3182 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
3184 if (!_session || _selection.axes.empty()) {
3188 PluginInfoPtr pip = ppp->_pip;
3189 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
3190 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
3196 PluginPtr p = pip->load (*_session);
3202 if (ppp->_preset.valid) {
3203 p->load_preset (ppp->_preset);
3206 Route::ProcessorStreams err;
3207 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
3211 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
3214 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
3221 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
3225 if (!np->display_to_user()) {
3228 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
3229 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
3234 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
3238 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
3245 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
3247 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
3251 // only allow to re-order top-level items
3253 if (TreePath::get_from_selection_data (data, src)) {
3254 if (src.up() && src.up()) {
3259 // don't allow to drop as child-rows.
3260 Gtk::TreeModel::Path _dest = dest; // un const
3261 const bool is_child = _dest.up (); // explicit bool for clang
3262 if (!is_child || _dest.empty ()) {
3269 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
3271 if (data.get_target() != "PluginPresetPtr") {
3274 if (data.get_length() != sizeof (PluginPresetPtr)) {
3277 const void *d = data.get_data();
3278 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
3280 PluginManager::PluginStatusType status = PluginManager::Favorite;
3281 PluginManager& manager (PluginManager::instance());
3283 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3284 manager.save_statuses ();
3288 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
3290 /* call protected MixerActor:: method */
3295 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
3297 /* call protected MixerActor:: method */
3302 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
3304 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
3307 show_spill_change (s); /* EMIT SIGNAL */
3309 _group_tabs->hide ();
3311 _group_tabs->show ();
3313 redisplay_track_list ();
3318 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
3320 return s == spilled_strip.lock();
3324 Mixer_UI::register_actions ()
3326 Glib::RefPtr<ActionGroup> group = ActionManager::create_action_group (bindings, X_("Mixer"));
3328 ActionManager::register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
3329 ActionManager::register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
3330 ActionManager::register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
3331 ActionManager::register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
3332 ActionManager::register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
3333 ActionManager::register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
3336 ActionManager::register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
3337 ActionManager::register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
3338 ActionManager::register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
3339 ActionManager::register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
3340 ActionManager::register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
3341 ActionManager::register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
3342 ActionManager::register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
3343 ActionManager::register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
3345 ActionManager::register_action (group, "select-next-stripable", _("Select Next Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_next_strip));
3346 ActionManager::register_action (group, "select-prev-stripable", _("Scroll Previous Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_prev_strip));
3348 ActionManager::register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
3349 ActionManager::register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
3351 ActionManager::register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
3352 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
3354 ActionManager::register_toggle_action (group, X_("ToggleMixerList"), _("Mixer: Show Mixer List"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixer_list));
3356 ActionManager::register_toggle_action (group, X_("ToggleVCAPane"), _("Mixer: Show VCAs"), sigc::mem_fun (*this, &Mixer_UI::toggle_vcas));
3359 ActionManager::register_toggle_action (group, X_("ToggleMixbusPane"), _("Mixer: Show Mixbusses"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixbuses));
3362 ActionManager::register_toggle_action (group, X_("ToggleMonitorSection"), _("Mixer: Show Monitor Section"), sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_section));
3366 Mixer_UI::load_bindings ()
3368 bindings = Bindings::get_bindings (X_("Mixer"));
3371 template<class T> void
3372 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
3374 boost::shared_ptr<ControlList> cl (new ControlList);
3375 boost::shared_ptr<AutomationControl> ac;
3377 bool have_val = false;
3379 set_axis_targets_for_operation ();
3381 BOOST_FOREACH(AxisView* r, _axis_targets) {
3382 boost::shared_ptr<Stripable> s = r->stripable();
3384 ac = (s.get()->*get_control)();
3388 val = !ac->get_value();
3395 _session->set_controls (cl, val, Controllable::UseGroup);
3399 Mixer_UI::solo_action ()
3401 control_action (&Stripable::solo_control);
3405 Mixer_UI::mute_action ()
3407 control_action (&Stripable::mute_control);
3411 Mixer_UI::rec_enable_action ()
3413 control_action (&Stripable::rec_enable_control);
3416 AutomationControlSet
3417 Mixer_UI::selected_gaincontrols ()
3419 set_axis_targets_for_operation ();
3420 AutomationControlSet rv;
3421 BOOST_FOREACH(AxisView* r, _axis_targets) {
3422 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3424 boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
3425 ControlList cl (ac->grouped_controls());
3426 for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
3436 Mixer_UI::step_gain_up_action ()
3438 AutomationControlSet acs = selected_gaincontrols ();
3439 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3440 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3442 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
3447 Mixer_UI::step_gain_down_action ()
3449 AutomationControlSet acs = selected_gaincontrols ();
3450 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3451 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3453 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
3458 Mixer_UI::unity_gain_action ()
3460 set_axis_targets_for_operation ();
3462 BOOST_FOREACH(AxisView* r, _axis_targets) {
3463 boost::shared_ptr<Stripable> s = r->stripable();
3465 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3467 ac->set_value (1.0, Controllable::UseGroup);
3474 Mixer_UI::copy_processors ()
3476 set_axis_targets_for_operation ();
3478 BOOST_FOREACH(AxisView* r, _axis_targets) {
3479 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3481 ms->copy_processors ();
3486 Mixer_UI::cut_processors ()
3488 set_axis_targets_for_operation ();
3490 BOOST_FOREACH(AxisView* r, _axis_targets) {
3491 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3493 ms->cut_processors ();
3498 Mixer_UI::paste_processors ()
3500 set_axis_targets_for_operation ();
3502 BOOST_FOREACH(AxisView* r, _axis_targets) {
3503 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3505 ms->paste_processors ();
3510 Mixer_UI::select_all_processors ()
3512 set_axis_targets_for_operation ();
3514 BOOST_FOREACH(AxisView* r, _axis_targets) {
3515 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3517 ms->select_all_processors ();
3522 Mixer_UI::toggle_processors ()
3524 set_axis_targets_for_operation ();
3526 BOOST_FOREACH(AxisView* r, _axis_targets) {
3527 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3529 ms->toggle_processors ();
3534 Mixer_UI::ab_plugins ()
3536 set_axis_targets_for_operation ();
3538 BOOST_FOREACH(AxisView* r, _axis_targets) {
3539 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3547 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3549 set_axis_targets_for_operation ();
3550 BOOST_FOREACH(AxisView* r, _axis_targets) {
3551 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3553 ms->vca_assign (vca);
3559 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3561 set_axis_targets_for_operation ();
3562 BOOST_FOREACH(AxisView* r, _axis_targets) {
3563 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3565 ms->vca_unassign (vca);
3571 Mixer_UI::screenshot (std::string const& filename)
3577 int height = strip_packer.get_height();
3578 bool with_vca = vca_vpacker.is_visible ();
3579 MixerStrip* master = strip_by_route (_session->master_out ());
3581 Gtk::OffscreenWindow osw;
3586 /* unpack widgets, add to OffscreenWindow */
3588 strip_group_box.remove (strip_packer);
3589 b.pack_start (strip_packer, false, false);
3590 /* hide extra elements inside strip_packer */
3592 scroller_base.hide ();
3598 /* work around Gtk::ScrolledWindow */
3599 Gtk::Viewport* viewport = (Gtk::Viewport*) vca_scroller.get_child();
3600 viewport->remove (); // << vca_hpacker
3601 b.pack_start (vca_hpacker, false, false);
3602 /* hide some growing widgets */
3603 add_vca_button.hide ();
3604 vca_scroller_base.hide();
3608 out_packer.remove (*master);
3609 b.pack_start (*master, false, false);
3610 master->hide_master_spacer (true);
3613 /* prepare the OffscreenWindow for rendering */
3614 osw.set_size_request (-1, height);
3616 osw.queue_resize ();
3618 osw.get_window()->process_updates (true);
3620 /* create screenshot */
3621 Glib::RefPtr<Gdk::Pixbuf> pb = osw.get_pixbuf ();
3622 pb->save (filename, "png");
3624 /* unpack elements before destorying the Box & OffscreenWindow */
3625 list<Gtk::Widget*> children = b.get_children();
3626 for (list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
3631 /* now re-pack the widgets into the main mixer window */
3633 scroller_base.show ();
3637 strip_group_box.pack_start (strip_packer);
3639 add_vca_button.show ();
3640 vca_scroller_base.show();
3641 vca_scroller.add (vca_hpacker);
3644 master->hide_master_spacer (false);
3645 out_packer.pack_start (*master, false, false);