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 , _monitor_section (0)
107 , _plugin_selector (0)
108 , _strip_width (UIConfiguration::instance().get_default_narrow_ms() ? Narrow : Wide)
109 , ignore_reorder (false)
110 , _in_group_rebuild_or_clear (false)
111 , _route_deletion_in_progress (false)
113 , _show_mixer_list (true)
114 , _strip_selection_change_without_scroll (false)
115 , myactions (X_("mixer"))
116 , _selection (*this, *this)
120 _content.set_data ("ardour-bindings", bindings);
122 PresentationInfo::Change.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::presentation_info_changed, this, _1), gui_context());
124 scroller.set_can_default (true);
125 // set_default (scroller);
127 scroller_base.set_flags (Gtk::CAN_FOCUS);
128 scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
129 scroller_base.set_name ("MixerWindow");
130 scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
132 /* set up drag-n-drop */
133 vector<TargetEntry> target_table;
134 target_table.push_back (TargetEntry ("PluginFavoritePtr"));
135 scroller_base.drag_dest_set (target_table);
136 scroller_base.signal_drag_data_received().connect (sigc::mem_fun(*this, &Mixer_UI::scroller_drag_data_received));
138 /* create a button to add VCA strips ... will get packed in redisplay_track_list() */
139 Widget* w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
141 add_vca_button.add (*w);
142 add_vca_button.set_can_focus(false);
143 add_vca_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
145 /* create a button to add mixer strips */
146 w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
149 add_button.set_can_focus(false);
150 add_button.signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_track_or_bus));
152 /* add as last item of strip packer */
153 strip_packer.pack_end (scroller_base, true, true);
154 strip_packer.pack_end (add_button, false, false);
157 /* create a drop-shadow at the end of the mixer strips */
158 mb_shadow.set_size_request( 4, -1 );
159 mb_shadow.set_name("EditorWindow");
161 strip_packer.pack_end (mb_shadow, false, false);
164 _group_tabs = new MixerGroupTabs (this);
165 VBox* b = manage (new VBox);
167 b->set_border_width (0);
168 b->pack_start (*_group_tabs, PACK_SHRINK);
169 b->pack_start (strip_packer);
171 b->signal_scroll_event().connect (sigc::mem_fun (*this, &Mixer_UI::on_scroll_event), false);
174 scroller.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC);
176 setup_track_display ();
178 group_model = ListStore::create (group_columns);
179 group_display.set_model (group_model);
180 group_display.append_column (_("Show"), group_columns.visible);
181 group_display.append_column (_("Group"), group_columns.text);
182 group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
183 group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
184 group_display.get_column (0)->set_expand(false);
185 group_display.get_column (1)->set_expand(true);
186 group_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
187 group_display.set_name ("EditGroupList");
188 group_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
189 group_display.set_reorderable (true);
190 group_display.set_headers_visible (true);
191 group_display.set_rules_hint (true);
192 group_display.set_can_focus(false);
194 /* name is directly editable */
196 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
197 name_cell->property_editable() = true;
198 name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
200 /* use checkbox for the active column */
202 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(group_display.get_column_cell_renderer (0));
203 active_cell->property_activatable() = true;
204 active_cell->property_radio() = false;
206 group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
207 /* We use this to notice drag-and-drop reorders of the group list */
208 group_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_deleted));
209 group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
211 group_display_scroller.add (group_display);
212 group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
215 group_display_vbox.pack_start (group_display_scroller, true, true);
217 group_display_frame.set_name ("BaseFrame");
218 group_display_frame.set_shadow_type (Gtk::SHADOW_IN);
219 group_display_frame.add (group_display_vbox);
221 list<TargetEntry> target_list;
222 target_list.push_back (TargetEntry ("PluginPresetPtr"));
224 favorite_plugins_model = PluginTreeStore::create (favorite_plugins_columns);
225 favorite_plugins_display.set_model (favorite_plugins_model);
226 favorite_plugins_display.append_column (_("Favorite Plugins"), favorite_plugins_columns.name);
227 favorite_plugins_display.set_name ("EditGroupList");
228 favorite_plugins_display.get_selection()->set_mode (Gtk::SELECTION_SINGLE);
229 favorite_plugins_display.set_reorderable (false);
230 favorite_plugins_display.set_headers_visible (true);
231 favorite_plugins_display.set_rules_hint (true);
232 favorite_plugins_display.set_can_focus (false);
233 favorite_plugins_display.set_tooltip_column (0);
234 favorite_plugins_display.add_object_drag (favorite_plugins_columns.plugin.index(), "PluginFavoritePtr");
235 favorite_plugins_display.set_drag_column (favorite_plugins_columns.name.index());
236 favorite_plugins_display.add_drop_targets (target_list);
237 favorite_plugins_display.signal_row_activated().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_activated));
238 favorite_plugins_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::plugin_row_button_press), false);
239 favorite_plugins_display.signal_drop.connect (sigc::mem_fun (*this, &Mixer_UI::plugin_drop));
240 favorite_plugins_display.signal_row_expanded().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
241 favorite_plugins_display.signal_row_collapsed().connect (sigc::mem_fun (*this, &Mixer_UI::save_favorite_ui_state));
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 MixerStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_strip, this, _1), gui_context());
351 VCAMasterStrip::CatchDeletion.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::remove_master, this, _1), gui_context());
355 ARDOUR_UI::instance()->Escape.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::escape, this), gui_context());
357 #ifndef DEFER_PLUGIN_SELECTOR_LOAD
358 _plugin_selector = new PluginSelector (PluginManager::instance ());
360 #error implement deferred Plugin-Favorite list
363 PluginManager::instance ().PluginListChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
364 PluginManager::instance ().PluginStatusChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::plugin_list_changed, this), gui_context());
365 ARDOUR::Plugin::PresetsChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::refill_favorite_plugins, this), gui_context());
368 Mixer_UI::~Mixer_UI ()
370 if (_monitor_section) {
371 monitor_section_detached ();
372 delete _monitor_section;
374 delete _plugin_selector;
385 Mixer_UI::tag_combo_changed ()
387 refill_favorite_plugins();
391 Mixer_UI::use_own_window (bool and_fill_it)
393 bool new_window = !own_window();
395 Gtk::Window* win = Tabbable::use_own_window (and_fill_it);
397 if (win && new_window) {
398 win->set_name ("MixerWindow");
399 ARDOUR_UI::instance()->setup_toplevel_window (*win, _("Mixer"), this);
400 win->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), win));
401 win->set_data ("ardour-bindings", bindings);
403 if (!win->get_focus()) {
404 /* set focus widget to something, anything */
405 win->set_focus (scroller);
413 Mixer_UI::show_window ()
415 Tabbable::show_window ();
417 /* show/hide group tabs as required */
418 parameter_changed ("show-group-tabs");
420 /* now reset each strips width so the right widgets are shown */
422 TreeModel::Children rows = track_model->children();
423 TreeModel::Children::iterator ri;
425 for (ri = rows.begin(); ri != rows.end(); ++ri) {
426 AxisView* av = (*ri)[stripable_columns.strip];
427 MixerStrip* ms = dynamic_cast<MixerStrip*> (av);
431 ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
432 /* Fix visibility of mixer strip stuff */
433 ms->parameter_changed (X_("mixer-element-visibility"));
436 /* force focus into main area */
437 scroller_base.grab_focus ();
441 Mixer_UI::remove_master (VCAMasterStrip* vms)
443 if (_session && _session->deletion_in_progress()) {
444 /* its all being taken care of */
448 TreeModel::Children rows = track_model->children();
449 TreeModel::Children::iterator ri;
451 for (ri = rows.begin(); ri != rows.end(); ++ri) {
452 if ((*ri)[stripable_columns.strip] == vms) {
453 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
454 track_model->erase (ri);
461 Mixer_UI::masters_scroller_button_release (GdkEventButton* ev)
463 using namespace Menu_Helpers;
465 if (Keyboard::is_context_menu_event (ev)) {
466 ARDOUR_UI::instance()->add_route ();
474 Mixer_UI::add_masters (VCAList& vlist)
478 for (VCAList::iterator v = vlist.begin(); v != vlist.end(); ++v) {
479 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
486 Mixer_UI::add_routes (RouteList& rlist)
490 for (RouteList::iterator r = rlist.begin(); r != rlist.end(); ++r) {
498 Mixer_UI::add_stripables (StripableList& slist)
500 Gtk::TreeModel::Children::iterator insert_iter = track_model->children().end();
501 bool from_scratch = (track_model->children().size() == 0);
502 uint32_t nroutes = 0;
504 slist.sort (Stripable::Sorter());
506 for (Gtk::TreeModel::Children::iterator it = track_model->children().begin(); it != track_model->children().end(); ++it) {
507 boost::shared_ptr<Stripable> s = (*it)[stripable_columns.stripable];
515 // XXX what does this special case do?
516 if (s->presentation_info().order() == (slist.front()->presentation_info().order() + slist.size())) {
525 PBD::Unwinder<bool> uw (no_track_list_redisplay, true);
527 track_display.set_model (Glib::RefPtr<ListStore>());
529 for (StripableList::iterator s = slist.begin(); s != slist.end(); ++s) {
531 boost::shared_ptr<Route> route;
532 boost::shared_ptr<VCA> vca;
534 if ((vca = boost::dynamic_pointer_cast<VCA> (*s))) {
536 VCAMasterStrip* vms = new VCAMasterStrip (_session, vca);
538 TreeModel::Row row = *(track_model->append());
540 row[stripable_columns.text] = vca->name();
541 row[stripable_columns.visible] = vms->marked_for_display ();
542 row[stripable_columns.strip] = vms;
543 row[stripable_columns.stripable] = vca;
545 vms->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::vca_button_release_event), vms));
547 } else if ((route = boost::dynamic_pointer_cast<Route> (*s))) {
549 if (route->is_auditioner()) {
553 if (route->is_monitor()) {
555 if (!_monitor_section) {
556 _monitor_section = new MonitorSection (_session);
558 XMLNode* mnode = ARDOUR_UI::instance()->tearoff_settings (X_("monitor-section"));
560 _monitor_section->tearoff().set_state (*mnode);
564 out_packer.pack_end (_monitor_section->tearoff(), false, false);
565 _monitor_section->set_session (_session);
566 _monitor_section->tearoff().show_all ();
568 _monitor_section->tearoff().Detach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_detached));
569 _monitor_section->tearoff().Attach.connect (sigc::mem_fun(*this, &Mixer_UI::monitor_section_attached));
571 if (_monitor_section->tearoff().torn_off()) {
572 monitor_section_detached ();
574 monitor_section_attached ();
577 route->DropReferences.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::monitor_section_going_away, this), gui_context());
579 /* no regular strip shown for control out */
584 strip = new MixerStrip (*this, _session, route);
585 strips.push_back (strip);
587 UIConfiguration::instance().get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
589 if (strip->width_owner() != strip) {
590 strip->set_width_enum (_strip_width, this);
595 if (route->is_master()) {
597 out_packer.pack_start (*strip, false, false);
598 strip->set_packed (true);
602 TreeModel::Row row = *(track_model->insert (insert_iter));
604 row[stripable_columns.text] = route->name();
605 row[stripable_columns.visible] = strip->marked_for_display();
606 row[stripable_columns.stripable] = route;
607 row[stripable_columns.strip] = strip;
610 strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
611 strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
614 (*s)->presentation_info().PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
615 (*s)->PropertyChanged.connect (*this, invalidator(*this), boost::bind (&Mixer_UI::stripable_property_changed, this, _1, boost::weak_ptr<Stripable>(*s)), gui_context());
618 } catch (const std::exception& e) {
619 error << string_compose (_("Error adding GUI elements for new tracks/busses %1"), e.what()) << endmsg;
622 track_display.set_model (track_model);
624 /* catch up on selection state, which we left to the editor to set */
625 sync_treeview_from_presentation_info (PropertyChange (Properties::selected));
628 sync_presentation_info_from_treeview ();
631 redisplay_track_list ();
635 Mixer_UI::deselect_all_strip_processors ()
637 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
638 (*i)->deselect_all_processors();
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 PBD::Unwinder<bool> uwi (ignore_reorder, true);
676 for (ri = rows.begin(); ri != rows.end(); ++ri) {
677 if ((*ri)[stripable_columns.strip] == strip) {
678 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
679 track_model->erase (ri);
686 Mixer_UI::presentation_info_changed (PropertyChange const & what_changed)
688 if (what_changed.contains (Properties::selected)) {
689 _selection.presentation_info_changed (what_changed);
693 soh.add (Properties::selected);
694 soh.add (Properties::order);
695 soh.add (Properties::hidden);
697 if (what_changed.contains (soh)) {
698 sync_treeview_from_presentation_info (what_changed);
703 Mixer_UI::sync_presentation_info_from_treeview ()
705 if (ignore_reorder || !_session || _session->deletion_in_progress()) {
709 TreeModel::Children rows = track_model->children();
715 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync presentation info from treeview\n");
717 TreeModel::Children::iterator ri;
720 PresentationInfo::order_t master_key = _session->master_order_key ();
721 PresentationInfo::order_t 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];
729 #ifndef NDEBUG // these should not exist in the mixer's treeview
734 if (stripable->is_monitor() || stripable->is_auditioner()) {
738 if (stripable->is_master()) {
744 stripable->presentation_info().set_hidden (!visible);
746 // leave master where it is.
747 if (order == master_key) {
751 if (order != stripable->presentation_info().order()) {
752 stripable->set_presentation_order (order);
758 change |= _session->ensure_stripable_sort_order ();
761 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from mixer GUI\n");
762 _session->set_dirty();
767 Mixer_UI::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
769 if (!_session || _session->deletion_in_progress()) {
773 DEBUG_TRACE (DEBUG::OrderKeys, "mixer sync model from presentation info.\n");
775 /* we could get here after either a change in the Mixer or Editor sort
776 * order, but either way, the mixer order keys reflect the intended
777 * order for the GUI, so reorder the treeview model to match it.
780 vector<int> neworder;
781 TreeModel::Children rows = track_model->children();
782 uint32_t old_order = 0;
783 bool changed = false;
789 TreeOrderKeys sorted;
790 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
791 boost::shared_ptr<Stripable> stripable = (*ri)[stripable_columns.stripable];
792 sorted.push_back (TreeOrderKey (old_order, stripable));
795 TreeOrderKeySorter cmp;
797 sort (sorted.begin(), sorted.end(), cmp);
798 neworder.assign (sorted.size(), 0);
802 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
804 neworder[n] = sr->old_display_order;
806 if (sr->old_display_order != n) {
812 Unwinder<bool> uw (ignore_reorder, true);
813 track_model->reorder (neworder);
816 if (what_changed.contains (Properties::selected)) {
818 PresentationInfo::ChangeSuspender cs;
820 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
821 boost::shared_ptr<Stripable> stripable = (*i)->stripable();
822 if (stripable && stripable->is_selected()) {
825 _selection.remove (*i);
829 if (!_selection.axes.empty() && !PublicEditor::instance().track_selection_change_without_scroll () && !_strip_selection_change_without_scroll) {
830 move_stripable_into_view ((*_selection.axes.begin())->stripable());
833 TreeModel::Children rows = track_model->children();
834 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
835 AxisView* av = (*i)[stripable_columns.strip];
836 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
840 if (vms->vca() && vms->vca()->is_selected()) {
841 _selection.add (vms);
843 _selection.remove (vms);
848 redisplay_track_list ();
853 Mixer_UI::strip_by_route (boost::shared_ptr<Route> r) const
855 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
856 if ((*i)->route() == r) {
865 Mixer_UI::strip_by_stripable (boost::shared_ptr<Stripable> s) const
867 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
868 if ((*i)->stripable() == s) {
877 Mixer_UI::axis_view_by_stripable (boost::shared_ptr<Stripable> s) const
879 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
880 if ((*i)->stripable() == s) {
885 TreeModel::Children rows = track_model->children();
886 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
887 AxisView* av = (*i)[stripable_columns.strip];
888 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
889 if (vms && vms->stripable () == s) {
898 Mixer_UI::axis_view_by_control (boost::shared_ptr<AutomationControl> c) const
900 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
901 if ((*i)->control() == c) {
909 struct MixerStripSorter {
910 bool operator() (const MixerStrip* ms_a, const MixerStrip* ms_b)
912 boost::shared_ptr<ARDOUR::Stripable> const& a = ms_a->stripable ();
913 boost::shared_ptr<ARDOUR::Stripable> const& b = ms_b->stripable ();
914 return ARDOUR::Stripable::Sorter(true)(a, b);
919 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
921 /* Selecting a mixer-strip may also select grouped-tracks, and
922 * presentation_info_changed() being emitted and
923 * _selection.axes.begin() is being moved into view. This may
924 * effectively move the track that was clicked-on out of view.
926 * So here only the track that is actually clicked-on is moved into
927 * view (in case it's partially visible)
929 PBD::Unwinder<bool> uw (_strip_selection_change_without_scroll, true);
930 move_stripable_into_view (strip->stripable());
932 if (ev->button == 1) {
933 if (_selection.selected (strip)) {
934 /* primary-click: toggle selection state of strip */
935 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
936 _selection.remove (strip, true);
937 } else if (_selection.axes.size() > 1) {
938 /* de-select others */
939 _selection.set (strip);
941 PublicEditor& pe = PublicEditor::instance();
942 TimeAxisView* tav = pe.time_axis_view_from_stripable (strip->stripable());
944 pe.set_selected_mixer_strip (*tav);
947 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
948 _selection.add (strip, true);
949 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::RangeSelectModifier)) {
951 /* extend selection */
953 vector<MixerStrip*> tmp;
954 bool accumulate = false;
955 bool found_another = false;
957 strips.sort (MixerStripSorter());
959 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
964 /* hit clicked strip, start accumulating till we hit the first
973 } else if (_selection.selected (ms)) {
974 /* hit selected strip. if currently accumulating others,
975 we're done. if not accumulating others, start doing so.
977 found_another = true;
991 tmp.push_back (strip);
994 PresentationInfo::ChangeSuspender cs;
995 for (vector<MixerStrip*>::iterator i = tmp.begin(); i != tmp.end(); ++i) {
996 _selection.add (*i, true);
999 _selection.set (strip); //user wants to start a range selection, but there aren't any others selected yet
1002 _selection.set (strip);
1011 Mixer_UI::vca_button_release_event (GdkEventButton *ev, VCAMasterStrip *strip)
1013 _selection.set (strip);
1018 Mixer_UI::set_session (Session* sess)
1020 SessionHandlePtr::set_session (sess);
1022 if (_plugin_selector) {
1023 _plugin_selector->set_session (_session);
1026 _group_tabs->set_session (sess);
1028 if (_monitor_section) {
1029 _monitor_section->set_session (_session);
1033 _selection.clear ();
1037 refill_favorite_plugins();
1040 XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
1041 set_state (*node, 0);
1045 initial_track_display ();
1047 _session->RouteAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_routes, this, _1), gui_context());
1048 _session->route_group_added.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_route_group, this, _1), gui_context());
1049 _session->route_group_removed.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1050 _session->route_groups_reordered.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
1051 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
1052 _session->DirtyChanged.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1053 _session->StateSaved.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::update_title, this), gui_context());
1055 _session->vca_manager().VCAAdded.connect (_session_connections, invalidator (*this), boost::bind (&Mixer_UI::add_masters, this, _1), gui_context());
1057 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::parameter_changed, this, _1), gui_context ());
1059 route_groups_changed ();
1065 /* catch up on selection state, etc. */
1068 sc.add (Properties::selected);
1069 _selection.presentation_info_changed (sc);
1075 Mixer_UI::session_going_away ()
1077 ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away);
1079 _in_group_rebuild_or_clear = true;
1080 group_model->clear ();
1081 _in_group_rebuild_or_clear = false;
1083 _selection.clear ();
1084 track_model->clear ();
1086 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1090 if (_monitor_section) {
1091 _monitor_section->tearoff().hide_visible ();
1094 monitor_section_detached ();
1100 SessionHandlePtr::session_going_away ();
1107 Mixer_UI::track_visibility_changed (std::string const & path)
1109 if (_session && _session->deletion_in_progress()) {
1115 if ((iter = track_model->get_iter (path))) {
1117 AxisView* av = (*iter)[stripable_columns.strip];
1118 bool visible = (*iter)[stripable_columns.visible];
1120 if (av->set_marked_for_display (!visible)) {
1121 update_track_visibility ();
1127 Mixer_UI::update_track_visibility ()
1129 TreeModel::Children rows = track_model->children();
1130 TreeModel::Children::iterator i;
1133 Unwinder<bool> uw (no_track_list_redisplay, true);
1135 for (i = rows.begin(); i != rows.end(); ++i) {
1136 AxisView* av = (*i)[stripable_columns.strip];
1137 (*i)[stripable_columns.visible] = av->marked_for_display ();
1140 /* force presentation catch up with visibility changes
1143 sync_presentation_info_from_treeview ();
1146 redisplay_track_list ();
1150 Mixer_UI::show_strip (MixerStrip* ms)
1152 TreeModel::Children rows = track_model->children();
1153 TreeModel::Children::iterator i;
1155 for (i = rows.begin(); i != rows.end(); ++i) {
1157 AxisView* av = (*i)[stripable_columns.strip];
1158 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1160 (*i)[stripable_columns.visible] = true;
1161 av->set_marked_for_display (true);
1162 update_track_visibility ();
1169 Mixer_UI::hide_strip (MixerStrip* ms)
1171 TreeModel::Children rows = track_model->children();
1172 TreeModel::Children::iterator i;
1174 for (i = rows.begin(); i != rows.end(); ++i) {
1176 AxisView* av = (*i)[stripable_columns.strip];
1177 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1179 (*i)[stripable_columns.visible] = false;
1180 av->set_marked_for_display (false);
1181 update_track_visibility ();
1188 Mixer_UI::start_updating ()
1190 fast_screen_update_connection = Timers::super_rapid_connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
1195 Mixer_UI::stop_updating ()
1197 fast_screen_update_connection.disconnect();
1202 Mixer_UI::fast_update_strips ()
1204 if (_content.is_mapped () && _session) {
1205 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1206 (*i)->fast_update ();
1212 Mixer_UI::set_all_strips_visibility (bool yn)
1214 TreeModel::Children rows = track_model->children();
1215 TreeModel::Children::iterator i;
1218 Unwinder<bool> uw (no_track_list_redisplay, true);
1220 for (i = rows.begin(); i != rows.end(); ++i) {
1222 AxisView* av = (*i)[stripable_columns.strip];
1223 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1229 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1233 (*i)[stripable_columns.visible] = yn;
1237 redisplay_track_list ();
1242 Mixer_UI::set_all_audio_midi_visibility (int tracks, bool yn)
1244 TreeModel::Children rows = track_model->children();
1245 TreeModel::Children::iterator i;
1248 Unwinder<bool> uw (no_track_list_redisplay, true);
1250 for (i = rows.begin(); i != rows.end(); ++i) {
1252 AxisView* av = (*i)[stripable_columns.strip];
1253 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1259 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1263 boost::shared_ptr<AudioTrack> at = strip->audio_track();
1264 boost::shared_ptr<MidiTrack> mt = strip->midi_track();
1268 (*i)[stripable_columns.visible] = yn;
1272 if (at) { /* track */
1273 (*i)[stripable_columns.visible] = yn;
1278 if (!at && !mt) { /* bus */
1279 (*i)[stripable_columns.visible] = yn;
1284 if (mt) { /* midi-track */
1285 (*i)[stripable_columns.visible] = yn;
1292 redisplay_track_list ();
1296 Mixer_UI::hide_all_routes ()
1298 set_all_strips_visibility (false);
1302 Mixer_UI::show_all_routes ()
1304 set_all_strips_visibility (true);
1308 Mixer_UI::show_all_audiobus ()
1310 set_all_audio_midi_visibility (2, true);
1313 Mixer_UI::hide_all_audiobus ()
1315 set_all_audio_midi_visibility (2, false);
1319 Mixer_UI::show_all_audiotracks()
1321 set_all_audio_midi_visibility (1, true);
1324 Mixer_UI::hide_all_audiotracks ()
1326 set_all_audio_midi_visibility (1, false);
1330 Mixer_UI::show_all_miditracks()
1332 set_all_audio_midi_visibility (3, true);
1335 Mixer_UI::hide_all_miditracks ()
1337 set_all_audio_midi_visibility (3, false);
1341 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
1343 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview reordered\n");
1344 sync_presentation_info_from_treeview ();
1348 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
1350 /* this happens as the second step of a DnD within the treeview as well
1351 as when a row/route is actually deleted.
1353 if it was a deletion then we have to force a redisplay because
1354 order keys may not have changed.
1357 DEBUG_TRACE (DEBUG::OrderKeys, "mixer UI treeview row deleted\n");
1358 sync_presentation_info_from_treeview ();
1360 if (_route_deletion_in_progress) {
1361 redisplay_track_list ();
1366 Mixer_UI::spill_redisplay (boost::shared_ptr<VCA> vca)
1368 TreeModel::Children rows = track_model->children();
1369 std::list<boost::shared_ptr<VCA> > vcas;
1370 vcas.push_back (vca);
1372 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1373 AxisView* av = (*i)[stripable_columns.strip];
1374 VCAMasterStrip* vms = dynamic_cast<VCAMasterStrip*> (av);
1375 if (vms && vms->vca()->slaved_to (vca)) {
1376 vcas.push_back (vms->vca());
1380 for (TreeModel::Children::const_iterator i = rows.begin(); i != rows.end(); ++i) {
1382 AxisView* av = (*i)[stripable_columns.strip];
1383 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1384 bool const visible = (*i)[stripable_columns.visible];
1387 /* we're in the middle of changing a row, don't worry */
1391 if (!strip->route()) {
1392 /* non-route element */
1396 if (strip->route()->is_master() || strip->route()->is_monitor()) {
1400 bool slaved = false;
1401 for (std::list<boost::shared_ptr<VCA> >::const_iterator m = vcas.begin(); m != vcas.end(); ++m) {
1402 if (strip->route()->slaved_to (*m)) {
1408 if (slaved && visible) {
1410 if (strip->packed()) {
1411 strip_packer.reorder_child (*strip, -1); /* put at end */
1413 strip_packer.pack_start (*strip, false, false);
1414 strip->set_packed (true);
1419 if (strip->packed()) {
1420 strip_packer.remove (*strip);
1421 strip->set_packed (false);
1428 Mixer_UI::redisplay_track_list ()
1430 if (no_track_list_redisplay) {
1434 boost::shared_ptr<Stripable> ss = spilled_strip.lock ();
1436 boost::shared_ptr<VCA> sv = boost::dynamic_pointer_cast<VCA> (ss);
1438 spill_redisplay (sv);
1443 TreeModel::Children rows = track_model->children();
1444 TreeModel::Children::iterator i;
1445 uint32_t n_masters = 0;
1447 container_clear (vca_hpacker);
1449 vca_hpacker.pack_end (vca_scroller_base, true, true);
1450 vca_hpacker.pack_end (add_vca_button, false, false);
1452 add_vca_button.show ();
1453 vca_scroller_base.show();
1455 for (i = rows.begin(); i != rows.end(); ++i) {
1457 AxisView* s = (*i)[stripable_columns.strip];
1458 bool const visible = (*i)[stripable_columns.visible];
1459 boost::shared_ptr<Stripable> stripable = (*i)[stripable_columns.stripable];
1462 /* we're in the middle of changing a row, don't worry */
1466 VCAMasterStrip* vms;
1468 if ((vms = dynamic_cast<VCAMasterStrip*> (s))) {
1470 vca_hpacker.pack_start (*vms, false, false);
1477 MixerStrip* strip = dynamic_cast<MixerStrip*> (s);
1485 if (strip->packed()) {
1486 strip_packer.reorder_child (*strip, -1); /* put at end */
1488 strip_packer.pack_start (*strip, false, false);
1489 strip->set_packed (true);
1494 if (stripable->is_master() || stripable->is_monitor()) {
1495 /* do nothing, these cannot be hidden */
1497 if (strip->packed()) {
1498 strip_packer.remove (*strip);
1499 strip->set_packed (false);
1505 /* update visibility of VCA assign buttons */
1507 if (n_masters == 0) {
1508 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::remove_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1509 vca_vpacker.hide ();
1510 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleVCAPane");
1512 act->set_sensitive (false);
1516 UIConfiguration::instance().set_mixer_strip_visibility (VisibilityGroup::add_element (UIConfiguration::instance().get_mixer_strip_visibility(), X_("VCA")));
1518 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleVCAPane");
1520 act->set_sensitive (true);
1521 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
1522 showhide_vcas (tact->get_active());
1524 vca_vpacker.show ();
1528 _group_tabs->set_dirty ();
1532 Mixer_UI::strip_width_changed ()
1534 _group_tabs->set_dirty ();
1537 TreeModel::Children rows = track_model->children();
1538 TreeModel::Children::iterator i;
1541 for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
1542 AxisView* av = (*i)[stripable_columns.strip];
1543 MixerStrip* strip = dynamic_cast<MixerStrip*> (av);
1549 bool visible = (*i)[stripable_columns.visible];
1552 strip->queue_draw();
1559 struct PresentationInfoMixerSorter
1561 bool operator() (boost::shared_ptr<Stripable> a, boost::shared_ptr<Stripable> b) {
1562 if (a->is_master()) {
1563 /* master after everything else */
1565 } else if (b->is_master()) {
1566 /* everything else before master */
1569 return a->presentation_info().order () < b->presentation_info().order ();
1574 Mixer_UI::initial_track_display ()
1578 boost::shared_ptr<RouteList> routes = _session->get_routes();
1580 for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) {
1584 VCAList vcas = _session->vca_manager().vcas();
1586 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
1587 sl.push_back (boost::dynamic_pointer_cast<Stripable> (*v));
1590 sl.sort (PresentationInfoMixerSorter());
1593 /* These are also used inside ::add_stripables() but we need
1594 * them here because we're going to clear the track_model also.
1596 Unwinder<bool> uw1 (no_track_list_redisplay, true);
1597 Unwinder<bool> uw2 (ignore_reorder, true);
1599 track_model->clear ();
1600 add_stripables (sl);
1603 sync_treeview_from_presentation_info (Properties::order);
1607 Mixer_UI::track_display_button_press (GdkEventButton* ev)
1609 if (Keyboard::is_context_menu_event (ev)) {
1610 if (track_menu == 0) {
1611 build_track_menu ();
1613 track_menu->popup (ev->button, ev->time);
1616 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 1)) {
1617 TreeModel::Path path;
1618 TreeViewColumn* column;
1620 if (track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1621 TreeIter iter = track_model->get_iter (path);
1622 if ((*iter)[stripable_columns.visible]) {
1623 boost::shared_ptr<ARDOUR::Stripable> s = (*iter)[stripable_columns.stripable];
1624 move_stripable_into_view (s);
1633 Mixer_UI::move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable> s)
1635 if (!scroller.get_hscrollbar()) {
1638 if (s->presentation_info().special () || s->presentation_info().flag_match (PresentationInfo::VCA)) {
1648 Gtk::Allocation alloc;
1649 for (list<MixerStrip *>::const_iterator i = strips.begin(); i != strips.end(); ++i) {
1650 if ((*i)->route() == s) {
1653 (*i)->translate_coordinates (strip_packer, 0, 0, x0, y);
1654 alloc = (*i)->get_allocation ();
1662 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
1664 if (x0 < adj->get_value()) {
1665 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x0)));
1666 } else if (x0 + alloc.get_width() >= adj->get_value() + adj->get_page_size()) {
1667 int x1 = x0 + alloc.get_width() - adj->get_page_size();
1668 adj->set_value (max (adj->get_lower(), min (adj->get_upper(), (double) x1)));
1673 Mixer_UI::build_track_menu ()
1675 using namespace Menu_Helpers;
1676 using namespace Gtk;
1678 track_menu = new Menu;
1679 track_menu->set_name ("ArdourContextMenu");
1680 MenuList& items = track_menu->items();
1682 items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
1683 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
1684 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
1685 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
1686 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
1687 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
1688 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::show_all_miditracks)));
1689 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &Mixer_UI::hide_all_miditracks)));
1694 Mixer_UI::stripable_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> ws)
1696 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
1700 boost::shared_ptr<Stripable> s = ws.lock ();
1706 TreeModel::Children rows = track_model->children();
1707 TreeModel::Children::iterator i;
1709 for (i = rows.begin(); i != rows.end(); ++i) {
1710 boost::shared_ptr<Stripable> ss = (*i)[stripable_columns.stripable];
1714 if (what_changed.contains (ARDOUR::Properties::name)) {
1715 (*i)[stripable_columns.text] = s->name();
1718 if (what_changed.contains (ARDOUR::Properties::hidden)) {
1719 (*i)[stripable_columns.visible] = !s->presentation_info().hidden();
1720 redisplay_track_list ();
1727 if (s->is_master ()) {
1731 error << _("track display list item for renamed strip not found!") << endmsg;
1735 Mixer_UI::group_display_button_press (GdkEventButton* ev)
1737 TreeModel::Path path;
1738 TreeViewColumn* column;
1742 if (!group_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
1743 if (ev->button == 3) {
1744 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1749 TreeIter iter = group_model->get_iter (path);
1751 if (ev->button == 3) {
1752 _group_tabs->get_menu(0)->popup (ev->button, ev->time);
1757 RouteGroup* group = (*iter)[group_columns.group];
1759 if (Keyboard::is_context_menu_event (ev)) {
1760 _group_tabs->get_menu(group)->popup (1, ev->time);
1764 switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
1766 if (Keyboard::is_edit_event (ev)) {
1768 // edit_route_group (group);
1770 group_display.queue_draw();
1779 bool visible = (*iter)[group_columns.visible];
1780 (*iter)[group_columns.visible] = !visible;
1782 group_display.queue_draw();
1795 Mixer_UI::activate_all_route_groups ()
1797 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
1801 Mixer_UI::disable_all_route_groups ()
1803 _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
1807 Mixer_UI::route_groups_changed ()
1809 ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed);
1811 _in_group_rebuild_or_clear = true;
1813 /* just rebuild the while thing */
1815 group_model->clear ();
1818 /* this is currently not used,
1819 * Mixer_UI::group_display_button_press() has a case for it,
1820 * and a commented edit_route_group() but that's n/a since 2011.
1822 * This code is left as reminder that
1823 * row[group_columns.group] = 0 has special meaning.
1827 row = *(group_model->append());
1828 row[group_columns.visible] = true;
1829 row[group_columns.text] = (_("-all-"));
1830 row[group_columns.group] = 0;
1834 _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
1836 _group_tabs->set_dirty ();
1837 _in_group_rebuild_or_clear = false;
1841 Mixer_UI::new_route_group ()
1843 _group_tabs->run_new_group_dialog (0, false);
1847 Mixer_UI::remove_selected_route_group ()
1849 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1850 TreeView::Selection::ListHandle_Path rows = selection->get_selected_rows ();
1856 TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
1859 /* selection mode is single, so rows.begin() is it */
1861 if ((iter = group_model->get_iter (*i))) {
1863 RouteGroup* rg = (*iter)[group_columns.group];
1866 _session->remove_route_group (*rg);
1872 Mixer_UI::route_group_property_changed (RouteGroup* group, const PropertyChange& change)
1874 if (in_group_row_change) {
1878 /* force an update of any mixer strips that are using this group,
1879 otherwise mix group names don't change in mixer strips
1882 for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
1883 if ((*i)->route_group() == group) {
1884 (*i)->route_group_changed();
1888 TreeModel::iterator i;
1889 TreeModel::Children rows = group_model->children();
1890 Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
1892 in_group_row_change = true;
1894 for (i = rows.begin(); i != rows.end(); ++i) {
1895 if ((*i)[group_columns.group] == group) {
1896 (*i)[group_columns.visible] = !group->is_hidden ();
1897 (*i)[group_columns.text] = group->name ();
1902 in_group_row_change = false;
1904 if (change.contains (Properties::name)) {
1905 _group_tabs->set_dirty ();
1908 for (list<MixerStrip*>::iterator j = strips.begin(); j != strips.end(); ++j) {
1909 if ((*j)->route_group() == group) {
1910 if (group->is_hidden ()) {
1920 Mixer_UI::show_mixer_list (bool yn)
1923 list_vpacker.show ();
1925 list_vpacker.hide ();
1928 _show_mixer_list = yn;
1932 Mixer_UI::show_monitor_section (bool yn)
1934 if (!monitor_section()) {
1937 if (monitor_section()->tearoff().torn_off()) {
1942 monitor_section()->tearoff().show();
1944 monitor_section()->tearoff().hide();
1949 Mixer_UI::route_group_name_edit (const std::string& path, const std::string& new_text)
1954 if ((iter = group_model->get_iter (path))) {
1956 if ((group = (*iter)[group_columns.group]) == 0) {
1960 if (new_text != group->name()) {
1961 group->set_name (new_text);
1967 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
1971 if (in_group_row_change) {
1975 if ((group = (*iter)[group_columns.group]) == 0) {
1979 std::string name = (*iter)[group_columns.text];
1981 if (name != group->name()) {
1982 group->set_name (name);
1985 bool hidden = !(*iter)[group_columns.visible];
1987 if (hidden != group->is_hidden ()) {
1988 group->set_hidden (hidden, this);
1992 /** Called when a group model row is deleted, but also when the model is
1993 * reordered by a user drag-and-drop; the latter is what we are
1994 * interested in here.
1997 Mixer_UI::route_group_row_deleted (Gtk::TreeModel::Path const &)
1999 if (_in_group_rebuild_or_clear) {
2003 /* Re-write the session's route group list so that the new order is preserved */
2005 list<RouteGroup*> new_list;
2007 Gtk::TreeModel::Children children = group_model->children();
2008 for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
2009 RouteGroup* g = (*i)[group_columns.group];
2011 new_list.push_back (g);
2015 _session->reorder_route_groups (new_list);
2020 Mixer_UI::add_route_group (RouteGroup* group)
2022 ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
2025 in_group_row_change = true;
2027 TreeModel::Row row = *(group_model->append());
2028 row[group_columns.visible] = !group->is_hidden ();
2029 row[group_columns.group] = group;
2030 if (!group->name().empty()) {
2031 row[group_columns.text] = group->name();
2033 row[group_columns.text] = _("unnamed");
2037 group->PropertyChanged.connect (*this, invalidator (*this), boost::bind (&Mixer_UI::route_group_property_changed, this, group, _1), gui_context());
2040 TreeViewColumn* col = group_display.get_column (0);
2041 CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (1));
2042 group_display.set_cursor (group_model->get_path (row), *col, *name_cell, true);
2045 _group_tabs->set_dirty ();
2047 in_group_row_change = false;
2051 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
2053 using namespace Menu_Helpers;
2055 if (Keyboard::is_context_menu_event (ev)) {
2056 ARDOUR_UI::instance()->add_route ();
2064 Mixer_UI::scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& data, guint info, guint time)
2066 if (data.get_target() != "PluginFavoritePtr") {
2067 context->drag_finish (false, false, time);
2071 const void * d = data.get_data();
2072 const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
2074 PluginPresetList nfos;
2076 tv->get_object_drag_data (nfos, &source);
2078 Route::ProcessorList pl;
2081 for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
2082 PluginPresetPtr ppp = (*i);
2083 PluginInfoPtr pip = ppp->_pip;
2084 if (!pip->is_instrument ()) {
2087 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);
2091 context->drag_finish (ok, false, time);
2095 Mixer_UI::set_strip_width (Width w, bool save)
2099 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2100 (*i)->set_width_enum (w, save ? (*i)->width_owner() : this);
2105 struct PluginStateSorter {
2107 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2108 std::list<std::string>::const_iterator aiter = std::find(_user.begin(), _user.end(), (*a).unique_id);
2109 std::list<std::string>::const_iterator biter = std::find(_user.begin(), _user.end(), (*b).unique_id);
2110 if (aiter != _user.end() && biter != _user.end()) {
2111 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2113 if (aiter != _user.end()) {
2116 if (biter != _user.end()) {
2119 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2122 PluginStateSorter(std::list<std::string> user) : _user (user) {}
2124 std::list<std::string> _user;
2128 Mixer_UI::set_state (const XMLNode& node, int version)
2132 Tabbable::set_state (node, version);
2134 if (node.get_property ("narrow-strips", yn)) {
2136 set_strip_width (Narrow);
2138 set_strip_width (Wide);
2142 node.get_property ("show-mixer", _visible);
2144 if (node.get_property ("maximised", yn)) {
2145 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMaximalMixer"));
2147 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2148 bool fs = tact && tact->get_active();
2150 ActionManager::do_action ("Common", "ToggleMaximalMixer");
2154 if (node.get_property ("show-mixer-list", yn)) {
2155 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Common"), X_("ToggleMixerList"));
2157 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2159 /* do it twice to force the change */
2160 tact->set_active (!yn);
2161 tact->set_active (yn);
2164 if (node.get_property ("monitor-section-visible", yn)) {
2165 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2166 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2167 /* do it twice to force the change */
2168 tact->set_active (yn);
2169 show_monitor_section (yn);
2172 //check for the user's plugin_order file
2173 XMLNode plugin_order_new(X_("PO"));
2174 if (PluginManager::instance().load_plugin_order_file(plugin_order_new)) {
2175 store_current_favorite_order ();
2176 std::list<string> order;
2177 const XMLNodeList& kids = plugin_order_new.children("PluginInfo");
2178 XMLNodeConstIterator i;
2179 for (i = kids.begin(); i != kids.end(); ++i) {
2180 std::string unique_id;
2181 if ((*i)->get_property ("unique-id", unique_id)) {
2182 order.push_back (unique_id);
2183 if ((*i)->get_property ("expanded", yn)) {
2184 favorite_ui_state[unique_id] = yn;
2188 PluginStateSorter cmp (order);
2189 favorite_order.sort (cmp);
2190 sync_treeview_from_favorite_order ();
2193 //if there is no user file, then use an existing one from instant.xml
2194 //NOTE: if you are loading an old session, this might come from the session's instant.xml
2195 //Todo: in the next major version, we should probably stop doing the instant.xml check, and just use the new file
2196 XMLNode* plugin_order;
2197 if ((plugin_order = find_named_node (node, "PluginOrder")) != 0) {
2198 store_current_favorite_order ();
2199 std::list<string> order;
2200 const XMLNodeList& kids = plugin_order->children("PluginInfo");
2201 XMLNodeConstIterator i;
2202 for (i = kids.begin(); i != kids.end(); ++i) {
2203 std::string unique_id;
2204 if ((*i)->get_property ("unique-id", unique_id)) {
2205 order.push_back (unique_id);
2206 if ((*i)->get_property ("expanded", yn)) {
2207 favorite_ui_state[unique_id] = yn;
2212 PluginStateSorter cmp (order);
2213 favorite_order.sort (cmp);
2214 sync_treeview_from_favorite_order ();
2222 Mixer_UI::save_plugin_order_file ()
2224 //this writes the plugin order to the user's preference file ( plugin_metadata/plugin_order )
2226 //NOTE: this replaces the old code that stores info in instant.xml
2227 //why? because instant.xml prefers the per-session settings, and we want this to be a global pref
2229 store_current_favorite_order ();
2230 XMLNode plugin_order ("PluginOrder");
2232 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i, ++cnt) {
2233 XMLNode* p = new XMLNode ("PluginInfo");
2234 p->set_property ("sort", cnt);
2235 p->set_property ("unique-id", (*i)->unique_id);
2236 if (favorite_ui_state.find ((*i)->unique_id) != favorite_ui_state.end ()) {
2237 p->set_property ("expanded", favorite_ui_state[(*i)->unique_id]);
2239 plugin_order.add_child_nocopy (*p);
2241 PluginManager::instance().save_plugin_order_file( plugin_order );
2245 Mixer_UI::get_state ()
2247 XMLNode* node = new XMLNode (X_("Mixer"));
2249 node->add_child_nocopy (Tabbable::get_state());
2251 node->set_property (X_("mixer-rhs-pane1-pos"), rhs_pane1.get_divider());
2252 node->set_property (X_("mixer-rhs_pane2-pos"), rhs_pane2.get_divider());
2253 node->set_property (X_("mixer-list-hpane-pos"), list_hpane.get_divider());
2254 node->set_property (X_("mixer-inner-pane-pos"), inner_pane.get_divider());
2256 node->set_property ("narrow-strips", (_strip_width == Narrow));
2257 node->set_property ("show-mixer", _visible);
2258 node->set_property ("show-mixer-list", _show_mixer_list);
2259 node->set_property ("maximised", _maximised);
2261 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2262 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2264 node->set_property ("monitor-section-visible", tact->get_active ());
2270 Mixer_UI::scroll_left ()
2272 if (!scroller.get_hscrollbar()) return;
2273 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2274 int sc_w = scroller.get_width();
2275 int sp_w = strip_packer.get_width();
2279 int lp = adj->get_value();
2281 using namespace Gtk::Box_Helpers;
2282 const BoxList& strips = strip_packer.children();
2283 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2284 if (i->get_widget() == & add_button) {
2288 if (i->get_widget() == &mb_shadow) {
2292 lm += i->get_widget()->get_width ();
2294 lm -= i->get_widget()->get_width ();
2298 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2302 Mixer_UI::scroll_right ()
2304 if (!scroller.get_hscrollbar()) return;
2305 Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
2306 int sc_w = scroller.get_width();
2307 int sp_w = strip_packer.get_width();
2311 int lp = adj->get_value();
2313 using namespace Gtk::Box_Helpers;
2314 const BoxList& strips = strip_packer.children();
2315 for (BoxList::const_iterator i = strips.begin(); i != strips.end(); ++i) {
2316 if (i->get_widget() == & add_button) {
2320 if (i->get_widget() == &mb_shadow) {
2324 lm += i->get_widget()->get_width ();
2329 scroller.get_hscrollbar()->set_value (max (adj->get_lower(), min (adj->get_upper(), lm - 1.0)));
2333 Mixer_UI::on_scroll_event (GdkEventScroll* ev)
2335 switch (ev->direction) {
2336 case GDK_SCROLL_LEFT:
2340 if (ev->state & Keyboard::TertiaryModifier) {
2346 case GDK_SCROLL_RIGHT:
2350 case GDK_SCROLL_DOWN:
2351 if (ev->state & Keyboard::TertiaryModifier) {
2363 Mixer_UI::parameter_changed (string const & p)
2365 if (p == "show-group-tabs") {
2366 bool const s = _session->config.get_show_group_tabs ();
2368 _group_tabs->show ();
2370 _group_tabs->hide ();
2372 } else if (p == "default-narrow_ms") {
2373 bool const s = UIConfiguration::instance().get_default_narrow_ms ();
2374 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2375 (*i)->set_width_enum (s ? Narrow : Wide, this);
2381 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
2383 g->set_active (a, this);
2387 Mixer_UI::plugin_selector()
2389 #ifdef DEFER_PLUGIN_SELECTOR_LOAD
2390 if (!_plugin_selector)
2391 _plugin_selector = new PluginSelector (PluginManager::instance());
2394 return _plugin_selector;
2398 Mixer_UI::setup_track_display ()
2400 track_model = ListStore::create (stripable_columns);
2401 track_display.set_model (track_model);
2402 track_display.append_column (_("Show"), stripable_columns.visible);
2403 track_display.append_column (_("Strips"), stripable_columns.text);
2404 track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
2405 track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
2406 track_display.get_column (0)->set_expand(false);
2407 track_display.get_column (1)->set_expand(true);
2408 track_display.get_column (1)->set_sizing (Gtk::TREE_VIEW_COLUMN_FIXED);
2409 track_display.set_name (X_("EditGroupList"));
2410 track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
2411 track_display.set_reorderable (true);
2412 track_display.set_headers_visible (true);
2413 track_display.set_can_focus(false);
2415 track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
2416 track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
2418 CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (0));
2419 track_list_visible_cell->property_activatable() = true;
2420 track_list_visible_cell->property_radio() = false;
2421 track_list_visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &Mixer_UI::track_visibility_changed));
2423 track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
2425 track_display_scroller.add (track_display);
2426 track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2428 VBox* v = manage (new VBox);
2430 v->pack_start (track_display_scroller, true, true);
2432 track_display_frame.set_name("BaseFrame");
2433 track_display_frame.set_shadow_type (Gtk::SHADOW_IN);
2434 track_display_frame.add (*v);
2436 track_display_scroller.show();
2437 track_display_frame.show();
2438 track_display.show();
2442 Mixer_UI::new_track_or_bus ()
2444 ARDOUR_UI::instance()->add_route ();
2448 Mixer_UI::update_title ()
2450 if (!own_window()) {
2457 if (_session->snap_name() != _session->name()) {
2458 n = _session->snap_name ();
2460 n = _session->name ();
2463 if (_session->dirty ()) {
2467 WindowTitle title (n);
2468 title += S_("Window|Mixer");
2469 title += Glib::get_application_name ();
2470 own_window()->set_title (title.get_string());
2474 WindowTitle title (S_("Window|Mixer"));
2475 title += Glib::get_application_name ();
2476 own_window()->set_title (title.get_string());
2481 Mixer_UI::strip_by_x (int x)
2483 for (list<MixerStrip*>::iterator i = strips.begin(); i != strips.end(); ++i) {
2486 (*i)->translate_coordinates (_content, 0, 0, x1, y);
2487 x2 = x1 + (*i)->get_width();
2489 if (x >= x1 && x <= x2) {
2498 Mixer_UI::set_axis_targets_for_operation ()
2500 _axis_targets.clear ();
2502 if (!_selection.empty()) {
2503 _axis_targets = _selection.axes;
2507 // removed "implicit" selections of strips, after discussion on IRC
2512 Mixer_UI::monitor_section_going_away ()
2514 if (_monitor_section) {
2515 XMLNode* ui_node = Config->extra_xml(X_("UI"));
2516 /* immediate state save.
2518 * Tearoff settings are otherwise only stored during
2519 * save_ardour_state(). The mon-section may or may not
2520 * exist at that point.
2523 XMLNode* tearoff_node = ui_node->child (X_("Tearoffs"));
2525 tearoff_node->remove_nodes_and_delete (X_("monitor-section"));
2526 XMLNode* t = new XMLNode (X_("monitor-section"));
2527 _monitor_section->tearoff().add_state (*t);
2528 tearoff_node->add_child_nocopy (*t);
2531 monitor_section_detached ();
2532 out_packer.remove (_monitor_section->tearoff());
2533 _monitor_section->set_session (0);
2534 delete _monitor_section;
2535 _monitor_section = 0;
2540 Mixer_UI::toggle_midi_input_active (bool flip_others)
2542 boost::shared_ptr<RouteList> rl (new RouteList);
2545 set_axis_targets_for_operation ();
2547 for (AxisViewSelection::iterator r = _axis_targets.begin(); r != _axis_targets.end(); ++r) {
2548 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> ((*r)->stripable());
2552 onoff = !mt->input_active();
2556 _session->set_exclusive_input_active (rl, onoff, flip_others);
2560 Mixer_UI::maximise_mixer_space ()
2562 if (!own_window()) {
2570 _window->fullscreen ();
2575 Mixer_UI::restore_mixer_space ()
2577 if (!own_window()) {
2585 own_window()->unfullscreen();
2590 Mixer_UI::monitor_section_attached ()
2592 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2593 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
2594 act->set_sensitive (true);
2595 show_monitor_section (tact->get_active ());
2599 Mixer_UI::monitor_section_detached ()
2601 Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMonitorSection");
2602 act->set_sensitive (false);
2606 Mixer_UI::store_current_favorite_order ()
2608 typedef Gtk::TreeModel::Children type_children;
2609 type_children children = favorite_plugins_model->children();
2610 favorite_order.clear();
2611 for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
2613 Gtk::TreeModel::Row row = *iter;
2614 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2615 favorite_order.push_back (ppp->_pip);
2616 std::string name = row[favorite_plugins_columns.name];
2617 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2622 Mixer_UI::save_favorite_ui_state (const TreeModel::iterator& iter, const TreeModel::Path& path)
2624 Gtk::TreeModel::Row row = *iter;
2625 ARDOUR::PluginPresetPtr ppp = row[favorite_plugins_columns.plugin];
2627 favorite_ui_state[(*ppp->_pip).unique_id] = favorite_plugins_display.row_expanded (favorite_plugins_model->get_path(iter));
2631 Mixer_UI::refiller (PluginInfoList& result, const PluginInfoList& plugs)
2633 PluginManager& manager (PluginManager::instance());
2634 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
2636 /* not a Favorite? skip it */
2637 if (manager.get_status (*i) != PluginManager::Favorite) {
2641 /* Check the tag combo selection, and skip this plugin if it doesn't match the selected tag(s) */
2642 string test = favorite_plugins_tag_combo.get_active_text();
2643 if (test != _("Show All")) {
2644 vector<string> tags = manager.get_tags(*i);
2646 //does the selected tag match any of the tags in the plugin?
2647 vector<string>::iterator tt = find (tags.begin(), tags.end(), test);
2648 if (tt == tags.end()) {
2653 result.push_back (*i);
2657 struct PluginCustomSorter {
2659 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
2660 PluginInfoList::const_iterator aiter = _user.begin();
2661 PluginInfoList::const_iterator biter = _user.begin();
2662 while (aiter != _user.end()) { if ((*aiter)->unique_id == a->unique_id) { break; } ++aiter; }
2663 while (biter != _user.end()) { if ((*biter)->unique_id == b->unique_id) { break; } ++biter; }
2665 if (aiter != _user.end() && biter != _user.end()) {
2666 return std::distance (_user.begin(), aiter) < std::distance (_user.begin(), biter);
2668 if (aiter != _user.end()) {
2671 if (biter != _user.end()) {
2674 return ARDOUR::cmp_nocase((*a).name, (*b).name) == -1;
2676 PluginCustomSorter(PluginInfoList user) : _user (user) {}
2678 PluginInfoList _user;
2682 Mixer_UI::refill_favorite_plugins ()
2684 PluginInfoList plugs;
2685 PluginManager& mgr (PluginManager::instance());
2688 refiller (plugs, mgr.lv2_plugin_info ());
2690 #ifdef WINDOWS_VST_SUPPORT
2691 refiller (plugs, mgr.windows_vst_plugin_info ());
2693 #ifdef LXVST_SUPPORT
2694 refiller (plugs, mgr.lxvst_plugin_info ());
2696 #ifdef MACVST_SUPPORT
2697 refiller (plugs, mgr.mac_vst_plugin_info ());
2699 #ifdef AUDIOUNIT_SUPPORT
2700 refiller (plugs, mgr.au_plugin_info ());
2702 refiller (plugs, mgr.ladspa_plugin_info ());
2703 refiller (plugs, mgr.lua_plugin_info ());
2705 store_current_favorite_order ();
2707 PluginCustomSorter cmp (favorite_order);
2710 favorite_order = plugs;
2712 sync_treeview_from_favorite_order ();
2716 Mixer_UI::plugin_list_changed ()
2718 refill_favorite_plugins();
2723 Mixer_UI::refill_tag_combo ()
2725 PluginManager& mgr (PluginManager::instance());
2727 std::vector<std::string> tags = mgr.get_all_tags (PluginManager::OnlyFavorites);
2729 favorite_plugins_tag_combo.clear();
2730 favorite_plugins_tag_combo.append_text (_("Show All"));
2732 for (vector<string>::iterator t = tags.begin (); t != tags.end (); ++t) {
2733 favorite_plugins_tag_combo.append_text (*t);
2736 favorite_plugins_tag_combo.set_active_text (_("Show All"));
2740 Mixer_UI::sync_treeview_favorite_ui_state (const TreeModel::Path& path, const TreeModel::iterator&)
2743 if (!(iter = favorite_plugins_model->get_iter (path))) {
2746 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2750 PluginInfoPtr pip = ppp->_pip;
2751 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2752 if (favorite_ui_state[pip->unique_id]) {
2753 favorite_plugins_display.expand_row (path, true);
2759 Mixer_UI::sync_treeview_from_favorite_order ()
2761 favorite_plugins_model->clear ();
2762 for (PluginInfoList::const_iterator i = favorite_order.begin(); i != favorite_order.end(); ++i) {
2763 PluginInfoPtr pip = (*i);
2765 TreeModel::Row newrow = *(favorite_plugins_model->append());
2766 newrow[favorite_plugins_columns.name] = (*i)->name;
2767 newrow[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip));
2772 vector<ARDOUR::Plugin::PresetRecord> presets = (*i)->get_presets (true);
2773 for (vector<ARDOUR::Plugin::PresetRecord>::const_iterator j = presets.begin(); j != presets.end(); ++j) {
2774 Gtk::TreeModel::Row child_row = *(favorite_plugins_model->append (newrow.children()));
2775 child_row[favorite_plugins_columns.name] = (*j).label;
2776 child_row[favorite_plugins_columns.plugin] = PluginPresetPtr (new PluginPreset(pip, &(*j)));
2778 if (favorite_ui_state.find (pip->unique_id) != favorite_ui_state.end ()) {
2779 if (favorite_ui_state[pip->unique_id]) {
2780 favorite_plugins_display.expand_row (favorite_plugins_model->get_path(newrow), true);
2787 Mixer_UI::popup_note_context_menu (GdkEventButton *ev)
2789 using namespace Gtk::Menu_Helpers;
2791 Gtk::Menu* m = manage (new Menu);
2792 MenuList& items = m->items ();
2794 if (_selection.axes.empty()) {
2795 items.push_back (MenuElem (_("No Track/Bus is selected.")));
2797 items.push_back (MenuElem (_("Add at the top"),
2798 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddTop)));
2799 items.push_back (MenuElem (_("Add Pre-Fader"),
2800 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPreFader)));
2801 items.push_back (MenuElem (_("Add Post-Fader"),
2802 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddPostFader)));
2803 items.push_back (MenuElem (_("Add at the end"),
2804 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::add_selected_processor), AddBottom)));
2807 items.push_back (SeparatorElem());
2809 items.push_back (MenuElem (_("Remove from favorites"), sigc::mem_fun (*this, &Mixer_UI::remove_selected_from_favorites)));
2811 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2812 if (ppp && ppp->_preset.valid && ppp->_preset.user) {
2813 // we cannot currently delete AU presets
2814 if (!ppp->_pip || ppp->_pip->type != AudioUnit) {
2815 items.push_back (MenuElem (_("Delete Preset"), sigc::mem_fun (*this, &Mixer_UI::delete_selected_preset)));
2819 m->popup (ev->button, ev->time);
2823 Mixer_UI::plugin_row_button_press (GdkEventButton *ev)
2825 if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) {
2826 TreeModel::Path path;
2827 TreeViewColumn* column;
2829 if (favorite_plugins_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
2830 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2832 selection->unselect_all();
2833 selection->select(path);
2836 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2838 popup_note_context_menu (ev);
2846 Mixer_UI::selected_plugin ()
2848 Glib::RefPtr<Gtk::TreeView::Selection> selection = favorite_plugins_display.get_selection();
2850 return PluginPresetPtr();
2852 Gtk::TreeModel::iterator iter = selection->get_selected();
2854 return PluginPresetPtr();
2856 return (*iter)[favorite_plugins_columns.plugin];
2860 Mixer_UI::add_selected_processor (ProcessorPosition pos)
2862 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2864 add_favorite_processor (ppp, pos);
2869 Mixer_UI::delete_selected_preset ()
2874 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2875 if (!ppp || !ppp->_preset.valid || !ppp->_preset.user) {
2878 PluginPtr plugin = ppp->_pip->load (*_session);
2879 plugin->get_presets();
2880 plugin->remove_preset (ppp->_preset.label);
2884 Mixer_UI::remove_selected_from_favorites ()
2886 ARDOUR::PluginPresetPtr ppp = selected_plugin();
2890 PluginManager::PluginStatusType status = PluginManager::Normal;
2891 PluginManager& manager (PluginManager::instance());
2893 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
2894 manager.save_statuses ();
2898 Mixer_UI::plugin_row_activated (const TreeModel::Path& path, TreeViewColumn* column)
2901 if (!(iter = favorite_plugins_model->get_iter (path))) {
2904 ARDOUR::PluginPresetPtr ppp = (*iter)[favorite_plugins_columns.plugin];
2905 add_favorite_processor (ppp, AddPreFader); // TODO: preference?!
2909 Mixer_UI::add_favorite_processor (ARDOUR::PluginPresetPtr ppp, ProcessorPosition pos)
2911 if (!_session || _selection.axes.empty()) {
2915 PluginInfoPtr pip = ppp->_pip;
2916 for (AxisViewSelection::iterator i = _selection.axes.begin(); i != _selection.axes.end(); ++i) {
2917 boost::shared_ptr<ARDOUR::Route> rt = boost::dynamic_pointer_cast<ARDOUR::Route> ((*i)->stripable());
2923 PluginPtr p = pip->load (*_session);
2929 if (ppp->_preset.valid) {
2930 p->load_preset (ppp->_preset);
2933 Route::ProcessorStreams err;
2934 boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
2938 rt->add_processor_by_index (processor, 0, &err, Config->get_new_plugins_active ());
2941 rt->add_processor (processor, PreFader, &err, Config->get_new_plugins_active ());
2948 boost::shared_ptr<Processor> np = rt->nth_processor (idx);
2952 if (!np->display_to_user()) {
2955 if (boost::dynamic_pointer_cast<Amp> (np) && // Fader, not Trim
2956 boost::dynamic_pointer_cast<Amp> (np)->gain_control()->parameter().type() == GainAutomation) {
2961 rt->add_processor_by_index (processor, ++pos, &err, Config->get_new_plugins_active ());
2965 rt->add_processor_by_index (processor, -1, &err, Config->get_new_plugins_active ());
2972 PluginTreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, const Gtk::SelectionData& data) const
2974 if (data.get_target() != "GTK_TREE_MODEL_ROW") {
2978 // only allow to re-order top-level items
2980 if (TreePath::get_from_selection_data (data, src)) {
2981 if (src.up() && src.up()) {
2986 // don't allow to drop as child-rows.
2987 Gtk::TreeModel::Path _dest = dest; // un const
2988 const bool is_child = _dest.up (); // explicit bool for clang
2989 if (!is_child || _dest.empty ()) {
2996 Mixer_UI::plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data)
2998 if (data.get_target() != "PluginPresetPtr") {
3001 if (data.get_length() != sizeof (PluginPresetPtr)) {
3004 const void *d = data.get_data();
3005 const PluginPresetPtr ppp = *(static_cast<const PluginPresetPtr*> (d));
3007 PluginManager::PluginStatusType status = PluginManager::Favorite;
3008 PluginManager& manager (PluginManager::instance());
3010 manager.set_status (ppp->_pip->type, ppp->_pip->unique_id, status);
3011 manager.save_statuses ();
3015 Mixer_UI::do_vca_assign (boost::shared_ptr<VCA> vca)
3017 /* call protected MixerActor:: method */
3022 Mixer_UI::do_vca_unassign (boost::shared_ptr<VCA> vca)
3024 /* call protected MixerActor:: method */
3029 Mixer_UI::show_spill (boost::shared_ptr<Stripable> s)
3031 boost::shared_ptr<Stripable> ss = spilled_strip.lock();
3034 show_spill_change (s); /* EMIT SIGNAL */
3036 _group_tabs->hide ();
3038 _group_tabs->show ();
3040 redisplay_track_list ();
3045 Mixer_UI::showing_spill_for (boost::shared_ptr<Stripable> s) const
3047 return s == spilled_strip.lock();
3051 Mixer_UI::show_editor_window () const
3053 PublicEditor::instance().make_visible ();
3057 Mixer_UI::register_actions ()
3059 Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
3061 myactions.register_action (group, "show-editor", _("Show Editor"), sigc::mem_fun (*this, &Mixer_UI::show_editor_window));
3063 myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::solo_action));
3064 myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::mute_action));
3065 myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::rec_enable_action));
3066 myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_up_action));
3067 myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::step_gain_down_action));
3068 myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &Mixer_UI::unity_gain_action));
3071 myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::copy_processors));
3072 myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::cut_processors));
3073 myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::paste_processors));
3074 myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::delete_processors));
3075 myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &Mixer_UI::select_all_processors));
3076 myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &Mixer_UI::toggle_processors));
3077 myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &Mixer_UI::ab_plugins));
3078 myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &Mixer_UI::select_none));
3080 myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &Mixer_UI::scroll_left));
3081 myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the right"), sigc::mem_fun (*this, &Mixer_UI::scroll_right));
3083 myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
3084 sigc::bind (sigc::mem_fun (*this, &Mixer_UI::toggle_midi_input_active), false));
3088 Mixer_UI::load_bindings ()
3090 bindings = Bindings::get_bindings (X_("Mixer"), myactions);
3093 template<class T> void
3094 Mixer_UI::control_action (boost::shared_ptr<T> (Stripable::*get_control)() const)
3096 boost::shared_ptr<ControlList> cl (new ControlList);
3097 boost::shared_ptr<AutomationControl> ac;
3099 bool have_val = false;
3101 set_axis_targets_for_operation ();
3103 BOOST_FOREACH(AxisView* r, _axis_targets) {
3104 boost::shared_ptr<Stripable> s = r->stripable();
3106 ac = (s.get()->*get_control)();
3110 val = !ac->get_value();
3117 _session->set_controls (cl, val, Controllable::UseGroup);
3121 Mixer_UI::solo_action ()
3123 control_action (&Stripable::solo_control);
3127 Mixer_UI::mute_action ()
3129 control_action (&Stripable::mute_control);
3133 Mixer_UI::rec_enable_action ()
3135 control_action (&Stripable::rec_enable_control);
3138 AutomationControlSet
3139 Mixer_UI::selected_gaincontrols ()
3141 set_axis_targets_for_operation ();
3142 AutomationControlSet rv;
3143 BOOST_FOREACH(AxisView* r, _axis_targets) {
3144 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3146 boost::shared_ptr<GainControl> ac (ms->route()->gain_control());
3147 ControlList cl (ac->grouped_controls());
3148 for (ControlList::const_iterator c = cl.begin(); c != cl.end (); ++c) {
3158 Mixer_UI::step_gain_up_action ()
3160 AutomationControlSet acs = selected_gaincontrols ();
3161 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3162 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3164 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) + 0.1), Controllable::NoGroup);
3169 Mixer_UI::step_gain_down_action ()
3171 AutomationControlSet acs = selected_gaincontrols ();
3172 for (AutomationControlSet::const_iterator i = acs.begin(); i != acs.end (); ++i) {
3173 boost::shared_ptr<GainControl> ac = boost::dynamic_pointer_cast<GainControl> (*i);
3175 ac->set_value (dB_to_coefficient (accurate_coefficient_to_dB (ac->get_value()) - 0.1), Controllable::NoGroup);
3180 Mixer_UI::unity_gain_action ()
3182 set_axis_targets_for_operation ();
3184 BOOST_FOREACH(AxisView* r, _axis_targets) {
3185 boost::shared_ptr<Stripable> s = r->stripable();
3187 boost::shared_ptr<AutomationControl> ac = s->gain_control();
3189 ac->set_value (1.0, Controllable::UseGroup);
3196 Mixer_UI::copy_processors ()
3198 set_axis_targets_for_operation ();
3200 BOOST_FOREACH(AxisView* r, _axis_targets) {
3201 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3203 ms->copy_processors ();
3208 Mixer_UI::cut_processors ()
3210 set_axis_targets_for_operation ();
3212 BOOST_FOREACH(AxisView* r, _axis_targets) {
3213 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3215 ms->cut_processors ();
3220 Mixer_UI::paste_processors ()
3222 set_axis_targets_for_operation ();
3224 BOOST_FOREACH(AxisView* r, _axis_targets) {
3225 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3227 ms->paste_processors ();
3232 Mixer_UI::select_all_processors ()
3234 set_axis_targets_for_operation ();
3236 BOOST_FOREACH(AxisView* r, _axis_targets) {
3237 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3239 ms->select_all_processors ();
3244 Mixer_UI::toggle_processors ()
3246 set_axis_targets_for_operation ();
3248 BOOST_FOREACH(AxisView* r, _axis_targets) {
3249 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3251 ms->toggle_processors ();
3256 Mixer_UI::ab_plugins ()
3258 set_axis_targets_for_operation ();
3260 BOOST_FOREACH(AxisView* r, _axis_targets) {
3261 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3269 Mixer_UI::vca_assign (boost::shared_ptr<VCA> vca)
3271 set_axis_targets_for_operation ();
3272 BOOST_FOREACH(AxisView* r, _axis_targets) {
3273 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3275 ms->vca_assign (vca);
3281 Mixer_UI::vca_unassign (boost::shared_ptr<VCA> vca)
3283 set_axis_targets_for_operation ();
3284 BOOST_FOREACH(AxisView* r, _axis_targets) {
3285 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
3287 ms->vca_unassign (vca);