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/selection.h"
52 #include "ardour/session.h"
53 #include "ardour/vca.h"
54 #include "ardour/vca_manager.h"
58 #include "mixer_strip.h"
59 #include "monitor_section.h"
60 #include "plugin_selector.h"
61 #include "public_editor.h"
62 #include "mouse_cursors.h"
63 #include "ardour_ui.h"
66 #include "route_sorter.h"
68 #include "gui_thread.h"
69 #include "mixer_group_tabs.h"
70 #include "route_sorter.h"
72 #include "ui_config.h"
73 #include "vca_master_strip.h"
77 using namespace ARDOUR;
78 using namespace ARDOUR_UI_UTILS;
82 using namespace Gtkmm2ext;
88 Mixer_UI* Mixer_UI::_instance = 0;
94 _instance = new Mixer_UI;
100 Mixer_UI::Mixer_UI ()
101 : Tabbable (_content, _("Mixer"))
102 , no_track_list_redisplay (false)
103 , in_group_row_change (false)
105 , _monitor_section (0)
106 , _plugin_selector (0)
107 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
108 , ignore_reorder (false)
109 , _in_group_rebuild_or_clear (false)
110 , _route_deletion_in_progress (false)
112 , _show_mixer_list (true)
113 , myactions (X_("mixer"))
114 , _selection (*this, *this)
118 _content.set_data ("ardour-bindings", bindings);
120 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
122 scroller.set_can_default (true);
123 // set_default (scroller);
125 scroller_base.set_flags (Gtk::CAN_FOCUS);
126 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
127 scroller_base.set_name ("MixerWindow");
128 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
130 /* set up drag-n-drop */
131 vector<TargetEntry> target_table;
132 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
133 scroller_base.drag_dest_set (target_table);
134 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
136 // add as last item of strip packer
137 strip_packer.pack_end (scroller_base, true, true);
139 _group_tabs = new MixerGroupTabs (this);
140 VBox* b = manage (new VBox);
142 b->set_border_width (0);
143 b->pack_start (*_group_tabs, PACK_SHRINK);
144 b->pack_start (strip_packer);
146 b->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
149 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
151 setup_track_display ();
153 group_model = ListStore::create (group_columns);
154 group_display.set_model (group_model);
155 group_display.append_column (_("Show"), group_columns.visible);
156 group_display.append_column (_("Group"), group_columns.text);
157 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
158 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
159 group_display.get_column (0)->set_expand(false);
160 group_display.get_column (1)->set_expand(true);
161 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
162 group_display.set_name ("EditGroupList");
163 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
164 group_display.set_reorderable (true);
165 group_display.set_headers_visible (true);
166 group_display.set_rules_hint (true);
167 group_display.set_can_focus(false);
169 /* name is directly editable */
171 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
172 name_cell->property_editable() = true;
173 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
175 /* use checkbox for the active column */
177 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
178 active_cell->property_activatable() = true;
179 active_cell->property_radio() = false;
181 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
182 /* We use this to notice drag-and-drop reorders of the group list */
183 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
184 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
186 group_display_scroller.add (group_display);
187 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
189 HBox* route_group_display_button_box = manage (new HBox());
191 Button* route_group_add_button = manage (new Button ());
192 Button* route_group_remove_button = manage (new Button ());
196 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
198 route_group_add_button->add (*w);
200 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
202 route_group_remove_button->add (*w);
204 route_group_display_button_box->set_homogeneous (true);
206 route_group_add_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_route_group));
207 route_group_remove_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::remove_selected_route_group));
209 route_group_display_button_box->add (*route_group_add_button);
210 route_group_display_button_box->add (*route_group_remove_button);
212 group_display_vbox.pack_start (group_display_scroller, true, true);
213 group_display_vbox.pack_start (*route_group_display_button_box, false, false);
215 group_display_frame.set_name ("BaseFrame");
216 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
217 group_display_frame.add (group_display_vbox);
220 list<TargetEntry> target_list;
221 target_list.push_back (TargetEntry ("PluginPresetPtr"));
223 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
224 favorite_plugins_display.set_model (favorite_plugins_model);
225 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
226 favorite_plugins_display.set_name ("EditGroupList");
227 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
228 favorite_plugins_display.set_reorderable (false);
229 favorite_plugins_display.set_headers_visible (true);
230 favorite_plugins_display.set_rules_hint (true);
231 favorite_plugins_display.set_can_focus (false);
232 favorite_plugins_display.set_tooltip_column (0);
233 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
234 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
235 favorite_plugins_display.add_drop_targets (target_list);
236 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
237 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
238 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
239 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
240 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
241 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
243 favorite_plugins_scroller.add (favorite_plugins_display);
244 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
246 favorite_plugins_frame.set_name ("BaseFrame");
247 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
248 favorite_plugins_frame.add (favorite_plugins_scroller);
250 rhs_pane1.add (favorite_plugins_frame);
251 rhs_pane1.add (track_display_frame);
253 rhs_pane2.add (rhs_pane1);
254 rhs_pane2.add (group_display_frame);
256 list_vpacker.pack_start (rhs_pane2, true, true);
258 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
259 vca_vpacker.pack_start (vca_label_bar, false, false);
261 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
262 vca_scroller_base.set_name (X_("MixerWindow"));
263 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
264 vca_hpacker.pack_end (vca_scroller_base, true, true);
266 vca_scroller.add (vca_hpacker);
267 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
268 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
270 vca_vpacker.pack_start (vca_scroller, true, true);
272 inner_pane.add (scroller);
273 inner_pane.add (vca_vpacker);
275 global_hpacker.pack_start (inner_pane, true, true);
276 global_hpacker.pack_start (out_packer, false, false);
278 list_hpane.set_check_divider_position (true);
279 list_hpane.add (list_vpacker);
280 list_hpane.add (global_hpacker);
281 list_hpane.set_child_minsize (list_vpacker, 1);
284 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
290 if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) {
293 rhs_pane1.set_divider (0, fract);
295 if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
298 rhs_pane2.set_divider (0, fract);
300 if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
303 list_hpane.set_divider (0, fract);
305 if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
308 inner_pane.set_divider (0, fract);
311 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
312 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
313 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
314 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
316 _content.pack_start (list_hpane, true, true);
320 route_group_display_button_box->show();
321 route_group_add_button->show();
322 route_group_remove_button->show();
325 _content.set_name ("MixerWindow");
327 global_hpacker.show();
329 scroller_base.show();
330 scroller_hpacker.show();
331 mixer_scroller_vpacker.show();
333 group_display_button_label.show();
334 group_display_button.show();
335 group_display_scroller.show();
336 favorite_plugins_scroller.show();
337 group_display_vbox.show();
338 group_display_frame.show();
339 favorite_plugins_frame.show();
347 vca_label_bar.show();
349 vca_scroller_base.show();
352 group_display.show();
353 favorite_plugins_display.show();
355 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
359 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
361 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
362 _plugin_selector = new PluginSelector (PluginManager::instance ());
364 #error implement deferred Plugin-Favorite list
366 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
367 PluginManager::instance ().PluginStatusesChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
368 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
371 Mixer_UI::~Mixer_UI ()
373 if (_monitor_section) {
374 monitor_section_detached ();
375 delete _monitor_section;
377 delete _plugin_selector;
388 Mixer_UI::use_own_window (bool and_fill_it)
390 bool new_window = !own_window();
392 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
394 if (win && new_window) {
395 win->set_name ("MixerWindow");
396 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
397 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
398 win->set_data ("ardour-bindings", bindings);
400 if (!win->get_focus()) {
401 /* set focus widget to something, anything */
402 win->set_focus (scroller);
410 Mixer_UI::show_window ()
412 Tabbable::show_window ();
414 /* show/hide group tabs as required */
415 parameter_changed ("show-group-tabs");
417 /* now reset each strips width so the right widgets are shown */
419 TreeModel::Children rows = track_model->children();
420 TreeModel::Children::iterator ri;
422 for (ri = rows.begin(); ri != rows.end(); ++ri) {
423 AxisView* av = (*ri)[stripable_columns.strip];
424 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
428 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
429 /* Fix visibility of mixer strip stuff */
430 ms->parameter_changed (X_("mixer-element-visibility"));
433 /* force focus into main area */
434 scroller_base.grab_focus ();
438 Mixer_UI::remove_master (VCAMasterStrip* vms)
440 if (_session && _session->deletion_in_progress()) {
441 /* its all being taken care of */
445 TreeModel::Children rows = track_model->children();
446 TreeModel::Children::iterator ri;
448 for (ri = rows.begin(); ri != rows.end(); ++ri) {
449 if ((*ri)[stripable_columns.strip] == vms) {
450 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
451 track_model->erase (ri);
458 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
460 using namespace Menu_Helpers;
462 if (Keyboard::is_context_menu_event (ev)) {
463 ARDOUR_UI::instance()->add_route ();
471 Mixer_UI::add_masters (VCAList& vlist)
475 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
476 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
483 Mixer_UI::add_routes (RouteList& rlist)
487 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
495 Mixer_UI::add_stripables (StripableList& slist)
497 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
498 bool from_scratch = (track_model->children().size() == 0);
499 uint32_t nroutes = 0;
501 slist.sort (Stripable::Sorter());
503 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
504 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
512 // XXX what does this special case do?
513 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
522 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
524 track_display.set_model (Glib::RefPtr<ListStore>());
526 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
528 boost::shared_ptr<Route> route;
529 boost::shared_ptr<VCA> vca;
531 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
533 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
535 TreeModel::Row row = *(track_model->append());
537 row[stripable_columns.text] = vca->name();
538 row[stripable_columns.visible] = vms->marked_for_display ();
539 row[stripable_columns.strip] = vms;
540 row[stripable_columns.stripable] = vca;
542 vms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
544 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
546 if (route->is_auditioner()) {
550 if (route->is_monitor()) {
552 if (!_monitor_section) {
553 _monitor_section = new MonitorSection (_session);
555 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
557 _monitor_section->tearoff().set_state (*mnode);
561 out_packer.pack_end (_monitor_section->tearoff(), false, false);
562 _monitor_section->set_session (_session);
563 _monitor_section->tearoff().show_all ();
565 _monitor_section->tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
566 _monitor_section->tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
568 if (_monitor_section->tearoff().torn_off()) {
569 monitor_section_detached ();
571 monitor_section_attached ();
574 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
576 /* no regular strip shown for control out */
581 strip = new MixerStrip (*this, _session, route);
582 strips.push_back (strip);
584 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
586 if (strip->width_owner() != strip) {
587 strip->set_width_enum (_strip_width, this);
592 if (!route->is_master()) {
594 TreeModel::Row row = *(track_model->insert (insert_iter));
596 row[stripable_columns.text] = route->name();
597 row[stripable_columns.visible] = strip->marked_for_display();
598 row[stripable_columns.stripable] = route;
599 row[stripable_columns.strip] = strip;
603 out_packer.pack_start (*strip, false, false);
604 strip->set_packed (true);
607 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
608 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
611 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
612 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
615 } catch (const std::exception& e) {
616 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
619 track_display.set_model (track_model);
621 /* catch up on selection state, which we left to the editor to set */
622 sync_treeview_from_presentation_info (PropertyChange (Properties::selected));
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_none ()
642 _selection.clear_routes();
643 deselect_all_strip_processors();
647 Mixer_UI::delete_processors ()
649 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
650 (*i)->delete_processors();
656 Mixer_UI::remove_strip (MixerStrip* strip)
658 if (_session && _session->deletion_in_progress()) {
659 /* its all being taken care of */
663 TreeModel::Children rows = track_model->children();
664 TreeModel::Children::iterator ri;
665 list<MixerStrip *>::iterator i;
667 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
671 PBD::Unwinder<bool> uwi (ignore_reorder, true);
673 for (ri = rows.begin(); ri != rows.end(); ++ri) {
674 if ((*ri)[stripable_columns.strip] == strip) {
675 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
676 track_model->erase (ri);
683 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
685 if (what_changed.contains (Properties::selected)) {
686 _selection.presentation_info_changed (what_changed);
690 soh.add (Properties::selected);
691 soh.add (Properties::order);
692 soh.add (Properties::hidden);
694 if (what_changed.contains (soh)) {
695 sync_treeview_from_presentation_info (what_changed);
700 Mixer_UI::sync_presentation_info_from_treeview ()
702 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
706 TreeModel::Children rows = track_model->children();
712 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
714 TreeModel::Children::iterator ri;
717 PresentationInfo::order_t master_key = _session->master_order_key ();
718 PresentationInfo::order_t order = 0;
721 TreeOrderKeys sorted;
723 PresentationInfo::ChangeSuspender cs;
725 for (ri = rows.begin(); ri != rows.end(); ++ri) {
726 bool visible = (*ri)[stripable_columns.visible];
727 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
729 #ifndef NDEBUG // these should not exist in the mixer's treeview
734 if (stripable->is_monitor() || stripable->is_auditioner()) {
738 if (stripable->is_master()) {
744 stripable->presentation_info().set_hidden (!visible);
746 // leave master where it is.
747 if (order == master_key) {
751 if (order != stripable->presentation_info().order()) {
752 stripable->set_presentation_order (order);
756 sorted.push_back (TreeOrderKey (count, stripable));
761 change |= _session->ensure_stripable_sort_order ();
764 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
765 _session->set_dirty();
770 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
772 if (!_session || _session->deletion_in_progress()) {
776 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
778 /* we could get here after either a change in the Mixer or Editor sort
779 * order, but either way, the mixer order keys reflect the intended
780 * order for the GUI, so reorder the treeview model to match it.
783 vector<int> neworder;
784 TreeModel::Children rows = track_model->children();
785 uint32_t old_order = 0;
786 bool changed = false;
792 TreeOrderKeys sorted;
793 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
794 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
795 sorted.push_back (TreeOrderKey (old_order, stripable));
798 TreeOrderKeySorter cmp;
800 sort (sorted.begin(), sorted.end(), cmp);
801 neworder.assign (sorted.size(), 0);
805 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
807 neworder[n] = sr->old_display_order;
809 if (sr->old_display_order != n) {
815 Unwinder<bool> uw (ignore_reorder, true);
816 track_model->reorder (neworder);
819 if (what_changed.contains (Properties::selected)) {
821 PresentationInfo::ChangeSuspender cs;
823 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
824 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
825 if (stripable && stripable->is_selected()) {
828 _selection.remove (*i);
832 if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll ()) {
833 move_stripable_into_view ((*_selection.axes.begin())->stripable());
837 redisplay_track_list ();
842 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
844 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
845 if ((*i)->route() == r) {
854 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
856 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
857 if ((*i)->stripable() == s) {
866 Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
868 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
869 if ((*i)->stripable() == s) {
878 Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
880 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
881 if ((*i)->control() == c) {
889 struct MixerStripSorter {
890 bool operator() (const MixerStrip* ms_a, const MixerStrip* ms_b)
892 boost::shared_ptr<ARDOUR::Stripable> const& a = ms_a->stripable ();
893 boost::shared_ptr<ARDOUR::Stripable> const& b = ms_b->stripable ();
894 return ARDOUR::Stripable::Sorter(true)(a, b);
899 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
901 if (ev->button == 1) {
902 if (_selection.selected (strip)) {
903 /* primary-click: toggle selection state of strip */
904 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
905 _selection.remove (strip);
906 } else if (_selection.axes.size() > 1) {
907 /* de-select others */
908 _selection.set (strip);
911 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
912 _selection.add (strip);
913 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
915 /* extend selection */
917 vector<MixerStrip*> tmp;
918 bool accumulate = false;
919 bool found_another = false;
921 strips.sort (MixerStripSorter());
923 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
928 /* hit clicked strip, start accumulating till we hit the first
937 } else if (_selection.selected (ms)) {
938 /* hit selected strip. if currently accumulating others,
939 we're done. if not accumulating others, start doing so.
941 found_another = true;
955 tmp.push_back (strip);
958 PresentationInfo::ChangeSuspender cs;
959 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
963 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
966 _selection.set (strip);
975 Mixer_UI::set_session (Session* sess)
977 SessionHandlePtr::set_session (sess);
979 if (_plugin_selector) {
980 _plugin_selector->set_session (_session);
983 _group_tabs->set_session (sess);
985 if (_monitor_section) {
986 _monitor_section->set_session (_session);
994 refill_favorite_plugins();
996 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
997 set_state (*node, 0);
1001 initial_track_display ();
1003 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1004 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1005 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1006 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1007 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1008 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1009 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1011 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1013 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1015 route_groups_changed ();
1021 /* catch up on selection state, etc. */
1024 sc.add (Properties::selected);
1025 _selection.presentation_info_changed (sc);
1031 Mixer_UI::session_going_away ()
1033 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1035 _in_group_rebuild_or_clear = true;
1036 group_model->clear ();
1037 _in_group_rebuild_or_clear = false;
1039 _selection.clear ();
1040 track_model->clear ();
1042 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1046 if (_monitor_section) {
1047 _monitor_section->tearoff().hide_visible ();
1050 monitor_section_detached ();
1056 SessionHandlePtr::session_going_away ();
1063 Mixer_UI::track_visibility_changed (std::string const & path)
1065 if (_session && _session->deletion_in_progress()) {
1071 if ((iter = track_model->get_iter (path))) {
1073 AxisView* av = (*iter)[stripable_columns.strip];
1074 bool visible = (*iter)[stripable_columns.visible];
1076 if (av->set_marked_for_display (!visible)) {
1077 update_track_visibility ();
1083 Mixer_UI::update_track_visibility ()
1085 TreeModel::Children rows = track_model->children();
1086 TreeModel::Children::iterator i;
1089 Unwinder<bool> uw (no_track_list_redisplay, true);
1091 for (i = rows.begin(); i != rows.end(); ++i) {
1092 AxisView* av = (*i)[stripable_columns.strip];
1093 (*i)[stripable_columns.visible] = av->marked_for_display ();
1096 /* force presentation catch up with visibility changes
1099 sync_presentation_info_from_treeview ();
1102 redisplay_track_list ();
1106 Mixer_UI::show_strip (MixerStrip* ms)
1108 TreeModel::Children rows = track_model->children();
1109 TreeModel::Children::iterator i;
1111 for (i = rows.begin(); i != rows.end(); ++i) {
1113 AxisView* av = (*i)[stripable_columns.strip];
1114 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1116 (*i)[stripable_columns.visible] = true;
1117 av->set_marked_for_display (true);
1118 update_track_visibility ();
1125 Mixer_UI::hide_strip (MixerStrip* ms)
1127 TreeModel::Children rows = track_model->children();
1128 TreeModel::Children::iterator i;
1130 for (i = rows.begin(); i != rows.end(); ++i) {
1132 AxisView* av = (*i)[stripable_columns.strip];
1133 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1135 (*i)[stripable_columns.visible] = false;
1136 av->set_marked_for_display (false);
1137 update_track_visibility ();
1144 Mixer_UI::start_updating ()
1146 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1151 Mixer_UI::stop_updating ()
1153 fast_screen_update_connection.disconnect();
1158 Mixer_UI::fast_update_strips ()
1160 if (_content.is_mapped () && _session) {
1161 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1162 (*i)->fast_update ();
1168 Mixer_UI::set_all_strips_visibility (bool yn)
1170 TreeModel::Children rows = track_model->children();
1171 TreeModel::Children::iterator i;
1174 Unwinder<bool> uw (no_track_list_redisplay, true);
1176 for (i = rows.begin(); i != rows.end(); ++i) {
1178 AxisView* av = (*i)[stripable_columns.strip];
1179 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1185 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1189 (*i)[stripable_columns.visible] = yn;
1193 redisplay_track_list ();
1198 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1200 TreeModel::Children rows = track_model->children();
1201 TreeModel::Children::iterator i;
1204 Unwinder<bool> uw (no_track_list_redisplay, true);
1206 for (i = rows.begin(); i != rows.end(); ++i) {
1208 AxisView* av = (*i)[stripable_columns.strip];
1209 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1215 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1219 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1220 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1224 (*i)[stripable_columns.visible] = yn;
1228 if (at) { /* track */
1229 (*i)[stripable_columns.visible] = yn;
1234 if (!at && !mt) { /* bus */
1235 (*i)[stripable_columns.visible] = yn;
1240 if (mt) { /* midi-track */
1241 (*i)[stripable_columns.visible] = yn;
1248 redisplay_track_list ();
1252 Mixer_UI::hide_all_routes ()
1254 set_all_strips_visibility (false);
1258 Mixer_UI::show_all_routes ()
1260 set_all_strips_visibility (true);
1264 Mixer_UI::show_all_audiobus ()
1266 set_all_audio_midi_visibility (2, true);
1269 Mixer_UI::hide_all_audiobus ()
1271 set_all_audio_midi_visibility (2, false);
1275 Mixer_UI::show_all_audiotracks()
1277 set_all_audio_midi_visibility (1, true);
1280 Mixer_UI::hide_all_audiotracks ()
1282 set_all_audio_midi_visibility (1, false);
1286 Mixer_UI::show_all_miditracks()
1288 set_all_audio_midi_visibility (3, true);
1291 Mixer_UI::hide_all_miditracks ()
1293 set_all_audio_midi_visibility (3, false);
1297 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1299 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1300 sync_presentation_info_from_treeview ();
1304 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1306 /* this happens as the second step of a DnD within the treeview as well
1307 as when a row/route is actually deleted.
1309 if it was a deletion then we have to force a redisplay because
1310 order keys may not have changed.
1313 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1314 sync_presentation_info_from_treeview ();
1316 if (_route_deletion_in_progress) {
1317 redisplay_track_list ();
1322 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1324 TreeModel::Children rows = track_model->children();
1325 std::list<boost::shared_ptr<VCA> > vcas;
1326 vcas.push_back (vca);
1328 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1329 AxisView* av = (*i)[stripable_columns.strip];
1330 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1331 if (vms && vms->vca()->slaved_to (vca)) {
1332 vcas.push_back (vms->vca());
1336 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1338 AxisView* av = (*i)[stripable_columns.strip];
1339 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1340 bool const visible = (*i)[stripable_columns.visible];
1343 /* we're in the middle of changing a row, don't worry */
1347 if (!strip->route()) {
1348 /* non-route element */
1352 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1356 bool slaved = false;
1357 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1358 if (strip->route()->slaved_to (*m)) {
1364 if (slaved && visible) {
1366 if (strip->packed()) {
1367 strip_packer.reorder_child (*strip, -1); /* put at end */
1369 strip_packer.pack_start (*strip, false, false);
1370 strip->set_packed (true);
1375 if (strip->packed()) {
1376 strip_packer.remove (*strip);
1377 strip->set_packed (false);
1384 Mixer_UI::redisplay_track_list ()
1386 if (no_track_list_redisplay) {
1390 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1392 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1394 spill_redisplay (sv);
1399 TreeModel::Children rows = track_model->children();
1400 TreeModel::Children::iterator i;
1401 uint32_t n_masters = 0;
1403 container_clear (vca_hpacker);
1404 vca_hpacker.pack_end (vca_scroller_base, true, true);
1406 for (i = rows.begin(); i != rows.end(); ++i) {
1408 AxisView* s = (*i)[stripable_columns.strip];
1409 bool const visible = (*i)[stripable_columns.visible];
1410 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1413 /* we're in the middle of changing a row, don't worry */
1417 VCAMasterStrip* vms;
1419 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1421 vca_hpacker.pack_start (*vms, false, false);
1428 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1436 if (strip->packed()) {
1437 strip_packer.reorder_child (*strip, -1); /* put at end */
1439 strip_packer.pack_start (*strip, false, false);
1440 strip->set_packed (true);
1445 if (stripable->is_master() || stripable->is_monitor()) {
1446 /* do nothing, these cannot be hidden */
1448 if (strip->packed()) {
1449 strip_packer.remove (*strip);
1450 strip->set_packed (false);
1456 /* update visibility of VCA assign buttons */
1458 if (n_masters == 0) {
1459 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1460 vca_vpacker.hide ();
1462 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1463 vca_vpacker.show ();
1466 _group_tabs->set_dirty ();
1470 Mixer_UI::strip_width_changed ()
1472 _group_tabs->set_dirty ();
1475 TreeModel::Children rows = track_model->children();
1476 TreeModel::Children::iterator i;
1479 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1480 AxisView* av = (*i)[stripable_columns.strip];
1481 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1487 bool visible = (*i)[stripable_columns.visible];
1490 strip->queue_draw();
1497 struct PresentationInfoMixerSorter
1499 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1500 if (a->is_master()) {
1501 /* master after everything else */
1503 } else if (b->is_master()) {
1504 /* everything else before master */
1507 return a->presentation_info().order () < b->presentation_info().order ();
1512 Mixer_UI::initial_track_display ()
1516 boost::shared_ptr<RouteList> routes = _session->get_routes();
1518 for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) {
1522 VCAList vcas = _session->vca_manager().vcas();
1524 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
1525 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
1528 sl.sort (PresentationInfoMixerSorter());
1531 /* These are also used inside ::add_stripables() but we need
1532 * them here because we're going to clear the track_model also.
1534 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1535 Unwinder<bool> uw2 (ignore_reorder, true);
1537 track_model->clear ();
1538 add_stripables (sl);
1541 sync_treeview_from_presentation_info (Properties::order);
1545 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1547 if (Keyboard::is_context_menu_event (ev)) {
1548 if (track_menu == 0) {
1549 build_track_menu ();
1551 track_menu->popup (ev->button, ev->time);
1554 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1555 TreeModel::Path path;
1556 TreeViewColumn* column;
1558 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1559 TreeIter iter = track_model->get_iter (path);
1560 if ((*iter)[stripable_columns.visible]) {
1561 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1562 move_stripable_into_view (s);
1571 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1573 if (!scroller.get_hscrollbar()) {
1576 if (s->presentation_info().special () || s->presentation_info().flag_match (PresentationInfo::VCA)) {
1586 Gtk::Allocation alloc;
1587 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1588 if ((*i)->route() == s) {
1591 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1592 alloc = (*i)->get_allocation ();
1600 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1602 if (x0 < adj->get_value()) {
1603 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1604 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1605 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1606 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1611 Mixer_UI::build_track_menu ()
1613 using namespace Menu_Helpers;
1614 using namespace Gtk;
1616 track_menu = new Menu;
1617 track_menu->set_name ("ArdourContextMenu");
1618 MenuList& items = track_menu->items();
1620 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1621 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1622 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1623 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1624 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1625 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1626 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1627 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1632 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1634 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1638 boost::shared_ptr<Stripable> s = ws.lock ();
1644 TreeModel::Children rows = track_model->children();
1645 TreeModel::Children::iterator i;
1647 for (i = rows.begin(); i != rows.end(); ++i) {
1648 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1652 if (what_changed.contains (ARDOUR::Properties::name)) {
1653 (*i)[stripable_columns.text] = s->name();
1656 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1657 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1658 redisplay_track_list ();
1665 if (s->is_master ()) {
1669 error << _("track display list item for renamed strip not found!") << endmsg;
1673 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1675 TreeModel::Path path;
1676 TreeViewColumn* column;
1680 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1681 if (ev->button == 3) {
1682 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1687 TreeIter iter = group_model->get_iter (path);
1689 if (ev->button == 3) {
1690 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1695 RouteGroup* group = (*iter)[group_columns.group];
1697 if (Keyboard::is_context_menu_event (ev)) {
1698 _group_tabs->get_menu(group)->popup (1, ev->time);
1702 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1704 if (Keyboard::is_edit_event (ev)) {
1706 // edit_route_group (group);
1708 group_display.queue_draw();
1717 bool visible = (*iter)[group_columns.visible];
1718 (*iter)[group_columns.visible] = !visible;
1720 group_display.queue_draw();
1733 Mixer_UI::activate_all_route_groups ()
1735 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1739 Mixer_UI::disable_all_route_groups ()
1741 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1745 Mixer_UI::route_groups_changed ()
1747 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1749 _in_group_rebuild_or_clear = true;
1751 /* just rebuild the while thing */
1753 group_model->clear ();
1756 /* this is currently not used,
1757 * Mixer_UI::group_display_button_press() has a case for it,
1758 * and a commented edit_route_group() but that's n/a since 2011.
1760 * This code is left as reminder that
1761 * row[group_columns.group] = 0 has special meaning.
1765 row = *(group_model->append());
1766 row[group_columns.visible] = true;
1767 row[group_columns.text] = (_("-all-"));
1768 row[group_columns.group] = 0;
1772 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1774 _group_tabs->set_dirty ();
1775 _in_group_rebuild_or_clear = false;
1779 Mixer_UI::new_route_group ()
1781 _group_tabs->run_new_group_dialog (0, false);
1785 Mixer_UI::remove_selected_route_group ()
1787 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1788 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1794 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1797 /* selection mode is single, so rows.begin() is it */
1799 if ((iter = group_model->get_iter (*i))) {
1801 RouteGroup* rg = (*iter)[group_columns.group];
1804 _session->remove_route_group (*rg);
1810 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1812 if (in_group_row_change) {
1816 /* force an update of any mixer strips that are using this group,
1817 otherwise mix group names don't change in mixer strips
1820 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1821 if ((*i)->route_group() == group) {
1822 (*i)->route_group_changed();
1826 TreeModel::iterator i;
1827 TreeModel::Children rows = group_model->children();
1828 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1830 in_group_row_change = true;
1832 for (i = rows.begin(); i != rows.end(); ++i) {
1833 if ((*i)[group_columns.group] == group) {
1834 (*i)[group_columns.visible] = !group->is_hidden ();
1835 (*i)[group_columns.text] = group->name ();
1840 in_group_row_change = false;
1842 if (change.contains (Properties::name)) {
1843 _group_tabs->set_dirty ();
1846 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
1847 if ((*j)->route_group() == group) {
1848 if (group->is_hidden ()) {
1858 Mixer_UI::show_mixer_list (bool yn)
1861 list_vpacker.show ();
1863 list_vpacker.hide ();
1866 _show_mixer_list = yn;
1870 Mixer_UI::show_monitor_section (bool yn)
1872 if (!monitor_section()) {
1875 if (monitor_section()->tearoff().torn_off()) {
1880 monitor_section()->tearoff().show();
1882 monitor_section()->tearoff().hide();
1887 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
1892 if ((iter = group_model->get_iter (path))) {
1894 if ((group = (*iter)[group_columns.group]) == 0) {
1898 if (new_text != group->name()) {
1899 group->set_name (new_text);
1905 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
1909 if (in_group_row_change) {
1913 if ((group = (*iter)[group_columns.group]) == 0) {
1917 std::string name = (*iter)[group_columns.text];
1919 if (name != group->name()) {
1920 group->set_name (name);
1923 bool hidden = !(*iter)[group_columns.visible];
1925 if (hidden != group->is_hidden ()) {
1926 group->set_hidden (hidden, this);
1930 /** Called when a group model row is deleted, but also when the model is
1931 * reordered by a user drag-and-drop; the latter is what we are
1932 * interested in here.
1935 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
1937 if (_in_group_rebuild_or_clear) {
1941 /* Re-write the session's route group list so that the new order is preserved */
1943 list<RouteGroup*> new_list;
1945 Gtk::TreeModel::Children children = group_model->children();
1946 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
1947 RouteGroup* g = (*i)[group_columns.group];
1949 new_list.push_back (g);
1953 _session->reorder_route_groups (new_list);
1958 Mixer_UI::add_route_group (RouteGroup* group)
1960 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
1963 in_group_row_change = true;
1965 TreeModel::Row row = *(group_model->append());
1966 row[group_columns.visible] = !group->is_hidden ();
1967 row[group_columns.group] = group;
1968 if (!group->name().empty()) {
1969 row[group_columns.text] = group->name();
1971 row[group_columns.text] = _("unnamed");
1975 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
1978 TreeViewColumn* col = group_display.get_column (0);
1979 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
1980 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
1983 _group_tabs->set_dirty ();
1985 in_group_row_change = false;
1989 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
1991 using namespace Menu_Helpers;
1993 if (Keyboard::is_context_menu_event (ev)) {
1994 ARDOUR_UI::instance()->add_route ();
2002 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
2004 printf ("Mixer_UI::scroller_drag_data_received\n");
2005 if (data.get_target() != "PluginFavoritePtr") {
2006 context->drag_finish (false, false, time);
2010 const void * d = data.get_data();
2011 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2013 PluginPresetList nfos;
2015 tv->get_object_drag_data (nfos, &source);
2017 Route::ProcessorList pl;
2020 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2021 PluginPresetPtr ppp = (*i);
2022 PluginInfoPtr pip = ppp->_pip;
2023 if (!pip->is_instrument ()) {
2026 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);
2030 context->drag_finish (ok, false, time);
2034 Mixer_UI::set_strip_width (Width w, bool save)
2038 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2039 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2044 struct PluginStateSorter {
2046 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2047 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2048 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2049 if (aiter != _user.end() && biter != _user.end()) {
2050 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2052 if (aiter != _user.end()) {
2055 if (biter != _user.end()) {
2058 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2061 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2063 std::list<std::string> _user;
2067 Mixer_UI::set_state (const XMLNode& node, int version)
2072 Tabbable::set_state (node, version);
2074 if (node.get_property ("narrow-strips", yn)) {
2076 set_strip_width (Narrow);
2078 set_strip_width (Wide);
2082 node.get_property ("show-mixer", _visible);
2084 if (node.get_property ("maximised", yn)) {
2085 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer"));
2087 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2088 bool fs = tact && tact->get_active();
2090 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2094 if (node.get_property ("show-mixer-list", yn)) {
2095 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMixerList"));
2097 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2099 /* do it twice to force the change */
2100 tact->set_active (!yn);
2101 tact->set_active (yn);
2104 if (node.get_property ("monitor-section-visible", yn)) {
2105 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2106 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2107 /* do it twice to force the change */
2108 tact->set_active (yn);
2109 show_monitor_section (yn);
2113 XMLNode* plugin_order;
2114 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2115 store_current_favorite_order ();
2116 std::list<string> order;
2117 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2118 XMLNodeConstIterator i;
2119 for (i = kids.begin(); i != kids.end(); ++i) {
2120 std::string unique_id;
2121 if ((*i)->get_property ("unique-id", unique_id)) {
2122 order.push_back (unique_id);
2123 if ((*i)->get_property ("expanded", yn)) {
2124 favorite_ui_state[unique_id] = yn;
2128 PluginStateSorter cmp (order);
2129 favorite_order.sort (cmp);
2130 sync_treeview_from_favorite_order ();
2136 Mixer_UI::get_state ()
2138 XMLNode* node = new XMLNode (X_("Mixer"));
2141 node->add_child_nocopy (Tabbable::get_state());
2143 node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider());
2144 node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider());
2145 node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider());
2146 node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider());
2148 node->set_property ("narrow-strips", (_strip_width == Narrow));
2149 node->set_property ("show-mixer", _visible);
2150 node->set_property ("show-mixer-list", _show_mixer_list);
2151 node->set_property ("maximised", _maximised);
2153 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2154 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2156 node->set_property ("monitor-section-visible", tact->get_active ());
2158 store_current_favorite_order ();
2159 XMLNode* plugin_order = new XMLNode ("PluginOrder");
2161 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2162 XMLNode* p = new XMLNode ("PluginInfo");
2163 p->set_property ("sort", cnt);
2164 p->set_property ("unique-id", (*i)->unique_id);
2165 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2166 p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2168 plugin_order->add_child_nocopy (*p);
2170 node->add_child_nocopy (*plugin_order);
2176 Mixer_UI::scroll_left ()
2178 if (!scroller.get_hscrollbar()) return;
2179 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2180 int sc_w = scroller.get_width();
2181 int sp_w = strip_packer.get_width();
2185 int lp = adj->get_value();
2187 using namespace Gtk::Box_Helpers;
2188 const BoxList& strips = strip_packer.children();
2189 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2190 lm += i->get_widget()->get_width ();
2192 lm -= i->get_widget()->get_width ();
2196 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2200 Mixer_UI::scroll_right ()
2202 if (!scroller.get_hscrollbar()) return;
2203 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2204 int sc_w = scroller.get_width();
2205 int sp_w = strip_packer.get_width();
2209 int lp = adj->get_value();
2211 using namespace Gtk::Box_Helpers;
2212 const BoxList& strips = strip_packer.children();
2213 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2214 lm += i->get_widget()->get_width ();
2219 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2223 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2225 switch (ev->direction) {
2226 case GDK_SCROLL_LEFT:
2230 if (ev->state & Keyboard::TertiaryModifier) {
2236 case GDK_SCROLL_RIGHT:
2240 case GDK_SCROLL_DOWN:
2241 if (ev->state & Keyboard::TertiaryModifier) {
2253 Mixer_UI::parameter_changed (string const & p)
2255 if (p == "show-group-tabs") {
2256 bool const s = _session->config.get_show_group_tabs ();
2258 _group_tabs->show ();
2260 _group_tabs->hide ();
2262 } else if (p == "default-narrow_ms") {
2263 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2264 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2265 (*i)->set_width_enum (s ? Narrow : Wide, this);
2271 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2273 g->set_active (a, this);
2277 Mixer_UI::plugin_selector()
2279 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2280 if (!_plugin_selector)
2281 _plugin_selector = new PluginSelector (PluginManager::instance());
2284 return _plugin_selector;
2288 Mixer_UI::setup_track_display ()
2290 track_model = ListStore::create (stripable_columns);
2291 track_display.set_model (track_model);
2292 track_display.append_column (_("Show"), stripable_columns.visible);
2293 track_display.append_column (_("Strips"), stripable_columns.text);
2294 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2295 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2296 track_display.get_column (0)->set_expand(false);
2297 track_display.get_column (1)->set_expand(true);
2298 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2299 track_display.set_name (X_("EditGroupList"));
2300 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2301 track_display.set_reorderable (true);
2302 track_display.set_headers_visible (true);
2303 track_display.set_can_focus(false);
2305 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2306 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2308 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2309 track_list_visible_cell->property_activatable() = true;
2310 track_list_visible_cell->property_radio() = false;
2311 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2313 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2315 track_display_scroller.add (track_display);
2316 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2318 VBox* v = manage (new VBox);
2320 v->pack_start (track_display_scroller, true, true);
2322 Button* b = manage (new Button);
2324 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
2328 b->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
2330 v->pack_start (*b, false, false);
2332 track_display_frame.set_name("BaseFrame");
2333 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2334 track_display_frame.add (*v);
2336 track_display_scroller.show();
2337 track_display_frame.show();
2338 track_display.show();
2342 Mixer_UI::new_track_or_bus ()
2344 ARDOUR_UI::instance()->add_route ();
2348 Mixer_UI::update_title ()
2350 if (!own_window()) {
2357 if (_session->snap_name() != _session->name()) {
2358 n = _session->snap_name ();
2360 n = _session->name ();
2363 if (_session->dirty ()) {
2367 WindowTitle title (n);
2368 title += S_("Window|Mixer");
2369 title += Glib::get_application_name ();
2370 own_window()->set_title (title.get_string());
2374 WindowTitle title (S_("Window|Mixer"));
2375 title += Glib::get_application_name ();
2376 own_window()->set_title (title.get_string());
2381 Mixer_UI::strip_by_x (int x)
2383 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2386 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2387 x2 = x1 + (*i)->get_width();
2389 if (x >= x1 && x <= x2) {
2398 Mixer_UI::set_axis_targets_for_operation ()
2400 _axis_targets.clear ();
2402 if (!_selection.empty()) {
2403 _axis_targets = _selection.axes;
2407 // removed "implicit" selections of strips, after discussion on IRC
2412 Mixer_UI::monitor_section_going_away ()
2414 if (_monitor_section) {
2415 XMLNode* ui_node = Config->extra_xml(X_("UI"));
2416 /* immediate state save.
2418 * Tearoff settings are otherwise only stored during
2419 * save_ardour_state(). The mon-section may or may not
2420 * exist at that point.
2423 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
2425 tearoff_node->remove_nodes_and_delete (X_("monitor-section"));
2426 XMLNode* t = new XMLNode (X_("monitor-section"));
2427 _monitor_section->tearoff().add_state (*t);
2428 tearoff_node->add_child_nocopy (*t);
2431 monitor_section_detached ();
2432 out_packer.remove (_monitor_section->tearoff());
2433 _monitor_section->set_session (0);
2434 delete _monitor_section;
2435 _monitor_section = 0;
2440 Mixer_UI::toggle_midi_input_active (bool flip_others)
2442 boost::shared_ptr<RouteList> rl (new RouteList);
2445 set_axis_targets_for_operation ();
2447 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2448 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2452 onoff = !mt->input_active();
2456 _session->set_exclusive_input_active (rl, onoff, flip_others);
2460 Mixer_UI::maximise_mixer_space ()
2462 if (!own_window()) {
2470 _window->fullscreen ();
2475 Mixer_UI::restore_mixer_space ()
2477 if (!own_window()) {
2485 own_window()->unfullscreen();
2490 Mixer_UI::monitor_section_attached ()
2492 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2493 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2494 act->set_sensitive (true);
2495 show_monitor_section (tact->get_active ());
2499 Mixer_UI::monitor_section_detached ()
2501 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2502 act->set_sensitive (false);
2506 Mixer_UI::store_current_favorite_order ()
2508 typedef Gtk::TreeModel::Children type_children;
2509 type_children children = favorite_plugins_model->children();
2510 favorite_order.clear();
2511 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2513 Gtk::TreeModel::Row row = *iter;
2514 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2515 favorite_order.push_back (ppp->_pip);
2516 std::string name = row[favorite_plugins_columns.name];
2517 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2522 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2524 Gtk::TreeModel::Row row = *iter;
2525 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2527 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2531 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2533 PluginManager& manager (PluginManager::instance());
2534 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2535 if (manager.get_status (*i) != PluginManager::Favorite) {
2538 result.push_back (*i);
2542 struct PluginCustomSorter {
2544 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2545 PluginInfoList::const_iterator aiter = _user.begin();
2546 PluginInfoList::const_iterator biter = _user.begin();
2547 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2548 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2550 if (aiter != _user.end() && biter != _user.end()) {
2551 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2553 if (aiter != _user.end()) {
2556 if (biter != _user.end()) {
2559 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2561 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2563 PluginInfoList _user;
2567 Mixer_UI::refill_favorite_plugins ()
2569 PluginInfoList plugs;
2570 PluginManager& mgr (PluginManager::instance());
2573 refiller (plugs, mgr.lv2_plugin_info ());
2575 #ifdef WINDOWS_VST_SUPPORT
2576 refiller (plugs, mgr.windows_vst_plugin_info ());
2578 #ifdef LXVST_SUPPORT
2579 refiller (plugs, mgr.lxvst_plugin_info ());
2581 #ifdef MACVST_SUPPORT
2582 refiller (plugs, mgr.mac_vst_plugin_info ());
2584 #ifdef AUDIOUNIT_SUPPORT
2585 refiller (plugs, mgr.au_plugin_info ());
2587 refiller (plugs, mgr.ladspa_plugin_info ());
2588 refiller (plugs, mgr.lua_plugin_info ());
2590 store_current_favorite_order ();
2592 PluginCustomSorter cmp (favorite_order);
2595 favorite_order = plugs;
2597 sync_treeview_from_favorite_order ();
2601 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2604 if (!(iter = favorite_plugins_model->get_iter (path))) {
2607 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2611 PluginInfoPtr pip = ppp->_pip;
2612 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2613 if (favorite_ui_state[pip->unique_id]) {
2614 favorite_plugins_display.expand_row (path, true);
2620 Mixer_UI::sync_treeview_from_favorite_order ()
2622 favorite_plugins_model->clear ();
2623 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
2624 PluginInfoPtr pip = (*i);
2626 TreeModel::Row newrow = *(favorite_plugins_model->append());
2627 newrow[favorite_plugins_columns.name] = (*i)->name;
2628 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
2633 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
2634 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
2635 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
2636 child_row[favorite_plugins_columns.name] = (*j).label;
2637 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
2639 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2640 if (favorite_ui_state[pip->unique_id]) {
2641 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
2648 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
2650 using namespace Gtk::Menu_Helpers;
2652 Gtk::Menu* m = manage (new Menu);
2653 MenuList& items = m->items ();
2655 if (_selection.axes.empty()) {
2656 items.push_back (MenuElem (_("No Track/Bus is selected.")));
2658 items.push_back (MenuElem (_("Add at the top"),
2659 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
2660 items.push_back (MenuElem (_("Add Pre-Fader"),
2661 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
2662 items.push_back (MenuElem (_("Add Post-Fader"),
2663 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
2664 items.push_back (MenuElem (_("Add at the end"),
2665 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
2668 items.push_back (SeparatorElem());
2670 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
2672 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2673 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
2674 // we cannot currently delete AU presets
2675 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
2676 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
2680 m->popup (ev->button, ev->time);
2684 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
2686 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) {
2687 TreeModel::Path path;
2688 TreeViewColumn* column;
2690 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
2691 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2693 selection->unselect_all();
2694 selection->select(path);
2697 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2699 popup_note_context_menu (ev);
2707 Mixer_UI::selected_plugin ()
2709 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2711 return PluginPresetPtr();
2713 Gtk::TreeModel::iterator iter = selection->get_selected();
2715 return PluginPresetPtr();
2717 return (*iter)[favorite_plugins_columns.plugin];
2721 Mixer_UI::add_selected_processor (ProcessorPosition pos)
2723 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2725 add_favorite_processor (ppp, pos);
2730 Mixer_UI::delete_selected_preset ()
2735 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2736 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
2739 PluginPtr plugin = ppp->_pip->load (*_session);
2740 plugin->get_presets();
2741 plugin->remove_preset (ppp->_preset.label);
2745 Mixer_UI::remove_selected_from_favorites ()
2747 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2751 PluginManager::PluginStatusType status = PluginManager::Normal;
2752 PluginManager& manager (PluginManager::instance());
2754 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2755 manager.save_statuses ();
2759 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
2762 if (!(iter = favorite_plugins_model->get_iter (path))) {
2765 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2766 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
2770 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
2772 if (!_session || _selection.axes.empty()) {
2776 PluginInfoPtr pip = ppp->_pip;
2777 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
2778 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
2784 PluginPtr p = pip->load (*_session);
2790 if (ppp->_preset.valid) {
2791 p->load_preset (ppp->_preset);
2794 Route::ProcessorStreams err;
2795 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2799 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
2802 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
2809 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
2813 if (!np->display_to_user()) {
2816 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
2817 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
2822 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
2826 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
2833 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
2835 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
2839 // only allow to re-order top-level items
2841 if (TreePath::get_from_selection_data (data, src)) {
2842 if (src.up() && src.up()) {
2847 // don't allow to drop as child-rows.
2848 Gtk::TreeModel::Path _dest = dest; // un const
2849 const bool is_child = _dest.up (); // explicit bool for clang
2850 if (!is_child || _dest.empty ()) {
2857 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
2859 if (data.get_target() != "PluginPresetPtr") {
2862 if (data.get_length() != sizeof (PluginPresetPtr)) {
2865 const void *d = data.get_data();
2866 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
2868 PluginManager::PluginStatusType status = PluginManager::Favorite;
2869 PluginManager& manager (PluginManager::instance());
2871 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2872 manager.save_statuses ();
2876 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
2878 /* call protected MixerActor:: method */
2883 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
2885 /* call protected MixerActor:: method */
2890 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
2892 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
2895 show_spill_change (s); /* EMIT SIGNAL */
2897 _group_tabs->hide ();
2899 _group_tabs->show ();
2901 redisplay_track_list ();
2906 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
2908 return s == spilled_strip.lock();
2912 Mixer_UI::show_editor_window () const
2914 PublicEditor::instance().make_visible ();
2918 Mixer_UI::register_actions ()
2920 Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
2922 myactions.register_action (group, "show-editor", _("Show Editor"), sigc::mem_fun (*this, &Mixer_UI::show_editor_window));
2924 myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
2925 myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
2926 myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
2927 myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
2928 myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
2929 myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
2932 myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
2933 myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
2934 myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
2935 myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
2936 myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
2937 myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
2938 myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
2939 myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
2941 myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
2942 myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
2944 myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
2945 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
2949 Mixer_UI::load_bindings ()
2951 bindings = Bindings::get_bindings (X_("Mixer"), myactions);
2954 template<class T> void
2955 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
2957 boost::shared_ptr<ControlList> cl (new ControlList);
2958 boost::shared_ptr<AutomationControl> ac;
2960 bool have_val = false;
2962 set_axis_targets_for_operation ();
2964 BOOST_FOREACH(AxisView* r, _axis_targets) {
2965 boost::shared_ptr<Stripable> s = r->stripable();
2967 ac = (s.get()->*get_control)();
2971 val = !ac->get_value();
2978 _session->set_controls (cl, val, Controllable::UseGroup);
2982 Mixer_UI::solo_action ()
2984 control_action (&Stripable::solo_control);
2988 Mixer_UI::mute_action ()
2990 control_action (&Stripable::mute_control);
2994 Mixer_UI::rec_enable_action ()
2996 control_action (&Stripable::rec_enable_control);
3000 Mixer_UI::step_gain_up_action ()
3002 set_axis_targets_for_operation ();
3004 BOOST_FOREACH(AxisView* r, _axis_targets) {
3005 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3007 ms->step_gain_up ();
3013 Mixer_UI::step_gain_down_action ()
3015 set_axis_targets_for_operation ();
3017 BOOST_FOREACH(AxisView* r, _axis_targets) {
3018 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3020 ms->step_gain_down ();
3026 Mixer_UI::unity_gain_action ()
3028 set_axis_targets_for_operation ();
3030 BOOST_FOREACH(AxisView* r, _axis_targets) {
3031 boost::shared_ptr<Stripable> s = r->stripable();
3033 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3035 ac->set_value (1.0, Controllable::UseGroup);
3042 Mixer_UI::copy_processors ()
3044 set_axis_targets_for_operation ();
3046 BOOST_FOREACH(AxisView* r, _axis_targets) {
3047 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3049 ms->copy_processors ();
3054 Mixer_UI::cut_processors ()
3056 set_axis_targets_for_operation ();
3058 BOOST_FOREACH(AxisView* r, _axis_targets) {
3059 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3061 ms->cut_processors ();
3066 Mixer_UI::paste_processors ()
3068 set_axis_targets_for_operation ();
3070 BOOST_FOREACH(AxisView* r, _axis_targets) {
3071 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3073 ms->paste_processors ();
3078 Mixer_UI::select_all_processors ()
3080 set_axis_targets_for_operation ();
3082 BOOST_FOREACH(AxisView* r, _axis_targets) {
3083 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3085 ms->select_all_processors ();
3090 Mixer_UI::toggle_processors ()
3092 set_axis_targets_for_operation ();
3094 BOOST_FOREACH(AxisView* r, _axis_targets) {
3095 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3097 ms->toggle_processors ();
3102 Mixer_UI::ab_plugins ()
3104 set_axis_targets_for_operation ();
3106 BOOST_FOREACH(AxisView* r, _axis_targets) {
3107 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3115 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3117 set_axis_targets_for_operation ();
3118 BOOST_FOREACH(AxisView* r, _axis_targets) {
3119 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3121 ms->vca_assign (vca);
3127 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3129 set_axis_targets_for_operation ();
3130 BOOST_FOREACH(AxisView* r, _axis_targets) {
3131 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3133 ms->vca_unassign (vca);