2 * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
3 * Copyright (C) 2009-2014 David Robillard <d@drobilla.net>
4 * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2013-2015 Nick Mainsbridge <mainsbridge@gmail.com>
6 * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
7 * Copyright (C) 2016-2018 Len Ovens <len@ovenwerks.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include "pbd/unknown_type.h"
32 #include "pbd/unwind.h"
34 #include "ardour/debug.h"
35 #include "ardour/audio_track.h"
36 #include "ardour/midi_track.h"
37 #include "ardour/route.h"
38 #include "ardour/selection.h"
39 #include "ardour/session.h"
40 #include "ardour/solo_isolate_control.h"
41 #include "ardour/utils.h"
42 #include "ardour/vca.h"
43 #include "ardour/vca_manager.h"
45 #include "gtkmm2ext/cell_renderer_pixbuf_multi.h"
46 #include "gtkmm2ext/cell_renderer_pixbuf_toggle.h"
47 #include "gtkmm2ext/treeutils.h"
49 #include "widgets/tooltips.h"
52 #include "ardour_ui.h"
53 #include "audio_time_axis.h"
55 #include "editor_group_tabs.h"
56 #include "editor_routes.h"
57 #include "gui_thread.h"
59 #include "midi_time_axis.h"
60 #include "mixer_strip.h"
61 #include "plugin_setup_dialog.h"
62 #include "route_sorter.h"
63 #include "vca_time_axis.h"
69 using namespace ARDOUR;
70 using namespace ArdourWidgets;
71 using namespace ARDOUR_UI_UTILS;
74 using namespace Gtkmm2ext;
76 using Gtkmm2ext::Keyboard;
84 EditorRoutes::EditorRoutes (Editor* e)
86 , _ignore_reorder (false)
87 , _ignore_selection_change (false)
88 , column_does_not_select (false)
89 , _no_redisplay (false)
90 , _adding_routes (false)
91 , _route_deletion_in_progress (false)
92 , _redisplay_on_resume (false)
93 , _redisplay_active (0)
94 , _queue_tv_update (0)
99 static const int column_width = 22;
101 _scroller.add (_display);
102 _scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
104 _model = ListStore::create (_columns);
105 _display.set_model (_model);
107 _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRoutes::select_function));
109 // Record enable toggle
110 CellRendererPixbufMulti* rec_col_renderer = manage (new CellRendererPixbufMulti());
112 rec_col_renderer->set_pixbuf (0, ::get_icon("record-normal-disabled"));
113 rec_col_renderer->set_pixbuf (1, ::get_icon("record-normal-in-progress"));
114 rec_col_renderer->set_pixbuf (2, ::get_icon("record-normal-enabled"));
115 rec_col_renderer->set_pixbuf (3, ::get_icon("record-step"));
116 rec_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_enable_changed));
118 rec_state_column = manage (new TreeViewColumn("R", *rec_col_renderer));
120 rec_state_column->add_attribute(rec_col_renderer->property_state(), _columns.rec_state);
121 rec_state_column->add_attribute(rec_col_renderer->property_visible(), _columns.is_track);
123 rec_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
124 rec_state_column->set_alignment(ALIGN_CENTER);
125 rec_state_column->set_expand(false);
126 rec_state_column->set_fixed_width(column_width);
129 // Record safe toggle
130 CellRendererPixbufMulti* rec_safe_renderer = manage (new CellRendererPixbufMulti ());
132 rec_safe_renderer->set_pixbuf (0, ::get_icon("rec-safe-disabled"));
133 rec_safe_renderer->set_pixbuf (1, ::get_icon("rec-safe-enabled"));
134 rec_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_safe_toggled));
136 rec_safe_column = manage (new TreeViewColumn(_("RS"), *rec_safe_renderer));
137 rec_safe_column->add_attribute(rec_safe_renderer->property_state(), _columns.rec_safe);
138 rec_safe_column->add_attribute(rec_safe_renderer->property_visible(), _columns.is_track);
139 rec_safe_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
140 rec_safe_column->set_alignment(ALIGN_CENTER);
141 rec_safe_column->set_expand(false);
142 rec_safe_column->set_fixed_width(column_width);
147 CellRendererPixbufMulti* input_active_col_renderer = manage (new CellRendererPixbufMulti());
148 input_active_col_renderer->set_pixbuf (0, ::get_icon("midi-input-inactive"));
149 input_active_col_renderer->set_pixbuf (1, ::get_icon("midi-input-active"));
150 input_active_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_input_active_changed));
152 input_active_column = manage (new TreeViewColumn ("I", *input_active_col_renderer));
154 input_active_column->add_attribute(input_active_col_renderer->property_state(), _columns.is_input_active);
155 input_active_column->add_attribute (input_active_col_renderer->property_visible(), _columns.is_midi);
157 input_active_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
158 input_active_column->set_alignment(ALIGN_CENTER);
159 input_active_column->set_expand(false);
160 input_active_column->set_fixed_width(column_width);
162 // Mute enable toggle
163 CellRendererPixbufMulti* mute_col_renderer = manage (new CellRendererPixbufMulti());
165 mute_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("mute-disabled"));
166 mute_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("muted-by-others"));
167 mute_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("mute-enabled"));
168 mute_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_mute_enable_toggled));
170 mute_state_column = manage (new TreeViewColumn("M", *mute_col_renderer));
172 mute_state_column->add_attribute(mute_col_renderer->property_state(), _columns.mute_state);
173 mute_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
174 mute_state_column->set_alignment(ALIGN_CENTER);
175 mute_state_column->set_expand(false);
176 mute_state_column->set_fixed_width(15);
178 // Solo enable toggle
179 CellRendererPixbufMulti* solo_col_renderer = manage (new CellRendererPixbufMulti());
181 solo_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("solo-disabled"));
182 solo_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("solo-enabled"));
183 solo_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("soloed-by-others"));
184 solo_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_enable_toggled));
186 solo_state_column = manage (new TreeViewColumn("S", *solo_col_renderer));
188 solo_state_column->add_attribute(solo_col_renderer->property_state(), _columns.solo_state);
189 solo_state_column->add_attribute(solo_col_renderer->property_visible(), _columns.solo_visible);
190 solo_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
191 solo_state_column->set_alignment(ALIGN_CENTER);
192 solo_state_column->set_expand(false);
193 solo_state_column->set_fixed_width(column_width);
195 // Solo isolate toggle
196 CellRendererPixbufMulti* solo_iso_renderer = manage (new CellRendererPixbufMulti());
198 solo_iso_renderer->set_pixbuf (0, ::get_icon("solo-isolate-disabled"));
199 solo_iso_renderer->set_pixbuf (1, ::get_icon("solo-isolate-enabled"));
200 solo_iso_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_isolate_toggled));
202 solo_isolate_state_column = manage (new TreeViewColumn("SI", *solo_iso_renderer));
204 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_state(), _columns.solo_isolate_state);
205 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_visible(), _columns.solo_lock_iso_visible);
206 solo_isolate_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
207 solo_isolate_state_column->set_alignment(ALIGN_CENTER);
208 solo_isolate_state_column->set_expand(false);
209 solo_isolate_state_column->set_fixed_width(column_width);
212 CellRendererPixbufMulti* solo_safe_renderer = manage (new CellRendererPixbufMulti ());
214 solo_safe_renderer->set_pixbuf (0, ::get_icon("solo-safe-disabled"));
215 solo_safe_renderer->set_pixbuf (1, ::get_icon("solo-safe-enabled"));
216 solo_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_safe_toggled));
218 solo_safe_state_column = manage (new TreeViewColumn(_("SS"), *solo_safe_renderer));
219 solo_safe_state_column->add_attribute(solo_safe_renderer->property_state(), _columns.solo_safe_state);
220 solo_safe_state_column->add_attribute(solo_safe_renderer->property_visible(), _columns.solo_lock_iso_visible);
221 solo_safe_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
222 solo_safe_state_column->set_alignment(ALIGN_CENTER);
223 solo_safe_state_column->set_expand(false);
224 solo_safe_state_column->set_fixed_width(column_width);
226 _name_column = _display.append_column ("", _columns.text) - 1;
227 _visible_column = _display.append_column ("", _columns.visible) - 1;
228 _active_column = _display.append_column ("", _columns.active) - 1;
230 name_column = _display.get_column (_name_column);
231 visible_column = _display.get_column (_visible_column);
232 active_column = _display.get_column (_active_column);
234 _display.append_column (*input_active_column);
235 _display.append_column (*rec_state_column);
236 _display.append_column (*rec_safe_column);
237 _display.append_column (*mute_state_column);
238 _display.append_column (*solo_state_column);
239 _display.append_column (*solo_isolate_state_column);
240 _display.append_column (*solo_safe_state_column);
247 { 0, _("Name"), _("Track/Bus Name") },
248 { 1, S_("Visible|V"), _("Track/Bus visible ?") },
249 { 2, S_("Active|A"), _("Track/Bus active ?") },
250 { 3, S_("MidiInput|I"), _("MIDI input enabled") },
251 { 4, S_("Rec|R"), _("Record enabled") },
252 { 5, S_("Rec|RS"), _("Record Safe") },
253 { 6, S_("Mute|M"), _("Muted") },
254 { 7, S_("Solo|S"), _("Soloed") },
255 { 8, S_("SoloIso|SI"), _("Solo Isolated") },
256 { 9, S_("SoloLock|SS"), _("Solo Safe (Locked)") },
260 for (int i = 0; ci[i].index >= 0; ++i) {
261 col = _display.get_column (ci[i].index);
262 l = manage (new Label (ci[i].label));
263 set_tooltip (*l, ci[i].tooltip);
264 col->set_widget (*l);
268 _display.set_headers_visible (true);
269 _display.get_selection()->set_mode (SELECTION_MULTIPLE);
270 _display.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::selection_changed));
271 _display.set_reorderable (true);
272 _display.set_name (X_("EditGroupList"));
273 _display.set_rules_hint (true);
274 _display.set_size_request (100, -1);
276 CellRendererText* name_cell = dynamic_cast<CellRendererText*> (_display.get_column_cell_renderer (_name_column));
279 name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit_started));
281 TreeViewColumn* name_column = _display.get_column (_name_column);
283 assert (name_column);
285 name_column->add_attribute (name_cell->property_editable(), _columns.name_editable);
286 name_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
287 name_column->set_expand(true);
288 name_column->set_min_width(50);
290 name_cell->property_editable() = true;
291 name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit));
293 // Set the visible column cell renderer to radio toggle
294 CellRendererToggle* visible_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_visible_column));
296 visible_cell->property_activatable() = true;
297 visible_cell->property_radio() = false;
298 visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::visible_changed));
300 TreeViewColumn* visible_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_visible_column));
301 visible_col->set_expand(false);
302 visible_col->set_sizing(TREE_VIEW_COLUMN_FIXED);
303 visible_col->set_fixed_width(30);
304 visible_col->set_alignment(ALIGN_CENTER);
306 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_active_column));
308 active_cell->property_activatable() = true;
309 active_cell->property_radio() = false;
310 active_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::active_changed));
312 TreeViewColumn* active_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_active_column));
313 active_col->set_expand (false);
314 active_col->set_sizing (TREE_VIEW_COLUMN_FIXED);
315 active_col->set_fixed_width (30);
316 active_col->set_alignment (ALIGN_CENTER);
317 active_col->add_attribute (active_cell->property_visible(), _columns.no_vca);
319 _model->signal_row_deleted().connect (sigc::mem_fun (*this, &EditorRoutes::row_deleted));
320 _model->signal_rows_reordered().connect (sigc::mem_fun (*this, &EditorRoutes::reordered));
322 _display.signal_button_press_event().connect (sigc::mem_fun (*this, &EditorRoutes::button_press), false);
323 _display.signal_button_release_event().connect (sigc::mem_fun (*this, &EditorRoutes::button_release), false);
324 _scroller.signal_key_press_event().connect (sigc::mem_fun(*this, &EditorRoutes::key_press), false);
326 _scroller.signal_focus_in_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_in), false);
327 _scroller.signal_focus_out_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_out));
329 _display.signal_enter_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::enter_notify), false);
330 _display.signal_leave_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::leave_notify), false);
332 _display.set_enable_search (false);
334 Route::PluginSetup.connect_same_thread (*this, boost::bind (&EditorRoutes::plugin_setup, this, _1, _2, _3));
337 EditorRoutes::~EditorRoutes ()
343 EditorRoutes::focus_in (GdkEventFocus*)
345 Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ());
348 old_focus = win->get_focus ();
355 /* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
360 EditorRoutes::focus_out (GdkEventFocus*)
363 old_focus->grab_focus ();
371 EditorRoutes::enter_notify (GdkEventCrossing*)
377 Keyboard::magic_widget_grab_focus ();
382 EditorRoutes::leave_notify (GdkEventCrossing*)
385 old_focus->grab_focus ();
389 Keyboard::magic_widget_drop_focus ();
394 EditorRoutes::set_session (Session* s)
396 SessionHandlePtr::set_session (s);
401 _session->SoloChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::solo_changed_so_update_mute, this), gui_context());
402 _session->RecordStateChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
404 /* TODO: check if these needs to be tied in with DisplaySuspender
405 * Given that the UI is single-threaded and DisplaySuspender is only used
406 * in loops in the UI thread all should be fine.
408 _session->BatchUpdateStart.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::suspend_redisplay, this), gui_context());
409 _session->BatchUpdateEnd.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::resume_redisplay, this), gui_context());
414 EditorRoutes::on_input_active_changed (std::string const & path_string)
416 // Get the model row that has been toggled.
417 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
419 TimeAxisView* tv = row[_columns.tv];
420 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
423 boost::shared_ptr<MidiTrack> mt;
424 mt = rtv->midi_track();
426 mt->set_input_active (!mt->input_active());
432 EditorRoutes::on_tv_rec_enable_changed (std::string const & path_string)
434 // Get the model row that has been toggled.
435 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
437 TimeAxisView* tv = row[_columns.tv];
438 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
440 if (!stv || !stv->stripable()) {
444 boost::shared_ptr<AutomationControl> ac = stv->stripable()->rec_enable_control();
447 ac->set_value (!ac->get_value(), Controllable::UseGroup);
452 EditorRoutes::on_tv_rec_safe_toggled (std::string const & path_string)
454 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
455 TimeAxisView* tv = row[_columns.tv];
456 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
458 if (!stv || !stv->stripable()) {
462 boost::shared_ptr<AutomationControl> ac (stv->stripable()->rec_safe_control());
465 ac->set_value (!ac->get_value(), Controllable::UseGroup);
470 EditorRoutes::on_tv_mute_enable_toggled (std::string const & path_string)
472 // Get the model row that has been toggled.
473 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
475 TimeAxisView *tv = row[_columns.tv];
476 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
478 if (!stv || !stv->stripable()) {
482 boost::shared_ptr<AutomationControl> ac (stv->stripable()->mute_control());
485 ac->set_value (!ac->get_value(), Controllable::UseGroup);
490 EditorRoutes::on_tv_solo_enable_toggled (std::string const & path_string)
492 // Get the model row that has been toggled.
493 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
495 TimeAxisView *tv = row[_columns.tv];
496 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
498 if (!stv || !stv->stripable()) {
502 boost::shared_ptr<AutomationControl> ac (stv->stripable()->solo_control());
505 ac->set_value (!ac->get_value(), Controllable::UseGroup);
510 EditorRoutes::on_tv_solo_isolate_toggled (std::string const & path_string)
512 // Get the model row that has been toggled.
513 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
515 TimeAxisView *tv = row[_columns.tv];
516 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
518 if (!stv || !stv->stripable()) {
522 boost::shared_ptr<AutomationControl> ac (stv->stripable()->solo_isolate_control());
525 ac->set_value (!ac->get_value(), Controllable::UseGroup);
530 EditorRoutes::on_tv_solo_safe_toggled (std::string const & path_string)
532 // Get the model row that has been toggled.
533 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
535 TimeAxisView *tv = row[_columns.tv];
536 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
538 if (!stv || !stv->stripable()) {
542 boost::shared_ptr<AutomationControl> ac (stv->stripable()->solo_safe_control());
545 ac->set_value (!ac->get_value(), Controllable::UseGroup);
550 EditorRoutes::build_menu ()
552 using namespace Menu_Helpers;
557 MenuList& items = _menu->items();
558 _menu->set_name ("ArdourContextMenu");
560 items.push_back (MenuElem (_("Show All"), sigc::mem_fun (*this, &EditorRoutes::show_all_routes)));
561 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun (*this, &EditorRoutes::hide_all_routes)));
562 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiotracks)));
563 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiotracks)));
564 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_miditracks)));
565 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_miditracks)));
566 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiobus)));
567 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiobus)));
568 items.push_back (MenuElem (_("Only Show Tracks with Regions Under Playhead"), sigc::mem_fun (*this, &EditorRoutes::show_tracks_with_regions_at_playhead)));
572 EditorRoutes::redisplay_real ()
574 TreeModel::Children rows = _model->children();
575 TreeModel::Children::iterator i;
578 /* n will be the count of tracks plus children (updated by TimeAxisView::show_at),
579 * so we will use that to know where to put things.
583 for (n = 0, position = 0, i = rows.begin(); i != rows.end(); ++i) {
584 TimeAxisView *tv = (*i)[_columns.tv];
587 // just a "title" row
591 bool visible = tv->marked_for_display ();
593 /* show or hide the TimeAxisView */
595 position += tv->show_at (position, n, &_editor->edit_controls_vbox);
603 /* whenever we go idle, update the track view list to reflect the new order.
604 * we can't do this here, because we could mess up something that is traversing
605 * the track order and has caused a redisplay of the list.
607 Glib::signal_idle().connect (sigc::mem_fun (*_editor, &Editor::sync_track_view_list_and_routes));
609 _editor->reset_controls_layout_height (position);
610 _editor->reset_controls_layout_width ();
611 _editor->_full_canvas_height = position;
613 if ((_editor->vertical_adjustment.get_value() + _editor->_visible_canvas_height) > _editor->vertical_adjustment.get_upper()) {
615 * We're increasing the size of the canvas while the bottom is visible.
616 * We scroll down to keep in step with the controls layout.
618 _editor->vertical_adjustment.set_value (_editor->_full_canvas_height - _editor->_visible_canvas_height);
623 EditorRoutes::redisplay ()
625 if (!_session || _session->deletion_in_progress()) {
630 _redisplay_on_resume = true;
634 // model deprecated g_atomic_int_exchange_and_add(, 1)
635 g_atomic_int_inc(const_cast<gint*>(&_redisplay_active));
636 if (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 1)) {
637 /* recursive re-display can happen if redisplay shows/hides a TrackView
638 * which has children and their display status changes as result.
645 while (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 0)) {
646 g_atomic_int_set(const_cast<gint*>(&_redisplay_active), 1);
652 EditorRoutes::row_deleted (Gtk::TreeModel::Path const &)
654 if (!_session || _session->deletion_in_progress()) {
657 /* this happens as the second step of a DnD within the treeview, and
658 * when a route is actually removed. we don't differentiate between
661 * note that the sync_presentation_info_from_treeview() step may not
662 * actually change any presentation info (e.g. the last track may be
663 * removed, so all other tracks keep the same presentation info), which
664 * means that no redisplay would happen. so we have to force a
668 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview row deleted\n");
671 sync_presentation_info_from_treeview ();
675 EditorRoutes::reordered (TreeModel::Path const &, TreeModel::iterator const &, int* /*what*/)
677 /* reordering implies that RID's will change, so
678 sync_presentation_info_from_treeview() will cause a redisplay.
681 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview reordered\n");
682 sync_presentation_info_from_treeview ();
686 EditorRoutes::visible_changed (std::string const & path)
688 if (_session && _session->deletion_in_progress()) {
695 if ((iter = _model->get_iter (path))) {
696 TimeAxisView* tv = (*iter)[_columns.tv];
698 bool visible = (*iter)[_columns.visible];
700 if (tv->set_marked_for_display (!visible)) {
701 update_visibility ();
708 EditorRoutes::active_changed (std::string const & path)
710 if (_session && _session->deletion_in_progress ()) {
714 Gtk::TreeModel::Row row = *_model->get_iter (path);
715 boost::shared_ptr<Stripable> stripable = row[_columns.stripable];
716 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
718 bool const active = row[_columns.active];
719 route->set_active (!active, this);
724 EditorRoutes::time_axis_views_added (list<TimeAxisView*> tavs)
726 PBD::Unwinder<bool> at (_adding_routes, true);
727 bool from_scratch = (_model->children().size() == 0);
728 Gtk::TreeModel::Children::iterator insert_iter = _model->children().end();
730 for (Gtk::TreeModel::Children::iterator it = _model->children().begin(); it != _model->children().end(); ++it) {
732 boost::shared_ptr<Stripable> r = (*it)[_columns.stripable];
734 if (r->presentation_info().order() == (tavs.front()->stripable()->presentation_info().order() + tavs.size())) {
741 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
742 _display.set_model (Glib::RefPtr<ListStore>());
745 for (list<TimeAxisView*>::iterator x = tavs.begin(); x != tavs.end(); ++x) {
747 VCATimeAxisView* vtav = dynamic_cast<VCATimeAxisView*> (*x);
748 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (*x);
750 TreeModel::Row row = *(_model->insert (insert_iter));
752 boost::shared_ptr<Stripable> stripable;
753 boost::shared_ptr<MidiTrack> midi_trk;
757 stripable = vtav->vca();
759 row[_columns.is_track] = false;
760 row[_columns.is_input_active] = false;
761 row[_columns.is_midi] = false;
762 row[_columns.no_vca] = false;
766 stripable = rtav->route ();
767 midi_trk= boost::dynamic_pointer_cast<MidiTrack> (stripable);
769 row[_columns.is_track] = (boost::dynamic_pointer_cast<Track> (stripable) != 0);
770 row[_columns.no_vca] = true;
773 row[_columns.is_input_active] = midi_trk->input_active ();
774 row[_columns.is_midi] = true;
776 row[_columns.is_input_active] = false;
777 row[_columns.is_midi] = false;
785 row[_columns.text] = stripable->name();
786 row[_columns.visible] = (*x)->marked_for_display();
787 row[_columns.active] = true;
788 row[_columns.tv] = *x;
789 row[_columns.stripable] = stripable;
790 row[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
791 row[_columns.solo_state] = RouteUI::solo_active_state (stripable);
792 row[_columns.solo_visible] = !stripable->is_master ();
793 row[_columns.solo_lock_iso_visible] = row[_columns.solo_visible] && row[_columns.no_vca];
794 row[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable);
795 row[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable);
796 row[_columns.name_editable] = true;
798 boost::weak_ptr<Stripable> ws (stripable);
800 /* for now, we need both of these. PropertyChanged covers on
801 * pre-defined, "global" things of interest to a
802 * UI. gui_changed covers arbitrary, un-enumerated, un-typed
803 * changes that may only be of interest to a particular
804 * UI (e.g. track-height is not of any relevant to OSC)
807 stripable->gui_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::handle_gui_changes, this, _1, _2), gui_context());
808 stripable->PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, ws), gui_context());
809 stripable->presentation_info().PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, ws), gui_context());
811 if (boost::dynamic_pointer_cast<Track> (stripable)) {
812 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (stripable);
813 t->rec_enable_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
814 t->rec_safe_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
818 midi_trk->StepEditStatusChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
819 midi_trk->InputActiveChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_input_active_display, this), gui_context());
822 boost::shared_ptr<AutomationControl> ac;
824 if ((ac = stripable->mute_control()) != 0) {
825 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_mute_display, this), gui_context());
827 if ((ac = stripable->solo_control()) != 0) {
828 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_display, this), gui_context());
830 if ((ac = stripable->solo_isolate_control()) != 0) {
831 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_isolate_display, this), gui_context());
833 if ((ac = stripable->solo_safe_control()) != 0) {
834 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_safe_display, this), gui_context());
838 rtav->route()->active_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_active_display, this), gui_context ());
842 update_rec_display ();
843 update_mute_display ();
844 update_solo_display ();
845 update_solo_isolate_display ();
846 update_solo_safe_display ();
847 update_input_active_display ();
848 update_active_display ();
851 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
852 _display.set_model (_model);
855 /* now update route order keys from the treeview/track display order */
858 sync_presentation_info_from_treeview ();
865 EditorRoutes::handle_gui_changes (string const & what, void*)
867 if (_adding_routes) {
871 if (what == "track_height") {
872 /* Optional :make tracks change height while it happens, instead
878 if (what == "visible_tracks") {
884 EditorRoutes::route_removed (TimeAxisView *tv)
886 ENSURE_GUI_THREAD (*this, &EditorRoutes::route_removed, tv)
888 TreeModel::Children rows = _model->children();
889 TreeModel::Children::iterator ri;
891 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
893 for (ri = rows.begin(); ri != rows.end(); ++ri) {
894 if ((*ri)[_columns.tv] == tv) {
895 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
903 EditorRoutes::route_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> s)
905 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
909 if (_adding_routes) {
913 boost::shared_ptr<Stripable> stripable = s.lock ();
919 TreeModel::Children rows = _model->children();
920 TreeModel::Children::iterator i;
922 for (i = rows.begin(); i != rows.end(); ++i) {
924 boost::shared_ptr<Stripable> ss = (*i)[_columns.stripable];
926 if (ss == stripable) {
928 if (what_changed.contains (ARDOUR::Properties::name)) {
929 (*i)[_columns.text] = stripable->name();
933 if (what_changed.contains (ARDOUR::Properties::hidden)) {
934 (*i)[_columns.visible] = !stripable->presentation_info().hidden();
945 EditorRoutes::update_active_display ()
947 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
948 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
953 EditorRoutes::update_visibility ()
955 TreeModel::Children rows = _model->children();
956 TreeModel::Children::iterator i;
960 for (i = rows.begin(); i != rows.end(); ++i) {
961 TimeAxisView *tv = (*i)[_columns.tv];
962 (*i)[_columns.visible] = tv->marked_for_display ();
965 /* force route order keys catch up with visibility changes */
967 sync_presentation_info_from_treeview ();
971 EditorRoutes::hide_track_in_display (TimeAxisView& tv)
973 TreeModel::Children rows = _model->children();
974 TreeModel::Children::iterator i;
976 for (i = rows.begin(); i != rows.end(); ++i) {
977 if ((*i)[_columns.tv] == &tv) {
978 tv.set_marked_for_display (false);
979 (*i)[_columns.visible] = false;
987 EditorRoutes::show_track_in_display (TimeAxisView& tv)
989 TreeModel::Children rows = _model->children();
990 TreeModel::Children::iterator i;
993 for (i = rows.begin(); i != rows.end(); ++i) {
994 if ((*i)[_columns.tv] == &tv) {
995 tv.set_marked_for_display (true);
996 (*i)[_columns.visible] = true;
1004 EditorRoutes::sync_presentation_info_from_treeview ()
1006 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
1010 TreeModel::Children rows = _model->children();
1016 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync presentation info from treeview\n");
1018 bool change = false;
1019 PresentationInfo::order_t order = 0;
1021 PresentationInfo::ChangeSuspender cs;
1023 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) {
1024 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1025 bool visible = (*ri)[_columns.visible];
1027 #ifndef NDEBUG // these should not exist in the treeview
1029 if (stripable->is_monitor() || stripable->is_auditioner()) {
1035 stripable->presentation_info().set_hidden (!visible);
1037 if (order != stripable->presentation_info().order()) {
1038 stripable->set_presentation_order (order);
1044 change |= _session->ensure_stripable_sort_order ();
1047 _session->set_dirty();
1052 EditorRoutes::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
1054 /* Some route order key(s) have been changed, make sure that
1055 we update out tree/list model and GUI to reflect the change.
1058 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
1062 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync model from presentation info.\n");
1064 PropertyChange hidden_or_order;
1065 hidden_or_order.add (Properties::hidden);
1066 hidden_or_order.add (Properties::order);
1068 TreeModel::Children rows = _model->children();
1070 bool changed = false;
1072 if (what_changed.contains (hidden_or_order)) {
1073 vector<int> neworder;
1074 uint32_t old_order = 0;
1080 TreeOrderKeys sorted;
1081 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
1082 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1083 /* use global order */
1084 sorted.push_back (TreeOrderKey (old_order, stripable));
1087 TreeOrderKeySorter cmp;
1089 sort (sorted.begin(), sorted.end(), cmp);
1090 neworder.assign (sorted.size(), 0);
1094 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
1096 neworder[n] = sr->old_display_order;
1098 if (sr->old_display_order != n) {
1104 Unwinder<bool> uw (_ignore_reorder, true);
1105 /* prevent traverse_cells: assertion 'row_path != NULL'
1106 * in case of DnD re-order: row-removed + row-inserted.
1108 * The rows (stripables) are not actually removed from the model,
1109 * but only from the display in the DnDTreeView.
1110 * ->reorder() will fail to find the row_path.
1111 * (re-order drag -> remove row -> sync PI from TV -> notify -> sync TV from PI -> crash)
1113 Unwinder<bool> uw2 (_ignore_selection_change, true);
1115 _display.unset_model();
1116 _model->reorder (neworder);
1117 _display.set_model (_model);
1121 if (changed || what_changed.contains (Properties::selected)) {
1122 /* by the time this is invoked, the GUI Selection model has
1123 * already updated itself.
1125 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
1127 /* set the treeview model selection state */
1128 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) {
1129 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1130 if (stripable && stripable->is_selected()) {
1131 _display.get_selection()->select (*ri);
1133 _display.get_selection()->unselect (*ri);
1142 EditorRoutes::hide_all_tracks (bool /*with_select*/)
1144 TreeModel::Children rows = _model->children();
1145 TreeModel::Children::iterator i;
1147 DisplaySuspender ds;
1149 for (i = rows.begin(); i != rows.end(); ++i) {
1151 TreeModel::Row row = (*i);
1152 TimeAxisView *tv = row[_columns.tv];
1158 row[_columns.visible] = false;
1163 EditorRoutes::set_all_tracks_visibility (bool yn)
1165 TreeModel::Children rows = _model->children();
1166 TreeModel::Children::iterator i;
1168 DisplaySuspender ds;
1170 for (i = rows.begin(); i != rows.end(); ++i) {
1172 TreeModel::Row row = (*i);
1173 TimeAxisView* tv = row[_columns.tv];
1179 tv->set_marked_for_display (yn);
1180 (*i)[_columns.visible] = yn;
1183 /* force route order keys catch up with visibility changes
1186 sync_presentation_info_from_treeview ();
1190 EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn)
1192 TreeModel::Children rows = _model->children();
1193 TreeModel::Children::iterator i;
1195 DisplaySuspender ds;
1197 for (i = rows.begin(); i != rows.end(); ++i) {
1199 TreeModel::Row row = (*i);
1200 TimeAxisView* tv = row[_columns.tv];
1202 AudioTimeAxisView* atv;
1203 MidiTimeAxisView* mtv;
1209 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1212 atv->set_marked_for_display (yn);
1213 (*i)[_columns.visible] = yn;
1217 if (atv->is_audio_track()) {
1218 atv->set_marked_for_display (yn);
1219 (*i)[_columns.visible] = yn;
1224 if (!atv->is_audio_track()) {
1225 atv->set_marked_for_display (yn);
1226 (*i)[_columns.visible] = yn;
1231 else if ((mtv = dynamic_cast<MidiTimeAxisView*>(tv)) != 0) {
1234 mtv->set_marked_for_display (yn);
1235 (*i)[_columns.visible] = yn;
1239 if (mtv->is_midi_track()) {
1240 mtv->set_marked_for_display (yn);
1241 (*i)[_columns.visible] = yn;
1248 /* force route order keys catch up with visibility changes
1251 sync_presentation_info_from_treeview ();
1255 EditorRoutes::hide_all_routes ()
1257 set_all_tracks_visibility (false);
1261 EditorRoutes::show_all_routes ()
1263 set_all_tracks_visibility (true);
1267 EditorRoutes::show_all_audiotracks()
1269 set_all_audio_midi_visibility (1, true);
1272 EditorRoutes::hide_all_audiotracks ()
1274 set_all_audio_midi_visibility (1, false);
1278 EditorRoutes::show_all_audiobus ()
1280 set_all_audio_midi_visibility (2, true);
1283 EditorRoutes::hide_all_audiobus ()
1285 set_all_audio_midi_visibility (2, false);
1289 EditorRoutes::show_all_miditracks()
1291 set_all_audio_midi_visibility (3, true);
1294 EditorRoutes::hide_all_miditracks ()
1296 set_all_audio_midi_visibility (3, false);
1300 EditorRoutes::key_press (GdkEventKey* ev)
1302 TreeViewColumn *col;
1303 boost::shared_ptr<RouteList> rl (new RouteList);
1306 switch (ev->keyval) {
1308 case GDK_ISO_Left_Tab:
1310 /* If we appear to be editing something, leave that cleanly and appropriately. */
1311 if (name_editable) {
1312 name_editable->editing_done ();
1316 col = _display.get_column (_name_column); // select&focus on name column
1318 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
1319 treeview_select_previous (_display, _model, col);
1321 treeview_select_next (_display, _model, col);
1328 if (get_relevant_routes (rl)) {
1329 _session->set_controls (route_list_to_control_list (rl, &Stripable::mute_control), rl->front()->muted() ? 0.0 : 1.0, Controllable::NoGroup);
1335 if (get_relevant_routes (rl)) {
1336 _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), rl->front()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
1342 if (get_relevant_routes (rl)) {
1343 for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
1344 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*r);
1346 _session->set_controls (route_list_to_control_list (rl, &Stripable::rec_enable_control), !t->rec_enable_control()->get_value(), Controllable::NoGroup);
1361 EditorRoutes::get_relevant_routes (boost::shared_ptr<RouteList> rl)
1364 RouteTimeAxisView* rtv;
1365 RefPtr<TreeSelection> selection = _display.get_selection();
1369 if (selection->count_selected_rows() != 0) {
1373 RefPtr<TreeModel> tm = RefPtr<TreeModel>::cast_dynamic (_model);
1374 iter = selection->get_selected (tm);
1377 /* use mouse pointer */
1382 _display.get_pointer (x, y);
1383 _display.convert_widget_to_bin_window_coords (x, y, bx, by);
1385 if (_display.get_path_at_pos (bx, by, path)) {
1386 iter = _model->get_iter (path);
1391 tv = (*iter)[_columns.tv];
1393 rtv = dynamic_cast<RouteTimeAxisView*>(tv);
1395 rl->push_back (rtv->route());
1400 return !rl->empty();
1404 EditorRoutes::select_function(const Glib::RefPtr<Gtk::TreeModel>&, const Gtk::TreeModel::Path&, bool)
1406 return !column_does_not_select;
1410 EditorRoutes::button_release (GdkEventButton*)
1412 column_does_not_select = false;
1417 EditorRoutes::button_press (GdkEventButton* ev)
1419 if (Keyboard::is_context_menu_event (ev)) {
1423 _menu->popup (ev->button, ev->time);
1427 TreeModel::Path path;
1428 TreeViewColumn *tvc;
1432 if (!_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, tvc, cell_x, cell_y)) {
1433 /* cancel selection */
1434 _display.get_selection()->unselect_all ();
1435 /* end any editing by grabbing focus */
1436 _display.grab_focus ();
1440 if ((tvc == rec_state_column) ||
1441 (tvc == rec_safe_column) ||
1442 (tvc == input_active_column) ||
1443 (tvc == mute_state_column) ||
1444 (tvc == solo_state_column) ||
1445 (tvc == solo_safe_state_column) ||
1446 (tvc == solo_isolate_state_column) ||
1447 (tvc == visible_column) ||
1448 (tvc == active_column)) {
1449 column_does_not_select = true;
1452 //Scroll editor canvas to selected track
1453 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1455 Gtk::TreeModel::Row row = *_model->get_iter (path);
1456 TimeAxisView *tv = row[_columns.tv];
1459 _editor->ensure_time_axis_view_is_visible (*tv, true);
1467 EditorRoutes::selection_changed ()
1469 if (_ignore_selection_change || column_does_not_select) {
1473 _editor->begin_reversible_selection_op (X_("Select Track from Route List"));
1475 if (_display.get_selection()->count_selected_rows() > 0) {
1478 TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
1479 TrackViewList selected;
1481 for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
1483 if ((iter = _model->get_iter (*i))) {
1485 TimeAxisView* tv = (*iter)[_columns.tv];
1486 selected.push_back (tv);
1491 _editor->get_selection().set (selected);
1492 _editor->ensure_time_axis_view_is_visible (*(selected.front()), true);
1495 _editor->get_selection().clear_tracks ();
1498 _editor->commit_reversible_selection_op ();
1502 EditorRoutes::initial_display ()
1510 DisplaySuspender ds;
1515 _session->get_stripables (s);
1516 _editor->add_stripables (s);
1518 sync_treeview_from_presentation_info (Properties::order);
1521 struct ViewStripable {
1523 boost::shared_ptr<Stripable> stripable;
1525 ViewStripable (TimeAxisView* t, boost::shared_ptr<Stripable> s)
1526 : tav (t), stripable (s) {}
1530 EditorRoutes::move_selected_tracks (bool up)
1532 TimeAxisView* scroll_to = 0;
1534 _session->get_stripables (sl);
1536 if (sl.size() < 2) {
1541 sl.sort (Stripable::Sorter());
1543 std::list<ViewStripable> view_stripables;
1545 /* build a list that includes time axis view information */
1547 for (StripableList::const_iterator sli = sl.begin(); sli != sl.end(); ++sli) {
1548 TimeAxisView* tv = _editor->time_axis_view_from_stripable (*sli);
1549 view_stripables.push_back (ViewStripable (tv, *sli));
1552 /* for each selected stripable, move it above or below the adjacent
1553 * stripable that has a time-axis view representation here. If there's
1554 * no such representation, then
1557 list<ViewStripable>::iterator unselected_neighbour;
1558 list<ViewStripable>::iterator vsi;
1561 PresentationInfo::ChangeSuspender cs;
1564 unselected_neighbour = view_stripables.end ();
1565 vsi = view_stripables.begin();
1567 while (vsi != view_stripables.end()) {
1569 if (vsi->stripable->is_selected()) {
1571 if (unselected_neighbour != view_stripables.end()) {
1573 PresentationInfo::order_t unselected_neighbour_order = unselected_neighbour->stripable->presentation_info().order();
1574 PresentationInfo::order_t my_order = vsi->stripable->presentation_info().order();
1576 unselected_neighbour->stripable->set_presentation_order (my_order);
1577 vsi->stripable->set_presentation_order (unselected_neighbour_order);
1580 scroll_to = vsi->tav;
1587 unselected_neighbour = vsi;
1597 unselected_neighbour = view_stripables.end();
1598 vsi = unselected_neighbour;
1604 if (vsi->stripable->is_selected()) {
1606 if (unselected_neighbour != view_stripables.end()) {
1608 PresentationInfo::order_t unselected_neighbour_order = unselected_neighbour->stripable->presentation_info().order();
1609 PresentationInfo::order_t my_order = vsi->stripable->presentation_info().order();
1611 unselected_neighbour->stripable->set_presentation_order (my_order);
1612 vsi->stripable->set_presentation_order (unselected_neighbour_order);
1615 scroll_to = vsi->tav;
1622 unselected_neighbour = vsi;
1627 } while (vsi != view_stripables.begin());
1632 _editor->ensure_time_axis_view_is_visible (*scroll_to, false);
1637 EditorRoutes::update_input_active_display ()
1639 TreeModel::Children rows = _model->children();
1640 TreeModel::Children::iterator i;
1642 for (i = rows.begin(); i != rows.end(); ++i) {
1643 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1645 if (boost::dynamic_pointer_cast<Track> (stripable)) {
1646 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (stripable);
1649 (*i)[_columns.is_input_active] = mt->input_active();
1656 EditorRoutes::update_rec_display ()
1658 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1659 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1664 EditorRoutes::idle_update_mute_rec_solo_etc()
1666 g_atomic_int_set (const_cast<gint*>(&_queue_tv_update), 0);
1667 TreeModel::Children rows = _model->children();
1668 TreeModel::Children::iterator i;
1670 for (i = rows.begin(); i != rows.end(); ++i) {
1671 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1672 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
1673 (*i)[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
1674 (*i)[_columns.solo_state] = RouteUI::solo_active_state (stripable);
1675 (*i)[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable) ? 1 : 0;
1676 (*i)[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable) ? 1 : 0;
1678 (*i)[_columns.active] = route->active ();
1680 (*i)[_columns.active] = true;
1683 boost::shared_ptr<Track> trk (boost::dynamic_pointer_cast<Track>(route));
1686 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
1688 if (trk->rec_enable_control()->get_value()) {
1689 if (_session->record_status() == Session::Recording) {
1690 (*i)[_columns.rec_state] = 1;
1692 (*i)[_columns.rec_state] = 2;
1694 } else if (mt && mt->step_editing()) {
1695 (*i)[_columns.rec_state] = 3;
1697 (*i)[_columns.rec_state] = 0;
1700 (*i)[_columns.rec_safe] = trk->rec_safe_control()->get_value();
1701 (*i)[_columns.name_editable] = !trk->rec_enable_control()->get_value();
1705 return false; // do not call again (until needed)
1710 EditorRoutes::update_mute_display ()
1712 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1713 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1718 EditorRoutes::update_solo_display ()
1720 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1721 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1726 EditorRoutes::update_solo_isolate_display ()
1728 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1729 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1734 EditorRoutes::update_solo_safe_display ()
1736 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1737 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1742 EditorRoutes::views () const
1744 list<TimeAxisView*> v;
1745 for (TreeModel::Children::iterator i = _model->children().begin(); i != _model->children().end(); ++i) {
1746 v.push_back ((*i)[_columns.tv]);
1753 EditorRoutes::clear ()
1755 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
1756 _display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
1758 _display.set_model (_model);
1762 EditorRoutes::name_edit_started (CellEditable* ce, const Glib::ustring&)
1766 /* give it a special name */
1768 Gtk::Entry *e = dynamic_cast<Gtk::Entry*> (ce);
1771 e->set_name (X_("RouteNameEditorEntry"));
1776 EditorRoutes::name_edit (std::string const & path, std::string const & new_text)
1780 TreeIter iter = _model->get_iter (path);
1786 boost::shared_ptr<Stripable> stripable = (*iter)[_columns.stripable];
1788 if (stripable && stripable->name() != new_text) {
1789 stripable->set_name (new_text);
1794 EditorRoutes::solo_changed_so_update_mute ()
1796 update_mute_display ();
1800 EditorRoutes::show_tracks_with_regions_at_playhead ()
1802 boost::shared_ptr<RouteList> const r = _session->get_routes_with_regions_at (_session->transport_sample ());
1804 set<TimeAxisView*> show;
1805 for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
1806 TimeAxisView* tav = _editor->time_axis_view_from_stripable (*i);
1812 DisplaySuspender ds;
1814 TreeModel::Children rows = _model->children ();
1815 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
1816 TimeAxisView* tv = (*i)[_columns.tv];
1817 bool to_show = (show.find (tv) != show.end());
1819 tv->set_marked_for_display (to_show);
1820 (*i)[_columns.visible] = to_show;
1823 /* force route order keys catch up with visibility changes
1826 sync_presentation_info_from_treeview ();
1830 EditorRoutes::plugin_setup (boost::shared_ptr<Route> r, boost::shared_ptr<PluginInsert> pi, ARDOUR::Route::PluginSetupOptions flags)
1832 PluginSetupDialog psd (r, pi, flags);
1833 int rv = psd.run ();
1834 return rv + (psd.fan_out() ? 4 : 0);