2 Copyright (C) 2000-2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "pbd/unknown_type.h"
28 #include "pbd/unwind.h"
30 #include "ardour/debug.h"
31 #include "ardour/audio_track.h"
32 #include "ardour/midi_track.h"
33 #include "ardour/route.h"
34 #include "ardour/selection.h"
35 #include "ardour/session.h"
36 #include "ardour/solo_isolate_control.h"
37 #include "ardour/utils.h"
38 #include "ardour/vca.h"
39 #include "ardour/vca_manager.h"
41 #include "gtkmm2ext/cell_renderer_pixbuf_multi.h"
42 #include "gtkmm2ext/cell_renderer_pixbuf_toggle.h"
43 #include "gtkmm2ext/treeutils.h"
45 #include "widgets/tooltips.h"
48 #include "ardour_ui.h"
49 #include "audio_time_axis.h"
51 #include "editor_group_tabs.h"
52 #include "editor_routes.h"
53 #include "gui_thread.h"
55 #include "midi_time_axis.h"
56 #include "mixer_strip.h"
57 #include "plugin_setup_dialog.h"
58 #include "route_sorter.h"
59 #include "vca_time_axis.h"
65 using namespace ARDOUR;
66 using namespace ArdourWidgets;
67 using namespace ARDOUR_UI_UTILS;
70 using namespace Gtkmm2ext;
72 using Gtkmm2ext::Keyboard;
80 EditorRoutes::EditorRoutes (Editor* e)
82 , _ignore_reorder (false)
83 , _ignore_selection_change (false)
84 , _no_redisplay (false)
85 , _adding_routes (false)
86 , _route_deletion_in_progress (false)
87 , _redisplay_on_resume (false)
88 , _redisplay_active (0)
89 , _queue_tv_update (0)
94 static const int column_width = 22;
96 _scroller.add (_display);
97 _scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
99 _model = ListStore::create (_columns);
100 _display.set_model (_model);
102 // Record enable toggle
103 CellRendererPixbufMulti* rec_col_renderer = manage (new CellRendererPixbufMulti());
105 rec_col_renderer->set_pixbuf (0, ::get_icon("record-normal-disabled"));
106 rec_col_renderer->set_pixbuf (1, ::get_icon("record-normal-in-progress"));
107 rec_col_renderer->set_pixbuf (2, ::get_icon("record-normal-enabled"));
108 rec_col_renderer->set_pixbuf (3, ::get_icon("record-step"));
109 rec_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_enable_changed));
111 TreeViewColumn* rec_state_column = manage (new TreeViewColumn("R", *rec_col_renderer));
113 rec_state_column->add_attribute(rec_col_renderer->property_state(), _columns.rec_state);
114 rec_state_column->add_attribute(rec_col_renderer->property_visible(), _columns.is_track);
116 rec_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
117 rec_state_column->set_alignment(ALIGN_CENTER);
118 rec_state_column->set_expand(false);
119 rec_state_column->set_fixed_width(column_width);
122 // Record safe toggle
123 CellRendererPixbufMulti* rec_safe_renderer = manage (new CellRendererPixbufMulti ());
125 rec_safe_renderer->set_pixbuf (0, ::get_icon("rec-safe-disabled"));
126 rec_safe_renderer->set_pixbuf (1, ::get_icon("rec-safe-enabled"));
127 rec_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_safe_toggled));
129 TreeViewColumn* rec_safe_column = manage (new TreeViewColumn(_("RS"), *rec_safe_renderer));
130 rec_safe_column->add_attribute(rec_safe_renderer->property_state(), _columns.rec_safe);
131 rec_safe_column->add_attribute(rec_safe_renderer->property_visible(), _columns.is_track);
132 rec_safe_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
133 rec_safe_column->set_alignment(ALIGN_CENTER);
134 rec_safe_column->set_expand(false);
135 rec_safe_column->set_fixed_width(column_width);
140 CellRendererPixbufMulti* input_active_col_renderer = manage (new CellRendererPixbufMulti());
141 input_active_col_renderer->set_pixbuf (0, ::get_icon("midi-input-inactive"));
142 input_active_col_renderer->set_pixbuf (1, ::get_icon("midi-input-active"));
143 input_active_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_input_active_changed));
145 TreeViewColumn* input_active_column = manage (new TreeViewColumn ("I", *input_active_col_renderer));
147 input_active_column->add_attribute(input_active_col_renderer->property_state(), _columns.is_input_active);
148 input_active_column->add_attribute (input_active_col_renderer->property_visible(), _columns.is_midi);
150 input_active_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
151 input_active_column->set_alignment(ALIGN_CENTER);
152 input_active_column->set_expand(false);
153 input_active_column->set_fixed_width(column_width);
155 // Mute enable toggle
156 CellRendererPixbufMulti* mute_col_renderer = manage (new CellRendererPixbufMulti());
158 mute_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("mute-disabled"));
159 mute_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("muted-by-others"));
160 mute_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("mute-enabled"));
161 mute_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_mute_enable_toggled));
163 TreeViewColumn* mute_state_column = manage (new TreeViewColumn("M", *mute_col_renderer));
165 mute_state_column->add_attribute(mute_col_renderer->property_state(), _columns.mute_state);
166 mute_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
167 mute_state_column->set_alignment(ALIGN_CENTER);
168 mute_state_column->set_expand(false);
169 mute_state_column->set_fixed_width(15);
171 // Solo enable toggle
172 CellRendererPixbufMulti* solo_col_renderer = manage (new CellRendererPixbufMulti());
174 solo_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("solo-disabled"));
175 solo_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("solo-enabled"));
176 solo_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("soloed-by-others"));
177 solo_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_enable_toggled));
179 TreeViewColumn* solo_state_column = manage (new TreeViewColumn("S", *solo_col_renderer));
181 solo_state_column->add_attribute(solo_col_renderer->property_state(), _columns.solo_state);
182 solo_state_column->add_attribute(solo_col_renderer->property_visible(), _columns.solo_visible);
183 solo_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
184 solo_state_column->set_alignment(ALIGN_CENTER);
185 solo_state_column->set_expand(false);
186 solo_state_column->set_fixed_width(column_width);
188 // Solo isolate toggle
189 CellRendererPixbufMulti* solo_iso_renderer = manage (new CellRendererPixbufMulti());
191 solo_iso_renderer->set_pixbuf (0, ::get_icon("solo-isolate-disabled"));
192 solo_iso_renderer->set_pixbuf (1, ::get_icon("solo-isolate-enabled"));
193 solo_iso_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_isolate_toggled));
195 TreeViewColumn* solo_isolate_state_column = manage (new TreeViewColumn("SI", *solo_iso_renderer));
197 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_state(), _columns.solo_isolate_state);
198 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_visible(), _columns.solo_lock_iso_visible);
199 solo_isolate_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
200 solo_isolate_state_column->set_alignment(ALIGN_CENTER);
201 solo_isolate_state_column->set_expand(false);
202 solo_isolate_state_column->set_fixed_width(column_width);
205 CellRendererPixbufMulti* solo_safe_renderer = manage (new CellRendererPixbufMulti ());
207 solo_safe_renderer->set_pixbuf (0, ::get_icon("solo-safe-disabled"));
208 solo_safe_renderer->set_pixbuf (1, ::get_icon("solo-safe-enabled"));
209 solo_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_safe_toggled));
211 TreeViewColumn* solo_safe_state_column = manage (new TreeViewColumn(_("SS"), *solo_safe_renderer));
212 solo_safe_state_column->add_attribute(solo_safe_renderer->property_state(), _columns.solo_safe_state);
213 solo_safe_state_column->add_attribute(solo_safe_renderer->property_visible(), _columns.solo_lock_iso_visible);
214 solo_safe_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
215 solo_safe_state_column->set_alignment(ALIGN_CENTER);
216 solo_safe_state_column->set_expand(false);
217 solo_safe_state_column->set_fixed_width(column_width);
219 _name_column = _display.append_column ("", _columns.text) - 1;
220 _visible_column = _display.append_column ("", _columns.visible) - 1;
221 _active_column = _display.append_column ("", _columns.active) - 1;
223 _display.append_column (*input_active_column);
224 _display.append_column (*rec_state_column);
225 _display.append_column (*rec_safe_column);
226 _display.append_column (*mute_state_column);
227 _display.append_column (*solo_state_column);
228 _display.append_column (*solo_isolate_state_column);
229 _display.append_column (*solo_safe_state_column);
236 { 0, _("Name"), _("Track/Bus Name") },
237 { 1, S_("Visible|V"), _("Track/Bus visible ?") },
238 { 2, S_("Active|A"), _("Track/Bus active ?") },
239 { 3, S_("MidiInput|I"), _("MIDI input enabled") },
240 { 4, S_("Rec|R"), _("Record enabled") },
241 { 5, S_("Rec|RS"), _("Record Safe") },
242 { 6, S_("Mute|M"), _("Muted") },
243 { 7, S_("Solo|S"), _("Soloed") },
244 { 8, S_("SoloIso|SI"), _("Solo Isolated") },
245 { 9, S_("SoloLock|SS"), _("Solo Safe (Locked)") },
249 for (int i = 0; ci[i].index >= 0; ++i) {
250 col = _display.get_column (ci[i].index);
251 l = manage (new Label (ci[i].label));
252 set_tooltip (*l, ci[i].tooltip);
253 col->set_widget (*l);
257 _display.set_headers_visible (true);
258 _display.get_selection()->set_mode (SELECTION_MULTIPLE);
259 _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRoutes::selection_filter));
260 _display.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::selection_changed));
261 _display.set_reorderable (true);
262 _display.set_name (X_("EditGroupList"));
263 _display.set_rules_hint (true);
264 _display.set_size_request (100, -1);
266 CellRendererText* name_cell = dynamic_cast<CellRendererText*> (_display.get_column_cell_renderer (_name_column));
269 name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit_started));
271 TreeViewColumn* name_column = _display.get_column (_name_column);
273 assert (name_column);
275 name_column->add_attribute (name_cell->property_editable(), _columns.name_editable);
276 name_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
277 name_column->set_expand(true);
278 name_column->set_min_width(50);
280 name_cell->property_editable() = true;
281 name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit));
283 // Set the visible column cell renderer to radio toggle
284 CellRendererToggle* visible_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_visible_column));
286 visible_cell->property_activatable() = true;
287 visible_cell->property_radio() = false;
288 visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::visible_changed));
290 TreeViewColumn* visible_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_visible_column));
291 visible_col->set_expand(false);
292 visible_col->set_sizing(TREE_VIEW_COLUMN_FIXED);
293 visible_col->set_fixed_width(30);
294 visible_col->set_alignment(ALIGN_CENTER);
296 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_active_column));
298 active_cell->property_activatable() = true;
299 active_cell->property_radio() = false;
300 active_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::active_changed));
302 TreeViewColumn* active_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_active_column));
303 active_col->set_expand (false);
304 active_col->set_sizing (TREE_VIEW_COLUMN_FIXED);
305 active_col->set_fixed_width (30);
306 active_col->set_alignment (ALIGN_CENTER);
307 active_col->add_attribute (active_cell->property_visible(), _columns.no_vca);
309 _model->signal_row_deleted().connect (sigc::mem_fun (*this, &EditorRoutes::row_deleted));
310 _model->signal_rows_reordered().connect (sigc::mem_fun (*this, &EditorRoutes::reordered));
312 _display.signal_button_press_event().connect (sigc::mem_fun (*this, &EditorRoutes::button_press), false);
313 _scroller.signal_key_press_event().connect (sigc::mem_fun(*this, &EditorRoutes::key_press), false);
315 _scroller.signal_focus_in_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_in), false);
316 _scroller.signal_focus_out_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_out));
318 _display.signal_enter_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::enter_notify), false);
319 _display.signal_leave_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::leave_notify), false);
321 _display.set_enable_search (false);
323 Route::PluginSetup.connect_same_thread (*this, boost::bind (&EditorRoutes::plugin_setup, this, _1, _2, _3));
327 EditorRoutes::focus_in (GdkEventFocus*)
329 Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ());
332 old_focus = win->get_focus ();
339 /* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
344 EditorRoutes::focus_out (GdkEventFocus*)
347 old_focus->grab_focus ();
355 EditorRoutes::enter_notify (GdkEventCrossing*)
361 /* arm counter so that ::selection_filter() will deny selecting anything for the
362 * next two attempts to change selection status.
364 _scroller.grab_focus ();
365 Keyboard::magic_widget_grab_focus ();
370 EditorRoutes::leave_notify (GdkEventCrossing*)
373 old_focus->grab_focus ();
377 Keyboard::magic_widget_drop_focus ();
382 EditorRoutes::set_session (Session* s)
384 SessionHandlePtr::set_session (s);
389 _session->SoloChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::solo_changed_so_update_mute, this), gui_context());
390 _session->RecordStateChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
392 /* TODO: check if these needs to be tied in with DisplaySuspender
393 * Given that the UI is single-threaded and DisplaySuspender is only used
394 * in loops in the UI thread all should be fine.
396 _session->BatchUpdateStart.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::suspend_redisplay, this), gui_context());
397 _session->BatchUpdateEnd.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::resume_redisplay, this), gui_context());
402 EditorRoutes::on_input_active_changed (std::string const & path_string)
404 // Get the model row that has been toggled.
405 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
407 TimeAxisView* tv = row[_columns.tv];
408 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
411 boost::shared_ptr<MidiTrack> mt;
412 mt = rtv->midi_track();
414 mt->set_input_active (!mt->input_active());
420 EditorRoutes::on_tv_rec_enable_changed (std::string const & path_string)
422 // Get the model row that has been toggled.
423 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
425 TimeAxisView* tv = row[_columns.tv];
426 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
428 if (!stv || !stv->stripable()) {
432 boost::shared_ptr<AutomationControl> ac = stv->stripable()->rec_enable_control();
435 ac->set_value (!ac->get_value(), Controllable::UseGroup);
440 EditorRoutes::on_tv_rec_safe_toggled (std::string const & path_string)
442 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
443 TimeAxisView* tv = row[_columns.tv];
444 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
446 if (!stv || !stv->stripable()) {
450 boost::shared_ptr<AutomationControl> ac (stv->stripable()->rec_safe_control());
453 ac->set_value (!ac->get_value(), Controllable::UseGroup);
458 EditorRoutes::on_tv_mute_enable_toggled (std::string const & path_string)
460 // Get the model row that has been toggled.
461 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
463 TimeAxisView *tv = row[_columns.tv];
464 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
466 if (!stv || !stv->stripable()) {
470 boost::shared_ptr<AutomationControl> ac (stv->stripable()->mute_control());
473 ac->set_value (!ac->get_value(), Controllable::UseGroup);
478 EditorRoutes::on_tv_solo_enable_toggled (std::string const & path_string)
480 // Get the model row that has been toggled.
481 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
483 TimeAxisView *tv = row[_columns.tv];
484 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
486 if (!stv || !stv->stripable()) {
490 boost::shared_ptr<AutomationControl> ac (stv->stripable()->solo_control());
493 ac->set_value (!ac->get_value(), Controllable::UseGroup);
498 EditorRoutes::on_tv_solo_isolate_toggled (std::string const & path_string)
500 // Get the model row that has been toggled.
501 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
503 TimeAxisView *tv = row[_columns.tv];
504 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
506 if (!stv || !stv->stripable()) {
510 boost::shared_ptr<AutomationControl> ac (stv->stripable()->solo_isolate_control());
513 ac->set_value (!ac->get_value(), Controllable::UseGroup);
518 EditorRoutes::on_tv_solo_safe_toggled (std::string const & path_string)
520 // Get the model row that has been toggled.
521 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
523 TimeAxisView *tv = row[_columns.tv];
524 StripableTimeAxisView* stv = dynamic_cast<StripableTimeAxisView*> (tv);
526 if (!stv || !stv->stripable()) {
530 boost::shared_ptr<AutomationControl> ac (stv->stripable()->solo_safe_control());
533 ac->set_value (!ac->get_value(), Controllable::UseGroup);
538 EditorRoutes::build_menu ()
540 using namespace Menu_Helpers;
545 MenuList& items = _menu->items();
546 _menu->set_name ("ArdourContextMenu");
548 items.push_back (MenuElem (_("Show All"), sigc::mem_fun (*this, &EditorRoutes::show_all_routes)));
549 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun (*this, &EditorRoutes::hide_all_routes)));
550 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiotracks)));
551 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiotracks)));
552 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_miditracks)));
553 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_miditracks)));
554 items.push_back (MenuElem (_("Show All Busses"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiobus)));
555 items.push_back (MenuElem (_("Hide All Busses"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiobus)));
556 items.push_back (MenuElem (_("Only Show Tracks with Regions Under Playhead"), sigc::mem_fun (*this, &EditorRoutes::show_tracks_with_regions_at_playhead)));
560 EditorRoutes::redisplay_real ()
562 TreeModel::Children rows = _model->children();
563 TreeModel::Children::iterator i;
566 /* n will be the count of tracks plus children (updated by TimeAxisView::show_at),
567 * so we will use that to know where to put things.
571 for (n = 0, position = 0, i = rows.begin(); i != rows.end(); ++i) {
572 TimeAxisView *tv = (*i)[_columns.tv];
575 // just a "title" row
579 bool visible = tv->marked_for_display ();
581 /* show or hide the TimeAxisView */
583 position += tv->show_at (position, n, &_editor->edit_controls_vbox);
591 /* whenever we go idle, update the track view list to reflect the new order.
592 * we can't do this here, because we could mess up something that is traversing
593 * the track order and has caused a redisplay of the list.
595 Glib::signal_idle().connect (sigc::mem_fun (*_editor, &Editor::sync_track_view_list_and_routes));
597 _editor->reset_controls_layout_height (position);
598 _editor->reset_controls_layout_width ();
599 _editor->_full_canvas_height = position;
601 if ((_editor->vertical_adjustment.get_value() + _editor->_visible_canvas_height) > _editor->vertical_adjustment.get_upper()) {
603 * We're increasing the size of the canvas while the bottom is visible.
604 * We scroll down to keep in step with the controls layout.
606 _editor->vertical_adjustment.set_value (_editor->_full_canvas_height - _editor->_visible_canvas_height);
611 EditorRoutes::redisplay ()
613 if (!_session || _session->deletion_in_progress()) {
618 _redisplay_on_resume = true;
622 // model deprecated g_atomic_int_exchange_and_add(, 1)
623 g_atomic_int_inc(const_cast<gint*>(&_redisplay_active));
624 if (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 1)) {
625 /* recursive re-display can happen if redisplay shows/hides a TrackView
626 * which has children and their display status changes as result.
633 while (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 0)) {
634 g_atomic_int_set(const_cast<gint*>(&_redisplay_active), 1);
640 EditorRoutes::row_deleted (Gtk::TreeModel::Path const &)
642 if (!_session || _session->deletion_in_progress()) {
645 /* this happens as the second step of a DnD within the treeview, and
646 * when a route is actually removed. we don't differentiate between
649 * note that the sync_presentation_info_from_treeview() step may not
650 * actually change any presentation info (e.g. the last track may be
651 * removed, so all other tracks keep the same presentation info), which
652 * means that no redisplay would happen. so we have to force a
656 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview row deleted\n");
659 sync_presentation_info_from_treeview ();
663 EditorRoutes::reordered (TreeModel::Path const &, TreeModel::iterator const &, int* /*what*/)
665 /* reordering implies that RID's will change, so
666 sync_presentation_info_from_treeview() will cause a redisplay.
669 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview reordered\n");
670 sync_presentation_info_from_treeview ();
674 EditorRoutes::visible_changed (std::string const & path)
676 if (_session && _session->deletion_in_progress()) {
683 if ((iter = _model->get_iter (path))) {
684 TimeAxisView* tv = (*iter)[_columns.tv];
686 bool visible = (*iter)[_columns.visible];
688 if (tv->set_marked_for_display (!visible)) {
689 update_visibility ();
696 EditorRoutes::active_changed (std::string const & path)
698 if (_session && _session->deletion_in_progress ()) {
702 Gtk::TreeModel::Row row = *_model->get_iter (path);
703 boost::shared_ptr<Stripable> stripable = row[_columns.stripable];
704 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
706 bool const active = row[_columns.active];
707 route->set_active (!active, this);
712 EditorRoutes::time_axis_views_added (list<TimeAxisView*> tavs)
714 PBD::Unwinder<bool> at (_adding_routes, true);
715 bool from_scratch = (_model->children().size() == 0);
716 Gtk::TreeModel::Children::iterator insert_iter = _model->children().end();
718 for (Gtk::TreeModel::Children::iterator it = _model->children().begin(); it != _model->children().end(); ++it) {
720 boost::shared_ptr<Stripable> r = (*it)[_columns.stripable];
722 if (r->presentation_info().order() == (tavs.front()->stripable()->presentation_info().order() + tavs.size())) {
729 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
730 _display.set_model (Glib::RefPtr<ListStore>());
733 for (list<TimeAxisView*>::iterator x = tavs.begin(); x != tavs.end(); ++x) {
735 VCATimeAxisView* vtav = dynamic_cast<VCATimeAxisView*> (*x);
736 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (*x);
738 TreeModel::Row row = *(_model->insert (insert_iter));
740 boost::shared_ptr<Stripable> stripable;
741 boost::shared_ptr<MidiTrack> midi_trk;
745 stripable = vtav->vca();
747 row[_columns.is_track] = false;
748 row[_columns.is_input_active] = false;
749 row[_columns.is_midi] = false;
750 row[_columns.no_vca] = false;
754 stripable = rtav->route ();
755 midi_trk= boost::dynamic_pointer_cast<MidiTrack> (stripable);
757 row[_columns.is_track] = (boost::dynamic_pointer_cast<Track> (stripable) != 0);
758 row[_columns.no_vca] = true;
761 row[_columns.is_input_active] = midi_trk->input_active ();
762 row[_columns.is_midi] = true;
764 row[_columns.is_input_active] = false;
765 row[_columns.is_midi] = false;
773 row[_columns.text] = stripable->name();
774 row[_columns.visible] = (*x)->marked_for_display();
775 row[_columns.active] = true;
776 row[_columns.tv] = *x;
777 row[_columns.stripable] = stripable;
778 row[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
779 row[_columns.solo_state] = RouteUI::solo_active_state (stripable);
780 row[_columns.solo_visible] = !stripable->is_master ();
781 row[_columns.solo_lock_iso_visible] = row[_columns.solo_visible] && row[_columns.no_vca];
782 row[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable);
783 row[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable);
784 row[_columns.name_editable] = true;
786 boost::weak_ptr<Stripable> ws (stripable);
788 /* for now, we need both of these. PropertyChanged covers on
789 * pre-defined, "global" things of interest to a
790 * UI. gui_changed covers arbitrary, un-enumerated, un-typed
791 * changes that may only be of interest to a particular
792 * UI (e.g. track-height is not of any relevant to OSC)
795 stripable->gui_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::handle_gui_changes, this, _1, _2), gui_context());
796 stripable->PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, ws), gui_context());
797 stripable->presentation_info().PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, ws), gui_context());
799 if (boost::dynamic_pointer_cast<Track> (stripable)) {
800 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (stripable);
801 t->rec_enable_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
802 t->rec_safe_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
806 midi_trk->StepEditStatusChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
807 midi_trk->InputActiveChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_input_active_display, this), gui_context());
810 boost::shared_ptr<AutomationControl> ac;
812 if ((ac = stripable->mute_control()) != 0) {
813 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_mute_display, this), gui_context());
815 if ((ac = stripable->solo_control()) != 0) {
816 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_display, this), gui_context());
818 if ((ac = stripable->solo_isolate_control()) != 0) {
819 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_isolate_display, this), gui_context());
821 if ((ac = stripable->solo_safe_control()) != 0) {
822 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_safe_display, this), gui_context());
826 rtav->route()->active_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_active_display, this), gui_context ());
830 update_rec_display ();
831 update_mute_display ();
832 update_solo_display ();
833 update_solo_isolate_display ();
834 update_solo_safe_display ();
835 update_input_active_display ();
836 update_active_display ();
839 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
840 _display.set_model (_model);
843 /* now update route order keys from the treeview/track display order */
846 sync_presentation_info_from_treeview ();
853 EditorRoutes::handle_gui_changes (string const & what, void*)
855 if (_adding_routes) {
859 if (what == "track_height") {
860 /* Optional :make tracks change height while it happens, instead
866 if (what == "visible_tracks") {
872 EditorRoutes::route_removed (TimeAxisView *tv)
874 ENSURE_GUI_THREAD (*this, &EditorRoutes::route_removed, tv)
876 TreeModel::Children rows = _model->children();
877 TreeModel::Children::iterator ri;
879 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
881 for (ri = rows.begin(); ri != rows.end(); ++ri) {
882 if ((*ri)[_columns.tv] == tv) {
883 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
891 EditorRoutes::route_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> s)
893 if (!what_changed.contains (ARDOUR::Properties::hidden) && !what_changed.contains (ARDOUR::Properties::name)) {
897 if (_adding_routes) {
901 boost::shared_ptr<Stripable> stripable = s.lock ();
907 TreeModel::Children rows = _model->children();
908 TreeModel::Children::iterator i;
910 for (i = rows.begin(); i != rows.end(); ++i) {
912 boost::shared_ptr<Stripable> ss = (*i)[_columns.stripable];
914 if (ss == stripable) {
916 if (what_changed.contains (ARDOUR::Properties::name)) {
917 (*i)[_columns.text] = stripable->name();
921 if (what_changed.contains (ARDOUR::Properties::hidden)) {
922 (*i)[_columns.visible] = !stripable->presentation_info().hidden();
933 EditorRoutes::update_active_display ()
935 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
936 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
941 EditorRoutes::update_visibility ()
943 TreeModel::Children rows = _model->children();
944 TreeModel::Children::iterator i;
948 for (i = rows.begin(); i != rows.end(); ++i) {
949 TimeAxisView *tv = (*i)[_columns.tv];
950 (*i)[_columns.visible] = tv->marked_for_display ();
953 /* force route order keys catch up with visibility changes */
955 sync_presentation_info_from_treeview ();
959 EditorRoutes::hide_track_in_display (TimeAxisView& tv)
961 TreeModel::Children rows = _model->children();
962 TreeModel::Children::iterator i;
964 for (i = rows.begin(); i != rows.end(); ++i) {
965 if ((*i)[_columns.tv] == &tv) {
966 tv.set_marked_for_display (false);
967 (*i)[_columns.visible] = false;
975 EditorRoutes::show_track_in_display (TimeAxisView& tv)
977 TreeModel::Children rows = _model->children();
978 TreeModel::Children::iterator i;
981 for (i = rows.begin(); i != rows.end(); ++i) {
982 if ((*i)[_columns.tv] == &tv) {
983 tv.set_marked_for_display (true);
984 (*i)[_columns.visible] = true;
992 EditorRoutes::sync_presentation_info_from_treeview ()
994 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
998 TreeModel::Children rows = _model->children();
1004 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync presentation info from treeview\n");
1006 bool change = false;
1007 PresentationInfo::order_t order = 0;
1009 PresentationInfo::ChangeSuspender cs;
1011 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) {
1012 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1013 bool visible = (*ri)[_columns.visible];
1015 #ifndef NDEBUG // these should not exist in the treeview
1017 if (stripable->is_monitor() || stripable->is_auditioner()) {
1023 stripable->presentation_info().set_hidden (!visible);
1025 if (order != stripable->presentation_info().order()) {
1026 stripable->set_presentation_order (order);
1032 change |= _session->ensure_stripable_sort_order ();
1035 _session->set_dirty();
1040 EditorRoutes::sync_treeview_from_presentation_info (PropertyChange const & what_changed)
1042 /* Some route order key(s) have been changed, make sure that
1043 we update out tree/list model and GUI to reflect the change.
1046 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
1050 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync model from presentation info.\n");
1052 PropertyChange hidden_or_order;
1053 hidden_or_order.add (Properties::hidden);
1054 hidden_or_order.add (Properties::order);
1056 TreeModel::Children rows = _model->children();
1058 bool changed = false;
1060 if (what_changed.contains (hidden_or_order)) {
1061 vector<int> neworder;
1062 uint32_t old_order = 0;
1068 TreeOrderKeys sorted;
1069 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
1070 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1071 /* use global order */
1072 sorted.push_back (TreeOrderKey (old_order, stripable));
1075 TreeOrderKeySorter cmp;
1077 sort (sorted.begin(), sorted.end(), cmp);
1078 neworder.assign (sorted.size(), 0);
1082 for (TreeOrderKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
1084 neworder[n] = sr->old_display_order;
1086 if (sr->old_display_order != n) {
1092 Unwinder<bool> uw (_ignore_reorder, true);
1093 /* prevent traverse_cells: assertion 'row_path != NULL'
1094 * in case of DnD re-order: row-removed + row-inserted.
1096 * The rows (stripables) are not actually removed from the model,
1097 * but only from the display in the DnDTreeView.
1098 * ->reorder() will fail to find the row_path.
1099 * (re-order drag -> remove row -> sync PI from TV -> notify -> sync TV from PI -> crash)
1101 Unwinder<bool> uw2 (_ignore_selection_change, true);
1103 _display.unset_model();
1104 _model->reorder (neworder);
1105 _display.set_model (_model);
1109 if (changed || what_changed.contains (Properties::selected)) {
1110 /* by the time this is invoked, the GUI Selection model has
1111 * already updated itself.
1113 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
1115 /* set the treeview model selection state */
1116 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri) {
1117 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1118 if (stripable && stripable->is_selected()) {
1119 _display.get_selection()->select (*ri);
1121 _display.get_selection()->unselect (*ri);
1130 EditorRoutes::hide_all_tracks (bool /*with_select*/)
1132 TreeModel::Children rows = _model->children();
1133 TreeModel::Children::iterator i;
1135 DisplaySuspender ds;
1137 for (i = rows.begin(); i != rows.end(); ++i) {
1139 TreeModel::Row row = (*i);
1140 TimeAxisView *tv = row[_columns.tv];
1146 row[_columns.visible] = false;
1151 EditorRoutes::set_all_tracks_visibility (bool yn)
1153 TreeModel::Children rows = _model->children();
1154 TreeModel::Children::iterator i;
1156 DisplaySuspender ds;
1158 for (i = rows.begin(); i != rows.end(); ++i) {
1160 TreeModel::Row row = (*i);
1161 TimeAxisView* tv = row[_columns.tv];
1167 tv->set_marked_for_display (yn);
1168 (*i)[_columns.visible] = yn;
1171 /* force route order keys catch up with visibility changes
1174 sync_presentation_info_from_treeview ();
1178 EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn)
1180 TreeModel::Children rows = _model->children();
1181 TreeModel::Children::iterator i;
1183 DisplaySuspender ds;
1185 for (i = rows.begin(); i != rows.end(); ++i) {
1187 TreeModel::Row row = (*i);
1188 TimeAxisView* tv = row[_columns.tv];
1190 AudioTimeAxisView* atv;
1191 MidiTimeAxisView* mtv;
1197 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1200 atv->set_marked_for_display (yn);
1201 (*i)[_columns.visible] = yn;
1205 if (atv->is_audio_track()) {
1206 atv->set_marked_for_display (yn);
1207 (*i)[_columns.visible] = yn;
1212 if (!atv->is_audio_track()) {
1213 atv->set_marked_for_display (yn);
1214 (*i)[_columns.visible] = yn;
1219 else if ((mtv = dynamic_cast<MidiTimeAxisView*>(tv)) != 0) {
1222 mtv->set_marked_for_display (yn);
1223 (*i)[_columns.visible] = yn;
1227 if (mtv->is_midi_track()) {
1228 mtv->set_marked_for_display (yn);
1229 (*i)[_columns.visible] = yn;
1236 /* force route order keys catch up with visibility changes
1239 sync_presentation_info_from_treeview ();
1243 EditorRoutes::hide_all_routes ()
1245 set_all_tracks_visibility (false);
1249 EditorRoutes::show_all_routes ()
1251 set_all_tracks_visibility (true);
1255 EditorRoutes::show_all_audiotracks()
1257 set_all_audio_midi_visibility (1, true);
1260 EditorRoutes::hide_all_audiotracks ()
1262 set_all_audio_midi_visibility (1, false);
1266 EditorRoutes::show_all_audiobus ()
1268 set_all_audio_midi_visibility (2, true);
1271 EditorRoutes::hide_all_audiobus ()
1273 set_all_audio_midi_visibility (2, false);
1277 EditorRoutes::show_all_miditracks()
1279 set_all_audio_midi_visibility (3, true);
1282 EditorRoutes::hide_all_miditracks ()
1284 set_all_audio_midi_visibility (3, false);
1288 EditorRoutes::key_press (GdkEventKey* ev)
1290 TreeViewColumn *col;
1291 boost::shared_ptr<RouteList> rl (new RouteList);
1294 switch (ev->keyval) {
1296 case GDK_ISO_Left_Tab:
1298 /* If we appear to be editing something, leave that cleanly and appropriately. */
1299 if (name_editable) {
1300 name_editable->editing_done ();
1304 col = _display.get_column (_name_column); // select&focus on name column
1306 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
1307 treeview_select_previous (_display, _model, col);
1309 treeview_select_next (_display, _model, col);
1316 if (get_relevant_routes (rl)) {
1317 _session->set_controls (route_list_to_control_list (rl, &Stripable::mute_control), rl->front()->muted() ? 0.0 : 1.0, Controllable::NoGroup);
1323 if (get_relevant_routes (rl)) {
1324 _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), rl->front()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
1330 if (get_relevant_routes (rl)) {
1331 for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
1332 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*r);
1334 _session->set_controls (route_list_to_control_list (rl, &Stripable::rec_enable_control), !t->rec_enable_control()->get_value(), Controllable::NoGroup);
1349 EditorRoutes::get_relevant_routes (boost::shared_ptr<RouteList> rl)
1352 RouteTimeAxisView* rtv;
1353 RefPtr<TreeSelection> selection = _display.get_selection();
1357 if (selection->count_selected_rows() != 0) {
1361 RefPtr<TreeModel> tm = RefPtr<TreeModel>::cast_dynamic (_model);
1362 iter = selection->get_selected (tm);
1365 /* use mouse pointer */
1370 _display.get_pointer (x, y);
1371 _display.convert_widget_to_bin_window_coords (x, y, bx, by);
1373 if (_display.get_path_at_pos (bx, by, path)) {
1374 iter = _model->get_iter (path);
1379 tv = (*iter)[_columns.tv];
1381 rtv = dynamic_cast<RouteTimeAxisView*>(tv);
1383 rl->push_back (rtv->route());
1388 return !rl->empty();
1392 EditorRoutes::button_press (GdkEventButton* ev)
1394 if (Keyboard::is_context_menu_event (ev)) {
1398 _menu->popup (ev->button, ev->time);
1402 TreeModel::Path path;
1403 TreeViewColumn *tvc;
1407 if (!_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, tvc, cell_x, cell_y)) {
1408 /* cancel selection */
1409 _display.get_selection()->unselect_all ();
1410 /* end any editing by grabbing focus */
1411 _display.grab_focus ();
1415 //Scroll editor canvas to selected track
1416 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1418 Gtk::TreeModel::Row row = *_model->get_iter (path);
1419 TimeAxisView *tv = row[_columns.tv];
1422 _editor->ensure_time_axis_view_is_visible (*tv, true);
1430 EditorRoutes::selection_changed ()
1432 if (_ignore_selection_change) {
1436 _editor->begin_reversible_selection_op (X_("Select Track from Route List"));
1438 if (_display.get_selection()->count_selected_rows() > 0) {
1441 TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
1442 TrackViewList selected;
1444 for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
1446 if ((iter = _model->get_iter (*i))) {
1448 TimeAxisView* tv = (*iter)[_columns.tv];
1449 selected.push_back (tv);
1454 _editor->get_selection().set (selected);
1455 _editor->ensure_time_axis_view_is_visible (*(selected.front()), true);
1458 _editor->get_selection().clear_tracks ();
1461 _editor->commit_reversible_selection_op ();
1465 EditorRoutes::selection_filter (Glib::RefPtr<TreeModel> const& model, TreeModel::Path const& path, bool /*selected*/)
1467 TreeModel::iterator iter = model->get_iter (path);
1469 boost::shared_ptr<Stripable> stripable = (*iter)[_columns.stripable];
1476 EditorRoutes::initial_display ()
1484 DisplaySuspender ds;
1489 _session->get_stripables (s);
1490 _editor->add_stripables (s);
1492 sync_treeview_from_presentation_info (Properties::order);
1495 struct ViewStripable {
1497 boost::shared_ptr<Stripable> stripable;
1499 ViewStripable (TimeAxisView* t, boost::shared_ptr<Stripable> s)
1500 : tav (t), stripable (s) {}
1504 EditorRoutes::move_selected_tracks (bool up)
1506 TimeAxisView* scroll_to = 0;
1508 _session->get_stripables (sl);
1510 if (sl.size() < 2) {
1515 sl.sort (Stripable::Sorter());
1517 std::list<ViewStripable> view_stripables;
1519 /* build a list that includes time axis view information */
1521 for (StripableList::const_iterator sli = sl.begin(); sli != sl.end(); ++sli) {
1522 TimeAxisView* tv = _editor->time_axis_view_from_stripable (*sli);
1523 view_stripables.push_back (ViewStripable (tv, *sli));
1526 /* for each selected stripable, move it above or below the adjacent
1527 * stripable that has a time-axis view representation here. If there's
1528 * no such representation, then
1531 list<ViewStripable>::iterator unselected_neighbour;
1532 list<ViewStripable>::iterator vsi;
1535 PresentationInfo::ChangeSuspender cs;
1538 unselected_neighbour = view_stripables.end ();
1539 vsi = view_stripables.begin();
1541 while (vsi != view_stripables.end()) {
1543 if (vsi->stripable->is_selected()) {
1545 if (unselected_neighbour != view_stripables.end()) {
1547 PresentationInfo::order_t unselected_neighbour_order = unselected_neighbour->stripable->presentation_info().order();
1548 PresentationInfo::order_t my_order = vsi->stripable->presentation_info().order();
1550 unselected_neighbour->stripable->set_presentation_order (my_order);
1551 vsi->stripable->set_presentation_order (unselected_neighbour_order);
1554 scroll_to = vsi->tav;
1561 unselected_neighbour = vsi;
1571 unselected_neighbour = view_stripables.end();
1572 vsi = unselected_neighbour;
1578 if (vsi->stripable->is_selected()) {
1580 if (unselected_neighbour != view_stripables.end()) {
1582 PresentationInfo::order_t unselected_neighbour_order = unselected_neighbour->stripable->presentation_info().order();
1583 PresentationInfo::order_t my_order = vsi->stripable->presentation_info().order();
1585 unselected_neighbour->stripable->set_presentation_order (my_order);
1586 vsi->stripable->set_presentation_order (unselected_neighbour_order);
1589 scroll_to = vsi->tav;
1596 unselected_neighbour = vsi;
1601 } while (vsi != view_stripables.begin());
1606 _editor->ensure_time_axis_view_is_visible (*scroll_to, false);
1611 EditorRoutes::update_input_active_display ()
1613 TreeModel::Children rows = _model->children();
1614 TreeModel::Children::iterator i;
1616 for (i = rows.begin(); i != rows.end(); ++i) {
1617 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1619 if (boost::dynamic_pointer_cast<Track> (stripable)) {
1620 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (stripable);
1623 (*i)[_columns.is_input_active] = mt->input_active();
1630 EditorRoutes::update_rec_display ()
1632 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1633 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1638 EditorRoutes::idle_update_mute_rec_solo_etc()
1640 g_atomic_int_set (const_cast<gint*>(&_queue_tv_update), 0);
1641 TreeModel::Children rows = _model->children();
1642 TreeModel::Children::iterator i;
1644 for (i = rows.begin(); i != rows.end(); ++i) {
1645 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1646 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
1647 (*i)[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
1648 (*i)[_columns.solo_state] = RouteUI::solo_active_state (stripable);
1649 (*i)[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable) ? 1 : 0;
1650 (*i)[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable) ? 1 : 0;
1652 (*i)[_columns.active] = route->active ();
1654 (*i)[_columns.active] = true;
1657 boost::shared_ptr<Track> trk (boost::dynamic_pointer_cast<Track>(route));
1660 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
1662 if (trk->rec_enable_control()->get_value()) {
1663 if (_session->record_status() == Session::Recording) {
1664 (*i)[_columns.rec_state] = 1;
1666 (*i)[_columns.rec_state] = 2;
1668 } else if (mt && mt->step_editing()) {
1669 (*i)[_columns.rec_state] = 3;
1671 (*i)[_columns.rec_state] = 0;
1674 (*i)[_columns.rec_safe] = trk->rec_safe_control()->get_value();
1675 (*i)[_columns.name_editable] = !trk->rec_enable_control()->get_value();
1679 return false; // do not call again (until needed)
1684 EditorRoutes::update_mute_display ()
1686 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1687 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1692 EditorRoutes::update_solo_display ()
1694 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1695 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1700 EditorRoutes::update_solo_isolate_display ()
1702 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1703 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1708 EditorRoutes::update_solo_safe_display ()
1710 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1711 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1716 EditorRoutes::views () const
1718 list<TimeAxisView*> v;
1719 for (TreeModel::Children::iterator i = _model->children().begin(); i != _model->children().end(); ++i) {
1720 v.push_back ((*i)[_columns.tv]);
1727 EditorRoutes::clear ()
1729 PBD::Unwinder<bool> uw (_ignore_selection_change, true);
1730 _display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
1732 _display.set_model (_model);
1736 EditorRoutes::name_edit_started (CellEditable* ce, const Glib::ustring&)
1740 /* give it a special name */
1742 Gtk::Entry *e = dynamic_cast<Gtk::Entry*> (ce);
1745 e->set_name (X_("RouteNameEditorEntry"));
1750 EditorRoutes::name_edit (std::string const & path, std::string const & new_text)
1754 TreeIter iter = _model->get_iter (path);
1760 boost::shared_ptr<Stripable> stripable = (*iter)[_columns.stripable];
1762 if (stripable && stripable->name() != new_text) {
1763 stripable->set_name (new_text);
1768 EditorRoutes::solo_changed_so_update_mute ()
1770 update_mute_display ();
1774 EditorRoutes::show_tracks_with_regions_at_playhead ()
1776 boost::shared_ptr<RouteList> const r = _session->get_routes_with_regions_at (_session->transport_sample ());
1778 set<TimeAxisView*> show;
1779 for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
1780 TimeAxisView* tav = _editor->time_axis_view_from_stripable (*i);
1786 DisplaySuspender ds;
1788 TreeModel::Children rows = _model->children ();
1789 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
1790 TimeAxisView* tv = (*i)[_columns.tv];
1791 bool to_show = (show.find (tv) != show.end());
1793 tv->set_marked_for_display (to_show);
1794 (*i)[_columns.visible] = to_show;
1797 /* force route order keys catch up with visibility changes
1800 sync_presentation_info_from_treeview ();
1804 EditorRoutes::plugin_setup (boost::shared_ptr<Route> r, boost::shared_ptr<PluginInsert> pi, ARDOUR::Route::PluginSetupOptions flags)
1806 PluginSetupDialog psd (r, pi, flags);
1807 int rv = psd.run ();
1808 return rv + (psd.fan_out() ? 4 : 0);