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 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
257 vca_vpacker.pack_start (vca_label_bar, false, false);
259 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
260 vca_scroller_base.set_name (X_("MixerWindow"));
261 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
262 vca_hpacker.pack_end (vca_scroller_base, true, true);
264 vca_scroller.add (vca_hpacker);
265 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
266 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
268 vca_vpacker.pack_start (vca_scroller, true, true);
270 inner_pane.add (scroller);
271 inner_pane.add (vca_vpacker);
273 global_hpacker.pack_start (inner_pane, true, true);
274 global_hpacker.pack_start (out_packer, false, false);
276 list_hpane.set_check_divider_position (true);
277 list_hpane.add (list_vpacker);
278 list_hpane.add (global_hpacker);
281 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
282 XMLProperty const * prop;
288 if (!settings || ((prop = settings->property ("mixer-rhs-pane1-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
289 rhs_pane1.set_divider (0, 0.6f);
291 rhs_pane1.set_divider (0, fract);
293 if (!settings || ((prop = settings->property ("mixer-rhs-pane2-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
294 rhs_pane2.set_divider (0, 0.7f);
296 rhs_pane2.set_divider (0, fract);
298 if (!settings || ((prop = settings->property ("mixer-list-hpane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
299 list_hpane.set_divider (0, 0.2f);
301 list_hpane.set_divider (0, fract);
303 if (!settings || ((prop = settings->property ("mixer-inner-pane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
304 inner_pane.set_divider (0, 0.8f);
306 inner_pane.set_divider (0, atof (prop->value()));
310 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
311 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
312 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
313 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
315 _content.pack_start (list_hpane, true, true);
319 route_group_display_button_box->show();
320 route_group_add_button->show();
321 route_group_remove_button->show();
324 _content.set_name ("MixerWindow");
326 global_hpacker.show();
328 scroller_base.show();
329 scroller_hpacker.show();
330 mixer_scroller_vpacker.show();
332 group_display_button_label.show();
333 group_display_button.show();
334 group_display_scroller.show();
335 favorite_plugins_scroller.show();
336 group_display_vbox.show();
337 group_display_frame.show();
338 favorite_plugins_frame.show();
346 vca_label_bar.show();
348 vca_scroller_base.show();
351 group_display.show();
352 favorite_plugins_display.show();
354 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
358 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
360 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
361 _plugin_selector = new PluginSelector (PluginManager::instance ());
363 #error implement deferred Plugin-Favorite list
365 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
366 PluginManager::instance ().PluginStatusesChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
367 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
370 Mixer_UI::~Mixer_UI ()
372 if (_monitor_section) {
373 monitor_section_detached ();
374 delete _monitor_section;
376 delete _plugin_selector;
386 Mixer_UI::track_editor_selection ()
388 PublicEditor::instance().get_selection().TracksChanged.connect (sigc::mem_fun (*this, &Mixer_UI::follow_editor_selection));
392 Mixer_UI::use_own_window (bool and_fill_it)
394 bool new_window = !own_window();
396 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
399 if (win && new_window) {
400 win->set_name ("MixerWindow");
401 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
402 win->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
403 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
404 win->set_data ("ardour-bindings", bindings);
412 Mixer_UI::show_window ()
414 Tabbable::show_window ();
416 /* show/hide group tabs as required */
417 parameter_changed ("show-group-tabs");
419 /* now reset each strips width so the right widgets are shown */
421 TreeModel::Children rows = track_model->children();
422 TreeModel::Children::iterator ri;
424 for (ri = rows.begin(); ri != rows.end(); ++ri) {
425 AxisView* av = (*ri)[stripable_columns.strip];
426 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
430 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
431 /* Fix visibility of mixer strip stuff */
432 ms->parameter_changed (X_("mixer-element-visibility"));
435 /* force focus into main area */
436 scroller_base.grab_focus ();
440 Mixer_UI::remove_master (VCAMasterStrip* vms)
442 if (_session && _session->deletion_in_progress()) {
443 /* its all being taken care of */
447 TreeModel::Children rows = track_model->children();
448 TreeModel::Children::iterator ri;
450 for (ri = rows.begin(); ri != rows.end(); ++ri) {
451 if ((*ri)[stripable_columns.strip] == vms) {
452 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
453 track_model->erase (ri);
460 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
462 using namespace Menu_Helpers;
464 if (Keyboard::is_context_menu_event (ev)) {
465 ARDOUR_UI::instance()->add_route ();
473 Mixer_UI::add_masters (VCAList& vlist)
477 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
478 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
485 Mixer_UI::add_routes (RouteList& rlist)
489 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
497 Mixer_UI::add_stripables (StripableList& slist)
499 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
500 bool from_scratch = (track_model->children().size() == 0);
501 uint32_t nroutes = 0;
503 slist.sort (StripablePresentationInfoSorter());
505 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
506 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
514 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
524 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
526 track_display.set_model (Glib::RefPtr<ListStore>());
528 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
530 boost::shared_ptr<Route> route;
531 boost::shared_ptr<VCA> vca;
533 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
535 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
537 TreeModel::Row row = *(track_model->append());
539 row[stripable_columns.text] = vca->name();
540 row[stripable_columns.visible] = vms->marked_for_display ();
541 row[stripable_columns.strip] = vms;
542 row[stripable_columns.stripable] = vca;
544 vms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
546 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
548 if (route->is_auditioner()) {
552 if (route->is_monitor()) {
554 if (!_monitor_section) {
555 _monitor_section = new MonitorSection (_session);
557 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
559 _monitor_section->tearoff().set_state (*mnode);
563 out_packer.pack_end (_monitor_section->tearoff(), false, false);
564 _monitor_section->set_session (_session);
565 _monitor_section->tearoff().show_all ();
567 _monitor_section->tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
568 _monitor_section->tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
570 monitor_section_attached ();
572 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
574 /* no regular strip shown for control out */
579 strip = new MixerStrip (*this, _session, route);
580 strips.push_back (strip);
582 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
584 if (strip->width_owner() != strip) {
585 strip->set_width_enum (_strip_width, this);
590 if (!route->is_master()) {
592 TreeModel::Row row = *(track_model->insert (insert_iter));
594 row[stripable_columns.text] = route->name();
595 row[stripable_columns.visible] = strip->marked_for_display();
596 row[stripable_columns.stripable] = route;
597 row[stripable_columns.strip] = strip;
600 _selection.add (strip);
605 out_packer.pack_start (*strip, false, false);
606 strip->set_packed (true);
609 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
610 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
613 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
614 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
617 } catch (const std::exception& e) {
618 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
621 track_display.set_model (track_model);
624 sync_presentation_info_from_treeview ();
627 redisplay_track_list ();
631 Mixer_UI::deselect_all_strip_processors ()
633 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
634 (*i)->deselect_all_processors();
639 Mixer_UI::select_strip (MixerStrip& ms, bool add)
642 _selection.add (&ms);
644 _selection.set (&ms);
649 Mixer_UI::select_none ()
651 _selection.clear_routes();
652 deselect_all_strip_processors();
656 Mixer_UI::delete_processors ()
658 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
659 (*i)->delete_processors();
665 Mixer_UI::remove_strip (MixerStrip* strip)
667 if (_session && _session->deletion_in_progress()) {
668 /* its all being taken care of */
672 TreeModel::Children rows = track_model->children();
673 TreeModel::Children::iterator ri;
674 list<MixerStrip *>::iterator i;
676 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
680 for (ri = rows.begin(); ri != rows.end(); ++ri) {
681 if ((*ri)[stripable_columns.strip] == strip) {
682 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
683 track_model->erase (ri);
690 Mixer_UI::sync_presentation_info_from_treeview ()
692 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
696 TreeModel::Children rows = track_model->children();
702 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
704 TreeModel::Children::iterator ri;
708 // special case master if it's got PI order 0 lets keep it there
709 if (_session->master_out() && (_session->master_out()->presentation_info().order() == 0)) {
713 for (ri = rows.begin(); ri != rows.end(); ++ri) {
714 bool visible = (*ri)[stripable_columns.visible];
715 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
721 /* Monitor and Auditioner do not get their presentation
725 if (stripable->is_monitor() || stripable->is_auditioner()) {
729 /* Master also doesn't get set here but since the editor allows
730 * it to be reordered, we need to preserve its ordering.
733 stripable->presentation_info().set_hidden (!visible);
735 // master may not get set here, but if it is zero keep it there
736 if (stripable->is_master() && (stripable->presentation_info().order() == 0)) {
740 if (order != stripable->presentation_info().order()) {
741 stripable->set_presentation_order (order, false);
749 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
750 _session->notify_presentation_info_change ();
751 _session->set_dirty();
756 Mixer_UI::sync_treeview_from_presentation_info ()
758 if (!_session || _session->deletion_in_progress()) {
762 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
764 /* we could get here after either a change in the Mixer or Editor sort
765 * order, but either way, the mixer order keys reflect the intended
766 * order for the GUI, so reorder the treeview model to match it.
769 vector<int> neworder;
770 TreeModel::Children rows = track_model->children();
771 uint32_t old_order = 0;
772 bool changed = false;
779 const size_t cmp_max = rows.size ();
781 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
782 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
783 sorted.push_back (OrderKeys (old_order, stripable, cmp_max));
786 SortByNewDisplayOrder cmp;
788 sort (sorted.begin(), sorted.end(), cmp);
789 neworder.assign (sorted.size(), 0);
793 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
795 neworder[n] = sr->old_display_order;
797 if (sr->old_display_order != n) {
803 Unwinder<bool> uw (ignore_reorder, true);
804 track_model->reorder (neworder);
807 redisplay_track_list ();
811 Mixer_UI::follow_editor_selection ()
813 if (_following_editor_selection) {
817 _following_editor_selection = true;
818 _selection.block_routes_changed (true);
820 TrackSelection& s (PublicEditor::instance().get_selection().tracks);
822 _selection.clear_routes ();
824 for (TrackViewList::iterator i = s.begin(); i != s.end(); ++i) {
825 TimeAxisView* tav = dynamic_cast<TimeAxisView*> (*i);
827 AxisView* axis = axis_by_stripable (tav->stripable());
829 _selection.add (axis);
834 _following_editor_selection = false;
835 _selection.block_routes_changed (false);
840 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
842 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
843 if ((*i)->route() == r) {
852 Mixer_UI::axis_by_stripable (boost::shared_ptr<Stripable> s) const
854 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
855 if ((*i)->stripable() == s) {
864 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
866 if (ev->button == 1) {
867 if (_selection.selected (strip)) {
868 /* primary-click: toggle selection state of strip */
869 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
870 _selection.remove (strip);
871 } else if (_selection.axes.size() > 1) {
872 /* de-select others */
873 _selection.set (strip);
876 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
877 _selection.add (strip);
878 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
880 /* extend selection */
882 vector<MixerStrip*> tmp;
883 bool accumulate = false;
884 bool found_another = false;
886 tmp.push_back (strip);
888 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
890 /* hit clicked strip, start accumulating till we hit the first
899 } else if (_selection.selected (*i)) {
900 /* hit selected strip. if currently accumulating others,
901 we're done. if not accumulating others, start doing so.
903 found_another = true;
918 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
922 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
924 _selection.set (strip);
933 Mixer_UI::set_session (Session* sess)
935 SessionHandlePtr::set_session (sess);
937 if (_plugin_selector) {
938 _plugin_selector->set_session (_session);
941 _group_tabs->set_session (sess);
943 if (_monitor_section) {
944 _monitor_section->set_session (_session);
951 refill_favorite_plugins();
953 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
954 set_state (*node, 0);
958 initial_track_display ();
960 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
961 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
962 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
963 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
964 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
965 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
966 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
968 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
970 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
972 route_groups_changed ();
981 Mixer_UI::session_going_away ()
983 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
985 _in_group_rebuild_or_clear = true;
986 group_model->clear ();
987 _in_group_rebuild_or_clear = false;
990 track_model->clear ();
992 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
996 if (_monitor_section) {
997 _monitor_section->tearoff().hide_visible ();
1000 monitor_section_detached ();
1006 SessionHandlePtr::session_going_away ();
1013 Mixer_UI::track_visibility_changed (std::string const & path)
1015 if (_session && _session->deletion_in_progress()) {
1021 if ((iter = track_model->get_iter (path))) {
1023 AxisView* av = (*iter)[stripable_columns.strip];
1024 bool visible = (*iter)[stripable_columns.visible];
1026 if (av->set_marked_for_display (!visible)) {
1027 update_track_visibility ();
1033 Mixer_UI::update_track_visibility ()
1035 TreeModel::Children rows = track_model->children();
1036 TreeModel::Children::iterator i;
1039 Unwinder<bool> uw (no_track_list_redisplay, true);
1041 for (i = rows.begin(); i != rows.end(); ++i) {
1042 AxisView* av = (*i)[stripable_columns.strip];
1043 (*i)[stripable_columns.visible] = av->marked_for_display ();
1046 /* force presentation catch up with visibility changes
1049 sync_presentation_info_from_treeview ();
1052 redisplay_track_list ();
1056 Mixer_UI::show_strip (MixerStrip* ms)
1058 TreeModel::Children rows = track_model->children();
1059 TreeModel::Children::iterator i;
1061 for (i = rows.begin(); i != rows.end(); ++i) {
1063 AxisView* av = (*i)[stripable_columns.strip];
1064 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1066 (*i)[stripable_columns.visible] = true;
1067 av->set_marked_for_display (true);
1068 update_track_visibility ();
1075 Mixer_UI::hide_strip (MixerStrip* ms)
1077 TreeModel::Children rows = track_model->children();
1078 TreeModel::Children::iterator i;
1080 for (i = rows.begin(); i != rows.end(); ++i) {
1082 AxisView* av = (*i)[stripable_columns.strip];
1083 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1085 (*i)[stripable_columns.visible] = false;
1086 av->set_marked_for_display (false);
1087 update_track_visibility ();
1094 Mixer_UI::start_updating ()
1096 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1101 Mixer_UI::stop_updating ()
1103 fast_screen_update_connection.disconnect();
1108 Mixer_UI::fast_update_strips ()
1110 if (_content.is_mapped () && _session) {
1111 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1112 (*i)->fast_update ();
1118 Mixer_UI::set_all_strips_visibility (bool yn)
1120 TreeModel::Children rows = track_model->children();
1121 TreeModel::Children::iterator i;
1124 Unwinder<bool> uw (no_track_list_redisplay, true);
1126 for (i = rows.begin(); i != rows.end(); ++i) {
1128 AxisView* av = (*i)[stripable_columns.strip];
1129 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1135 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1139 (*i)[stripable_columns.visible] = yn;
1143 redisplay_track_list ();
1148 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1150 TreeModel::Children rows = track_model->children();
1151 TreeModel::Children::iterator i;
1154 Unwinder<bool> uw (no_track_list_redisplay, true);
1156 for (i = rows.begin(); i != rows.end(); ++i) {
1158 AxisView* av = (*i)[stripable_columns.strip];
1159 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1165 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1169 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1170 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1174 (*i)[stripable_columns.visible] = yn;
1178 if (at) { /* track */
1179 (*i)[stripable_columns.visible] = yn;
1184 if (!at && !mt) { /* bus */
1185 (*i)[stripable_columns.visible] = yn;
1190 if (mt) { /* midi-track */
1191 (*i)[stripable_columns.visible] = yn;
1198 redisplay_track_list ();
1202 Mixer_UI::hide_all_routes ()
1204 set_all_strips_visibility (false);
1208 Mixer_UI::show_all_routes ()
1210 set_all_strips_visibility (true);
1214 Mixer_UI::show_all_audiobus ()
1216 set_all_audio_midi_visibility (2, true);
1219 Mixer_UI::hide_all_audiobus ()
1221 set_all_audio_midi_visibility (2, false);
1225 Mixer_UI::show_all_audiotracks()
1227 set_all_audio_midi_visibility (1, true);
1230 Mixer_UI::hide_all_audiotracks ()
1232 set_all_audio_midi_visibility (1, false);
1236 Mixer_UI::show_all_miditracks()
1238 set_all_audio_midi_visibility (3, true);
1241 Mixer_UI::hide_all_miditracks ()
1243 set_all_audio_midi_visibility (3, false);
1247 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1249 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1250 sync_presentation_info_from_treeview ();
1254 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1256 /* this happens as the second step of a DnD within the treeview as well
1257 as when a row/route is actually deleted.
1259 if it was a deletion then we have to force a redisplay because
1260 order keys may not have changed.
1263 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1264 sync_presentation_info_from_treeview ();
1266 if (_route_deletion_in_progress) {
1267 redisplay_track_list ();
1272 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1274 TreeModel::Children rows = track_model->children();
1275 std::list<boost::shared_ptr<VCA> > vcas;
1276 vcas.push_back (vca);
1278 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1279 AxisView* av = (*i)[stripable_columns.strip];
1280 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1281 if (vms && vms->vca()->slaved_to (vca)) {
1282 vcas.push_back (vms->vca());
1286 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1288 AxisView* av = (*i)[stripable_columns.strip];
1289 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1292 /* we're in the middle of changing a row, don't worry */
1296 if (!strip->route()) {
1297 /* non-route element */
1301 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1305 bool slaved = false;
1306 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1307 if (strip->route()->slaved_to (*m)) {
1315 if (strip->packed()) {
1316 strip_packer.reorder_child (*strip, -1); /* put at end */
1318 strip_packer.pack_start (*strip, false, false);
1319 strip->set_packed (true);
1324 if (strip->packed()) {
1325 strip_packer.remove (*strip);
1326 strip->set_packed (false);
1333 Mixer_UI::redisplay_track_list ()
1335 if (no_track_list_redisplay) {
1339 boost::shared_ptr<VCA> sv = spilled_vca.lock ();
1342 spill_redisplay (sv);
1346 TreeModel::Children rows = track_model->children();
1347 TreeModel::Children::iterator i;
1348 uint32_t n_masters = 0;
1350 container_clear (vca_hpacker);
1351 vca_hpacker.pack_end (vca_scroller_base, true, true);
1353 for (i = rows.begin(); i != rows.end(); ++i) {
1355 AxisView* s = (*i)[stripable_columns.strip];
1356 bool const visible = (*i)[stripable_columns.visible];
1357 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1360 /* we're in the middle of changing a row, don't worry */
1364 VCAMasterStrip* vms;
1366 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1368 vca_hpacker.pack_start (*vms, false, false);
1375 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1383 if (strip->packed()) {
1384 strip_packer.reorder_child (*strip, -1); /* put at end */
1386 strip_packer.pack_start (*strip, false, false);
1387 strip->set_packed (true);
1392 if (stripable->is_master() || stripable->is_monitor()) {
1393 /* do nothing, these cannot be hidden */
1395 if (strip->packed()) {
1396 strip_packer.remove (*strip);
1397 strip->set_packed (false);
1403 /* update visibility of VCA assign buttons */
1405 if (n_masters == 0) {
1406 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1407 vca_vpacker.hide ();
1409 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1410 vca_vpacker.show ();
1413 _group_tabs->set_dirty ();
1417 Mixer_UI::strip_width_changed ()
1419 _group_tabs->set_dirty ();
1422 TreeModel::Children rows = track_model->children();
1423 TreeModel::Children::iterator i;
1426 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1427 AxisView* av = (*i)[stripable_columns.strip];
1428 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1434 bool visible = (*i)[stripable_columns.visible];
1437 strip->queue_draw();
1444 struct PresentationInfoMixerSorter
1446 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1447 if (a->is_master()) {
1448 /* master after everything else */
1450 } else if (b->is_master()) {
1451 /* everything else before master */
1454 return a->presentation_info().order () < b->presentation_info().order ();
1459 Mixer_UI::initial_track_display ()
1463 boost::shared_ptr<RouteList> routes = _session->get_routes();
1465 for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) {
1469 VCAList vcas = _session->vca_manager().vcas();
1471 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
1472 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
1475 sl.sort (PresentationInfoMixerSorter());
1478 /* These are also used inside ::add_stripables() but we need
1479 * them here because we're going to clear the track_model also.
1481 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1482 Unwinder<bool> uw2 (ignore_reorder, true);
1484 track_model->clear ();
1485 add_stripables (sl);
1488 redisplay_track_list ();
1492 Mixer_UI::show_track_list_menu ()
1494 if (track_menu == 0) {
1495 build_track_menu ();
1498 track_menu->popup (1, gtk_get_current_event_time());
1502 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1504 if (Keyboard::is_context_menu_event (ev)) {
1505 show_track_list_menu ();
1508 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1509 TreeModel::Path path;
1510 TreeViewColumn* column;
1512 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1513 TreeIter iter = track_model->get_iter (path);
1514 if ((*iter)[stripable_columns.visible]) {
1515 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1516 move_stripable_into_view (s);
1525 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1527 if (!scroller.get_hscrollbar()) {
1530 if (s->presentation_info().special () || s->presentation_info().flag_match (PresentationInfo::VCA)) {
1540 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1541 if ((*i)->route() == s) {
1544 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1552 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1553 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0)));
1557 Mixer_UI::build_track_menu ()
1559 using namespace Menu_Helpers;
1560 using namespace Gtk;
1562 track_menu = new Menu;
1563 track_menu->set_name ("ArdourContextMenu");
1564 MenuList& items = track_menu->items();
1566 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1567 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1568 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1569 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1570 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1571 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1572 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1573 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1578 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1580 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1584 boost::shared_ptr<Stripable> s = ws.lock ();
1590 TreeModel::Children rows = track_model->children();
1591 TreeModel::Children::iterator i;
1593 for (i = rows.begin(); i != rows.end(); ++i) {
1594 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1598 if (what_changed.contains (ARDOUR::Properties::name)) {
1599 (*i)[stripable_columns.text] = s->name();
1602 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1603 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1604 redisplay_track_list ();
1611 error << _("track display list item for renamed strip not found!") << endmsg;
1615 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1617 TreeModel::Path path;
1618 TreeViewColumn* column;
1622 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1623 _group_tabs->get_menu(0)->popup (1, ev->time);
1627 TreeIter iter = group_model->get_iter (path);
1629 _group_tabs->get_menu(0)->popup (1, ev->time);
1633 RouteGroup* group = (*iter)[group_columns.group];
1635 if (Keyboard::is_context_menu_event (ev)) {
1636 _group_tabs->get_menu(group)->popup (1, ev->time);
1640 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1642 if (Keyboard::is_edit_event (ev)) {
1644 // edit_route_group (group);
1646 group_display.queue_draw();
1655 bool visible = (*iter)[group_columns.visible];
1656 (*iter)[group_columns.visible] = !visible;
1658 group_display.queue_draw();
1671 Mixer_UI::activate_all_route_groups ()
1673 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1677 Mixer_UI::disable_all_route_groups ()
1679 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1683 Mixer_UI::route_groups_changed ()
1685 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1687 _in_group_rebuild_or_clear = true;
1689 /* just rebuild the while thing */
1691 group_model->clear ();
1694 /* this is currently not used,
1695 * Mixer_UI::group_display_button_press() has a case for it,
1696 * and a commented edit_route_group() but that's n/a since 2011.
1698 * This code is left as reminder that
1699 * row[group_columns.group] = 0 has special meaning.
1703 row = *(group_model->append());
1704 row[group_columns.visible] = true;
1705 row[group_columns.text] = (_("-all-"));
1706 row[group_columns.group] = 0;
1710 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1712 _group_tabs->set_dirty ();
1713 _in_group_rebuild_or_clear = false;
1717 Mixer_UI::new_route_group ()
1719 _group_tabs->run_new_group_dialog (0, false);
1723 Mixer_UI::remove_selected_route_group ()
1725 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1726 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1732 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1735 /* selection mode is single, so rows.begin() is it */
1737 if ((iter = group_model->get_iter (*i))) {
1739 RouteGroup* rg = (*iter)[group_columns.group];
1742 _session->remove_route_group (*rg);
1748 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1750 if (in_group_row_change) {
1754 /* force an update of any mixer strips that are using this group,
1755 otherwise mix group names don't change in mixer strips
1758 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1759 if ((*i)->route_group() == group) {
1760 (*i)->route_group_changed();
1764 TreeModel::iterator i;
1765 TreeModel::Children rows = group_model->children();
1766 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1768 in_group_row_change = true;
1770 for (i = rows.begin(); i != rows.end(); ++i) {
1771 if ((*i)[group_columns.group] == group) {
1772 (*i)[group_columns.visible] = !group->is_hidden ();
1773 (*i)[group_columns.text] = group->name ();
1778 in_group_row_change = false;
1780 if (change.contains (Properties::name)) {
1781 _group_tabs->set_dirty ();
1784 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
1785 if ((*j)->route_group() == group) {
1786 if (group->is_hidden ()) {
1796 Mixer_UI::show_mixer_list (bool yn)
1799 list_vpacker.show ();
1801 list_vpacker.hide ();
1804 _show_mixer_list = yn;
1808 Mixer_UI::show_monitor_section (bool yn)
1810 if (!monitor_section()) {
1813 if (monitor_section()->tearoff().torn_off()) {
1818 monitor_section()->tearoff().show();
1820 monitor_section()->tearoff().hide();
1825 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
1830 if ((iter = group_model->get_iter (path))) {
1832 if ((group = (*iter)[group_columns.group]) == 0) {
1836 if (new_text != group->name()) {
1837 group->set_name (new_text);
1843 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
1847 if (in_group_row_change) {
1851 if ((group = (*iter)[group_columns.group]) == 0) {
1855 std::string name = (*iter)[group_columns.text];
1857 if (name != group->name()) {
1858 group->set_name (name);
1861 bool hidden = !(*iter)[group_columns.visible];
1863 if (hidden != group->is_hidden ()) {
1864 group->set_hidden (hidden, this);
1868 /** Called when a group model row is deleted, but also when the model is
1869 * reordered by a user drag-and-drop; the latter is what we are
1870 * interested in here.
1873 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
1875 if (_in_group_rebuild_or_clear) {
1879 /* Re-write the session's route group list so that the new order is preserved */
1881 list<RouteGroup*> new_list;
1883 Gtk::TreeModel::Children children = group_model->children();
1884 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
1885 RouteGroup* g = (*i)[group_columns.group];
1887 new_list.push_back (g);
1891 _session->reorder_route_groups (new_list);
1896 Mixer_UI::add_route_group (RouteGroup* group)
1898 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
1901 in_group_row_change = true;
1903 TreeModel::Row row = *(group_model->append());
1904 row[group_columns.visible] = !group->is_hidden ();
1905 row[group_columns.group] = group;
1906 if (!group->name().empty()) {
1907 row[group_columns.text] = group->name();
1909 row[group_columns.text] = _("unnamed");
1913 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
1916 TreeViewColumn* col = group_display.get_column (0);
1917 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
1918 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
1921 _group_tabs->set_dirty ();
1923 in_group_row_change = false;
1927 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
1929 using namespace Menu_Helpers;
1931 if (Keyboard::is_context_menu_event (ev)) {
1932 ARDOUR_UI::instance()->add_route ();
1940 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
1942 printf ("Mixer_UI::scroller_drag_data_received\n");
1943 if (data.get_target() != "PluginFavoritePtr") {
1944 context->drag_finish (false, false, time);
1948 const void * d = data.get_data();
1949 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1951 PluginPresetList nfos;
1953 tv->get_object_drag_data (nfos, &source);
1955 Route::ProcessorList pl;
1958 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1959 PluginPresetPtr ppp = (*i);
1960 PluginInfoPtr pip = ppp->_pip;
1961 if (!pip->is_instrument ()) {
1964 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);
1968 context->drag_finish (ok, false, time);
1972 Mixer_UI::set_strip_width (Width w, bool save)
1976 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1977 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
1982 struct PluginStateSorter {
1984 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
1985 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
1986 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
1987 if (aiter != _user.end() && biter != _user.end()) {
1988 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
1990 if (aiter != _user.end()) {
1993 if (biter != _user.end()) {
1996 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
1999 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2001 std::list<std::string> _user;
2005 Mixer_UI::set_state (const XMLNode& node, int version)
2007 XMLProperty const * prop;
2010 Tabbable::set_state (node, version);
2012 if ((prop = node.property ("narrow-strips"))) {
2013 if (string_is_affirmative (prop->value())) {
2014 set_strip_width (Narrow);
2016 set_strip_width (Wide);
2020 if ((prop = node.property ("show-mixer"))) {
2021 if (string_is_affirmative (prop->value())) {
2026 if ((prop = node.property ("maximised"))) {
2027 bool yn = string_is_affirmative (prop->value());
2028 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer"));
2030 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2031 bool fs = tact && tact->get_active();
2033 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2037 if ((prop = node.property ("show-mixer-list"))) {
2038 bool yn = string_is_affirmative (prop->value());
2039 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMixerList"));
2041 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2043 /* do it twice to force the change */
2044 tact->set_active (!yn);
2045 tact->set_active (yn);
2049 XMLNode* plugin_order;
2050 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2051 store_current_favorite_order ();
2052 std::list<string> order;
2053 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2054 XMLNodeConstIterator i;
2055 for (i = kids.begin(); i != kids.end(); ++i) {
2056 if ((prop = (*i)->property ("unique-id"))) {
2057 std::string unique_id = prop->value();
2058 order.push_back (unique_id);
2059 if ((prop = (*i)->property ("expanded"))) {
2060 favorite_ui_state[unique_id] = string_is_affirmative (prop->value());
2064 PluginStateSorter cmp (order);
2065 favorite_order.sort (cmp);
2066 sync_treeview_from_favorite_order ();
2072 Mixer_UI::get_state ()
2074 XMLNode* node = new XMLNode (X_("Mixer"));
2078 node->add_child_nocopy (Tabbable::get_state());
2080 snprintf(buf,sizeof(buf), "%f", rhs_pane1.get_divider());
2081 node->add_property(X_("mixer-rhs-pane1-pos"), string(buf));
2082 snprintf(buf,sizeof(buf), "%f", rhs_pane2.get_divider());
2083 node->add_property(X_("mixer-rhs_pane2-pos"), string(buf));
2084 snprintf(buf,sizeof(buf), "%f", list_hpane.get_divider());
2085 node->add_property(X_("mixer-list-hpane-pos"), string(buf));
2086 snprintf(buf,sizeof(buf), "%f", inner_pane.get_divider());
2087 node->add_property(X_("mixer-inner-pane-pos"), string(buf));
2089 node->add_property ("narrow-strips", _strip_width == Narrow ? "yes" : "no");
2090 node->add_property ("show-mixer", _visible ? "yes" : "no");
2091 node->add_property ("show-mixer-list", _show_mixer_list ? "yes" : "no");
2092 node->add_property ("maximised", _maximised ? "yes" : "no");
2094 store_current_favorite_order ();
2095 XMLNode* plugin_order = new XMLNode ("PluginOrder");
2097 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2098 XMLNode* p = new XMLNode ("PluginInfo");
2099 p->add_property ("sort", cnt);
2100 p->add_property ("unique-id", (*i)->unique_id);
2101 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2102 p->add_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2104 plugin_order->add_child_nocopy (*p);
2106 node->add_child_nocopy (*plugin_order);
2112 Mixer_UI::scroll_left ()
2114 if (!scroller.get_hscrollbar()) return;
2115 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2116 int sc_w = scroller.get_width();
2117 int sp_w = strip_packer.get_width();
2121 int lp = adj->get_value();
2123 using namespace Gtk::Box_Helpers;
2124 const BoxList& strips = strip_packer.children();
2125 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2126 lm += i->get_widget()->get_width ();
2128 lm -= i->get_widget()->get_width ();
2132 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2136 Mixer_UI::scroll_right ()
2138 if (!scroller.get_hscrollbar()) return;
2139 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2140 int sc_w = scroller.get_width();
2141 int sp_w = strip_packer.get_width();
2145 int lp = adj->get_value();
2147 using namespace Gtk::Box_Helpers;
2148 const BoxList& strips = strip_packer.children();
2149 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2150 lm += i->get_widget()->get_width ();
2155 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2159 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2161 switch (ev->direction) {
2162 case GDK_SCROLL_LEFT:
2166 if (ev->state & Keyboard::TertiaryModifier) {
2172 case GDK_SCROLL_RIGHT:
2176 case GDK_SCROLL_DOWN:
2177 if (ev->state & Keyboard::TertiaryModifier) {
2189 Mixer_UI::parameter_changed (string const & p)
2191 if (p == "show-group-tabs") {
2192 bool const s = _session->config.get_show_group_tabs ();
2194 _group_tabs->show ();
2196 _group_tabs->hide ();
2198 } else if (p == "default-narrow_ms") {
2199 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2200 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2201 (*i)->set_width_enum (s ? Narrow : Wide, this);
2203 } else if (p == "use-monitor-bus") {
2204 if (_session && !_session->monitor_out()) {
2205 monitor_section_detached ();
2211 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2213 g->set_active (a, this);
2217 Mixer_UI::plugin_selector()
2219 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2220 if (!_plugin_selector)
2221 _plugin_selector = new PluginSelector (PluginManager::instance());
2224 return _plugin_selector;
2228 Mixer_UI::setup_track_display ()
2230 track_model = ListStore::create (stripable_columns);
2231 track_display.set_model (track_model);
2232 track_display.append_column (_("Show"), stripable_columns.visible);
2233 track_display.append_column (_("Strips"), stripable_columns.text);
2234 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2235 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2236 track_display.get_column (0)->set_expand(false);
2237 track_display.get_column (1)->set_expand(true);
2238 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2239 track_display.set_name (X_("EditGroupList"));
2240 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2241 track_display.set_reorderable (true);
2242 track_display.set_headers_visible (true);
2243 track_display.set_can_focus(false);
2245 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2246 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2248 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2249 track_list_visible_cell->property_activatable() = true;
2250 track_list_visible_cell->property_radio() = false;
2251 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2253 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2255 track_display_scroller.add (track_display);
2256 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2258 VBox* v = manage (new VBox);
2260 v->pack_start (track_display_scroller, true, true);
2262 Button* b = manage (new Button);
2264 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
2268 b->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
2270 v->pack_start (*b, false, false);
2272 track_display_frame.set_name("BaseFrame");
2273 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2274 track_display_frame.add (*v);
2276 track_display_scroller.show();
2277 track_display_frame.show();
2278 track_display.show();
2282 Mixer_UI::new_track_or_bus ()
2284 ARDOUR_UI::instance()->add_route ();
2288 Mixer_UI::update_title ()
2290 if (!own_window()) {
2297 if (_session->snap_name() != _session->name()) {
2298 n = _session->snap_name ();
2300 n = _session->name ();
2303 if (_session->dirty ()) {
2307 WindowTitle title (n);
2308 title += S_("Window|Mixer");
2309 title += Glib::get_application_name ();
2310 own_window()->set_title (title.get_string());
2314 WindowTitle title (S_("Window|Mixer"));
2315 title += Glib::get_application_name ();
2316 own_window()->set_title (title.get_string());
2321 Mixer_UI::strip_by_x (int x)
2323 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2326 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2327 x2 = x1 + (*i)->get_width();
2329 if (x >= x1 && x <= x2) {
2338 Mixer_UI::set_axis_targets_for_operation ()
2340 _axis_targets.clear ();
2342 if (!_selection.empty()) {
2343 _axis_targets = _selection.axes;
2347 // removed "implicit" selections of strips, after discussion on IRC
2352 Mixer_UI::monitor_section_going_away ()
2354 if (_monitor_section) {
2355 monitor_section_detached ();
2356 out_packer.remove (_monitor_section->tearoff());
2357 _monitor_section->set_session (0);
2358 delete _monitor_section;
2359 _monitor_section = 0;
2364 Mixer_UI::toggle_midi_input_active (bool flip_others)
2366 boost::shared_ptr<RouteList> rl (new RouteList);
2369 set_axis_targets_for_operation ();
2371 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2372 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2376 onoff = !mt->input_active();
2380 _session->set_exclusive_input_active (rl, onoff, flip_others);
2384 Mixer_UI::maximise_mixer_space ()
2386 if (!own_window()) {
2394 _window->fullscreen ();
2399 Mixer_UI::restore_mixer_space ()
2401 if (!own_window()) {
2409 own_window()->unfullscreen();
2414 Mixer_UI::monitor_section_attached ()
2416 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2417 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2418 act->set_sensitive (true);
2419 tact->set_active ();
2423 Mixer_UI::monitor_section_detached ()
2425 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2426 act->set_sensitive (false);
2430 Mixer_UI::store_current_favorite_order ()
2432 typedef Gtk::TreeModel::Children type_children;
2433 type_children children = favorite_plugins_model->children();
2434 favorite_order.clear();
2435 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2437 Gtk::TreeModel::Row row = *iter;
2438 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2439 favorite_order.push_back (ppp->_pip);
2440 std::string name = row[favorite_plugins_columns.name];
2441 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2446 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2448 Gtk::TreeModel::Row row = *iter;
2449 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2451 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2455 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2457 PluginManager& manager (PluginManager::instance());
2458 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2459 if (manager.get_status (*i) != PluginManager::Favorite) {
2462 result.push_back (*i);
2466 struct PluginCustomSorter {
2468 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2469 PluginInfoList::const_iterator aiter = _user.begin();
2470 PluginInfoList::const_iterator biter = _user.begin();
2471 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2472 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2474 if (aiter != _user.end() && biter != _user.end()) {
2475 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2477 if (aiter != _user.end()) {
2480 if (biter != _user.end()) {
2483 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2485 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2487 PluginInfoList _user;
2491 Mixer_UI::refill_favorite_plugins ()
2493 PluginInfoList plugs;
2494 PluginManager& mgr (PluginManager::instance());
2497 refiller (plugs, mgr.lv2_plugin_info ());
2499 #ifdef WINDOWS_VST_SUPPORT
2500 refiller (plugs, mgr.windows_vst_plugin_info ());
2502 #ifdef LXVST_SUPPORT
2503 refiller (plugs, mgr.lxvst_plugin_info ());
2505 #ifdef MACVST_SUPPORT
2506 refiller (plugs, mgr.mac_vst_plugin_info ());
2508 #ifdef AUDIOUNIT_SUPPORT
2509 refiller (plugs, mgr.au_plugin_info ());
2511 refiller (plugs, mgr.ladspa_plugin_info ());
2512 refiller (plugs, mgr.lua_plugin_info ());
2514 store_current_favorite_order ();
2516 PluginCustomSorter cmp (favorite_order);
2519 favorite_order = plugs;
2521 sync_treeview_from_favorite_order ();
2525 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2528 if (!(iter = favorite_plugins_model->get_iter (path))) {
2531 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2535 PluginInfoPtr pip = ppp->_pip;
2536 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2537 if (favorite_ui_state[pip->unique_id]) {
2538 favorite_plugins_display.expand_row (path, true);
2544 Mixer_UI::sync_treeview_from_favorite_order ()
2546 favorite_plugins_model->clear ();
2547 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
2548 PluginInfoPtr pip = (*i);
2550 TreeModel::Row newrow = *(favorite_plugins_model->append());
2551 newrow[favorite_plugins_columns.name] = (*i)->name;
2552 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
2557 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
2558 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
2559 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
2560 child_row[favorite_plugins_columns.name] = (*j).label;
2561 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
2563 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2564 if (favorite_ui_state[pip->unique_id]) {
2565 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
2572 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
2574 using namespace Gtk::Menu_Helpers;
2576 Gtk::Menu* m = manage (new Menu);
2577 MenuList& items = m->items ();
2579 if (_selection.axes.empty()) {
2580 items.push_back (MenuElem (_("No Track/Bus is selected.")));
2582 items.push_back (MenuElem (_("Add at the top"),
2583 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
2584 items.push_back (MenuElem (_("Add Pre-Fader"),
2585 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
2586 items.push_back (MenuElem (_("Add Post-Fader"),
2587 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
2588 items.push_back (MenuElem (_("Add at the end"),
2589 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
2592 items.push_back (SeparatorElem());
2594 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
2596 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2597 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
2598 // we cannot currently delete AU presets
2599 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
2600 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
2604 m->popup (ev->button, ev->time);
2608 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
2610 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) {
2611 TreeModel::Path path;
2612 TreeViewColumn* column;
2614 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
2615 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2617 selection->unselect_all();
2618 selection->select(path);
2621 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2623 popup_note_context_menu (ev);
2631 Mixer_UI::selected_plugin ()
2633 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2635 return PluginPresetPtr();
2637 Gtk::TreeModel::iterator iter = selection->get_selected();
2639 return PluginPresetPtr();
2641 return (*iter)[favorite_plugins_columns.plugin];
2645 Mixer_UI::add_selected_processor (ProcessorPosition pos)
2647 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2649 add_favorite_processor (ppp, pos);
2654 Mixer_UI::delete_selected_preset ()
2659 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2660 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
2663 PluginPtr plugin = ppp->_pip->load (*_session);
2664 plugin->get_presets();
2665 plugin->remove_preset (ppp->_preset.label);
2669 Mixer_UI::remove_selected_from_favorites ()
2671 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2675 PluginManager::PluginStatusType status = PluginManager::Normal;
2676 PluginManager& manager (PluginManager::instance());
2678 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2679 manager.save_statuses ();
2683 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
2686 if (!(iter = favorite_plugins_model->get_iter (path))) {
2689 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2690 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
2694 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
2696 if (!_session || _selection.axes.empty()) {
2700 PluginInfoPtr pip = ppp->_pip;
2701 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
2702 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
2708 PluginPtr p = pip->load (*_session);
2714 if (ppp->_preset.valid) {
2715 p->load_preset (ppp->_preset);
2718 Route::ProcessorStreams err;
2719 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2723 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
2726 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
2733 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
2737 if (!np->display_to_user()) {
2740 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
2741 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
2746 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
2750 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
2757 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
2759 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
2763 // only allow to re-order top-level items
2765 if (TreePath::get_from_selection_data (data, src)) {
2766 if (src.up() && src.up()) {
2771 // don't allow to drop as child-rows.
2772 Gtk::TreeModel::Path _dest = dest; // un const
2773 const bool is_child = _dest.up (); // explicit bool for clang
2774 if (!is_child || _dest.empty ()) {
2781 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
2783 if (data.get_target() != "PluginPresetPtr") {
2786 if (data.get_length() != sizeof (PluginPresetPtr)) {
2789 const void *d = data.get_data();
2790 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
2792 PluginManager::PluginStatusType status = PluginManager::Favorite;
2793 PluginManager& manager (PluginManager::instance());
2795 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2796 manager.save_statuses ();
2800 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
2802 /* call protected MixerActor:: method */
2807 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
2809 /* call protected MixerActor:: method */
2814 Mixer_UI::show_vca_slaves (boost::shared_ptr<VCA> vca)
2816 boost::shared_ptr<VCA> v = spilled_vca.lock();
2819 show_vca_change (vca); /* EMIT SIGNAL */
2821 _group_tabs->hide ();
2823 _group_tabs->show ();
2825 redisplay_track_list ();
2830 Mixer_UI::showing_vca_slaves_for (boost::shared_ptr<VCA> vca) const
2832 return vca == spilled_vca.lock();
2836 Mixer_UI::register_actions ()
2838 Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
2840 myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
2841 myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
2842 myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
2843 myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
2844 myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
2845 myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
2848 myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
2849 myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
2850 myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
2851 myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
2852 myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
2853 myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
2854 myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
2855 myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
2857 myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
2858 myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
2860 myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
2861 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
2865 Mixer_UI::load_bindings ()
2867 bindings = Bindings::get_bindings (X_("Mixer"), myactions);
2870 template<class T> void
2871 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
2873 boost::shared_ptr<ControlList> cl (new ControlList);
2874 boost::shared_ptr<AutomationControl> ac;
2876 bool have_val = false;
2878 set_axis_targets_for_operation ();
2880 BOOST_FOREACH(AxisView* r, _axis_targets) {
2881 boost::shared_ptr<Stripable> s = r->stripable();
2883 ac = (s.get()->*get_control)();
2887 val = !ac->get_value();
2894 _session->set_controls (cl, val, Controllable::UseGroup);
2898 Mixer_UI::solo_action ()
2900 control_action (&Stripable::solo_control);
2904 Mixer_UI::mute_action ()
2906 control_action (&Stripable::mute_control);
2910 Mixer_UI::rec_enable_action ()
2912 control_action (&Stripable::rec_enable_control);
2916 Mixer_UI::step_gain_up_action ()
2918 set_axis_targets_for_operation ();
2920 BOOST_FOREACH(AxisView* r, _axis_targets) {
2921 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2923 ms->step_gain_up ();
2929 Mixer_UI::step_gain_down_action ()
2931 set_axis_targets_for_operation ();
2933 BOOST_FOREACH(AxisView* r, _axis_targets) {
2934 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2936 ms->step_gain_down ();
2942 Mixer_UI::unity_gain_action ()
2944 set_axis_targets_for_operation ();
2946 BOOST_FOREACH(AxisView* r, _axis_targets) {
2947 boost::shared_ptr<Stripable> s = r->stripable();
2949 boost::shared_ptr<AutomationControl> ac = s->gain_control();
2951 ac->set_value (1.0, Controllable::UseGroup);
2958 Mixer_UI::copy_processors ()
2960 set_axis_targets_for_operation ();
2962 BOOST_FOREACH(AxisView* r, _axis_targets) {
2963 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2965 ms->copy_processors ();
2970 Mixer_UI::cut_processors ()
2972 set_axis_targets_for_operation ();
2974 BOOST_FOREACH(AxisView* r, _axis_targets) {
2975 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2977 ms->cut_processors ();
2982 Mixer_UI::paste_processors ()
2984 set_axis_targets_for_operation ();
2986 BOOST_FOREACH(AxisView* r, _axis_targets) {
2987 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2989 ms->paste_processors ();
2994 Mixer_UI::select_all_processors ()
2996 set_axis_targets_for_operation ();
2998 BOOST_FOREACH(AxisView* r, _axis_targets) {
2999 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3001 ms->select_all_processors ();
3006 Mixer_UI::toggle_processors ()
3008 set_axis_targets_for_operation ();
3010 BOOST_FOREACH(AxisView* r, _axis_targets) {
3011 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3013 ms->toggle_processors ();
3018 Mixer_UI::ab_plugins ()
3020 set_axis_targets_for_operation ();
3022 BOOST_FOREACH(AxisView* r, _axis_targets) {
3023 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3031 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3033 set_axis_targets_for_operation ();
3035 BOOST_FOREACH(AxisView* r, _axis_targets) {
3036 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3038 ms->vca_assign (vca);
3045 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3047 set_axis_targets_for_operation ();
3049 BOOST_FOREACH(AxisView* r, _axis_targets) {
3050 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3052 ms->vca_unassign (vca);