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)
111 , _show_mixer_list (true)
112 , myactions (X_("mixer"))
116 _content.set_data ("ardour-bindings", bindings);
118 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
120 scroller.set_can_default (true);
121 // set_default (scroller);
123 scroller_base.set_flags (Gtk::CAN_FOCUS);
124 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
125 scroller_base.set_name ("MixerWindow");
126 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
128 /* set up drag-n-drop */
129 vector<TargetEntry> target_table;
130 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
131 scroller_base.drag_dest_set (target_table);
132 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
134 // add as last item of strip packer
135 strip_packer.pack_end (scroller_base, true, true);
137 _group_tabs = new MixerGroupTabs (this);
138 VBox* b = manage (new VBox);
140 b->set_border_width (0);
141 b->pack_start (*_group_tabs, PACK_SHRINK);
142 b->pack_start (strip_packer);
144 b->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
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::use_own_window (bool and_fill_it)
389 bool new_window = !own_window();
391 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);
406 Mixer_UI::show_window ()
408 Tabbable::show_window ();
410 /* show/hide group tabs as required */
411 parameter_changed ("show-group-tabs");
413 /* now reset each strips width so the right widgets are shown */
415 TreeModel::Children rows = track_model->children();
416 TreeModel::Children::iterator ri;
418 for (ri = rows.begin(); ri != rows.end(); ++ri) {
419 AxisView* av = (*ri)[stripable_columns.strip];
420 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
424 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
425 /* Fix visibility of mixer strip stuff */
426 ms->parameter_changed (X_("mixer-element-visibility"));
429 /* force focus into main area */
430 scroller_base.grab_focus ();
434 Mixer_UI::remove_master (VCAMasterStrip* vms)
436 if (_session && _session->deletion_in_progress()) {
437 /* its all being taken care of */
441 TreeModel::Children rows = track_model->children();
442 TreeModel::Children::iterator ri;
444 for (ri = rows.begin(); ri != rows.end(); ++ri) {
445 if ((*ri)[stripable_columns.strip] == vms) {
446 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
447 track_model->erase (ri);
454 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
456 using namespace Menu_Helpers;
458 if (Keyboard::is_context_menu_event (ev)) {
459 ARDOUR_UI::instance()->add_route ();
467 Mixer_UI::add_masters (VCAList& vlist)
471 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
472 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
479 Mixer_UI::add_routes (RouteList& rlist)
483 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
491 Mixer_UI::add_stripables (StripableList& slist)
493 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
494 bool from_scratch = (track_model->children().size() == 0);
495 uint32_t nroutes = 0;
497 slist.sort (StripablePresentationInfoSorter());
499 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
500 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
508 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
518 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
520 track_display.set_model (Glib::RefPtr<ListStore>());
522 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
524 boost::shared_ptr<Route> route;
525 boost::shared_ptr<VCA> vca;
527 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
529 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
531 TreeModel::Row row = *(track_model->append());
533 row[stripable_columns.text] = vca->name();
534 row[stripable_columns.visible] = vms->marked_for_display ();
535 row[stripable_columns.strip] = vms;
536 row[stripable_columns.stripable] = vca;
538 vms->CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
540 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
542 if (route->is_auditioner()) {
546 if (route->is_monitor()) {
548 if (!_monitor_section) {
549 _monitor_section = new MonitorSection (_session);
551 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
553 _monitor_section->tearoff().set_state (*mnode);
557 out_packer.pack_end (_monitor_section->tearoff(), false, false);
558 _monitor_section->set_session (_session);
559 _monitor_section->tearoff().show_all ();
561 _monitor_section->tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
562 _monitor_section->tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
564 monitor_section_attached ();
566 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
568 /* no regular strip shown for control out */
573 strip = new MixerStrip (*this, _session, route);
574 strips.push_back (strip);
576 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
578 if (strip->width_owner() != strip) {
579 strip->set_width_enum (_strip_width, this);
584 if (!route->is_master()) {
586 TreeModel::Row row = *(track_model->insert (insert_iter));
588 row[stripable_columns.text] = route->name();
589 row[stripable_columns.visible] = strip->marked_for_display();
590 row[stripable_columns.stripable] = route;
591 row[stripable_columns.strip] = strip;
594 _selection.add (strip);
599 out_packer.pack_start (*strip, false, false);
600 strip->set_packed (true);
603 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
604 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
607 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
608 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
611 } catch (const std::exception& e) {
612 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
615 track_display.set_model (track_model);
618 sync_presentation_info_from_treeview ();
621 redisplay_track_list ();
625 Mixer_UI::deselect_all_strip_processors ()
627 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
628 (*i)->deselect_all_processors();
633 Mixer_UI::select_strip (MixerStrip& ms, bool add)
636 _selection.add (&ms);
638 _selection.set (&ms);
643 Mixer_UI::select_none ()
645 _selection.clear_routes();
646 deselect_all_strip_processors();
650 Mixer_UI::delete_processors ()
652 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
653 (*i)->delete_processors();
659 Mixer_UI::remove_strip (MixerStrip* strip)
661 if (_session && _session->deletion_in_progress()) {
662 /* its all being taken care of */
666 TreeModel::Children rows = track_model->children();
667 TreeModel::Children::iterator ri;
668 list<MixerStrip *>::iterator i;
670 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
674 for (ri = rows.begin(); ri != rows.end(); ++ri) {
675 if ((*ri)[stripable_columns.strip] == strip) {
676 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
677 track_model->erase (ri);
684 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
687 soh.add (Properties::selected);
688 soh.add (Properties::order);
689 soh.add (Properties::hidden);
691 if (what_changed.contains (soh)) {
692 sync_treeview_from_presentation_info (what_changed);
697 Mixer_UI::sync_presentation_info_from_treeview ()
699 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
703 TreeModel::Children rows = track_model->children();
709 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
711 TreeModel::Children::iterator ri;
716 const size_t cmp_max = rows.size ();
718 // special case master if it's got PI order 0 lets keep it there
719 if (_session->master_out() && (_session->master_out()->presentation_info().order() == 0)) {
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];
733 /* Monitor and Auditioner do not get their presentation
737 if (stripable->is_monitor() || stripable->is_auditioner()) {
741 /* Master also doesn't get set here but since the editor allows
742 * it to be reordered, we need to preserve its ordering.
745 stripable->presentation_info().set_hidden (!visible);
747 // master may not get set here, but if it is zero keep it there
748 if (stripable->is_master() && (stripable->presentation_info().order() == 0)) {
752 if (order != stripable->presentation_info().order()) {
753 stripable->set_presentation_order (order);
757 sorted.push_back (OrderKeys (order, stripable, cmp_max));
763 // VCA (and Mixbus) special cases according to SortByNewDisplayOrder
765 SortByNewDisplayOrder cmp;
766 sort (sorted.begin(), sorted.end(), cmp);
767 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
768 if (sr->old_display_order != n) {
774 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
775 if (sr->stripable->presentation_info().order() != n) {
776 sr->stripable->set_presentation_order (n);
783 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
784 _session->set_dirty();
789 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
791 if (!_session || _session->deletion_in_progress()) {
795 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
797 /* we could get here after either a change in the Mixer or Editor sort
798 * order, but either way, the mixer order keys reflect the intended
799 * order for the GUI, so reorder the treeview model to match it.
802 vector<int> neworder;
803 TreeModel::Children rows = track_model->children();
804 uint32_t old_order = 0;
805 bool changed = false;
812 const size_t cmp_max = rows.size ();
814 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
815 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
816 sorted.push_back (OrderKeys (old_order, stripable, cmp_max));
819 SortByNewDisplayOrder cmp;
821 sort (sorted.begin(), sorted.end(), cmp);
822 neworder.assign (sorted.size(), 0);
826 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
828 neworder[n] = sr->old_display_order;
830 if (sr->old_display_order != n) {
836 Unwinder<bool> uw (ignore_reorder, true);
837 track_model->reorder (neworder);
840 if (what_changed.contains (Properties::selected)) {
842 PresentationInfo::ChangeSuspender cs;
844 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
845 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
846 if (stripable && stripable->presentation_info().selected()) {
849 _selection.remove (*i);
853 if (!_selection.axes.empty()) {
854 move_stripable_into_view ((*_selection.axes.begin())->stripable());
858 redisplay_track_list ();
863 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
865 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
866 if ((*i)->route() == r) {
875 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
877 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
878 if ((*i)->stripable() == s) {
887 Mixer_UI::axis_by_stripable (boost::shared_ptr<Stripable> s) const
889 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
890 if ((*i)->stripable() == s) {
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 tmp.push_back (strip);
924 const size_t cmp_max = strips.size ();
925 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
926 sorted.push_back (OrderKeys (-1, (*i)->stripable(), cmp_max));
928 SortByNewDisplayOrder cmp;
929 sort (sorted.begin(), sorted.end(), cmp);
931 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr) {
932 MixerStrip* ms = strip_by_stripable (sr->stripable);
936 /* hit clicked strip, start accumulating till we hit the first
945 } else if (_selection.selected (ms)) {
946 /* hit selected strip. if currently accumulating others,
947 we're done. if not accumulating others, start doing so.
949 found_another = true;
964 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
968 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
970 _selection.set (strip);
979 Mixer_UI::set_session (Session* sess)
981 SessionHandlePtr::set_session (sess);
983 if (_plugin_selector) {
984 _plugin_selector->set_session (_session);
987 _group_tabs->set_session (sess);
989 if (_monitor_section) {
990 _monitor_section->set_session (_session);
997 refill_favorite_plugins();
999 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1000 set_state (*node, 0);
1004 initial_track_display ();
1006 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1007 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1008 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1009 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1010 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1011 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1012 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1014 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1016 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1018 route_groups_changed ();
1027 Mixer_UI::session_going_away ()
1029 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1031 _in_group_rebuild_or_clear = true;
1032 group_model->clear ();
1033 _in_group_rebuild_or_clear = false;
1035 _selection.clear ();
1036 track_model->clear ();
1038 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1042 if (_monitor_section) {
1043 _monitor_section->tearoff().hide_visible ();
1046 monitor_section_detached ();
1052 SessionHandlePtr::session_going_away ();
1059 Mixer_UI::track_visibility_changed (std::string const & path)
1061 if (_session && _session->deletion_in_progress()) {
1067 if ((iter = track_model->get_iter (path))) {
1069 AxisView* av = (*iter)[stripable_columns.strip];
1070 bool visible = (*iter)[stripable_columns.visible];
1072 if (av->set_marked_for_display (!visible)) {
1073 update_track_visibility ();
1079 Mixer_UI::update_track_visibility ()
1081 TreeModel::Children rows = track_model->children();
1082 TreeModel::Children::iterator i;
1085 Unwinder<bool> uw (no_track_list_redisplay, true);
1087 for (i = rows.begin(); i != rows.end(); ++i) {
1088 AxisView* av = (*i)[stripable_columns.strip];
1089 (*i)[stripable_columns.visible] = av->marked_for_display ();
1092 /* force presentation catch up with visibility changes
1095 sync_presentation_info_from_treeview ();
1098 redisplay_track_list ();
1102 Mixer_UI::show_strip (MixerStrip* ms)
1104 TreeModel::Children rows = track_model->children();
1105 TreeModel::Children::iterator i;
1107 for (i = rows.begin(); i != rows.end(); ++i) {
1109 AxisView* av = (*i)[stripable_columns.strip];
1110 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1112 (*i)[stripable_columns.visible] = true;
1113 av->set_marked_for_display (true);
1114 update_track_visibility ();
1121 Mixer_UI::hide_strip (MixerStrip* ms)
1123 TreeModel::Children rows = track_model->children();
1124 TreeModel::Children::iterator i;
1126 for (i = rows.begin(); i != rows.end(); ++i) {
1128 AxisView* av = (*i)[stripable_columns.strip];
1129 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1131 (*i)[stripable_columns.visible] = false;
1132 av->set_marked_for_display (false);
1133 update_track_visibility ();
1140 Mixer_UI::start_updating ()
1142 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1147 Mixer_UI::stop_updating ()
1149 fast_screen_update_connection.disconnect();
1154 Mixer_UI::fast_update_strips ()
1156 if (_content.is_mapped () && _session) {
1157 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1158 (*i)->fast_update ();
1164 Mixer_UI::set_all_strips_visibility (bool yn)
1166 TreeModel::Children rows = track_model->children();
1167 TreeModel::Children::iterator i;
1170 Unwinder<bool> uw (no_track_list_redisplay, true);
1172 for (i = rows.begin(); i != rows.end(); ++i) {
1174 AxisView* av = (*i)[stripable_columns.strip];
1175 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1181 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1185 (*i)[stripable_columns.visible] = yn;
1189 redisplay_track_list ();
1194 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1196 TreeModel::Children rows = track_model->children();
1197 TreeModel::Children::iterator i;
1200 Unwinder<bool> uw (no_track_list_redisplay, true);
1202 for (i = rows.begin(); i != rows.end(); ++i) {
1204 AxisView* av = (*i)[stripable_columns.strip];
1205 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1211 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1215 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1216 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1220 (*i)[stripable_columns.visible] = yn;
1224 if (at) { /* track */
1225 (*i)[stripable_columns.visible] = yn;
1230 if (!at && !mt) { /* bus */
1231 (*i)[stripable_columns.visible] = yn;
1236 if (mt) { /* midi-track */
1237 (*i)[stripable_columns.visible] = yn;
1244 redisplay_track_list ();
1248 Mixer_UI::hide_all_routes ()
1250 set_all_strips_visibility (false);
1254 Mixer_UI::show_all_routes ()
1256 set_all_strips_visibility (true);
1260 Mixer_UI::show_all_audiobus ()
1262 set_all_audio_midi_visibility (2, true);
1265 Mixer_UI::hide_all_audiobus ()
1267 set_all_audio_midi_visibility (2, false);
1271 Mixer_UI::show_all_audiotracks()
1273 set_all_audio_midi_visibility (1, true);
1276 Mixer_UI::hide_all_audiotracks ()
1278 set_all_audio_midi_visibility (1, false);
1282 Mixer_UI::show_all_miditracks()
1284 set_all_audio_midi_visibility (3, true);
1287 Mixer_UI::hide_all_miditracks ()
1289 set_all_audio_midi_visibility (3, false);
1293 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1295 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1296 sync_presentation_info_from_treeview ();
1300 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1302 /* this happens as the second step of a DnD within the treeview as well
1303 as when a row/route is actually deleted.
1305 if it was a deletion then we have to force a redisplay because
1306 order keys may not have changed.
1309 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1310 sync_presentation_info_from_treeview ();
1312 if (_route_deletion_in_progress) {
1313 redisplay_track_list ();
1318 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1320 TreeModel::Children rows = track_model->children();
1321 std::list<boost::shared_ptr<VCA> > vcas;
1322 vcas.push_back (vca);
1324 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1325 AxisView* av = (*i)[stripable_columns.strip];
1326 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1327 if (vms && vms->vca()->slaved_to (vca)) {
1328 vcas.push_back (vms->vca());
1332 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1334 AxisView* av = (*i)[stripable_columns.strip];
1335 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1338 /* we're in the middle of changing a row, don't worry */
1342 if (!strip->route()) {
1343 /* non-route element */
1347 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1351 bool slaved = false;
1352 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1353 if (strip->route()->slaved_to (*m)) {
1361 if (strip->packed()) {
1362 strip_packer.reorder_child (*strip, -1); /* put at end */
1364 strip_packer.pack_start (*strip, false, false);
1365 strip->set_packed (true);
1370 if (strip->packed()) {
1371 strip_packer.remove (*strip);
1372 strip->set_packed (false);
1379 Mixer_UI::redisplay_track_list ()
1381 if (no_track_list_redisplay) {
1385 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1387 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1389 spill_redisplay (sv);
1394 TreeModel::Children rows = track_model->children();
1395 TreeModel::Children::iterator i;
1396 uint32_t n_masters = 0;
1398 container_clear (vca_hpacker);
1399 vca_hpacker.pack_end (vca_scroller_base, true, true);
1401 for (i = rows.begin(); i != rows.end(); ++i) {
1403 AxisView* s = (*i)[stripable_columns.strip];
1404 bool const visible = (*i)[stripable_columns.visible];
1405 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1408 /* we're in the middle of changing a row, don't worry */
1412 VCAMasterStrip* vms;
1414 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1416 vca_hpacker.pack_start (*vms, false, false);
1423 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1431 if (strip->packed()) {
1432 strip_packer.reorder_child (*strip, -1); /* put at end */
1434 strip_packer.pack_start (*strip, false, false);
1435 strip->set_packed (true);
1440 if (stripable->is_master() || stripable->is_monitor()) {
1441 /* do nothing, these cannot be hidden */
1443 if (strip->packed()) {
1444 strip_packer.remove (*strip);
1445 strip->set_packed (false);
1451 /* update visibility of VCA assign buttons */
1453 if (n_masters == 0) {
1454 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1455 vca_vpacker.hide ();
1457 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1458 vca_vpacker.show ();
1461 _group_tabs->set_dirty ();
1465 Mixer_UI::strip_width_changed ()
1467 _group_tabs->set_dirty ();
1470 TreeModel::Children rows = track_model->children();
1471 TreeModel::Children::iterator i;
1474 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1475 AxisView* av = (*i)[stripable_columns.strip];
1476 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1482 bool visible = (*i)[stripable_columns.visible];
1485 strip->queue_draw();
1492 struct PresentationInfoMixerSorter
1494 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1495 if (a->is_master()) {
1496 /* master after everything else */
1498 } else if (b->is_master()) {
1499 /* everything else before master */
1502 return a->presentation_info().order () < b->presentation_info().order ();
1507 Mixer_UI::initial_track_display ()
1511 boost::shared_ptr<RouteList> routes = _session->get_routes();
1513 for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) {
1517 VCAList vcas = _session->vca_manager().vcas();
1519 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
1520 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
1523 sl.sort (PresentationInfoMixerSorter());
1526 /* These are also used inside ::add_stripables() but we need
1527 * them here because we're going to clear the track_model also.
1529 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1530 Unwinder<bool> uw2 (ignore_reorder, true);
1532 track_model->clear ();
1533 add_stripables (sl);
1536 sync_treeview_from_presentation_info (Properties::order);
1540 Mixer_UI::show_track_list_menu ()
1542 if (track_menu == 0) {
1543 build_track_menu ();
1546 track_menu->popup (1, gtk_get_current_event_time());
1550 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1552 if (Keyboard::is_context_menu_event (ev)) {
1553 show_track_list_menu ();
1556 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1557 TreeModel::Path path;
1558 TreeViewColumn* column;
1560 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1561 TreeIter iter = track_model->get_iter (path);
1562 if ((*iter)[stripable_columns.visible]) {
1563 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1564 move_stripable_into_view (s);
1573 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1575 if (!scroller.get_hscrollbar()) {
1578 if (s->presentation_info().special () || s->presentation_info().flag_match (PresentationInfo::VCA)) {
1588 Gtk::Allocation alloc;
1589 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1590 if ((*i)->route() == s) {
1593 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1594 alloc = (*i)->get_allocation ();
1602 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1604 if (x0 < adj->get_value()) {
1605 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1606 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1607 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1608 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1613 Mixer_UI::build_track_menu ()
1615 using namespace Menu_Helpers;
1616 using namespace Gtk;
1618 track_menu = new Menu;
1619 track_menu->set_name ("ArdourContextMenu");
1620 MenuList& items = track_menu->items();
1622 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1623 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1624 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1625 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1626 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1627 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1628 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1629 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1634 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1636 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1640 boost::shared_ptr<Stripable> s = ws.lock ();
1646 TreeModel::Children rows = track_model->children();
1647 TreeModel::Children::iterator i;
1649 for (i = rows.begin(); i != rows.end(); ++i) {
1650 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1654 if (what_changed.contains (ARDOUR::Properties::name)) {
1655 (*i)[stripable_columns.text] = s->name();
1658 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1659 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1660 redisplay_track_list ();
1667 error << _("track display list item for renamed strip not found!") << endmsg;
1671 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1673 TreeModel::Path path;
1674 TreeViewColumn* column;
1678 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1679 _group_tabs->get_menu(0)->popup (1, ev->time);
1683 TreeIter iter = group_model->get_iter (path);
1685 _group_tabs->get_menu(0)->popup (1, ev->time);
1689 RouteGroup* group = (*iter)[group_columns.group];
1691 if (Keyboard::is_context_menu_event (ev)) {
1692 _group_tabs->get_menu(group)->popup (1, ev->time);
1696 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1698 if (Keyboard::is_edit_event (ev)) {
1700 // edit_route_group (group);
1702 group_display.queue_draw();
1711 bool visible = (*iter)[group_columns.visible];
1712 (*iter)[group_columns.visible] = !visible;
1714 group_display.queue_draw();
1727 Mixer_UI::activate_all_route_groups ()
1729 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1733 Mixer_UI::disable_all_route_groups ()
1735 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1739 Mixer_UI::route_groups_changed ()
1741 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1743 _in_group_rebuild_or_clear = true;
1745 /* just rebuild the while thing */
1747 group_model->clear ();
1750 /* this is currently not used,
1751 * Mixer_UI::group_display_button_press() has a case for it,
1752 * and a commented edit_route_group() but that's n/a since 2011.
1754 * This code is left as reminder that
1755 * row[group_columns.group] = 0 has special meaning.
1759 row = *(group_model->append());
1760 row[group_columns.visible] = true;
1761 row[group_columns.text] = (_("-all-"));
1762 row[group_columns.group] = 0;
1766 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1768 _group_tabs->set_dirty ();
1769 _in_group_rebuild_or_clear = false;
1773 Mixer_UI::new_route_group ()
1775 _group_tabs->run_new_group_dialog (0, false);
1779 Mixer_UI::remove_selected_route_group ()
1781 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1782 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1788 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1791 /* selection mode is single, so rows.begin() is it */
1793 if ((iter = group_model->get_iter (*i))) {
1795 RouteGroup* rg = (*iter)[group_columns.group];
1798 _session->remove_route_group (*rg);
1804 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1806 if (in_group_row_change) {
1810 /* force an update of any mixer strips that are using this group,
1811 otherwise mix group names don't change in mixer strips
1814 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1815 if ((*i)->route_group() == group) {
1816 (*i)->route_group_changed();
1820 TreeModel::iterator i;
1821 TreeModel::Children rows = group_model->children();
1822 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1824 in_group_row_change = true;
1826 for (i = rows.begin(); i != rows.end(); ++i) {
1827 if ((*i)[group_columns.group] == group) {
1828 (*i)[group_columns.visible] = !group->is_hidden ();
1829 (*i)[group_columns.text] = group->name ();
1834 in_group_row_change = false;
1836 if (change.contains (Properties::name)) {
1837 _group_tabs->set_dirty ();
1840 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
1841 if ((*j)->route_group() == group) {
1842 if (group->is_hidden ()) {
1852 Mixer_UI::show_mixer_list (bool yn)
1855 list_vpacker.show ();
1857 list_vpacker.hide ();
1860 _show_mixer_list = yn;
1864 Mixer_UI::show_monitor_section (bool yn)
1866 if (!monitor_section()) {
1869 if (monitor_section()->tearoff().torn_off()) {
1874 monitor_section()->tearoff().show();
1876 monitor_section()->tearoff().hide();
1881 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
1886 if ((iter = group_model->get_iter (path))) {
1888 if ((group = (*iter)[group_columns.group]) == 0) {
1892 if (new_text != group->name()) {
1893 group->set_name (new_text);
1899 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
1903 if (in_group_row_change) {
1907 if ((group = (*iter)[group_columns.group]) == 0) {
1911 std::string name = (*iter)[group_columns.text];
1913 if (name != group->name()) {
1914 group->set_name (name);
1917 bool hidden = !(*iter)[group_columns.visible];
1919 if (hidden != group->is_hidden ()) {
1920 group->set_hidden (hidden, this);
1924 /** Called when a group model row is deleted, but also when the model is
1925 * reordered by a user drag-and-drop; the latter is what we are
1926 * interested in here.
1929 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
1931 if (_in_group_rebuild_or_clear) {
1935 /* Re-write the session's route group list so that the new order is preserved */
1937 list<RouteGroup*> new_list;
1939 Gtk::TreeModel::Children children = group_model->children();
1940 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
1941 RouteGroup* g = (*i)[group_columns.group];
1943 new_list.push_back (g);
1947 _session->reorder_route_groups (new_list);
1952 Mixer_UI::add_route_group (RouteGroup* group)
1954 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
1957 in_group_row_change = true;
1959 TreeModel::Row row = *(group_model->append());
1960 row[group_columns.visible] = !group->is_hidden ();
1961 row[group_columns.group] = group;
1962 if (!group->name().empty()) {
1963 row[group_columns.text] = group->name();
1965 row[group_columns.text] = _("unnamed");
1969 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
1972 TreeViewColumn* col = group_display.get_column (0);
1973 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
1974 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
1977 _group_tabs->set_dirty ();
1979 in_group_row_change = false;
1983 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
1985 using namespace Menu_Helpers;
1987 if (Keyboard::is_context_menu_event (ev)) {
1988 ARDOUR_UI::instance()->add_route ();
1996 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
1998 printf ("Mixer_UI::scroller_drag_data_received\n");
1999 if (data.get_target() != "PluginFavoritePtr") {
2000 context->drag_finish (false, false, time);
2004 const void * d = data.get_data();
2005 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2007 PluginPresetList nfos;
2009 tv->get_object_drag_data (nfos, &source);
2011 Route::ProcessorList pl;
2014 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2015 PluginPresetPtr ppp = (*i);
2016 PluginInfoPtr pip = ppp->_pip;
2017 if (!pip->is_instrument ()) {
2020 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);
2024 context->drag_finish (ok, false, time);
2028 Mixer_UI::set_strip_width (Width w, bool save)
2032 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2033 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2038 struct PluginStateSorter {
2040 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2041 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2042 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2043 if (aiter != _user.end() && biter != _user.end()) {
2044 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2046 if (aiter != _user.end()) {
2049 if (biter != _user.end()) {
2052 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2055 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2057 std::list<std::string> _user;
2061 Mixer_UI::set_state (const XMLNode& node, int version)
2063 XMLProperty const * prop;
2066 Tabbable::set_state (node, version);
2068 if ((prop = node.property ("narrow-strips"))) {
2069 if (string_is_affirmative (prop->value())) {
2070 set_strip_width (Narrow);
2072 set_strip_width (Wide);
2076 if ((prop = node.property ("show-mixer"))) {
2077 if (string_is_affirmative (prop->value())) {
2082 if ((prop = node.property ("maximised"))) {
2083 bool yn = string_is_affirmative (prop->value());
2084 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer"));
2086 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2087 bool fs = tact && tact->get_active();
2089 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2093 if ((prop = node.property ("show-mixer-list"))) {
2094 bool yn = string_is_affirmative (prop->value());
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);
2105 XMLNode* plugin_order;
2106 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2107 store_current_favorite_order ();
2108 std::list<string> order;
2109 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2110 XMLNodeConstIterator i;
2111 for (i = kids.begin(); i != kids.end(); ++i) {
2112 if ((prop = (*i)->property ("unique-id"))) {
2113 std::string unique_id = prop->value();
2114 order.push_back (unique_id);
2115 if ((prop = (*i)->property ("expanded"))) {
2116 favorite_ui_state[unique_id] = string_is_affirmative (prop->value());
2120 PluginStateSorter cmp (order);
2121 favorite_order.sort (cmp);
2122 sync_treeview_from_favorite_order ();
2128 Mixer_UI::get_state ()
2130 XMLNode* node = new XMLNode (X_("Mixer"));
2134 node->add_child_nocopy (Tabbable::get_state());
2136 snprintf(buf,sizeof(buf), "%f", rhs_pane1.get_divider());
2137 node->add_property(X_("mixer-rhs-pane1-pos"), string(buf));
2138 snprintf(buf,sizeof(buf), "%f", rhs_pane2.get_divider());
2139 node->add_property(X_("mixer-rhs_pane2-pos"), string(buf));
2140 snprintf(buf,sizeof(buf), "%f", list_hpane.get_divider());
2141 node->add_property(X_("mixer-list-hpane-pos"), string(buf));
2142 snprintf(buf,sizeof(buf), "%f", inner_pane.get_divider());
2143 node->add_property(X_("mixer-inner-pane-pos"), string(buf));
2145 node->add_property ("narrow-strips", _strip_width == Narrow ? "yes" : "no");
2146 node->add_property ("show-mixer", _visible ? "yes" : "no");
2147 node->add_property ("show-mixer-list", _show_mixer_list ? "yes" : "no");
2148 node->add_property ("maximised", _maximised ? "yes" : "no");
2150 store_current_favorite_order ();
2151 XMLNode* plugin_order = new XMLNode ("PluginOrder");
2153 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2154 XMLNode* p = new XMLNode ("PluginInfo");
2155 p->add_property ("sort", cnt);
2156 p->add_property ("unique-id", (*i)->unique_id);
2157 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2158 p->add_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2160 plugin_order->add_child_nocopy (*p);
2162 node->add_child_nocopy (*plugin_order);
2168 Mixer_UI::scroll_left ()
2170 if (!scroller.get_hscrollbar()) return;
2171 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2172 int sc_w = scroller.get_width();
2173 int sp_w = strip_packer.get_width();
2177 int lp = adj->get_value();
2179 using namespace Gtk::Box_Helpers;
2180 const BoxList& strips = strip_packer.children();
2181 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2182 lm += i->get_widget()->get_width ();
2184 lm -= i->get_widget()->get_width ();
2188 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2192 Mixer_UI::scroll_right ()
2194 if (!scroller.get_hscrollbar()) return;
2195 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2196 int sc_w = scroller.get_width();
2197 int sp_w = strip_packer.get_width();
2201 int lp = adj->get_value();
2203 using namespace Gtk::Box_Helpers;
2204 const BoxList& strips = strip_packer.children();
2205 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2206 lm += i->get_widget()->get_width ();
2211 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2215 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2217 switch (ev->direction) {
2218 case GDK_SCROLL_LEFT:
2222 if (ev->state & Keyboard::TertiaryModifier) {
2228 case GDK_SCROLL_RIGHT:
2232 case GDK_SCROLL_DOWN:
2233 if (ev->state & Keyboard::TertiaryModifier) {
2245 Mixer_UI::parameter_changed (string const & p)
2247 if (p == "show-group-tabs") {
2248 bool const s = _session->config.get_show_group_tabs ();
2250 _group_tabs->show ();
2252 _group_tabs->hide ();
2254 } else if (p == "default-narrow_ms") {
2255 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2256 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2257 (*i)->set_width_enum (s ? Narrow : Wide, this);
2259 } else if (p == "use-monitor-bus") {
2260 if (_session && !_session->monitor_out()) {
2261 monitor_section_detached ();
2267 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2269 g->set_active (a, this);
2273 Mixer_UI::plugin_selector()
2275 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2276 if (!_plugin_selector)
2277 _plugin_selector = new PluginSelector (PluginManager::instance());
2280 return _plugin_selector;
2284 Mixer_UI::setup_track_display ()
2286 track_model = ListStore::create (stripable_columns);
2287 track_display.set_model (track_model);
2288 track_display.append_column (_("Show"), stripable_columns.visible);
2289 track_display.append_column (_("Strips"), stripable_columns.text);
2290 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2291 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2292 track_display.get_column (0)->set_expand(false);
2293 track_display.get_column (1)->set_expand(true);
2294 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2295 track_display.set_name (X_("EditGroupList"));
2296 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2297 track_display.set_reorderable (true);
2298 track_display.set_headers_visible (true);
2299 track_display.set_can_focus(false);
2301 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2302 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2304 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2305 track_list_visible_cell->property_activatable() = true;
2306 track_list_visible_cell->property_radio() = false;
2307 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2309 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2311 track_display_scroller.add (track_display);
2312 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2314 VBox* v = manage (new VBox);
2316 v->pack_start (track_display_scroller, true, true);
2318 Button* b = manage (new Button);
2320 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
2324 b->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
2326 v->pack_start (*b, false, false);
2328 track_display_frame.set_name("BaseFrame");
2329 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2330 track_display_frame.add (*v);
2332 track_display_scroller.show();
2333 track_display_frame.show();
2334 track_display.show();
2338 Mixer_UI::new_track_or_bus ()
2340 ARDOUR_UI::instance()->add_route ();
2344 Mixer_UI::update_title ()
2346 if (!own_window()) {
2353 if (_session->snap_name() != _session->name()) {
2354 n = _session->snap_name ();
2356 n = _session->name ();
2359 if (_session->dirty ()) {
2363 WindowTitle title (n);
2364 title += S_("Window|Mixer");
2365 title += Glib::get_application_name ();
2366 own_window()->set_title (title.get_string());
2370 WindowTitle title (S_("Window|Mixer"));
2371 title += Glib::get_application_name ();
2372 own_window()->set_title (title.get_string());
2377 Mixer_UI::strip_by_x (int x)
2379 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2382 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2383 x2 = x1 + (*i)->get_width();
2385 if (x >= x1 && x <= x2) {
2394 Mixer_UI::set_axis_targets_for_operation ()
2396 _axis_targets.clear ();
2398 if (!_selection.empty()) {
2399 _axis_targets = _selection.axes;
2403 // removed "implicit" selections of strips, after discussion on IRC
2408 Mixer_UI::monitor_section_going_away ()
2410 if (_monitor_section) {
2411 monitor_section_detached ();
2412 out_packer.remove (_monitor_section->tearoff());
2413 _monitor_section->set_session (0);
2414 delete _monitor_section;
2415 _monitor_section = 0;
2420 Mixer_UI::toggle_midi_input_active (bool flip_others)
2422 boost::shared_ptr<RouteList> rl (new RouteList);
2425 set_axis_targets_for_operation ();
2427 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2428 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2432 onoff = !mt->input_active();
2436 _session->set_exclusive_input_active (rl, onoff, flip_others);
2440 Mixer_UI::maximise_mixer_space ()
2442 if (!own_window()) {
2450 _window->fullscreen ();
2455 Mixer_UI::restore_mixer_space ()
2457 if (!own_window()) {
2465 own_window()->unfullscreen();
2470 Mixer_UI::monitor_section_attached ()
2472 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2473 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2474 act->set_sensitive (true);
2475 tact->set_active ();
2479 Mixer_UI::monitor_section_detached ()
2481 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2482 act->set_sensitive (false);
2486 Mixer_UI::store_current_favorite_order ()
2488 typedef Gtk::TreeModel::Children type_children;
2489 type_children children = favorite_plugins_model->children();
2490 favorite_order.clear();
2491 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2493 Gtk::TreeModel::Row row = *iter;
2494 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2495 favorite_order.push_back (ppp->_pip);
2496 std::string name = row[favorite_plugins_columns.name];
2497 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2502 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2504 Gtk::TreeModel::Row row = *iter;
2505 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2507 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2511 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2513 PluginManager& manager (PluginManager::instance());
2514 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2515 if (manager.get_status (*i) != PluginManager::Favorite) {
2518 result.push_back (*i);
2522 struct PluginCustomSorter {
2524 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2525 PluginInfoList::const_iterator aiter = _user.begin();
2526 PluginInfoList::const_iterator biter = _user.begin();
2527 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2528 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2530 if (aiter != _user.end() && biter != _user.end()) {
2531 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2533 if (aiter != _user.end()) {
2536 if (biter != _user.end()) {
2539 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2541 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2543 PluginInfoList _user;
2547 Mixer_UI::refill_favorite_plugins ()
2549 PluginInfoList plugs;
2550 PluginManager& mgr (PluginManager::instance());
2553 refiller (plugs, mgr.lv2_plugin_info ());
2555 #ifdef WINDOWS_VST_SUPPORT
2556 refiller (plugs, mgr.windows_vst_plugin_info ());
2558 #ifdef LXVST_SUPPORT
2559 refiller (plugs, mgr.lxvst_plugin_info ());
2561 #ifdef MACVST_SUPPORT
2562 refiller (plugs, mgr.mac_vst_plugin_info ());
2564 #ifdef AUDIOUNIT_SUPPORT
2565 refiller (plugs, mgr.au_plugin_info ());
2567 refiller (plugs, mgr.ladspa_plugin_info ());
2568 refiller (plugs, mgr.lua_plugin_info ());
2570 store_current_favorite_order ();
2572 PluginCustomSorter cmp (favorite_order);
2575 favorite_order = plugs;
2577 sync_treeview_from_favorite_order ();
2581 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2584 if (!(iter = favorite_plugins_model->get_iter (path))) {
2587 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2591 PluginInfoPtr pip = ppp->_pip;
2592 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2593 if (favorite_ui_state[pip->unique_id]) {
2594 favorite_plugins_display.expand_row (path, true);
2600 Mixer_UI::sync_treeview_from_favorite_order ()
2602 favorite_plugins_model->clear ();
2603 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
2604 PluginInfoPtr pip = (*i);
2606 TreeModel::Row newrow = *(favorite_plugins_model->append());
2607 newrow[favorite_plugins_columns.name] = (*i)->name;
2608 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
2613 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
2614 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
2615 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
2616 child_row[favorite_plugins_columns.name] = (*j).label;
2617 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
2619 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2620 if (favorite_ui_state[pip->unique_id]) {
2621 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
2628 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
2630 using namespace Gtk::Menu_Helpers;
2632 Gtk::Menu* m = manage (new Menu);
2633 MenuList& items = m->items ();
2635 if (_selection.axes.empty()) {
2636 items.push_back (MenuElem (_("No Track/Bus is selected.")));
2638 items.push_back (MenuElem (_("Add at the top"),
2639 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
2640 items.push_back (MenuElem (_("Add Pre-Fader"),
2641 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
2642 items.push_back (MenuElem (_("Add Post-Fader"),
2643 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
2644 items.push_back (MenuElem (_("Add at the end"),
2645 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
2648 items.push_back (SeparatorElem());
2650 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
2652 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2653 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
2654 // we cannot currently delete AU presets
2655 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
2656 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
2660 m->popup (ev->button, ev->time);
2664 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
2666 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) {
2667 TreeModel::Path path;
2668 TreeViewColumn* column;
2670 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
2671 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2673 selection->unselect_all();
2674 selection->select(path);
2677 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2679 popup_note_context_menu (ev);
2687 Mixer_UI::selected_plugin ()
2689 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2691 return PluginPresetPtr();
2693 Gtk::TreeModel::iterator iter = selection->get_selected();
2695 return PluginPresetPtr();
2697 return (*iter)[favorite_plugins_columns.plugin];
2701 Mixer_UI::add_selected_processor (ProcessorPosition pos)
2703 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2705 add_favorite_processor (ppp, pos);
2710 Mixer_UI::delete_selected_preset ()
2715 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2716 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
2719 PluginPtr plugin = ppp->_pip->load (*_session);
2720 plugin->get_presets();
2721 plugin->remove_preset (ppp->_preset.label);
2725 Mixer_UI::remove_selected_from_favorites ()
2727 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2731 PluginManager::PluginStatusType status = PluginManager::Normal;
2732 PluginManager& manager (PluginManager::instance());
2734 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2735 manager.save_statuses ();
2739 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
2742 if (!(iter = favorite_plugins_model->get_iter (path))) {
2745 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2746 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
2750 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
2752 if (!_session || _selection.axes.empty()) {
2756 PluginInfoPtr pip = ppp->_pip;
2757 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
2758 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
2764 PluginPtr p = pip->load (*_session);
2770 if (ppp->_preset.valid) {
2771 p->load_preset (ppp->_preset);
2774 Route::ProcessorStreams err;
2775 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2779 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
2782 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
2789 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
2793 if (!np->display_to_user()) {
2796 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
2797 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
2802 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
2806 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
2813 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
2815 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
2819 // only allow to re-order top-level items
2821 if (TreePath::get_from_selection_data (data, src)) {
2822 if (src.up() && src.up()) {
2827 // don't allow to drop as child-rows.
2828 Gtk::TreeModel::Path _dest = dest; // un const
2829 const bool is_child = _dest.up (); // explicit bool for clang
2830 if (!is_child || _dest.empty ()) {
2837 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
2839 if (data.get_target() != "PluginPresetPtr") {
2842 if (data.get_length() != sizeof (PluginPresetPtr)) {
2845 const void *d = data.get_data();
2846 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
2848 PluginManager::PluginStatusType status = PluginManager::Favorite;
2849 PluginManager& manager (PluginManager::instance());
2851 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2852 manager.save_statuses ();
2856 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
2858 /* call protected MixerActor:: method */
2863 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
2865 /* call protected MixerActor:: method */
2870 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
2872 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
2875 show_spill_change (s); /* EMIT SIGNAL */
2877 _group_tabs->hide ();
2879 _group_tabs->show ();
2881 redisplay_track_list ();
2886 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
2888 return s == spilled_strip.lock();
2892 Mixer_UI::register_actions ()
2894 Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
2896 myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
2897 myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
2898 myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
2899 myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
2900 myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
2901 myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
2904 myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
2905 myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
2906 myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
2907 myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
2908 myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
2909 myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
2910 myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
2911 myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
2913 myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
2914 myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
2916 myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
2917 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
2921 Mixer_UI::load_bindings ()
2923 bindings = Bindings::get_bindings (X_("Mixer"), myactions);
2926 template<class T> void
2927 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
2929 boost::shared_ptr<ControlList> cl (new ControlList);
2930 boost::shared_ptr<AutomationControl> ac;
2932 bool have_val = false;
2934 set_axis_targets_for_operation ();
2936 BOOST_FOREACH(AxisView* r, _axis_targets) {
2937 boost::shared_ptr<Stripable> s = r->stripable();
2939 ac = (s.get()->*get_control)();
2943 val = !ac->get_value();
2950 _session->set_controls (cl, val, Controllable::UseGroup);
2954 Mixer_UI::solo_action ()
2956 control_action (&Stripable::solo_control);
2960 Mixer_UI::mute_action ()
2962 control_action (&Stripable::mute_control);
2966 Mixer_UI::rec_enable_action ()
2968 control_action (&Stripable::rec_enable_control);
2972 Mixer_UI::step_gain_up_action ()
2974 set_axis_targets_for_operation ();
2976 BOOST_FOREACH(AxisView* r, _axis_targets) {
2977 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2979 ms->step_gain_up ();
2985 Mixer_UI::step_gain_down_action ()
2987 set_axis_targets_for_operation ();
2989 BOOST_FOREACH(AxisView* r, _axis_targets) {
2990 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
2992 ms->step_gain_down ();
2998 Mixer_UI::unity_gain_action ()
3000 set_axis_targets_for_operation ();
3002 BOOST_FOREACH(AxisView* r, _axis_targets) {
3003 boost::shared_ptr<Stripable> s = r->stripable();
3005 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3007 ac->set_value (1.0, Controllable::UseGroup);
3014 Mixer_UI::copy_processors ()
3016 set_axis_targets_for_operation ();
3018 BOOST_FOREACH(AxisView* r, _axis_targets) {
3019 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3021 ms->copy_processors ();
3026 Mixer_UI::cut_processors ()
3028 set_axis_targets_for_operation ();
3030 BOOST_FOREACH(AxisView* r, _axis_targets) {
3031 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3033 ms->cut_processors ();
3038 Mixer_UI::paste_processors ()
3040 set_axis_targets_for_operation ();
3042 BOOST_FOREACH(AxisView* r, _axis_targets) {
3043 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3045 ms->paste_processors ();
3050 Mixer_UI::select_all_processors ()
3052 set_axis_targets_for_operation ();
3054 BOOST_FOREACH(AxisView* r, _axis_targets) {
3055 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3057 ms->select_all_processors ();
3062 Mixer_UI::toggle_processors ()
3064 set_axis_targets_for_operation ();
3066 BOOST_FOREACH(AxisView* r, _axis_targets) {
3067 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3069 ms->toggle_processors ();
3074 Mixer_UI::ab_plugins ()
3076 set_axis_targets_for_operation ();
3078 BOOST_FOREACH(AxisView* r, _axis_targets) {
3079 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3087 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3089 set_axis_targets_for_operation ();
3091 BOOST_FOREACH(AxisView* r, _axis_targets) {
3092 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3094 ms->vca_assign (vca);
3101 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3103 set_axis_targets_for_operation ();
3105 BOOST_FOREACH(AxisView* r, _axis_targets) {
3106 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3108 ms->vca_unassign (vca);