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);
145 b->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
148 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
150 setup_track_display ();
152 group_model = ListStore::create (group_columns);
153 group_display.set_model (group_model);
154 group_display.append_column (_("Show"), group_columns.visible);
155 group_display.append_column (_("Group"), group_columns.text);
156 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
157 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
158 group_display.get_column (0)->set_expand(false);
159 group_display.get_column (1)->set_expand(true);
160 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
161 group_display.set_name ("EditGroupList");
162 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
163 group_display.set_reorderable (true);
164 group_display.set_headers_visible (true);
165 group_display.set_rules_hint (true);
166 group_display.set_can_focus(false);
168 /* name is directly editable */
170 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
171 name_cell->property_editable() = true;
172 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
174 /* use checkbox for the active column */
176 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
177 active_cell->property_activatable() = true;
178 active_cell->property_radio() = false;
180 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
181 /* We use this to notice drag-and-drop reorders of the group list */
182 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
183 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
185 group_display_scroller.add (group_display);
186 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
188 HBox* route_group_display_button_box = manage (new HBox());
190 Button* route_group_add_button = manage (new Button ());
191 Button* route_group_remove_button = manage (new Button ());
195 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
197 route_group_add_button->add (*w);
199 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
201 route_group_remove_button->add (*w);
203 route_group_display_button_box->set_homogeneous (true);
205 route_group_add_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_route_group));
206 route_group_remove_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::remove_selected_route_group));
208 route_group_display_button_box->add (*route_group_add_button);
209 route_group_display_button_box->add (*route_group_remove_button);
211 group_display_vbox.pack_start (group_display_scroller, true, true);
212 group_display_vbox.pack_start (*route_group_display_button_box, false, false);
214 group_display_frame.set_name ("BaseFrame");
215 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
216 group_display_frame.add (group_display_vbox);
219 list<TargetEntry> target_list;
220 target_list.push_back (TargetEntry ("PluginPresetPtr"));
222 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
223 favorite_plugins_display.set_model (favorite_plugins_model);
224 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
225 favorite_plugins_display.set_name ("EditGroupList");
226 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
227 favorite_plugins_display.set_reorderable (false);
228 favorite_plugins_display.set_headers_visible (true);
229 favorite_plugins_display.set_rules_hint (true);
230 favorite_plugins_display.set_can_focus (false);
231 favorite_plugins_display.set_tooltip_column (0);
232 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
233 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
234 favorite_plugins_display.add_drop_targets (target_list);
235 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
236 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
237 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
238 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
239 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
240 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
242 favorite_plugins_scroller.add (favorite_plugins_display);
243 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
245 favorite_plugins_frame.set_name ("BaseFrame");
246 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
247 favorite_plugins_frame.add (favorite_plugins_scroller);
249 rhs_pane1.add (favorite_plugins_frame);
250 rhs_pane1.add (track_display_frame);
252 rhs_pane2.add (rhs_pane1);
253 rhs_pane2.add (group_display_frame);
255 list_vpacker.pack_start (rhs_pane2, true, true);
257 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
258 vca_vpacker.pack_start (vca_label_bar, false, false);
260 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
261 vca_scroller_base.set_name (X_("MixerWindow"));
262 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
263 vca_hpacker.pack_end (vca_scroller_base, true, true);
265 vca_scroller.add (vca_hpacker);
266 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
267 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
269 vca_vpacker.pack_start (vca_scroller, true, true);
271 inner_pane.add (scroller);
272 inner_pane.add (vca_vpacker);
274 global_hpacker.pack_start (inner_pane, true, true);
275 global_hpacker.pack_start (out_packer, false, false);
277 list_hpane.set_check_divider_position (true);
278 list_hpane.add (list_vpacker);
279 list_hpane.add (global_hpacker);
280 list_hpane.set_child_minsize (list_vpacker, 1);
283 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
284 XMLProperty const * prop;
290 if (!settings || ((prop = settings->property ("mixer-rhs-pane1-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
291 rhs_pane1.set_divider (0, 0.6f);
293 rhs_pane1.set_divider (0, fract);
295 if (!settings || ((prop = settings->property ("mixer-rhs-pane2-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
296 rhs_pane2.set_divider (0, 0.7f);
298 rhs_pane2.set_divider (0, fract);
300 if (!settings || ((prop = settings->property ("mixer-list-hpane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
301 list_hpane.set_divider (0, 0.2f);
303 list_hpane.set_divider (0, fract);
305 if (!settings || ((prop = settings->property ("mixer-inner-pane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
306 inner_pane.set_divider (0, 0.8f);
308 inner_pane.set_divider (0, atof (prop->value()));
312 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
313 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
314 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
315 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
317 _content.pack_start (list_hpane, true, true);
321 route_group_display_button_box->show();
322 route_group_add_button->show();
323 route_group_remove_button->show();
326 _content.set_name ("MixerWindow");
328 global_hpacker.show();
330 scroller_base.show();
331 scroller_hpacker.show();
332 mixer_scroller_vpacker.show();
334 group_display_button_label.show();
335 group_display_button.show();
336 group_display_scroller.show();
337 favorite_plugins_scroller.show();
338 group_display_vbox.show();
339 group_display_frame.show();
340 favorite_plugins_frame.show();
348 vca_label_bar.show();
350 vca_scroller_base.show();
353 group_display.show();
354 favorite_plugins_display.show();
356 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
360 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
362 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
363 _plugin_selector = new PluginSelector (PluginManager::instance ());
365 #error implement deferred Plugin-Favorite list
367 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
368 PluginManager::instance ().PluginStatusesChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
369 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
372 Mixer_UI::~Mixer_UI ()
374 if (_monitor_section) {
375 monitor_section_detached ();
376 delete _monitor_section;
378 delete _plugin_selector;
388 Mixer_UI::track_editor_selection ()
390 PublicEditor::instance().get_selection().TracksChanged.connect (sigc::mem_fun (*this, &Mixer_UI::follow_editor_selection));
394 Mixer_UI::use_own_window (bool and_fill_it)
396 bool new_window = !own_window();
398 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
401 if (win && new_window) {
402 win->set_name ("MixerWindow");
403 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
404 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
405 win->set_data ("ardour-bindings", bindings);
413 Mixer_UI::show_window ()
415 Tabbable::show_window ();
417 /* show/hide group tabs as required */
418 parameter_changed ("show-group-tabs");
420 /* now reset each strips width so the right widgets are shown */
422 TreeModel::Children rows = track_model->children();
423 TreeModel::Children::iterator ri;
425 for (ri = rows.begin(); ri != rows.end(); ++ri) {
426 AxisView* av = (*ri)[stripable_columns.strip];
427 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
431 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
432 /* Fix visibility of mixer strip stuff */
433 ms->parameter_changed (X_("mixer-element-visibility"));
436 /* force focus into main area */
437 scroller_base.grab_focus ();
441 Mixer_UI::remove_master (VCAMasterStrip* vms)
443 if (_session && _session->deletion_in_progress()) {
444 /* its all being taken care of */
448 TreeModel::Children rows = track_model->children();
449 TreeModel::Children::iterator ri;
451 for (ri = rows.begin(); ri != rows.end(); ++ri) {
452 if ((*ri)[stripable_columns.strip] == vms) {
453 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
454 track_model->erase (ri);
461 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
463 using namespace Menu_Helpers;
465 if (Keyboard::is_context_menu_event (ev)) {
466 ARDOUR_UI::instance()->add_route ();
474 Mixer_UI::add_masters (VCAList& vlist)
478 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
479 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
486 Mixer_UI::add_routes (RouteList& rlist)
490 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
498 Mixer_UI::add_stripables (StripableList& slist)
500 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
501 bool from_scratch = (track_model->children().size() == 0);
502 uint32_t nroutes = 0;
504 slist.sort (StripablePresentationInfoSorter());
506 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
507 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
515 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
525 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
527 track_display.set_model (Glib::RefPtr<ListStore>());
529 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
531 boost::shared_ptr<Route> route;
532 boost::shared_ptr<VCA> vca;
534 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
536 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
538 TreeModel::Row row = *(track_model->append());
540 row[stripable_columns.text] = vca->name();
541 row[stripable_columns.visible] = vms->marked_for_display ();
542 row[stripable_columns.strip] = vms;
543 row[stripable_columns.stripable] = vca;
545 vms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
547 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
549 if (route->is_auditioner()) {
553 if (route->is_monitor()) {
555 if (!_monitor_section) {
556 _monitor_section = new MonitorSection (_session);
558 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
560 _monitor_section->tearoff().set_state (*mnode);
564 out_packer.pack_end (_monitor_section->tearoff(), false, false);
565 _monitor_section->set_session (_session);
566 _monitor_section->tearoff().show_all ();
568 _monitor_section->tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
569 _monitor_section->tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
571 monitor_section_attached ();
573 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
575 /* no regular strip shown for control out */
580 strip = new MixerStrip (*this, _session, route);
581 strips.push_back (strip);
583 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
585 if (strip->width_owner() != strip) {
586 strip->set_width_enum (_strip_width, this);
591 if (!route->is_master()) {
593 TreeModel::Row row = *(track_model->insert (insert_iter));
595 row[stripable_columns.text] = route->name();
596 row[stripable_columns.visible] = strip->marked_for_display();
597 row[stripable_columns.stripable] = route;
598 row[stripable_columns.strip] = strip;
601 _selection.add (strip);
606 out_packer.pack_start (*strip, false, false);
607 strip->set_packed (true);
610 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
611 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
614 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
615 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
618 } catch (const std::exception& e) {
619 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
622 track_display.set_model (track_model);
625 sync_presentation_info_from_treeview ();
628 redisplay_track_list ();
632 Mixer_UI::deselect_all_strip_processors ()
634 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
635 (*i)->deselect_all_processors();
640 Mixer_UI::select_strip (MixerStrip& ms, bool add)
643 _selection.add (&ms);
645 _selection.set (&ms);
650 Mixer_UI::select_none ()
652 _selection.clear_routes();
653 deselect_all_strip_processors();
657 Mixer_UI::delete_processors ()
659 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
660 (*i)->delete_processors();
666 Mixer_UI::remove_strip (MixerStrip* strip)
668 if (_session && _session->deletion_in_progress()) {
669 /* its all being taken care of */
673 TreeModel::Children rows = track_model->children();
674 TreeModel::Children::iterator ri;
675 list<MixerStrip *>::iterator i;
677 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
681 for (ri = rows.begin(); ri != rows.end(); ++ri) {
682 if ((*ri)[stripable_columns.strip] == strip) {
683 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
684 track_model->erase (ri);
691 Mixer_UI::sync_presentation_info_from_treeview ()
693 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
697 TreeModel::Children rows = track_model->children();
703 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
705 TreeModel::Children::iterator ri;
710 const size_t cmp_max = rows.size ();
712 // special case master if it's got PI order 0 lets keep it there
713 if (_session->master_out() && (_session->master_out()->presentation_info().order() == 0)) {
717 for (ri = rows.begin(); ri != rows.end(); ++ri) {
718 bool visible = (*ri)[stripable_columns.visible];
719 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
725 /* Monitor and Auditioner do not get their presentation
729 if (stripable->is_monitor() || stripable->is_auditioner()) {
733 /* Master also doesn't get set here but since the editor allows
734 * it to be reordered, we need to preserve its ordering.
737 stripable->presentation_info().set_hidden (!visible);
739 // master may not get set here, but if it is zero keep it there
740 if (stripable->is_master() && (stripable->presentation_info().order() == 0)) {
744 if (order != stripable->presentation_info().order()) {
745 stripable->set_presentation_order (order, false);
749 sorted.push_back (OrderKeys (order, stripable, cmp_max));
755 // VCA (and Mixbus) special cases according to SortByNewDisplayOrder
757 SortByNewDisplayOrder cmp;
758 sort (sorted.begin(), sorted.end(), cmp);
759 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
760 if (sr->old_display_order != n) {
767 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
768 _session->notify_presentation_info_change ();
769 _session->set_dirty();
774 Mixer_UI::sync_treeview_from_presentation_info ()
776 if (!_session || _session->deletion_in_progress()) {
780 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
782 /* we could get here after either a change in the Mixer or Editor sort
783 * order, but either way, the mixer order keys reflect the intended
784 * order for the GUI, so reorder the treeview model to match it.
787 vector<int> neworder;
788 TreeModel::Children rows = track_model->children();
789 uint32_t old_order = 0;
790 bool changed = false;
797 const size_t cmp_max = rows.size ();
799 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
800 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
801 sorted.push_back (OrderKeys (old_order, stripable, cmp_max));
804 SortByNewDisplayOrder cmp;
806 sort (sorted.begin(), sorted.end(), cmp);
807 neworder.assign (sorted.size(), 0);
811 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
813 neworder[n] = sr->old_display_order;
815 if (sr->old_display_order != n) {
821 Unwinder<bool> uw (ignore_reorder, true);
822 track_model->reorder (neworder);
825 redisplay_track_list ();
829 Mixer_UI::follow_editor_selection ()
831 if (_following_editor_selection) {
835 _following_editor_selection = true;
836 _selection.block_routes_changed (true);
838 TrackSelection& s (PublicEditor::instance().get_selection().tracks);
840 _selection.clear_routes ();
842 for (TrackViewList::iterator i = s.begin(); i != s.end(); ++i) {
843 TimeAxisView* tav = dynamic_cast<TimeAxisView*> (*i);
845 AxisView* axis = axis_by_stripable (tav->stripable());
847 _selection.add (axis);
852 _following_editor_selection = false;
853 _selection.block_routes_changed (false);
858 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
860 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
861 if ((*i)->route() == r) {
870 Mixer_UI::axis_by_stripable (boost::shared_ptr<Stripable> s) const
872 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
873 if ((*i)->stripable() == s) {
882 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
884 if (ev->button == 1) {
885 if (_selection.selected (strip)) {
886 /* primary-click: toggle selection state of strip */
887 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
888 _selection.remove (strip);
889 } else if (_selection.axes.size() > 1) {
890 /* de-select others */
891 _selection.set (strip);
894 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
895 _selection.add (strip);
896 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
898 /* extend selection */
900 vector<MixerStrip*> tmp;
901 bool accumulate = false;
902 bool found_another = false;
904 tmp.push_back (strip);
906 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
908 /* hit clicked strip, start accumulating till we hit the first
917 } else if (_selection.selected (*i)) {
918 /* hit selected strip. if currently accumulating others,
919 we're done. if not accumulating others, start doing so.
921 found_another = true;
936 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
940 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
942 _selection.set (strip);
951 Mixer_UI::set_session (Session* sess)
953 SessionHandlePtr::set_session (sess);
955 if (_plugin_selector) {
956 _plugin_selector->set_session (_session);
959 _group_tabs->set_session (sess);
961 if (_monitor_section) {
962 _monitor_section->set_session (_session);
969 refill_favorite_plugins();
971 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
972 set_state (*node, 0);
976 initial_track_display ();
978 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
979 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
980 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
981 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
982 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
983 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
984 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
986 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
988 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
990 route_groups_changed ();
999 Mixer_UI::session_going_away ()
1001 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1003 _in_group_rebuild_or_clear = true;
1004 group_model->clear ();
1005 _in_group_rebuild_or_clear = false;
1007 _selection.clear ();
1008 track_model->clear ();
1010 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1014 if (_monitor_section) {
1015 _monitor_section->tearoff().hide_visible ();
1018 monitor_section_detached ();
1024 SessionHandlePtr::session_going_away ();
1031 Mixer_UI::track_visibility_changed (std::string const & path)
1033 if (_session && _session->deletion_in_progress()) {
1039 if ((iter = track_model->get_iter (path))) {
1041 AxisView* av = (*iter)[stripable_columns.strip];
1042 bool visible = (*iter)[stripable_columns.visible];
1044 if (av->set_marked_for_display (!visible)) {
1045 update_track_visibility ();
1051 Mixer_UI::update_track_visibility ()
1053 TreeModel::Children rows = track_model->children();
1054 TreeModel::Children::iterator i;
1057 Unwinder<bool> uw (no_track_list_redisplay, true);
1059 for (i = rows.begin(); i != rows.end(); ++i) {
1060 AxisView* av = (*i)[stripable_columns.strip];
1061 (*i)[stripable_columns.visible] = av->marked_for_display ();
1064 /* force presentation catch up with visibility changes
1067 sync_presentation_info_from_treeview ();
1070 redisplay_track_list ();
1074 Mixer_UI::show_strip (MixerStrip* ms)
1076 TreeModel::Children rows = track_model->children();
1077 TreeModel::Children::iterator i;
1079 for (i = rows.begin(); i != rows.end(); ++i) {
1081 AxisView* av = (*i)[stripable_columns.strip];
1082 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1084 (*i)[stripable_columns.visible] = true;
1085 av->set_marked_for_display (true);
1086 update_track_visibility ();
1093 Mixer_UI::hide_strip (MixerStrip* ms)
1095 TreeModel::Children rows = track_model->children();
1096 TreeModel::Children::iterator i;
1098 for (i = rows.begin(); i != rows.end(); ++i) {
1100 AxisView* av = (*i)[stripable_columns.strip];
1101 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1103 (*i)[stripable_columns.visible] = false;
1104 av->set_marked_for_display (false);
1105 update_track_visibility ();
1112 Mixer_UI::start_updating ()
1114 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1119 Mixer_UI::stop_updating ()
1121 fast_screen_update_connection.disconnect();
1126 Mixer_UI::fast_update_strips ()
1128 if (_content.is_mapped () && _session) {
1129 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1130 (*i)->fast_update ();
1136 Mixer_UI::set_all_strips_visibility (bool yn)
1138 TreeModel::Children rows = track_model->children();
1139 TreeModel::Children::iterator i;
1142 Unwinder<bool> uw (no_track_list_redisplay, true);
1144 for (i = rows.begin(); i != rows.end(); ++i) {
1146 AxisView* av = (*i)[stripable_columns.strip];
1147 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1153 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1157 (*i)[stripable_columns.visible] = yn;
1161 redisplay_track_list ();
1166 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1168 TreeModel::Children rows = track_model->children();
1169 TreeModel::Children::iterator i;
1172 Unwinder<bool> uw (no_track_list_redisplay, true);
1174 for (i = rows.begin(); i != rows.end(); ++i) {
1176 AxisView* av = (*i)[stripable_columns.strip];
1177 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1183 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1187 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1188 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1192 (*i)[stripable_columns.visible] = yn;
1196 if (at) { /* track */
1197 (*i)[stripable_columns.visible] = yn;
1202 if (!at && !mt) { /* bus */
1203 (*i)[stripable_columns.visible] = yn;
1208 if (mt) { /* midi-track */
1209 (*i)[stripable_columns.visible] = yn;
1216 redisplay_track_list ();
1220 Mixer_UI::hide_all_routes ()
1222 set_all_strips_visibility (false);
1226 Mixer_UI::show_all_routes ()
1228 set_all_strips_visibility (true);
1232 Mixer_UI::show_all_audiobus ()
1234 set_all_audio_midi_visibility (2, true);
1237 Mixer_UI::hide_all_audiobus ()
1239 set_all_audio_midi_visibility (2, false);
1243 Mixer_UI::show_all_audiotracks()
1245 set_all_audio_midi_visibility (1, true);
1248 Mixer_UI::hide_all_audiotracks ()
1250 set_all_audio_midi_visibility (1, false);
1254 Mixer_UI::show_all_miditracks()
1256 set_all_audio_midi_visibility (3, true);
1259 Mixer_UI::hide_all_miditracks ()
1261 set_all_audio_midi_visibility (3, false);
1265 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1267 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1268 sync_presentation_info_from_treeview ();
1272 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1274 /* this happens as the second step of a DnD within the treeview as well
1275 as when a row/route is actually deleted.
1277 if it was a deletion then we have to force a redisplay because
1278 order keys may not have changed.
1281 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1282 sync_presentation_info_from_treeview ();
1284 if (_route_deletion_in_progress) {
1285 redisplay_track_list ();
1290 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1292 TreeModel::Children rows = track_model->children();
1293 std::list<boost::shared_ptr<VCA> > vcas;
1294 vcas.push_back (vca);
1296 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1297 AxisView* av = (*i)[stripable_columns.strip];
1298 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1299 if (vms && vms->vca()->slaved_to (vca)) {
1300 vcas.push_back (vms->vca());
1304 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1306 AxisView* av = (*i)[stripable_columns.strip];
1307 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1310 /* we're in the middle of changing a row, don't worry */
1314 if (!strip->route()) {
1315 /* non-route element */
1319 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1323 bool slaved = false;
1324 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1325 if (strip->route()->slaved_to (*m)) {
1333 if (strip->packed()) {
1334 strip_packer.reorder_child (*strip, -1); /* put at end */
1336 strip_packer.pack_start (*strip, false, false);
1337 strip->set_packed (true);
1342 if (strip->packed()) {
1343 strip_packer.remove (*strip);
1344 strip->set_packed (false);
1351 Mixer_UI::redisplay_track_list ()
1353 if (no_track_list_redisplay) {
1357 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1359 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1361 spill_redisplay (sv);
1366 TreeModel::Children rows = track_model->children();
1367 TreeModel::Children::iterator i;
1368 uint32_t n_masters = 0;
1370 container_clear (vca_hpacker);
1371 vca_hpacker.pack_end (vca_scroller_base, true, true);
1373 for (i = rows.begin(); i != rows.end(); ++i) {
1375 AxisView* s = (*i)[stripable_columns.strip];
1376 bool const visible = (*i)[stripable_columns.visible];
1377 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1380 /* we're in the middle of changing a row, don't worry */
1384 VCAMasterStrip* vms;
1386 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1388 vca_hpacker.pack_start (*vms, false, false);
1395 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1403 if (strip->packed()) {
1404 strip_packer.reorder_child (*strip, -1); /* put at end */
1406 strip_packer.pack_start (*strip, false, false);
1407 strip->set_packed (true);
1412 if (stripable->is_master() || stripable->is_monitor()) {
1413 /* do nothing, these cannot be hidden */
1415 if (strip->packed()) {
1416 strip_packer.remove (*strip);
1417 strip->set_packed (false);
1423 /* update visibility of VCA assign buttons */
1425 if (n_masters == 0) {
1426 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1427 vca_vpacker.hide ();
1429 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1430 vca_vpacker.show ();
1433 _group_tabs->set_dirty ();
1437 Mixer_UI::strip_width_changed ()
1439 _group_tabs->set_dirty ();
1442 TreeModel::Children rows = track_model->children();
1443 TreeModel::Children::iterator i;
1446 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1447 AxisView* av = (*i)[stripable_columns.strip];
1448 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1454 bool visible = (*i)[stripable_columns.visible];
1457 strip->queue_draw();
1464 struct PresentationInfoMixerSorter
1466 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1467 if (a->is_master()) {
1468 /* master after everything else */
1470 } else if (b->is_master()) {
1471 /* everything else before master */
1474 return a->presentation_info().order () < b->presentation_info().order ();
1479 Mixer_UI::initial_track_display ()
1483 boost::shared_ptr<RouteList> routes = _session->get_routes();
1485 for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) {
1489 VCAList vcas = _session->vca_manager().vcas();
1491 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
1492 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
1495 sl.sort (PresentationInfoMixerSorter());
1498 /* These are also used inside ::add_stripables() but we need
1499 * them here because we're going to clear the track_model also.
1501 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1502 Unwinder<bool> uw2 (ignore_reorder, true);
1504 track_model->clear ();
1505 add_stripables (sl);
1508 redisplay_track_list ();
1509 sync_treeview_from_presentation_info ();
1513 Mixer_UI::show_track_list_menu ()
1515 if (track_menu == 0) {
1516 build_track_menu ();
1519 track_menu->popup (1, gtk_get_current_event_time());
1523 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1525 if (Keyboard::is_context_menu_event (ev)) {
1526 show_track_list_menu ();
1529 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1530 TreeModel::Path path;
1531 TreeViewColumn* column;
1533 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1534 TreeIter iter = track_model->get_iter (path);
1535 if ((*iter)[stripable_columns.visible]) {
1536 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1537 move_stripable_into_view (s);
1546 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1548 if (!scroller.get_hscrollbar()) {
1551 if (s->presentation_info().special () || s->presentation_info().flag_match (PresentationInfo::VCA)) {
1561 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1562 if ((*i)->route() == s) {
1565 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1573 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1574 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0)));
1578 Mixer_UI::build_track_menu ()
1580 using namespace Menu_Helpers;
1581 using namespace Gtk;
1583 track_menu = new Menu;
1584 track_menu->set_name ("ArdourContextMenu");
1585 MenuList& items = track_menu->items();
1587 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1588 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1589 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1590 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1591 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1592 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1593 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1594 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1599 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1601 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1605 boost::shared_ptr<Stripable> s = ws.lock ();
1611 TreeModel::Children rows = track_model->children();
1612 TreeModel::Children::iterator i;
1614 for (i = rows.begin(); i != rows.end(); ++i) {
1615 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1619 if (what_changed.contains (ARDOUR::Properties::name)) {
1620 (*i)[stripable_columns.text] = s->name();
1623 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1624 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1625 redisplay_track_list ();
1632 error << _("track display list item for renamed strip not found!") << endmsg;
1636 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1638 TreeModel::Path path;
1639 TreeViewColumn* column;
1643 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1644 _group_tabs->get_menu(0)->popup (1, ev->time);
1648 TreeIter iter = group_model->get_iter (path);
1650 _group_tabs->get_menu(0)->popup (1, ev->time);
1654 RouteGroup* group = (*iter)[group_columns.group];
1656 if (Keyboard::is_context_menu_event (ev)) {
1657 _group_tabs->get_menu(group)->popup (1, ev->time);
1661 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1663 if (Keyboard::is_edit_event (ev)) {
1665 // edit_route_group (group);
1667 group_display.queue_draw();
1676 bool visible = (*iter)[group_columns.visible];
1677 (*iter)[group_columns.visible] = !visible;
1679 group_display.queue_draw();
1692 Mixer_UI::activate_all_route_groups ()
1694 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1698 Mixer_UI::disable_all_route_groups ()
1700 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1704 Mixer_UI::route_groups_changed ()
1706 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1708 _in_group_rebuild_or_clear = true;
1710 /* just rebuild the while thing */
1712 group_model->clear ();
1715 /* this is currently not used,
1716 * Mixer_UI::group_display_button_press() has a case for it,
1717 * and a commented edit_route_group() but that's n/a since 2011.
1719 * This code is left as reminder that
1720 * row[group_columns.group] = 0 has special meaning.
1724 row = *(group_model->append());
1725 row[group_columns.visible] = true;
1726 row[group_columns.text] = (_("-all-"));
1727 row[group_columns.group] = 0;
1731 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1733 _group_tabs->set_dirty ();
1734 _in_group_rebuild_or_clear = false;
1738 Mixer_UI::new_route_group ()
1740 _group_tabs->run_new_group_dialog (0, false);
1744 Mixer_UI::remove_selected_route_group ()
1746 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1747 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1753 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1756 /* selection mode is single, so rows.begin() is it */
1758 if ((iter = group_model->get_iter (*i))) {
1760 RouteGroup* rg = (*iter)[group_columns.group];
1763 _session->remove_route_group (*rg);
1769 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1771 if (in_group_row_change) {
1775 /* force an update of any mixer strips that are using this group,
1776 otherwise mix group names don't change in mixer strips
1779 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1780 if ((*i)->route_group() == group) {
1781 (*i)->route_group_changed();
1785 TreeModel::iterator i;
1786 TreeModel::Children rows = group_model->children();
1787 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1789 in_group_row_change = true;
1791 for (i = rows.begin(); i != rows.end(); ++i) {
1792 if ((*i)[group_columns.group] == group) {
1793 (*i)[group_columns.visible] = !group->is_hidden ();
1794 (*i)[group_columns.text] = group->name ();
1799 in_group_row_change = false;
1801 if (change.contains (Properties::name)) {
1802 _group_tabs->set_dirty ();
1805 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
1806 if ((*j)->route_group() == group) {
1807 if (group->is_hidden ()) {
1817 Mixer_UI::show_mixer_list (bool yn)
1820 list_vpacker.show ();
1822 list_vpacker.hide ();
1825 _show_mixer_list = yn;
1829 Mixer_UI::show_monitor_section (bool yn)
1831 if (!monitor_section()) {
1834 if (monitor_section()->tearoff().torn_off()) {
1839 monitor_section()->tearoff().show();
1841 monitor_section()->tearoff().hide();
1846 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
1851 if ((iter = group_model->get_iter (path))) {
1853 if ((group = (*iter)[group_columns.group]) == 0) {
1857 if (new_text != group->name()) {
1858 group->set_name (new_text);
1864 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
1868 if (in_group_row_change) {
1872 if ((group = (*iter)[group_columns.group]) == 0) {
1876 std::string name = (*iter)[group_columns.text];
1878 if (name != group->name()) {
1879 group->set_name (name);
1882 bool hidden = !(*iter)[group_columns.visible];
1884 if (hidden != group->is_hidden ()) {
1885 group->set_hidden (hidden, this);
1889 /** Called when a group model row is deleted, but also when the model is
1890 * reordered by a user drag-and-drop; the latter is what we are
1891 * interested in here.
1894 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
1896 if (_in_group_rebuild_or_clear) {
1900 /* Re-write the session's route group list so that the new order is preserved */
1902 list<RouteGroup*> new_list;
1904 Gtk::TreeModel::Children children = group_model->children();
1905 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
1906 RouteGroup* g = (*i)[group_columns.group];
1908 new_list.push_back (g);
1912 _session->reorder_route_groups (new_list);
1917 Mixer_UI::add_route_group (RouteGroup* group)
1919 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
1922 in_group_row_change = true;
1924 TreeModel::Row row = *(group_model->append());
1925 row[group_columns.visible] = !group->is_hidden ();
1926 row[group_columns.group] = group;
1927 if (!group->name().empty()) {
1928 row[group_columns.text] = group->name();
1930 row[group_columns.text] = _("unnamed");
1934 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
1937 TreeViewColumn* col = group_display.get_column (0);
1938 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
1939 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
1942 _group_tabs->set_dirty ();
1944 in_group_row_change = false;
1948 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
1950 using namespace Menu_Helpers;
1952 if (Keyboard::is_context_menu_event (ev)) {
1953 ARDOUR_UI::instance()->add_route ();
1961 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
1963 printf ("Mixer_UI::scroller_drag_data_received\n");
1964 if (data.get_target() != "PluginFavoritePtr") {
1965 context->drag_finish (false, false, time);
1969 const void * d = data.get_data();
1970 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1972 PluginPresetList nfos;
1974 tv->get_object_drag_data (nfos, &source);
1976 Route::ProcessorList pl;
1979 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1980 PluginPresetPtr ppp = (*i);
1981 PluginInfoPtr pip = ppp->_pip;
1982 if (!pip->is_instrument ()) {
1985 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);
1989 context->drag_finish (ok, false, time);
1993 Mixer_UI::set_strip_width (Width w, bool save)
1997 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1998 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2003 struct PluginStateSorter {
2005 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2006 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2007 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2008 if (aiter != _user.end() && biter != _user.end()) {
2009 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2011 if (aiter != _user.end()) {
2014 if (biter != _user.end()) {
2017 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2020 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2022 std::list<std::string> _user;
2026 Mixer_UI::set_state (const XMLNode& node, int version)
2028 XMLProperty const * prop;
2031 Tabbable::set_state (node, version);
2033 if ((prop = node.property ("narrow-strips"))) {
2034 if (string_is_affirmative (prop->value())) {
2035 set_strip_width (Narrow);
2037 set_strip_width (Wide);
2041 if ((prop = node.property ("show-mixer"))) {
2042 if (string_is_affirmative (prop->value())) {
2047 if ((prop = node.property ("maximised"))) {
2048 bool yn = string_is_affirmative (prop->value());
2049 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer"));
2051 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2052 bool fs = tact && tact->get_active();
2054 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2058 if ((prop = node.property ("show-mixer-list"))) {
2059 bool yn = string_is_affirmative (prop->value());
2060 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMixerList"));
2062 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2064 /* do it twice to force the change */
2065 tact->set_active (!yn);
2066 tact->set_active (yn);
2070 XMLNode* plugin_order;
2071 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2072 store_current_favorite_order ();
2073 std::list<string> order;
2074 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2075 XMLNodeConstIterator i;
2076 for (i = kids.begin(); i != kids.end(); ++i) {
2077 if ((prop = (*i)->property ("unique-id"))) {
2078 std::string unique_id = prop->value();
2079 order.push_back (unique_id);
2080 if ((prop = (*i)->property ("expanded"))) {
2081 favorite_ui_state[unique_id] = string_is_affirmative (prop->value());
2085 PluginStateSorter cmp (order);
2086 favorite_order.sort (cmp);
2087 sync_treeview_from_favorite_order ();
2093 Mixer_UI::get_state ()
2095 XMLNode* node = new XMLNode (X_("Mixer"));
2099 node->add_child_nocopy (Tabbable::get_state());
2101 snprintf(buf,sizeof(buf), "%f", rhs_pane1.get_divider());
2102 node->add_property(X_("mixer-rhs-pane1-pos"), string(buf));
2103 snprintf(buf,sizeof(buf), "%f", rhs_pane2.get_divider());
2104 node->add_property(X_("mixer-rhs_pane2-pos"), string(buf));
2105 snprintf(buf,sizeof(buf), "%f", list_hpane.get_divider());
2106 node->add_property(X_("mixer-list-hpane-pos"), string(buf));
2107 snprintf(buf,sizeof(buf), "%f", inner_pane.get_divider());
2108 node->add_property(X_("mixer-inner-pane-pos"), string(buf));
2110 node->add_property ("narrow-strips", _strip_width == Narrow ? "yes" : "no");
2111 node->add_property ("show-mixer", _visible ? "yes" : "no");
2112 node->add_property ("show-mixer-list", _show_mixer_list ? "yes" : "no");
2113 node->add_property ("maximised", _maximised ? "yes" : "no");
2115 store_current_favorite_order ();
2116 XMLNode* plugin_order = new XMLNode ("PluginOrder");
2118 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2119 XMLNode* p = new XMLNode ("PluginInfo");
2120 p->add_property ("sort", cnt);
2121 p->add_property ("unique-id", (*i)->unique_id);
2122 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2123 p->add_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2125 plugin_order->add_child_nocopy (*p);
2127 node->add_child_nocopy (*plugin_order);
2133 Mixer_UI::scroll_left ()
2135 if (!scroller.get_hscrollbar()) return;
2136 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2137 int sc_w = scroller.get_width();
2138 int sp_w = strip_packer.get_width();
2142 int lp = adj->get_value();
2144 using namespace Gtk::Box_Helpers;
2145 const BoxList& strips = strip_packer.children();
2146 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2147 lm += i->get_widget()->get_width ();
2149 lm -= i->get_widget()->get_width ();
2153 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2157 Mixer_UI::scroll_right ()
2159 if (!scroller.get_hscrollbar()) return;
2160 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2161 int sc_w = scroller.get_width();
2162 int sp_w = strip_packer.get_width();
2166 int lp = adj->get_value();
2168 using namespace Gtk::Box_Helpers;
2169 const BoxList& strips = strip_packer.children();
2170 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2171 lm += i->get_widget()->get_width ();
2176 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2180 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2182 switch (ev->direction) {
2183 case GDK_SCROLL_LEFT:
2187 if (ev->state & Keyboard::TertiaryModifier) {
2193 case GDK_SCROLL_RIGHT:
2197 case GDK_SCROLL_DOWN:
2198 if (ev->state & Keyboard::TertiaryModifier) {
2210 Mixer_UI::parameter_changed (string const & p)
2212 if (p == "show-group-tabs") {
2213 bool const s = _session->config.get_show_group_tabs ();
2215 _group_tabs->show ();
2217 _group_tabs->hide ();
2219 } else if (p == "default-narrow_ms") {
2220 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2221 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2222 (*i)->set_width_enum (s ? Narrow : Wide, this);
2224 } else if (p == "use-monitor-bus") {
2225 if (_session && !_session->monitor_out()) {
2226 monitor_section_detached ();
2232 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2234 g->set_active (a, this);
2238 Mixer_UI::plugin_selector()
2240 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2241 if (!_plugin_selector)
2242 _plugin_selector = new PluginSelector (PluginManager::instance());
2245 return _plugin_selector;
2249 Mixer_UI::setup_track_display ()
2251 track_model = ListStore::create (stripable_columns);
2252 track_display.set_model (track_model);
2253 track_display.append_column (_("Show"), stripable_columns.visible);
2254 track_display.append_column (_("Strips"), stripable_columns.text);
2255 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2256 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2257 track_display.get_column (0)->set_expand(false);
2258 track_display.get_column (1)->set_expand(true);
2259 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2260 track_display.set_name (X_("EditGroupList"));
2261 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2262 track_display.set_reorderable (true);
2263 track_display.set_headers_visible (true);
2264 track_display.set_can_focus(false);
2266 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2267 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2269 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2270 track_list_visible_cell->property_activatable() = true;
2271 track_list_visible_cell->property_radio() = false;
2272 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2274 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2276 track_display_scroller.add (track_display);
2277 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2279 VBox* v = manage (new VBox);
2281 v->pack_start (track_display_scroller, true, true);
2283 Button* b = manage (new Button);
2285 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
2289 b->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
2291 v->pack_start (*b, false, false);
2293 track_display_frame.set_name("BaseFrame");
2294 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2295 track_display_frame.add (*v);
2297 track_display_scroller.show();
2298 track_display_frame.show();
2299 track_display.show();
2303 Mixer_UI::new_track_or_bus ()
2305 ARDOUR_UI::instance()->add_route ();
2309 Mixer_UI::update_title ()
2311 if (!own_window()) {
2318 if (_session->snap_name() != _session->name()) {
2319 n = _session->snap_name ();
2321 n = _session->name ();
2324 if (_session->dirty ()) {
2328 WindowTitle title (n);
2329 title += S_("Window|Mixer");
2330 title += Glib::get_application_name ();
2331 own_window()->set_title (title.get_string());
2335 WindowTitle title (S_("Window|Mixer"));
2336 title += Glib::get_application_name ();
2337 own_window()->set_title (title.get_string());
2342 Mixer_UI::strip_by_x (int x)
2344 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2347 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2348 x2 = x1 + (*i)->get_width();
2350 if (x >= x1 && x <= x2) {
2359 Mixer_UI::set_axis_targets_for_operation ()
2361 _axis_targets.clear ();
2363 if (!_selection.empty()) {
2364 _axis_targets = _selection.axes;
2368 // removed "implicit" selections of strips, after discussion on IRC
2373 Mixer_UI::monitor_section_going_away ()
2375 if (_monitor_section) {
2376 monitor_section_detached ();
2377 out_packer.remove (_monitor_section->tearoff());
2378 _monitor_section->set_session (0);
2379 delete _monitor_section;
2380 _monitor_section = 0;
2385 Mixer_UI::toggle_midi_input_active (bool flip_others)
2387 boost::shared_ptr<RouteList> rl (new RouteList);
2390 set_axis_targets_for_operation ();
2392 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2393 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2397 onoff = !mt->input_active();
2401 _session->set_exclusive_input_active (rl, onoff, flip_others);
2405 Mixer_UI::maximise_mixer_space ()
2407 if (!own_window()) {
2415 _window->fullscreen ();
2420 Mixer_UI::restore_mixer_space ()
2422 if (!own_window()) {
2430 own_window()->unfullscreen();
2435 Mixer_UI::monitor_section_attached ()
2437 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2438 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2439 act->set_sensitive (true);
2440 tact->set_active ();
2444 Mixer_UI::monitor_section_detached ()
2446 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2447 act->set_sensitive (false);
2451 Mixer_UI::store_current_favorite_order ()
2453 typedef Gtk::TreeModel::Children type_children;
2454 type_children children = favorite_plugins_model->children();
2455 favorite_order.clear();
2456 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2458 Gtk::TreeModel::Row row = *iter;
2459 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2460 favorite_order.push_back (ppp->_pip);
2461 std::string name = row[favorite_plugins_columns.name];
2462 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2467 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2469 Gtk::TreeModel::Row row = *iter;
2470 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2472 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2476 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2478 PluginManager& manager (PluginManager::instance());
2479 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2480 if (manager.get_status (*i) != PluginManager::Favorite) {
2483 result.push_back (*i);
2487 struct PluginCustomSorter {
2489 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2490 PluginInfoList::const_iterator aiter = _user.begin();
2491 PluginInfoList::const_iterator biter = _user.begin();
2492 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2493 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2495 if (aiter != _user.end() && biter != _user.end()) {
2496 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2498 if (aiter != _user.end()) {
2501 if (biter != _user.end()) {
2504 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2506 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2508 PluginInfoList _user;
2512 Mixer_UI::refill_favorite_plugins ()
2514 PluginInfoList plugs;
2515 PluginManager& mgr (PluginManager::instance());
2518 refiller (plugs, mgr.lv2_plugin_info ());
2520 #ifdef WINDOWS_VST_SUPPORT
2521 refiller (plugs, mgr.windows_vst_plugin_info ());
2523 #ifdef LXVST_SUPPORT
2524 refiller (plugs, mgr.lxvst_plugin_info ());
2526 #ifdef MACVST_SUPPORT
2527 refiller (plugs, mgr.mac_vst_plugin_info ());
2529 #ifdef AUDIOUNIT_SUPPORT
2530 refiller (plugs, mgr.au_plugin_info ());
2532 refiller (plugs, mgr.ladspa_plugin_info ());
2533 refiller (plugs, mgr.lua_plugin_info ());
2535 store_current_favorite_order ();
2537 PluginCustomSorter cmp (favorite_order);
2540 favorite_order = plugs;
2542 sync_treeview_from_favorite_order ();
2546 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2549 if (!(iter = favorite_plugins_model->get_iter (path))) {
2552 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2556 PluginInfoPtr pip = ppp->_pip;
2557 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2558 if (favorite_ui_state[pip->unique_id]) {
2559 favorite_plugins_display.expand_row (path, true);
2565 Mixer_UI::sync_treeview_from_favorite_order ()
2567 favorite_plugins_model->clear ();
2568 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
2569 PluginInfoPtr pip = (*i);
2571 TreeModel::Row newrow = *(favorite_plugins_model->append());
2572 newrow[favorite_plugins_columns.name] = (*i)->name;
2573 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
2578 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
2579 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
2580 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
2581 child_row[favorite_plugins_columns.name] = (*j).label;
2582 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
2584 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2585 if (favorite_ui_state[pip->unique_id]) {
2586 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
2593 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
2595 using namespace Gtk::Menu_Helpers;
2597 Gtk::Menu* m = manage (new Menu);
2598 MenuList& items = m->items ();
2600 if (_selection.axes.empty()) {
2601 items.push_back (MenuElem (_("No Track/Bus is selected.")));
2603 items.push_back (MenuElem (_("Add at the top"),
2604 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
2605 items.push_back (MenuElem (_("Add Pre-Fader"),
2606 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
2607 items.push_back (MenuElem (_("Add Post-Fader"),
2608 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
2609 items.push_back (MenuElem (_("Add at the end"),
2610 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
2613 items.push_back (SeparatorElem());
2615 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
2617 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2618 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
2619 // we cannot currently delete AU presets
2620 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
2621 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
2625 m->popup (ev->button, ev->time);
2629 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
2631 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) {
2632 TreeModel::Path path;
2633 TreeViewColumn* column;
2635 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
2636 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2638 selection->unselect_all();
2639 selection->select(path);
2642 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2644 popup_note_context_menu (ev);
2652 Mixer_UI::selected_plugin ()
2654 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2656 return PluginPresetPtr();
2658 Gtk::TreeModel::iterator iter = selection->get_selected();
2660 return PluginPresetPtr();
2662 return (*iter)[favorite_plugins_columns.plugin];
2666 Mixer_UI::add_selected_processor (ProcessorPosition pos)
2668 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2670 add_favorite_processor (ppp, pos);
2675 Mixer_UI::delete_selected_preset ()
2680 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2681 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
2684 PluginPtr plugin = ppp->_pip->load (*_session);
2685 plugin->get_presets();
2686 plugin->remove_preset (ppp->_preset.label);
2690 Mixer_UI::remove_selected_from_favorites ()
2692 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2696 PluginManager::PluginStatusType status = PluginManager::Normal;
2697 PluginManager& manager (PluginManager::instance());
2699 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2700 manager.save_statuses ();
2704 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
2707 if (!(iter = favorite_plugins_model->get_iter (path))) {
2710 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2711 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
2715 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
2717 if (!_session || _selection.axes.empty()) {
2721 PluginInfoPtr pip = ppp->_pip;
2722 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
2723 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
2729 PluginPtr p = pip->load (*_session);
2735 if (ppp->_preset.valid) {
2736 p->load_preset (ppp->_preset);
2739 Route::ProcessorStreams err;
2740 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2744 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
2747 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
2754 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
2758 if (!np->display_to_user()) {
2761 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
2762 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
2767 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
2771 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
2778 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
2780 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
2784 // only allow to re-order top-level items
2786 if (TreePath::get_from_selection_data (data, src)) {
2787 if (src.up() && src.up()) {
2792 // don't allow to drop as child-rows.
2793 Gtk::TreeModel::Path _dest = dest; // un const
2794 const bool is_child = _dest.up (); // explicit bool for clang
2795 if (!is_child || _dest.empty ()) {
2802 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
2804 if (data.get_target() != "PluginPresetPtr") {
2807 if (data.get_length() != sizeof (PluginPresetPtr)) {
2810 const void *d = data.get_data();
2811 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
2813 PluginManager::PluginStatusType status = PluginManager::Favorite;
2814 PluginManager& manager (PluginManager::instance());
2816 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2817 manager.save_statuses ();
2821 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
2823 /* call protected MixerActor:: method */
2828 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
2830 /* call protected MixerActor:: method */
2835 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
2837 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
2840 show_spill_change (s); /* EMIT SIGNAL */
2842 _group_tabs->hide ();
2844 _group_tabs->show ();
2846 redisplay_track_list ();
2851 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
2853 return s == spilled_strip.lock();
2857 Mixer_UI::register_actions ()
2859 Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
2861 myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
2862 myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
2863 myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
2864 myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
2865 myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
2866 myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
2869 myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
2870 myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
2871 myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
2872 myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
2873 myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
2874 myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
2875 myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
2876 myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
2878 myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
2879 myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
2881 myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
2882 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
2886 Mixer_UI::load_bindings ()
2888 bindings = Bindings::get_bindings (X_("Mixer"), myactions);
2891 template<class T> void
2892 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
2894 boost::shared_ptr<ControlList> cl (new ControlList);
2895 boost::shared_ptr<AutomationControl> ac;
2897 bool have_val = false;
2899 set_axis_targets_for_operation ();
2901 BOOST_FOREACH(AxisView* r, _axis_targets) {
2902 boost::shared_ptr<Stripable> s = r->stripable();
2904 ac = (s.get()->*get_control)();
2908 val = !ac->get_value();
2915 _session->set_controls (cl, val, Controllable::UseGroup);
2919 Mixer_UI::solo_action ()
2921 control_action (&Stripable::solo_control);
2925 Mixer_UI::mute_action ()
2927 control_action (&Stripable::mute_control);
2931 Mixer_UI::rec_enable_action ()
2933 control_action (&Stripable::rec_enable_control);
2937 Mixer_UI::step_gain_up_action ()
2939 set_axis_targets_for_operation ();
2941 BOOST_FOREACH(AxisView* r, _axis_targets) {
2942 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2944 ms->step_gain_up ();
2950 Mixer_UI::step_gain_down_action ()
2952 set_axis_targets_for_operation ();
2954 BOOST_FOREACH(AxisView* r, _axis_targets) {
2955 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2957 ms->step_gain_down ();
2963 Mixer_UI::unity_gain_action ()
2965 set_axis_targets_for_operation ();
2967 BOOST_FOREACH(AxisView* r, _axis_targets) {
2968 boost::shared_ptr<Stripable> s = r->stripable();
2970 boost::shared_ptr<AutomationControl> ac = s->gain_control();
2972 ac->set_value (1.0, Controllable::UseGroup);
2979 Mixer_UI::copy_processors ()
2981 set_axis_targets_for_operation ();
2983 BOOST_FOREACH(AxisView* r, _axis_targets) {
2984 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2986 ms->copy_processors ();
2991 Mixer_UI::cut_processors ()
2993 set_axis_targets_for_operation ();
2995 BOOST_FOREACH(AxisView* r, _axis_targets) {
2996 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2998 ms->cut_processors ();
3003 Mixer_UI::paste_processors ()
3005 set_axis_targets_for_operation ();
3007 BOOST_FOREACH(AxisView* r, _axis_targets) {
3008 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3010 ms->paste_processors ();
3015 Mixer_UI::select_all_processors ()
3017 set_axis_targets_for_operation ();
3019 BOOST_FOREACH(AxisView* r, _axis_targets) {
3020 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3022 ms->select_all_processors ();
3027 Mixer_UI::toggle_processors ()
3029 set_axis_targets_for_operation ();
3031 BOOST_FOREACH(AxisView* r, _axis_targets) {
3032 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3034 ms->toggle_processors ();
3039 Mixer_UI::ab_plugins ()
3041 set_axis_targets_for_operation ();
3043 BOOST_FOREACH(AxisView* r, _axis_targets) {
3044 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3052 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3054 set_axis_targets_for_operation ();
3056 BOOST_FOREACH(AxisView* r, _axis_targets) {
3057 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3059 ms->vca_assign (vca);
3066 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3068 set_axis_targets_for_operation ();
3070 BOOST_FOREACH(AxisView* r, _axis_targets) {
3071 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3073 ms->vca_unassign (vca);