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"
69 #include "mixer_strip.h"
70 #include "monitor_section.h"
71 #include "plugin_selector.h"
72 #include "public_editor.h"
73 #include "mouse_cursors.h"
74 #include "ardour_ui.h"
76 #include "route_sorter.h"
78 #include "gui_thread.h"
79 #include "mixer_group_tabs.h"
80 #include "route_sorter.h"
82 #include "ui_config.h"
83 #include "vca_master_strip.h"
87 using namespace ARDOUR;
88 using namespace ARDOUR_UI_UTILS;
92 using namespace Gtkmm2ext;
98 Mixer_UI* Mixer_UI::_instance = 0;
101 Mixer_UI::instance ()
104 _instance = new Mixer_UI;
110 Mixer_UI::Mixer_UI ()
111 : Tabbable (_content, _("Mixer"))
112 , no_track_list_redisplay (false)
113 , in_group_row_change (false)
115 , _plugin_selector (0)
116 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
117 , _spill_scroll_position (0)
118 , ignore_reorder (false)
119 , _in_group_rebuild_or_clear (false)
120 , _route_deletion_in_progress (false)
122 , _strip_selection_change_without_scroll (false)
123 , _selection (*this, *this)
127 _content.set_data ("ardour-bindings", bindings);
129 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
131 scroller.set_can_default (true);
132 // set_default (scroller);
134 scroller_base.set_flags (Gtk::CAN_FOCUS);
135 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
136 scroller_base.set_name ("MixerWindow");
137 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
139 /* set up drag-n-drop */
140 vector<TargetEntry> target_table;
141 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
142 scroller_base.drag_dest_set (target_table);
143 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
145 /* create a button to add VCA strips ... will get packed in redisplay_track_list() */
146 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
148 add_vca_button.add (*w);
149 add_vca_button.set_can_focus(false);
150 add_vca_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
152 /* create a button to add mixer strips */
153 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
156 add_button.set_can_focus(false);
157 add_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
159 /* add as last item of strip packer */
160 strip_packer.pack_end (scroller_base, true, true);
161 strip_packer.pack_end (add_button, false, false);
164 /* create a drop-shadow at the end of the mixer strips */
165 mb_shadow.set_size_request( 4, -1 );
166 mb_shadow.set_name("EditorWindow");
168 strip_packer.pack_end (mb_shadow, false, false);
171 _group_tabs = new MixerGroupTabs (this);
172 strip_group_box.set_spacing (0);
173 strip_group_box.set_border_width (0);
174 strip_group_box.pack_start (*_group_tabs, PACK_SHRINK);
175 strip_group_box.pack_start (strip_packer);
176 strip_group_box.show_all ();
177 strip_group_box.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
179 scroller.add (strip_group_box);
180 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
182 setup_track_display ();
184 group_model = ListStore::create (group_columns);
185 group_display.set_model (group_model);
186 group_display.append_column (_("Show"), group_columns.visible);
187 group_display.append_column (_("Group"), group_columns.text);
188 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
189 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
190 group_display.get_column (0)->set_expand(false);
191 group_display.get_column (1)->set_expand(true);
192 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
193 group_display.set_name ("EditGroupList");
194 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
195 group_display.set_reorderable (true);
196 group_display.set_headers_visible (true);
197 group_display.set_rules_hint (true);
198 group_display.set_can_focus(false);
200 /* name is directly editable */
202 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
203 name_cell->property_editable() = true;
204 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
206 /* use checkbox for the active column */
208 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
209 active_cell->property_activatable() = true;
210 active_cell->property_radio() = false;
212 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
213 /* We use this to notice drag-and-drop reorders of the group list */
214 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
215 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
217 group_display_scroller.add (group_display);
218 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
221 group_display_vbox.pack_start (group_display_scroller, true, true);
223 group_display_frame.set_name ("BaseFrame");
224 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
225 group_display_frame.add (group_display_vbox);
227 list<TargetEntry> target_list;
228 target_list.push_back (TargetEntry ("PluginPresetPtr"));
230 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
231 favorite_plugins_display.set_model (favorite_plugins_model);
232 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
233 favorite_plugins_display.set_name ("EditGroupList");
234 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
235 favorite_plugins_display.set_reorderable (false);
236 favorite_plugins_display.set_headers_visible (true);
237 favorite_plugins_display.set_rules_hint (true);
238 favorite_plugins_display.set_can_focus (false);
239 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
240 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
241 favorite_plugins_display.add_drop_targets (target_list);
242 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
243 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
244 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
245 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
246 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
247 if (UIConfiguration::instance().get_use_tooltips()) {
248 favorite_plugins_display.set_tooltip_column (0);
250 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
252 favorite_plugins_scroller.add (favorite_plugins_display);
253 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
255 favorite_plugins_frame.set_name ("BaseFrame");
256 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
257 favorite_plugins_frame.add (favorite_plugins_vbox);
259 favorite_plugins_vbox.pack_start (favorite_plugins_scroller, true, true);
260 favorite_plugins_vbox.pack_start (favorite_plugins_tag_combo, false, false);
261 favorite_plugins_tag_combo.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::tag_combo_changed));
263 rhs_pane1.add (favorite_plugins_frame);
264 rhs_pane1.add (track_display_frame);
266 rhs_pane2.add (rhs_pane1);
267 rhs_pane2.add (group_display_frame);
269 list_vpacker.pack_start (rhs_pane2, true, true);
271 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
272 vca_vpacker.pack_start (vca_label_bar, false, false);
274 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
275 vca_scroller_base.set_name (X_("MixerWindow"));
276 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
278 vca_hpacker.signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_vca_scroll_event), false);
279 vca_scroller.add (vca_hpacker);
280 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
281 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
283 vca_vpacker.pack_start (vca_scroller, true, true);
285 inner_pane.add (scroller);
286 inner_pane.add (vca_vpacker);
288 global_hpacker.pack_start (inner_pane, true, true);
289 global_hpacker.pack_start (out_packer, false, false);
291 list_hpane.set_check_divider_position (true);
292 list_hpane.add (list_vpacker);
293 list_hpane.add (global_hpacker);
294 list_hpane.set_child_minsize (list_vpacker, 30);
296 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
299 if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) {
302 rhs_pane1.set_divider (0, fract);
304 if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
307 rhs_pane2.set_divider (0, fract);
309 if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
312 list_hpane.set_divider (0, fract);
314 if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
317 inner_pane.set_divider (0, fract);
319 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
320 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
321 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
322 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
324 _content.pack_start (list_hpane, true, true);
329 _content.set_name ("MixerWindow");
331 global_hpacker.show();
333 scroller_base.show();
334 scroller_hpacker.show();
335 mixer_scroller_vpacker.show();
337 group_display_button_label.show();
338 group_display_scroller.show();
339 favorite_plugins_scroller.show();
340 group_display_vbox.show();
341 group_display_frame.show();
342 favorite_plugins_frame.show();
350 vca_label_bar.show();
352 vca_scroller_base.show();
355 group_display.show();
356 favorite_plugins_display.show();
359 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
361 _monitor_section.tearoff().set_state (*mnode);
364 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
365 VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
369 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
371 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
372 _plugin_selector = new PluginSelector (PluginManager::instance ());
374 #error implement deferred Plugin-Favorite list
377 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
378 PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
379 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
382 Mixer_UI::~Mixer_UI ()
384 monitor_section_detached ();
386 delete _plugin_selector;
390 struct MixerStripSorter {
391 bool operator() (const MixerStrip* ms_a, const MixerStrip* ms_b)
393 boost::shared_ptr<ARDOUR::Stripable> const& a = ms_a->stripable ();
394 boost::shared_ptr<ARDOUR::Stripable> const& b = ms_b->stripable ();
395 return ARDOUR::Stripable::Sorter(true)(a, b);
407 Mixer_UI::tag_combo_changed ()
409 refill_favorite_plugins();
413 Mixer_UI::use_own_window (bool and_fill_it)
415 bool new_window = !own_window();
417 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
419 if (win && new_window) {
420 win->set_name ("MixerWindow");
421 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
422 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
423 win->set_data ("ardour-bindings", bindings);
425 if (!win->get_focus()) {
426 /* set focus widget to something, anything */
427 win->set_focus (scroller);
435 Mixer_UI::show_window ()
437 Tabbable::show_window ();
439 /* show/hide group tabs as required */
440 parameter_changed ("show-group-tabs");
442 /* now reset each strips width so the right widgets are shown */
444 TreeModel::Children rows = track_model->children();
445 TreeModel::Children::iterator ri;
447 for (ri = rows.begin(); ri != rows.end(); ++ri) {
448 AxisView* av = (*ri)[stripable_columns.strip];
449 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
453 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
454 /* Fix visibility of mixer strip stuff */
455 ms->parameter_changed (X_("mixer-element-visibility"));
458 /* force focus into main area */
459 scroller_base.grab_focus ();
463 Mixer_UI::remove_master (VCAMasterStrip* vms)
465 if (_session && _session->deletion_in_progress()) {
466 /* its all being taken care of */
470 TreeModel::Children rows = track_model->children();
471 TreeModel::Children::iterator ri;
473 for (ri = rows.begin(); ri != rows.end(); ++ri) {
474 if ((*ri)[stripable_columns.strip] == vms) {
475 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
476 track_model->erase (ri);
483 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
485 using namespace Menu_Helpers;
487 if (Keyboard::is_context_menu_event (ev)) {
488 ARDOUR_UI::instance()->add_route ();
496 Mixer_UI::new_masters_created ()
498 ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane")->set_active (true);
502 Mixer_UI::add_masters (VCAList& vlist)
506 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
507 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
514 Mixer_UI::add_routes (RouteList& rlist)
518 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
526 Mixer_UI::add_stripables (StripableList& slist)
528 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
529 bool from_scratch = (track_model->children().size() == 0);
530 uint32_t nroutes = 0;
532 slist.sort (Stripable::Sorter());
534 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
535 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
543 // XXX what does this special case do?
544 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
553 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
555 track_display.set_model (Glib::RefPtr<ListStore>());
557 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
559 boost::shared_ptr<Route> route;
560 boost::shared_ptr<VCA> vca;
562 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
564 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
566 TreeModel::Row row = *(track_model->append());
568 row[stripable_columns.text] = vca->name();
569 row[stripable_columns.visible] = vms->marked_for_display ();
570 row[stripable_columns.strip] = vms;
571 row[stripable_columns.stripable] = vca;
573 vms->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::vca_button_release_event), vms));
575 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
577 if (route->is_auditioner()) {
581 if (route->is_monitor()) {
583 out_packer.pack_end (_monitor_section.tearoff(), false, false);
584 _monitor_section.set_session (_session);
585 _monitor_section.tearoff().show_all ();
587 _monitor_section.tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
588 _monitor_section.tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
590 if (_monitor_section.tearoff().torn_off()) {
591 monitor_section_detached ();
593 monitor_section_attached ();
596 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
598 /* no regular strip shown for control out */
603 strip = new MixerStrip (*this, _session, route);
604 strips.push_back (strip);
606 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
608 if (strip->width_owner() != strip) {
609 strip->set_width_enum (_strip_width, this);
614 if (route->is_master()) {
616 out_packer.pack_start (*strip, false, false);
617 strip->set_packed (true);
621 TreeModel::Row row = *(track_model->insert (insert_iter));
623 row[stripable_columns.text] = route->name();
624 row[stripable_columns.visible] = strip->marked_for_display();
625 row[stripable_columns.stripable] = route;
626 row[stripable_columns.strip] = strip;
629 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
630 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
633 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
634 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
637 } catch (const std::exception& e) {
638 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
641 track_display.set_model (track_model);
643 /* catch up on selection state, which we left to the editor to set */
644 sync_treeview_from_presentation_info (PropertyChange (Properties::selected));
647 sync_presentation_info_from_treeview ();
650 redisplay_track_list ();
654 Mixer_UI::deselect_all_strip_processors ()
656 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
657 (*i)->deselect_all_processors();
662 Mixer_UI::select_none ()
664 _selection.clear_routes();
665 deselect_all_strip_processors();
669 Mixer_UI::select_next_strip ()
671 deselect_all_strip_processors();
672 _session->selection().select_next_stripable (true, false);
676 Mixer_UI::select_prev_strip ()
678 deselect_all_strip_processors();
679 _session->selection().select_prev_stripable (true, false);
683 Mixer_UI::delete_processors ()
685 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
686 (*i)->delete_processors();
692 Mixer_UI::remove_strip (MixerStrip* strip)
694 if (_session && _session->deletion_in_progress()) {
695 /* its all being taken care of */
699 TreeModel::Children rows = track_model->children();
700 TreeModel::Children::iterator ri;
701 list<MixerStrip *>::iterator i;
703 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
707 PBD::Unwinder<bool> uwi (ignore_reorder, true);
709 for (ri = rows.begin(); ri != rows.end(); ++ri) {
710 if ((*ri)[stripable_columns.strip] == strip) {
711 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
712 track_model->erase (ri);
719 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
721 if (what_changed.contains (Properties::selected)) {
722 _selection.presentation_info_changed (what_changed);
726 soh.add (Properties::selected);
727 soh.add (Properties::order);
728 soh.add (Properties::hidden);
730 if (what_changed.contains (soh)) {
731 sync_treeview_from_presentation_info (what_changed);
736 Mixer_UI::sync_presentation_info_from_treeview ()
738 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
742 TreeModel::Children rows = track_model->children();
748 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
750 TreeModel::Children::iterator ri;
753 PresentationInfo::order_t master_key = _session->master_order_key ();
754 PresentationInfo::order_t order = 0;
756 PresentationInfo::ChangeSuspender cs;
758 for (ri = rows.begin(); ri != rows.end(); ++ri) {
759 bool visible = (*ri)[stripable_columns.visible];
760 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
762 #ifndef NDEBUG // these should not exist in the mixer's treeview
767 if (stripable->is_monitor() || stripable->is_auditioner()) {
771 if (stripable->is_master()) {
777 stripable->presentation_info().set_hidden (!visible);
779 // leave master where it is.
780 if (order == master_key) {
784 if (order != stripable->presentation_info().order()) {
785 stripable->set_presentation_order (order);
791 change |= _session->ensure_stripable_sort_order ();
794 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
795 _session->set_dirty();
800 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
802 if (!_session || _session->deletion_in_progress()) {
806 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
808 /* we could get here after either a change in the Mixer or Editor sort
809 * order, but either way, the mixer order keys reflect the intended
810 * order for the GUI, so reorder the treeview model to match it.
813 vector<int> neworder;
814 TreeModel::Children rows = track_model->children();
815 uint32_t old_order = 0;
816 bool changed = false;
822 TreeOrderKeys sorted;
823 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
824 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
825 sorted.push_back (TreeOrderKey (old_order, stripable));
828 TreeOrderKeySorter cmp;
830 sort (sorted.begin(), sorted.end(), cmp);
831 neworder.assign (sorted.size(), 0);
835 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
837 neworder[n] = sr->old_display_order;
839 if (sr->old_display_order != n) {
845 Unwinder<bool> uw (ignore_reorder, true);
846 track_model->reorder (neworder);
849 if (what_changed.contains (Properties::selected)) {
851 PresentationInfo::ChangeSuspender cs;
853 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
854 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
855 if (stripable && stripable->is_selected()) {
858 _selection.remove (*i);
862 if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) {
863 move_stripable_into_view ((*_selection.axes.begin())->stripable());
866 TreeModel::Children rows = track_model->children();
867 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
868 AxisView* av = (*i)[stripable_columns.strip];
869 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
873 if (vms->vca() && vms->vca()->is_selected()) {
874 _selection.add (vms);
876 _selection.remove (vms);
881 redisplay_track_list ();
886 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
888 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
889 if ((*i)->route() == r) {
898 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
900 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
901 if ((*i)->stripable() == s) {
910 Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
912 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
913 if ((*i)->stripable() == s) {
918 TreeModel::Children rows = track_model->children();
919 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
920 AxisView* av = (*i)[stripable_columns.strip];
921 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
922 if (vms && vms->stripable () == s) {
931 Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
933 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
934 if ((*i)->control() == c) {
943 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
945 /* Selecting a mixer-strip may also select grouped-tracks, and
946 * presentation_info_changed() being emitted and
947 * _selection.axes.begin() is being moved into view. This may
948 * effectively move the track that was clicked-on out of view.
950 * So here only the track that is actually clicked-on is moved into
951 * view (in case it's partially visible)
953 PBD::Unwinder<bool> uw (_strip_selection_change_without_scroll, true);
954 move_stripable_into_view (strip->stripable());
956 if (ev->button == 1) {
957 if (_selection.selected (strip)) {
958 /* primary-click: toggle selection state of strip */
959 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
960 _selection.remove (strip, true);
961 } else if (_selection.axes.size() > 1) {
962 /* de-select others */
963 _selection.set (strip);
965 PublicEditor& pe = PublicEditor::instance();
966 TimeAxisView* tav = pe.time_axis_view_from_stripable (strip->stripable());
968 pe.set_selected_mixer_strip (*tav);
971 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
972 _selection.add (strip, true);
973 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
975 /* extend selection */
977 vector<MixerStrip*> tmp;
978 bool accumulate = false;
979 bool found_another = false;
981 strips.sort (MixerStripSorter());
983 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
988 /* hit clicked strip, start accumulating till we hit the first
997 } else if (_selection.selected (ms)) {
998 /* hit selected strip. if currently accumulating others,
999 we're done. if not accumulating others, start doing so.
1001 found_another = true;
1015 tmp.push_back (strip);
1017 if (found_another) {
1018 PresentationInfo::ChangeSuspender cs;
1019 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
1020 _selection.add (*i, true);
1023 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
1026 _selection.set (strip);
1035 Mixer_UI::vca_button_release_event (GdkEventButton *ev, VCAMasterStrip *strip)
1037 _selection.set (strip);
1042 Mixer_UI::set_session (Session* sess)
1044 SessionHandlePtr::set_session (sess);
1045 _monitor_section.set_session (sess);
1047 if (_plugin_selector) {
1048 _plugin_selector->set_session (_session);
1051 _group_tabs->set_session (sess);
1054 _selection.clear ();
1058 refill_favorite_plugins();
1061 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1062 set_state (*node, 0);
1066 initial_track_display ();
1068 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1069 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1070 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1071 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1072 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1073 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1074 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1076 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1077 _session->vca_manager().VCACreated.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::new_masters_created, this), gui_context());
1079 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1081 route_groups_changed ();
1087 /* catch up on selection state, etc. */
1090 sc.add (Properties::selected);
1091 _selection.presentation_info_changed (sc);
1097 Mixer_UI::session_going_away ()
1099 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1101 _in_group_rebuild_or_clear = true;
1102 group_model->clear ();
1103 _in_group_rebuild_or_clear = false;
1105 _selection.clear ();
1106 track_model->clear ();
1108 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1112 _monitor_section.tearoff().hide_visible ();
1114 monitor_section_detached ();
1120 SessionHandlePtr::session_going_away ();
1127 Mixer_UI::track_visibility_changed (std::string const & path)
1129 if (_session && _session->deletion_in_progress()) {
1135 if ((iter = track_model->get_iter (path))) {
1137 AxisView* av = (*iter)[stripable_columns.strip];
1138 bool visible = (*iter)[stripable_columns.visible];
1140 if (av->set_marked_for_display (!visible)) {
1141 update_track_visibility ();
1147 Mixer_UI::update_track_visibility ()
1149 TreeModel::Children rows = track_model->children();
1150 TreeModel::Children::iterator i;
1153 Unwinder<bool> uw (no_track_list_redisplay, true);
1155 for (i = rows.begin(); i != rows.end(); ++i) {
1156 AxisView* av = (*i)[stripable_columns.strip];
1157 (*i)[stripable_columns.visible] = av->marked_for_display ();
1160 /* force presentation catch up with visibility changes
1163 sync_presentation_info_from_treeview ();
1166 redisplay_track_list ();
1170 Mixer_UI::show_strip (MixerStrip* ms)
1172 TreeModel::Children rows = track_model->children();
1173 TreeModel::Children::iterator i;
1175 for (i = rows.begin(); i != rows.end(); ++i) {
1177 AxisView* av = (*i)[stripable_columns.strip];
1178 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1180 (*i)[stripable_columns.visible] = true;
1181 av->set_marked_for_display (true);
1182 update_track_visibility ();
1189 Mixer_UI::hide_strip (MixerStrip* ms)
1191 TreeModel::Children rows = track_model->children();
1192 TreeModel::Children::iterator i;
1194 for (i = rows.begin(); i != rows.end(); ++i) {
1196 AxisView* av = (*i)[stripable_columns.strip];
1197 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1199 (*i)[stripable_columns.visible] = false;
1200 av->set_marked_for_display (false);
1201 update_track_visibility ();
1208 Mixer_UI::start_updating ()
1210 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1215 Mixer_UI::stop_updating ()
1217 fast_screen_update_connection.disconnect();
1222 Mixer_UI::fast_update_strips ()
1224 if (_content.is_mapped () && _session) {
1225 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1226 (*i)->fast_update ();
1232 Mixer_UI::set_all_strips_visibility (bool yn)
1234 TreeModel::Children rows = track_model->children();
1235 TreeModel::Children::iterator i;
1238 Unwinder<bool> uw (no_track_list_redisplay, true);
1240 for (i = rows.begin(); i != rows.end(); ++i) {
1242 AxisView* av = (*i)[stripable_columns.strip];
1243 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1249 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1253 (*i)[stripable_columns.visible] = yn;
1257 redisplay_track_list ();
1262 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1264 TreeModel::Children rows = track_model->children();
1265 TreeModel::Children::iterator i;
1268 Unwinder<bool> uw (no_track_list_redisplay, true);
1270 for (i = rows.begin(); i != rows.end(); ++i) {
1272 AxisView* av = (*i)[stripable_columns.strip];
1273 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1279 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1283 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1284 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1288 (*i)[stripable_columns.visible] = yn;
1292 if (at) { /* track */
1293 (*i)[stripable_columns.visible] = yn;
1298 if (!at && !mt) { /* bus */
1299 (*i)[stripable_columns.visible] = yn;
1304 if (mt) { /* midi-track */
1305 (*i)[stripable_columns.visible] = yn;
1312 redisplay_track_list ();
1316 Mixer_UI::hide_all_routes ()
1318 set_all_strips_visibility (false);
1322 Mixer_UI::show_all_routes ()
1324 set_all_strips_visibility (true);
1328 Mixer_UI::show_all_audiobus ()
1330 set_all_audio_midi_visibility (2, true);
1333 Mixer_UI::hide_all_audiobus ()
1335 set_all_audio_midi_visibility (2, false);
1339 Mixer_UI::show_all_audiotracks()
1341 set_all_audio_midi_visibility (1, true);
1344 Mixer_UI::hide_all_audiotracks ()
1346 set_all_audio_midi_visibility (1, false);
1350 Mixer_UI::show_all_miditracks()
1352 set_all_audio_midi_visibility (3, true);
1355 Mixer_UI::hide_all_miditracks ()
1357 set_all_audio_midi_visibility (3, false);
1361 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1363 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1364 sync_presentation_info_from_treeview ();
1368 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1370 /* this happens as the second step of a DnD within the treeview as well
1371 as when a row/route is actually deleted.
1373 if it was a deletion then we have to force a redisplay because
1374 order keys may not have changed.
1377 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1378 sync_presentation_info_from_treeview ();
1380 if (_route_deletion_in_progress) {
1381 redisplay_track_list ();
1386 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1388 TreeModel::Children rows = track_model->children();
1389 std::list<boost::shared_ptr<VCA> > vcas;
1390 vcas.push_back (vca);
1392 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1393 AxisView* av = (*i)[stripable_columns.strip];
1394 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1395 if (vms && vms->vca()->slaved_to (vca)) {
1396 vcas.push_back (vms->vca());
1400 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1402 AxisView* av = (*i)[stripable_columns.strip];
1403 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1404 bool const visible = (*i)[stripable_columns.visible];
1407 /* we're in the middle of changing a row, don't worry */
1411 if (!strip->route()) {
1412 /* non-route element */
1416 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1420 bool slaved = false;
1421 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1422 if (strip->route()->slaved_to (*m)) {
1428 if (slaved && visible) {
1430 if (strip->packed()) {
1431 strip_packer.reorder_child (*strip, -1); /* put at end */
1433 strip_packer.pack_start (*strip, false, false);
1434 strip->set_packed (true);
1439 if (strip->packed()) {
1440 strip_packer.remove (*strip);
1441 strip->set_packed (false);
1448 Mixer_UI::redisplay_track_list ()
1450 if (no_track_list_redisplay) {
1454 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1456 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1458 if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) {
1459 _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value();
1461 spill_redisplay (sv);
1466 TreeModel::Children rows = track_model->children();
1467 TreeModel::Children::iterator i;
1468 uint32_t n_masters = 0;
1470 container_clear (vca_hpacker);
1472 vca_hpacker.pack_end (vca_scroller_base, true, true);
1473 vca_hpacker.pack_end (add_vca_button, false, false);
1475 add_vca_button.show ();
1476 vca_scroller_base.show();
1478 for (i = rows.begin(); i != rows.end(); ++i) {
1480 AxisView* s = (*i)[stripable_columns.strip];
1481 bool const visible = (*i)[stripable_columns.visible];
1482 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1485 /* we're in the middle of changing a row, don't worry */
1489 VCAMasterStrip* vms;
1491 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1493 vca_hpacker.pack_start (*vms, false, false);
1500 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1508 if (strip->packed()) {
1509 strip_packer.reorder_child (*strip, -1); /* put at end */
1511 strip_packer.pack_start (*strip, false, false);
1512 strip->set_packed (true);
1517 if (stripable->is_master() || stripable->is_monitor()) {
1518 /* do nothing, these cannot be hidden */
1520 if (strip->packed()) {
1521 strip_packer.remove (*strip);
1522 strip->set_packed (false);
1528 /* update visibility of VCA assign buttons */
1530 if (n_masters == 0) {
1531 //show/hide the channelstrip VCA assign buttons on channelstrips:
1532 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1534 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleVCAPane");
1536 act->set_sensitive (false);
1539 //remove the VCA packer, but don't change our prior setting for show/hide:
1540 vca_vpacker.hide ();
1542 //show/hide the channelstrip VCA assign buttons on channelstrips:
1543 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1545 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
1546 act->set_sensitive (true);
1548 //if we were showing VCAs before, show them now:
1549 showhide_vcas (act->get_active ());
1552 _group_tabs->set_dirty ();
1554 if (_spill_scroll_position > 0 && scroller.get_hscrollbar()) {
1555 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1556 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), _spill_scroll_position)));
1558 _spill_scroll_position = 0;
1563 Mixer_UI::strip_width_changed ()
1565 _group_tabs->set_dirty ();
1568 TreeModel::Children rows = track_model->children();
1569 TreeModel::Children::iterator i;
1572 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1573 AxisView* av = (*i)[stripable_columns.strip];
1574 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1580 bool visible = (*i)[stripable_columns.visible];
1583 strip->queue_draw();
1590 struct PresentationInfoMixerSorter
1592 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1593 if (a->is_master()) {
1594 /* master after everything else */
1596 } else if (b->is_master()) {
1597 /* everything else before master */
1600 return a->presentation_info().order () < b->presentation_info().order ();
1605 Mixer_UI::initial_track_display ()
1608 _session->get_stripables (sl);
1610 sl.sort (PresentationInfoMixerSorter());
1613 /* These are also used inside ::add_stripables() but we need
1614 * them here because we're going to clear the track_model also.
1616 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1617 Unwinder<bool> uw2 (ignore_reorder, true);
1619 track_model->clear ();
1620 add_stripables (sl);
1623 sync_treeview_from_presentation_info (Properties::order);
1627 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1629 if (Keyboard::is_context_menu_event (ev)) {
1630 if (track_menu == 0) {
1631 build_track_menu ();
1633 track_menu->popup (ev->button, ev->time);
1636 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1637 TreeModel::Path path;
1638 TreeViewColumn* column;
1640 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1641 TreeIter iter = track_model->get_iter (path);
1642 if ((*iter)[stripable_columns.visible]) {
1643 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1644 move_stripable_into_view (s);
1653 Mixer_UI::move_vca_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1655 if (!vca_scroller.get_hscrollbar()) {
1661 Gtk::Allocation alloc;
1663 TreeModel::Children rows = track_model->children();
1664 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1665 AxisView* av = (*i)[stripable_columns.strip];
1666 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1667 if (vms && vms->stripable () == s) {
1670 vms->translate_coordinates (vca_hpacker, 0, 0, x0, y);
1671 alloc = vms->get_allocation ();
1680 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
1682 if (x0 < adj->get_value()) {
1683 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1684 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1685 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1686 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1691 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1693 if (!scroller.get_hscrollbar()) {
1696 if (s->presentation_info().special ()) {
1699 if (s->presentation_info().flag_match (PresentationInfo::VCA)) {
1700 move_vca_into_view (s);
1709 Gtk::Allocation alloc;
1710 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1711 if ((*i)->route() == s) {
1714 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1715 alloc = (*i)->get_allocation ();
1723 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1725 if (x0 < adj->get_value()) {
1726 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1727 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1728 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1729 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1734 Mixer_UI::build_track_menu ()
1736 using namespace Menu_Helpers;
1737 using namespace Gtk;
1739 track_menu = new Menu;
1740 track_menu->set_name ("ArdourContextMenu");
1741 MenuList& items = track_menu->items();
1743 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1744 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1745 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1746 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1747 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1748 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1749 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1750 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1755 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1757 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1761 boost::shared_ptr<Stripable> s = ws.lock ();
1767 TreeModel::Children rows = track_model->children();
1768 TreeModel::Children::iterator i;
1770 for (i = rows.begin(); i != rows.end(); ++i) {
1771 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1775 if (what_changed.contains (ARDOUR::Properties::name)) {
1776 (*i)[stripable_columns.text] = s->name();
1779 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1780 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1781 redisplay_track_list ();
1788 if (s->is_master ()) {
1792 error << _("track display list item for renamed strip not found!") << endmsg;
1796 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1798 TreeModel::Path path;
1799 TreeViewColumn* column;
1803 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1804 if (ev->button == 3) {
1805 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1810 TreeIter iter = group_model->get_iter (path);
1812 if (ev->button == 3) {
1813 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1818 RouteGroup* group = (*iter)[group_columns.group];
1820 if (Keyboard::is_context_menu_event (ev)) {
1821 _group_tabs->get_menu(group)->popup (1, ev->time);
1825 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1827 if (Keyboard::is_edit_event (ev)) {
1829 // edit_route_group (group);
1831 group_display.queue_draw();
1840 bool visible = (*iter)[group_columns.visible];
1841 (*iter)[group_columns.visible] = !visible;
1843 group_display.queue_draw();
1856 Mixer_UI::activate_all_route_groups ()
1858 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1862 Mixer_UI::disable_all_route_groups ()
1864 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1868 Mixer_UI::route_groups_changed ()
1870 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1872 _in_group_rebuild_or_clear = true;
1874 /* just rebuild the while thing */
1876 group_model->clear ();
1879 /* this is currently not used,
1880 * Mixer_UI::group_display_button_press() has a case for it,
1881 * and a commented edit_route_group() but that's n/a since 2011.
1883 * This code is left as reminder that
1884 * row[group_columns.group] = 0 has special meaning.
1888 row = *(group_model->append());
1889 row[group_columns.visible] = true;
1890 row[group_columns.text] = (_("-all-"));
1891 row[group_columns.group] = 0;
1895 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1897 _group_tabs->set_dirty ();
1898 _in_group_rebuild_or_clear = false;
1902 Mixer_UI::new_route_group ()
1904 _group_tabs->run_new_group_dialog (0, false);
1908 Mixer_UI::remove_selected_route_group ()
1910 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1911 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1917 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1920 /* selection mode is single, so rows.begin() is it */
1922 if ((iter = group_model->get_iter (*i))) {
1924 RouteGroup* rg = (*iter)[group_columns.group];
1927 _session->remove_route_group (*rg);
1933 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1935 if (in_group_row_change) {
1939 /* force an update of any mixer strips that are using this group,
1940 otherwise mix group names don't change in mixer strips
1943 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1944 if ((*i)->route_group() == group) {
1945 (*i)->route_group_changed();
1949 TreeModel::iterator i;
1950 TreeModel::Children rows = group_model->children();
1951 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1953 in_group_row_change = true;
1955 for (i = rows.begin(); i != rows.end(); ++i) {
1956 if ((*i)[group_columns.group] == group) {
1957 (*i)[group_columns.visible] = !group->is_hidden ();
1958 (*i)[group_columns.text] = group->name ();
1963 in_group_row_change = false;
1965 if (change.contains (Properties::name)) {
1966 _group_tabs->set_dirty ();
1969 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
1970 if ((*j)->route_group() == group) {
1971 if (group->is_hidden ()) {
1981 Mixer_UI::toggle_mixer_list ()
1983 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
1984 showhide_mixer_list (act->get_active());
1988 Mixer_UI::showhide_mixer_list (bool yn)
1991 list_vpacker.show ();
1993 list_vpacker.hide ();
1998 Mixer_UI::toggle_monitor_section ()
2000 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2001 showhide_monitor_section (act->get_active());
2006 Mixer_UI::showhide_monitor_section (bool yn)
2008 if (monitor_section().tearoff().torn_off()) {
2013 monitor_section().tearoff().show();
2015 monitor_section().tearoff().hide();
2020 Mixer_UI::toggle_vcas ()
2022 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2023 showhide_vcas (act->get_active());
2027 Mixer_UI::showhide_vcas (bool yn)
2038 Mixer_UI::toggle_mixbuses ()
2040 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2041 showhide_mixbuses (act->get_active());
2045 Mixer_UI::showhide_mixbuses (bool on)
2057 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
2062 if ((iter = group_model->get_iter (path))) {
2064 if ((group = (*iter)[group_columns.group]) == 0) {
2068 if (new_text != group->name()) {
2069 group->set_name (new_text);
2075 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
2079 if (in_group_row_change) {
2083 if ((group = (*iter)[group_columns.group]) == 0) {
2087 std::string name = (*iter)[group_columns.text];
2089 if (name != group->name()) {
2090 group->set_name (name);
2093 bool hidden = !(*iter)[group_columns.visible];
2095 if (hidden != group->is_hidden ()) {
2096 group->set_hidden (hidden, this);
2100 /** Called when a group model row is deleted, but also when the model is
2101 * reordered by a user drag-and-drop; the latter is what we are
2102 * interested in here.
2105 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
2107 if (_in_group_rebuild_or_clear) {
2111 /* Re-write the session's route group list so that the new order is preserved */
2113 list<RouteGroup*> new_list;
2115 Gtk::TreeModel::Children children = group_model->children();
2116 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
2117 RouteGroup* g = (*i)[group_columns.group];
2119 new_list.push_back (g);
2123 _session->reorder_route_groups (new_list);
2128 Mixer_UI::add_route_group (RouteGroup* group)
2130 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
2133 in_group_row_change = true;
2135 TreeModel::Row row = *(group_model->append());
2136 row[group_columns.visible] = !group->is_hidden ();
2137 row[group_columns.group] = group;
2138 if (!group->name().empty()) {
2139 row[group_columns.text] = group->name();
2141 row[group_columns.text] = _("unnamed");
2145 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
2148 TreeViewColumn* col = group_display.get_column (0);
2149 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
2150 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
2153 _group_tabs->set_dirty ();
2155 in_group_row_change = false;
2159 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
2161 using namespace Menu_Helpers;
2163 if (Keyboard::is_context_menu_event (ev)) {
2164 ARDOUR_UI::instance()->add_route ();
2172 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
2174 if (data.get_target() != "PluginFavoritePtr") {
2175 context->drag_finish (false, false, time);
2179 const void * d = data.get_data();
2180 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2182 PluginPresetList nfos;
2184 tv->get_object_drag_data (nfos, &source);
2186 Route::ProcessorList pl;
2189 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2190 PluginPresetPtr ppp = (*i);
2191 PluginInfoPtr pip = ppp->_pip;
2192 if (!pip->is_instrument ()) {
2195 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);
2199 context->drag_finish (ok, false, time);
2203 Mixer_UI::set_strip_width (Width w, bool save)
2207 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2208 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2213 struct PluginStateSorter {
2215 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2216 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2217 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2218 if (aiter != _user.end() && biter != _user.end()) {
2219 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2221 if (aiter != _user.end()) {
2224 if (biter != _user.end()) {
2227 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2230 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2232 std::list<std::string> _user;
2236 Mixer_UI::set_state (const XMLNode& node, int version)
2240 Tabbable::set_state (node, version);
2242 if (node.get_property ("narrow-strips", yn)) {
2244 set_strip_width (Narrow);
2246 set_strip_width (Wide);
2250 node.get_property ("show-mixer", _visible);
2253 node.get_property ("maximised", yn);
2255 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Common"), X_("ToggleMaximalMixer"));
2256 bool fs = act && act->get_active();
2258 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2263 node.get_property ("show-mixer-list", yn);
2265 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixerList"));
2266 /* do it twice to force the change */
2267 act->set_active (!yn);
2268 act->set_active (yn);
2272 node.get_property ("monitor-section-visible", yn);
2274 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection"));
2275 /* do it twice to force the change */
2276 act->set_active (!yn);
2277 act->set_active (yn);
2281 node.get_property ("show-vca-pane", yn);
2283 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleVCAPane"));
2284 /* do it twice to force the change */
2285 act->set_active (!yn);
2286 act->set_active (yn);
2291 node.get_property ("show-mixbus-pane", yn);
2293 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixbusPane"));
2294 /* do it twice to force the change */
2295 act->set_active (!yn);
2296 act->set_active (yn);
2300 //check for the user's plugin_order file
2301 XMLNode plugin_order_new(X_("PO"));
2302 if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) {
2303 store_current_favorite_order ();
2304 std::list<string> order;
2305 const XMLNodeList& kids = plugin_order_new.children("PluginInfo");
2306 XMLNodeConstIterator i;
2307 for (i = kids.begin(); i != kids.end(); ++i) {
2308 std::string unique_id;
2309 if ((*i)->get_property ("unique-id", unique_id)) {
2310 order.push_back (unique_id);
2311 if ((*i)->get_property ("expanded", yn)) {
2312 favorite_ui_state[unique_id] = yn;
2316 PluginStateSorter cmp (order);
2317 favorite_order.sort (cmp);
2318 sync_treeview_from_favorite_order ();
2321 //if there is no user file, then use an existing one from instant.xml
2322 //NOTE: if you are loading an old session, this might come from the session's instant.xml
2323 //Todo: in the next major version, we should probably stop doing the instant.xml check, and just use the new file
2324 XMLNode* plugin_order;
2325 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2326 store_current_favorite_order ();
2327 std::list<string> order;
2328 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2329 XMLNodeConstIterator i;
2330 for (i = kids.begin(); i != kids.end(); ++i) {
2331 std::string unique_id;
2332 if ((*i)->get_property ("unique-id", unique_id)) {
2333 order.push_back (unique_id);
2334 if ((*i)->get_property ("expanded", yn)) {
2335 favorite_ui_state[unique_id] = yn;
2340 PluginStateSorter cmp (order);
2341 favorite_order.sort (cmp);
2342 sync_treeview_from_favorite_order ();
2350 Mixer_UI::save_plugin_order_file ()
2352 //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order )
2354 //NOTE: this replaces the old code that stores info in instant.xml
2355 //why? because instant.xml prefers the per-session settings, and we want this to be a global pref
2357 store_current_favorite_order ();
2358 XMLNode plugin_order ("PluginOrder");
2360 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2361 XMLNode* p = new XMLNode ("PluginInfo");
2362 p->set_property ("sort", cnt);
2363 p->set_property ("unique-id", (*i)->unique_id);
2364 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2365 p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2367 plugin_order.add_child_nocopy (*p);
2369 PluginManager::instance().save_plugin_order_file( plugin_order );
2373 Mixer_UI::get_state ()
2375 XMLNode* node = new XMLNode (X_("Mixer"));
2377 node->add_child_nocopy (Tabbable::get_state());
2379 node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider());
2380 node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider());
2381 node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider());
2382 node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider());
2384 node->set_property ("narrow-strips", (_strip_width == Narrow));
2385 node->set_property ("show-mixer", _visible);
2386 node->set_property ("maximised", _maximised);
2388 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2389 node->set_property ("show-mixer-list", act->get_active ());
2391 act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2392 node->set_property ("monitor-section-visible", act->get_active ());
2394 act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2395 node->set_property ("show-vca-pane", act->get_active ());
2398 act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2399 node->set_property ("show-mixbus-pane", act->get_active ());
2406 Mixer_UI::scroll_left ()
2408 if (!scroller.get_hscrollbar()) return;
2409 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2410 int sc_w = scroller.get_width();
2411 int sp_w = strip_packer.get_width();
2415 int lp = adj->get_value();
2417 using namespace Gtk::Box_Helpers;
2418 const BoxList& strips = strip_packer.children();
2419 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2420 if (i->get_widget() == & add_button) {
2424 if (i->get_widget() == &mb_shadow) {
2428 lm += i->get_widget()->get_width ();
2430 lm -= i->get_widget()->get_width ();
2434 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2438 Mixer_UI::scroll_right ()
2440 if (!scroller.get_hscrollbar()) return;
2441 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2442 int sc_w = scroller.get_width();
2443 int sp_w = strip_packer.get_width();
2447 int lp = adj->get_value();
2449 using namespace Gtk::Box_Helpers;
2450 const BoxList& strips = strip_packer.children();
2451 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2452 if (i->get_widget() == & add_button) {
2456 if (i->get_widget() == &mb_shadow) {
2460 lm += i->get_widget()->get_width ();
2465 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2469 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2471 switch (ev->direction) {
2472 case GDK_SCROLL_LEFT:
2476 if (ev->state & Keyboard::TertiaryModifier) {
2482 case GDK_SCROLL_RIGHT:
2486 case GDK_SCROLL_DOWN:
2487 if (ev->state & Keyboard::TertiaryModifier) {
2498 Mixer_UI::vca_scroll_left ()
2500 if (!vca_scroller.get_hscrollbar()) return;
2501 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2502 int sc_w = vca_scroller.get_width();
2503 int sp_w = strip_packer.get_width();
2507 int lp = adj->get_value();
2509 using namespace Gtk::Box_Helpers;
2510 const BoxList& strips = vca_hpacker.children();
2511 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2512 if (i->get_widget() == &add_vca_button) {
2515 lm += i->get_widget()->get_width ();
2517 lm -= i->get_widget()->get_width ();
2521 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2525 Mixer_UI::vca_scroll_right ()
2527 if (!vca_scroller.get_hscrollbar()) return;
2528 Adjustment* adj = vca_scroller.get_hscrollbar()->get_adjustment();
2529 int sc_w = vca_scroller.get_width();
2530 int sp_w = strip_packer.get_width();
2534 int lp = adj->get_value();
2536 using namespace Gtk::Box_Helpers;
2537 const BoxList& strips = vca_hpacker.children();
2538 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2539 if (i->get_widget() == &add_vca_button) {
2542 lm += i->get_widget()->get_width ();
2547 vca_scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2551 Mixer_UI::on_vca_scroll_event (GdkEventScroll* ev)
2553 switch (ev->direction) {
2554 case GDK_SCROLL_LEFT:
2558 if (ev->state & Keyboard::TertiaryModifier) {
2564 case GDK_SCROLL_RIGHT:
2565 vca_scroll_right ();
2568 case GDK_SCROLL_DOWN:
2569 if (ev->state & Keyboard::TertiaryModifier) {
2570 vca_scroll_right ();
2580 Mixer_UI::parameter_changed (string const & p)
2582 if (p == "show-group-tabs") {
2583 bool const s = _session->config.get_show_group_tabs ();
2585 _group_tabs->show ();
2587 _group_tabs->hide ();
2589 } else if (p == "default-narrow_ms") {
2590 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2591 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2592 (*i)->set_width_enum (s ? Narrow : Wide, this);
2598 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2600 g->set_active (a, this);
2604 Mixer_UI::plugin_selector()
2606 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2607 if (!_plugin_selector)
2608 _plugin_selector = new PluginSelector (PluginManager::instance());
2611 return _plugin_selector;
2615 Mixer_UI::setup_track_display ()
2617 track_model = ListStore::create (stripable_columns);
2618 track_display.set_model (track_model);
2619 track_display.append_column (_("Show"), stripable_columns.visible);
2620 track_display.append_column (_("Strips"), stripable_columns.text);
2621 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2622 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2623 track_display.get_column (0)->set_expand(false);
2624 track_display.get_column (1)->set_expand(true);
2625 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2626 track_display.set_name (X_("EditGroupList"));
2627 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2628 track_display.set_reorderable (true);
2629 track_display.set_headers_visible (true);
2630 track_display.set_can_focus(false);
2632 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2633 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2635 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2636 track_list_visible_cell->property_activatable() = true;
2637 track_list_visible_cell->property_radio() = false;
2638 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2640 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2642 track_display_scroller.add (track_display);
2643 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2645 VBox* v = manage (new VBox);
2647 v->pack_start (track_display_scroller, true, true);
2649 track_display_frame.set_name("BaseFrame");
2650 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2651 track_display_frame.add (*v);
2653 track_display_scroller.show();
2654 track_display_frame.show();
2655 track_display.show();
2659 Mixer_UI::new_track_or_bus ()
2661 ARDOUR_UI::instance()->add_route ();
2665 Mixer_UI::update_title ()
2667 if (!own_window()) {
2674 if (_session->snap_name() != _session->name()) {
2675 n = _session->snap_name ();
2677 n = _session->name ();
2680 if (_session->dirty ()) {
2684 WindowTitle title (n);
2685 title += S_("Window|Mixer");
2686 title += Glib::get_application_name ();
2687 own_window()->set_title (title.get_string());
2691 WindowTitle title (S_("Window|Mixer"));
2692 title += Glib::get_application_name ();
2693 own_window()->set_title (title.get_string());
2698 Mixer_UI::strip_by_x (int x)
2700 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2703 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2704 x2 = x1 + (*i)->get_width();
2706 if (x >= x1 && x <= x2) {
2715 Mixer_UI::set_axis_targets_for_operation ()
2717 _axis_targets.clear ();
2719 if (!_selection.empty()) {
2720 _axis_targets = _selection.axes;
2724 // removed "implicit" selections of strips, after discussion on IRC
2729 Mixer_UI::monitor_section_going_away ()
2731 XMLNode* ui_node = Config->extra_xml(X_("UI"));
2733 /* immediate state save.
2735 * Tearoff settings are otherwise only stored during
2736 * save_ardour_state(). The mon-section may or may not
2737 * exist at that point.
2741 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
2743 tearoff_node->remove_nodes_and_delete (X_("monitor-section"));
2744 XMLNode* t = new XMLNode (X_("monitor-section"));
2745 _monitor_section.tearoff().add_state (*t);
2746 tearoff_node->add_child_nocopy (*t);
2750 monitor_section_detached ();
2751 out_packer.remove (_monitor_section.tearoff());
2755 Mixer_UI::toggle_midi_input_active (bool flip_others)
2757 boost::shared_ptr<RouteList> rl (new RouteList);
2760 set_axis_targets_for_operation ();
2762 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2763 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2767 onoff = !mt->input_active();
2771 _session->set_exclusive_input_active (rl, onoff, flip_others);
2775 Mixer_UI::maximise_mixer_space ()
2777 if (!own_window()) {
2785 _window->fullscreen ();
2790 Mixer_UI::restore_mixer_space ()
2792 if (!own_window()) {
2800 own_window()->unfullscreen();
2805 Mixer_UI::monitor_section_attached ()
2807 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2808 act->set_sensitive (true);
2809 showhide_monitor_section (act->get_active ());
2813 Mixer_UI::monitor_section_detached ()
2815 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleMonitorSection");
2816 act->set_sensitive (false);
2820 Mixer_UI::store_current_favorite_order ()
2822 typedef Gtk::TreeModel::Children type_children;
2823 type_children children = favorite_plugins_model->children();
2824 favorite_order.clear();
2825 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2827 Gtk::TreeModel::Row row = *iter;
2828 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2829 favorite_order.push_back (ppp->_pip);
2830 std::string name = row[favorite_plugins_columns.name];
2831 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2836 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2838 Gtk::TreeModel::Row row = *iter;
2839 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2841 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2845 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2847 PluginManager& manager (PluginManager::instance());
2848 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2850 /* not a Favorite? skip it */
2851 if (manager.get_status (*i) != PluginManager::Favorite) {
2855 /* Check the tag combo selection, and skip this plugin if it doesn't match the selected tag(s) */
2856 string test = favorite_plugins_tag_combo.get_active_text();
2857 if (test != _("Show All")) {
2858 vector<string> tags = manager.get_tags(*i);
2860 //does the selected tag match any of the tags in the plugin?
2861 vector<string>::iterator tt = find (tags.begin(), tags.end(), test);
2862 if (tt == tags.end()) {
2867 result.push_back (*i);
2871 struct PluginCustomSorter {
2873 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2874 PluginInfoList::const_iterator aiter = _user.begin();
2875 PluginInfoList::const_iterator biter = _user.begin();
2876 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2877 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2879 if (aiter != _user.end() && biter != _user.end()) {
2880 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2882 if (aiter != _user.end()) {
2885 if (biter != _user.end()) {
2888 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2890 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2892 PluginInfoList _user;
2896 Mixer_UI::refill_favorite_plugins ()
2898 PluginInfoList plugs;
2899 PluginManager& mgr (PluginManager::instance());
2902 refiller (plugs, mgr.lv2_plugin_info ());
2904 #ifdef WINDOWS_VST_SUPPORT
2905 refiller (plugs, mgr.windows_vst_plugin_info ());
2907 #ifdef LXVST_SUPPORT
2908 refiller (plugs, mgr.lxvst_plugin_info ());
2910 #ifdef MACVST_SUPPORT
2911 refiller (plugs, mgr.mac_vst_plugin_info ());
2913 #ifdef AUDIOUNIT_SUPPORT
2914 refiller (plugs, mgr.au_plugin_info ());
2916 refiller (plugs, mgr.ladspa_plugin_info ());
2917 refiller (plugs, mgr.lua_plugin_info ());
2919 store_current_favorite_order ();
2921 PluginCustomSorter cmp (favorite_order);
2924 favorite_order = plugs;
2926 sync_treeview_from_favorite_order ();
2930 Mixer_UI::plugin_list_changed ()
2932 refill_favorite_plugins();
2937 Mixer_UI::refill_tag_combo ()
2939 PluginManager& mgr (PluginManager::instance());
2941 std::vector<std::string> tags = mgr.get_all_tags (PluginManager::OnlyFavorites);
2943 favorite_plugins_tag_combo.clear();
2944 favorite_plugins_tag_combo.append_text (_("Show All"));
2946 for (vector<string>::iterator t = tags.begin (); t != tags.end (); ++t) {
2947 favorite_plugins_tag_combo.append_text (*t);
2950 favorite_plugins_tag_combo.set_active_text (_("Show All"));
2954 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2957 if (!(iter = favorite_plugins_model->get_iter (path))) {
2960 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2964 PluginInfoPtr pip = ppp->_pip;
2965 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2966 if (favorite_ui_state[pip->unique_id]) {
2967 favorite_plugins_display.expand_row (path, true);
2973 Mixer_UI::sync_treeview_from_favorite_order ()
2975 favorite_plugins_model->clear ();
2976 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
2977 PluginInfoPtr pip = (*i);
2979 TreeModel::Row newrow = *(favorite_plugins_model->append());
2980 newrow[favorite_plugins_columns.name] = (*i)->name;
2981 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
2986 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
2987 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
2991 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
2992 child_row[favorite_plugins_columns.name] = (*j).label;
2993 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
2995 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2996 if (favorite_ui_state[pip->unique_id]) {
2997 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
3004 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
3006 using namespace Gtk::Menu_Helpers;
3008 Gtk::Menu* m = ARDOUR_UI::instance()->shared_popup_menu ();
3009 MenuList& items = m->items ();
3011 if (_selection.axes.empty()) {
3012 items.push_back (MenuElem (_("No Track/Bus is selected.")));
3014 items.push_back (MenuElem (_("Add at the top"),
3015 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
3016 items.push_back (MenuElem (_("Add Pre-Fader"),
3017 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
3018 items.push_back (MenuElem (_("Add Post-Fader"),
3019 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
3020 items.push_back (MenuElem (_("Add at the end"),
3021 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
3024 items.push_back (SeparatorElem());
3026 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
3028 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3029 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
3030 // we cannot currently delete AU presets
3031 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
3032 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
3036 m->popup (ev->button, ev->time);
3040 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
3042 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
3043 TreeModel::Path path;
3044 TreeViewColumn* column;
3046 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
3047 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3049 selection->unselect_all();
3050 selection->select(path);
3053 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3055 popup_note_context_menu (ev);
3063 Mixer_UI::selected_plugin ()
3065 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
3067 return PluginPresetPtr();
3069 Gtk::TreeModel::iterator iter = selection->get_selected();
3071 return PluginPresetPtr();
3073 return (*iter)[favorite_plugins_columns.plugin];
3077 Mixer_UI::add_selected_processor (ProcessorPosition pos)
3079 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3081 add_favorite_processor (ppp, pos);
3086 Mixer_UI::delete_selected_preset ()
3091 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3092 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
3095 PluginPtr plugin = ppp->_pip->load (*_session);
3096 plugin->get_presets();
3097 plugin->remove_preset (ppp->_preset.label);
3101 Mixer_UI::remove_selected_from_favorites ()
3103 ARDOUR::PluginPresetPtr ppp = selected_plugin();
3107 PluginManager::PluginStatusType status = PluginManager::Normal;
3108 PluginManager& manager (PluginManager::instance());
3110 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3111 manager.save_statuses ();
3115 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
3118 if (!(iter = favorite_plugins_model->get_iter (path))) {
3121 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
3122 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
3126 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
3128 if (!_session || _selection.axes.empty()) {
3132 PluginInfoPtr pip = ppp->_pip;
3133 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
3134 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
3140 PluginPtr p = pip->load (*_session);
3146 if (ppp->_preset.valid) {
3147 p->load_preset (ppp->_preset);
3150 Route::ProcessorStreams err;
3151 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
3155 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
3158 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
3165 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
3169 if (!np->display_to_user()) {
3172 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
3173 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
3178 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
3182 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
3189 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
3191 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
3195 // only allow to re-order top-level items
3197 if (TreePath::get_from_selection_data (data, src)) {
3198 if (src.up() && src.up()) {
3203 // don't allow to drop as child-rows.
3204 Gtk::TreeModel::Path _dest = dest; // un const
3205 const bool is_child = _dest.up (); // explicit bool for clang
3206 if (!is_child || _dest.empty ()) {
3213 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
3215 if (data.get_target() != "PluginPresetPtr") {
3218 if (data.get_length() != sizeof (PluginPresetPtr)) {
3221 const void *d = data.get_data();
3222 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
3224 PluginManager::PluginStatusType status = PluginManager::Favorite;
3225 PluginManager& manager (PluginManager::instance());
3227 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3228 manager.save_statuses ();
3232 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
3234 /* call protected MixerActor:: method */
3239 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
3241 /* call protected MixerActor:: method */
3246 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
3248 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
3251 show_spill_change (s); /* EMIT SIGNAL */
3253 _group_tabs->hide ();
3255 _group_tabs->show ();
3257 redisplay_track_list ();
3262 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
3264 return s == spilled_strip.lock();
3268 Mixer_UI::register_actions ()
3270 Glib::RefPtr<ActionGroup> group = ActionManager::create_action_group (bindings, X_("Mixer"));
3272 ActionManager::register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
3273 ActionManager::register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
3274 ActionManager::register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
3275 ActionManager::register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
3276 ActionManager::register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
3277 ActionManager::register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
3280 ActionManager::register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
3281 ActionManager::register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
3282 ActionManager::register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
3283 ActionManager::register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
3284 ActionManager::register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
3285 ActionManager::register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
3286 ActionManager::register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
3287 ActionManager::register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
3289 ActionManager::register_action (group, "select-next-stripable", _("Select Next Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_next_strip));
3290 ActionManager::register_action (group, "select-prev-stripable", _("Scroll Previous Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_prev_strip));
3292 ActionManager::register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
3293 ActionManager::register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
3295 ActionManager::register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
3296 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
3298 ActionManager::register_toggle_action (group, X_("ToggleMixerList"), _("Mixer: Show Mixer List"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixer_list));
3300 ActionManager::register_toggle_action (group, X_("ToggleVCAPane"), _("Mixer: Show VCAs"), sigc::mem_fun (*this, &Mixer_UI::toggle_vcas));
3303 ActionManager::register_toggle_action (group, X_("ToggleMixbusPane"), _("Mixer: Show Mixbusses"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixbuses));
3306 ActionManager::register_toggle_action (group, X_("ToggleMonitorSection"), _("Mixer: Show Monitor Section"), sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_section));
3310 Mixer_UI::load_bindings ()
3312 bindings = Bindings::get_bindings (X_("Mixer"));
3315 template<class T> void
3316 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
3318 boost::shared_ptr<ControlList> cl (new ControlList);
3319 boost::shared_ptr<AutomationControl> ac;
3321 bool have_val = false;
3323 set_axis_targets_for_operation ();
3325 BOOST_FOREACH(AxisView* r, _axis_targets) {
3326 boost::shared_ptr<Stripable> s = r->stripable();
3328 ac = (s.get()->*get_control)();
3332 val = !ac->get_value();
3339 _session->set_controls (cl, val, Controllable::UseGroup);
3343 Mixer_UI::solo_action ()
3345 control_action (&Stripable::solo_control);
3349 Mixer_UI::mute_action ()
3351 control_action (&Stripable::mute_control);
3355 Mixer_UI::rec_enable_action ()
3357 control_action (&Stripable::rec_enable_control);
3360 AutomationControlSet
3361 Mixer_UI::selected_gaincontrols ()
3363 set_axis_targets_for_operation ();
3364 AutomationControlSet rv;
3365 BOOST_FOREACH(AxisView* r, _axis_targets) {
3366 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3368 boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
3369 ControlList cl (ac->grouped_controls());
3370 for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
3380 Mixer_UI::step_gain_up_action ()
3382 AutomationControlSet acs = selected_gaincontrols ();
3383 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3384 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3386 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
3391 Mixer_UI::step_gain_down_action ()
3393 AutomationControlSet acs = selected_gaincontrols ();
3394 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3395 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3397 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
3402 Mixer_UI::unity_gain_action ()
3404 set_axis_targets_for_operation ();
3406 BOOST_FOREACH(AxisView* r, _axis_targets) {
3407 boost::shared_ptr<Stripable> s = r->stripable();
3409 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3411 ac->set_value (1.0, Controllable::UseGroup);
3418 Mixer_UI::copy_processors ()
3420 set_axis_targets_for_operation ();
3422 BOOST_FOREACH(AxisView* r, _axis_targets) {
3423 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3425 ms->copy_processors ();
3430 Mixer_UI::cut_processors ()
3432 set_axis_targets_for_operation ();
3434 BOOST_FOREACH(AxisView* r, _axis_targets) {
3435 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3437 ms->cut_processors ();
3442 Mixer_UI::paste_processors ()
3444 set_axis_targets_for_operation ();
3446 BOOST_FOREACH(AxisView* r, _axis_targets) {
3447 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3449 ms->paste_processors ();
3454 Mixer_UI::select_all_processors ()
3456 set_axis_targets_for_operation ();
3458 BOOST_FOREACH(AxisView* r, _axis_targets) {
3459 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3461 ms->select_all_processors ();
3466 Mixer_UI::toggle_processors ()
3468 set_axis_targets_for_operation ();
3470 BOOST_FOREACH(AxisView* r, _axis_targets) {
3471 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3473 ms->toggle_processors ();
3478 Mixer_UI::ab_plugins ()
3480 set_axis_targets_for_operation ();
3482 BOOST_FOREACH(AxisView* r, _axis_targets) {
3483 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3491 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3493 set_axis_targets_for_operation ();
3494 BOOST_FOREACH(AxisView* r, _axis_targets) {
3495 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3497 ms->vca_assign (vca);
3503 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3505 set_axis_targets_for_operation ();
3506 BOOST_FOREACH(AxisView* r, _axis_targets) {
3507 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3509 ms->vca_unassign (vca);
3515 Mixer_UI::screenshot (std::string const& filename)
3521 int height = strip_packer.get_height();
3522 bool with_vca = vca_vpacker.is_visible ();
3523 MixerStrip* master = strip_by_route (_session->master_out ());
3525 Gtk::OffscreenWindow osw;
3530 /* unpack widgets, add to OffscreenWindow */
3532 strip_group_box.remove (strip_packer);
3533 b.pack_start (strip_packer, false, false);
3534 /* hide extra elements inside strip_packer */
3536 scroller_base.hide ();
3542 /* work around Gtk::ScrolledWindow */
3543 Gtk::Viewport* viewport = (Gtk::Viewport*) vca_scroller.get_child();
3544 viewport->remove (); // << vca_hpacker
3545 b.pack_start (vca_hpacker, false, false);
3546 /* hide some growing widgets */
3547 add_vca_button.hide ();
3548 vca_scroller_base.hide();
3552 out_packer.remove (*master);
3553 b.pack_start (*master, false, false);
3554 master->hide_master_spacer (true);
3557 /* prepare the OffscreenWindow for rendering */
3558 osw.set_size_request (-1, height);
3560 osw.queue_resize ();
3562 osw.get_window()->process_updates (true);
3564 /* create screenshot */
3565 Glib::RefPtr<Gdk::Pixbuf> pb = osw.get_pixbuf ();
3566 pb->save (filename, "png");
3568 /* unpack elements before destorying the Box & OffscreenWindow */
3569 list<Gtk::Widget*> children = b.get_children();
3570 for (list<Gtk::Widget*>::iterator child = children.begin(); child != children.end(); ++child) {
3575 /* now re-pack the widgets into the main mixer window */
3577 scroller_base.show ();
3581 strip_group_box.pack_start (strip_packer);
3583 add_vca_button.show ();
3584 vca_scroller_base.show();
3585 vca_scroller.add (vca_hpacker);
3588 master->hide_master_spacer (false);
3589 out_packer.pack_start (*master, false, false);