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 , _no_redisplay (false)
89 , _adding_routes (false)
90 , _route_deletion_in_progress (false)
91 , _redisplay_on_resume (false)
92 , _redisplay_active (0)
93 , _queue_tv_update (0)
98 static const int column_width = 22;
100 _scroller.add (_display);
101 _scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
103 _model = ListStore::create (_columns);
104 _display.set_model (_model);
106 // Record enable toggle
107 CellRendererPixbufMulti* rec_col_renderer = manage (new CellRendererPixbufMulti());
109 rec_col_renderer->set_pixbuf (0, ::get_icon("record-normal-disabled"));
110 rec_col_renderer->set_pixbuf (1, ::get_icon("record-normal-in-progress"));
111 rec_col_renderer->set_pixbuf (2, ::get_icon("record-normal-enabled"));
112 rec_col_renderer->set_pixbuf (3, ::get_icon("record-step"));
113 rec_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_enable_changed));
115 TreeViewColumn* rec_state_column = manage (new TreeViewColumn("R", *rec_col_renderer));
117 rec_state_column->add_attribute(rec_col_renderer->property_state(), _columns.rec_state);
118 rec_state_column->add_attribute(rec_col_renderer->property_visible(), _columns.is_track);
120 rec_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
121 rec_state_column->set_alignment(ALIGN_CENTER);
122 rec_state_column->set_expand(false);
123 rec_state_column->set_fixed_width(column_width);
126 // Record safe toggle
127 CellRendererPixbufMulti* rec_safe_renderer = manage (new CellRendererPixbufMulti ());
129 rec_safe_renderer->set_pixbuf (0, ::get_icon("rec-safe-disabled"));
130 rec_safe_renderer->set_pixbuf (1, ::get_icon("rec-safe-enabled"));
131 rec_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_safe_toggled));
133 TreeViewColumn* rec_safe_column = manage (new TreeViewColumn(_("RS"), *rec_safe_renderer));
134 rec_safe_column->add_attribute(rec_safe_renderer->property_state(), _columns.rec_safe);
135 rec_safe_column->add_attribute(rec_safe_renderer->property_visible(), _columns.is_track);
136 rec_safe_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
137 rec_safe_column->set_alignment(ALIGN_CENTER);
138 rec_safe_column->set_expand(false);
139 rec_safe_column->set_fixed_width(column_width);
144 CellRendererPixbufMulti* input_active_col_renderer = manage (new CellRendererPixbufMulti());
145 input_active_col_renderer->set_pixbuf (0, ::get_icon("midi-input-inactive"));
146 input_active_col_renderer->set_pixbuf (1, ::get_icon("midi-input-active"));
147 input_active_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_input_active_changed));
149 TreeViewColumn* input_active_column = manage (new TreeViewColumn ("I", *input_active_col_renderer));
151 input_active_column->add_attribute(input_active_col_renderer->property_state(), _columns.is_input_active);
152 input_active_column->add_attribute (input_active_col_renderer->property_visible(), _columns.is_midi);
154 input_active_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
155 input_active_column->set_alignment(ALIGN_CENTER);
156 input_active_column->set_expand(false);
157 input_active_column->set_fixed_width(column_width);
159 // Mute enable toggle
160 CellRendererPixbufMulti* mute_col_renderer = manage (new CellRendererPixbufMulti());
162 mute_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("mute-disabled"));
163 mute_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("muted-by-others"));
164 mute_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("mute-enabled"));
165 mute_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_mute_enable_toggled));
167 TreeViewColumn* mute_state_column = manage (new TreeViewColumn("M", *mute_col_renderer));
169 mute_state_column->add_attribute(mute_col_renderer->property_state(), _columns.mute_state);
170 mute_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
171 mute_state_column->set_alignment(ALIGN_CENTER);
172 mute_state_column->set_expand(false);
173 mute_state_column->set_fixed_width(15);
175 // Solo enable toggle
176 CellRendererPixbufMulti* solo_col_renderer = manage (new CellRendererPixbufMulti());
178 solo_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("solo-disabled"));
179 solo_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("solo-enabled"));
180 solo_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("soloed-by-others"));
181 solo_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_enable_toggled));
183 TreeViewColumn* solo_state_column = manage (new TreeViewColumn("S", *solo_col_renderer));
185 solo_state_column->add_attribute(solo_col_renderer->property_state(), _columns.solo_state);
186 solo_state_column->add_attribute(solo_col_renderer->property_visible(), _columns.solo_visible);
187 solo_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
188 solo_state_column->set_alignment(ALIGN_CENTER);
189 solo_state_column->set_expand(false);
190 solo_state_column->set_fixed_width(column_width);
192 // Solo isolate toggle
193 CellRendererPixbufMulti* solo_iso_renderer = manage (new CellRendererPixbufMulti());
195 solo_iso_renderer->set_pixbuf (0, ::get_icon("solo-isolate-disabled"));
196 solo_iso_renderer->set_pixbuf (1, ::get_icon("solo-isolate-enabled"));
197 solo_iso_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_isolate_toggled));
199 TreeViewColumn* solo_isolate_state_column = manage (new TreeViewColumn("SI", *solo_iso_renderer));
201 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_state(), _columns.solo_isolate_state);
202 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_visible(), _columns.solo_lock_iso_visible);
203 solo_isolate_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
204 solo_isolate_state_column->set_alignment(ALIGN_CENTER);
205 solo_isolate_state_column->set_expand(false);
206 solo_isolate_state_column->set_fixed_width(column_width);
209 CellRendererPixbufMulti* solo_safe_renderer = manage (new CellRendererPixbufMulti ());
211 solo_safe_renderer->set_pixbuf (0, ::get_icon("solo-safe-disabled"));
212 solo_safe_renderer->set_pixbuf (1, ::get_icon("solo-safe-enabled"));
213 solo_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_safe_toggled));
215 TreeViewColumn* solo_safe_state_column = manage (new TreeViewColumn(_("SS"), *solo_safe_renderer));
216 solo_safe_state_column->add_attribute(solo_safe_renderer->property_state(), _columns.solo_safe_state);
217 solo_safe_state_column->add_attribute(solo_safe_renderer->property_visible(), _columns.solo_lock_iso_visible);
218 solo_safe_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
219 solo_safe_state_column->set_alignment(ALIGN_CENTER);
220 solo_safe_state_column->set_expand(false);
221 solo_safe_state_column->set_fixed_width(column_width);
223 _name_column = _display.append_column ("", _columns.text) - 1;
224 _visible_column = _display.append_column ("", _columns.visible) - 1;
225 _active_column = _display.append_column ("", _columns.active) - 1;
227 _display.append_column (*input_active_column);
228 _display.append_column (*rec_state_column);
229 _display.append_column (*rec_safe_column);
230 _display.append_column (*mute_state_column);
231 _display.append_column (*solo_state_column);
232 _display.append_column (*solo_isolate_state_column);
233 _display.append_column (*solo_safe_state_column);
240 { 0, _("Name"), _("Track/Bus Name") },
241 { 1, S_("Visible|V"), _("Track/Bus visible ?") },
242 { 2, S_("Active|A"), _("Track/Bus active ?") },
243 { 3, S_("MidiInput|I"), _("MIDI input enabled") },
244 { 4, S_("Rec|R"), _("Record enabled") },
245 { 5, S_("Rec|RS"), _("Record Safe") },
246 { 6, S_("Mute|M"), _("Muted") },
247 { 7, S_("Solo|S"), _("Soloed") },
248 { 8, S_("SoloIso|SI"), _("Solo Isolated") },
249 { 9, S_("SoloLock|SS"), _("Solo Safe (Locked)") },
253 for (int i = 0; ci[i].index >= 0; ++i) {
254 col = _display.get_column (ci[i].index);
255 l = manage (new Label (ci[i].label));
256 set_tooltip (*l, ci[i].tooltip);
257 col->set_widget (*l);
261 _display.set_headers_visible (true);
262 _display.get_selection()->set_mode (SELECTION_MULTIPLE);
263 _display.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::selection_changed));
264 _display.set_reorderable (true);
265 _display.set_name (X_("EditGroupList"));
266 _display.set_rules_hint (true);
267 _display.set_size_request (100, -1);
269 CellRendererText* name_cell = dynamic_cast<CellRendererText*> (_display.get_column_cell_renderer (_name_column));
272 name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit_started));
274 TreeViewColumn* name_column = _display.get_column (_name_column);
276 assert (name_column);
278 name_column->add_attribute (name_cell->property_editable(), _columns.name_editable);
279 name_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
280 name_column->set_expand(true);
281 name_column->set_min_width(50);
283 name_cell->property_editable() = true;
284 name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit));
286 // Set the visible column cell renderer to radio toggle
287 CellRendererToggle* visible_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_visible_column));
289 visible_cell->property_activatable() = true;
290 visible_cell->property_radio() = false;
291 visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::visible_changed));
293 TreeViewColumn* visible_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_visible_column));
294 visible_col->set_expand(false);
295 visible_col->set_sizing(TREE_VIEW_COLUMN_FIXED);
296 visible_col->set_fixed_width(30);
297 visible_col->set_alignment(ALIGN_CENTER);
299 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_active_column));
301 active_cell->property_activatable() = true;
302 active_cell->property_radio() = false;
303 active_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::active_changed));
305 TreeViewColumn* active_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_active_column));
306 active_col->set_expand (false);
307 active_col->set_sizing (TREE_VIEW_COLUMN_FIXED);
308 active_col->set_fixed_width (30);
309 active_col->set_alignment (ALIGN_CENTER);
310 active_col->add_attribute (active_cell->property_visible(), _columns.no_vca);
312 _model->signal_row_deleted().connect (sigc::mem_fun (*this, &EditorRoutes::row_deleted));
313 _model->signal_rows_reordered().connect (sigc::mem_fun (*this, &EditorRoutes::reordered));
315 _display.signal_button_press_event().connect (sigc::mem_fun (*this, &EditorRoutes::button_press), false);
316 _scroller.signal_key_press_event().connect (sigc::mem_fun(*this, &EditorRoutes::key_press), false);
318 _scroller.signal_focus_in_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_in), false);
319 _scroller.signal_focus_out_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_out));
321 _display.signal_enter_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::enter_notify), false);
322 _display.signal_leave_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::leave_notify), false);
324 _display.set_enable_search (false);
326 Route::PluginSetup.connect_same_thread (*this, boost::bind (&EditorRoutes::plugin_setup, this, _1, _2, _3));
329 EditorRoutes::~EditorRoutes ()
335 EditorRoutes::focus_in (GdkEventFocus*)
337 Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ());
340 old_focus = win->get_focus ();
347 /* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
352 EditorRoutes::focus_out (GdkEventFocus*)
355 old_focus->grab_focus ();
363 EditorRoutes::enter_notify (GdkEventCrossing*)
369 Keyboard::magic_widget_grab_focus ();
374 EditorRoutes::leave_notify (GdkEventCrossing*)
377 old_focus->grab_focus ();
381 Keyboard::magic_widget_drop_focus ();
386 EditorRoutes::set_session (Session* s)
388 SessionHandlePtr::set_session (s);
393 _session->SoloChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::solo_changed_so_update_mute, this), gui_context());
394 _session->RecordStateChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
396 /* TODO: check if these needs to be tied in with DisplaySuspender
397 * Given that the UI is single-threaded and DisplaySuspender is only used
398 * in loops in the UI thread all should be fine.
400 _session->BatchUpdateStart.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::suspend_redisplay, this), gui_context());
401 _session->BatchUpdateEnd.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::resume_redisplay, this), gui_context());
406 EditorRoutes::on_input_active_changed (std::string const & path_string)
408 // Get the model row that has been toggled.
409 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
411 TimeAxisView* tv = row[_columns.tv];
412 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
415 boost::shared_ptr<MidiTrack> mt;
416 mt = rtv->midi_track();
418 mt->set_input_active (!mt->input_active());
424 EditorRoutes::on_tv_rec_enable_changed (std::string const & path_string)
426 // Get the model row that has been toggled.
427 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
429 TimeAxisView* tv = row[_columns.tv];
430 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
432 if (!stv || !stv->stripable()) {
436 boost::shared_ptr<AutomationControl> ac = stv->stripable()->rec_enable_control();
439 ac->set_value (!ac->get_value(), Controllable::UseGroup);
444 EditorRoutes::on_tv_rec_safe_toggled (std::string const & path_string)
446 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
447 TimeAxisView* tv = row[_columns.tv];
448 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
450 if (!stv || !stv->stripable()) {
454 boost::shared_ptr<AutomationControl> ac (stv->stripable()->rec_safe_control());
457 ac->set_value (!ac->get_value(), Controllable::UseGroup);
462 EditorRoutes::on_tv_mute_enable_toggled (std::string const & path_string)
464 // Get the model row that has been toggled.
465 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
467 TimeAxisView *tv = row[_columns.tv];
468 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
470 if (!stv || !stv->stripable()) {
474 boost::shared_ptr<AutomationControl> ac (stv->stripable()->mute_control());
477 ac->set_value (!ac->get_value(), Controllable::UseGroup);
482 EditorRoutes::on_tv_solo_enable_toggled (std::string const & path_string)
484 // Get the model row that has been toggled.
485 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
487 TimeAxisView *tv = row[_columns.tv];
488 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
490 if (!stv || !stv->stripable()) {
494 boost::shared_ptr<AutomationControl> ac (stv->stripable()->solo_control());
497 ac->set_value (!ac->get_value(), Controllable::UseGroup);
502 EditorRoutes::on_tv_solo_isolate_toggled (std::string const & path_string)
504 // Get the model row that has been toggled.
505 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
507 TimeAxisView *tv = row[_columns.tv];
508 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
510 if (!stv || !stv->stripable()) {
514 boost::shared_ptr<AutomationControl> ac (stv->stripable()->solo_isolate_control());
517 ac->set_value (!ac->get_value(), Controllable::UseGroup);
522 EditorRoutes::on_tv_solo_safe_toggled (std::string const & path_string)
524 // Get the model row that has been toggled.
525 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
527 TimeAxisView *tv = row[_columns.tv];
528 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
530 if (!stv || !stv->stripable()) {
534 boost::shared_ptr<AutomationControl> ac (stv->stripable()->solo_safe_control());
537 ac->set_value (!ac->get_value(), Controllable::UseGroup);
542 EditorRoutes::build_menu ()
544 using namespace Menu_Helpers;
549 MenuList& items = _menu->items();
550 _menu->set_name ("ArdourContextMenu");
552 items.push_back (MenuElem (_("Show All"), sigc::mem_fun (*this, &EditorRoutes::show_all_routes)));
553 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun (*this, &EditorRoutes::hide_all_routes)));
554 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiotracks)));
555 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiotracks)));
556 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_miditracks)));
557 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_miditracks)));
558 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiobus)));
559 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiobus)));
560 items.push_back (MenuElem (_("Only Show Tracks with Regions Under Playhead"), sigc::mem_fun (*this, &EditorRoutes::show_tracks_with_regions_at_playhead)));
564 EditorRoutes::redisplay_real ()
566 TreeModel::Children rows = _model->children();
567 TreeModel::Children::iterator i;
570 /* n will be the count of tracks plus children (updated by TimeAxisView::show_at),
571 * so we will use that to know where to put things.
575 for (n = 0, position = 0, i = rows.begin(); i != rows.end(); ++i) {
576 TimeAxisView *tv = (*i)[_columns.tv];
579 // just a "title" row
583 bool visible = tv->marked_for_display ();
585 /* show or hide the TimeAxisView */
587 position += tv->show_at (position, n, &_editor->edit_controls_vbox);
595 /* whenever we go idle, update the track view list to reflect the new order.
596 * we can't do this here, because we could mess up something that is traversing
597 * the track order and has caused a redisplay of the list.
599 Glib::signal_idle().connect (sigc::mem_fun (*_editor, &Editor::sync_track_view_list_and_routes));
601 _editor->reset_controls_layout_height (position);
602 _editor->reset_controls_layout_width ();
603 _editor->_full_canvas_height = position;
605 if ((_editor->vertical_adjustment.get_value() + _editor->_visible_canvas_height) > _editor->vertical_adjustment.get_upper()) {
607 * We're increasing the size of the canvas while the bottom is visible.
608 * We scroll down to keep in step with the controls layout.
610 _editor->vertical_adjustment.set_value (_editor->_full_canvas_height - _editor->_visible_canvas_height);
615 EditorRoutes::redisplay ()
617 if (!_session || _session->deletion_in_progress()) {
622 _redisplay_on_resume = true;
626 // model deprecated g_atomic_int_exchange_and_add(, 1)
627 g_atomic_int_inc(const_cast<gint*>(&_redisplay_active));
628 if (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 1)) {
629 /* recursive re-display can happen if redisplay shows/hides a TrackView
630 * which has children and their display status changes as result.
637 while (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 0)) {
638 g_atomic_int_set(const_cast<gint*>(&_redisplay_active), 1);
644 EditorRoutes::row_deleted (Gtk::TreeModel::Path const &)
646 if (!_session || _session->deletion_in_progress()) {
649 /* this happens as the second step of a DnD within the treeview, and
650 * when a route is actually removed. we don't differentiate between
653 * note that the sync_presentation_info_from_treeview() step may not
654 * actually change any presentation info (e.g. the last track may be
655 * removed, so all other tracks keep the same presentation info), which
656 * means that no redisplay would happen. so we have to force a
660 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview row deleted\n");
663 sync_presentation_info_from_treeview ();
667 EditorRoutes::reordered (TreeModel::Path const &, TreeModel::iterator const &, int* /*what*/)
669 /* reordering implies that RID's will change, so
670 sync_presentation_info_from_treeview() will cause a redisplay.
673 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview reordered\n");
674 sync_presentation_info_from_treeview ();
678 EditorRoutes::visible_changed (std::string const & path)
680 if (_session && _session->deletion_in_progress()) {
687 if ((iter = _model->get_iter (path))) {
688 TimeAxisView* tv = (*iter)[_columns.tv];
690 bool visible = (*iter)[_columns.visible];
692 if (tv->set_marked_for_display (!visible)) {
693 update_visibility ();
700 EditorRoutes::active_changed (std::string const & path)
702 if (_session && _session->deletion_in_progress ()) {
706 Gtk::TreeModel::Row row = *_model->get_iter (path);
707 boost::shared_ptr<Stripable> stripable = row[_columns.stripable];
708 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
710 bool const active = row[_columns.active];
711 route->set_active (!active, this);
716 EditorRoutes::time_axis_views_added (list<TimeAxisView*> tavs)
718 PBD::Unwinder<bool> at (_adding_routes, true);
719 bool from_scratch = (_model->children().size() == 0);
720 Gtk::TreeModel::Children::iterator insert_iter = _model->children().end();
722 for (Gtk::TreeModel::Children::iterator it = _model->children().begin(); it != _model->children().end(); ++it) {
724 boost::shared_ptr<Stripable> r = (*it)[_columns.stripable];
726 if (r->presentation_info().order() == (tavs.front()->stripable()->presentation_info().order() + tavs.size())) {
733 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
734 _display.set_model (Glib::RefPtr<ListStore>());
737 for (list<TimeAxisView*>::iterator x = tavs.begin(); x != tavs.end(); ++x) {
739 VCATimeAxisView* vtav = dynamic_cast<VCATimeAxisView*> (*x);
740 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (*x);
742 TreeModel::Row row = *(_model->insert (insert_iter));
744 boost::shared_ptr<Stripable> stripable;
745 boost::shared_ptr<MidiTrack> midi_trk;
749 stripable = vtav->vca();
751 row[_columns.is_track] = false;
752 row[_columns.is_input_active] = false;
753 row[_columns.is_midi] = false;
754 row[_columns.no_vca] = false;
758 stripable = rtav->route ();
759 midi_trk= boost::dynamic_pointer_cast<MidiTrack> (stripable);
761 row[_columns.is_track] = (boost::dynamic_pointer_cast<Track> (stripable) != 0);
762 row[_columns.no_vca] = true;
765 row[_columns.is_input_active] = midi_trk->input_active ();
766 row[_columns.is_midi] = true;
768 row[_columns.is_input_active] = false;
769 row[_columns.is_midi] = false;
777 row[_columns.text] = stripable->name();
778 row[_columns.visible] = (*x)->marked_for_display();
779 row[_columns.active] = true;
780 row[_columns.tv] = *x;
781 row[_columns.stripable] = stripable;
782 row[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
783 row[_columns.solo_state] = RouteUI::solo_active_state (stripable);
784 row[_columns.solo_visible] = !stripable->is_master ();
785 row[_columns.solo_lock_iso_visible] = row[_columns.solo_visible] && row[_columns.no_vca];
786 row[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable);
787 row[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable);
788 row[_columns.name_editable] = true;
790 boost::weak_ptr<Stripable> ws (stripable);
792 /* for now, we need both of these. PropertyChanged covers on
793 * pre-defined, "global" things of interest to a
794 * UI. gui_changed covers arbitrary, un-enumerated, un-typed
795 * changes that may only be of interest to a particular
796 * UI (e.g. track-height is not of any relevant to OSC)
799 stripable->gui_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::handle_gui_changes, this, _1, _2), gui_context());
800 stripable->PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, ws), gui_context());
801 stripable->presentation_info().PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, ws), gui_context());
803 if (boost::dynamic_pointer_cast<Track> (stripable)) {
804 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (stripable);
805 t->rec_enable_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
806 t->rec_safe_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
810 midi_trk->StepEditStatusChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
811 midi_trk->InputActiveChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_input_active_display, this), gui_context());
814 boost::shared_ptr<AutomationControl> ac;
816 if ((ac = stripable->mute_control()) != 0) {
817 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_mute_display, this), gui_context());
819 if ((ac = stripable->solo_control()) != 0) {
820 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_display, this), gui_context());
822 if ((ac = stripable->solo_isolate_control()) != 0) {
823 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_isolate_display, this), gui_context());
825 if ((ac = stripable->solo_safe_control()) != 0) {
826 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_safe_display, this), gui_context());
830 rtav->route()->active_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_active_display, this), gui_context ());
834 update_rec_display ();
835 update_mute_display ();
836 update_solo_display ();
837 update_solo_isolate_display ();
838 update_solo_safe_display ();
839 update_input_active_display ();
840 update_active_display ();
843 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
844 _display.set_model (_model);
847 /* now update route order keys from the treeview/track display order */
850 sync_presentation_info_from_treeview ();
857 EditorRoutes::handle_gui_changes (string const & what, void*)
859 if (_adding_routes) {
863 if (what == "track_height") {
864 /* Optional :make tracks change height while it happens, instead
870 if (what == "visible_tracks") {
876 EditorRoutes::route_removed (TimeAxisView *tv)
878 ENSURE_GUI_THREAD (*this, &EditorRoutes::route_removed, tv)
880 TreeModel::Children rows = _model->children();
881 TreeModel::Children::iterator ri;
883 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
885 for (ri = rows.begin(); ri != rows.end(); ++ri) {
886 if ((*ri)[_columns.tv] == tv) {
887 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
895 EditorRoutes::route_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> s)
897 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
901 if (_adding_routes) {
905 boost::shared_ptr<Stripable> stripable = s.lock ();
911 TreeModel::Children rows = _model->children();
912 TreeModel::Children::iterator i;
914 for (i = rows.begin(); i != rows.end(); ++i) {
916 boost::shared_ptr<Stripable> ss = (*i)[_columns.stripable];
918 if (ss == stripable) {
920 if (what_changed.contains (ARDOUR::Properties::name)) {
921 (*i)[_columns.text] = stripable->name();
925 if (what_changed.contains (ARDOUR::Properties::hidden)) {
926 (*i)[_columns.visible] = !stripable->presentation_info().hidden();
937 EditorRoutes::update_active_display ()
939 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
940 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
945 EditorRoutes::update_visibility ()
947 TreeModel::Children rows = _model->children();
948 TreeModel::Children::iterator i;
952 for (i = rows.begin(); i != rows.end(); ++i) {
953 TimeAxisView *tv = (*i)[_columns.tv];
954 (*i)[_columns.visible] = tv->marked_for_display ();
957 /* force route order keys catch up with visibility changes */
959 sync_presentation_info_from_treeview ();
963 EditorRoutes::hide_track_in_display (TimeAxisView& tv)
965 TreeModel::Children rows = _model->children();
966 TreeModel::Children::iterator i;
968 for (i = rows.begin(); i != rows.end(); ++i) {
969 if ((*i)[_columns.tv] == &tv) {
970 tv.set_marked_for_display (false);
971 (*i)[_columns.visible] = false;
979 EditorRoutes::show_track_in_display (TimeAxisView& tv)
981 TreeModel::Children rows = _model->children();
982 TreeModel::Children::iterator i;
985 for (i = rows.begin(); i != rows.end(); ++i) {
986 if ((*i)[_columns.tv] == &tv) {
987 tv.set_marked_for_display (true);
988 (*i)[_columns.visible] = true;
996 EditorRoutes::sync_presentation_info_from_treeview ()
998 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
1002 TreeModel::Children rows = _model->children();
1008 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync presentation info from treeview\n");
1010 bool change = false;
1011 PresentationInfo::order_t order = 0;
1013 PresentationInfo::ChangeSuspender cs;
1015 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) {
1016 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1017 bool visible = (*ri)[_columns.visible];
1019 #ifndef NDEBUG // these should not exist in the treeview
1021 if (stripable->is_monitor() || stripable->is_auditioner()) {
1027 stripable->presentation_info().set_hidden (!visible);
1029 if (order != stripable->presentation_info().order()) {
1030 stripable->set_presentation_order (order);
1036 change |= _session->ensure_stripable_sort_order ();
1039 _session->set_dirty();
1044 EditorRoutes::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
1046 /* Some route order key(s) have been changed, make sure that
1047 we update out tree/list model and GUI to reflect the change.
1050 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
1054 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync model from presentation info.\n");
1056 PropertyChange hidden_or_order;
1057 hidden_or_order.add (Properties::hidden);
1058 hidden_or_order.add (Properties::order);
1060 TreeModel::Children rows = _model->children();
1062 bool changed = false;
1064 if (what_changed.contains (hidden_or_order)) {
1065 vector<int> neworder;
1066 uint32_t old_order = 0;
1072 TreeOrderKeys sorted;
1073 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
1074 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1075 /* use global order */
1076 sorted.push_back (TreeOrderKey (old_order, stripable));
1079 TreeOrderKeySorter cmp;
1081 sort (sorted.begin(), sorted.end(), cmp);
1082 neworder.assign (sorted.size(), 0);
1086 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
1088 neworder[n] = sr->old_display_order;
1090 if (sr->old_display_order != n) {
1096 Unwinder<bool> uw (_ignore_reorder, true);
1097 /* prevent traverse_cells: assertion 'row_path != NULL'
1098 * in case of DnD re-order: row-removed + row-inserted.
1100 * The rows (stripables) are not actually removed from the model,
1101 * but only from the display in the DnDTreeView.
1102 * ->reorder() will fail to find the row_path.
1103 * (re-order drag -> remove row -> sync PI from TV -> notify -> sync TV from PI -> crash)
1105 Unwinder<bool> uw2 (_ignore_selection_change, true);
1107 _display.unset_model();
1108 _model->reorder (neworder);
1109 _display.set_model (_model);
1113 if (changed || what_changed.contains (Properties::selected)) {
1114 /* by the time this is invoked, the GUI Selection model has
1115 * already updated itself.
1117 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
1119 /* set the treeview model selection state */
1120 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) {
1121 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1122 if (stripable && stripable->is_selected()) {
1123 _display.get_selection()->select (*ri);
1125 _display.get_selection()->unselect (*ri);
1134 EditorRoutes::hide_all_tracks (bool /*with_select*/)
1136 TreeModel::Children rows = _model->children();
1137 TreeModel::Children::iterator i;
1139 DisplaySuspender ds;
1141 for (i = rows.begin(); i != rows.end(); ++i) {
1143 TreeModel::Row row = (*i);
1144 TimeAxisView *tv = row[_columns.tv];
1150 row[_columns.visible] = false;
1155 EditorRoutes::set_all_tracks_visibility (bool yn)
1157 TreeModel::Children rows = _model->children();
1158 TreeModel::Children::iterator i;
1160 DisplaySuspender ds;
1162 for (i = rows.begin(); i != rows.end(); ++i) {
1164 TreeModel::Row row = (*i);
1165 TimeAxisView* tv = row[_columns.tv];
1171 tv->set_marked_for_display (yn);
1172 (*i)[_columns.visible] = yn;
1175 /* force route order keys catch up with visibility changes
1178 sync_presentation_info_from_treeview ();
1182 EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn)
1184 TreeModel::Children rows = _model->children();
1185 TreeModel::Children::iterator i;
1187 DisplaySuspender ds;
1189 for (i = rows.begin(); i != rows.end(); ++i) {
1191 TreeModel::Row row = (*i);
1192 TimeAxisView* tv = row[_columns.tv];
1194 AudioTimeAxisView* atv;
1195 MidiTimeAxisView* mtv;
1201 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1204 atv->set_marked_for_display (yn);
1205 (*i)[_columns.visible] = yn;
1209 if (atv->is_audio_track()) {
1210 atv->set_marked_for_display (yn);
1211 (*i)[_columns.visible] = yn;
1216 if (!atv->is_audio_track()) {
1217 atv->set_marked_for_display (yn);
1218 (*i)[_columns.visible] = yn;
1223 else if ((mtv = dynamic_cast<MidiTimeAxisView*>(tv)) != 0) {
1226 mtv->set_marked_for_display (yn);
1227 (*i)[_columns.visible] = yn;
1231 if (mtv->is_midi_track()) {
1232 mtv->set_marked_for_display (yn);
1233 (*i)[_columns.visible] = yn;
1240 /* force route order keys catch up with visibility changes
1243 sync_presentation_info_from_treeview ();
1247 EditorRoutes::hide_all_routes ()
1249 set_all_tracks_visibility (false);
1253 EditorRoutes::show_all_routes ()
1255 set_all_tracks_visibility (true);
1259 EditorRoutes::show_all_audiotracks()
1261 set_all_audio_midi_visibility (1, true);
1264 EditorRoutes::hide_all_audiotracks ()
1266 set_all_audio_midi_visibility (1, false);
1270 EditorRoutes::show_all_audiobus ()
1272 set_all_audio_midi_visibility (2, true);
1275 EditorRoutes::hide_all_audiobus ()
1277 set_all_audio_midi_visibility (2, false);
1281 EditorRoutes::show_all_miditracks()
1283 set_all_audio_midi_visibility (3, true);
1286 EditorRoutes::hide_all_miditracks ()
1288 set_all_audio_midi_visibility (3, false);
1292 EditorRoutes::key_press (GdkEventKey* ev)
1294 TreeViewColumn *col;
1295 boost::shared_ptr<RouteList> rl (new RouteList);
1298 switch (ev->keyval) {
1300 case GDK_ISO_Left_Tab:
1302 /* If we appear to be editing something, leave that cleanly and appropriately. */
1303 if (name_editable) {
1304 name_editable->editing_done ();
1308 col = _display.get_column (_name_column); // select&focus on name column
1310 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
1311 treeview_select_previous (_display, _model, col);
1313 treeview_select_next (_display, _model, col);
1320 if (get_relevant_routes (rl)) {
1321 _session->set_controls (route_list_to_control_list (rl, &Stripable::mute_control), rl->front()->muted() ? 0.0 : 1.0, Controllable::NoGroup);
1327 if (get_relevant_routes (rl)) {
1328 _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), rl->front()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
1334 if (get_relevant_routes (rl)) {
1335 for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
1336 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*r);
1338 _session->set_controls (route_list_to_control_list (rl, &Stripable::rec_enable_control), !t->rec_enable_control()->get_value(), Controllable::NoGroup);
1353 EditorRoutes::get_relevant_routes (boost::shared_ptr<RouteList> rl)
1356 RouteTimeAxisView* rtv;
1357 RefPtr<TreeSelection> selection = _display.get_selection();
1361 if (selection->count_selected_rows() != 0) {
1365 RefPtr<TreeModel> tm = RefPtr<TreeModel>::cast_dynamic (_model);
1366 iter = selection->get_selected (tm);
1369 /* use mouse pointer */
1374 _display.get_pointer (x, y);
1375 _display.convert_widget_to_bin_window_coords (x, y, bx, by);
1377 if (_display.get_path_at_pos (bx, by, path)) {
1378 iter = _model->get_iter (path);
1383 tv = (*iter)[_columns.tv];
1385 rtv = dynamic_cast<RouteTimeAxisView*>(tv);
1387 rl->push_back (rtv->route());
1392 return !rl->empty();
1396 EditorRoutes::button_press (GdkEventButton* ev)
1398 if (Keyboard::is_context_menu_event (ev)) {
1402 _menu->popup (ev->button, ev->time);
1406 TreeModel::Path path;
1407 TreeViewColumn *tvc;
1411 if (!_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, tvc, cell_x, cell_y)) {
1412 /* cancel selection */
1413 _display.get_selection()->unselect_all ();
1414 /* end any editing by grabbing focus */
1415 _display.grab_focus ();
1419 //Scroll editor canvas to selected track
1420 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1422 Gtk::TreeModel::Row row = *_model->get_iter (path);
1423 TimeAxisView *tv = row[_columns.tv];
1426 _editor->ensure_time_axis_view_is_visible (*tv, true);
1434 EditorRoutes::selection_changed ()
1436 if (_ignore_selection_change) {
1440 _editor->begin_reversible_selection_op (X_("Select Track from Route List"));
1442 if (_display.get_selection()->count_selected_rows() > 0) {
1445 TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
1446 TrackViewList selected;
1448 for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
1450 if ((iter = _model->get_iter (*i))) {
1452 TimeAxisView* tv = (*iter)[_columns.tv];
1453 selected.push_back (tv);
1458 _editor->get_selection().set (selected);
1459 _editor->ensure_time_axis_view_is_visible (*(selected.front()), true);
1462 _editor->get_selection().clear_tracks ();
1465 _editor->commit_reversible_selection_op ();
1469 EditorRoutes::initial_display ()
1477 DisplaySuspender ds;
1482 _session->get_stripables (s);
1483 _editor->add_stripables (s);
1485 sync_treeview_from_presentation_info (Properties::order);
1488 struct ViewStripable {
1490 boost::shared_ptr<Stripable> stripable;
1492 ViewStripable (TimeAxisView* t, boost::shared_ptr<Stripable> s)
1493 : tav (t), stripable (s) {}
1497 EditorRoutes::move_selected_tracks (bool up)
1499 TimeAxisView* scroll_to = 0;
1501 _session->get_stripables (sl);
1503 if (sl.size() < 2) {
1508 sl.sort (Stripable::Sorter());
1510 std::list<ViewStripable> view_stripables;
1512 /* build a list that includes time axis view information */
1514 for (StripableList::const_iterator sli = sl.begin(); sli != sl.end(); ++sli) {
1515 TimeAxisView* tv = _editor->time_axis_view_from_stripable (*sli);
1516 view_stripables.push_back (ViewStripable (tv, *sli));
1519 /* for each selected stripable, move it above or below the adjacent
1520 * stripable that has a time-axis view representation here. If there's
1521 * no such representation, then
1524 list<ViewStripable>::iterator unselected_neighbour;
1525 list<ViewStripable>::iterator vsi;
1528 PresentationInfo::ChangeSuspender cs;
1531 unselected_neighbour = view_stripables.end ();
1532 vsi = view_stripables.begin();
1534 while (vsi != view_stripables.end()) {
1536 if (vsi->stripable->is_selected()) {
1538 if (unselected_neighbour != view_stripables.end()) {
1540 PresentationInfo::order_t unselected_neighbour_order = unselected_neighbour->stripable->presentation_info().order();
1541 PresentationInfo::order_t my_order = vsi->stripable->presentation_info().order();
1543 unselected_neighbour->stripable->set_presentation_order (my_order);
1544 vsi->stripable->set_presentation_order (unselected_neighbour_order);
1547 scroll_to = vsi->tav;
1554 unselected_neighbour = vsi;
1564 unselected_neighbour = view_stripables.end();
1565 vsi = unselected_neighbour;
1571 if (vsi->stripable->is_selected()) {
1573 if (unselected_neighbour != view_stripables.end()) {
1575 PresentationInfo::order_t unselected_neighbour_order = unselected_neighbour->stripable->presentation_info().order();
1576 PresentationInfo::order_t my_order = vsi->stripable->presentation_info().order();
1578 unselected_neighbour->stripable->set_presentation_order (my_order);
1579 vsi->stripable->set_presentation_order (unselected_neighbour_order);
1582 scroll_to = vsi->tav;
1589 unselected_neighbour = vsi;
1594 } while (vsi != view_stripables.begin());
1599 _editor->ensure_time_axis_view_is_visible (*scroll_to, false);
1604 EditorRoutes::update_input_active_display ()
1606 TreeModel::Children rows = _model->children();
1607 TreeModel::Children::iterator i;
1609 for (i = rows.begin(); i != rows.end(); ++i) {
1610 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1612 if (boost::dynamic_pointer_cast<Track> (stripable)) {
1613 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (stripable);
1616 (*i)[_columns.is_input_active] = mt->input_active();
1623 EditorRoutes::update_rec_display ()
1625 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1626 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1631 EditorRoutes::idle_update_mute_rec_solo_etc()
1633 g_atomic_int_set (const_cast<gint*>(&_queue_tv_update), 0);
1634 TreeModel::Children rows = _model->children();
1635 TreeModel::Children::iterator i;
1637 for (i = rows.begin(); i != rows.end(); ++i) {
1638 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1639 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
1640 (*i)[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
1641 (*i)[_columns.solo_state] = RouteUI::solo_active_state (stripable);
1642 (*i)[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable) ? 1 : 0;
1643 (*i)[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable) ? 1 : 0;
1645 (*i)[_columns.active] = route->active ();
1647 (*i)[_columns.active] = true;
1650 boost::shared_ptr<Track> trk (boost::dynamic_pointer_cast<Track>(route));
1653 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
1655 if (trk->rec_enable_control()->get_value()) {
1656 if (_session->record_status() == Session::Recording) {
1657 (*i)[_columns.rec_state] = 1;
1659 (*i)[_columns.rec_state] = 2;
1661 } else if (mt && mt->step_editing()) {
1662 (*i)[_columns.rec_state] = 3;
1664 (*i)[_columns.rec_state] = 0;
1667 (*i)[_columns.rec_safe] = trk->rec_safe_control()->get_value();
1668 (*i)[_columns.name_editable] = !trk->rec_enable_control()->get_value();
1672 return false; // do not call again (until needed)
1677 EditorRoutes::update_mute_display ()
1679 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1680 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1685 EditorRoutes::update_solo_display ()
1687 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1688 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1693 EditorRoutes::update_solo_isolate_display ()
1695 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1696 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1701 EditorRoutes::update_solo_safe_display ()
1703 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1704 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1709 EditorRoutes::views () const
1711 list<TimeAxisView*> v;
1712 for (TreeModel::Children::iterator i = _model->children().begin(); i != _model->children().end(); ++i) {
1713 v.push_back ((*i)[_columns.tv]);
1720 EditorRoutes::clear ()
1722 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
1723 _display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
1725 _display.set_model (_model);
1729 EditorRoutes::name_edit_started (CellEditable* ce, const Glib::ustring&)
1733 /* give it a special name */
1735 Gtk::Entry *e = dynamic_cast<Gtk::Entry*> (ce);
1738 e->set_name (X_("RouteNameEditorEntry"));
1743 EditorRoutes::name_edit (std::string const & path, std::string const & new_text)
1747 TreeIter iter = _model->get_iter (path);
1753 boost::shared_ptr<Stripable> stripable = (*iter)[_columns.stripable];
1755 if (stripable && stripable->name() != new_text) {
1756 stripable->set_name (new_text);
1761 EditorRoutes::solo_changed_so_update_mute ()
1763 update_mute_display ();
1767 EditorRoutes::show_tracks_with_regions_at_playhead ()
1769 boost::shared_ptr<RouteList> const r = _session->get_routes_with_regions_at (_session->transport_sample ());
1771 set<TimeAxisView*> show;
1772 for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
1773 TimeAxisView* tav = _editor->time_axis_view_from_stripable (*i);
1779 DisplaySuspender ds;
1781 TreeModel::Children rows = _model->children ();
1782 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
1783 TimeAxisView* tv = (*i)[_columns.tv];
1784 bool to_show = (show.find (tv) != show.end());
1786 tv->set_marked_for_display (to_show);
1787 (*i)[_columns.visible] = to_show;
1790 /* force route order keys catch up with visibility changes
1793 sync_presentation_info_from_treeview ();
1797 EditorRoutes::plugin_setup (boost::shared_ptr<Route> r, boost::shared_ptr<PluginInsert> pi, ARDOUR::Route::PluginSetupOptions flags)
1799 PluginSetupDialog psd (r, pi, flags);
1800 int rv = psd.run ();
1801 return rv + (psd.fan_out() ? 4 : 0);