2 Copyright (C) 2000-2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "gtk2ardour-config.h"
26 #include <sigc++/bind.h>
28 #include <boost/foreach.hpp>
30 #include <gtkmm/accelmap.h>
32 #include "pbd/convert.h"
33 #include "pbd/stacktrace.h"
34 #include "pbd/unwind.h"
36 #include <glibmm/threads.h>
38 #include <gtkmm2ext/gtk_ui.h>
39 #include <gtkmm2ext/keyboard.h>
40 #include <gtkmm2ext/utils.h>
41 #include <gtkmm2ext/tearoff.h>
42 #include <gtkmm2ext/window_title.h>
43 #include <gtkmm2ext/doi.h>
45 #include "ardour/amp.h"
46 #include "ardour/debug.h"
47 #include "ardour/audio_track.h"
48 #include "ardour/midi_track.h"
49 #include "ardour/plugin_manager.h"
50 #include "ardour/route_group.h"
51 #include "ardour/session.h"
52 #include "ardour/vca.h"
53 #include "ardour/vca_manager.h"
57 #include "mixer_strip.h"
58 #include "monitor_section.h"
59 #include "plugin_selector.h"
60 #include "public_editor.h"
61 #include "mouse_cursors.h"
62 #include "ardour_ui.h"
65 #include "route_sorter.h"
67 #include "gui_thread.h"
68 #include "mixer_group_tabs.h"
69 #include "route_sorter.h"
71 #include "ui_config.h"
72 #include "vca_master_strip.h"
76 using namespace ARDOUR;
77 using namespace ARDOUR_UI_UTILS;
81 using namespace Gtkmm2ext;
87 Mixer_UI* Mixer_UI::_instance = 0;
93 _instance = new Mixer_UI;
100 : Tabbable (_content, _("Mixer"))
101 , no_track_list_redisplay (false)
102 , in_group_row_change (false)
104 , _monitor_section (0)
105 , _plugin_selector (0)
106 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
107 , ignore_reorder (false)
108 , _in_group_rebuild_or_clear (false)
109 , _route_deletion_in_progress (false)
110 , _following_editor_selection (false)
112 , _show_mixer_list (true)
113 , myactions (X_("mixer"))
117 _content.set_data ("ardour-bindings", bindings);
119 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_treeview_from_presentation_info, this), gui_context());
121 scroller.set_can_default (true);
122 // set_default (scroller);
124 scroller_base.set_flags (Gtk::CAN_FOCUS);
125 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
126 scroller_base.set_name ("MixerWindow");
127 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
129 /* set up drag-n-drop */
130 vector<TargetEntry> target_table;
131 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
132 scroller_base.drag_dest_set (target_table);
133 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
135 // add as last item of strip packer
136 strip_packer.pack_end (scroller_base, true, true);
138 _group_tabs = new MixerGroupTabs (this);
139 VBox* b = manage (new VBox);
140 b->pack_start (*_group_tabs, PACK_SHRINK);
141 b->pack_start (strip_packer);
145 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
147 setup_track_display ();
149 group_model = ListStore::create (group_columns);
150 group_display.set_model (group_model);
151 group_display.append_column (_("Show"), group_columns.visible);
152 group_display.append_column (_("Group"), group_columns.text);
153 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
154 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
155 group_display.get_column (0)->set_expand(false);
156 group_display.get_column (1)->set_expand(true);
157 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
158 group_display.set_name ("EditGroupList");
159 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
160 group_display.set_reorderable (true);
161 group_display.set_headers_visible (true);
162 group_display.set_rules_hint (true);
163 group_display.set_can_focus(false);
165 /* name is directly editable */
167 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
168 name_cell->property_editable() = true;
169 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
171 /* use checkbox for the active column */
173 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
174 active_cell->property_activatable() = true;
175 active_cell->property_radio() = false;
177 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
178 /* We use this to notice drag-and-drop reorders of the group list */
179 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
180 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
182 group_display_scroller.add (group_display);
183 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
185 HBox* route_group_display_button_box = manage (new HBox());
187 Button* route_group_add_button = manage (new Button ());
188 Button* route_group_remove_button = manage (new Button ());
192 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
194 route_group_add_button->add (*w);
196 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
198 route_group_remove_button->add (*w);
200 route_group_display_button_box->set_homogeneous (true);
202 route_group_add_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_route_group));
203 route_group_remove_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::remove_selected_route_group));
205 route_group_display_button_box->add (*route_group_add_button);
206 route_group_display_button_box->add (*route_group_remove_button);
208 group_display_vbox.pack_start (group_display_scroller, true, true);
209 group_display_vbox.pack_start (*route_group_display_button_box, false, false);
211 group_display_frame.set_name ("BaseFrame");
212 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
213 group_display_frame.add (group_display_vbox);
216 list<TargetEntry> target_list;
217 target_list.push_back (TargetEntry ("PluginPresetPtr"));
219 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
220 favorite_plugins_display.set_model (favorite_plugins_model);
221 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
222 favorite_plugins_display.set_name ("EditGroupList");
223 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
224 favorite_plugins_display.set_reorderable (false);
225 favorite_plugins_display.set_headers_visible (true);
226 favorite_plugins_display.set_rules_hint (true);
227 favorite_plugins_display.set_can_focus (false);
228 favorite_plugins_display.set_tooltip_column (0);
229 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
230 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
231 favorite_plugins_display.add_drop_targets (target_list);
232 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
233 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
234 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
235 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
236 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
237 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
239 favorite_plugins_scroller.add (favorite_plugins_display);
240 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
242 favorite_plugins_frame.set_name ("BaseFrame");
243 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
244 favorite_plugins_frame.add (favorite_plugins_scroller);
246 rhs_pane1.add (favorite_plugins_frame);
247 rhs_pane1.add (track_display_frame);
249 rhs_pane2.add (rhs_pane1);
250 rhs_pane2.add (group_display_frame);
252 list_vpacker.pack_start (rhs_pane2, true, true);
254 string vca_text = _("Control Masters");
255 Gtk::HBox* vca_top_padding = manage (new Gtk::HBox);
256 vca_top_padding->set_size_request (-1, 2);
257 vca_vpacker.pack_start (*vca_top_padding, false, false);
259 vca_label.set_text (vca_text);
260 vca_label_bar.set_size_request (-1, 16); /* must match height in GroupTabs::set_size_request() */
262 vca_label_bar.set_name (X_("VCALabelBar"));
263 vca_label_bar.add (vca_label);
265 vca_vpacker.pack_start (vca_label_bar, false, false);
267 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
268 vca_scroller_base.set_name (X_("MixerWindow"));
269 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
270 vca_hpacker.pack_end (vca_scroller_base, true, true);
272 vca_scroller.add (vca_hpacker);
273 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
274 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
276 vca_vpacker.pack_start (vca_scroller, true, true);
278 inner_pane.add (scroller);
279 inner_pane.add (vca_vpacker);
281 global_hpacker.pack_start (inner_pane, true, true);
282 global_hpacker.pack_start (out_packer, false, false);
284 list_hpane.set_check_divider_position (true);
285 list_hpane.add (list_vpacker);
286 list_hpane.add (global_hpacker);
289 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
290 XMLProperty const * prop;
296 if (!settings || ((prop = settings->property ("mixer-rhs-pane1-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
297 rhs_pane1.set_divider (0, 0.6f);
299 rhs_pane1.set_divider (0, fract);
301 if (!settings || ((prop = settings->property ("mixer-rhs-pane2-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
302 rhs_pane2.set_divider (0, 0.7f);
304 rhs_pane2.set_divider (0, fract);
306 if (!settings || ((prop = settings->property ("mixer-list-hpane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
307 list_hpane.set_divider (0, 0.2f);
309 list_hpane.set_divider (0, fract);
311 if (!settings || ((prop = settings->property ("mixer-inner-pane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
312 inner_pane.set_divider (0, 0.8f);
314 inner_pane.set_divider (0, atof (prop->value()));
318 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
319 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
320 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
321 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
323 _content.pack_start (list_hpane, true, true);
327 route_group_display_button_box->show();
328 route_group_add_button->show();
329 route_group_remove_button->show();
332 _content.set_name ("MixerWindow");
334 global_hpacker.show();
336 scroller_base.show();
337 scroller_hpacker.show();
338 mixer_scroller_vpacker.show();
340 group_display_button_label.show();
341 group_display_button.show();
342 group_display_scroller.show();
343 favorite_plugins_scroller.show();
344 group_display_vbox.show();
345 group_display_frame.show();
346 favorite_plugins_frame.show();
351 vca_top_padding->show ();
355 vca_label_bar.show();
357 vca_scroller_base.show();
360 group_display.show();
361 favorite_plugins_display.show();
363 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
367 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
369 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
370 _plugin_selector = new PluginSelector (PluginManager::instance ());
372 #error implement deferred Plugin-Favorite list
374 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
375 PluginManager::instance ().PluginStatusesChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
376 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
379 Mixer_UI::~Mixer_UI ()
381 if (_monitor_section) {
382 monitor_section_detached ();
383 delete _monitor_section;
385 delete _plugin_selector;
395 Mixer_UI::track_editor_selection ()
397 PublicEditor::instance().get_selection().TracksChanged.connect (sigc::mem_fun (*this, &Mixer_UI::follow_editor_selection));
401 Mixer_UI::use_own_window (bool and_fill_it)
403 bool new_window = !own_window();
405 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
408 if (win && new_window) {
409 win->set_name ("MixerWindow");
410 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
411 win->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
412 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
413 win->set_data ("ardour-bindings", bindings);
421 Mixer_UI::show_window ()
423 Tabbable::show_window ();
425 /* show/hide group tabs as required */
426 parameter_changed ("show-group-tabs");
428 /* now reset each strips width so the right widgets are shown */
430 TreeModel::Children rows = track_model->children();
431 TreeModel::Children::iterator ri;
433 for (ri = rows.begin(); ri != rows.end(); ++ri) {
434 AxisView* av = (*ri)[stripable_columns.strip];
435 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
439 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
440 /* Fix visibility of mixer strip stuff */
441 ms->parameter_changed (X_("mixer-element-visibility"));
444 /* force focus into main area */
445 scroller_base.grab_focus ();
449 Mixer_UI::remove_master (VCAMasterStrip* vms)
451 if (_session && _session->deletion_in_progress()) {
452 /* its all being taken care of */
456 TreeModel::Children rows = track_model->children();
457 TreeModel::Children::iterator ri;
459 for (ri = rows.begin(); ri != rows.end(); ++ri) {
460 if ((*ri)[stripable_columns.strip] == vms) {
461 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
462 track_model->erase (ri);
469 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
471 using namespace Menu_Helpers;
473 if (Keyboard::is_context_menu_event (ev)) {
474 ARDOUR_UI::instance()->add_route ();
482 Mixer_UI::add_masters (VCAList& vlist)
486 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
487 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
494 Mixer_UI::add_routes (RouteList& rlist)
498 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
506 Mixer_UI::add_stripables (StripableList& slist)
508 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
509 bool from_scratch = (track_model->children().size() == 0);
510 uint32_t nroutes = 0;
512 slist.sort (StripablePresentationInfoSorter());
514 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
515 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
523 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
533 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
535 track_display.set_model (Glib::RefPtr<ListStore>());
537 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
539 boost::shared_ptr<Route> route;
540 boost::shared_ptr<VCA> vca;
542 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
544 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
546 TreeModel::Row row = *(track_model->append());
548 row[stripable_columns.text] = vca->name();
549 row[stripable_columns.visible] = vms->marked_for_display ();
550 row[stripable_columns.strip] = vms;
551 row[stripable_columns.stripable] = vca;
553 vms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
555 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
557 if (route->is_auditioner()) {
561 if (route->is_monitor()) {
563 if (!_monitor_section) {
564 _monitor_section = new MonitorSection (_session);
566 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
568 _monitor_section->tearoff().set_state (*mnode);
572 out_packer.pack_end (_monitor_section->tearoff(), false, false);
573 _monitor_section->set_session (_session);
574 _monitor_section->tearoff().show_all ();
576 _monitor_section->tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
577 _monitor_section->tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
579 monitor_section_attached ();
581 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
583 /* no regular strip shown for control out */
588 strip = new MixerStrip (*this, _session, route);
589 strips.push_back (strip);
591 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
593 if (strip->width_owner() != strip) {
594 strip->set_width_enum (_strip_width, this);
599 if (!route->is_master()) {
601 TreeModel::Row row = *(track_model->insert (insert_iter));
603 row[stripable_columns.text] = route->name();
604 row[stripable_columns.visible] = strip->marked_for_display();
605 row[stripable_columns.stripable] = route;
606 row[stripable_columns.strip] = strip;
609 _selection.add (strip);
614 out_packer.pack_start (*strip, false, false);
615 strip->set_packed (true);
618 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
619 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
622 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
623 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
626 } catch (const std::exception& e) {
627 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
630 track_display.set_model (track_model);
633 sync_presentation_info_from_treeview ();
636 redisplay_track_list ();
640 Mixer_UI::deselect_all_strip_processors ()
642 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
643 (*i)->deselect_all_processors();
648 Mixer_UI::select_strip (MixerStrip& ms, bool add)
651 _selection.add (&ms);
653 _selection.set (&ms);
658 Mixer_UI::select_none ()
660 _selection.clear_routes();
661 deselect_all_strip_processors();
665 Mixer_UI::delete_processors ()
667 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
668 (*i)->delete_processors();
674 Mixer_UI::remove_strip (MixerStrip* strip)
676 if (_session && _session->deletion_in_progress()) {
677 /* its all being taken care of */
681 TreeModel::Children rows = track_model->children();
682 TreeModel::Children::iterator ri;
683 list<MixerStrip *>::iterator i;
685 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
689 for (ri = rows.begin(); ri != rows.end(); ++ri) {
690 if ((*ri)[stripable_columns.strip] == strip) {
691 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
692 track_model->erase (ri);
699 Mixer_UI::sync_presentation_info_from_treeview ()
701 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
705 TreeModel::Children rows = track_model->children();
711 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
713 TreeModel::Children::iterator ri;
717 for (ri = rows.begin(); ri != rows.end(); ++ri) {
718 bool visible = (*ri)[stripable_columns.visible];
719 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
725 /* Monitor and Auditioner do not get their presentation
729 if (stripable->is_monitor() || stripable->is_auditioner()) {
733 /* Master also doesn't get set here but since the editor allows
734 * it to be reordered, we need to preserve its ordering.
737 stripable->presentation_info().set_hidden (!visible);
739 if (order != stripable->presentation_info().order()) {
740 stripable->set_presentation_order (order, false);
748 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
749 _session->notify_presentation_info_change ();
754 Mixer_UI::sync_treeview_from_presentation_info ()
756 if (!_session || _session->deletion_in_progress()) {
760 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
762 /* we could get here after either a change in the Mixer or Editor sort
763 * order, but either way, the mixer order keys reflect the intended
764 * order for the GUI, so reorder the treeview model to match it.
767 vector<int> neworder;
768 TreeModel::Children rows = track_model->children();
769 uint32_t old_order = 0;
770 bool changed = false;
778 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
779 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
780 sorted.push_back (OrderKeys (old_order, stripable->presentation_info().order()));
783 SortByNewDisplayOrder cmp;
785 sort (sorted.begin(), sorted.end(), cmp);
786 neworder.assign (sorted.size(), 0);
790 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
792 neworder[n] = sr->old_display_order;
794 if (sr->old_display_order != n) {
800 Unwinder<bool> uw (ignore_reorder, true);
801 track_model->reorder (neworder);
804 redisplay_track_list ();
808 Mixer_UI::follow_editor_selection ()
810 if (_following_editor_selection) {
814 _following_editor_selection = true;
815 _selection.block_routes_changed (true);
817 TrackSelection& s (PublicEditor::instance().get_selection().tracks);
819 _selection.clear_routes ();
821 for (TrackViewList::iterator i = s.begin(); i != s.end(); ++i) {
822 TimeAxisView* tav = dynamic_cast<TimeAxisView*> (*i);
824 AxisView* axis = axis_by_stripable (tav->stripable());
826 _selection.add (axis);
831 _following_editor_selection = false;
832 _selection.block_routes_changed (false);
837 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
839 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
840 if ((*i)->route() == r) {
849 Mixer_UI::axis_by_stripable (boost::shared_ptr<Stripable> s) const
851 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
852 if ((*i)->stripable() == s) {
861 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
863 if (ev->button == 1) {
864 if (_selection.selected (strip)) {
865 /* primary-click: toggle selection state of strip */
866 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
867 _selection.remove (strip);
868 } else if (_selection.axes.size() > 1) {
869 /* de-select others */
870 _selection.set (strip);
873 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
874 _selection.add (strip);
875 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
877 /* extend selection */
879 vector<MixerStrip*> tmp;
880 bool accumulate = false;
881 bool found_another = false;
883 tmp.push_back (strip);
885 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
887 /* hit clicked strip, start accumulating till we hit the first
896 } else if (_selection.selected (*i)) {
897 /* hit selected strip. if currently accumulating others,
898 we're done. if not accumulating others, start doing so.
900 found_another = true;
915 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
919 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
921 _selection.set (strip);
930 Mixer_UI::set_session (Session* sess)
932 SessionHandlePtr::set_session (sess);
934 if (_plugin_selector) {
935 _plugin_selector->set_session (_session);
938 _group_tabs->set_session (sess);
944 refill_favorite_plugins();
946 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
947 set_state (*node, 0);
951 initial_track_display ();
953 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
954 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
955 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
956 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
957 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
958 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
959 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
961 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
963 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
965 route_groups_changed ();
974 Mixer_UI::session_going_away ()
976 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
978 _in_group_rebuild_or_clear = true;
979 group_model->clear ();
980 _in_group_rebuild_or_clear = false;
983 track_model->clear ();
985 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
989 if (_monitor_section) {
990 _monitor_section->tearoff().hide_visible ();
993 monitor_section_detached ();
999 SessionHandlePtr::session_going_away ();
1006 Mixer_UI::track_visibility_changed (std::string const & path)
1008 if (_session && _session->deletion_in_progress()) {
1014 if ((iter = track_model->get_iter (path))) {
1016 AxisView* av = (*iter)[stripable_columns.strip];
1017 bool visible = (*iter)[stripable_columns.visible];
1019 if (av->set_marked_for_display (!visible)) {
1020 update_track_visibility ();
1026 Mixer_UI::update_track_visibility ()
1028 TreeModel::Children rows = track_model->children();
1029 TreeModel::Children::iterator i;
1032 Unwinder<bool> uw (no_track_list_redisplay, true);
1034 for (i = rows.begin(); i != rows.end(); ++i) {
1035 AxisView* av = (*i)[stripable_columns.strip];
1036 (*i)[stripable_columns.visible] = av->marked_for_display ();
1039 /* force presentation catch up with visibility changes
1042 sync_presentation_info_from_treeview ();
1045 redisplay_track_list ();
1049 Mixer_UI::show_strip (MixerStrip* ms)
1051 TreeModel::Children rows = track_model->children();
1052 TreeModel::Children::iterator i;
1054 for (i = rows.begin(); i != rows.end(); ++i) {
1056 AxisView* av = (*i)[stripable_columns.strip];
1057 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1059 (*i)[stripable_columns.visible] = true;
1060 av->set_marked_for_display (true);
1061 update_track_visibility ();
1068 Mixer_UI::hide_strip (MixerStrip* ms)
1070 TreeModel::Children rows = track_model->children();
1071 TreeModel::Children::iterator i;
1073 for (i = rows.begin(); i != rows.end(); ++i) {
1075 AxisView* av = (*i)[stripable_columns.strip];
1076 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1078 (*i)[stripable_columns.visible] = false;
1079 av->set_marked_for_display (false);
1080 update_track_visibility ();
1087 Mixer_UI::start_updating ()
1089 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1094 Mixer_UI::stop_updating ()
1096 fast_screen_update_connection.disconnect();
1101 Mixer_UI::fast_update_strips ()
1103 if (_content.is_mapped () && _session) {
1104 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1105 (*i)->fast_update ();
1111 Mixer_UI::set_all_strips_visibility (bool yn)
1113 TreeModel::Children rows = track_model->children();
1114 TreeModel::Children::iterator i;
1117 Unwinder<bool> uw (no_track_list_redisplay, true);
1119 for (i = rows.begin(); i != rows.end(); ++i) {
1121 AxisView* av = (*i)[stripable_columns.strip];
1122 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1128 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1132 (*i)[stripable_columns.visible] = yn;
1136 redisplay_track_list ();
1141 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1143 TreeModel::Children rows = track_model->children();
1144 TreeModel::Children::iterator i;
1147 Unwinder<bool> uw (no_track_list_redisplay, true);
1149 for (i = rows.begin(); i != rows.end(); ++i) {
1151 AxisView* av = (*i)[stripable_columns.strip];
1152 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1158 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1162 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1163 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1167 (*i)[stripable_columns.visible] = yn;
1171 if (at) { /* track */
1172 (*i)[stripable_columns.visible] = yn;
1177 if (!at && !mt) { /* bus */
1178 (*i)[stripable_columns.visible] = yn;
1183 if (mt) { /* midi-track */
1184 (*i)[stripable_columns.visible] = yn;
1191 redisplay_track_list ();
1195 Mixer_UI::hide_all_routes ()
1197 set_all_strips_visibility (false);
1201 Mixer_UI::show_all_routes ()
1203 set_all_strips_visibility (true);
1207 Mixer_UI::show_all_audiobus ()
1209 set_all_audio_midi_visibility (2, true);
1212 Mixer_UI::hide_all_audiobus ()
1214 set_all_audio_midi_visibility (2, false);
1218 Mixer_UI::show_all_audiotracks()
1220 set_all_audio_midi_visibility (1, true);
1223 Mixer_UI::hide_all_audiotracks ()
1225 set_all_audio_midi_visibility (1, false);
1229 Mixer_UI::show_all_miditracks()
1231 set_all_audio_midi_visibility (3, true);
1234 Mixer_UI::hide_all_miditracks ()
1236 set_all_audio_midi_visibility (3, false);
1240 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1242 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1243 sync_presentation_info_from_treeview ();
1247 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1249 /* this happens as the second step of a DnD within the treeview as well
1250 as when a row/route is actually deleted.
1252 if it was a deletion then we have to force a redisplay because
1253 order keys may not have changed.
1256 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1257 sync_presentation_info_from_treeview ();
1259 if (_route_deletion_in_progress) {
1260 redisplay_track_list ();
1265 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1267 TreeModel::Children rows = track_model->children();
1269 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
1271 AxisView* av = (*i)[stripable_columns.strip];
1272 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1275 /* we're in the middle of changing a row, don't worry */
1279 if (!strip->route()) {
1280 /* non-route element */
1284 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1288 if (strip->route()->slaved_to (vca)) {
1290 if (strip->packed()) {
1291 strip_packer.reorder_child (*strip, -1); /* put at end */
1293 strip_packer.pack_start (*strip, false, false);
1294 strip->set_packed (true);
1299 if (strip->packed()) {
1300 strip_packer.remove (*strip);
1301 strip->set_packed (false);
1308 Mixer_UI::redisplay_track_list ()
1310 if (no_track_list_redisplay) {
1314 boost::shared_ptr<VCA> sv = spilled_vca.lock ();
1317 spill_redisplay (sv);
1321 TreeModel::Children rows = track_model->children();
1322 TreeModel::Children::iterator i;
1323 uint32_t n_masters = 0;
1325 container_clear (vca_hpacker);
1326 vca_hpacker.pack_end (vca_scroller_base, true, true);
1328 for (i = rows.begin(); i != rows.end(); ++i) {
1330 AxisView* s = (*i)[stripable_columns.strip];
1331 bool const visible = (*i)[stripable_columns.visible];
1332 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1335 /* we're in the middle of changing a row, don't worry */
1339 VCAMasterStrip* vms;
1341 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1343 vca_hpacker.pack_start (*vms, false, false);
1350 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1358 if (strip->packed()) {
1359 strip_packer.reorder_child (*strip, -1); /* put at end */
1361 strip_packer.pack_start (*strip, false, false);
1362 strip->set_packed (true);
1367 if (stripable->is_master() || stripable->is_monitor()) {
1368 /* do nothing, these cannot be hidden */
1370 if (strip->packed()) {
1371 strip_packer.remove (*strip);
1372 strip->set_packed (false);
1378 /* update visibility of VCA assign buttons */
1380 if (n_masters == 0) {
1381 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1382 vca_vpacker.hide ();
1384 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1385 vca_vpacker.show ();
1388 _group_tabs->set_dirty ();
1392 Mixer_UI::strip_width_changed ()
1394 _group_tabs->set_dirty ();
1397 TreeModel::Children rows = track_model->children();
1398 TreeModel::Children::iterator i;
1401 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1402 AxisView* av = (*i)[stripable_columns.strip];
1403 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1409 bool visible = (*i)[stripable_columns.visible];
1412 strip->queue_draw();
1419 struct PresentationInfoMixerSorter
1421 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1422 if (a->is_master()) {
1423 /* master after everything else */
1425 } else if (b->is_master()) {
1426 /* everything else before master */
1429 return a->presentation_info().order () < b->presentation_info().order ();
1434 Mixer_UI::initial_track_display ()
1438 boost::shared_ptr<RouteList> routes = _session->get_routes();
1440 for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) {
1444 VCAList vcas = _session->vca_manager().vcas();
1446 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
1447 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
1450 sl.sort (PresentationInfoMixerSorter());
1453 /* These are also used inside ::add_stripables() but we need
1454 * them here because we're going to clear the track_model also.
1456 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1457 Unwinder<bool> uw2 (ignore_reorder, true);
1459 track_model->clear ();
1460 add_stripables (sl);
1463 redisplay_track_list ();
1467 Mixer_UI::show_track_list_menu ()
1469 if (track_menu == 0) {
1470 build_track_menu ();
1473 track_menu->popup (1, gtk_get_current_event_time());
1477 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1479 if (Keyboard::is_context_menu_event (ev)) {
1480 show_track_list_menu ();
1483 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1484 TreeModel::Path path;
1485 TreeViewColumn* column;
1487 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1488 TreeIter iter = track_model->get_iter (path);
1489 if ((*iter)[stripable_columns.visible]) {
1490 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1491 move_stripable_into_view (s);
1500 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1502 if (!scroller.get_hscrollbar()) {
1507 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1508 if ((*i)->route() == s) {
1511 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1519 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1520 int sl = adj->get_value();
1521 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0)));
1525 Mixer_UI::build_track_menu ()
1527 using namespace Menu_Helpers;
1528 using namespace Gtk;
1530 track_menu = new Menu;
1531 track_menu->set_name ("ArdourContextMenu");
1532 MenuList& items = track_menu->items();
1534 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1535 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1536 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1537 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1538 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1539 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1540 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1541 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1546 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1548 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1552 boost::shared_ptr<Stripable> s = ws.lock ();
1558 TreeModel::Children rows = track_model->children();
1559 TreeModel::Children::iterator i;
1561 for (i = rows.begin(); i != rows.end(); ++i) {
1562 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1566 if (what_changed.contains (ARDOUR::Properties::name)) {
1567 (*i)[stripable_columns.text] = s->name();
1570 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1571 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1572 redisplay_track_list ();
1579 error << _("track display list item for renamed strip not found!") << endmsg;
1583 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1585 TreeModel::Path path;
1586 TreeViewColumn* column;
1590 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1591 _group_tabs->get_menu(0)->popup (1, ev->time);
1595 TreeIter iter = group_model->get_iter (path);
1597 _group_tabs->get_menu(0)->popup (1, ev->time);
1601 RouteGroup* group = (*iter)[group_columns.group];
1603 if (Keyboard::is_context_menu_event (ev)) {
1604 _group_tabs->get_menu(group)->popup (1, ev->time);
1608 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1610 if (Keyboard::is_edit_event (ev)) {
1612 // edit_route_group (group);
1614 group_display.queue_draw();
1623 bool visible = (*iter)[group_columns.visible];
1624 (*iter)[group_columns.visible] = !visible;
1626 group_display.queue_draw();
1639 Mixer_UI::activate_all_route_groups ()
1641 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1645 Mixer_UI::disable_all_route_groups ()
1647 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1651 Mixer_UI::route_groups_changed ()
1653 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1655 _in_group_rebuild_or_clear = true;
1657 /* just rebuild the while thing */
1659 group_model->clear ();
1662 /* this is currently not used,
1663 * Mixer_UI::group_display_button_press() has a case for it,
1664 * and a commented edit_route_group() but that's n/a since 2011.
1666 * This code is left as reminder that
1667 * row[group_columns.group] = 0 has special meaning.
1671 row = *(group_model->append());
1672 row[group_columns.visible] = true;
1673 row[group_columns.text] = (_("-all-"));
1674 row[group_columns.group] = 0;
1678 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1680 _group_tabs->set_dirty ();
1681 _in_group_rebuild_or_clear = false;
1685 Mixer_UI::new_route_group ()
1687 _group_tabs->run_new_group_dialog (0, false);
1691 Mixer_UI::remove_selected_route_group ()
1693 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1694 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1700 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1703 /* selection mode is single, so rows.begin() is it */
1705 if ((iter = group_model->get_iter (*i))) {
1707 RouteGroup* rg = (*iter)[group_columns.group];
1710 _session->remove_route_group (*rg);
1716 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1718 if (in_group_row_change) {
1722 /* force an update of any mixer strips that are using this group,
1723 otherwise mix group names don't change in mixer strips
1726 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1727 if ((*i)->route_group() == group) {
1728 (*i)->route_group_changed();
1732 TreeModel::iterator i;
1733 TreeModel::Children rows = group_model->children();
1734 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1736 in_group_row_change = true;
1738 for (i = rows.begin(); i != rows.end(); ++i) {
1739 if ((*i)[group_columns.group] == group) {
1740 (*i)[group_columns.visible] = !group->is_hidden ();
1741 (*i)[group_columns.text] = group->name ();
1746 in_group_row_change = false;
1748 if (change.contains (Properties::name)) {
1749 _group_tabs->set_dirty ();
1752 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
1753 if ((*j)->route_group() == group) {
1754 if (group->is_hidden ()) {
1764 Mixer_UI::show_mixer_list (bool yn)
1767 list_vpacker.show ();
1769 list_vpacker.hide ();
1772 _show_mixer_list = yn;
1776 Mixer_UI::show_monitor_section (bool yn)
1778 if (!monitor_section()) {
1781 if (monitor_section()->tearoff().torn_off()) {
1786 monitor_section()->tearoff().show();
1788 monitor_section()->tearoff().hide();
1793 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
1798 if ((iter = group_model->get_iter (path))) {
1800 if ((group = (*iter)[group_columns.group]) == 0) {
1804 if (new_text != group->name()) {
1805 group->set_name (new_text);
1811 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
1815 if (in_group_row_change) {
1819 if ((group = (*iter)[group_columns.group]) == 0) {
1823 std::string name = (*iter)[group_columns.text];
1825 if (name != group->name()) {
1826 group->set_name (name);
1829 bool hidden = !(*iter)[group_columns.visible];
1831 if (hidden != group->is_hidden ()) {
1832 group->set_hidden (hidden, this);
1836 /** Called when a group model row is deleted, but also when the model is
1837 * reordered by a user drag-and-drop; the latter is what we are
1838 * interested in here.
1841 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
1843 if (_in_group_rebuild_or_clear) {
1847 /* Re-write the session's route group list so that the new order is preserved */
1849 list<RouteGroup*> new_list;
1851 Gtk::TreeModel::Children children = group_model->children();
1852 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
1853 RouteGroup* g = (*i)[group_columns.group];
1855 new_list.push_back (g);
1859 _session->reorder_route_groups (new_list);
1864 Mixer_UI::add_route_group (RouteGroup* group)
1866 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
1869 in_group_row_change = true;
1871 TreeModel::Row row = *(group_model->append());
1872 row[group_columns.visible] = !group->is_hidden ();
1873 row[group_columns.group] = group;
1874 if (!group->name().empty()) {
1875 row[group_columns.text] = group->name();
1877 row[group_columns.text] = _("unnamed");
1881 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
1884 TreeViewColumn* col = group_display.get_column (0);
1885 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
1886 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
1889 _group_tabs->set_dirty ();
1891 in_group_row_change = false;
1895 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
1897 using namespace Menu_Helpers;
1899 if (Keyboard::is_context_menu_event (ev)) {
1900 ARDOUR_UI::instance()->add_route ();
1908 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
1910 printf ("Mixer_UI::scroller_drag_data_received\n");
1911 if (data.get_target() != "PluginFavoritePtr") {
1912 context->drag_finish (false, false, time);
1916 const void * d = data.get_data();
1917 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1919 PluginPresetList nfos;
1921 tv->get_object_drag_data (nfos, &source);
1923 Route::ProcessorList pl;
1926 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1927 PluginPresetPtr ppp = (*i);
1928 PluginInfoPtr pip = ppp->_pip;
1929 if (!pip->is_instrument ()) {
1932 ARDOUR_UI::instance()->session_add_midi_track ((RouteGroup*) 0, 1, _("MIDI"), Config->get_strict_io (), pip, ppp->_preset.valid ? &ppp->_preset : 0, PresentationInfo::max_order);
1936 context->drag_finish (ok, false, time);
1940 Mixer_UI::set_strip_width (Width w, bool save)
1944 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1945 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
1950 struct PluginStateSorter {
1952 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
1953 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
1954 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
1955 if (aiter != _user.end() && biter != _user.end()) {
1956 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
1958 if (aiter != _user.end()) {
1961 if (biter != _user.end()) {
1964 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
1967 PluginStateSorter(std::list<std::string> user) : _user (user) {}
1969 std::list<std::string> _user;
1973 Mixer_UI::set_state (const XMLNode& node, int version)
1975 XMLProperty const * prop;
1978 Tabbable::set_state (node, version);
1980 if ((prop = node.property ("narrow-strips"))) {
1981 if (string_is_affirmative (prop->value())) {
1982 set_strip_width (Narrow);
1984 set_strip_width (Wide);
1988 if ((prop = node.property ("show-mixer"))) {
1989 if (string_is_affirmative (prop->value())) {
1994 if ((prop = node.property ("maximised"))) {
1995 bool yn = string_is_affirmative (prop->value());
1996 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer"));
1998 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
1999 bool fs = tact && tact->get_active();
2001 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2005 if ((prop = node.property ("show-mixer-list"))) {
2006 bool yn = string_is_affirmative (prop->value());
2007 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMixerList"));
2009 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2011 /* do it twice to force the change */
2012 tact->set_active (!yn);
2013 tact->set_active (yn);
2017 XMLNode* plugin_order;
2018 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2019 store_current_favorite_order ();
2020 std::list<string> order;
2021 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2022 XMLNodeConstIterator i;
2023 for (i = kids.begin(); i != kids.end(); ++i) {
2024 if ((prop = (*i)->property ("unique-id"))) {
2025 std::string unique_id = prop->value();
2026 order.push_back (unique_id);
2027 if ((prop = (*i)->property ("expanded"))) {
2028 favorite_ui_state[unique_id] = string_is_affirmative (prop->value());
2032 PluginStateSorter cmp (order);
2033 favorite_order.sort (cmp);
2034 sync_treeview_from_favorite_order ();
2040 Mixer_UI::get_state ()
2042 XMLNode* node = new XMLNode (X_("Mixer"));
2046 node->add_child_nocopy (Tabbable::get_state());
2048 snprintf(buf,sizeof(buf), "%f", rhs_pane1.get_divider());
2049 node->add_property(X_("mixer-rhs-pane1-pos"), string(buf));
2050 snprintf(buf,sizeof(buf), "%f", rhs_pane2.get_divider());
2051 node->add_property(X_("mixer-rhs_pane2-pos"), string(buf));
2052 snprintf(buf,sizeof(buf), "%f", list_hpane.get_divider());
2053 node->add_property(X_("mixer-list-hpane-pos"), string(buf));
2054 snprintf(buf,sizeof(buf), "%f", inner_pane.get_divider());
2055 node->add_property(X_("mixer-inner-pane-pos"), string(buf));
2057 node->add_property ("narrow-strips", _strip_width == Narrow ? "yes" : "no");
2058 node->add_property ("show-mixer", _visible ? "yes" : "no");
2059 node->add_property ("show-mixer-list", _show_mixer_list ? "yes" : "no");
2060 node->add_property ("maximised", _maximised ? "yes" : "no");
2062 store_current_favorite_order ();
2063 XMLNode* plugin_order = new XMLNode ("PluginOrder");
2065 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2066 XMLNode* p = new XMLNode ("PluginInfo");
2067 p->add_property ("sort", cnt);
2068 p->add_property ("unique-id", (*i)->unique_id);
2069 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2070 p->add_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2072 plugin_order->add_child_nocopy (*p);
2074 node->add_child_nocopy (*plugin_order);
2080 Mixer_UI::scroll_left ()
2082 if (!scroller.get_hscrollbar()) return;
2083 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2084 int sc_w = scroller.get_width();
2085 int sp_w = strip_packer.get_width();
2089 int lp = adj->get_value();
2091 using namespace Gtk::Box_Helpers;
2092 const BoxList& strips = strip_packer.children();
2093 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2094 lm += i->get_widget()->get_width ();
2096 lm -= i->get_widget()->get_width ();
2100 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2104 Mixer_UI::scroll_right ()
2106 if (!scroller.get_hscrollbar()) return;
2107 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2108 int sc_w = scroller.get_width();
2109 int sp_w = strip_packer.get_width();
2113 int lp = adj->get_value();
2115 using namespace Gtk::Box_Helpers;
2116 const BoxList& strips = strip_packer.children();
2117 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2118 lm += i->get_widget()->get_width ();
2123 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2127 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2129 switch (ev->direction) {
2130 case GDK_SCROLL_LEFT:
2134 if (ev->state & Keyboard::TertiaryModifier) {
2140 case GDK_SCROLL_RIGHT:
2144 case GDK_SCROLL_DOWN:
2145 if (ev->state & Keyboard::TertiaryModifier) {
2157 Mixer_UI::parameter_changed (string const & p)
2159 if (p == "show-group-tabs") {
2160 bool const s = _session->config.get_show_group_tabs ();
2162 _group_tabs->show ();
2164 _group_tabs->hide ();
2166 } else if (p == "default-narrow_ms") {
2167 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2168 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2169 (*i)->set_width_enum (s ? Narrow : Wide, this);
2171 } else if (p == "use-monitor-bus") {
2172 if (_session && !_session->monitor_out()) {
2173 monitor_section_detached ();
2179 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2181 g->set_active (a, this);
2185 Mixer_UI::plugin_selector()
2187 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2188 if (!_plugin_selector)
2189 _plugin_selector = new PluginSelector (PluginManager::instance());
2192 return _plugin_selector;
2196 Mixer_UI::setup_track_display ()
2198 track_model = ListStore::create (stripable_columns);
2199 track_display.set_model (track_model);
2200 track_display.append_column (_("Show"), stripable_columns.visible);
2201 track_display.append_column (_("Strips"), stripable_columns.text);
2202 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2203 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2204 track_display.get_column (0)->set_expand(false);
2205 track_display.get_column (1)->set_expand(true);
2206 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2207 track_display.set_name (X_("EditGroupList"));
2208 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2209 track_display.set_reorderable (true);
2210 track_display.set_headers_visible (true);
2211 track_display.set_can_focus(false);
2213 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2214 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2216 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2217 track_list_visible_cell->property_activatable() = true;
2218 track_list_visible_cell->property_radio() = false;
2219 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2221 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2223 track_display_scroller.add (track_display);
2224 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2226 VBox* v = manage (new VBox);
2228 v->pack_start (track_display_scroller, true, true);
2230 Button* b = manage (new Button);
2232 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
2236 b->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
2238 v->pack_start (*b, false, false);
2240 track_display_frame.set_name("BaseFrame");
2241 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2242 track_display_frame.add (*v);
2244 track_display_scroller.show();
2245 track_display_frame.show();
2246 track_display.show();
2250 Mixer_UI::new_track_or_bus ()
2252 ARDOUR_UI::instance()->add_route ();
2256 Mixer_UI::update_title ()
2258 if (!own_window()) {
2265 if (_session->snap_name() != _session->name()) {
2266 n = _session->snap_name ();
2268 n = _session->name ();
2271 if (_session->dirty ()) {
2275 WindowTitle title (n);
2276 title += S_("Window|Mixer");
2277 title += Glib::get_application_name ();
2278 own_window()->set_title (title.get_string());
2282 WindowTitle title (S_("Window|Mixer"));
2283 title += Glib::get_application_name ();
2284 own_window()->set_title (title.get_string());
2289 Mixer_UI::strip_by_x (int x)
2291 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2294 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2295 x2 = x1 + (*i)->get_width();
2297 if (x >= x1 && x <= x2) {
2306 Mixer_UI::set_axis_targets_for_operation ()
2308 _axis_targets.clear ();
2310 if (!_selection.empty()) {
2311 _axis_targets = _selection.axes;
2315 // removed "implicit" selections of strips, after discussion on IRC
2320 Mixer_UI::monitor_section_going_away ()
2322 if (_monitor_section) {
2323 monitor_section_detached ();
2324 out_packer.remove (_monitor_section->tearoff());
2325 _monitor_section->set_session (0);
2326 delete _monitor_section;
2327 _monitor_section = 0;
2332 Mixer_UI::toggle_midi_input_active (bool flip_others)
2334 boost::shared_ptr<RouteList> rl (new RouteList);
2337 set_axis_targets_for_operation ();
2339 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2340 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2344 onoff = !mt->input_active();
2348 _session->set_exclusive_input_active (rl, onoff, flip_others);
2352 Mixer_UI::maximise_mixer_space ()
2354 if (!own_window()) {
2362 _window->fullscreen ();
2367 Mixer_UI::restore_mixer_space ()
2369 if (!own_window()) {
2377 own_window()->unfullscreen();
2382 Mixer_UI::monitor_section_attached ()
2384 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2385 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2386 act->set_sensitive (true);
2387 tact->set_active ();
2391 Mixer_UI::monitor_section_detached ()
2393 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2394 act->set_sensitive (false);
2398 Mixer_UI::store_current_favorite_order ()
2400 typedef Gtk::TreeModel::Children type_children;
2401 type_children children = favorite_plugins_model->children();
2402 favorite_order.clear();
2403 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2405 Gtk::TreeModel::Row row = *iter;
2406 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2407 favorite_order.push_back (ppp->_pip);
2408 std::string name = row[favorite_plugins_columns.name];
2409 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2414 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2416 Gtk::TreeModel::Row row = *iter;
2417 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2419 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2423 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2425 PluginManager& manager (PluginManager::instance());
2426 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2427 if (manager.get_status (*i) != PluginManager::Favorite) {
2430 result.push_back (*i);
2434 struct PluginCustomSorter {
2436 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2437 PluginInfoList::const_iterator aiter = _user.begin();
2438 PluginInfoList::const_iterator biter = _user.begin();
2439 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2440 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2442 if (aiter != _user.end() && biter != _user.end()) {
2443 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2445 if (aiter != _user.end()) {
2448 if (biter != _user.end()) {
2451 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2453 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2455 PluginInfoList _user;
2459 Mixer_UI::refill_favorite_plugins ()
2461 PluginInfoList plugs;
2462 PluginManager& mgr (PluginManager::instance());
2465 refiller (plugs, mgr.lv2_plugin_info ());
2467 #ifdef WINDOWS_VST_SUPPORT
2468 refiller (plugs, mgr.windows_vst_plugin_info ());
2470 #ifdef LXVST_SUPPORT
2471 refiller (plugs, mgr.lxvst_plugin_info ());
2473 #ifdef AUDIOUNIT_SUPPORT
2474 refiller (plugs, mgr.au_plugin_info ());
2476 refiller (plugs, mgr.ladspa_plugin_info ());
2477 refiller (plugs, mgr.lua_plugin_info ());
2479 store_current_favorite_order ();
2481 PluginCustomSorter cmp (favorite_order);
2484 favorite_order = plugs;
2486 sync_treeview_from_favorite_order ();
2490 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2493 if (!(iter = favorite_plugins_model->get_iter (path))) {
2496 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2500 PluginInfoPtr pip = ppp->_pip;
2501 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2502 if (favorite_ui_state[pip->unique_id]) {
2503 favorite_plugins_display.expand_row (path, true);
2509 Mixer_UI::sync_treeview_from_favorite_order ()
2511 favorite_plugins_model->clear ();
2512 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
2513 PluginInfoPtr pip = (*i);
2515 TreeModel::Row newrow = *(favorite_plugins_model->append());
2516 newrow[favorite_plugins_columns.name] = (*i)->name;
2517 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
2522 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
2523 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
2524 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
2525 child_row[favorite_plugins_columns.name] = (*j).label;
2526 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
2528 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2529 if (favorite_ui_state[pip->unique_id]) {
2530 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
2537 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
2539 using namespace Gtk::Menu_Helpers;
2541 Gtk::Menu* m = manage (new Menu);
2542 MenuList& items = m->items ();
2544 if (_selection.axes.empty()) {
2545 items.push_back (MenuElem (_("No Track/Bus is selected.")));
2547 items.push_back (MenuElem (_("Add at the top"),
2548 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
2549 items.push_back (MenuElem (_("Add Pre-Fader"),
2550 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
2551 items.push_back (MenuElem (_("Add Post-Fader"),
2552 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
2553 items.push_back (MenuElem (_("Add at the end"),
2554 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
2557 items.push_back (SeparatorElem());
2559 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
2561 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2562 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
2563 // we cannot currently delete AU presets
2564 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
2565 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
2569 m->popup (ev->button, ev->time);
2573 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
2575 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) {
2576 TreeModel::Path path;
2577 TreeViewColumn* column;
2579 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
2580 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2582 selection->unselect_all();
2583 selection->select(path);
2586 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2588 popup_note_context_menu (ev);
2596 Mixer_UI::selected_plugin ()
2598 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2600 return PluginPresetPtr();
2602 Gtk::TreeModel::iterator iter = selection->get_selected();
2604 return PluginPresetPtr();
2606 return (*iter)[favorite_plugins_columns.plugin];
2610 Mixer_UI::add_selected_processor (ProcessorPosition pos)
2612 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2614 add_favorite_processor (ppp, pos);
2619 Mixer_UI::delete_selected_preset ()
2624 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2625 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
2628 PluginPtr plugin = ppp->_pip->load (*_session);
2629 plugin->get_presets();
2630 plugin->remove_preset (ppp->_preset.label);
2634 Mixer_UI::remove_selected_from_favorites ()
2636 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2640 PluginManager::PluginStatusType status = PluginManager::Normal;
2641 PluginManager& manager (PluginManager::instance());
2643 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2644 manager.save_statuses ();
2648 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
2651 if (!(iter = favorite_plugins_model->get_iter (path))) {
2654 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2655 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
2659 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
2661 if (!_session || _selection.axes.empty()) {
2665 PluginInfoPtr pip = ppp->_pip;
2666 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
2667 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
2673 PluginPtr p = pip->load (*_session);
2679 if (ppp->_preset.valid) {
2680 p->load_preset (ppp->_preset);
2683 Route::ProcessorStreams err;
2684 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2688 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
2691 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
2698 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
2702 if (!np->display_to_user()) {
2705 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
2706 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
2711 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
2715 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
2722 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
2724 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
2728 // only allow to re-order top-level items
2730 if (TreePath::get_from_selection_data (data, src)) {
2731 if (src.up() && src.up()) {
2736 // don't allow to drop as child-rows.
2737 Gtk::TreeModel::Path _dest = dest; // un const
2738 const bool is_child = _dest.up (); // explicit bool for clang
2739 if (!is_child || _dest.empty ()) {
2746 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
2748 if (data.get_target() != "PluginPresetPtr") {
2751 if (data.get_length() != sizeof (PluginPresetPtr)) {
2754 const void *d = data.get_data();
2755 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
2757 PluginManager::PluginStatusType status = PluginManager::Favorite;
2758 PluginManager& manager (PluginManager::instance());
2760 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2761 manager.save_statuses ();
2765 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
2767 /* call protected MixerActor:: method */
2772 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
2774 /* call protected MixerActor:: method */
2779 Mixer_UI::show_vca_slaves (boost::shared_ptr<VCA> vca)
2781 boost::shared_ptr<VCA> v = spilled_vca.lock();
2784 show_vca_change (vca); /* EMIT SIGNAL */
2786 _group_tabs->hide ();
2788 _group_tabs->show ();
2790 redisplay_track_list ();
2795 Mixer_UI::showing_vca_slaves_for (boost::shared_ptr<VCA> vca) const
2797 return vca == spilled_vca.lock();
2801 Mixer_UI::register_actions ()
2803 Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
2805 myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
2806 myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
2807 myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
2808 myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
2809 myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
2810 myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
2813 myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
2814 myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
2815 myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
2816 myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
2817 myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
2818 myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
2819 myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
2820 myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
2822 myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
2823 myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
2825 myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
2826 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
2830 Mixer_UI::load_bindings ()
2832 bindings = Bindings::get_bindings (X_("Mixer"), myactions);
2835 template<class T> void
2836 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
2838 boost::shared_ptr<ControlList> cl (new ControlList);
2839 boost::shared_ptr<AutomationControl> ac;
2841 bool have_val = false;
2843 set_axis_targets_for_operation ();
2845 BOOST_FOREACH(AxisView* r, _axis_targets) {
2846 boost::shared_ptr<Stripable> s = r->stripable();
2848 ac = (s.get()->*get_control)();
2852 val = !ac->get_value();
2859 _session->set_controls (cl, val, Controllable::UseGroup);
2863 Mixer_UI::solo_action ()
2865 control_action (&Stripable::solo_control);
2869 Mixer_UI::mute_action ()
2871 control_action (&Stripable::mute_control);
2875 Mixer_UI::rec_enable_action ()
2877 control_action (&Stripable::rec_enable_control);
2881 Mixer_UI::step_gain_up_action ()
2883 set_axis_targets_for_operation ();
2885 BOOST_FOREACH(AxisView* r, _axis_targets) {
2886 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2888 ms->step_gain_up ();
2894 Mixer_UI::step_gain_down_action ()
2896 set_axis_targets_for_operation ();
2898 BOOST_FOREACH(AxisView* r, _axis_targets) {
2899 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2901 ms->step_gain_down ();
2907 Mixer_UI::unity_gain_action ()
2909 set_axis_targets_for_operation ();
2911 BOOST_FOREACH(AxisView* r, _axis_targets) {
2912 boost::shared_ptr<Stripable> s = r->stripable();
2914 boost::shared_ptr<AutomationControl> ac = s->gain_control();
2916 ac->set_value (1.0, Controllable::UseGroup);
2923 Mixer_UI::copy_processors ()
2925 set_axis_targets_for_operation ();
2927 BOOST_FOREACH(AxisView* r, _axis_targets) {
2928 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2930 ms->copy_processors ();
2935 Mixer_UI::cut_processors ()
2937 set_axis_targets_for_operation ();
2939 BOOST_FOREACH(AxisView* r, _axis_targets) {
2940 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2942 ms->cut_processors ();
2947 Mixer_UI::paste_processors ()
2949 set_axis_targets_for_operation ();
2951 BOOST_FOREACH(AxisView* r, _axis_targets) {
2952 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2954 ms->paste_processors ();
2959 Mixer_UI::select_all_processors ()
2961 set_axis_targets_for_operation ();
2963 BOOST_FOREACH(AxisView* r, _axis_targets) {
2964 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2966 ms->select_all_processors ();
2971 Mixer_UI::toggle_processors ()
2973 set_axis_targets_for_operation ();
2975 BOOST_FOREACH(AxisView* r, _axis_targets) {
2976 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2978 ms->toggle_processors ();
2983 Mixer_UI::ab_plugins ()
2985 set_axis_targets_for_operation ();
2987 BOOST_FOREACH(AxisView* r, _axis_targets) {
2988 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2996 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
2998 set_axis_targets_for_operation ();
3000 BOOST_FOREACH(AxisView* r, _axis_targets) {
3001 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3003 ms->vca_assign (vca);
3010 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3012 set_axis_targets_for_operation ();
3014 BOOST_FOREACH(AxisView* r, _axis_targets) {
3015 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3017 ms->vca_unassign (vca);