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 <glibmm/threads.h>
32 #include <gtkmm/accelmap.h>
33 #include <gtkmm/stock.h>
35 #include "pbd/convert.h"
36 #include "pbd/stacktrace.h"
37 #include "pbd/unwind.h"
39 #include "ardour/amp.h"
40 #include "ardour/debug.h"
41 #include "ardour/audio_track.h"
42 #include "ardour/midi_track.h"
43 #include "ardour/plugin_manager.h"
44 #include "ardour/route_group.h"
45 #include "ardour/selection.h"
46 #include "ardour/session.h"
47 #include "ardour/vca.h"
48 #include "ardour/vca_manager.h"
50 #include "gtkmm2ext/gtk_ui.h"
51 #include "gtkmm2ext/keyboard.h"
52 #include "gtkmm2ext/utils.h"
53 #include "gtkmm2ext/window_title.h"
54 #include "gtkmm2ext/doi.h"
56 #include "widgets/tearoff.h"
60 #include "mixer_strip.h"
61 #include "monitor_section.h"
62 #include "plugin_selector.h"
63 #include "public_editor.h"
64 #include "mouse_cursors.h"
65 #include "ardour_ui.h"
67 #include "route_sorter.h"
69 #include "gui_thread.h"
70 #include "mixer_group_tabs.h"
71 #include "route_sorter.h"
73 #include "ui_config.h"
74 #include "vca_master_strip.h"
78 using namespace ARDOUR;
79 using namespace ARDOUR_UI_UTILS;
83 using namespace Gtkmm2ext;
89 Mixer_UI* Mixer_UI::_instance = 0;
95 _instance = new Mixer_UI;
101 Mixer_UI::Mixer_UI ()
102 : Tabbable (_content, _("Mixer"))
103 , no_track_list_redisplay (false)
104 , in_group_row_change (false)
106 , _plugin_selector (0)
107 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
108 , _spill_scroll_position (0)
109 , ignore_reorder (false)
110 , _in_group_rebuild_or_clear (false)
111 , _route_deletion_in_progress (false)
113 , _strip_selection_change_without_scroll (false)
114 , _selection (*this, *this)
118 _content.set_data ("ardour-bindings", bindings);
120 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
122 scroller.set_can_default (true);
123 // set_default (scroller);
125 scroller_base.set_flags (Gtk::CAN_FOCUS);
126 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
127 scroller_base.set_name ("MixerWindow");
128 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
130 /* set up drag-n-drop */
131 vector<TargetEntry> target_table;
132 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
133 scroller_base.drag_dest_set (target_table);
134 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
136 /* create a button to add VCA strips ... will get packed in redisplay_track_list() */
137 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
139 add_vca_button.add (*w);
140 add_vca_button.set_can_focus(false);
141 add_vca_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
143 /* create a button to add mixer strips */
144 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
147 add_button.set_can_focus(false);
148 add_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
150 /* add as last item of strip packer */
151 strip_packer.pack_end (scroller_base, true, true);
152 strip_packer.pack_end (add_button, false, false);
155 /* create a drop-shadow at the end of the mixer strips */
156 mb_shadow.set_size_request( 4, -1 );
157 mb_shadow.set_name("EditorWindow");
159 strip_packer.pack_end (mb_shadow, false, false);
162 _group_tabs = new MixerGroupTabs (this);
163 VBox* b = manage (new VBox);
165 b->set_border_width (0);
166 b->pack_start (*_group_tabs, PACK_SHRINK);
167 b->pack_start (strip_packer);
169 b->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
172 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
174 setup_track_display ();
176 group_model = ListStore::create (group_columns);
177 group_display.set_model (group_model);
178 group_display.append_column (_("Show"), group_columns.visible);
179 group_display.append_column (_("Group"), group_columns.text);
180 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
181 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
182 group_display.get_column (0)->set_expand(false);
183 group_display.get_column (1)->set_expand(true);
184 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
185 group_display.set_name ("EditGroupList");
186 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
187 group_display.set_reorderable (true);
188 group_display.set_headers_visible (true);
189 group_display.set_rules_hint (true);
190 group_display.set_can_focus(false);
192 /* name is directly editable */
194 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
195 name_cell->property_editable() = true;
196 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
198 /* use checkbox for the active column */
200 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
201 active_cell->property_activatable() = true;
202 active_cell->property_radio() = false;
204 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
205 /* We use this to notice drag-and-drop reorders of the group list */
206 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
207 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
209 group_display_scroller.add (group_display);
210 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
213 group_display_vbox.pack_start (group_display_scroller, true, true);
215 group_display_frame.set_name ("BaseFrame");
216 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
217 group_display_frame.add (group_display_vbox);
219 list<TargetEntry> target_list;
220 target_list.push_back (TargetEntry ("PluginPresetPtr"));
222 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
223 favorite_plugins_display.set_model (favorite_plugins_model);
224 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
225 favorite_plugins_display.set_name ("EditGroupList");
226 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
227 favorite_plugins_display.set_reorderable (false);
228 favorite_plugins_display.set_headers_visible (true);
229 favorite_plugins_display.set_rules_hint (true);
230 favorite_plugins_display.set_can_focus (false);
231 favorite_plugins_display.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 if (UIConfiguration::instance().get_use_tooltips()) {
240 favorite_plugins_display.set_tooltip_column (0);
242 favorite_plugins_model->signal_row_has_child_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::sync_treeview_favorite_ui_state));
244 favorite_plugins_scroller.add (favorite_plugins_display);
245 favorite_plugins_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
247 favorite_plugins_frame.set_name ("BaseFrame");
248 favorite_plugins_frame.set_shadow_type (Gtk::SHADOW_IN);
249 favorite_plugins_frame.add (favorite_plugins_vbox);
251 favorite_plugins_vbox.pack_start (favorite_plugins_scroller, true, true);
252 favorite_plugins_vbox.pack_start (favorite_plugins_tag_combo, false, false);
253 favorite_plugins_tag_combo.signal_changed().connect (sigc::mem_fun (*this, &Mixer_UI::tag_combo_changed));
255 rhs_pane1.add (favorite_plugins_frame);
256 rhs_pane1.add (track_display_frame);
258 rhs_pane2.add (rhs_pane1);
259 rhs_pane2.add (group_display_frame);
261 list_vpacker.pack_start (rhs_pane2, true, true);
263 vca_label_bar.set_size_request (-1, 16 + 1); /* must match height in GroupTabs::set_size_request() + 1 border px*/
264 vca_vpacker.pack_start (vca_label_bar, false, false);
266 vca_scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
267 vca_scroller_base.set_name (X_("MixerWindow"));
268 vca_scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::masters_scroller_button_release), false);
270 vca_scroller.add (vca_hpacker);
271 vca_scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
272 vca_scroller.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
274 vca_vpacker.pack_start (vca_scroller, true, true);
276 inner_pane.add (scroller);
277 inner_pane.add (vca_vpacker);
279 global_hpacker.pack_start (inner_pane, true, true);
280 global_hpacker.pack_start (out_packer, false, false);
282 list_hpane.set_check_divider_position (true);
283 list_hpane.add (list_vpacker);
284 list_hpane.add (global_hpacker);
285 list_hpane.set_child_minsize (list_vpacker, 30);
287 XMLNode const * settings = ARDOUR_UI::instance()->mixer_settings();
290 if (!settings || !settings->get_property ("mixer-rhs-pane1-pos", fract) || fract > 1.0) {
293 rhs_pane1.set_divider (0, fract);
295 if (!settings || !settings->get_property ("mixer-rhs-pane2-pos", fract) || fract > 1.0) {
298 rhs_pane2.set_divider (0, fract);
300 if (!settings || !settings->get_property ("mixer-list-hpane-pos", fract) || fract > 1.0) {
303 list_hpane.set_divider (0, fract);
305 if (!settings || !settings->get_property ("mixer-inner-pane-pos", fract) || fract > 1.0) {
308 inner_pane.set_divider (0, fract);
310 rhs_pane1.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
311 rhs_pane2.set_drag_cursor (*PublicEditor::instance().cursors()->expand_up_down);
312 list_hpane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
313 inner_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
315 _content.pack_start (list_hpane, true, true);
320 _content.set_name ("MixerWindow");
322 global_hpacker.show();
324 scroller_base.show();
325 scroller_hpacker.show();
326 mixer_scroller_vpacker.show();
328 group_display_button_label.show();
329 group_display_scroller.show();
330 favorite_plugins_scroller.show();
331 group_display_vbox.show();
332 group_display_frame.show();
333 favorite_plugins_frame.show();
341 vca_label_bar.show();
343 vca_scroller_base.show();
346 group_display.show();
347 favorite_plugins_display.show();
350 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
352 _monitor_section.tearoff().set_state (*mnode);
355 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
356 VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
360 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
362 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
363 _plugin_selector = new PluginSelector (PluginManager::instance ());
365 #error implement deferred Plugin-Favorite list
368 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
369 PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
370 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
373 Mixer_UI::~Mixer_UI ()
375 monitor_section_detached ();
377 delete _plugin_selector;
381 struct MixerStripSorter {
382 bool operator() (const MixerStrip* ms_a, const MixerStrip* ms_b)
384 boost::shared_ptr<ARDOUR::Stripable> const& a = ms_a->stripable ();
385 boost::shared_ptr<ARDOUR::Stripable> const& b = ms_b->stripable ();
386 return ARDOUR::Stripable::Sorter(true)(a, b);
398 Mixer_UI::tag_combo_changed ()
400 refill_favorite_plugins();
404 Mixer_UI::use_own_window (bool and_fill_it)
406 bool new_window = !own_window();
408 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
410 if (win && new_window) {
411 win->set_name ("MixerWindow");
412 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
413 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
414 win->set_data ("ardour-bindings", bindings);
416 if (!win->get_focus()) {
417 /* set focus widget to something, anything */
418 win->set_focus (scroller);
426 Mixer_UI::show_window ()
428 Tabbable::show_window ();
430 /* show/hide group tabs as required */
431 parameter_changed ("show-group-tabs");
433 /* now reset each strips width so the right widgets are shown */
435 TreeModel::Children rows = track_model->children();
436 TreeModel::Children::iterator ri;
438 for (ri = rows.begin(); ri != rows.end(); ++ri) {
439 AxisView* av = (*ri)[stripable_columns.strip];
440 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
444 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
445 /* Fix visibility of mixer strip stuff */
446 ms->parameter_changed (X_("mixer-element-visibility"));
449 /* force focus into main area */
450 scroller_base.grab_focus ();
454 Mixer_UI::remove_master (VCAMasterStrip* vms)
456 if (_session && _session->deletion_in_progress()) {
457 /* its all being taken care of */
461 TreeModel::Children rows = track_model->children();
462 TreeModel::Children::iterator ri;
464 for (ri = rows.begin(); ri != rows.end(); ++ri) {
465 if ((*ri)[stripable_columns.strip] == vms) {
466 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
467 track_model->erase (ri);
474 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
476 using namespace Menu_Helpers;
478 if (Keyboard::is_context_menu_event (ev)) {
479 ARDOUR_UI::instance()->add_route ();
487 Mixer_UI::add_masters (VCAList& vlist)
491 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
492 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
499 Mixer_UI::add_routes (RouteList& rlist)
503 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
511 Mixer_UI::add_stripables (StripableList& slist)
513 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
514 bool from_scratch = (track_model->children().size() == 0);
515 uint32_t nroutes = 0;
517 slist.sort (Stripable::Sorter());
519 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
520 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
528 // XXX what does this special case do?
529 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
538 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
540 track_display.set_model (Glib::RefPtr<ListStore>());
542 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
544 boost::shared_ptr<Route> route;
545 boost::shared_ptr<VCA> vca;
547 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
549 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
551 TreeModel::Row row = *(track_model->append());
553 row[stripable_columns.text] = vca->name();
554 row[stripable_columns.visible] = vms->marked_for_display ();
555 row[stripable_columns.strip] = vms;
556 row[stripable_columns.stripable] = vca;
558 vms->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::vca_button_release_event), vms));
560 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
562 if (route->is_auditioner()) {
566 if (route->is_monitor()) {
568 out_packer.pack_end (_monitor_section.tearoff(), false, false);
569 _monitor_section.set_session (_session);
570 _monitor_section.tearoff().show_all ();
572 _monitor_section.tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
573 _monitor_section.tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
575 if (_monitor_section.tearoff().torn_off()) {
576 monitor_section_detached ();
578 monitor_section_attached ();
581 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
583 /* no regular strip shown for control out */
588 strip = new MixerStrip (*this, _session, route);
589 strips.push_back (strip);
591 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
593 if (strip->width_owner() != strip) {
594 strip->set_width_enum (_strip_width, this);
599 if (route->is_master()) {
601 out_packer.pack_start (*strip, false, false);
602 strip->set_packed (true);
606 TreeModel::Row row = *(track_model->insert (insert_iter));
608 row[stripable_columns.text] = route->name();
609 row[stripable_columns.visible] = strip->marked_for_display();
610 row[stripable_columns.stripable] = route;
611 row[stripable_columns.strip] = strip;
614 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
615 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
618 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
619 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
622 } catch (const std::exception& e) {
623 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
626 track_display.set_model (track_model);
628 /* catch up on selection state, which we left to the editor to set */
629 sync_treeview_from_presentation_info (PropertyChange (Properties::selected));
632 sync_presentation_info_from_treeview ();
635 redisplay_track_list ();
639 Mixer_UI::deselect_all_strip_processors ()
641 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
642 (*i)->deselect_all_processors();
647 Mixer_UI::select_none ()
649 _selection.clear_routes();
650 deselect_all_strip_processors();
654 Mixer_UI::select_next_strip ()
656 deselect_all_strip_processors();
657 _session->selection().select_next_stripable (true, false);
661 Mixer_UI::select_prev_strip ()
663 deselect_all_strip_processors();
664 _session->selection().select_prev_stripable (true, false);
668 Mixer_UI::delete_processors ()
670 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
671 (*i)->delete_processors();
677 Mixer_UI::remove_strip (MixerStrip* strip)
679 if (_session && _session->deletion_in_progress()) {
680 /* its all being taken care of */
684 TreeModel::Children rows = track_model->children();
685 TreeModel::Children::iterator ri;
686 list<MixerStrip *>::iterator i;
688 if ((i = find (strips.begin(), strips.end(), strip)) != strips.end()) {
692 PBD::Unwinder<bool> uwi (ignore_reorder, true);
694 for (ri = rows.begin(); ri != rows.end(); ++ri) {
695 if ((*ri)[stripable_columns.strip] == strip) {
696 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
697 track_model->erase (ri);
704 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
706 if (what_changed.contains (Properties::selected)) {
707 _selection.presentation_info_changed (what_changed);
711 soh.add (Properties::selected);
712 soh.add (Properties::order);
713 soh.add (Properties::hidden);
715 if (what_changed.contains (soh)) {
716 sync_treeview_from_presentation_info (what_changed);
721 Mixer_UI::sync_presentation_info_from_treeview ()
723 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
727 TreeModel::Children rows = track_model->children();
733 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
735 TreeModel::Children::iterator ri;
738 PresentationInfo::order_t master_key = _session->master_order_key ();
739 PresentationInfo::order_t order = 0;
741 PresentationInfo::ChangeSuspender cs;
743 for (ri = rows.begin(); ri != rows.end(); ++ri) {
744 bool visible = (*ri)[stripable_columns.visible];
745 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
747 #ifndef NDEBUG // these should not exist in the mixer's treeview
752 if (stripable->is_monitor() || stripable->is_auditioner()) {
756 if (stripable->is_master()) {
762 stripable->presentation_info().set_hidden (!visible);
764 // leave master where it is.
765 if (order == master_key) {
769 if (order != stripable->presentation_info().order()) {
770 stripable->set_presentation_order (order);
776 change |= _session->ensure_stripable_sort_order ();
779 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
780 _session->set_dirty();
785 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
787 if (!_session || _session->deletion_in_progress()) {
791 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
793 /* we could get here after either a change in the Mixer or Editor sort
794 * order, but either way, the mixer order keys reflect the intended
795 * order for the GUI, so reorder the treeview model to match it.
798 vector<int> neworder;
799 TreeModel::Children rows = track_model->children();
800 uint32_t old_order = 0;
801 bool changed = false;
807 TreeOrderKeys sorted;
808 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
809 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
810 sorted.push_back (TreeOrderKey (old_order, stripable));
813 TreeOrderKeySorter cmp;
815 sort (sorted.begin(), sorted.end(), cmp);
816 neworder.assign (sorted.size(), 0);
820 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
822 neworder[n] = sr->old_display_order;
824 if (sr->old_display_order != n) {
830 Unwinder<bool> uw (ignore_reorder, true);
831 track_model->reorder (neworder);
834 if (what_changed.contains (Properties::selected)) {
836 PresentationInfo::ChangeSuspender cs;
838 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
839 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
840 if (stripable && stripable->is_selected()) {
843 _selection.remove (*i);
847 if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) {
848 move_stripable_into_view ((*_selection.axes.begin())->stripable());
851 TreeModel::Children rows = track_model->children();
852 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
853 AxisView* av = (*i)[stripable_columns.strip];
854 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
858 if (vms->vca() && vms->vca()->is_selected()) {
859 _selection.add (vms);
861 _selection.remove (vms);
866 redisplay_track_list ();
871 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
873 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
874 if ((*i)->route() == r) {
883 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
885 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
886 if ((*i)->stripable() == s) {
895 Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
897 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
898 if ((*i)->stripable() == s) {
903 TreeModel::Children rows = track_model->children();
904 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
905 AxisView* av = (*i)[stripable_columns.strip];
906 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
907 if (vms && vms->stripable () == s) {
916 Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
918 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
919 if ((*i)->control() == c) {
928 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
930 /* Selecting a mixer-strip may also select grouped-tracks, and
931 * presentation_info_changed() being emitted and
932 * _selection.axes.begin() is being moved into view. This may
933 * effectively move the track that was clicked-on out of view.
935 * So here only the track that is actually clicked-on is moved into
936 * view (in case it's partially visible)
938 PBD::Unwinder<bool> uw (_strip_selection_change_without_scroll, true);
939 move_stripable_into_view (strip->stripable());
941 if (ev->button == 1) {
942 if (_selection.selected (strip)) {
943 /* primary-click: toggle selection state of strip */
944 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
945 _selection.remove (strip, true);
946 } else if (_selection.axes.size() > 1) {
947 /* de-select others */
948 _selection.set (strip);
950 PublicEditor& pe = PublicEditor::instance();
951 TimeAxisView* tav = pe.time_axis_view_from_stripable (strip->stripable());
953 pe.set_selected_mixer_strip (*tav);
956 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
957 _selection.add (strip, true);
958 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
960 /* extend selection */
962 vector<MixerStrip*> tmp;
963 bool accumulate = false;
964 bool found_another = false;
966 strips.sort (MixerStripSorter());
968 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
973 /* hit clicked strip, start accumulating till we hit the first
982 } else if (_selection.selected (ms)) {
983 /* hit selected strip. if currently accumulating others,
984 we're done. if not accumulating others, start doing so.
986 found_another = true;
1000 tmp.push_back (strip);
1002 if (found_another) {
1003 PresentationInfo::ChangeSuspender cs;
1004 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
1005 _selection.add (*i, true);
1008 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
1011 _selection.set (strip);
1020 Mixer_UI::vca_button_release_event (GdkEventButton *ev, VCAMasterStrip *strip)
1022 _selection.set (strip);
1027 Mixer_UI::set_session (Session* sess)
1029 SessionHandlePtr::set_session (sess);
1030 _monitor_section.set_session (sess);
1032 if (_plugin_selector) {
1033 _plugin_selector->set_session (_session);
1036 _group_tabs->set_session (sess);
1039 _selection.clear ();
1043 refill_favorite_plugins();
1046 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1047 set_state (*node, 0);
1051 initial_track_display ();
1053 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1054 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1055 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1056 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1057 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1058 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1059 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1061 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1063 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1065 route_groups_changed ();
1071 /* catch up on selection state, etc. */
1074 sc.add (Properties::selected);
1075 _selection.presentation_info_changed (sc);
1081 Mixer_UI::session_going_away ()
1083 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1085 _in_group_rebuild_or_clear = true;
1086 group_model->clear ();
1087 _in_group_rebuild_or_clear = false;
1089 _selection.clear ();
1090 track_model->clear ();
1092 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1096 _monitor_section.tearoff().hide_visible ();
1098 monitor_section_detached ();
1104 SessionHandlePtr::session_going_away ();
1111 Mixer_UI::track_visibility_changed (std::string const & path)
1113 if (_session && _session->deletion_in_progress()) {
1119 if ((iter = track_model->get_iter (path))) {
1121 AxisView* av = (*iter)[stripable_columns.strip];
1122 bool visible = (*iter)[stripable_columns.visible];
1124 if (av->set_marked_for_display (!visible)) {
1125 update_track_visibility ();
1131 Mixer_UI::update_track_visibility ()
1133 TreeModel::Children rows = track_model->children();
1134 TreeModel::Children::iterator i;
1137 Unwinder<bool> uw (no_track_list_redisplay, true);
1139 for (i = rows.begin(); i != rows.end(); ++i) {
1140 AxisView* av = (*i)[stripable_columns.strip];
1141 (*i)[stripable_columns.visible] = av->marked_for_display ();
1144 /* force presentation catch up with visibility changes
1147 sync_presentation_info_from_treeview ();
1150 redisplay_track_list ();
1154 Mixer_UI::show_strip (MixerStrip* ms)
1156 TreeModel::Children rows = track_model->children();
1157 TreeModel::Children::iterator i;
1159 for (i = rows.begin(); i != rows.end(); ++i) {
1161 AxisView* av = (*i)[stripable_columns.strip];
1162 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1164 (*i)[stripable_columns.visible] = true;
1165 av->set_marked_for_display (true);
1166 update_track_visibility ();
1173 Mixer_UI::hide_strip (MixerStrip* ms)
1175 TreeModel::Children rows = track_model->children();
1176 TreeModel::Children::iterator i;
1178 for (i = rows.begin(); i != rows.end(); ++i) {
1180 AxisView* av = (*i)[stripable_columns.strip];
1181 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1183 (*i)[stripable_columns.visible] = false;
1184 av->set_marked_for_display (false);
1185 update_track_visibility ();
1192 Mixer_UI::start_updating ()
1194 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1199 Mixer_UI::stop_updating ()
1201 fast_screen_update_connection.disconnect();
1206 Mixer_UI::fast_update_strips ()
1208 if (_content.is_mapped () && _session) {
1209 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1210 (*i)->fast_update ();
1216 Mixer_UI::set_all_strips_visibility (bool yn)
1218 TreeModel::Children rows = track_model->children();
1219 TreeModel::Children::iterator i;
1222 Unwinder<bool> uw (no_track_list_redisplay, true);
1224 for (i = rows.begin(); i != rows.end(); ++i) {
1226 AxisView* av = (*i)[stripable_columns.strip];
1227 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1233 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1237 (*i)[stripable_columns.visible] = yn;
1241 redisplay_track_list ();
1246 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1248 TreeModel::Children rows = track_model->children();
1249 TreeModel::Children::iterator i;
1252 Unwinder<bool> uw (no_track_list_redisplay, true);
1254 for (i = rows.begin(); i != rows.end(); ++i) {
1256 AxisView* av = (*i)[stripable_columns.strip];
1257 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1263 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1267 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1268 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1272 (*i)[stripable_columns.visible] = yn;
1276 if (at) { /* track */
1277 (*i)[stripable_columns.visible] = yn;
1282 if (!at && !mt) { /* bus */
1283 (*i)[stripable_columns.visible] = yn;
1288 if (mt) { /* midi-track */
1289 (*i)[stripable_columns.visible] = yn;
1296 redisplay_track_list ();
1300 Mixer_UI::hide_all_routes ()
1302 set_all_strips_visibility (false);
1306 Mixer_UI::show_all_routes ()
1308 set_all_strips_visibility (true);
1312 Mixer_UI::show_all_audiobus ()
1314 set_all_audio_midi_visibility (2, true);
1317 Mixer_UI::hide_all_audiobus ()
1319 set_all_audio_midi_visibility (2, false);
1323 Mixer_UI::show_all_audiotracks()
1325 set_all_audio_midi_visibility (1, true);
1328 Mixer_UI::hide_all_audiotracks ()
1330 set_all_audio_midi_visibility (1, false);
1334 Mixer_UI::show_all_miditracks()
1336 set_all_audio_midi_visibility (3, true);
1339 Mixer_UI::hide_all_miditracks ()
1341 set_all_audio_midi_visibility (3, false);
1345 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1347 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1348 sync_presentation_info_from_treeview ();
1352 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1354 /* this happens as the second step of a DnD within the treeview as well
1355 as when a row/route is actually deleted.
1357 if it was a deletion then we have to force a redisplay because
1358 order keys may not have changed.
1361 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1362 sync_presentation_info_from_treeview ();
1364 if (_route_deletion_in_progress) {
1365 redisplay_track_list ();
1370 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1372 TreeModel::Children rows = track_model->children();
1373 std::list<boost::shared_ptr<VCA> > vcas;
1374 vcas.push_back (vca);
1376 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1377 AxisView* av = (*i)[stripable_columns.strip];
1378 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1379 if (vms && vms->vca()->slaved_to (vca)) {
1380 vcas.push_back (vms->vca());
1384 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1386 AxisView* av = (*i)[stripable_columns.strip];
1387 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1388 bool const visible = (*i)[stripable_columns.visible];
1391 /* we're in the middle of changing a row, don't worry */
1395 if (!strip->route()) {
1396 /* non-route element */
1400 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1404 bool slaved = false;
1405 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1406 if (strip->route()->slaved_to (*m)) {
1412 if (slaved && visible) {
1414 if (strip->packed()) {
1415 strip_packer.reorder_child (*strip, -1); /* put at end */
1417 strip_packer.pack_start (*strip, false, false);
1418 strip->set_packed (true);
1423 if (strip->packed()) {
1424 strip_packer.remove (*strip);
1425 strip->set_packed (false);
1432 Mixer_UI::redisplay_track_list ()
1434 if (no_track_list_redisplay) {
1438 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1440 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1442 if (_spill_scroll_position <= 0 && scroller.get_hscrollbar()) {
1443 _spill_scroll_position = scroller.get_hscrollbar()->get_adjustment()->get_value();
1445 spill_redisplay (sv);
1450 TreeModel::Children rows = track_model->children();
1451 TreeModel::Children::iterator i;
1452 uint32_t n_masters = 0;
1454 container_clear (vca_hpacker);
1456 vca_hpacker.pack_end (vca_scroller_base, true, true);
1457 vca_hpacker.pack_end (add_vca_button, false, false);
1459 add_vca_button.show ();
1460 vca_scroller_base.show();
1462 for (i = rows.begin(); i != rows.end(); ++i) {
1464 AxisView* s = (*i)[stripable_columns.strip];
1465 bool const visible = (*i)[stripable_columns.visible];
1466 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1469 /* we're in the middle of changing a row, don't worry */
1473 VCAMasterStrip* vms;
1475 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1477 vca_hpacker.pack_start (*vms, false, false);
1484 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1492 if (strip->packed()) {
1493 strip_packer.reorder_child (*strip, -1); /* put at end */
1495 strip_packer.pack_start (*strip, false, false);
1496 strip->set_packed (true);
1501 if (stripable->is_master() || stripable->is_monitor()) {
1502 /* do nothing, these cannot be hidden */
1504 if (strip->packed()) {
1505 strip_packer.remove (*strip);
1506 strip->set_packed (false);
1512 /* update visibility of VCA assign buttons */
1514 if (n_masters == 0) {
1515 //show/hide the channelstrip VCA assign buttons on channelstrips:
1516 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1518 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleVCAPane");
1520 act->set_sensitive (false);
1523 //remove the VCA packer, but don't change our prior setting for show/hide:
1524 vca_vpacker.hide ();
1526 //show/hide the channelstrip VCA assign buttons on channelstrips:
1527 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1529 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
1530 act->set_sensitive (true);
1532 //if we were showing VCAs before, show them now:
1533 showhide_vcas (act->get_active ());
1536 _group_tabs->set_dirty ();
1538 if (_spill_scroll_position > 0 && scroller.get_hscrollbar()) {
1539 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1540 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), _spill_scroll_position)));
1542 _spill_scroll_position = 0;
1547 Mixer_UI::strip_width_changed ()
1549 _group_tabs->set_dirty ();
1552 TreeModel::Children rows = track_model->children();
1553 TreeModel::Children::iterator i;
1556 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1557 AxisView* av = (*i)[stripable_columns.strip];
1558 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1564 bool visible = (*i)[stripable_columns.visible];
1567 strip->queue_draw();
1574 struct PresentationInfoMixerSorter
1576 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1577 if (a->is_master()) {
1578 /* master after everything else */
1580 } else if (b->is_master()) {
1581 /* everything else before master */
1584 return a->presentation_info().order () < b->presentation_info().order ();
1589 Mixer_UI::initial_track_display ()
1592 _session->get_stripables (sl);
1594 sl.sort (PresentationInfoMixerSorter());
1597 /* These are also used inside ::add_stripables() but we need
1598 * them here because we're going to clear the track_model also.
1600 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1601 Unwinder<bool> uw2 (ignore_reorder, true);
1603 track_model->clear ();
1604 add_stripables (sl);
1607 sync_treeview_from_presentation_info (Properties::order);
1611 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1613 if (Keyboard::is_context_menu_event (ev)) {
1614 if (track_menu == 0) {
1615 build_track_menu ();
1617 track_menu->popup (ev->button, ev->time);
1620 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1621 TreeModel::Path path;
1622 TreeViewColumn* column;
1624 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1625 TreeIter iter = track_model->get_iter (path);
1626 if ((*iter)[stripable_columns.visible]) {
1627 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1628 move_stripable_into_view (s);
1637 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1639 if (!scroller.get_hscrollbar()) {
1642 if (s->presentation_info().special () || s->presentation_info().flag_match (PresentationInfo::VCA)) {
1652 Gtk::Allocation alloc;
1653 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1654 if ((*i)->route() == s) {
1657 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1658 alloc = (*i)->get_allocation ();
1666 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1668 if (x0 < adj->get_value()) {
1669 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1670 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1671 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1672 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1677 Mixer_UI::build_track_menu ()
1679 using namespace Menu_Helpers;
1680 using namespace Gtk;
1682 track_menu = new Menu;
1683 track_menu->set_name ("ArdourContextMenu");
1684 MenuList& items = track_menu->items();
1686 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1687 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1688 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1689 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1690 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1691 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1692 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1693 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1698 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1700 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1704 boost::shared_ptr<Stripable> s = ws.lock ();
1710 TreeModel::Children rows = track_model->children();
1711 TreeModel::Children::iterator i;
1713 for (i = rows.begin(); i != rows.end(); ++i) {
1714 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1718 if (what_changed.contains (ARDOUR::Properties::name)) {
1719 (*i)[stripable_columns.text] = s->name();
1722 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1723 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1724 redisplay_track_list ();
1731 if (s->is_master ()) {
1735 error << _("track display list item for renamed strip not found!") << endmsg;
1739 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1741 TreeModel::Path path;
1742 TreeViewColumn* column;
1746 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1747 if (ev->button == 3) {
1748 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1753 TreeIter iter = group_model->get_iter (path);
1755 if (ev->button == 3) {
1756 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1761 RouteGroup* group = (*iter)[group_columns.group];
1763 if (Keyboard::is_context_menu_event (ev)) {
1764 _group_tabs->get_menu(group)->popup (1, ev->time);
1768 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1770 if (Keyboard::is_edit_event (ev)) {
1772 // edit_route_group (group);
1774 group_display.queue_draw();
1783 bool visible = (*iter)[group_columns.visible];
1784 (*iter)[group_columns.visible] = !visible;
1786 group_display.queue_draw();
1799 Mixer_UI::activate_all_route_groups ()
1801 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1805 Mixer_UI::disable_all_route_groups ()
1807 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1811 Mixer_UI::route_groups_changed ()
1813 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1815 _in_group_rebuild_or_clear = true;
1817 /* just rebuild the while thing */
1819 group_model->clear ();
1822 /* this is currently not used,
1823 * Mixer_UI::group_display_button_press() has a case for it,
1824 * and a commented edit_route_group() but that's n/a since 2011.
1826 * This code is left as reminder that
1827 * row[group_columns.group] = 0 has special meaning.
1831 row = *(group_model->append());
1832 row[group_columns.visible] = true;
1833 row[group_columns.text] = (_("-all-"));
1834 row[group_columns.group] = 0;
1838 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1840 _group_tabs->set_dirty ();
1841 _in_group_rebuild_or_clear = false;
1845 Mixer_UI::new_route_group ()
1847 _group_tabs->run_new_group_dialog (0, false);
1851 Mixer_UI::remove_selected_route_group ()
1853 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1854 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1860 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1863 /* selection mode is single, so rows.begin() is it */
1865 if ((iter = group_model->get_iter (*i))) {
1867 RouteGroup* rg = (*iter)[group_columns.group];
1870 _session->remove_route_group (*rg);
1876 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1878 if (in_group_row_change) {
1882 /* force an update of any mixer strips that are using this group,
1883 otherwise mix group names don't change in mixer strips
1886 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1887 if ((*i)->route_group() == group) {
1888 (*i)->route_group_changed();
1892 TreeModel::iterator i;
1893 TreeModel::Children rows = group_model->children();
1894 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1896 in_group_row_change = true;
1898 for (i = rows.begin(); i != rows.end(); ++i) {
1899 if ((*i)[group_columns.group] == group) {
1900 (*i)[group_columns.visible] = !group->is_hidden ();
1901 (*i)[group_columns.text] = group->name ();
1906 in_group_row_change = false;
1908 if (change.contains (Properties::name)) {
1909 _group_tabs->set_dirty ();
1912 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
1913 if ((*j)->route_group() == group) {
1914 if (group->is_hidden ()) {
1924 Mixer_UI::toggle_mixer_list ()
1926 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
1927 showhide_mixer_list (act->get_active());
1931 Mixer_UI::showhide_mixer_list (bool yn)
1934 list_vpacker.show ();
1936 list_vpacker.hide ();
1941 Mixer_UI::toggle_monitor_section ()
1943 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
1944 showhide_monitor_section (act->get_active());
1949 Mixer_UI::showhide_monitor_section (bool yn)
1951 if (monitor_section().tearoff().torn_off()) {
1956 monitor_section().tearoff().show();
1958 monitor_section().tearoff().hide();
1963 Mixer_UI::toggle_vcas ()
1965 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
1966 showhide_vcas (act->get_active());
1970 Mixer_UI::showhide_vcas (bool yn)
1981 Mixer_UI::toggle_mixbuses ()
1983 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
1984 showhide_mixbuses (act->get_active());
1988 Mixer_UI::showhide_mixbuses (bool on)
2000 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
2005 if ((iter = group_model->get_iter (path))) {
2007 if ((group = (*iter)[group_columns.group]) == 0) {
2011 if (new_text != group->name()) {
2012 group->set_name (new_text);
2018 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
2022 if (in_group_row_change) {
2026 if ((group = (*iter)[group_columns.group]) == 0) {
2030 std::string name = (*iter)[group_columns.text];
2032 if (name != group->name()) {
2033 group->set_name (name);
2036 bool hidden = !(*iter)[group_columns.visible];
2038 if (hidden != group->is_hidden ()) {
2039 group->set_hidden (hidden, this);
2043 /** Called when a group model row is deleted, but also when the model is
2044 * reordered by a user drag-and-drop; the latter is what we are
2045 * interested in here.
2048 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
2050 if (_in_group_rebuild_or_clear) {
2054 /* Re-write the session's route group list so that the new order is preserved */
2056 list<RouteGroup*> new_list;
2058 Gtk::TreeModel::Children children = group_model->children();
2059 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
2060 RouteGroup* g = (*i)[group_columns.group];
2062 new_list.push_back (g);
2066 _session->reorder_route_groups (new_list);
2071 Mixer_UI::add_route_group (RouteGroup* group)
2073 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
2076 in_group_row_change = true;
2078 TreeModel::Row row = *(group_model->append());
2079 row[group_columns.visible] = !group->is_hidden ();
2080 row[group_columns.group] = group;
2081 if (!group->name().empty()) {
2082 row[group_columns.text] = group->name();
2084 row[group_columns.text] = _("unnamed");
2088 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
2091 TreeViewColumn* col = group_display.get_column (0);
2092 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
2093 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
2096 _group_tabs->set_dirty ();
2098 in_group_row_change = false;
2102 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
2104 using namespace Menu_Helpers;
2106 if (Keyboard::is_context_menu_event (ev)) {
2107 ARDOUR_UI::instance()->add_route ();
2115 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
2117 if (data.get_target() != "PluginFavoritePtr") {
2118 context->drag_finish (false, false, time);
2122 const void * d = data.get_data();
2123 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2125 PluginPresetList nfos;
2127 tv->get_object_drag_data (nfos, &source);
2129 Route::ProcessorList pl;
2132 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2133 PluginPresetPtr ppp = (*i);
2134 PluginInfoPtr pip = ppp->_pip;
2135 if (!pip->is_instrument ()) {
2138 ARDOUR_UI::instance()->session_add_midi_route (true, (RouteGroup*) 0, 1, _("MIDI"), Config->get_strict_io (), pip, ppp->_preset.valid ? &ppp->_preset : 0, PresentationInfo::max_order);
2142 context->drag_finish (ok, false, time);
2146 Mixer_UI::set_strip_width (Width w, bool save)
2150 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2151 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2156 struct PluginStateSorter {
2158 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2159 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2160 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2161 if (aiter != _user.end() && biter != _user.end()) {
2162 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2164 if (aiter != _user.end()) {
2167 if (biter != _user.end()) {
2170 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2173 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2175 std::list<std::string> _user;
2179 Mixer_UI::set_state (const XMLNode& node, int version)
2183 Tabbable::set_state (node, version);
2185 if (node.get_property ("narrow-strips", yn)) {
2187 set_strip_width (Narrow);
2189 set_strip_width (Wide);
2193 node.get_property ("show-mixer", _visible);
2195 if (node.get_property ("maximised", yn)) {
2196 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Common"), X_("ToggleMaximalMixer"));
2197 bool fs = act && act->get_active();
2199 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2203 if (node.get_property ("show-mixer-list", yn)) {
2204 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixerList"));
2206 /* do it twice to force the change */
2207 act->set_active (!yn);
2208 act->set_active (yn);
2211 if (node.get_property ("monitor-section-visible", yn)) {
2212 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection"));
2213 /* do it twice to force the change */
2214 act->set_active (!yn);
2215 act->set_active (yn);
2218 if (node.get_property ("show-vca-pane", yn)) {
2219 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleVCAPane"));
2220 /* do it twice to force the change */
2221 act->set_active (!yn);
2222 act->set_active (yn);
2226 if (node.get_property ("show-mixbus-pane", yn)) {
2227 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMixbusPane"));
2228 /* do it twice to force the change */
2229 act->set_active (!yn);
2230 act->set_active (yn);
2235 //check for the user's plugin_order file
2236 XMLNode plugin_order_new(X_("PO"));
2237 if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) {
2238 store_current_favorite_order ();
2239 std::list<string> order;
2240 const XMLNodeList& kids = plugin_order_new.children("PluginInfo");
2241 XMLNodeConstIterator i;
2242 for (i = kids.begin(); i != kids.end(); ++i) {
2243 std::string unique_id;
2244 if ((*i)->get_property ("unique-id", unique_id)) {
2245 order.push_back (unique_id);
2246 if ((*i)->get_property ("expanded", yn)) {
2247 favorite_ui_state[unique_id] = yn;
2251 PluginStateSorter cmp (order);
2252 favorite_order.sort (cmp);
2253 sync_treeview_from_favorite_order ();
2256 //if there is no user file, then use an existing one from instant.xml
2257 //NOTE: if you are loading an old session, this might come from the session's instant.xml
2258 //Todo: in the next major version, we should probably stop doing the instant.xml check, and just use the new file
2259 XMLNode* plugin_order;
2260 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2261 store_current_favorite_order ();
2262 std::list<string> order;
2263 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2264 XMLNodeConstIterator i;
2265 for (i = kids.begin(); i != kids.end(); ++i) {
2266 std::string unique_id;
2267 if ((*i)->get_property ("unique-id", unique_id)) {
2268 order.push_back (unique_id);
2269 if ((*i)->get_property ("expanded", yn)) {
2270 favorite_ui_state[unique_id] = yn;
2275 PluginStateSorter cmp (order);
2276 favorite_order.sort (cmp);
2277 sync_treeview_from_favorite_order ();
2285 Mixer_UI::save_plugin_order_file ()
2287 //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order )
2289 //NOTE: this replaces the old code that stores info in instant.xml
2290 //why? because instant.xml prefers the per-session settings, and we want this to be a global pref
2292 store_current_favorite_order ();
2293 XMLNode plugin_order ("PluginOrder");
2295 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2296 XMLNode* p = new XMLNode ("PluginInfo");
2297 p->set_property ("sort", cnt);
2298 p->set_property ("unique-id", (*i)->unique_id);
2299 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2300 p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2302 plugin_order.add_child_nocopy (*p);
2304 PluginManager::instance().save_plugin_order_file( plugin_order );
2308 Mixer_UI::get_state ()
2310 XMLNode* node = new XMLNode (X_("Mixer"));
2312 node->add_child_nocopy (Tabbable::get_state());
2314 node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider());
2315 node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider());
2316 node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider());
2317 node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider());
2319 node->set_property ("narrow-strips", (_strip_width == Narrow));
2320 node->set_property ("show-mixer", _visible);
2321 node->set_property ("maximised", _maximised);
2323 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMixerList");
2324 node->set_property ("show-mixer-list", act->get_active ());
2326 act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2327 node->set_property ("monitor-section-visible", act->get_active ());
2329 act = ActionManager::get_toggle_action ("Mixer", "ToggleVCAPane");
2330 node->set_property ("show-vca-pane", act->get_active ());
2333 act = ActionManager::get_toggle_action ("Mixer", "ToggleMixbusPane");
2334 node->set_property ("show-mixbus-pane", act->get_active ());
2341 Mixer_UI::scroll_left ()
2343 if (!scroller.get_hscrollbar()) return;
2344 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2345 int sc_w = scroller.get_width();
2346 int sp_w = strip_packer.get_width();
2350 int lp = adj->get_value();
2352 using namespace Gtk::Box_Helpers;
2353 const BoxList& strips = strip_packer.children();
2354 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2355 if (i->get_widget() == & add_button) {
2359 if (i->get_widget() == &mb_shadow) {
2363 lm += i->get_widget()->get_width ();
2365 lm -= i->get_widget()->get_width ();
2369 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2373 Mixer_UI::scroll_right ()
2375 if (!scroller.get_hscrollbar()) return;
2376 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2377 int sc_w = scroller.get_width();
2378 int sp_w = strip_packer.get_width();
2382 int lp = adj->get_value();
2384 using namespace Gtk::Box_Helpers;
2385 const BoxList& strips = strip_packer.children();
2386 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2387 if (i->get_widget() == & add_button) {
2391 if (i->get_widget() == &mb_shadow) {
2395 lm += i->get_widget()->get_width ();
2400 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2404 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2406 switch (ev->direction) {
2407 case GDK_SCROLL_LEFT:
2411 if (ev->state & Keyboard::TertiaryModifier) {
2417 case GDK_SCROLL_RIGHT:
2421 case GDK_SCROLL_DOWN:
2422 if (ev->state & Keyboard::TertiaryModifier) {
2434 Mixer_UI::parameter_changed (string const & p)
2436 if (p == "show-group-tabs") {
2437 bool const s = _session->config.get_show_group_tabs ();
2439 _group_tabs->show ();
2441 _group_tabs->hide ();
2443 } else if (p == "default-narrow_ms") {
2444 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2445 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2446 (*i)->set_width_enum (s ? Narrow : Wide, this);
2452 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2454 g->set_active (a, this);
2458 Mixer_UI::plugin_selector()
2460 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2461 if (!_plugin_selector)
2462 _plugin_selector = new PluginSelector (PluginManager::instance());
2465 return _plugin_selector;
2469 Mixer_UI::setup_track_display ()
2471 track_model = ListStore::create (stripable_columns);
2472 track_display.set_model (track_model);
2473 track_display.append_column (_("Show"), stripable_columns.visible);
2474 track_display.append_column (_("Strips"), stripable_columns.text);
2475 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2476 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2477 track_display.get_column (0)->set_expand(false);
2478 track_display.get_column (1)->set_expand(true);
2479 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2480 track_display.set_name (X_("EditGroupList"));
2481 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2482 track_display.set_reorderable (true);
2483 track_display.set_headers_visible (true);
2484 track_display.set_can_focus(false);
2486 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2487 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2489 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2490 track_list_visible_cell->property_activatable() = true;
2491 track_list_visible_cell->property_radio() = false;
2492 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2494 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2496 track_display_scroller.add (track_display);
2497 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2499 VBox* v = manage (new VBox);
2501 v->pack_start (track_display_scroller, true, true);
2503 track_display_frame.set_name("BaseFrame");
2504 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2505 track_display_frame.add (*v);
2507 track_display_scroller.show();
2508 track_display_frame.show();
2509 track_display.show();
2513 Mixer_UI::new_track_or_bus ()
2515 ARDOUR_UI::instance()->add_route ();
2519 Mixer_UI::update_title ()
2521 if (!own_window()) {
2528 if (_session->snap_name() != _session->name()) {
2529 n = _session->snap_name ();
2531 n = _session->name ();
2534 if (_session->dirty ()) {
2538 WindowTitle title (n);
2539 title += S_("Window|Mixer");
2540 title += Glib::get_application_name ();
2541 own_window()->set_title (title.get_string());
2545 WindowTitle title (S_("Window|Mixer"));
2546 title += Glib::get_application_name ();
2547 own_window()->set_title (title.get_string());
2552 Mixer_UI::strip_by_x (int x)
2554 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2557 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2558 x2 = x1 + (*i)->get_width();
2560 if (x >= x1 && x <= x2) {
2569 Mixer_UI::set_axis_targets_for_operation ()
2571 _axis_targets.clear ();
2573 if (!_selection.empty()) {
2574 _axis_targets = _selection.axes;
2578 // removed "implicit" selections of strips, after discussion on IRC
2583 Mixer_UI::monitor_section_going_away ()
2585 XMLNode* ui_node = Config->extra_xml(X_("UI"));
2587 /* immediate state save.
2589 * Tearoff settings are otherwise only stored during
2590 * save_ardour_state(). The mon-section may or may not
2591 * exist at that point.
2595 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
2597 tearoff_node->remove_nodes_and_delete (X_("monitor-section"));
2598 XMLNode* t = new XMLNode (X_("monitor-section"));
2599 _monitor_section.tearoff().add_state (*t);
2600 tearoff_node->add_child_nocopy (*t);
2604 monitor_section_detached ();
2605 out_packer.remove (_monitor_section.tearoff());
2609 Mixer_UI::toggle_midi_input_active (bool flip_others)
2611 boost::shared_ptr<RouteList> rl (new RouteList);
2614 set_axis_targets_for_operation ();
2616 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2617 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2621 onoff = !mt->input_active();
2625 _session->set_exclusive_input_active (rl, onoff, flip_others);
2629 Mixer_UI::maximise_mixer_space ()
2631 if (!own_window()) {
2639 _window->fullscreen ();
2644 Mixer_UI::restore_mixer_space ()
2646 if (!own_window()) {
2654 own_window()->unfullscreen();
2659 Mixer_UI::monitor_section_attached ()
2661 Glib::RefPtr<ToggleAction> act = ActionManager::get_toggle_action ("Mixer", "ToggleMonitorSection");
2662 act->set_sensitive (true);
2663 showhide_monitor_section (act->get_active ());
2667 Mixer_UI::monitor_section_detached ()
2669 Glib::RefPtr<Action> act = ActionManager::get_action ("Mixer", "ToggleMonitorSection");
2670 act->set_sensitive (false);
2674 Mixer_UI::store_current_favorite_order ()
2676 typedef Gtk::TreeModel::Children type_children;
2677 type_children children = favorite_plugins_model->children();
2678 favorite_order.clear();
2679 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2681 Gtk::TreeModel::Row row = *iter;
2682 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2683 favorite_order.push_back (ppp->_pip);
2684 std::string name = row[favorite_plugins_columns.name];
2685 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2690 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2692 Gtk::TreeModel::Row row = *iter;
2693 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2695 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2699 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2701 PluginManager& manager (PluginManager::instance());
2702 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2704 /* not a Favorite? skip it */
2705 if (manager.get_status (*i) != PluginManager::Favorite) {
2709 /* Check the tag combo selection, and skip this plugin if it doesn't match the selected tag(s) */
2710 string test = favorite_plugins_tag_combo.get_active_text();
2711 if (test != _("Show All")) {
2712 vector<string> tags = manager.get_tags(*i);
2714 //does the selected tag match any of the tags in the plugin?
2715 vector<string>::iterator tt = find (tags.begin(), tags.end(), test);
2716 if (tt == tags.end()) {
2721 result.push_back (*i);
2725 struct PluginCustomSorter {
2727 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2728 PluginInfoList::const_iterator aiter = _user.begin();
2729 PluginInfoList::const_iterator biter = _user.begin();
2730 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2731 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2733 if (aiter != _user.end() && biter != _user.end()) {
2734 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2736 if (aiter != _user.end()) {
2739 if (biter != _user.end()) {
2742 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2744 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2746 PluginInfoList _user;
2750 Mixer_UI::refill_favorite_plugins ()
2752 PluginInfoList plugs;
2753 PluginManager& mgr (PluginManager::instance());
2756 refiller (plugs, mgr.lv2_plugin_info ());
2758 #ifdef WINDOWS_VST_SUPPORT
2759 refiller (plugs, mgr.windows_vst_plugin_info ());
2761 #ifdef LXVST_SUPPORT
2762 refiller (plugs, mgr.lxvst_plugin_info ());
2764 #ifdef MACVST_SUPPORT
2765 refiller (plugs, mgr.mac_vst_plugin_info ());
2767 #ifdef AUDIOUNIT_SUPPORT
2768 refiller (plugs, mgr.au_plugin_info ());
2770 refiller (plugs, mgr.ladspa_plugin_info ());
2771 refiller (plugs, mgr.lua_plugin_info ());
2773 store_current_favorite_order ();
2775 PluginCustomSorter cmp (favorite_order);
2778 favorite_order = plugs;
2780 sync_treeview_from_favorite_order ();
2784 Mixer_UI::plugin_list_changed ()
2786 refill_favorite_plugins();
2791 Mixer_UI::refill_tag_combo ()
2793 PluginManager& mgr (PluginManager::instance());
2795 std::vector<std::string> tags = mgr.get_all_tags (PluginManager::OnlyFavorites);
2797 favorite_plugins_tag_combo.clear();
2798 favorite_plugins_tag_combo.append_text (_("Show All"));
2800 for (vector<string>::iterator t = tags.begin (); t != tags.end (); ++t) {
2801 favorite_plugins_tag_combo.append_text (*t);
2804 favorite_plugins_tag_combo.set_active_text (_("Show All"));
2808 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2811 if (!(iter = favorite_plugins_model->get_iter (path))) {
2814 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2818 PluginInfoPtr pip = ppp->_pip;
2819 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2820 if (favorite_ui_state[pip->unique_id]) {
2821 favorite_plugins_display.expand_row (path, true);
2827 Mixer_UI::sync_treeview_from_favorite_order ()
2829 favorite_plugins_model->clear ();
2830 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
2831 PluginInfoPtr pip = (*i);
2833 TreeModel::Row newrow = *(favorite_plugins_model->append());
2834 newrow[favorite_plugins_columns.name] = (*i)->name;
2835 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
2840 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
2841 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
2845 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
2846 child_row[favorite_plugins_columns.name] = (*j).label;
2847 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
2849 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2850 if (favorite_ui_state[pip->unique_id]) {
2851 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
2858 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
2860 using namespace Gtk::Menu_Helpers;
2862 Gtk::Menu* m = manage (new Menu);
2863 MenuList& items = m->items ();
2865 if (_selection.axes.empty()) {
2866 items.push_back (MenuElem (_("No Track/Bus is selected.")));
2868 items.push_back (MenuElem (_("Add at the top"),
2869 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
2870 items.push_back (MenuElem (_("Add Pre-Fader"),
2871 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
2872 items.push_back (MenuElem (_("Add Post-Fader"),
2873 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
2874 items.push_back (MenuElem (_("Add at the end"),
2875 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
2878 items.push_back (SeparatorElem());
2880 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
2882 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2883 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
2884 // we cannot currently delete AU presets
2885 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
2886 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
2890 m->popup (ev->button, ev->time);
2894 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
2896 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
2897 TreeModel::Path path;
2898 TreeViewColumn* column;
2900 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
2901 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2903 selection->unselect_all();
2904 selection->select(path);
2907 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2909 popup_note_context_menu (ev);
2917 Mixer_UI::selected_plugin ()
2919 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2921 return PluginPresetPtr();
2923 Gtk::TreeModel::iterator iter = selection->get_selected();
2925 return PluginPresetPtr();
2927 return (*iter)[favorite_plugins_columns.plugin];
2931 Mixer_UI::add_selected_processor (ProcessorPosition pos)
2933 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2935 add_favorite_processor (ppp, pos);
2940 Mixer_UI::delete_selected_preset ()
2945 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2946 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
2949 PluginPtr plugin = ppp->_pip->load (*_session);
2950 plugin->get_presets();
2951 plugin->remove_preset (ppp->_preset.label);
2955 Mixer_UI::remove_selected_from_favorites ()
2957 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2961 PluginManager::PluginStatusType status = PluginManager::Normal;
2962 PluginManager& manager (PluginManager::instance());
2964 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2965 manager.save_statuses ();
2969 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
2972 if (!(iter = favorite_plugins_model->get_iter (path))) {
2975 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2976 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
2980 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
2982 if (!_session || _selection.axes.empty()) {
2986 PluginInfoPtr pip = ppp->_pip;
2987 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
2988 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
2994 PluginPtr p = pip->load (*_session);
3000 if (ppp->_preset.valid) {
3001 p->load_preset (ppp->_preset);
3004 Route::ProcessorStreams err;
3005 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
3009 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
3012 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
3019 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
3023 if (!np->display_to_user()) {
3026 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
3027 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
3032 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
3036 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
3043 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
3045 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
3049 // only allow to re-order top-level items
3051 if (TreePath::get_from_selection_data (data, src)) {
3052 if (src.up() && src.up()) {
3057 // don't allow to drop as child-rows.
3058 Gtk::TreeModel::Path _dest = dest; // un const
3059 const bool is_child = _dest.up (); // explicit bool for clang
3060 if (!is_child || _dest.empty ()) {
3067 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
3069 if (data.get_target() != "PluginPresetPtr") {
3072 if (data.get_length() != sizeof (PluginPresetPtr)) {
3075 const void *d = data.get_data();
3076 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
3078 PluginManager::PluginStatusType status = PluginManager::Favorite;
3079 PluginManager& manager (PluginManager::instance());
3081 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3082 manager.save_statuses ();
3086 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
3088 /* call protected MixerActor:: method */
3093 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
3095 /* call protected MixerActor:: method */
3100 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
3102 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
3105 show_spill_change (s); /* EMIT SIGNAL */
3107 _group_tabs->hide ();
3109 _group_tabs->show ();
3111 redisplay_track_list ();
3116 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
3118 return s == spilled_strip.lock();
3122 Mixer_UI::register_actions ()
3124 Glib::RefPtr<ActionGroup> group = ActionManager::create_action_group (bindings, X_("Mixer"));
3126 ActionManager::register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
3127 ActionManager::register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
3128 ActionManager::register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
3129 ActionManager::register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
3130 ActionManager::register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
3131 ActionManager::register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
3134 ActionManager::register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
3135 ActionManager::register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
3136 ActionManager::register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
3137 ActionManager::register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
3138 ActionManager::register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
3139 ActionManager::register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
3140 ActionManager::register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
3141 ActionManager::register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
3143 ActionManager::register_action (group, "select-next-stripable", _("Select Next Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_next_strip));
3144 ActionManager::register_action (group, "select-prev-stripable", _("Scroll Previous Mixer Strip"), sigc::mem_fun (*this, &Mixer_UI::select_prev_strip));
3146 ActionManager::register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
3147 ActionManager::register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
3149 ActionManager::register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
3150 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
3152 ActionManager::register_toggle_action (group, X_("ToggleMixerList"), _("Mixer: Show Mixer List"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixer_list));
3154 ActionManager::register_toggle_action (group, X_("ToggleVCAPane"), _("Mixer: Show VCAs"), sigc::mem_fun (*this, &Mixer_UI::toggle_vcas));
3157 ActionManager::register_toggle_action (group, X_("ToggleMixbusPane"), _("Mixer: Show Mixbuses"), sigc::mem_fun (*this, &Mixer_UI::toggle_mixbuses));
3160 ActionManager::register_toggle_action (group, X_("ToggleMonitorSection"), _("Mixer: Show Monitor Section"), sigc::mem_fun (*this, &Mixer_UI::toggle_monitor_section));
3164 Mixer_UI::load_bindings ()
3166 bindings = Bindings::get_bindings (X_("Mixer"));
3169 template<class T> void
3170 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
3172 boost::shared_ptr<ControlList> cl (new ControlList);
3173 boost::shared_ptr<AutomationControl> ac;
3175 bool have_val = false;
3177 set_axis_targets_for_operation ();
3179 BOOST_FOREACH(AxisView* r, _axis_targets) {
3180 boost::shared_ptr<Stripable> s = r->stripable();
3182 ac = (s.get()->*get_control)();
3186 val = !ac->get_value();
3193 _session->set_controls (cl, val, Controllable::UseGroup);
3197 Mixer_UI::solo_action ()
3199 control_action (&Stripable::solo_control);
3203 Mixer_UI::mute_action ()
3205 control_action (&Stripable::mute_control);
3209 Mixer_UI::rec_enable_action ()
3211 control_action (&Stripable::rec_enable_control);
3214 AutomationControlSet
3215 Mixer_UI::selected_gaincontrols ()
3217 set_axis_targets_for_operation ();
3218 AutomationControlSet rv;
3219 BOOST_FOREACH(AxisView* r, _axis_targets) {
3220 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3222 boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
3223 ControlList cl (ac->grouped_controls());
3224 for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
3234 Mixer_UI::step_gain_up_action ()
3236 AutomationControlSet acs = selected_gaincontrols ();
3237 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3238 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3240 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
3245 Mixer_UI::step_gain_down_action ()
3247 AutomationControlSet acs = selected_gaincontrols ();
3248 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3249 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3251 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
3256 Mixer_UI::unity_gain_action ()
3258 set_axis_targets_for_operation ();
3260 BOOST_FOREACH(AxisView* r, _axis_targets) {
3261 boost::shared_ptr<Stripable> s = r->stripable();
3263 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3265 ac->set_value (1.0, Controllable::UseGroup);
3272 Mixer_UI::copy_processors ()
3274 set_axis_targets_for_operation ();
3276 BOOST_FOREACH(AxisView* r, _axis_targets) {
3277 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3279 ms->copy_processors ();
3284 Mixer_UI::cut_processors ()
3286 set_axis_targets_for_operation ();
3288 BOOST_FOREACH(AxisView* r, _axis_targets) {
3289 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3291 ms->cut_processors ();
3296 Mixer_UI::paste_processors ()
3298 set_axis_targets_for_operation ();
3300 BOOST_FOREACH(AxisView* r, _axis_targets) {
3301 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3303 ms->paste_processors ();
3308 Mixer_UI::select_all_processors ()
3310 set_axis_targets_for_operation ();
3312 BOOST_FOREACH(AxisView* r, _axis_targets) {
3313 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3315 ms->select_all_processors ();
3320 Mixer_UI::toggle_processors ()
3322 set_axis_targets_for_operation ();
3324 BOOST_FOREACH(AxisView* r, _axis_targets) {
3325 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3327 ms->toggle_processors ();
3332 Mixer_UI::ab_plugins ()
3334 set_axis_targets_for_operation ();
3336 BOOST_FOREACH(AxisView* r, _axis_targets) {
3337 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3345 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3347 set_axis_targets_for_operation ();
3348 BOOST_FOREACH(AxisView* r, _axis_targets) {
3349 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3351 ms->vca_assign (vca);
3357 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3359 set_axis_targets_for_operation ();
3360 BOOST_FOREACH(AxisView* r, _axis_targets) {
3361 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3363 ms->vca_unassign (vca);