2 * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3 * Copyright (C) 2005-2018 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2006-2007 Doug McLain <doug@nostar.net>
5 * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2007-2012 David Robillard <d@drobilla.net>
7 * Copyright (C) 2007-2016 Tim Mayberry <mojofunk@gmail.com>
8 * Copyright (C) 2013-2015 Nick Mainsbridge <mainsbridge@gmail.com>
9 * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
10 * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
11 * Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "gtk2ardour-config.h"
34 #include <sigc++/bind.h>
36 #include <boost/foreach.hpp>
38 #include <glibmm/threads.h>
40 #include <gtkmm/accelmap.h>
41 #include <gtkmm/offscreenwindow.h>
42 #include <gtkmm/stock.h>
44 #include "pbd/convert.h"
45 #include "pbd/stacktrace.h"
46 #include "pbd/unwind.h"
48 #include "ardour/amp.h"
49 #include "ardour/debug.h"
50 #include "ardour/audio_track.h"
51 #include "ardour/midi_track.h"
52 #include "ardour/plugin_manager.h"
53 #include "ardour/route_group.h"
54 #include "ardour/selection.h"
55 #include "ardour/session.h"
56 #include "ardour/vca.h"
57 #include "ardour/vca_manager.h"
59 #include "gtkmm2ext/gtk_ui.h"
60 #include "gtkmm2ext/keyboard.h"
61 #include "gtkmm2ext/utils.h"
62 #include "gtkmm2ext/window_title.h"
63 #include "gtkmm2ext/doi.h"
65 #include "widgets/tearoff.h"
67 #include "foldback_strip.h"
70 #include "mixer_strip.h"
71 #include "monitor_section.h"
72 #include "plugin_selector.h"
73 #include "public_editor.h"
74 #include "mouse_cursors.h"
75 #include "ardour_ui.h"
77 #include "route_sorter.h"
79 #include "gui_thread.h"
80 #include "mixer_group_tabs.h"
81 #include "route_sorter.h"
83 #include "ui_config.h"
84 #include "vca_master_strip.h"
88 using namespace ARDOUR;
89 using namespace ARDOUR_UI_UTILS;
93 using namespace Gtkmm2ext;
99 Mixer_UI* Mixer_UI::_instance = 0;
102 Mixer_UI::instance ()
105 _instance = new Mixer_UI;
111 Mixer_UI::Mixer_UI ()
112 : Tabbable (_content, _("Mixer"))
113 , no_track_list_redisplay (false)
114 , in_group_row_change (false)
116 , _plugin_selector (0)
118 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
119 , _spill_scroll_position (0)
120 , ignore_reorder (false)
121 , _in_group_rebuild_or_clear (false)
122 , _route_deletion_in_progress (false)
124 , _strip_selection_change_without_scroll (false)
125 , _selection (*this, *this)
129 _content.set_data ("ardour-bindings", bindings);
131 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
133 scroller.set_can_default (true);
134 // set_default (scroller);
136 scroller_base.set_flags (Gtk::CAN_FOCUS);
137 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
138 scroller_base.set_name ("MixerWindow");
139 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
141 /* set up drag-n-drop */
142 vector<TargetEntry> target_table;
143 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
144 scroller_base.drag_dest_set (target_table);
145 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
147 /* create a button to add VCA strips ... will get packed in redisplay_track_list() */
148 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
150 add_vca_button.add (*w);
151 add_vca_button.set_can_focus(false);
152 add_vca_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
154 /* create a button to add mixer strips */
155 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
158 add_button.set_can_focus(false);
159 add_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
161 /* add as last item of strip packer */
162 strip_packer.pack_end (scroller_base, true, true);
163 strip_packer.pack_end (add_button, false, false);
166 /* create a drop-shadow at the end of the mixer strips */
167 mb_shadow.set_size_request( 4, -1 );
168 mb_shadow.set_name("EditorWindow");
170 strip_packer.pack_end (mb_shadow, false, false);
173 _group_tabs = new MixerGroupTabs (this);
174 strip_group_box.set_spacing (0);
175 strip_group_box.set_border_width (0);
176 strip_group_box.pack_start (*_group_tabs, PACK_SHRINK);
177 strip_group_box.pack_start (strip_packer);
178 strip_group_box.show_all ();
179 strip_group_box.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
181 scroller.add (strip_group_box);
182 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
184 setup_track_display ();
186 group_model = ListStore::create (group_columns);
187 group_display.set_model (group_model);
188 group_display.append_column (_("Show"), group_columns.visible);
189 group_display.append_column (_("Group"), group_columns.text);
190 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
191 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
192 group_display.get_column (0)->set_expand(false);
193 group_display.get_column (1)->set_expand(true);
194 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
195 group_display.set_name ("EditGroupList");
196 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
197 group_display.set_reorderable (true);
198 group_display.set_headers_visible (true);
199 group_display.set_rules_hint (true);
200 group_display.set_can_focus(false);
202 /* name is directly editable */
204 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
205 name_cell->property_editable() = true;
206 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
208 /* use checkbox for the active column */
210 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
211 active_cell->property_activatable() = true;
212 active_cell->property_radio() = false;
214 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
215 /* We use this to notice drag-and-drop reorders of the group list */
216 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
217 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
219 group_display_scroller.add (group_display);
220 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
223 group_display_vbox.pack_start (group_display_scroller, true, true);
225 group_display_frame.set_name ("BaseFrame");
226 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
227 group_display_frame.add (group_display_vbox);
229 list<TargetEntry> target_list;
230 target_list.push_back (TargetEntry ("PluginPresetPtr"));
232 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
233 favorite_plugins_display.set_model (favorite_plugins_model);
234 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
235 favorite_plugins_display.set_name ("EditGroupList");
236 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
237 favorite_plugins_display.set_reorderable (false);
238 favorite_plugins_display.set_headers_visible (true);
239 favorite_plugins_display.set_rules_hint (true);
240 favorite_plugins_display.set_can_focus (false);
241 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
242 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
243 favorite_plugins_display.add_drop_targets (target_list);
244 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
245 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
246 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
247 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
248 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
249 if (UIConfiguration::instance().get_use_tooltips()) {
250 favorite_plugins_display.set_tooltip_column (0);
252 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
254 favorite_plugins_scroller.add (favorite_plugins_display);
255 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
257 favorite_plugins_frame.set_name ("BaseFrame");
258 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
259 favorite_plugins_frame.add (favorite_plugins_vbox);
261 favorite_plugins_vbox.pack_start (favorite_plugins_scroller, true, true);
262 favorite_plugins_vbox.pack_start (favorite_plugins_tag_combo, false, false);
263 favorite_plugins_tag_combo.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::tag_combo_changed));
265 rhs_pane1.add (favorite_plugins_frame);
266 rhs_pane1.add (track_display_frame);
268 rhs_pane2.add (rhs_pane1);
269 rhs_pane2.add (group_display_frame);
271 list_vpacker.pack_start (rhs_pane2, true, true);
273 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
274 vca_vpacker.pack_start (vca_label_bar, false, false);
276 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
277 vca_scroller_base.set_name (X_("MixerWindow"));
278 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
280 vca_hpacker.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_vca_scroll_event), false);
281 vca_scroller.add (vca_hpacker);
282 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
283 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
285 vca_vpacker.pack_start (vca_scroller, true, true);
287 inner_pane.add (scroller);
288 inner_pane.add (vca_vpacker);
290 global_hpacker.pack_start (inner_pane, true, true);
291 global_hpacker.pack_start (out_packer, false, false);
293 list_hpane.set_check_divider_position (true);
294 list_hpane.add (list_vpacker);
295 list_hpane.add (global_hpacker);
296 list_hpane.set_child_minsize (list_vpacker, 30);
298 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
301 if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) {
304 rhs_pane1.set_divider (0, fract);
306 if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
309 rhs_pane2.set_divider (0, fract);
311 if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
314 list_hpane.set_divider (0, fract);
316 if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
319 inner_pane.set_divider (0, fract);
321 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
322 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
323 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
324 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
326 _content.pack_start (list_hpane, true, true);
331 _content.set_name ("MixerWindow");
333 global_hpacker.show();
335 scroller_base.show();
336 scroller_hpacker.show();
337 mixer_scroller_vpacker.show();
339 group_display_button_label.show();
340 group_display_scroller.show();
341 favorite_plugins_scroller.show();
342 group_display_vbox.show();
343 group_display_frame.show();
344 favorite_plugins_frame.show();
352 vca_label_bar.show();
354 vca_scroller_base.show();
357 group_display.show();
358 favorite_plugins_display.show();
361 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
363 _monitor_section.tearoff().set_state (*mnode);
366 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
367 VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
371 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
373 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
374 _plugin_selector = new PluginSelector (PluginManager::instance ());
376 #error implement deferred Plugin-Favorite list
379 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
380 PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
381 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
384 Mixer_UI::~Mixer_UI ()
386 monitor_section_detached ();
389 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
391 if (foldback_strip) {
392 delete foldback_strip;
396 delete _plugin_selector;
400 struct MixerStripSorter {
401 bool operator() (const MixerStrip* ms_a, const MixerStrip* ms_b)
403 boost::shared_ptr<ARDOUR::Stripable> const& a = ms_a->stripable ();
404 boost::shared_ptr<ARDOUR::Stripable> const& b = ms_b->stripable ();
405 return ARDOUR::Stripable::Sorter(true)(a, b);
417 Mixer_UI::tag_combo_changed ()
419 refill_favorite_plugins();
423 Mixer_UI::use_own_window (bool and_fill_it)
425 bool new_window = !own_window();
427 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
429 if (win && new_window) {
430 win->set_name ("MixerWindow");
431 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
432 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
433 win->set_data ("ardour-bindings", bindings);
435 if (!win->get_focus()) {
436 /* set focus widget to something, anything */
437 win->set_focus (scroller);
445 Mixer_UI::show_window ()
447 Tabbable::show_window ();
449 /* show/hide group tabs as required */
450 parameter_changed ("show-group-tabs");
452 /* now reset each strips width so the right widgets are shown */
454 TreeModel::Children rows = track_model->children();
455 TreeModel::Children::iterator ri;
457 for (ri = rows.begin(); ri != rows.end(); ++ri) {
458 AxisView* av = (*ri)[stripable_columns.strip];
459 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
463 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
464 /* Fix visibility of mixer strip stuff */
465 ms->parameter_changed (X_("mixer-element-visibility"));
468 /* force focus into main area */
469 scroller_base.grab_focus ();
473 Mixer_UI::remove_master (VCAMasterStrip* vms)
475 if (_session && _session->deletion_in_progress()) {
476 /* its all being taken care of */
480 TreeModel::Children rows = track_model->children();
481 TreeModel::Children::iterator ri;
483 for (ri = rows.begin(); ri != rows.end(); ++ri) {
484 if ((*ri)[stripable_columns.strip] == vms) {
485 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
486 track_model->erase (ri);
493 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
495 using namespace Menu_Helpers;
497 if (Keyboard::is_context_menu_event (ev)) {
498 ARDOUR_UI::instance()->add_route ();
506 Mixer_UI::new_masters_created ()
508 ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane")->set_active (true);
512 Mixer_UI::add_masters (VCAList& vlist)
516 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
517 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
524 Mixer_UI::add_routes (RouteList& rlist)
528 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
536 Mixer_UI::add_stripables (StripableList& slist)
538 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
539 bool from_scratch = (track_model->children().size() == 0);
540 uint32_t nroutes = 0;
542 slist.sort (Stripable::Sorter());
544 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
545 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
553 // XXX what does this special case do?
554 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
563 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
565 track_display.set_model (Glib::RefPtr<ListStore>());
567 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
569 boost::shared_ptr<Route> route;
570 boost::shared_ptr<VCA> vca;
572 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
574 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
576 TreeModel::Row row = *(track_model->append());
578 row[stripable_columns.text] = vca->name();
579 row[stripable_columns.visible] = vms->marked_for_display ();
580 row[stripable_columns.strip] = vms;
581 row[stripable_columns.stripable] = vca;
583 vms->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::vca_button_release_event), vms));
585 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
587 if (route->is_auditioner()) {
591 if (route->is_monitor()) {
593 out_packer.pack_end (_monitor_section.tearoff(), false, false);
594 if (foldback_strip) {
595 out_packer.remove (*foldback_strip);
596 out_packer.pack_end (*foldback_strip, false, false);
597 foldback_strip->set_packed (true);
599 _monitor_section.set_session (_session);
600 _monitor_section.tearoff().show_all ();
602 _monitor_section.tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
603 _monitor_section.tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
605 if (_monitor_section.tearoff().torn_off()) {
606 monitor_section_detached ();
608 monitor_section_attached ();
611 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
613 /* no regular strip shown for control out */
617 if (route->is_foldbackbus ()) {
618 if (foldback_strip) {
619 foldback_strip->set_route (route);
621 foldback_strip = new FoldbackStrip (*this, _session, route);
622 out_packer.pack_end (*foldback_strip, false, false);
623 foldback_strip->set_packed (true);
628 strip = new MixerStrip (*this, _session, route);
629 strips.push_back (strip);
631 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
633 if (strip->width_owner() != strip) {
634 strip->set_width_enum (_strip_width, this);
639 if (route->is_master()) {
641 out_packer.pack_start (*strip, false, false);
642 strip->set_packed (true);
646 TreeModel::Row row = *(track_model->insert (insert_iter));
648 row[stripable_columns.text] = route->name();
649 row[stripable_columns.visible] = strip->marked_for_display();
650 row[stripable_columns.stripable] = route;
651 row[stripable_columns.strip] = strip;
654 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
655 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
658 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
659 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
662 } catch (const std::exception& e) {
663 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
666 track_display.set_model (track_model);
668 /* catch up on selection state, which we left to the editor to set */
669 sync_treeview_from_presentation_info (PropertyChange (Properties::selected));
672 sync_presentation_info_from_treeview ();
675 redisplay_track_list ();
679 Mixer_UI::deselect_all_strip_processors ()
681 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
682 (*i)->deselect_all_processors();
687 Mixer_UI::select_none ()
689 _selection.clear_routes();
690 deselect_all_strip_processors();
694 Mixer_UI::select_next_strip ()
696 deselect_all_strip_processors();
697 _session->selection().select_next_stripable (true, false);
701 Mixer_UI::select_prev_strip ()
703 deselect_all_strip_processors();
704 _session->selection().select_prev_stripable (true, false);
708 Mixer_UI::delete_processors ()
710 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
711 (*i)->delete_processors();
717 Mixer_UI::remove_strip (MixerStrip* strip)
719 if (_session && _session->deletion_in_progress()) {
720 /* its all being taken care of */
724 TreeModel::Children rows = track_model->children();
725 TreeModel::Children::iterator ri;
726 list<MixerStrip *>::iterator i;
728 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
732 PBD::Unwinder<bool> uwi (ignore_reorder, true);
734 for (ri = rows.begin(); ri != rows.end(); ++ri) {
735 if ((*ri)[stripable_columns.strip] == strip) {
736 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
737 track_model->erase (ri);
744 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
746 if (what_changed.contains (Properties::selected)) {
747 _selection.presentation_info_changed (what_changed);
751 soh.add (Properties::selected);
752 soh.add (Properties::order);
753 soh.add (Properties::hidden);
755 if (what_changed.contains (soh)) {
756 sync_treeview_from_presentation_info (what_changed);
761 Mixer_UI::sync_presentation_info_from_treeview ()
763 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
767 TreeModel::Children rows = track_model->children();
773 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
775 TreeModel::Children::iterator ri;
778 PresentationInfo::order_t master_key = _session->master_order_key ();
779 PresentationInfo::order_t order = 0;
781 PresentationInfo::ChangeSuspender cs;
783 for (ri = rows.begin(); ri != rows.end(); ++ri) {
784 bool visible = (*ri)[stripable_columns.visible];
785 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
787 #ifndef NDEBUG // these should not exist in the mixer's treeview
792 if (stripable->is_monitor() || stripable->is_auditioner()) {
796 if (stripable->is_master()) {
802 stripable->presentation_info().set_hidden (!visible);
804 // leave master where it is.
805 if (order == master_key) {
809 if (order != stripable->presentation_info().order()) {
810 stripable->set_presentation_order (order);
816 change |= _session->ensure_stripable_sort_order ();
819 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
820 _session->set_dirty();
825 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
827 if (!_session || _session->deletion_in_progress()) {
831 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
833 /* we could get here after either a change in the Mixer or Editor sort
834 * order, but either way, the mixer order keys reflect the intended
835 * order for the GUI, so reorder the treeview model to match it.
838 vector<int> neworder;
839 TreeModel::Children rows = track_model->children();
840 uint32_t old_order = 0;
841 bool changed = false;
847 TreeOrderKeys sorted;
848 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
849 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
850 sorted.push_back (TreeOrderKey (old_order, stripable));
853 TreeOrderKeySorter cmp;
855 sort (sorted.begin(), sorted.end(), cmp);
856 neworder.assign (sorted.size(), 0);
860 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
862 neworder[n] = sr->old_display_order;
864 if (sr->old_display_order != n) {
870 Unwinder<bool> uw (ignore_reorder, true);
871 track_model->reorder (neworder);
874 if (what_changed.contains (Properties::selected)) {
876 PresentationInfo::ChangeSuspender cs;
878 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
879 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
880 if (stripable && stripable->is_selected()) {
883 _selection.remove (*i);
887 if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) {
888 move_stripable_into_view ((*_selection.axes.begin())->stripable());
891 TreeModel::Children rows = track_model->children();
892 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
893 AxisView* av = (*i)[stripable_columns.strip];
894 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
898 if (vms->vca() && vms->vca()->is_selected()) {
899 _selection.add (vms);
901 _selection.remove (vms);
906 redisplay_track_list ();
911 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
913 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
914 if ((*i)->route() == r) {
923 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
925 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
926 if ((*i)->stripable() == s) {
935 Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
937 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
938 if ((*i)->stripable() == s) {
943 TreeModel::Children rows = track_model->children();
944 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
945 AxisView* av = (*i)[stripable_columns.strip];
946 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
947 if (vms && vms->stripable () == s) {
956 Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
958 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
959 if ((*i)->control() == c) {
968 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
970 /* Selecting a mixer-strip may also select grouped-tracks, and
971 * presentation_info_changed() being emitted and
972 * _selection.axes.begin() is being moved into view. This may
973 * effectively move the track that was clicked-on out of view.
975 * So here only the track that is actually clicked-on is moved into
976 * view (in case it's partially visible)
978 PBD::Unwinder<bool> uw (_strip_selection_change_without_scroll, true);
979 move_stripable_into_view (strip->stripable());
981 if (ev->button == 1) {
982 if (_selection.selected (strip)) {
983 /* primary-click: toggle selection state of strip */
984 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
985 _selection.remove (strip, true);
986 } else if (_selection.axes.size() > 1) {
987 /* de-select others */
988 _selection.set (strip);
990 PublicEditor& pe = PublicEditor::instance();
991 TimeAxisView* tav = pe.time_axis_view_from_stripable (strip->stripable());
993 pe.set_selected_mixer_strip (*tav);
996 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
997 _selection.add (strip, true);
998 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
1000 /* extend selection */
1002 vector<MixerStrip*> tmp;
1003 bool accumulate = false;
1004 bool found_another = false;
1006 strips.sort (MixerStripSorter());
1008 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1009 MixerStrip* ms = *i;
1013 /* hit clicked strip, start accumulating till we hit the first
1022 } else if (_selection.selected (ms)) {
1023 /* hit selected strip. if currently accumulating others,
1024 we're done. if not accumulating others, start doing so.
1026 found_another = true;
1040 tmp.push_back (strip);
1042 if (found_another) {
1043 PresentationInfo::ChangeSuspender cs;
1044 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
1045 _selection.add (*i, true);
1048 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
1051 _selection.set (strip);
1060 Mixer_UI::vca_button_release_event (GdkEventButton *ev, VCAMasterStrip *strip)
1062 _selection.set (strip);
1067 Mixer_UI::set_session (Session* sess)
1069 SessionHandlePtr::set_session (sess);
1070 _monitor_section.set_session (sess);
1072 if (_plugin_selector) {
1073 _plugin_selector->set_session (_session);
1076 _group_tabs->set_session (sess);
1079 _selection.clear ();
1083 refill_favorite_plugins();
1086 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1087 set_state (*node, 0);
1091 initial_track_display ();
1093 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1094 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1095 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1096 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1097 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1098 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1099 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1101 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1102 _session->vca_manager().VCACreated.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::new_masters_created, this), gui_context());
1104 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1106 route_groups_changed ();
1112 /* catch up on selection state, etc. */
1115 sc.add (Properties::selected);
1116 _selection.presentation_info_changed (sc);
1122 Mixer_UI::session_going_away ()
1124 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1126 _in_group_rebuild_or_clear = true;
1127 group_model->clear ();
1128 _in_group_rebuild_or_clear = false;
1130 _selection.clear ();
1131 track_model->clear ();
1133 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1137 _monitor_section.tearoff().hide_visible ();
1139 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1141 if (foldback_strip) {
1142 delete foldback_strip;
1147 monitor_section_detached ();
1153 SessionHandlePtr::session_going_away ();
1160 Mixer_UI::track_visibility_changed (std::string const & path)
1162 if (_session && _session->deletion_in_progress()) {
1168 if ((iter = track_model->get_iter (path))) {
1170 AxisView* av = (*iter)[stripable_columns.strip];
1171 bool visible = (*iter)[stripable_columns.visible];
1173 if (av->set_marked_for_display (!visible)) {
1174 update_track_visibility ();
1180 Mixer_UI::update_track_visibility ()
1182 TreeModel::Children rows = track_model->children();
1183 TreeModel::Children::iterator i;
1186 Unwinder<bool> uw (no_track_list_redisplay, true);
1188 for (i = rows.begin(); i != rows.end(); ++i) {
1189 AxisView* av = (*i)[stripable_columns.strip];
1190 (*i)[stripable_columns.visible] = av->marked_for_display ();
1193 /* force presentation catch up with visibility changes
1196 sync_presentation_info_from_treeview ();
1199 redisplay_track_list ();
1203 Mixer_UI::show_strip (MixerStrip* ms)
1205 TreeModel::Children rows = track_model->children();
1206 TreeModel::Children::iterator i;
1208 for (i = rows.begin(); i != rows.end(); ++i) {
1210 AxisView* av = (*i)[stripable_columns.strip];
1211 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1213 (*i)[stripable_columns.visible] = true;
1214 av->set_marked_for_display (true);
1215 update_track_visibility ();
1222 Mixer_UI::hide_strip (MixerStrip* ms)
1224 TreeModel::Children rows = track_model->children();
1225 TreeModel::Children::iterator i;
1227 for (i = rows.begin(); i != rows.end(); ++i) {
1229 AxisView* av = (*i)[stripable_columns.strip];
1230 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1232 (*i)[stripable_columns.visible] = false;
1233 av->set_marked_for_display (false);
1234 update_track_visibility ();
1241 Mixer_UI::start_updating ()
1243 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1248 Mixer_UI::stop_updating ()
1250 fast_screen_update_connection.disconnect();
1255 Mixer_UI::fast_update_strips ()
1257 if (_content.is_mapped () && _session) {
1258 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1259 (*i)->fast_update ();
1265 Mixer_UI::set_all_strips_visibility (bool yn)
1267 TreeModel::Children rows = track_model->children();
1268 TreeModel::Children::iterator i;
1271 Unwinder<bool> uw (no_track_list_redisplay, true);
1273 for (i = rows.begin(); i != rows.end(); ++i) {
1275 AxisView* av = (*i)[stripable_columns.strip];
1276 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1282 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1286 (*i)[stripable_columns.visible] = yn;
1290 redisplay_track_list ();
1295 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1297 TreeModel::Children rows = track_model->children();
1298 TreeModel::Children::iterator i;
1301 Unwinder<bool> uw (no_track_list_redisplay, true);
1303 for (i = rows.begin(); i != rows.end(); ++i) {
1305 AxisView* av = (*i)[stripable_columns.strip];
1306 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1312 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1316 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1317 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1321 (*i)[stripable_columns.visible] = yn;
1325 if (at) { /* track */
1326 (*i)[stripable_columns.visible] = yn;
1331 if (!at && !mt) { /* bus */
1332 (*i)[stripable_columns.visible] = yn;
1337 if (mt) { /* midi-track */
1338 (*i)[stripable_columns.visible] = yn;
1345 redisplay_track_list ();
1349 Mixer_UI::hide_all_routes ()
1351 set_all_strips_visibility (false);
1355 Mixer_UI::show_all_routes ()
1357 set_all_strips_visibility (true);
1361 Mixer_UI::show_all_audiobus ()
1363 set_all_audio_midi_visibility (2, true);
1366 Mixer_UI::hide_all_audiobus ()
1368 set_all_audio_midi_visibility (2, false);
1372 Mixer_UI::show_all_audiotracks()
1374 set_all_audio_midi_visibility (1, true);
1377 Mixer_UI::hide_all_audiotracks ()
1379 set_all_audio_midi_visibility (1, false);
1383 Mixer_UI::show_all_miditracks()
1385 set_all_audio_midi_visibility (3, true);
1388 Mixer_UI::hide_all_miditracks ()
1390 set_all_audio_midi_visibility (3, false);
1394 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1396 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1397 sync_presentation_info_from_treeview ();
1401 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1403 /* this happens as the second step of a DnD within the treeview as well
1404 as when a row/route is actually deleted.
1406 if it was a deletion then we have to force a redisplay because
1407 order keys may not have changed.
1410 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1411 sync_presentation_info_from_treeview ();
1413 if (_route_deletion_in_progress) {
1414 redisplay_track_list ();
1419 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1421 TreeModel::Children rows = track_model->children();
1422 std::list<boost::shared_ptr<VCA> > vcas;
1423 vcas.push_back (vca);
1425 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1426 AxisView* av = (*i)[stripable_columns.strip];
1427 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1428 if (vms && vms->vca()->slaved_to (vca)) {
1429 vcas.push_back (vms->vca());
1433 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1435 AxisView* av = (*i)[stripable_columns.strip];
1436 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1437 bool const visible = (*i)[stripable_columns.visible];
1440 /* we're in the middle of changing a row, don't worry */
1444 if (!strip->route()) {
1445 /* non-route element */
1449 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1453 bool slaved = false;
1454 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1455 if (strip->route()->slaved_to (*m)) {
1461 if (slaved && visible) {
1463 if (strip->packed()) {
1464 strip_packer.reorder_child (*strip, -1); /* put at end */
1466 strip_packer.pack_start (*strip, false, false);
1467 strip->set_packed (true);
1472 if (strip->packed()) {
1473 strip_packer.remove (*strip);
1474 strip->set_packed (false);
1481 Mixer_UI::redisplay_track_list ()
1483 if (no_track_list_redisplay) {
1487 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1489 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1491 if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) {
1492 _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value();
1494 spill_redisplay (sv);
1499 TreeModel::Children rows = track_model->children();
1500 TreeModel::Children::iterator i;
1501 uint32_t n_masters = 0;
1503 container_clear (vca_hpacker);
1505 vca_hpacker.pack_end (vca_scroller_base, true, true);
1506 vca_hpacker.pack_end (add_vca_button, false, false);
1508 add_vca_button.show ();
1509 vca_scroller_base.show();
1511 for (i = rows.begin(); i != rows.end(); ++i) {
1513 AxisView* s = (*i)[stripable_columns.strip];
1514 bool const visible = (*i)[stripable_columns.visible];
1515 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1518 /* we're in the middle of changing a row, don't worry */
1522 VCAMasterStrip* vms;
1524 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1526 vca_hpacker.pack_start (*vms, false, false);
1533 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1541 if (strip->packed()) {
1542 strip_packer.reorder_child (*strip, -1); /* put at end */
1544 strip_packer.pack_start (*strip, false, false);
1545 strip->set_packed (true);
1550 if (stripable->is_master() || stripable->is_monitor()) {
1551 /* do nothing, these cannot be hidden */
1553 if (strip->packed()) {
1554 strip_packer.remove (*strip);
1555 strip->set_packed (false);
1561 /* update visibility of VCA assign buttons */
1563 if (n_masters == 0) {
1564 //show/hide the channelstrip VCA assign buttons on channelstrips:
1565 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1567 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleVCAPane");
1569 act->set_sensitive (false);
1572 //remove the VCA packer, but don't change our prior setting for show/hide:
1573 vca_vpacker.hide ();
1575 //show/hide the channelstrip VCA assign buttons on channelstrips:
1576 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1578 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
1579 act->set_sensitive (true);
1581 //if we were showing VCAs before, show them now:
1582 showhide_vcas (act->get_active ());
1585 _group_tabs->set_dirty ();
1587 if (_spill_scroll_position > 0 && scroller.get_hscrollbar()) {
1588 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1589 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), _spill_scroll_position)));
1591 _spill_scroll_position = 0;
1596 Mixer_UI::strip_width_changed ()
1598 _group_tabs->set_dirty ();
1601 TreeModel::Children rows = track_model->children();
1602 TreeModel::Children::iterator i;
1605 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1606 AxisView* av = (*i)[stripable_columns.strip];
1607 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1613 bool visible = (*i)[stripable_columns.visible];
1616 strip->queue_draw();
1623 struct PresentationInfoMixerSorter
1625 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1626 if (a->is_master()) {
1627 /* master after everything else */
1629 } else if (b->is_master()) {
1630 /* everything else before master */
1633 return a->presentation_info().order () < b->presentation_info().order ();
1638 Mixer_UI::initial_track_display ()
1642 _session->get_stripables (sl);
1643 _session->get_stripables (fb, PresentationInfo::FoldbackBus);
1645 boost::shared_ptr<ARDOUR::Stripable> _current_foldback = *(fb.begin());
1646 sl.push_back (_current_foldback);
1649 sl.sort (PresentationInfoMixerSorter());
1652 /* These are also used inside ::add_stripables() but we need
1653 * them here because we're going to clear the track_model also.
1655 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1656 Unwinder<bool> uw2 (ignore_reorder, true);
1658 track_model->clear ();
1659 add_stripables (sl);
1662 sync_treeview_from_presentation_info (Properties::order);
1666 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1668 if (Keyboard::is_context_menu_event (ev)) {
1669 if (track_menu == 0) {
1670 build_track_menu ();
1672 track_menu->popup (ev->button, ev->time);
1675 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1676 TreeModel::Path path;
1677 TreeViewColumn* column;
1679 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1680 TreeIter iter = track_model->get_iter (path);
1681 if ((*iter)[stripable_columns.visible]) {
1682 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1683 move_stripable_into_view (s);
1692 Mixer_UI::move_vca_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1694 if (!vca_scroller.get_hscrollbar()) {
1700 Gtk::Allocation alloc;
1702 TreeModel::Children rows = track_model->children();
1703 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1704 AxisView* av = (*i)[stripable_columns.strip];
1705 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1706 if (vms && vms->stripable () == s) {
1709 vms->translate_coordinates (vca_hpacker, 0, 0, x0, y);
1710 alloc = vms->get_allocation ();
1719 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
1721 if (x0 < adj->get_value()) {
1722 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1723 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1724 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1725 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1730 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1732 if (!scroller.get_hscrollbar()) {
1735 if (s->presentation_info().special ()) {
1738 if (s->presentation_info().flag_match (PresentationInfo::VCA)) {
1739 move_vca_into_view (s);
1748 Gtk::Allocation alloc;
1749 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1750 if ((*i)->route() == s) {
1753 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1754 alloc = (*i)->get_allocation ();
1762 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1764 if (x0 < adj->get_value()) {
1765 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1766 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1767 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1768 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1773 Mixer_UI::build_track_menu ()
1775 using namespace Menu_Helpers;
1776 using namespace Gtk;
1778 track_menu = new Menu;
1779 track_menu->set_name ("ArdourContextMenu");
1780 MenuList& items = track_menu->items();
1782 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1783 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1784 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1785 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1786 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1787 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1788 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1789 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1794 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1796 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1800 boost::shared_ptr<Stripable> s = ws.lock ();
1806 TreeModel::Children rows = track_model->children();
1807 TreeModel::Children::iterator i;
1809 for (i = rows.begin(); i != rows.end(); ++i) {
1810 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1814 if (what_changed.contains (ARDOUR::Properties::name)) {
1815 (*i)[stripable_columns.text] = s->name();
1818 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1819 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1820 redisplay_track_list ();
1827 if (s->is_master ()) {
1831 error << _("track display list item for renamed strip not found!") << endmsg;
1835 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1837 TreeModel::Path path;
1838 TreeViewColumn* column;
1842 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1843 if (ev->button == 3) {
1844 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1849 TreeIter iter = group_model->get_iter (path);
1851 if (ev->button == 3) {
1852 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1857 RouteGroup* group = (*iter)[group_columns.group];
1859 if (Keyboard::is_context_menu_event (ev)) {
1860 _group_tabs->get_menu(group)->popup (1, ev->time);
1864 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1866 if (Keyboard::is_edit_event (ev)) {
1868 // edit_route_group (group);
1870 group_display.queue_draw();
1879 bool visible = (*iter)[group_columns.visible];
1880 (*iter)[group_columns.visible] = !visible;
1882 group_display.queue_draw();
1895 Mixer_UI::activate_all_route_groups ()
1897 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1901 Mixer_UI::disable_all_route_groups ()
1903 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1907 Mixer_UI::route_groups_changed ()
1909 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1911 _in_group_rebuild_or_clear = true;
1913 /* just rebuild the while thing */
1915 group_model->clear ();
1918 /* this is currently not used,
1919 * Mixer_UI::group_display_button_press() has a case for it,
1920 * and a commented edit_route_group() but that's n/a since 2011.
1922 * This code is left as reminder that
1923 * row[group_columns.group] = 0 has special meaning.
1927 row = *(group_model->append());
1928 row[group_columns.visible] = true;
1929 row[group_columns.text] = (_("-all-"));
1930 row[group_columns.group] = 0;
1934 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1936 _group_tabs->set_dirty ();
1937 _in_group_rebuild_or_clear = false;
1941 Mixer_UI::new_route_group ()
1943 _group_tabs->run_new_group_dialog (0, false);
1947 Mixer_UI::remove_selected_route_group ()
1949 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1950 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1956 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1959 /* selection mode is single, so rows.begin() is it */
1961 if ((iter = group_model->get_iter (*i))) {
1963 RouteGroup* rg = (*iter)[group_columns.group];
1966 _session->remove_route_group (*rg);
1972 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1974 if (in_group_row_change) {
1978 /* force an update of any mixer strips that are using this group,
1979 otherwise mix group names don't change in mixer strips
1982 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1983 if ((*i)->route_group() == group) {
1984 (*i)->route_group_changed();
1988 TreeModel::iterator i;
1989 TreeModel::Children rows = group_model->children();
1990 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1992 in_group_row_change = true;
1994 for (i = rows.begin(); i != rows.end(); ++i) {
1995 if ((*i)[group_columns.group] == group) {
1996 (*i)[group_columns.visible] = !group->is_hidden ();
1997 (*i)[group_columns.text] = group->name ();
2002 in_group_row_change = false;
2004 if (change.contains (Properties::name)) {
2005 _group_tabs->set_dirty ();
2008 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
2009 if ((*j)->route_group() == group) {
2010 if (group->is_hidden ()) {
2020 Mixer_UI::toggle_mixer_list ()
2022 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2023 showhide_mixer_list (act->get_active());
2027 Mixer_UI::showhide_mixer_list (bool yn)
2030 list_vpacker.show ();
2032 list_vpacker.hide ();
2037 Mixer_UI::toggle_monitor_section ()
2039 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2040 showhide_monitor_section (act->get_active());
2045 Mixer_UI::showhide_monitor_section (bool yn)
2047 if (monitor_section().tearoff().torn_off()) {
2052 monitor_section().tearoff().show();
2054 monitor_section().tearoff().hide();
2059 Mixer_UI::toggle_vcas ()
2061 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2062 showhide_vcas (act->get_active());
2066 Mixer_UI::showhide_vcas (bool yn)
2077 Mixer_UI::toggle_mixbuses ()
2079 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2080 showhide_mixbuses (act->get_active());
2084 Mixer_UI::showhide_mixbuses (bool on)
2096 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
2101 if ((iter = group_model->get_iter (path))) {
2103 if ((group = (*iter)[group_columns.group]) == 0) {
2107 if (new_text != group->name()) {
2108 group->set_name (new_text);
2114 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
2118 if (in_group_row_change) {
2122 if ((group = (*iter)[group_columns.group]) == 0) {
2126 std::string name = (*iter)[group_columns.text];
2128 if (name != group->name()) {
2129 group->set_name (name);
2132 bool hidden = !(*iter)[group_columns.visible];
2134 if (hidden != group->is_hidden ()) {
2135 group->set_hidden (hidden, this);
2139 /** Called when a group model row is deleted, but also when the model is
2140 * reordered by a user drag-and-drop; the latter is what we are
2141 * interested in here.
2144 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
2146 if (_in_group_rebuild_or_clear) {
2150 /* Re-write the session's route group list so that the new order is preserved */
2152 list<RouteGroup*> new_list;
2154 Gtk::TreeModel::Children children = group_model->children();
2155 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
2156 RouteGroup* g = (*i)[group_columns.group];
2158 new_list.push_back (g);
2162 _session->reorder_route_groups (new_list);
2167 Mixer_UI::add_route_group (RouteGroup* group)
2169 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
2172 in_group_row_change = true;
2174 TreeModel::Row row = *(group_model->append());
2175 row[group_columns.visible] = !group->is_hidden ();
2176 row[group_columns.group] = group;
2177 if (!group->name().empty()) {
2178 row[group_columns.text] = group->name();
2180 row[group_columns.text] = _("unnamed");
2184 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
2187 TreeViewColumn* col = group_display.get_column (0);
2188 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
2189 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
2192 _group_tabs->set_dirty ();
2194 in_group_row_change = false;
2198 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
2200 using namespace Menu_Helpers;
2202 if (Keyboard::is_context_menu_event (ev)) {
2203 ARDOUR_UI::instance()->add_route ();
2211 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
2213 if (data.get_target() != "PluginFavoritePtr") {
2214 context->drag_finish (false, false, time);
2218 const void * d = data.get_data();
2219 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2221 PluginPresetList nfos;
2223 tv->get_object_drag_data (nfos, &source);
2225 Route::ProcessorList pl;
2228 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2229 PluginPresetPtr ppp = (*i);
2230 PluginInfoPtr pip = ppp->_pip;
2231 if (!pip->is_instrument ()) {
2234 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);
2238 context->drag_finish (ok, false, time);
2242 Mixer_UI::set_strip_width (Width w, bool save)
2246 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2247 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2252 struct PluginStateSorter {
2254 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2255 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2256 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2257 if (aiter != _user.end() && biter != _user.end()) {
2258 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2260 if (aiter != _user.end()) {
2263 if (biter != _user.end()) {
2266 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2269 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2271 std::list<std::string> _user;
2275 Mixer_UI::set_state (const XMLNode& node, int version)
2279 Tabbable::set_state (node, version);
2281 if (node.get_property ("narrow-strips", yn)) {
2283 set_strip_width (Narrow);
2285 set_strip_width (Wide);
2289 node.get_property ("show-mixer", _visible);
2292 node.get_property ("maximised", yn);
2294 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Common"), X_("ToggleMaximalMixer"));
2295 bool fs = act && act->get_active();
2297 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2302 node.get_property ("show-mixer-list", yn);
2304 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixerList"));
2305 /* do it twice to force the change */
2306 act->set_active (!yn);
2307 act->set_active (yn);
2311 node.get_property ("monitor-section-visible", yn);
2313 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection"));
2314 /* do it twice to force the change */
2315 act->set_active (!yn);
2316 act->set_active (yn);
2320 node.get_property ("show-vca-pane", yn);
2322 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleVCAPane"));
2323 /* do it twice to force the change */
2324 act->set_active (!yn);
2325 act->set_active (yn);
2330 node.get_property ("show-mixbus-pane", yn);
2332 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixbusPane"));
2333 /* do it twice to force the change */
2334 act->set_active (!yn);
2335 act->set_active (yn);
2339 //check for the user's plugin_order file
2340 XMLNode plugin_order_new(X_("PO"));
2341 if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) {
2342 store_current_favorite_order ();
2343 std::list<string> order;
2344 const XMLNodeList& kids = plugin_order_new.children("PluginInfo");
2345 XMLNodeConstIterator i;
2346 for (i = kids.begin(); i != kids.end(); ++i) {
2347 std::string unique_id;
2348 if ((*i)->get_property ("unique-id", unique_id)) {
2349 order.push_back (unique_id);
2350 if ((*i)->get_property ("expanded", yn)) {
2351 favorite_ui_state[unique_id] = yn;
2355 PluginStateSorter cmp (order);
2356 favorite_order.sort (cmp);
2357 sync_treeview_from_favorite_order ();
2360 //if there is no user file, then use an existing one from instant.xml
2361 //NOTE: if you are loading an old session, this might come from the session's instant.xml
2362 //Todo: in the next major version, we should probably stop doing the instant.xml check, and just use the new file
2363 XMLNode* plugin_order;
2364 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2365 store_current_favorite_order ();
2366 std::list<string> order;
2367 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2368 XMLNodeConstIterator i;
2369 for (i = kids.begin(); i != kids.end(); ++i) {
2370 std::string unique_id;
2371 if ((*i)->get_property ("unique-id", unique_id)) {
2372 order.push_back (unique_id);
2373 if ((*i)->get_property ("expanded", yn)) {
2374 favorite_ui_state[unique_id] = yn;
2379 PluginStateSorter cmp (order);
2380 favorite_order.sort (cmp);
2381 sync_treeview_from_favorite_order ();
2389 Mixer_UI::save_plugin_order_file ()
2391 //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order )
2393 //NOTE: this replaces the old code that stores info in instant.xml
2394 //why? because instant.xml prefers the per-session settings, and we want this to be a global pref
2396 store_current_favorite_order ();
2397 XMLNode plugin_order ("PluginOrder");
2399 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2400 XMLNode* p = new XMLNode ("PluginInfo");
2401 p->set_property ("sort", cnt);
2402 p->set_property ("unique-id", (*i)->unique_id);
2403 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2404 p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2406 plugin_order.add_child_nocopy (*p);
2408 PluginManager::instance().save_plugin_order_file( plugin_order );
2412 Mixer_UI::get_state ()
2414 XMLNode* node = new XMLNode (X_("Mixer"));
2416 node->add_child_nocopy (Tabbable::get_state());
2418 node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider());
2419 node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider());
2420 node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider());
2421 node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider());
2423 node->set_property ("narrow-strips", (_strip_width == Narrow));
2424 node->set_property ("show-mixer", _visible);
2425 node->set_property ("maximised", _maximised);
2427 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2428 node->set_property ("show-mixer-list", act->get_active ());
2430 act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2431 node->set_property ("monitor-section-visible", act->get_active ());
2433 act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2434 node->set_property ("show-vca-pane", act->get_active ());
2437 act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2438 node->set_property ("show-mixbus-pane", act->get_active ());
2445 Mixer_UI::scroll_left ()
2447 if (!scroller.get_hscrollbar()) return;
2448 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2449 int sc_w = scroller.get_width();
2450 int sp_w = strip_packer.get_width();
2454 int lp = adj->get_value();
2456 using namespace Gtk::Box_Helpers;
2457 const BoxList& strips = strip_packer.children();
2458 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2459 if (i->get_widget() == & add_button) {
2463 if (i->get_widget() == &mb_shadow) {
2467 lm += i->get_widget()->get_width ();
2469 lm -= i->get_widget()->get_width ();
2473 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2477 Mixer_UI::scroll_right ()
2479 if (!scroller.get_hscrollbar()) return;
2480 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2481 int sc_w = scroller.get_width();
2482 int sp_w = strip_packer.get_width();
2486 int lp = adj->get_value();
2488 using namespace Gtk::Box_Helpers;
2489 const BoxList& strips = strip_packer.children();
2490 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2491 if (i->get_widget() == & add_button) {
2495 if (i->get_widget() == &mb_shadow) {
2499 lm += i->get_widget()->get_width ();
2504 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2508 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2510 switch (ev->direction) {
2511 case GDK_SCROLL_LEFT:
2515 if (ev->state & Keyboard::TertiaryModifier) {
2521 case GDK_SCROLL_RIGHT:
2525 case GDK_SCROLL_DOWN:
2526 if (ev->state & Keyboard::TertiaryModifier) {
2537 Mixer_UI::vca_scroll_left ()
2539 if (!vca_scroller.get_hscrollbar()) return;
2540 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2541 int sc_w = vca_scroller.get_width();
2542 int sp_w = strip_packer.get_width();
2546 int lp = adj->get_value();
2548 using namespace Gtk::Box_Helpers;
2549 const BoxList& strips = vca_hpacker.children();
2550 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2551 if (i->get_widget() == &add_vca_button) {
2554 lm += i->get_widget()->get_width ();
2556 lm -= i->get_widget()->get_width ();
2560 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2564 Mixer_UI::vca_scroll_right ()
2566 if (!vca_scroller.get_hscrollbar()) return;
2567 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2568 int sc_w = vca_scroller.get_width();
2569 int sp_w = strip_packer.get_width();
2573 int lp = adj->get_value();
2575 using namespace Gtk::Box_Helpers;
2576 const BoxList& strips = vca_hpacker.children();
2577 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2578 if (i->get_widget() == &add_vca_button) {
2581 lm += i->get_widget()->get_width ();
2586 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2590 Mixer_UI::on_vca_scroll_event (GdkEventScroll* ev)
2592 switch (ev->direction) {
2593 case GDK_SCROLL_LEFT:
2597 if (ev->state & Keyboard::TertiaryModifier) {
2603 case GDK_SCROLL_RIGHT:
2604 vca_scroll_right ();
2607 case GDK_SCROLL_DOWN:
2608 if (ev->state & Keyboard::TertiaryModifier) {
2609 vca_scroll_right ();
2619 Mixer_UI::parameter_changed (string const & p)
2621 if (p == "show-group-tabs") {
2622 bool const s = _session->config.get_show_group_tabs ();
2624 _group_tabs->show ();
2626 _group_tabs->hide ();
2628 } else if (p == "default-narrow_ms") {
2629 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2630 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2631 (*i)->set_width_enum (s ? Narrow : Wide, this);
2637 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2639 g->set_active (a, this);
2643 Mixer_UI::plugin_selector()
2645 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2646 if (!_plugin_selector)
2647 _plugin_selector = new PluginSelector (PluginManager::instance());
2650 return _plugin_selector;
2654 Mixer_UI::setup_track_display ()
2656 track_model = ListStore::create (stripable_columns);
2657 track_display.set_model (track_model);
2658 track_display.append_column (_("Show"), stripable_columns.visible);
2659 track_display.append_column (_("Strips"), stripable_columns.text);
2660 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2661 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2662 track_display.get_column (0)->set_expand(false);
2663 track_display.get_column (1)->set_expand(true);
2664 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2665 track_display.set_name (X_("EditGroupList"));
2666 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2667 track_display.set_reorderable (true);
2668 track_display.set_headers_visible (true);
2669 track_display.set_can_focus(false);
2671 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2672 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2674 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2675 track_list_visible_cell->property_activatable() = true;
2676 track_list_visible_cell->property_radio() = false;
2677 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2679 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2681 track_display_scroller.add (track_display);
2682 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2684 VBox* v = manage (new VBox);
2686 v->pack_start (track_display_scroller, true, true);
2688 track_display_frame.set_name("BaseFrame");
2689 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2690 track_display_frame.add (*v);
2692 track_display_scroller.show();
2693 track_display_frame.show();
2694 track_display.show();
2698 Mixer_UI::new_track_or_bus ()
2700 ARDOUR_UI::instance()->add_route ();
2704 Mixer_UI::update_title ()
2706 if (!own_window()) {
2713 if (_session->snap_name() != _session->name()) {
2714 n = _session->snap_name ();
2716 n = _session->name ();
2719 if (_session->dirty ()) {
2723 WindowTitle title (n);
2724 title += S_("Window|Mixer");
2725 title += Glib::get_application_name ();
2726 own_window()->set_title (title.get_string());
2730 WindowTitle title (S_("Window|Mixer"));
2731 title += Glib::get_application_name ();
2732 own_window()->set_title (title.get_string());
2737 Mixer_UI::strip_by_x (int x)
2739 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2742 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2743 x2 = x1 + (*i)->get_width();
2745 if (x >= x1 && x <= x2) {
2754 Mixer_UI::set_axis_targets_for_operation ()
2756 _axis_targets.clear ();
2758 if (!_selection.empty()) {
2759 _axis_targets = _selection.axes;
2763 // removed "implicit" selections of strips, after discussion on IRC
2768 Mixer_UI::monitor_section_going_away ()
2770 XMLNode* ui_node = Config->extra_xml(X_("UI"));
2772 /* immediate state save.
2774 * Tearoff settings are otherwise only stored during
2775 * save_ardour_state(). The mon-section may or may not
2776 * exist at that point.
2780 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
2782 tearoff_node->remove_nodes_and_delete (X_("monitor-section"));
2783 XMLNode* t = new XMLNode (X_("monitor-section"));
2784 _monitor_section.tearoff().add_state (*t);
2785 tearoff_node->add_child_nocopy (*t);
2789 monitor_section_detached ();
2790 out_packer.remove (_monitor_section.tearoff());
2794 Mixer_UI::toggle_midi_input_active (bool flip_others)
2796 boost::shared_ptr<RouteList> rl (new RouteList);
2799 set_axis_targets_for_operation ();
2801 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2802 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2806 onoff = !mt->input_active();
2810 _session->set_exclusive_input_active (rl, onoff, flip_others);
2814 Mixer_UI::maximise_mixer_space ()
2816 if (!own_window()) {
2824 _window->fullscreen ();
2829 Mixer_UI::restore_mixer_space ()
2831 if (!own_window()) {
2839 own_window()->unfullscreen();
2844 Mixer_UI::monitor_section_attached ()
2846 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2847 act->set_sensitive (true);
2848 showhide_monitor_section (act->get_active ());
2852 Mixer_UI::monitor_section_detached ()
2854 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleMonitorSection");
2855 act->set_sensitive (false);
2859 Mixer_UI::store_current_favorite_order ()
2861 typedef Gtk::TreeModel::Children type_children;
2862 type_children children = favorite_plugins_model->children();
2863 favorite_order.clear();
2864 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2866 Gtk::TreeModel::Row row = *iter;
2867 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2868 favorite_order.push_back (ppp->_pip);
2869 std::string name = row[favorite_plugins_columns.name];
2870 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2875 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2877 Gtk::TreeModel::Row row = *iter;
2878 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2880 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2884 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2886 PluginManager& manager (PluginManager::instance());
2887 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2889 /* not a Favorite? skip it */
2890 if (manager.get_status (*i) != PluginManager::Favorite) {
2894 /* Check the tag combo selection, and skip this plugin if it doesn't match the selected tag(s) */
2895 string test = favorite_plugins_tag_combo.get_active_text();
2896 if (test != _("Show All")) {
2897 vector<string> tags = manager.get_tags(*i);
2899 //does the selected tag match any of the tags in the plugin?
2900 vector<string>::iterator tt = find (tags.begin(), tags.end(), test);
2901 if (tt == tags.end()) {
2906 result.push_back (*i);
2910 struct PluginCustomSorter {
2912 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2913 PluginInfoList::const_iterator aiter = _user.begin();
2914 PluginInfoList::const_iterator biter = _user.begin();
2915 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2916 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2918 if (aiter != _user.end() && biter != _user.end()) {
2919 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2921 if (aiter != _user.end()) {
2924 if (biter != _user.end()) {
2927 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2929 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2931 PluginInfoList _user;
2935 Mixer_UI::refill_favorite_plugins ()
2937 PluginInfoList plugs;
2938 PluginManager& mgr (PluginManager::instance());
2941 refiller (plugs, mgr.lv2_plugin_info ());
2943 #ifdef WINDOWS_VST_SUPPORT
2944 refiller (plugs, mgr.windows_vst_plugin_info ());
2946 #ifdef LXVST_SUPPORT
2947 refiller (plugs, mgr.lxvst_plugin_info ());
2949 #ifdef MACVST_SUPPORT
2950 refiller (plugs, mgr.mac_vst_plugin_info ());
2952 #ifdef AUDIOUNIT_SUPPORT
2953 refiller (plugs, mgr.au_plugin_info ());
2955 refiller (plugs, mgr.ladspa_plugin_info ());
2956 refiller (plugs, mgr.lua_plugin_info ());
2958 store_current_favorite_order ();
2960 PluginCustomSorter cmp (favorite_order);
2963 favorite_order = plugs;
2965 sync_treeview_from_favorite_order ();
2969 Mixer_UI::plugin_list_changed ()
2971 refill_favorite_plugins();
2976 Mixer_UI::refill_tag_combo ()
2978 PluginManager& mgr (PluginManager::instance());
2980 std::vector<std::string> tags = mgr.get_all_tags (PluginManager::OnlyFavorites);
2982 favorite_plugins_tag_combo.clear();
2983 favorite_plugins_tag_combo.append_text (_("Show All"));
2985 for (vector<string>::iterator t = tags.begin (); t != tags.end (); ++t) {
2986 favorite_plugins_tag_combo.append_text (*t);
2989 favorite_plugins_tag_combo.set_active_text (_("Show All"));
2993 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2996 if (!(iter = favorite_plugins_model->get_iter (path))) {
2999 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3003 PluginInfoPtr pip = ppp->_pip;
3004 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3005 if (favorite_ui_state[pip->unique_id]) {
3006 favorite_plugins_display.expand_row (path, true);
3012 Mixer_UI::sync_treeview_from_favorite_order ()
3014 favorite_plugins_model->clear ();
3015 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
3016 PluginInfoPtr pip = (*i);
3018 TreeModel::Row newrow = *(favorite_plugins_model->append());
3019 newrow[favorite_plugins_columns.name] = (*i)->name;
3020 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
3025 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
3026 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
3030 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
3031 child_row[favorite_plugins_columns.name] = (*j).label;
3032 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
3034 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
3035 if (favorite_ui_state[pip->unique_id]) {
3036 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
3043 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
3045 using namespace Gtk::Menu_Helpers;
3047 Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu ();
3048 MenuList& items = m->items ();
3050 if (_selection.axes.empty()) {
3051 items.push_back (MenuElem (_("No Track/Bus is selected.")));
3053 items.push_back (MenuElem (_("Add at the top"),
3054 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
3055 items.push_back (MenuElem (_("Add Pre-Fader"),
3056 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
3057 items.push_back (MenuElem (_("Add Post-Fader"),
3058 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
3059 items.push_back (MenuElem (_("Add at the end"),
3060 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
3063 items.push_back (SeparatorElem());
3065 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
3067 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3068 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
3069 // we cannot currently delete AU presets
3070 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
3071 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
3075 m->popup (ev->button, ev->time);
3079 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
3081 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
3082 TreeModel::Path path;
3083 TreeViewColumn* column;
3085 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
3086 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3088 selection->unselect_all();
3089 selection->select(path);
3092 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3094 popup_note_context_menu (ev);
3102 Mixer_UI::selected_plugin ()
3104 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3106 return PluginPresetPtr();
3108 Gtk::TreeModel::iterator iter = selection->get_selected();
3110 return PluginPresetPtr();
3112 return (*iter)[favorite_plugins_columns.plugin];
3116 Mixer_UI::add_selected_processor (ProcessorPosition pos)
3118 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3120 add_favorite_processor (ppp, pos);
3125 Mixer_UI::delete_selected_preset ()
3130 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3131 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
3134 PluginPtr plugin = ppp->_pip->load (*_session);
3135 plugin->get_presets();
3136 plugin->remove_preset (ppp->_preset.label);
3140 Mixer_UI::remove_selected_from_favorites ()
3142 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3146 PluginManager::PluginStatusType status = PluginManager::Normal;
3147 PluginManager& manager (PluginManager::instance());
3149 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3150 manager.save_statuses ();
3154 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
3157 if (!(iter = favorite_plugins_model->get_iter (path))) {
3160 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3161 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
3165 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
3167 if (!_session || _selection.axes.empty()) {
3171 PluginInfoPtr pip = ppp->_pip;
3172 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
3173 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
3179 PluginPtr p = pip->load (*_session);
3185 if (ppp->_preset.valid) {
3186 p->load_preset (ppp->_preset);
3189 Route::ProcessorStreams err;
3190 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
3194 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
3197 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
3204 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
3208 if (!np->display_to_user()) {
3211 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
3212 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
3217 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
3221 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
3228 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
3230 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
3234 // only allow to re-order top-level items
3236 if (TreePath::get_from_selection_data (data, src)) {
3237 if (src.up() && src.up()) {
3242 // don't allow to drop as child-rows.
3243 Gtk::TreeModel::Path _dest = dest; // un const
3244 const bool is_child = _dest.up (); // explicit bool for clang
3245 if (!is_child || _dest.empty ()) {
3252 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
3254 if (data.get_target() != "PluginPresetPtr") {
3257 if (data.get_length() != sizeof (PluginPresetPtr)) {
3260 const void *d = data.get_data();
3261 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
3263 PluginManager::PluginStatusType status = PluginManager::Favorite;
3264 PluginManager& manager (PluginManager::instance());
3266 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3267 manager.save_statuses ();
3271 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
3273 /* call protected MixerActor:: method */
3278 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
3280 /* call protected MixerActor:: method */
3285 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
3287 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
3290 show_spill_change (s); /* EMIT SIGNAL */
3292 _group_tabs->hide ();
3294 _group_tabs->show ();
3296 redisplay_track_list ();
3301 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
3303 return s == spilled_strip.lock();
3307 Mixer_UI::register_actions ()
3309 Glib::RefPtr<ActionGroup> group = ActionManager::create_action_group (bindings, X_("Mixer"));
3311 ActionManager::register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
3312 ActionManager::register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
3313 ActionManager::register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
3314 ActionManager::register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
3315 ActionManager::register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
3316 ActionManager::register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
3319 ActionManager::register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
3320 ActionManager::register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
3321 ActionManager::register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
3322 ActionManager::register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
3323 ActionManager::register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
3324 ActionManager::register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
3325 ActionManager::register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
3326 ActionManager::register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
3328 ActionManager::register_action (group, "select-next-stripable", _("Select Next Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_next_strip));
3329 ActionManager::register_action (group, "select-prev-stripable", _("Scroll Previous Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_prev_strip));
3331 ActionManager::register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
3332 ActionManager::register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
3334 ActionManager::register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
3335 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
3337 ActionManager::register_toggle_action (group, X_("ToggleMixerList"), _("Mixer: Show Mixer List"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixer_list));
3339 ActionManager::register_toggle_action (group, X_("ToggleVCAPane"), _("Mixer: Show VCAs"), sigc::mem_fun (*this, &Mixer_UI::toggle_vcas));
3342 ActionManager::register_toggle_action (group, X_("ToggleMixbusPane"), _("Mixer: Show Mixbusses"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixbuses));
3345 ActionManager::register_toggle_action (group, X_("ToggleMonitorSection"), _("Mixer: Show Monitor Section"), sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_section));
3349 Mixer_UI::load_bindings ()
3351 bindings = Bindings::get_bindings (X_("Mixer"));
3354 template<class T> void
3355 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
3357 boost::shared_ptr<ControlList> cl (new ControlList);
3358 boost::shared_ptr<AutomationControl> ac;
3360 bool have_val = false;
3362 set_axis_targets_for_operation ();
3364 BOOST_FOREACH(AxisView* r, _axis_targets) {
3365 boost::shared_ptr<Stripable> s = r->stripable();
3367 ac = (s.get()->*get_control)();
3371 val = !ac->get_value();
3378 _session->set_controls (cl, val, Controllable::UseGroup);
3382 Mixer_UI::solo_action ()
3384 control_action (&Stripable::solo_control);
3388 Mixer_UI::mute_action ()
3390 control_action (&Stripable::mute_control);
3394 Mixer_UI::rec_enable_action ()
3396 control_action (&Stripable::rec_enable_control);
3399 AutomationControlSet
3400 Mixer_UI::selected_gaincontrols ()
3402 set_axis_targets_for_operation ();
3403 AutomationControlSet rv;
3404 BOOST_FOREACH(AxisView* r, _axis_targets) {
3405 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3407 boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
3408 ControlList cl (ac->grouped_controls());
3409 for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
3419 Mixer_UI::step_gain_up_action ()
3421 AutomationControlSet acs = selected_gaincontrols ();
3422 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3423 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3425 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
3430 Mixer_UI::step_gain_down_action ()
3432 AutomationControlSet acs = selected_gaincontrols ();
3433 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3434 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3436 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
3441 Mixer_UI::unity_gain_action ()
3443 set_axis_targets_for_operation ();
3445 BOOST_FOREACH(AxisView* r, _axis_targets) {
3446 boost::shared_ptr<Stripable> s = r->stripable();
3448 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3450 ac->set_value (1.0, Controllable::UseGroup);
3457 Mixer_UI::copy_processors ()
3459 set_axis_targets_for_operation ();
3461 BOOST_FOREACH(AxisView* r, _axis_targets) {
3462 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3464 ms->copy_processors ();
3469 Mixer_UI::cut_processors ()
3471 set_axis_targets_for_operation ();
3473 BOOST_FOREACH(AxisView* r, _axis_targets) {
3474 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3476 ms->cut_processors ();
3481 Mixer_UI::paste_processors ()
3483 set_axis_targets_for_operation ();
3485 BOOST_FOREACH(AxisView* r, _axis_targets) {
3486 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3488 ms->paste_processors ();
3493 Mixer_UI::select_all_processors ()
3495 set_axis_targets_for_operation ();
3497 BOOST_FOREACH(AxisView* r, _axis_targets) {
3498 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3500 ms->select_all_processors ();
3505 Mixer_UI::toggle_processors ()
3507 set_axis_targets_for_operation ();
3509 BOOST_FOREACH(AxisView* r, _axis_targets) {
3510 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3512 ms->toggle_processors ();
3517 Mixer_UI::ab_plugins ()
3519 set_axis_targets_for_operation ();
3521 BOOST_FOREACH(AxisView* r, _axis_targets) {
3522 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3530 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3532 set_axis_targets_for_operation ();
3533 BOOST_FOREACH(AxisView* r, _axis_targets) {
3534 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3536 ms->vca_assign (vca);
3542 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3544 set_axis_targets_for_operation ();
3545 BOOST_FOREACH(AxisView* r, _axis_targets) {
3546 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3548 ms->vca_unassign (vca);
3554 Mixer_UI::screenshot (std::string const& filename)
3560 int height = strip_packer.get_height();
3561 bool with_vca = vca_vpacker.is_visible ();
3562 MixerStrip* master = strip_by_route (_session->master_out ());
3564 Gtk::OffscreenWindow osw;
3569 /* unpack widgets, add to OffscreenWindow */
3571 strip_group_box.remove (strip_packer);
3572 b.pack_start (strip_packer, false, false);
3573 /* hide extra elements inside strip_packer */
3575 scroller_base.hide ();
3581 /* work around Gtk::ScrolledWindow */
3582 Gtk::Viewport* viewport = (Gtk::Viewport*) vca_scroller.get_child();
3583 viewport->remove (); // << vca_hpacker
3584 b.pack_start (vca_hpacker, false, false);
3585 /* hide some growing widgets */
3586 add_vca_button.hide ();
3587 vca_scroller_base.hide();
3591 out_packer.remove (*master);
3592 b.pack_start (*master, false, false);
3593 master->hide_master_spacer (true);
3596 /* prepare the OffscreenWindow for rendering */
3597 osw.set_size_request (-1, height);
3599 osw.queue_resize ();
3601 osw.get_window()->process_updates (true);
3603 /* create screenshot */
3604 Glib::RefPtr<Gdk::Pixbuf> pb = osw.get_pixbuf ();
3605 pb->save (filename, "png");
3607 /* unpack elements before destorying the Box & OffscreenWindow */
3608 list<Gtk::Widget*> children = b.get_children();
3609 for (list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
3614 /* now re-pack the widgets into the main mixer window */
3616 scroller_base.show ();
3620 strip_group_box.pack_start (strip_packer);
3622 add_vca_button.show ();
3623 vca_scroller_base.show();
3624 vca_scroller.add (vca_hpacker);
3627 master->hide_master_spacer (false);
3628 out_packer.pack_start (*master, false, false);