2 Copyright (C) 2000-2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "gtk2ardour-config.h"
26 #include <sigc++/bind.h>
28 #include <boost/foreach.hpp>
30 #include <gtkmm/accelmap.h>
32 #include "pbd/convert.h"
33 #include "pbd/stacktrace.h"
34 #include "pbd/unwind.h"
36 #include <glibmm/threads.h>
38 #include <gtkmm2ext/gtk_ui.h>
39 #include <gtkmm2ext/keyboard.h>
40 #include <gtkmm2ext/utils.h>
41 #include <gtkmm2ext/tearoff.h>
42 #include <gtkmm2ext/window_title.h>
43 #include <gtkmm2ext/doi.h>
45 #include "ardour/amp.h"
46 #include "ardour/debug.h"
47 #include "ardour/audio_track.h"
48 #include "ardour/midi_track.h"
49 #include "ardour/plugin_manager.h"
50 #include "ardour/route_group.h"
51 #include "ardour/session.h"
52 #include "ardour/vca.h"
53 #include "ardour/vca_manager.h"
57 #include "mixer_strip.h"
58 #include "monitor_section.h"
59 #include "plugin_selector.h"
60 #include "public_editor.h"
61 #include "mouse_cursors.h"
62 #include "ardour_ui.h"
65 #include "route_sorter.h"
67 #include "gui_thread.h"
68 #include "mixer_group_tabs.h"
69 #include "route_sorter.h"
71 #include "ui_config.h"
72 #include "vca_master_strip.h"
76 using namespace ARDOUR;
77 using namespace ARDOUR_UI_UTILS;
81 using namespace Gtkmm2ext;
87 Mixer_UI* Mixer_UI::_instance = 0;
93 _instance = new Mixer_UI;
100 : Tabbable (_content, _("Mixer"))
101 , no_track_list_redisplay (false)
102 , in_group_row_change (false)
104 , _monitor_section (0)
105 , _plugin_selector (0)
106 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
107 , ignore_reorder (false)
108 , _in_group_rebuild_or_clear (false)
109 , _route_deletion_in_progress (false)
110 , _following_editor_selection (false)
112 , _show_mixer_list (true)
113 , myactions (X_("mixer"))
117 _content.set_data ("ardour-bindings", bindings);
119 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::sync_treeview_from_presentation_info, this), gui_context());
121 scroller.set_can_default (true);
122 // set_default (scroller);
124 scroller_base.set_flags (Gtk::CAN_FOCUS);
125 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
126 scroller_base.set_name ("MixerWindow");
127 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
129 /* set up drag-n-drop */
130 vector<TargetEntry> target_table;
131 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
132 scroller_base.drag_dest_set (target_table);
133 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
135 // add as last item of strip packer
136 strip_packer.pack_end (scroller_base, true, true);
138 _group_tabs = new MixerGroupTabs (this);
139 VBox* b = manage (new VBox);
141 b->set_border_width (0);
142 b->pack_start (*_group_tabs, PACK_SHRINK);
143 b->pack_start (strip_packer);
147 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
149 setup_track_display ();
151 group_model = ListStore::create (group_columns);
152 group_display.set_model (group_model);
153 group_display.append_column (_("Show"), group_columns.visible);
154 group_display.append_column (_("Group"), group_columns.text);
155 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
156 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
157 group_display.get_column (0)->set_expand(false);
158 group_display.get_column (1)->set_expand(true);
159 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
160 group_display.set_name ("EditGroupList");
161 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
162 group_display.set_reorderable (true);
163 group_display.set_headers_visible (true);
164 group_display.set_rules_hint (true);
165 group_display.set_can_focus(false);
167 /* name is directly editable */
169 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
170 name_cell->property_editable() = true;
171 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
173 /* use checkbox for the active column */
175 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
176 active_cell->property_activatable() = true;
177 active_cell->property_radio() = false;
179 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
180 /* We use this to notice drag-and-drop reorders of the group list */
181 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
182 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
184 group_display_scroller.add (group_display);
185 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
187 HBox* route_group_display_button_box = manage (new HBox());
189 Button* route_group_add_button = manage (new Button ());
190 Button* route_group_remove_button = manage (new Button ());
194 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
196 route_group_add_button->add (*w);
198 w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
200 route_group_remove_button->add (*w);
202 route_group_display_button_box->set_homogeneous (true);
204 route_group_add_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_route_group));
205 route_group_remove_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::remove_selected_route_group));
207 route_group_display_button_box->add (*route_group_add_button);
208 route_group_display_button_box->add (*route_group_remove_button);
210 group_display_vbox.pack_start (group_display_scroller, true, true);
211 group_display_vbox.pack_start (*route_group_display_button_box, false, false);
213 group_display_frame.set_name ("BaseFrame");
214 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
215 group_display_frame.add (group_display_vbox);
218 list<TargetEntry> target_list;
219 target_list.push_back (TargetEntry ("PluginPresetPtr"));
221 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
222 favorite_plugins_display.set_model (favorite_plugins_model);
223 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
224 favorite_plugins_display.set_name ("EditGroupList");
225 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
226 favorite_plugins_display.set_reorderable (false);
227 favorite_plugins_display.set_headers_visible (true);
228 favorite_plugins_display.set_rules_hint (true);
229 favorite_plugins_display.set_can_focus (false);
230 favorite_plugins_display.set_tooltip_column (0);
231 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
232 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
233 favorite_plugins_display.add_drop_targets (target_list);
234 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
235 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
236 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
237 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
238 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
239 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
241 favorite_plugins_scroller.add (favorite_plugins_display);
242 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
244 favorite_plugins_frame.set_name ("BaseFrame");
245 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
246 favorite_plugins_frame.add (favorite_plugins_scroller);
248 rhs_pane1.add (favorite_plugins_frame);
249 rhs_pane1.add (track_display_frame);
251 rhs_pane2.add (rhs_pane1);
252 rhs_pane2.add (group_display_frame);
254 list_vpacker.pack_start (rhs_pane2, true, true);
256 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
257 vca_vpacker.pack_start (vca_label_bar, false, false);
259 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
260 vca_scroller_base.set_name (X_("MixerWindow"));
261 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
262 vca_hpacker.pack_end (vca_scroller_base, true, true);
264 vca_scroller.add (vca_hpacker);
265 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
266 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
268 vca_vpacker.pack_start (vca_scroller, true, true);
270 inner_pane.add (scroller);
271 inner_pane.add (vca_vpacker);
273 global_hpacker.pack_start (inner_pane, true, true);
274 global_hpacker.pack_start (out_packer, false, false);
276 list_hpane.set_check_divider_position (true);
277 list_hpane.add (list_vpacker);
278 list_hpane.add (global_hpacker);
279 list_hpane.set_child_minsize (list_vpacker, 1);
282 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
283 XMLProperty const * prop;
289 if (!settings || ((prop = settings->property ("mixer-rhs-pane1-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
290 rhs_pane1.set_divider (0, 0.6f);
292 rhs_pane1.set_divider (0, fract);
294 if (!settings || ((prop = settings->property ("mixer-rhs-pane2-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
295 rhs_pane2.set_divider (0, 0.7f);
297 rhs_pane2.set_divider (0, fract);
299 if (!settings || ((prop = settings->property ("mixer-list-hpane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
300 list_hpane.set_divider (0, 0.2f);
302 list_hpane.set_divider (0, fract);
304 if (!settings || ((prop = settings->property ("mixer-inner-pane-pos")) == 0) || ((fract = atof (prop->value())) > 1.0)) {
305 inner_pane.set_divider (0, 0.8f);
307 inner_pane.set_divider (0, atof (prop->value()));
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;
387 Mixer_UI::track_editor_selection ()
389 PublicEditor::instance().get_selection().TracksChanged.connect (sigc::mem_fun (*this, &Mixer_UI::follow_editor_selection));
393 Mixer_UI::use_own_window (bool and_fill_it)
395 bool new_window = !own_window();
397 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
400 if (win && new_window) {
401 win->set_name ("MixerWindow");
402 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
403 win->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
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;
709 // special case master if it's got PI order 0 lets keep it there
710 if (_session->master_out() && (_session->master_out()->presentation_info().order() == 0)) {
714 for (ri = rows.begin(); ri != rows.end(); ++ri) {
715 bool visible = (*ri)[stripable_columns.visible];
716 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
722 /* Monitor and Auditioner do not get their presentation
726 if (stripable->is_monitor() || stripable->is_auditioner()) {
730 /* Master also doesn't get set here but since the editor allows
731 * it to be reordered, we need to preserve its ordering.
734 stripable->presentation_info().set_hidden (!visible);
736 // master may not get set here, but if it is zero keep it there
737 if (stripable->is_master() && (stripable->presentation_info().order() == 0)) {
741 if (order != stripable->presentation_info().order()) {
742 stripable->set_presentation_order (order, false);
750 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
751 _session->notify_presentation_info_change ();
752 _session->set_dirty();
757 Mixer_UI::sync_treeview_from_presentation_info ()
759 if (!_session || _session->deletion_in_progress()) {
763 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
765 /* we could get here after either a change in the Mixer or Editor sort
766 * order, but either way, the mixer order keys reflect the intended
767 * order for the GUI, so reorder the treeview model to match it.
770 vector<int> neworder;
771 TreeModel::Children rows = track_model->children();
772 uint32_t old_order = 0;
773 bool changed = false;
780 const size_t cmp_max = rows.size ();
782 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
783 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
784 sorted.push_back (OrderKeys (old_order, stripable, cmp_max));
787 SortByNewDisplayOrder cmp;
789 sort (sorted.begin(), sorted.end(), cmp);
790 neworder.assign (sorted.size(), 0);
794 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
796 neworder[n] = sr->old_display_order;
798 if (sr->old_display_order != n) {
804 Unwinder<bool> uw (ignore_reorder, true);
805 track_model->reorder (neworder);
808 redisplay_track_list ();
812 Mixer_UI::follow_editor_selection ()
814 if (_following_editor_selection) {
818 _following_editor_selection = true;
819 _selection.block_routes_changed (true);
821 TrackSelection& s (PublicEditor::instance().get_selection().tracks);
823 _selection.clear_routes ();
825 for (TrackViewList::iterator i = s.begin(); i != s.end(); ++i) {
826 TimeAxisView* tav = dynamic_cast<TimeAxisView*> (*i);
828 AxisView* axis = axis_by_stripable (tav->stripable());
830 _selection.add (axis);
835 _following_editor_selection = false;
836 _selection.block_routes_changed (false);
841 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
843 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
844 if ((*i)->route() == r) {
853 Mixer_UI::axis_by_stripable (boost::shared_ptr<Stripable> s) const
855 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
856 if ((*i)->stripable() == s) {
865 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
867 if (ev->button == 1) {
868 if (_selection.selected (strip)) {
869 /* primary-click: toggle selection state of strip */
870 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
871 _selection.remove (strip);
872 } else if (_selection.axes.size() > 1) {
873 /* de-select others */
874 _selection.set (strip);
877 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
878 _selection.add (strip);
879 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
881 /* extend selection */
883 vector<MixerStrip*> tmp;
884 bool accumulate = false;
885 bool found_another = false;
887 tmp.push_back (strip);
889 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
891 /* hit clicked strip, start accumulating till we hit the first
900 } else if (_selection.selected (*i)) {
901 /* hit selected strip. if currently accumulating others,
902 we're done. if not accumulating others, start doing so.
904 found_another = true;
919 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
923 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
925 _selection.set (strip);
934 Mixer_UI::set_session (Session* sess)
936 SessionHandlePtr::set_session (sess);
938 if (_plugin_selector) {
939 _plugin_selector->set_session (_session);
942 _group_tabs->set_session (sess);
944 if (_monitor_section) {
945 _monitor_section->set_session (_session);
952 refill_favorite_plugins();
954 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
955 set_state (*node, 0);
959 initial_track_display ();
961 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
962 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
963 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
964 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
965 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
966 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
967 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
969 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
971 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
973 route_groups_changed ();
982 Mixer_UI::session_going_away ()
984 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
986 _in_group_rebuild_or_clear = true;
987 group_model->clear ();
988 _in_group_rebuild_or_clear = false;
991 track_model->clear ();
993 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
997 if (_monitor_section) {
998 _monitor_section->tearoff().hide_visible ();
1001 monitor_section_detached ();
1007 SessionHandlePtr::session_going_away ();
1014 Mixer_UI::track_visibility_changed (std::string const & path)
1016 if (_session && _session->deletion_in_progress()) {
1022 if ((iter = track_model->get_iter (path))) {
1024 AxisView* av = (*iter)[stripable_columns.strip];
1025 bool visible = (*iter)[stripable_columns.visible];
1027 if (av->set_marked_for_display (!visible)) {
1028 update_track_visibility ();
1034 Mixer_UI::update_track_visibility ()
1036 TreeModel::Children rows = track_model->children();
1037 TreeModel::Children::iterator i;
1040 Unwinder<bool> uw (no_track_list_redisplay, true);
1042 for (i = rows.begin(); i != rows.end(); ++i) {
1043 AxisView* av = (*i)[stripable_columns.strip];
1044 (*i)[stripable_columns.visible] = av->marked_for_display ();
1047 /* force presentation catch up with visibility changes
1050 sync_presentation_info_from_treeview ();
1053 redisplay_track_list ();
1057 Mixer_UI::show_strip (MixerStrip* ms)
1059 TreeModel::Children rows = track_model->children();
1060 TreeModel::Children::iterator i;
1062 for (i = rows.begin(); i != rows.end(); ++i) {
1064 AxisView* av = (*i)[stripable_columns.strip];
1065 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1067 (*i)[stripable_columns.visible] = true;
1068 av->set_marked_for_display (true);
1069 update_track_visibility ();
1076 Mixer_UI::hide_strip (MixerStrip* ms)
1078 TreeModel::Children rows = track_model->children();
1079 TreeModel::Children::iterator i;
1081 for (i = rows.begin(); i != rows.end(); ++i) {
1083 AxisView* av = (*i)[stripable_columns.strip];
1084 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1086 (*i)[stripable_columns.visible] = false;
1087 av->set_marked_for_display (false);
1088 update_track_visibility ();
1095 Mixer_UI::start_updating ()
1097 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1102 Mixer_UI::stop_updating ()
1104 fast_screen_update_connection.disconnect();
1109 Mixer_UI::fast_update_strips ()
1111 if (_content.is_mapped () && _session) {
1112 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1113 (*i)->fast_update ();
1119 Mixer_UI::set_all_strips_visibility (bool yn)
1121 TreeModel::Children rows = track_model->children();
1122 TreeModel::Children::iterator i;
1125 Unwinder<bool> uw (no_track_list_redisplay, true);
1127 for (i = rows.begin(); i != rows.end(); ++i) {
1129 AxisView* av = (*i)[stripable_columns.strip];
1130 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1136 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1140 (*i)[stripable_columns.visible] = yn;
1144 redisplay_track_list ();
1149 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1151 TreeModel::Children rows = track_model->children();
1152 TreeModel::Children::iterator i;
1155 Unwinder<bool> uw (no_track_list_redisplay, true);
1157 for (i = rows.begin(); i != rows.end(); ++i) {
1159 AxisView* av = (*i)[stripable_columns.strip];
1160 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1166 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1170 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1171 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1175 (*i)[stripable_columns.visible] = yn;
1179 if (at) { /* track */
1180 (*i)[stripable_columns.visible] = yn;
1185 if (!at && !mt) { /* bus */
1186 (*i)[stripable_columns.visible] = yn;
1191 if (mt) { /* midi-track */
1192 (*i)[stripable_columns.visible] = yn;
1199 redisplay_track_list ();
1203 Mixer_UI::hide_all_routes ()
1205 set_all_strips_visibility (false);
1209 Mixer_UI::show_all_routes ()
1211 set_all_strips_visibility (true);
1215 Mixer_UI::show_all_audiobus ()
1217 set_all_audio_midi_visibility (2, true);
1220 Mixer_UI::hide_all_audiobus ()
1222 set_all_audio_midi_visibility (2, false);
1226 Mixer_UI::show_all_audiotracks()
1228 set_all_audio_midi_visibility (1, true);
1231 Mixer_UI::hide_all_audiotracks ()
1233 set_all_audio_midi_visibility (1, false);
1237 Mixer_UI::show_all_miditracks()
1239 set_all_audio_midi_visibility (3, true);
1242 Mixer_UI::hide_all_miditracks ()
1244 set_all_audio_midi_visibility (3, false);
1248 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1250 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1251 sync_presentation_info_from_treeview ();
1255 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1257 /* this happens as the second step of a DnD within the treeview as well
1258 as when a row/route is actually deleted.
1260 if it was a deletion then we have to force a redisplay because
1261 order keys may not have changed.
1264 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1265 sync_presentation_info_from_treeview ();
1267 if (_route_deletion_in_progress) {
1268 redisplay_track_list ();
1273 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1275 TreeModel::Children rows = track_model->children();
1276 std::list<boost::shared_ptr<VCA> > vcas;
1277 vcas.push_back (vca);
1279 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1280 AxisView* av = (*i)[stripable_columns.strip];
1281 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1282 if (vms && vms->vca()->slaved_to (vca)) {
1283 vcas.push_back (vms->vca());
1287 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1289 AxisView* av = (*i)[stripable_columns.strip];
1290 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1293 /* we're in the middle of changing a row, don't worry */
1297 if (!strip->route()) {
1298 /* non-route element */
1302 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1306 bool slaved = false;
1307 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1308 if (strip->route()->slaved_to (*m)) {
1316 if (strip->packed()) {
1317 strip_packer.reorder_child (*strip, -1); /* put at end */
1319 strip_packer.pack_start (*strip, false, false);
1320 strip->set_packed (true);
1325 if (strip->packed()) {
1326 strip_packer.remove (*strip);
1327 strip->set_packed (false);
1334 Mixer_UI::redisplay_track_list ()
1336 if (no_track_list_redisplay) {
1340 boost::shared_ptr<VCA> sv = spilled_vca.lock ();
1343 spill_redisplay (sv);
1347 TreeModel::Children rows = track_model->children();
1348 TreeModel::Children::iterator i;
1349 uint32_t n_masters = 0;
1351 container_clear (vca_hpacker);
1352 vca_hpacker.pack_end (vca_scroller_base, true, true);
1354 for (i = rows.begin(); i != rows.end(); ++i) {
1356 AxisView* s = (*i)[stripable_columns.strip];
1357 bool const visible = (*i)[stripable_columns.visible];
1358 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1361 /* we're in the middle of changing a row, don't worry */
1365 VCAMasterStrip* vms;
1367 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1369 vca_hpacker.pack_start (*vms, false, false);
1376 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1384 if (strip->packed()) {
1385 strip_packer.reorder_child (*strip, -1); /* put at end */
1387 strip_packer.pack_start (*strip, false, false);
1388 strip->set_packed (true);
1393 if (stripable->is_master() || stripable->is_monitor()) {
1394 /* do nothing, these cannot be hidden */
1396 if (strip->packed()) {
1397 strip_packer.remove (*strip);
1398 strip->set_packed (false);
1404 /* update visibility of VCA assign buttons */
1406 if (n_masters == 0) {
1407 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1408 vca_vpacker.hide ();
1410 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1411 vca_vpacker.show ();
1414 _group_tabs->set_dirty ();
1418 Mixer_UI::strip_width_changed ()
1420 _group_tabs->set_dirty ();
1423 TreeModel::Children rows = track_model->children();
1424 TreeModel::Children::iterator i;
1427 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1428 AxisView* av = (*i)[stripable_columns.strip];
1429 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1435 bool visible = (*i)[stripable_columns.visible];
1438 strip->queue_draw();
1445 struct PresentationInfoMixerSorter
1447 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1448 if (a->is_master()) {
1449 /* master after everything else */
1451 } else if (b->is_master()) {
1452 /* everything else before master */
1455 return a->presentation_info().order () < b->presentation_info().order ();
1460 Mixer_UI::initial_track_display ()
1464 boost::shared_ptr<RouteList> routes = _session->get_routes();
1466 for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) {
1470 VCAList vcas = _session->vca_manager().vcas();
1472 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
1473 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
1476 sl.sort (PresentationInfoMixerSorter());
1479 /* These are also used inside ::add_stripables() but we need
1480 * them here because we're going to clear the track_model also.
1482 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1483 Unwinder<bool> uw2 (ignore_reorder, true);
1485 track_model->clear ();
1486 add_stripables (sl);
1489 redisplay_track_list ();
1493 Mixer_UI::show_track_list_menu ()
1495 if (track_menu == 0) {
1496 build_track_menu ();
1499 track_menu->popup (1, gtk_get_current_event_time());
1503 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1505 if (Keyboard::is_context_menu_event (ev)) {
1506 show_track_list_menu ();
1509 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1510 TreeModel::Path path;
1511 TreeViewColumn* column;
1513 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1514 TreeIter iter = track_model->get_iter (path);
1515 if ((*iter)[stripable_columns.visible]) {
1516 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1517 move_stripable_into_view (s);
1526 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1528 if (!scroller.get_hscrollbar()) {
1531 if (s->presentation_info().special () || s->presentation_info().flag_match (PresentationInfo::VCA)) {
1541 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1542 if ((*i)->route() == s) {
1545 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1553 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1554 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), x0 - 1.0)));
1558 Mixer_UI::build_track_menu ()
1560 using namespace Menu_Helpers;
1561 using namespace Gtk;
1563 track_menu = new Menu;
1564 track_menu->set_name ("ArdourContextMenu");
1565 MenuList& items = track_menu->items();
1567 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1568 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1569 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1570 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1571 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1572 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1573 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1574 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1579 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1581 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1585 boost::shared_ptr<Stripable> s = ws.lock ();
1591 TreeModel::Children rows = track_model->children();
1592 TreeModel::Children::iterator i;
1594 for (i = rows.begin(); i != rows.end(); ++i) {
1595 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1599 if (what_changed.contains (ARDOUR::Properties::name)) {
1600 (*i)[stripable_columns.text] = s->name();
1603 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1604 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1605 redisplay_track_list ();
1612 error << _("track display list item for renamed strip not found!") << endmsg;
1616 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1618 TreeModel::Path path;
1619 TreeViewColumn* column;
1623 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1624 _group_tabs->get_menu(0)->popup (1, ev->time);
1628 TreeIter iter = group_model->get_iter (path);
1630 _group_tabs->get_menu(0)->popup (1, ev->time);
1634 RouteGroup* group = (*iter)[group_columns.group];
1636 if (Keyboard::is_context_menu_event (ev)) {
1637 _group_tabs->get_menu(group)->popup (1, ev->time);
1641 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1643 if (Keyboard::is_edit_event (ev)) {
1645 // edit_route_group (group);
1647 group_display.queue_draw();
1656 bool visible = (*iter)[group_columns.visible];
1657 (*iter)[group_columns.visible] = !visible;
1659 group_display.queue_draw();
1672 Mixer_UI::activate_all_route_groups ()
1674 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1678 Mixer_UI::disable_all_route_groups ()
1680 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1684 Mixer_UI::route_groups_changed ()
1686 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1688 _in_group_rebuild_or_clear = true;
1690 /* just rebuild the while thing */
1692 group_model->clear ();
1695 /* this is currently not used,
1696 * Mixer_UI::group_display_button_press() has a case for it,
1697 * and a commented edit_route_group() but that's n/a since 2011.
1699 * This code is left as reminder that
1700 * row[group_columns.group] = 0 has special meaning.
1704 row = *(group_model->append());
1705 row[group_columns.visible] = true;
1706 row[group_columns.text] = (_("-all-"));
1707 row[group_columns.group] = 0;
1711 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1713 _group_tabs->set_dirty ();
1714 _in_group_rebuild_or_clear = false;
1718 Mixer_UI::new_route_group ()
1720 _group_tabs->run_new_group_dialog (0, false);
1724 Mixer_UI::remove_selected_route_group ()
1726 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1727 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1733 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1736 /* selection mode is single, so rows.begin() is it */
1738 if ((iter = group_model->get_iter (*i))) {
1740 RouteGroup* rg = (*iter)[group_columns.group];
1743 _session->remove_route_group (*rg);
1749 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1751 if (in_group_row_change) {
1755 /* force an update of any mixer strips that are using this group,
1756 otherwise mix group names don't change in mixer strips
1759 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1760 if ((*i)->route_group() == group) {
1761 (*i)->route_group_changed();
1765 TreeModel::iterator i;
1766 TreeModel::Children rows = group_model->children();
1767 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1769 in_group_row_change = true;
1771 for (i = rows.begin(); i != rows.end(); ++i) {
1772 if ((*i)[group_columns.group] == group) {
1773 (*i)[group_columns.visible] = !group->is_hidden ();
1774 (*i)[group_columns.text] = group->name ();
1779 in_group_row_change = false;
1781 if (change.contains (Properties::name)) {
1782 _group_tabs->set_dirty ();
1785 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
1786 if ((*j)->route_group() == group) {
1787 if (group->is_hidden ()) {
1797 Mixer_UI::show_mixer_list (bool yn)
1800 list_vpacker.show ();
1802 list_vpacker.hide ();
1805 _show_mixer_list = yn;
1809 Mixer_UI::show_monitor_section (bool yn)
1811 if (!monitor_section()) {
1814 if (monitor_section()->tearoff().torn_off()) {
1819 monitor_section()->tearoff().show();
1821 monitor_section()->tearoff().hide();
1826 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
1831 if ((iter = group_model->get_iter (path))) {
1833 if ((group = (*iter)[group_columns.group]) == 0) {
1837 if (new_text != group->name()) {
1838 group->set_name (new_text);
1844 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
1848 if (in_group_row_change) {
1852 if ((group = (*iter)[group_columns.group]) == 0) {
1856 std::string name = (*iter)[group_columns.text];
1858 if (name != group->name()) {
1859 group->set_name (name);
1862 bool hidden = !(*iter)[group_columns.visible];
1864 if (hidden != group->is_hidden ()) {
1865 group->set_hidden (hidden, this);
1869 /** Called when a group model row is deleted, but also when the model is
1870 * reordered by a user drag-and-drop; the latter is what we are
1871 * interested in here.
1874 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
1876 if (_in_group_rebuild_or_clear) {
1880 /* Re-write the session's route group list so that the new order is preserved */
1882 list<RouteGroup*> new_list;
1884 Gtk::TreeModel::Children children = group_model->children();
1885 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
1886 RouteGroup* g = (*i)[group_columns.group];
1888 new_list.push_back (g);
1892 _session->reorder_route_groups (new_list);
1897 Mixer_UI::add_route_group (RouteGroup* group)
1899 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
1902 in_group_row_change = true;
1904 TreeModel::Row row = *(group_model->append());
1905 row[group_columns.visible] = !group->is_hidden ();
1906 row[group_columns.group] = group;
1907 if (!group->name().empty()) {
1908 row[group_columns.text] = group->name();
1910 row[group_columns.text] = _("unnamed");
1914 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
1917 TreeViewColumn* col = group_display.get_column (0);
1918 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
1919 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
1922 _group_tabs->set_dirty ();
1924 in_group_row_change = false;
1928 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
1930 using namespace Menu_Helpers;
1932 if (Keyboard::is_context_menu_event (ev)) {
1933 ARDOUR_UI::instance()->add_route ();
1941 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
1943 printf ("Mixer_UI::scroller_drag_data_received\n");
1944 if (data.get_target() != "PluginFavoritePtr") {
1945 context->drag_finish (false, false, time);
1949 const void * d = data.get_data();
1950 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
1952 PluginPresetList nfos;
1954 tv->get_object_drag_data (nfos, &source);
1956 Route::ProcessorList pl;
1959 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
1960 PluginPresetPtr ppp = (*i);
1961 PluginInfoPtr pip = ppp->_pip;
1962 if (!pip->is_instrument ()) {
1965 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);
1969 context->drag_finish (ok, false, time);
1973 Mixer_UI::set_strip_width (Width w, bool save)
1977 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
1978 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
1983 struct PluginStateSorter {
1985 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
1986 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
1987 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
1988 if (aiter != _user.end() && biter != _user.end()) {
1989 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
1991 if (aiter != _user.end()) {
1994 if (biter != _user.end()) {
1997 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2000 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2002 std::list<std::string> _user;
2006 Mixer_UI::set_state (const XMLNode& node, int version)
2008 XMLProperty const * prop;
2011 Tabbable::set_state (node, version);
2013 if ((prop = node.property ("narrow-strips"))) {
2014 if (string_is_affirmative (prop->value())) {
2015 set_strip_width (Narrow);
2017 set_strip_width (Wide);
2021 if ((prop = node.property ("show-mixer"))) {
2022 if (string_is_affirmative (prop->value())) {
2027 if ((prop = node.property ("maximised"))) {
2028 bool yn = string_is_affirmative (prop->value());
2029 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer"));
2031 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2032 bool fs = tact && tact->get_active();
2034 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2038 if ((prop = node.property ("show-mixer-list"))) {
2039 bool yn = string_is_affirmative (prop->value());
2040 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMixerList"));
2042 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2044 /* do it twice to force the change */
2045 tact->set_active (!yn);
2046 tact->set_active (yn);
2050 XMLNode* plugin_order;
2051 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2052 store_current_favorite_order ();
2053 std::list<string> order;
2054 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2055 XMLNodeConstIterator i;
2056 for (i = kids.begin(); i != kids.end(); ++i) {
2057 if ((prop = (*i)->property ("unique-id"))) {
2058 std::string unique_id = prop->value();
2059 order.push_back (unique_id);
2060 if ((prop = (*i)->property ("expanded"))) {
2061 favorite_ui_state[unique_id] = string_is_affirmative (prop->value());
2065 PluginStateSorter cmp (order);
2066 favorite_order.sort (cmp);
2067 sync_treeview_from_favorite_order ();
2073 Mixer_UI::get_state ()
2075 XMLNode* node = new XMLNode (X_("Mixer"));
2079 node->add_child_nocopy (Tabbable::get_state());
2081 snprintf(buf,sizeof(buf), "%f", rhs_pane1.get_divider());
2082 node->add_property(X_("mixer-rhs-pane1-pos"), string(buf));
2083 snprintf(buf,sizeof(buf), "%f", rhs_pane2.get_divider());
2084 node->add_property(X_("mixer-rhs_pane2-pos"), string(buf));
2085 snprintf(buf,sizeof(buf), "%f", list_hpane.get_divider());
2086 node->add_property(X_("mixer-list-hpane-pos"), string(buf));
2087 snprintf(buf,sizeof(buf), "%f", inner_pane.get_divider());
2088 node->add_property(X_("mixer-inner-pane-pos"), string(buf));
2090 node->add_property ("narrow-strips", _strip_width == Narrow ? "yes" : "no");
2091 node->add_property ("show-mixer", _visible ? "yes" : "no");
2092 node->add_property ("show-mixer-list", _show_mixer_list ? "yes" : "no");
2093 node->add_property ("maximised", _maximised ? "yes" : "no");
2095 store_current_favorite_order ();
2096 XMLNode* plugin_order = new XMLNode ("PluginOrder");
2098 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2099 XMLNode* p = new XMLNode ("PluginInfo");
2100 p->add_property ("sort", cnt);
2101 p->add_property ("unique-id", (*i)->unique_id);
2102 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2103 p->add_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2105 plugin_order->add_child_nocopy (*p);
2107 node->add_child_nocopy (*plugin_order);
2113 Mixer_UI::scroll_left ()
2115 if (!scroller.get_hscrollbar()) return;
2116 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2117 int sc_w = scroller.get_width();
2118 int sp_w = strip_packer.get_width();
2122 int lp = adj->get_value();
2124 using namespace Gtk::Box_Helpers;
2125 const BoxList& strips = strip_packer.children();
2126 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2127 lm += i->get_widget()->get_width ();
2129 lm -= i->get_widget()->get_width ();
2133 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2137 Mixer_UI::scroll_right ()
2139 if (!scroller.get_hscrollbar()) return;
2140 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2141 int sc_w = scroller.get_width();
2142 int sp_w = strip_packer.get_width();
2146 int lp = adj->get_value();
2148 using namespace Gtk::Box_Helpers;
2149 const BoxList& strips = strip_packer.children();
2150 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2151 lm += i->get_widget()->get_width ();
2156 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2160 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2162 switch (ev->direction) {
2163 case GDK_SCROLL_LEFT:
2167 if (ev->state & Keyboard::TertiaryModifier) {
2173 case GDK_SCROLL_RIGHT:
2177 case GDK_SCROLL_DOWN:
2178 if (ev->state & Keyboard::TertiaryModifier) {
2190 Mixer_UI::parameter_changed (string const & p)
2192 if (p == "show-group-tabs") {
2193 bool const s = _session->config.get_show_group_tabs ();
2195 _group_tabs->show ();
2197 _group_tabs->hide ();
2199 } else if (p == "default-narrow_ms") {
2200 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2201 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2202 (*i)->set_width_enum (s ? Narrow : Wide, this);
2204 } else if (p == "use-monitor-bus") {
2205 if (_session && !_session->monitor_out()) {
2206 monitor_section_detached ();
2212 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2214 g->set_active (a, this);
2218 Mixer_UI::plugin_selector()
2220 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2221 if (!_plugin_selector)
2222 _plugin_selector = new PluginSelector (PluginManager::instance());
2225 return _plugin_selector;
2229 Mixer_UI::setup_track_display ()
2231 track_model = ListStore::create (stripable_columns);
2232 track_display.set_model (track_model);
2233 track_display.append_column (_("Show"), stripable_columns.visible);
2234 track_display.append_column (_("Strips"), stripable_columns.text);
2235 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2236 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2237 track_display.get_column (0)->set_expand(false);
2238 track_display.get_column (1)->set_expand(true);
2239 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2240 track_display.set_name (X_("EditGroupList"));
2241 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2242 track_display.set_reorderable (true);
2243 track_display.set_headers_visible (true);
2244 track_display.set_can_focus(false);
2246 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2247 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2249 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2250 track_list_visible_cell->property_activatable() = true;
2251 track_list_visible_cell->property_radio() = false;
2252 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2254 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2256 track_display_scroller.add (track_display);
2257 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2259 VBox* v = manage (new VBox);
2261 v->pack_start (track_display_scroller, true, true);
2263 Button* b = manage (new Button);
2265 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
2269 b->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
2271 v->pack_start (*b, false, false);
2273 track_display_frame.set_name("BaseFrame");
2274 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2275 track_display_frame.add (*v);
2277 track_display_scroller.show();
2278 track_display_frame.show();
2279 track_display.show();
2283 Mixer_UI::new_track_or_bus ()
2285 ARDOUR_UI::instance()->add_route ();
2289 Mixer_UI::update_title ()
2291 if (!own_window()) {
2298 if (_session->snap_name() != _session->name()) {
2299 n = _session->snap_name ();
2301 n = _session->name ();
2304 if (_session->dirty ()) {
2308 WindowTitle title (n);
2309 title += S_("Window|Mixer");
2310 title += Glib::get_application_name ();
2311 own_window()->set_title (title.get_string());
2315 WindowTitle title (S_("Window|Mixer"));
2316 title += Glib::get_application_name ();
2317 own_window()->set_title (title.get_string());
2322 Mixer_UI::strip_by_x (int x)
2324 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2327 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2328 x2 = x1 + (*i)->get_width();
2330 if (x >= x1 && x <= x2) {
2339 Mixer_UI::set_axis_targets_for_operation ()
2341 _axis_targets.clear ();
2343 if (!_selection.empty()) {
2344 _axis_targets = _selection.axes;
2348 // removed "implicit" selections of strips, after discussion on IRC
2353 Mixer_UI::monitor_section_going_away ()
2355 if (_monitor_section) {
2356 monitor_section_detached ();
2357 out_packer.remove (_monitor_section->tearoff());
2358 _monitor_section->set_session (0);
2359 delete _monitor_section;
2360 _monitor_section = 0;
2365 Mixer_UI::toggle_midi_input_active (bool flip_others)
2367 boost::shared_ptr<RouteList> rl (new RouteList);
2370 set_axis_targets_for_operation ();
2372 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2373 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2377 onoff = !mt->input_active();
2381 _session->set_exclusive_input_active (rl, onoff, flip_others);
2385 Mixer_UI::maximise_mixer_space ()
2387 if (!own_window()) {
2395 _window->fullscreen ();
2400 Mixer_UI::restore_mixer_space ()
2402 if (!own_window()) {
2410 own_window()->unfullscreen();
2415 Mixer_UI::monitor_section_attached ()
2417 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2418 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2419 act->set_sensitive (true);
2420 tact->set_active ();
2424 Mixer_UI::monitor_section_detached ()
2426 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2427 act->set_sensitive (false);
2431 Mixer_UI::store_current_favorite_order ()
2433 typedef Gtk::TreeModel::Children type_children;
2434 type_children children = favorite_plugins_model->children();
2435 favorite_order.clear();
2436 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2438 Gtk::TreeModel::Row row = *iter;
2439 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2440 favorite_order.push_back (ppp->_pip);
2441 std::string name = row[favorite_plugins_columns.name];
2442 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2447 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2449 Gtk::TreeModel::Row row = *iter;
2450 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2452 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2456 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2458 PluginManager& manager (PluginManager::instance());
2459 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2460 if (manager.get_status (*i) != PluginManager::Favorite) {
2463 result.push_back (*i);
2467 struct PluginCustomSorter {
2469 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2470 PluginInfoList::const_iterator aiter = _user.begin();
2471 PluginInfoList::const_iterator biter = _user.begin();
2472 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2473 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2475 if (aiter != _user.end() && biter != _user.end()) {
2476 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2478 if (aiter != _user.end()) {
2481 if (biter != _user.end()) {
2484 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2486 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2488 PluginInfoList _user;
2492 Mixer_UI::refill_favorite_plugins ()
2494 PluginInfoList plugs;
2495 PluginManager& mgr (PluginManager::instance());
2498 refiller (plugs, mgr.lv2_plugin_info ());
2500 #ifdef WINDOWS_VST_SUPPORT
2501 refiller (plugs, mgr.windows_vst_plugin_info ());
2503 #ifdef LXVST_SUPPORT
2504 refiller (plugs, mgr.lxvst_plugin_info ());
2506 #ifdef MACVST_SUPPORT
2507 refiller (plugs, mgr.mac_vst_plugin_info ());
2509 #ifdef AUDIOUNIT_SUPPORT
2510 refiller (plugs, mgr.au_plugin_info ());
2512 refiller (plugs, mgr.ladspa_plugin_info ());
2513 refiller (plugs, mgr.lua_plugin_info ());
2515 store_current_favorite_order ();
2517 PluginCustomSorter cmp (favorite_order);
2520 favorite_order = plugs;
2522 sync_treeview_from_favorite_order ();
2526 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2529 if (!(iter = favorite_plugins_model->get_iter (path))) {
2532 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2536 PluginInfoPtr pip = ppp->_pip;
2537 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2538 if (favorite_ui_state[pip->unique_id]) {
2539 favorite_plugins_display.expand_row (path, true);
2545 Mixer_UI::sync_treeview_from_favorite_order ()
2547 favorite_plugins_model->clear ();
2548 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
2549 PluginInfoPtr pip = (*i);
2551 TreeModel::Row newrow = *(favorite_plugins_model->append());
2552 newrow[favorite_plugins_columns.name] = (*i)->name;
2553 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
2558 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
2559 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
2560 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
2561 child_row[favorite_plugins_columns.name] = (*j).label;
2562 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
2564 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2565 if (favorite_ui_state[pip->unique_id]) {
2566 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
2573 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
2575 using namespace Gtk::Menu_Helpers;
2577 Gtk::Menu* m = manage (new Menu);
2578 MenuList& items = m->items ();
2580 if (_selection.axes.empty()) {
2581 items.push_back (MenuElem (_("No Track/Bus is selected.")));
2583 items.push_back (MenuElem (_("Add at the top"),
2584 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
2585 items.push_back (MenuElem (_("Add Pre-Fader"),
2586 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
2587 items.push_back (MenuElem (_("Add Post-Fader"),
2588 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
2589 items.push_back (MenuElem (_("Add at the end"),
2590 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
2593 items.push_back (SeparatorElem());
2595 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
2597 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2598 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
2599 // we cannot currently delete AU presets
2600 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
2601 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
2605 m->popup (ev->button, ev->time);
2609 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
2611 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) {
2612 TreeModel::Path path;
2613 TreeViewColumn* column;
2615 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
2616 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2618 selection->unselect_all();
2619 selection->select(path);
2622 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2624 popup_note_context_menu (ev);
2632 Mixer_UI::selected_plugin ()
2634 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2636 return PluginPresetPtr();
2638 Gtk::TreeModel::iterator iter = selection->get_selected();
2640 return PluginPresetPtr();
2642 return (*iter)[favorite_plugins_columns.plugin];
2646 Mixer_UI::add_selected_processor (ProcessorPosition pos)
2648 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2650 add_favorite_processor (ppp, pos);
2655 Mixer_UI::delete_selected_preset ()
2660 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2661 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
2664 PluginPtr plugin = ppp->_pip->load (*_session);
2665 plugin->get_presets();
2666 plugin->remove_preset (ppp->_preset.label);
2670 Mixer_UI::remove_selected_from_favorites ()
2672 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2676 PluginManager::PluginStatusType status = PluginManager::Normal;
2677 PluginManager& manager (PluginManager::instance());
2679 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2680 manager.save_statuses ();
2684 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
2687 if (!(iter = favorite_plugins_model->get_iter (path))) {
2690 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2691 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
2695 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
2697 if (!_session || _selection.axes.empty()) {
2701 PluginInfoPtr pip = ppp->_pip;
2702 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
2703 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
2709 PluginPtr p = pip->load (*_session);
2715 if (ppp->_preset.valid) {
2716 p->load_preset (ppp->_preset);
2719 Route::ProcessorStreams err;
2720 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2724 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
2727 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
2734 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
2738 if (!np->display_to_user()) {
2741 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
2742 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
2747 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
2751 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
2758 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
2760 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
2764 // only allow to re-order top-level items
2766 if (TreePath::get_from_selection_data (data, src)) {
2767 if (src.up() && src.up()) {
2772 // don't allow to drop as child-rows.
2773 Gtk::TreeModel::Path _dest = dest; // un const
2774 const bool is_child = _dest.up (); // explicit bool for clang
2775 if (!is_child || _dest.empty ()) {
2782 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
2784 if (data.get_target() != "PluginPresetPtr") {
2787 if (data.get_length() != sizeof (PluginPresetPtr)) {
2790 const void *d = data.get_data();
2791 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
2793 PluginManager::PluginStatusType status = PluginManager::Favorite;
2794 PluginManager& manager (PluginManager::instance());
2796 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2797 manager.save_statuses ();
2801 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
2803 /* call protected MixerActor:: method */
2808 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
2810 /* call protected MixerActor:: method */
2815 Mixer_UI::show_vca_slaves (boost::shared_ptr<VCA> vca)
2817 boost::shared_ptr<VCA> v = spilled_vca.lock();
2820 show_vca_change (vca); /* EMIT SIGNAL */
2822 _group_tabs->hide ();
2824 _group_tabs->show ();
2826 redisplay_track_list ();
2831 Mixer_UI::showing_vca_slaves_for (boost::shared_ptr<VCA> vca) const
2833 return vca == spilled_vca.lock();
2837 Mixer_UI::register_actions ()
2839 Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
2841 myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
2842 myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
2843 myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
2844 myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
2845 myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
2846 myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
2849 myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
2850 myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
2851 myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
2852 myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
2853 myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
2854 myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
2855 myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
2856 myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
2858 myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
2859 myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
2861 myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
2862 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
2866 Mixer_UI::load_bindings ()
2868 bindings = Bindings::get_bindings (X_("Mixer"), myactions);
2871 template<class T> void
2872 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
2874 boost::shared_ptr<ControlList> cl (new ControlList);
2875 boost::shared_ptr<AutomationControl> ac;
2877 bool have_val = false;
2879 set_axis_targets_for_operation ();
2881 BOOST_FOREACH(AxisView* r, _axis_targets) {
2882 boost::shared_ptr<Stripable> s = r->stripable();
2884 ac = (s.get()->*get_control)();
2888 val = !ac->get_value();
2895 _session->set_controls (cl, val, Controllable::UseGroup);
2899 Mixer_UI::solo_action ()
2901 control_action (&Stripable::solo_control);
2905 Mixer_UI::mute_action ()
2907 control_action (&Stripable::mute_control);
2911 Mixer_UI::rec_enable_action ()
2913 control_action (&Stripable::rec_enable_control);
2917 Mixer_UI::step_gain_up_action ()
2919 set_axis_targets_for_operation ();
2921 BOOST_FOREACH(AxisView* r, _axis_targets) {
2922 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2924 ms->step_gain_up ();
2930 Mixer_UI::step_gain_down_action ()
2932 set_axis_targets_for_operation ();
2934 BOOST_FOREACH(AxisView* r, _axis_targets) {
2935 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2937 ms->step_gain_down ();
2943 Mixer_UI::unity_gain_action ()
2945 set_axis_targets_for_operation ();
2947 BOOST_FOREACH(AxisView* r, _axis_targets) {
2948 boost::shared_ptr<Stripable> s = r->stripable();
2950 boost::shared_ptr<AutomationControl> ac = s->gain_control();
2952 ac->set_value (1.0, Controllable::UseGroup);
2959 Mixer_UI::copy_processors ()
2961 set_axis_targets_for_operation ();
2963 BOOST_FOREACH(AxisView* r, _axis_targets) {
2964 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2966 ms->copy_processors ();
2971 Mixer_UI::cut_processors ()
2973 set_axis_targets_for_operation ();
2975 BOOST_FOREACH(AxisView* r, _axis_targets) {
2976 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2978 ms->cut_processors ();
2983 Mixer_UI::paste_processors ()
2985 set_axis_targets_for_operation ();
2987 BOOST_FOREACH(AxisView* r, _axis_targets) {
2988 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2990 ms->paste_processors ();
2995 Mixer_UI::select_all_processors ()
2997 set_axis_targets_for_operation ();
2999 BOOST_FOREACH(AxisView* r, _axis_targets) {
3000 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3002 ms->select_all_processors ();
3007 Mixer_UI::toggle_processors ()
3009 set_axis_targets_for_operation ();
3011 BOOST_FOREACH(AxisView* r, _axis_targets) {
3012 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3014 ms->toggle_processors ();
3019 Mixer_UI::ab_plugins ()
3021 set_axis_targets_for_operation ();
3023 BOOST_FOREACH(AxisView* r, _axis_targets) {
3024 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3032 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3034 set_axis_targets_for_operation ();
3036 BOOST_FOREACH(AxisView* r, _axis_targets) {
3037 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3039 ms->vca_assign (vca);
3046 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3048 set_axis_targets_for_operation ();
3050 BOOST_FOREACH(AxisView* r, _axis_targets) {
3051 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3053 ms->vca_unassign (vca);