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);
141 b->set_border_width (0);
142 b->pack_start (*_group_tabs, PACK_SHRINK);
143 b->pack_start (strip_packer);
147 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
149 setup_track_display ();
151 group_model = ListStore::create (group_columns);
152 group_display.set_model (group_model);
153 group_display.append_column (_("Show"), group_columns.visible);
154 group_display.append_column (_("Group"), group_columns.text);
155 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
156 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
157 group_display.get_column (0)->set_expand(false);
158 group_display.get_column (1)->set_expand(true);
159 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
160 group_display.set_name ("EditGroupList");
161 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
162 group_display.set_reorderable (true);
163 group_display.set_headers_visible (true);
164 group_display.set_rules_hint (true);
165 group_display.set_can_focus(false);
167 /* name is directly editable */
169 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
170 name_cell->property_editable() = true;
171 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
173 /* use checkbox for the active column */
175 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
176 active_cell->property_activatable() = true;
177 active_cell->property_radio() = false;
179 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
180 /* We use this to notice drag-and-drop reorders of the group list */
181 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
182 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
184 group_display_scroller.add (group_display);
185 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
187 HBox* route_group_display_button_box = manage (new HBox());
189 Button* route_group_add_button = manage (new Button ());
190 Button* route_group_remove_button = manage (new Button ());
194 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
196 route_group_add_button->add (*w);
198 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
200 route_group_remove_button->add (*w);
202 route_group_display_button_box->set_homogeneous (true);
204 route_group_add_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_route_group));
205 route_group_remove_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::remove_selected_route_group));
207 route_group_display_button_box->add (*route_group_add_button);
208 route_group_display_button_box->add (*route_group_remove_button);
210 group_display_vbox.pack_start (group_display_scroller, true, true);
211 group_display_vbox.pack_start (*route_group_display_button_box, false, false);
213 group_display_frame.set_name ("BaseFrame");
214 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
215 group_display_frame.add (group_display_vbox);
218 list<TargetEntry> target_list;
219 target_list.push_back (TargetEntry ("PluginPresetPtr"));
221 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
222 favorite_plugins_display.set_model (favorite_plugins_model);
223 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
224 favorite_plugins_display.set_name ("EditGroupList");
225 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
226 favorite_plugins_display.set_reorderable (false);
227 favorite_plugins_display.set_headers_visible (true);
228 favorite_plugins_display.set_rules_hint (true);
229 favorite_plugins_display.set_can_focus (false);
230 favorite_plugins_display.set_tooltip_column (0);
231 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
232 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
233 favorite_plugins_display.add_drop_targets (target_list);
234 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
235 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
236 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
237 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
238 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
239 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
241 favorite_plugins_scroller.add (favorite_plugins_display);
242 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
244 favorite_plugins_frame.set_name ("BaseFrame");
245 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
246 favorite_plugins_frame.add (favorite_plugins_scroller);
248 rhs_pane1.add (favorite_plugins_frame);
249 rhs_pane1.add (track_display_frame);
251 rhs_pane2.add (rhs_pane1);
252 rhs_pane2.add (group_display_frame);
254 list_vpacker.pack_start (rhs_pane2, true, true);
256 string vca_text = _("Control Masters");
257 vca_label.set_text (vca_text);
258 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
261 vca_label_bar.set_name (X_("VCALabelBar"));
262 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();
354 vca_label_bar.show();
356 vca_scroller_base.show();
359 group_display.show();
360 favorite_plugins_display.show();
362 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
366 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
368 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
369 _plugin_selector = new PluginSelector (PluginManager::instance ());
371 #error implement deferred Plugin-Favorite list
373 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
374 PluginManager::instance ().PluginStatusesChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
375 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
378 Mixer_UI::~Mixer_UI ()
380 if (_monitor_section) {
381 monitor_section_detached ();
382 delete _monitor_section;
384 delete _plugin_selector;
394 Mixer_UI::track_editor_selection ()
396 PublicEditor::instance().get_selection().TracksChanged.connect (sigc::mem_fun (*this, &Mixer_UI::follow_editor_selection));
400 Mixer_UI::use_own_window (bool and_fill_it)
402 bool new_window = !own_window();
404 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
407 if (win && new_window) {
408 win->set_name ("MixerWindow");
409 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
410 win->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
411 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
412 win->set_data ("ardour-bindings", bindings);
420 Mixer_UI::show_window ()
422 Tabbable::show_window ();
424 /* show/hide group tabs as required */
425 parameter_changed ("show-group-tabs");
427 /* now reset each strips width so the right widgets are shown */
429 TreeModel::Children rows = track_model->children();
430 TreeModel::Children::iterator ri;
432 for (ri = rows.begin(); ri != rows.end(); ++ri) {
433 AxisView* av = (*ri)[stripable_columns.strip];
434 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
438 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
439 /* Fix visibility of mixer strip stuff */
440 ms->parameter_changed (X_("mixer-element-visibility"));
443 /* force focus into main area */
444 scroller_base.grab_focus ();
448 Mixer_UI::remove_master (VCAMasterStrip* vms)
450 if (_session && _session->deletion_in_progress()) {
451 /* its all being taken care of */
455 TreeModel::Children rows = track_model->children();
456 TreeModel::Children::iterator ri;
458 for (ri = rows.begin(); ri != rows.end(); ++ri) {
459 if ((*ri)[stripable_columns.strip] == vms) {
460 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
461 track_model->erase (ri);
468 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
470 using namespace Menu_Helpers;
472 if (Keyboard::is_context_menu_event (ev)) {
473 ARDOUR_UI::instance()->add_route ();
481 Mixer_UI::add_masters (VCAList& vlist)
485 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
486 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
493 Mixer_UI::add_routes (RouteList& rlist)
497 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
505 Mixer_UI::add_stripables (StripableList& slist)
507 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
508 bool from_scratch = (track_model->children().size() == 0);
509 uint32_t nroutes = 0;
511 slist.sort (StripablePresentationInfoSorter());
513 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
514 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
522 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
532 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
534 track_display.set_model (Glib::RefPtr<ListStore>());
536 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
538 boost::shared_ptr<Route> route;
539 boost::shared_ptr<VCA> vca;
541 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
543 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
545 TreeModel::Row row = *(track_model->append());
547 row[stripable_columns.text] = vca->name();
548 row[stripable_columns.visible] = vms->marked_for_display ();
549 row[stripable_columns.strip] = vms;
550 row[stripable_columns.stripable] = vca;
552 vms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
554 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
556 if (route->is_auditioner()) {
560 if (route->is_monitor()) {
562 if (!_monitor_section) {
563 _monitor_section = new MonitorSection (_session);
565 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
567 _monitor_section->tearoff().set_state (*mnode);
571 out_packer.pack_end (_monitor_section->tearoff(), false, false);
572 _monitor_section->set_session (_session);
573 _monitor_section->tearoff().show_all ();
575 _monitor_section->tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
576 _monitor_section->tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
578 monitor_section_attached ();
580 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
582 /* no regular strip shown for control out */
587 strip = new MixerStrip (*this, _session, route);
588 strips.push_back (strip);
590 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
592 if (strip->width_owner() != strip) {
593 strip->set_width_enum (_strip_width, this);
598 if (!route->is_master()) {
600 TreeModel::Row row = *(track_model->insert (insert_iter));
602 row[stripable_columns.text] = route->name();
603 row[stripable_columns.visible] = strip->marked_for_display();
604 row[stripable_columns.stripable] = route;
605 row[stripable_columns.strip] = strip;
608 _selection.add (strip);
613 out_packer.pack_start (*strip, false, false);
614 strip->set_packed (true);
617 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
618 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
621 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
622 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
625 } catch (const std::exception& e) {
626 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
629 track_display.set_model (track_model);
632 sync_presentation_info_from_treeview ();
635 redisplay_track_list ();
639 Mixer_UI::deselect_all_strip_processors ()
641 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
642 (*i)->deselect_all_processors();
647 Mixer_UI::select_strip (MixerStrip& ms, bool add)
650 _selection.add (&ms);
652 _selection.set (&ms);
657 Mixer_UI::select_none ()
659 _selection.clear_routes();
660 deselect_all_strip_processors();
664 Mixer_UI::delete_processors ()
666 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
667 (*i)->delete_processors();
673 Mixer_UI::remove_strip (MixerStrip* strip)
675 if (_session && _session->deletion_in_progress()) {
676 /* its all being taken care of */
680 TreeModel::Children rows = track_model->children();
681 TreeModel::Children::iterator ri;
682 list<MixerStrip *>::iterator i;
684 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
688 for (ri = rows.begin(); ri != rows.end(); ++ri) {
689 if ((*ri)[stripable_columns.strip] == strip) {
690 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
691 track_model->erase (ri);
698 Mixer_UI::sync_presentation_info_from_treeview ()
700 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
704 TreeModel::Children rows = track_model->children();
710 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
712 TreeModel::Children::iterator ri;
716 // special case master if it's got PI order 0 lets keep it there
717 if (_session->master_out() && (_session->master_out()->presentation_info().order() == 0)) {
721 for (ri = rows.begin(); ri != rows.end(); ++ri) {
722 bool visible = (*ri)[stripable_columns.visible];
723 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
729 /* Monitor and Auditioner do not get their presentation
733 if (stripable->is_monitor() || stripable->is_auditioner()) {
737 /* Master also doesn't get set here but since the editor allows
738 * it to be reordered, we need to preserve its ordering.
741 stripable->presentation_info().set_hidden (!visible);
743 // master may not get set here, but if it is zero keep it there
744 if (stripable->is_master() && (stripable->presentation_info().order() == 0)) {
748 if (order != stripable->presentation_info().order()) {
749 stripable->set_presentation_order (order, false);
757 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
758 _session->notify_presentation_info_change ();
759 _session->set_dirty();
764 Mixer_UI::sync_treeview_from_presentation_info ()
766 if (!_session || _session->deletion_in_progress()) {
770 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
772 /* we could get here after either a change in the Mixer or Editor sort
773 * order, but either way, the mixer order keys reflect the intended
774 * order for the GUI, so reorder the treeview model to match it.
777 vector<int> neworder;
778 TreeModel::Children rows = track_model->children();
779 uint32_t old_order = 0;
780 bool changed = false;
788 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
789 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
790 sorted.push_back (OrderKeys (old_order, stripable->presentation_info().order()));
793 SortByNewDisplayOrder cmp;
795 sort (sorted.begin(), sorted.end(), cmp);
796 neworder.assign (sorted.size(), 0);
800 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
802 neworder[n] = sr->old_display_order;
804 if (sr->old_display_order != n) {
810 Unwinder<bool> uw (ignore_reorder, true);
811 track_model->reorder (neworder);
814 redisplay_track_list ();
818 Mixer_UI::follow_editor_selection ()
820 if (_following_editor_selection) {
824 _following_editor_selection = true;
825 _selection.block_routes_changed (true);
827 TrackSelection& s (PublicEditor::instance().get_selection().tracks);
829 _selection.clear_routes ();
831 for (TrackViewList::iterator i = s.begin(); i != s.end(); ++i) {
832 TimeAxisView* tav = dynamic_cast<TimeAxisView*> (*i);
834 AxisView* axis = axis_by_stripable (tav->stripable());
836 _selection.add (axis);
841 _following_editor_selection = false;
842 _selection.block_routes_changed (false);
847 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
849 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
850 if ((*i)->route() == r) {
859 Mixer_UI::axis_by_stripable (boost::shared_ptr<Stripable> s) const
861 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
862 if ((*i)->stripable() == s) {
871 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
873 if (ev->button == 1) {
874 if (_selection.selected (strip)) {
875 /* primary-click: toggle selection state of strip */
876 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
877 _selection.remove (strip);
878 } else if (_selection.axes.size() > 1) {
879 /* de-select others */
880 _selection.set (strip);
883 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
884 _selection.add (strip);
885 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
887 /* extend selection */
889 vector<MixerStrip*> tmp;
890 bool accumulate = false;
891 bool found_another = false;
893 tmp.push_back (strip);
895 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
897 /* hit clicked strip, start accumulating till we hit the first
906 } else if (_selection.selected (*i)) {
907 /* hit selected strip. if currently accumulating others,
908 we're done. if not accumulating others, start doing so.
910 found_another = true;
925 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
929 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
931 _selection.set (strip);
940 Mixer_UI::set_session (Session* sess)
942 SessionHandlePtr::set_session (sess);
944 if (_plugin_selector) {
945 _plugin_selector->set_session (_session);
948 _group_tabs->set_session (sess);
950 if (_monitor_section) {
951 _monitor_section->set_session (_session);
958 refill_favorite_plugins();
960 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
961 set_state (*node, 0);
965 initial_track_display ();
967 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
968 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
969 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
970 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
971 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
972 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
973 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
975 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
977 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
979 route_groups_changed ();
988 Mixer_UI::session_going_away ()
990 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
992 _in_group_rebuild_or_clear = true;
993 group_model->clear ();
994 _in_group_rebuild_or_clear = false;
997 track_model->clear ();
999 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1003 if (_monitor_section) {
1004 _monitor_section->tearoff().hide_visible ();
1007 monitor_section_detached ();
1013 SessionHandlePtr::session_going_away ();
1020 Mixer_UI::track_visibility_changed (std::string const & path)
1022 if (_session && _session->deletion_in_progress()) {
1028 if ((iter = track_model->get_iter (path))) {
1030 AxisView* av = (*iter)[stripable_columns.strip];
1031 bool visible = (*iter)[stripable_columns.visible];
1033 if (av->set_marked_for_display (!visible)) {
1034 update_track_visibility ();
1040 Mixer_UI::update_track_visibility ()
1042 TreeModel::Children rows = track_model->children();
1043 TreeModel::Children::iterator i;
1046 Unwinder<bool> uw (no_track_list_redisplay, true);
1048 for (i = rows.begin(); i != rows.end(); ++i) {
1049 AxisView* av = (*i)[stripable_columns.strip];
1050 (*i)[stripable_columns.visible] = av->marked_for_display ();
1053 /* force presentation catch up with visibility changes
1056 sync_presentation_info_from_treeview ();
1059 redisplay_track_list ();
1063 Mixer_UI::show_strip (MixerStrip* ms)
1065 TreeModel::Children rows = track_model->children();
1066 TreeModel::Children::iterator i;
1068 for (i = rows.begin(); i != rows.end(); ++i) {
1070 AxisView* av = (*i)[stripable_columns.strip];
1071 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1073 (*i)[stripable_columns.visible] = true;
1074 av->set_marked_for_display (true);
1075 update_track_visibility ();
1082 Mixer_UI::hide_strip (MixerStrip* ms)
1084 TreeModel::Children rows = track_model->children();
1085 TreeModel::Children::iterator i;
1087 for (i = rows.begin(); i != rows.end(); ++i) {
1089 AxisView* av = (*i)[stripable_columns.strip];
1090 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1092 (*i)[stripable_columns.visible] = false;
1093 av->set_marked_for_display (false);
1094 update_track_visibility ();
1101 Mixer_UI::start_updating ()
1103 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1108 Mixer_UI::stop_updating ()
1110 fast_screen_update_connection.disconnect();
1115 Mixer_UI::fast_update_strips ()
1117 if (_content.is_mapped () && _session) {
1118 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1119 (*i)->fast_update ();
1125 Mixer_UI::set_all_strips_visibility (bool yn)
1127 TreeModel::Children rows = track_model->children();
1128 TreeModel::Children::iterator i;
1131 Unwinder<bool> uw (no_track_list_redisplay, true);
1133 for (i = rows.begin(); i != rows.end(); ++i) {
1135 AxisView* av = (*i)[stripable_columns.strip];
1136 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1142 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1146 (*i)[stripable_columns.visible] = yn;
1150 redisplay_track_list ();
1155 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1157 TreeModel::Children rows = track_model->children();
1158 TreeModel::Children::iterator i;
1161 Unwinder<bool> uw (no_track_list_redisplay, true);
1163 for (i = rows.begin(); i != rows.end(); ++i) {
1165 AxisView* av = (*i)[stripable_columns.strip];
1166 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1172 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1176 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1177 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1181 (*i)[stripable_columns.visible] = yn;
1185 if (at) { /* track */
1186 (*i)[stripable_columns.visible] = yn;
1191 if (!at && !mt) { /* bus */
1192 (*i)[stripable_columns.visible] = yn;
1197 if (mt) { /* midi-track */
1198 (*i)[stripable_columns.visible] = yn;
1205 redisplay_track_list ();
1209 Mixer_UI::hide_all_routes ()
1211 set_all_strips_visibility (false);
1215 Mixer_UI::show_all_routes ()
1217 set_all_strips_visibility (true);
1221 Mixer_UI::show_all_audiobus ()
1223 set_all_audio_midi_visibility (2, true);
1226 Mixer_UI::hide_all_audiobus ()
1228 set_all_audio_midi_visibility (2, false);
1232 Mixer_UI::show_all_audiotracks()
1234 set_all_audio_midi_visibility (1, true);
1237 Mixer_UI::hide_all_audiotracks ()
1239 set_all_audio_midi_visibility (1, false);
1243 Mixer_UI::show_all_miditracks()
1245 set_all_audio_midi_visibility (3, true);
1248 Mixer_UI::hide_all_miditracks ()
1250 set_all_audio_midi_visibility (3, false);
1254 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1256 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1257 sync_presentation_info_from_treeview ();
1261 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1263 /* this happens as the second step of a DnD within the treeview as well
1264 as when a row/route is actually deleted.
1266 if it was a deletion then we have to force a redisplay because
1267 order keys may not have changed.
1270 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1271 sync_presentation_info_from_treeview ();
1273 if (_route_deletion_in_progress) {
1274 redisplay_track_list ();
1279 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1281 TreeModel::Children rows = track_model->children();
1283 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
1285 AxisView* av = (*i)[stripable_columns.strip];
1286 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1289 /* we're in the middle of changing a row, don't worry */
1293 if (!strip->route()) {
1294 /* non-route element */
1298 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1302 if (strip->route()->slaved_to (vca)) {
1304 if (strip->packed()) {
1305 strip_packer.reorder_child (*strip, -1); /* put at end */
1307 strip_packer.pack_start (*strip, false, false);
1308 strip->set_packed (true);
1313 if (strip->packed()) {
1314 strip_packer.remove (*strip);
1315 strip->set_packed (false);
1322 Mixer_UI::redisplay_track_list ()
1324 if (no_track_list_redisplay) {
1328 boost::shared_ptr<VCA> sv = spilled_vca.lock ();
1331 spill_redisplay (sv);
1335 TreeModel::Children rows = track_model->children();
1336 TreeModel::Children::iterator i;
1337 uint32_t n_masters = 0;
1339 container_clear (vca_hpacker);
1340 vca_hpacker.pack_end (vca_scroller_base, true, true);
1342 for (i = rows.begin(); i != rows.end(); ++i) {
1344 AxisView* s = (*i)[stripable_columns.strip];
1345 bool const visible = (*i)[stripable_columns.visible];
1346 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1349 /* we're in the middle of changing a row, don't worry */
1353 VCAMasterStrip* vms;
1355 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1357 vca_hpacker.pack_start (*vms, false, false);
1364 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1372 if (strip->packed()) {
1373 strip_packer.reorder_child (*strip, -1); /* put at end */
1375 strip_packer.pack_start (*strip, false, false);
1376 strip->set_packed (true);
1381 if (stripable->is_master() || stripable->is_monitor()) {
1382 /* do nothing, these cannot be hidden */
1384 if (strip->packed()) {
1385 strip_packer.remove (*strip);
1386 strip->set_packed (false);
1392 /* update visibility of VCA assign buttons */
1394 if (n_masters == 0) {
1395 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1396 vca_vpacker.hide ();
1398 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1399 vca_vpacker.show ();
1402 _group_tabs->set_dirty ();
1406 Mixer_UI::strip_width_changed ()
1408 _group_tabs->set_dirty ();
1411 TreeModel::Children rows = track_model->children();
1412 TreeModel::Children::iterator i;
1415 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1416 AxisView* av = (*i)[stripable_columns.strip];
1417 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1423 bool visible = (*i)[stripable_columns.visible];
1426 strip->queue_draw();
1433 struct PresentationInfoMixerSorter
1435 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1436 if (a->is_master()) {
1437 /* master after everything else */
1439 } else if (b->is_master()) {
1440 /* everything else before master */
1443 return a->presentation_info().order () < b->presentation_info().order ();
1448 Mixer_UI::initial_track_display ()
1452 boost::shared_ptr<RouteList> routes = _session->get_routes();
1454 for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) {
1458 VCAList vcas = _session->vca_manager().vcas();
1460 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
1461 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
1464 sl.sort (PresentationInfoMixerSorter());
1467 /* These are also used inside ::add_stripables() but we need
1468 * them here because we're going to clear the track_model also.
1470 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1471 Unwinder<bool> uw2 (ignore_reorder, true);
1473 track_model->clear ();
1474 add_stripables (sl);
1477 redisplay_track_list ();
1481 Mixer_UI::show_track_list_menu ()
1483 if (track_menu == 0) {
1484 build_track_menu ();
1487 track_menu->popup (1, gtk_get_current_event_time());
1491 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1493 if (Keyboard::is_context_menu_event (ev)) {
1494 show_track_list_menu ();
1497 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1498 TreeModel::Path path;
1499 TreeViewColumn* column;
1501 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1502 TreeIter iter = track_model->get_iter (path);
1503 if ((*iter)[stripable_columns.visible]) {
1504 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1505 move_stripable_into_view (s);
1514 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1516 if (!scroller.get_hscrollbar()) {
1519 if (s->presentation_info().special () || s->presentation_info().flag_match (PresentationInfo::VCA)) {
1525 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1526 if ((*i)->route() == s) {
1529 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1537 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1538 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0)));
1542 Mixer_UI::build_track_menu ()
1544 using namespace Menu_Helpers;
1545 using namespace Gtk;
1547 track_menu = new Menu;
1548 track_menu->set_name ("ArdourContextMenu");
1549 MenuList& items = track_menu->items();
1551 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1552 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1553 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1554 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1555 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1556 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1557 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1558 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1563 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1565 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1569 boost::shared_ptr<Stripable> s = ws.lock ();
1575 TreeModel::Children rows = track_model->children();
1576 TreeModel::Children::iterator i;
1578 for (i = rows.begin(); i != rows.end(); ++i) {
1579 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1583 if (what_changed.contains (ARDOUR::Properties::name)) {
1584 (*i)[stripable_columns.text] = s->name();
1587 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1588 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1589 redisplay_track_list ();
1596 error << _("track display list item for renamed strip not found!") << endmsg;
1600 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1602 TreeModel::Path path;
1603 TreeViewColumn* column;
1607 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1608 _group_tabs->get_menu(0)->popup (1, ev->time);
1612 TreeIter iter = group_model->get_iter (path);
1614 _group_tabs->get_menu(0)->popup (1, ev->time);
1618 RouteGroup* group = (*iter)[group_columns.group];
1620 if (Keyboard::is_context_menu_event (ev)) {
1621 _group_tabs->get_menu(group)->popup (1, ev->time);
1625 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1627 if (Keyboard::is_edit_event (ev)) {
1629 // edit_route_group (group);
1631 group_display.queue_draw();
1640 bool visible = (*iter)[group_columns.visible];
1641 (*iter)[group_columns.visible] = !visible;
1643 group_display.queue_draw();
1656 Mixer_UI::activate_all_route_groups ()
1658 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1662 Mixer_UI::disable_all_route_groups ()
1664 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1668 Mixer_UI::route_groups_changed ()
1670 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1672 _in_group_rebuild_or_clear = true;
1674 /* just rebuild the while thing */
1676 group_model->clear ();
1679 /* this is currently not used,
1680 * Mixer_UI::group_display_button_press() has a case for it,
1681 * and a commented edit_route_group() but that's n/a since 2011.
1683 * This code is left as reminder that
1684 * row[group_columns.group] = 0 has special meaning.
1688 row = *(group_model->append());
1689 row[group_columns.visible] = true;
1690 row[group_columns.text] = (_("-all-"));
1691 row[group_columns.group] = 0;
1695 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1697 _group_tabs->set_dirty ();
1698 _in_group_rebuild_or_clear = false;
1702 Mixer_UI::new_route_group ()
1704 _group_tabs->run_new_group_dialog (0, false);
1708 Mixer_UI::remove_selected_route_group ()
1710 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1711 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1717 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1720 /* selection mode is single, so rows.begin() is it */
1722 if ((iter = group_model->get_iter (*i))) {
1724 RouteGroup* rg = (*iter)[group_columns.group];
1727 _session->remove_route_group (*rg);
1733 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1735 if (in_group_row_change) {
1739 /* force an update of any mixer strips that are using this group,
1740 otherwise mix group names don't change in mixer strips
1743 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1744 if ((*i)->route_group() == group) {
1745 (*i)->route_group_changed();
1749 TreeModel::iterator i;
1750 TreeModel::Children rows = group_model->children();
1751 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1753 in_group_row_change = true;
1755 for (i = rows.begin(); i != rows.end(); ++i) {
1756 if ((*i)[group_columns.group] == group) {
1757 (*i)[group_columns.visible] = !group->is_hidden ();
1758 (*i)[group_columns.text] = group->name ();
1763 in_group_row_change = false;
1765 if (change.contains (Properties::name)) {
1766 _group_tabs->set_dirty ();
1769 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
1770 if ((*j)->route_group() == group) {
1771 if (group->is_hidden ()) {
1781 Mixer_UI::show_mixer_list (bool yn)
1784 list_vpacker.show ();
1786 list_vpacker.hide ();
1789 _show_mixer_list = yn;
1793 Mixer_UI::show_monitor_section (bool yn)
1795 if (!monitor_section()) {
1798 if (monitor_section()->tearoff().torn_off()) {
1803 monitor_section()->tearoff().show();
1805 monitor_section()->tearoff().hide();
1810 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
1815 if ((iter = group_model->get_iter (path))) {
1817 if ((group = (*iter)[group_columns.group]) == 0) {
1821 if (new_text != group->name()) {
1822 group->set_name (new_text);
1828 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
1832 if (in_group_row_change) {
1836 if ((group = (*iter)[group_columns.group]) == 0) {
1840 std::string name = (*iter)[group_columns.text];
1842 if (name != group->name()) {
1843 group->set_name (name);
1846 bool hidden = !(*iter)[group_columns.visible];
1848 if (hidden != group->is_hidden ()) {
1849 group->set_hidden (hidden, this);
1853 /** Called when a group model row is deleted, but also when the model is
1854 * reordered by a user drag-and-drop; the latter is what we are
1855 * interested in here.
1858 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
1860 if (_in_group_rebuild_or_clear) {
1864 /* Re-write the session's route group list so that the new order is preserved */
1866 list<RouteGroup*> new_list;
1868 Gtk::TreeModel::Children children = group_model->children();
1869 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
1870 RouteGroup* g = (*i)[group_columns.group];
1872 new_list.push_back (g);
1876 _session->reorder_route_groups (new_list);
1881 Mixer_UI::add_route_group (RouteGroup* group)
1883 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
1886 in_group_row_change = true;
1888 TreeModel::Row row = *(group_model->append());
1889 row[group_columns.visible] = !group->is_hidden ();
1890 row[group_columns.group] = group;
1891 if (!group->name().empty()) {
1892 row[group_columns.text] = group->name();
1894 row[group_columns.text] = _("unnamed");
1898 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
1901 TreeViewColumn* col = group_display.get_column (0);
1902 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
1903 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
1906 _group_tabs->set_dirty ();
1908 in_group_row_change = false;
1912 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
1914 using namespace Menu_Helpers;
1916 if (Keyboard::is_context_menu_event (ev)) {
1917 ARDOUR_UI::instance()->add_route ();
1925 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
1927 printf ("Mixer_UI::scroller_drag_data_received\n");
1928 if (data.get_target() != "PluginFavoritePtr") {
1929 context->drag_finish (false, false, time);
1933 const void * d = data.get_data();
1934 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1936 PluginPresetList nfos;
1938 tv->get_object_drag_data (nfos, &source);
1940 Route::ProcessorList pl;
1943 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1944 PluginPresetPtr ppp = (*i);
1945 PluginInfoPtr pip = ppp->_pip;
1946 if (!pip->is_instrument ()) {
1949 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);
1953 context->drag_finish (ok, false, time);
1957 Mixer_UI::set_strip_width (Width w, bool save)
1961 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1962 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
1967 struct PluginStateSorter {
1969 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
1970 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
1971 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
1972 if (aiter != _user.end() && biter != _user.end()) {
1973 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
1975 if (aiter != _user.end()) {
1978 if (biter != _user.end()) {
1981 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
1984 PluginStateSorter(std::list<std::string> user) : _user (user) {}
1986 std::list<std::string> _user;
1990 Mixer_UI::set_state (const XMLNode& node, int version)
1992 XMLProperty const * prop;
1995 Tabbable::set_state (node, version);
1997 if ((prop = node.property ("narrow-strips"))) {
1998 if (string_is_affirmative (prop->value())) {
1999 set_strip_width (Narrow);
2001 set_strip_width (Wide);
2005 if ((prop = node.property ("show-mixer"))) {
2006 if (string_is_affirmative (prop->value())) {
2011 if ((prop = node.property ("maximised"))) {
2012 bool yn = string_is_affirmative (prop->value());
2013 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer"));
2015 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2016 bool fs = tact && tact->get_active();
2018 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2022 if ((prop = node.property ("show-mixer-list"))) {
2023 bool yn = string_is_affirmative (prop->value());
2024 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMixerList"));
2026 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2028 /* do it twice to force the change */
2029 tact->set_active (!yn);
2030 tact->set_active (yn);
2034 XMLNode* plugin_order;
2035 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2036 store_current_favorite_order ();
2037 std::list<string> order;
2038 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2039 XMLNodeConstIterator i;
2040 for (i = kids.begin(); i != kids.end(); ++i) {
2041 if ((prop = (*i)->property ("unique-id"))) {
2042 std::string unique_id = prop->value();
2043 order.push_back (unique_id);
2044 if ((prop = (*i)->property ("expanded"))) {
2045 favorite_ui_state[unique_id] = string_is_affirmative (prop->value());
2049 PluginStateSorter cmp (order);
2050 favorite_order.sort (cmp);
2051 sync_treeview_from_favorite_order ();
2057 Mixer_UI::get_state ()
2059 XMLNode* node = new XMLNode (X_("Mixer"));
2063 node->add_child_nocopy (Tabbable::get_state());
2065 snprintf(buf,sizeof(buf), "%f", rhs_pane1.get_divider());
2066 node->add_property(X_("mixer-rhs-pane1-pos"), string(buf));
2067 snprintf(buf,sizeof(buf), "%f", rhs_pane2.get_divider());
2068 node->add_property(X_("mixer-rhs_pane2-pos"), string(buf));
2069 snprintf(buf,sizeof(buf), "%f", list_hpane.get_divider());
2070 node->add_property(X_("mixer-list-hpane-pos"), string(buf));
2071 snprintf(buf,sizeof(buf), "%f", inner_pane.get_divider());
2072 node->add_property(X_("mixer-inner-pane-pos"), string(buf));
2074 node->add_property ("narrow-strips", _strip_width == Narrow ? "yes" : "no");
2075 node->add_property ("show-mixer", _visible ? "yes" : "no");
2076 node->add_property ("show-mixer-list", _show_mixer_list ? "yes" : "no");
2077 node->add_property ("maximised", _maximised ? "yes" : "no");
2079 store_current_favorite_order ();
2080 XMLNode* plugin_order = new XMLNode ("PluginOrder");
2082 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2083 XMLNode* p = new XMLNode ("PluginInfo");
2084 p->add_property ("sort", cnt);
2085 p->add_property ("unique-id", (*i)->unique_id);
2086 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2087 p->add_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2089 plugin_order->add_child_nocopy (*p);
2091 node->add_child_nocopy (*plugin_order);
2097 Mixer_UI::scroll_left ()
2099 if (!scroller.get_hscrollbar()) return;
2100 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2101 int sc_w = scroller.get_width();
2102 int sp_w = strip_packer.get_width();
2106 int lp = adj->get_value();
2108 using namespace Gtk::Box_Helpers;
2109 const BoxList& strips = strip_packer.children();
2110 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2111 lm += i->get_widget()->get_width ();
2113 lm -= i->get_widget()->get_width ();
2117 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2121 Mixer_UI::scroll_right ()
2123 if (!scroller.get_hscrollbar()) return;
2124 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2125 int sc_w = scroller.get_width();
2126 int sp_w = strip_packer.get_width();
2130 int lp = adj->get_value();
2132 using namespace Gtk::Box_Helpers;
2133 const BoxList& strips = strip_packer.children();
2134 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2135 lm += i->get_widget()->get_width ();
2140 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2144 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2146 switch (ev->direction) {
2147 case GDK_SCROLL_LEFT:
2151 if (ev->state & Keyboard::TertiaryModifier) {
2157 case GDK_SCROLL_RIGHT:
2161 case GDK_SCROLL_DOWN:
2162 if (ev->state & Keyboard::TertiaryModifier) {
2174 Mixer_UI::parameter_changed (string const & p)
2176 if (p == "show-group-tabs") {
2177 bool const s = _session->config.get_show_group_tabs ();
2179 _group_tabs->show ();
2181 _group_tabs->hide ();
2183 } else if (p == "default-narrow_ms") {
2184 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2185 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2186 (*i)->set_width_enum (s ? Narrow : Wide, this);
2188 } else if (p == "use-monitor-bus") {
2189 if (_session && !_session->monitor_out()) {
2190 monitor_section_detached ();
2196 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2198 g->set_active (a, this);
2202 Mixer_UI::plugin_selector()
2204 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2205 if (!_plugin_selector)
2206 _plugin_selector = new PluginSelector (PluginManager::instance());
2209 return _plugin_selector;
2213 Mixer_UI::setup_track_display ()
2215 track_model = ListStore::create (stripable_columns);
2216 track_display.set_model (track_model);
2217 track_display.append_column (_("Show"), stripable_columns.visible);
2218 track_display.append_column (_("Strips"), stripable_columns.text);
2219 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2220 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2221 track_display.get_column (0)->set_expand(false);
2222 track_display.get_column (1)->set_expand(true);
2223 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2224 track_display.set_name (X_("EditGroupList"));
2225 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2226 track_display.set_reorderable (true);
2227 track_display.set_headers_visible (true);
2228 track_display.set_can_focus(false);
2230 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2231 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2233 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2234 track_list_visible_cell->property_activatable() = true;
2235 track_list_visible_cell->property_radio() = false;
2236 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2238 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2240 track_display_scroller.add (track_display);
2241 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2243 VBox* v = manage (new VBox);
2245 v->pack_start (track_display_scroller, true, true);
2247 Button* b = manage (new Button);
2249 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
2253 b->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
2255 v->pack_start (*b, false, false);
2257 track_display_frame.set_name("BaseFrame");
2258 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2259 track_display_frame.add (*v);
2261 track_display_scroller.show();
2262 track_display_frame.show();
2263 track_display.show();
2267 Mixer_UI::new_track_or_bus ()
2269 ARDOUR_UI::instance()->add_route ();
2273 Mixer_UI::update_title ()
2275 if (!own_window()) {
2282 if (_session->snap_name() != _session->name()) {
2283 n = _session->snap_name ();
2285 n = _session->name ();
2288 if (_session->dirty ()) {
2292 WindowTitle title (n);
2293 title += S_("Window|Mixer");
2294 title += Glib::get_application_name ();
2295 own_window()->set_title (title.get_string());
2299 WindowTitle title (S_("Window|Mixer"));
2300 title += Glib::get_application_name ();
2301 own_window()->set_title (title.get_string());
2306 Mixer_UI::strip_by_x (int x)
2308 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2311 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2312 x2 = x1 + (*i)->get_width();
2314 if (x >= x1 && x <= x2) {
2323 Mixer_UI::set_axis_targets_for_operation ()
2325 _axis_targets.clear ();
2327 if (!_selection.empty()) {
2328 _axis_targets = _selection.axes;
2332 // removed "implicit" selections of strips, after discussion on IRC
2337 Mixer_UI::monitor_section_going_away ()
2339 if (_monitor_section) {
2340 monitor_section_detached ();
2341 out_packer.remove (_monitor_section->tearoff());
2342 _monitor_section->set_session (0);
2343 delete _monitor_section;
2344 _monitor_section = 0;
2349 Mixer_UI::toggle_midi_input_active (bool flip_others)
2351 boost::shared_ptr<RouteList> rl (new RouteList);
2354 set_axis_targets_for_operation ();
2356 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2357 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2361 onoff = !mt->input_active();
2365 _session->set_exclusive_input_active (rl, onoff, flip_others);
2369 Mixer_UI::maximise_mixer_space ()
2371 if (!own_window()) {
2379 _window->fullscreen ();
2384 Mixer_UI::restore_mixer_space ()
2386 if (!own_window()) {
2394 own_window()->unfullscreen();
2399 Mixer_UI::monitor_section_attached ()
2401 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2402 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2403 act->set_sensitive (true);
2404 tact->set_active ();
2408 Mixer_UI::monitor_section_detached ()
2410 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2411 act->set_sensitive (false);
2415 Mixer_UI::store_current_favorite_order ()
2417 typedef Gtk::TreeModel::Children type_children;
2418 type_children children = favorite_plugins_model->children();
2419 favorite_order.clear();
2420 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2422 Gtk::TreeModel::Row row = *iter;
2423 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2424 favorite_order.push_back (ppp->_pip);
2425 std::string name = row[favorite_plugins_columns.name];
2426 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2431 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2433 Gtk::TreeModel::Row row = *iter;
2434 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2436 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2440 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2442 PluginManager& manager (PluginManager::instance());
2443 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2444 if (manager.get_status (*i) != PluginManager::Favorite) {
2447 result.push_back (*i);
2451 struct PluginCustomSorter {
2453 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2454 PluginInfoList::const_iterator aiter = _user.begin();
2455 PluginInfoList::const_iterator biter = _user.begin();
2456 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2457 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2459 if (aiter != _user.end() && biter != _user.end()) {
2460 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2462 if (aiter != _user.end()) {
2465 if (biter != _user.end()) {
2468 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2470 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2472 PluginInfoList _user;
2476 Mixer_UI::refill_favorite_plugins ()
2478 PluginInfoList plugs;
2479 PluginManager& mgr (PluginManager::instance());
2482 refiller (plugs, mgr.lv2_plugin_info ());
2484 #ifdef WINDOWS_VST_SUPPORT
2485 refiller (plugs, mgr.windows_vst_plugin_info ());
2487 #ifdef LXVST_SUPPORT
2488 refiller (plugs, mgr.lxvst_plugin_info ());
2490 #ifdef MACVST_SUPPORT
2491 refiller (plugs, mgr.mac_vst_plugin_info ());
2493 #ifdef AUDIOUNIT_SUPPORT
2494 refiller (plugs, mgr.au_plugin_info ());
2496 refiller (plugs, mgr.ladspa_plugin_info ());
2497 refiller (plugs, mgr.lua_plugin_info ());
2499 store_current_favorite_order ();
2501 PluginCustomSorter cmp (favorite_order);
2504 favorite_order = plugs;
2506 sync_treeview_from_favorite_order ();
2510 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2513 if (!(iter = favorite_plugins_model->get_iter (path))) {
2516 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2520 PluginInfoPtr pip = ppp->_pip;
2521 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2522 if (favorite_ui_state[pip->unique_id]) {
2523 favorite_plugins_display.expand_row (path, true);
2529 Mixer_UI::sync_treeview_from_favorite_order ()
2531 favorite_plugins_model->clear ();
2532 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
2533 PluginInfoPtr pip = (*i);
2535 TreeModel::Row newrow = *(favorite_plugins_model->append());
2536 newrow[favorite_plugins_columns.name] = (*i)->name;
2537 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
2542 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
2543 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
2544 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
2545 child_row[favorite_plugins_columns.name] = (*j).label;
2546 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
2548 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2549 if (favorite_ui_state[pip->unique_id]) {
2550 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
2557 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
2559 using namespace Gtk::Menu_Helpers;
2561 Gtk::Menu* m = manage (new Menu);
2562 MenuList& items = m->items ();
2564 if (_selection.axes.empty()) {
2565 items.push_back (MenuElem (_("No Track/Bus is selected.")));
2567 items.push_back (MenuElem (_("Add at the top"),
2568 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
2569 items.push_back (MenuElem (_("Add Pre-Fader"),
2570 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
2571 items.push_back (MenuElem (_("Add Post-Fader"),
2572 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
2573 items.push_back (MenuElem (_("Add at the end"),
2574 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
2577 items.push_back (SeparatorElem());
2579 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
2581 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2582 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
2583 // we cannot currently delete AU presets
2584 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
2585 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
2589 m->popup (ev->button, ev->time);
2593 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
2595 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) {
2596 TreeModel::Path path;
2597 TreeViewColumn* column;
2599 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
2600 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2602 selection->unselect_all();
2603 selection->select(path);
2606 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2608 popup_note_context_menu (ev);
2616 Mixer_UI::selected_plugin ()
2618 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2620 return PluginPresetPtr();
2622 Gtk::TreeModel::iterator iter = selection->get_selected();
2624 return PluginPresetPtr();
2626 return (*iter)[favorite_plugins_columns.plugin];
2630 Mixer_UI::add_selected_processor (ProcessorPosition pos)
2632 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2634 add_favorite_processor (ppp, pos);
2639 Mixer_UI::delete_selected_preset ()
2644 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2645 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
2648 PluginPtr plugin = ppp->_pip->load (*_session);
2649 plugin->get_presets();
2650 plugin->remove_preset (ppp->_preset.label);
2654 Mixer_UI::remove_selected_from_favorites ()
2656 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2660 PluginManager::PluginStatusType status = PluginManager::Normal;
2661 PluginManager& manager (PluginManager::instance());
2663 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2664 manager.save_statuses ();
2668 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
2671 if (!(iter = favorite_plugins_model->get_iter (path))) {
2674 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2675 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
2679 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
2681 if (!_session || _selection.axes.empty()) {
2685 PluginInfoPtr pip = ppp->_pip;
2686 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
2687 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
2693 PluginPtr p = pip->load (*_session);
2699 if (ppp->_preset.valid) {
2700 p->load_preset (ppp->_preset);
2703 Route::ProcessorStreams err;
2704 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2708 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
2711 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
2718 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
2722 if (!np->display_to_user()) {
2725 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
2726 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
2731 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
2735 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
2742 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
2744 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
2748 // only allow to re-order top-level items
2750 if (TreePath::get_from_selection_data (data, src)) {
2751 if (src.up() && src.up()) {
2756 // don't allow to drop as child-rows.
2757 Gtk::TreeModel::Path _dest = dest; // un const
2758 const bool is_child = _dest.up (); // explicit bool for clang
2759 if (!is_child || _dest.empty ()) {
2766 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
2768 if (data.get_target() != "PluginPresetPtr") {
2771 if (data.get_length() != sizeof (PluginPresetPtr)) {
2774 const void *d = data.get_data();
2775 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
2777 PluginManager::PluginStatusType status = PluginManager::Favorite;
2778 PluginManager& manager (PluginManager::instance());
2780 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2781 manager.save_statuses ();
2785 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
2787 /* call protected MixerActor:: method */
2792 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
2794 /* call protected MixerActor:: method */
2799 Mixer_UI::show_vca_slaves (boost::shared_ptr<VCA> vca)
2801 boost::shared_ptr<VCA> v = spilled_vca.lock();
2804 show_vca_change (vca); /* EMIT SIGNAL */
2806 _group_tabs->hide ();
2808 _group_tabs->show ();
2810 redisplay_track_list ();
2815 Mixer_UI::showing_vca_slaves_for (boost::shared_ptr<VCA> vca) const
2817 return vca == spilled_vca.lock();
2821 Mixer_UI::register_actions ()
2823 Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
2825 myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
2826 myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
2827 myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
2828 myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
2829 myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
2830 myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
2833 myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
2834 myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
2835 myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
2836 myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
2837 myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
2838 myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
2839 myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
2840 myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
2842 myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
2843 myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
2845 myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
2846 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
2850 Mixer_UI::load_bindings ()
2852 bindings = Bindings::get_bindings (X_("Mixer"), myactions);
2855 template<class T> void
2856 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
2858 boost::shared_ptr<ControlList> cl (new ControlList);
2859 boost::shared_ptr<AutomationControl> ac;
2861 bool have_val = false;
2863 set_axis_targets_for_operation ();
2865 BOOST_FOREACH(AxisView* r, _axis_targets) {
2866 boost::shared_ptr<Stripable> s = r->stripable();
2868 ac = (s.get()->*get_control)();
2872 val = !ac->get_value();
2879 _session->set_controls (cl, val, Controllable::UseGroup);
2883 Mixer_UI::solo_action ()
2885 control_action (&Stripable::solo_control);
2889 Mixer_UI::mute_action ()
2891 control_action (&Stripable::mute_control);
2895 Mixer_UI::rec_enable_action ()
2897 control_action (&Stripable::rec_enable_control);
2901 Mixer_UI::step_gain_up_action ()
2903 set_axis_targets_for_operation ();
2905 BOOST_FOREACH(AxisView* r, _axis_targets) {
2906 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2908 ms->step_gain_up ();
2914 Mixer_UI::step_gain_down_action ()
2916 set_axis_targets_for_operation ();
2918 BOOST_FOREACH(AxisView* r, _axis_targets) {
2919 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2921 ms->step_gain_down ();
2927 Mixer_UI::unity_gain_action ()
2929 set_axis_targets_for_operation ();
2931 BOOST_FOREACH(AxisView* r, _axis_targets) {
2932 boost::shared_ptr<Stripable> s = r->stripable();
2934 boost::shared_ptr<AutomationControl> ac = s->gain_control();
2936 ac->set_value (1.0, Controllable::UseGroup);
2943 Mixer_UI::copy_processors ()
2945 set_axis_targets_for_operation ();
2947 BOOST_FOREACH(AxisView* r, _axis_targets) {
2948 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2950 ms->copy_processors ();
2955 Mixer_UI::cut_processors ()
2957 set_axis_targets_for_operation ();
2959 BOOST_FOREACH(AxisView* r, _axis_targets) {
2960 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2962 ms->cut_processors ();
2967 Mixer_UI::paste_processors ()
2969 set_axis_targets_for_operation ();
2971 BOOST_FOREACH(AxisView* r, _axis_targets) {
2972 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2974 ms->paste_processors ();
2979 Mixer_UI::select_all_processors ()
2981 set_axis_targets_for_operation ();
2983 BOOST_FOREACH(AxisView* r, _axis_targets) {
2984 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2986 ms->select_all_processors ();
2991 Mixer_UI::toggle_processors ()
2993 set_axis_targets_for_operation ();
2995 BOOST_FOREACH(AxisView* r, _axis_targets) {
2996 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2998 ms->toggle_processors ();
3003 Mixer_UI::ab_plugins ()
3005 set_axis_targets_for_operation ();
3007 BOOST_FOREACH(AxisView* r, _axis_targets) {
3008 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3016 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3018 set_axis_targets_for_operation ();
3020 BOOST_FOREACH(AxisView* r, _axis_targets) {
3021 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3023 ms->vca_assign (vca);
3030 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3032 set_axis_targets_for_operation ();
3034 BOOST_FOREACH(AxisView* r, _axis_targets) {
3035 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3037 ms->vca_unassign (vca);