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/session.h"
35 #include "ardour/solo_isolate_control.h"
36 #include "ardour/utils.h"
37 #include "ardour/vca.h"
38 #include "ardour/vca_manager.h"
40 #include "gtkmm2ext/cell_renderer_pixbuf_multi.h"
41 #include "gtkmm2ext/cell_renderer_pixbuf_toggle.h"
42 #include "gtkmm2ext/treeutils.h"
45 #include "ardour_ui.h"
46 #include "audio_time_axis.h"
48 #include "editor_group_tabs.h"
49 #include "editor_routes.h"
50 #include "gui_thread.h"
52 #include "midi_time_axis.h"
53 #include "mixer_strip.h"
54 #include "plugin_setup_dialog.h"
55 #include "route_sorter.h"
57 #include "vca_time_axis.h"
63 using namespace ARDOUR;
64 using namespace ARDOUR_UI_UTILS;
67 using namespace Gtkmm2ext;
69 using Gtkmm2ext::Keyboard;
77 EditorRoutes::EditorRoutes (Editor* e)
79 , _ignore_reorder (false)
80 , _no_redisplay (false)
81 , _adding_routes (false)
82 , _route_deletion_in_progress (false)
83 , _redisplay_on_resume (false)
84 , _redisplay_active (0)
85 , _queue_tv_update (0)
88 , selection_countdown (0)
91 static const int column_width = 22;
93 _scroller.add (_display);
94 _scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
96 _model = ListStore::create (_columns);
97 _display.set_model (_model);
99 // Record enable toggle
100 CellRendererPixbufMulti* rec_col_renderer = manage (new CellRendererPixbufMulti());
102 rec_col_renderer->set_pixbuf (0, ::get_icon("record-normal-disabled"));
103 rec_col_renderer->set_pixbuf (1, ::get_icon("record-normal-in-progress"));
104 rec_col_renderer->set_pixbuf (2, ::get_icon("record-normal-enabled"));
105 rec_col_renderer->set_pixbuf (3, ::get_icon("record-step"));
106 rec_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_enable_changed));
108 TreeViewColumn* rec_state_column = manage (new TreeViewColumn("R", *rec_col_renderer));
110 rec_state_column->add_attribute(rec_col_renderer->property_state(), _columns.rec_state);
111 rec_state_column->add_attribute(rec_col_renderer->property_visible(), _columns.is_track);
113 rec_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
114 rec_state_column->set_alignment(ALIGN_CENTER);
115 rec_state_column->set_expand(false);
116 rec_state_column->set_fixed_width(column_width);
119 // Record safe toggle
120 CellRendererPixbufMulti* rec_safe_renderer = manage (new CellRendererPixbufMulti ());
122 rec_safe_renderer->set_pixbuf (0, ::get_icon("rec-safe-disabled"));
123 rec_safe_renderer->set_pixbuf (1, ::get_icon("rec-safe-enabled"));
124 rec_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_rec_safe_toggled));
126 TreeViewColumn* rec_safe_column = manage (new TreeViewColumn(_("RS"), *rec_safe_renderer));
127 rec_safe_column->add_attribute(rec_safe_renderer->property_state(), _columns.rec_safe);
128 rec_safe_column->add_attribute(rec_safe_renderer->property_visible(), _columns.is_track);
129 rec_safe_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
130 rec_safe_column->set_alignment(ALIGN_CENTER);
131 rec_safe_column->set_expand(false);
132 rec_safe_column->set_fixed_width(column_width);
137 CellRendererPixbufMulti* input_active_col_renderer = manage (new CellRendererPixbufMulti());
138 input_active_col_renderer->set_pixbuf (0, ::get_icon("midi-input-inactive"));
139 input_active_col_renderer->set_pixbuf (1, ::get_icon("midi-input-active"));
140 input_active_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_input_active_changed));
142 TreeViewColumn* input_active_column = manage (new TreeViewColumn ("I", *input_active_col_renderer));
144 input_active_column->add_attribute(input_active_col_renderer->property_state(), _columns.is_input_active);
145 input_active_column->add_attribute (input_active_col_renderer->property_visible(), _columns.is_midi);
147 input_active_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
148 input_active_column->set_alignment(ALIGN_CENTER);
149 input_active_column->set_expand(false);
150 input_active_column->set_fixed_width(column_width);
152 // Mute enable toggle
153 CellRendererPixbufMulti* mute_col_renderer = manage (new CellRendererPixbufMulti());
155 mute_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("mute-disabled"));
156 mute_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("muted-by-others"));
157 mute_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("mute-enabled"));
158 mute_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_mute_enable_toggled));
160 TreeViewColumn* mute_state_column = manage (new TreeViewColumn("M", *mute_col_renderer));
162 mute_state_column->add_attribute(mute_col_renderer->property_state(), _columns.mute_state);
163 mute_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
164 mute_state_column->set_alignment(ALIGN_CENTER);
165 mute_state_column->set_expand(false);
166 mute_state_column->set_fixed_width(15);
168 // Solo enable toggle
169 CellRendererPixbufMulti* solo_col_renderer = manage (new CellRendererPixbufMulti());
171 solo_col_renderer->set_pixbuf (Gtkmm2ext::Off, ::get_icon("solo-disabled"));
172 solo_col_renderer->set_pixbuf (Gtkmm2ext::ExplicitActive, ::get_icon("solo-enabled"));
173 solo_col_renderer->set_pixbuf (Gtkmm2ext::ImplicitActive, ::get_icon("soloed-by-others"));
174 solo_col_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_enable_toggled));
176 TreeViewColumn* solo_state_column = manage (new TreeViewColumn("S", *solo_col_renderer));
178 solo_state_column->add_attribute(solo_col_renderer->property_state(), _columns.solo_state);
179 solo_state_column->add_attribute(solo_col_renderer->property_visible(), _columns.solo_visible);
180 solo_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
181 solo_state_column->set_alignment(ALIGN_CENTER);
182 solo_state_column->set_expand(false);
183 solo_state_column->set_fixed_width(column_width);
185 // Solo isolate toggle
186 CellRendererPixbufMulti* solo_iso_renderer = manage (new CellRendererPixbufMulti());
188 solo_iso_renderer->set_pixbuf (0, ::get_icon("solo-isolate-disabled"));
189 solo_iso_renderer->set_pixbuf (1, ::get_icon("solo-isolate-enabled"));
190 solo_iso_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_isolate_toggled));
192 TreeViewColumn* solo_isolate_state_column = manage (new TreeViewColumn("SI", *solo_iso_renderer));
194 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_state(), _columns.solo_isolate_state);
195 solo_isolate_state_column->add_attribute(solo_iso_renderer->property_visible(), _columns.solo_visible);
196 solo_isolate_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
197 solo_isolate_state_column->set_alignment(ALIGN_CENTER);
198 solo_isolate_state_column->set_expand(false);
199 solo_isolate_state_column->set_fixed_width(column_width);
202 CellRendererPixbufMulti* solo_safe_renderer = manage (new CellRendererPixbufMulti ());
204 solo_safe_renderer->set_pixbuf (0, ::get_icon("solo-safe-disabled"));
205 solo_safe_renderer->set_pixbuf (1, ::get_icon("solo-safe-enabled"));
206 solo_safe_renderer->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::on_tv_solo_safe_toggled));
208 TreeViewColumn* solo_safe_state_column = manage (new TreeViewColumn(_("SS"), *solo_safe_renderer));
209 solo_safe_state_column->add_attribute(solo_safe_renderer->property_state(), _columns.solo_safe_state);
210 solo_safe_state_column->add_attribute(solo_safe_renderer->property_visible(), _columns.solo_visible);
211 solo_safe_state_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
212 solo_safe_state_column->set_alignment(ALIGN_CENTER);
213 solo_safe_state_column->set_expand(false);
214 solo_safe_state_column->set_fixed_width(column_width);
216 _name_column = _display.append_column ("", _columns.text) - 1;
217 _visible_column = _display.append_column ("", _columns.visible) - 1;
218 _active_column = _display.append_column ("", _columns.active) - 1;
220 _display.append_column (*input_active_column);
221 _display.append_column (*rec_state_column);
222 _display.append_column (*rec_safe_column);
223 _display.append_column (*mute_state_column);
224 _display.append_column (*solo_state_column);
225 _display.append_column (*solo_isolate_state_column);
226 _display.append_column (*solo_safe_state_column);
233 { 0, _("Name"), _("Track/Bus Name") },
234 { 1, S_("Visible|V"), _("Track/Bus visible ?") },
235 { 2, S_("Active|A"), _("Track/Bus active ?") },
236 { 3, S_("MidiInput|I"), _("MIDI input enabled") },
237 { 4, S_("Rec|R"), _("Record enabled") },
238 { 5, S_("Rec|RS"), _("Record Safe") },
239 { 6, S_("Mute|M"), _("Muted") },
240 { 7, S_("Solo|S"), _("Soloed") },
241 { 8, S_("SoloIso|SI"), _("Solo Isolated") },
242 { 9, S_("SoloLock|SS"), _("Solo Safe (Locked)") },
246 for (int i = 0; ci[i].index >= 0; ++i) {
247 col = _display.get_column (ci[i].index);
248 l = manage (new Label (ci[i].label));
249 set_tooltip (*l, ci[i].tooltip);
250 col->set_widget (*l);
254 _display.set_headers_visible (true);
255 _display.get_selection()->set_mode (SELECTION_SINGLE);
256 _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRoutes::selection_filter));
257 _display.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &EditorRoutes::selection_changed));
258 _display.set_reorderable (true);
259 _display.set_name (X_("EditGroupList"));
260 _display.set_rules_hint (true);
261 _display.set_size_request (100, -1);
262 _display.add_object_drag (_columns.stripable.index(), "routes");
264 CellRendererText* name_cell = dynamic_cast<CellRendererText*> (_display.get_column_cell_renderer (_name_column));
267 name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit_started));
269 TreeViewColumn* name_column = _display.get_column (_name_column);
271 assert (name_column);
273 name_column->add_attribute (name_cell->property_editable(), _columns.name_editable);
274 name_column->set_sizing(TREE_VIEW_COLUMN_FIXED);
275 name_column->set_expand(true);
276 name_column->set_min_width(50);
278 name_cell->property_editable() = true;
279 name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRoutes::name_edit));
281 // Set the visible column cell renderer to radio toggle
282 CellRendererToggle* visible_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_visible_column));
284 visible_cell->property_activatable() = true;
285 visible_cell->property_radio() = false;
286 visible_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::visible_changed));
288 TreeViewColumn* visible_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_visible_column));
289 visible_col->set_expand(false);
290 visible_col->set_sizing(TREE_VIEW_COLUMN_FIXED);
291 visible_col->set_fixed_width(30);
292 visible_col->set_alignment(ALIGN_CENTER);
294 CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (_active_column));
296 active_cell->property_activatable() = true;
297 active_cell->property_radio() = false;
298 active_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRoutes::active_changed));
300 TreeViewColumn* active_col = dynamic_cast<TreeViewColumn*> (_display.get_column (_active_column));
301 active_col->set_expand (false);
302 active_col->set_sizing (TREE_VIEW_COLUMN_FIXED);
303 active_col->set_fixed_width (30);
304 active_col->set_alignment (ALIGN_CENTER);
306 _model->signal_row_deleted().connect (sigc::mem_fun (*this, &EditorRoutes::row_deleted));
307 _model->signal_rows_reordered().connect (sigc::mem_fun (*this, &EditorRoutes::reordered));
309 _display.signal_button_press_event().connect (sigc::mem_fun (*this, &EditorRoutes::button_press), false);
310 _scroller.signal_key_press_event().connect (sigc::mem_fun(*this, &EditorRoutes::key_press), false);
312 _scroller.signal_focus_in_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_in), false);
313 _scroller.signal_focus_out_event().connect (sigc::mem_fun (*this, &EditorRoutes::focus_out));
315 _display.signal_enter_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::enter_notify), false);
316 _display.signal_leave_notify_event().connect (sigc::mem_fun (*this, &EditorRoutes::leave_notify), false);
318 _display.set_enable_search (false);
320 Route::PluginSetup.connect_same_thread (*this, boost::bind (&EditorRoutes::plugin_setup, this, _1, _2, _3));
321 PresentationInfo::Change.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::sync_treeview_from_presentation_info, this), gui_context());
325 EditorRoutes::focus_in (GdkEventFocus*)
327 Window* win = dynamic_cast<Window*> (_scroller.get_toplevel ());
330 old_focus = win->get_focus ();
337 /* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */
342 EditorRoutes::focus_out (GdkEventFocus*)
345 old_focus->grab_focus ();
353 EditorRoutes::enter_notify (GdkEventCrossing*)
359 /* arm counter so that ::selection_filter() will deny selecting anything for the
360 * next two attempts to change selection status.
362 selection_countdown = 2;
363 _scroller.grab_focus ();
364 Keyboard::magic_widget_grab_focus ();
369 EditorRoutes::leave_notify (GdkEventCrossing*)
371 selection_countdown = 0;
374 old_focus->grab_focus ();
378 Keyboard::magic_widget_drop_focus ();
383 EditorRoutes::set_session (Session* s)
385 SessionHandlePtr::set_session (s);
390 _session->SoloChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::solo_changed_so_update_mute, this), gui_context());
391 _session->RecordStateChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
393 /* TODO: check if these needs to be tied in with DisplaySuspender
394 * Given that the UI is single-threaded and DisplaySuspender is only used
395 * in loops in the UI thread all should be fine.
397 _session->BatchUpdateStart.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::suspend_redisplay, this), gui_context());
398 _session->BatchUpdateEnd.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::resume_redisplay, this), gui_context());
403 EditorRoutes::on_input_active_changed (std::string const & path_string)
405 // Get the model row that has been toggled.
406 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
408 TimeAxisView* tv = row[_columns.tv];
409 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
412 boost::shared_ptr<MidiTrack> mt;
413 mt = rtv->midi_track();
415 mt->set_input_active (!mt->input_active());
421 EditorRoutes::on_tv_rec_enable_changed (std::string const & path_string)
423 // Get the model row that has been toggled.
424 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
426 TimeAxisView* tv = row[_columns.tv];
427 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
433 boost::shared_ptr<AutomationControl> ac = rtv->route()->rec_enable_control();
436 ac->set_value (!ac->get_value(), Controllable::UseGroup);
441 EditorRoutes::on_tv_rec_safe_toggled (std::string const & path_string)
443 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
444 TimeAxisView* tv = row[_columns.tv];
445 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
451 boost::shared_ptr<AutomationControl> ac (rtv->route()->rec_safe_control());
454 ac->set_value (!ac->get_value(), Controllable::UseGroup);
459 EditorRoutes::on_tv_mute_enable_toggled (std::string const & path_string)
461 // Get the model row that has been toggled.
462 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
464 TimeAxisView *tv = row[_columns.tv];
465 RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
471 boost::shared_ptr<AutomationControl> ac (rtv->route()->mute_control());
474 ac->set_value (!ac->get_value(), Controllable::UseGroup);
479 EditorRoutes::on_tv_solo_enable_toggled (std::string const & path_string)
481 // Get the model row that has been toggled.
482 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
484 TimeAxisView *tv = row[_columns.tv];
485 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
491 boost::shared_ptr<AutomationControl> ac (rtv->route()->solo_control());
494 ac->set_value (!ac->get_value(), Controllable::UseGroup);
499 EditorRoutes::on_tv_solo_isolate_toggled (std::string const & path_string)
501 // Get the model row that has been toggled.
502 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
504 TimeAxisView *tv = row[_columns.tv];
505 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
511 boost::shared_ptr<AutomationControl> ac (rtv->route()->solo_isolate_control());
514 ac->set_value (!ac->get_value(), Controllable::UseGroup);
519 EditorRoutes::on_tv_solo_safe_toggled (std::string const & path_string)
521 // Get the model row that has been toggled.
522 Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
524 TimeAxisView *tv = row[_columns.tv];
525 RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
531 boost::shared_ptr<AutomationControl> ac (rtv->route()->solo_safe_control());
534 ac->set_value (!ac->get_value(), Controllable::UseGroup);
539 EditorRoutes::build_menu ()
541 using namespace Menu_Helpers;
546 MenuList& items = _menu->items();
547 _menu->set_name ("ArdourContextMenu");
549 items.push_back (MenuElem (_("Show All"), sigc::mem_fun (*this, &EditorRoutes::show_all_routes)));
550 items.push_back (MenuElem (_("Hide All"), sigc::mem_fun (*this, &EditorRoutes::hide_all_routes)));
551 items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiotracks)));
552 items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiotracks)));
553 items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun (*this, &EditorRoutes::show_all_audiobus)));
554 items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun (*this, &EditorRoutes::hide_all_audiobus)));
555 items.push_back (MenuElem (_("Show All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::show_all_miditracks)));
556 items.push_back (MenuElem (_("Hide All Midi Tracks"), sigc::mem_fun (*this, &EditorRoutes::hide_all_miditracks)));
557 items.push_back (MenuElem (_("Only Show Tracks with Regions Under Playhead"), sigc::mem_fun (*this, &EditorRoutes::show_tracks_with_regions_at_playhead)));
561 EditorRoutes::show_menu ()
567 _menu->popup (1, gtk_get_current_event_time());
571 EditorRoutes::redisplay_real ()
573 TreeModel::Children rows = _model->children();
574 TreeModel::Children::iterator i;
577 /* n will be the count of tracks plus children (updated by TimeAxisView::show_at),
578 * so we will use that to know where to put things.
582 for (n = 0, position = 0, i = rows.begin(); i != rows.end(); ++i) {
583 TimeAxisView *tv = (*i)[_columns.tv];
584 boost::shared_ptr<Stripable> route = (*i)[_columns.stripable];
587 // just a "title" row
591 bool visible = tv->marked_for_display ();
593 /* show or hide the TimeAxisView */
595 position += tv->show_at (position, n, &_editor->edit_controls_vbox);
603 /* whenever we go idle, update the track view list to reflect the new order.
604 * we can't do this here, because we could mess up something that is traversing
605 * the track order and has caused a redisplay of the list.
607 Glib::signal_idle().connect (sigc::mem_fun (*_editor, &Editor::sync_track_view_list_and_routes));
609 _editor->reset_controls_layout_height (position);
610 _editor->reset_controls_layout_width ();
611 _editor->_full_canvas_height = position;
613 if ((_editor->vertical_adjustment.get_value() + _editor->_visible_canvas_height) > _editor->vertical_adjustment.get_upper()) {
615 * We're increasing the size of the canvas while the bottom is visible.
616 * We scroll down to keep in step with the controls layout.
618 _editor->vertical_adjustment.set_value (_editor->_full_canvas_height - _editor->_visible_canvas_height);
623 EditorRoutes::redisplay ()
625 if (!_session || _session->deletion_in_progress()) {
630 _redisplay_on_resume = true;
634 // model deprecated g_atomic_int_exchange_and_add(, 1)
635 g_atomic_int_inc(const_cast<gint*>(&_redisplay_active));
636 if (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 1)) {
637 /* recursive re-display can happen if redisplay shows/hides a TrackView
638 * which has children and their display status changes as result.
645 while (!g_atomic_int_compare_and_exchange (const_cast<gint*>(&_redisplay_active), 1, 0)) {
646 g_atomic_int_set(const_cast<gint*>(&_redisplay_active), 1);
652 EditorRoutes::row_deleted (Gtk::TreeModel::Path const &)
654 if (!_session || _session->deletion_in_progress()) {
657 /* this happens as the second step of a DnD within the treeview, and
658 * when a route is actually removed. we don't differentiate between
661 * note that the sync_presentation_info_from_treeview() step may not
662 * actually change any presentation info (e.g. the last track may be
663 * removed, so all other tracks keep the same presentation info), which
664 * means that no redisplay would happen. so we have to force a
668 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview row deleted\n");
671 sync_presentation_info_from_treeview ();
675 EditorRoutes::reordered (TreeModel::Path const &, TreeModel::iterator const &, int* /*what*/)
677 /* reordering implies that RID's will change, so
678 sync_presentation_info_from_treeview() will cause a redisplay.
681 DEBUG_TRACE (DEBUG::OrderKeys, "editor routes treeview reordered\n");
682 sync_presentation_info_from_treeview ();
686 EditorRoutes::visible_changed (std::string const & path)
688 if (_session && _session->deletion_in_progress()) {
695 if ((iter = _model->get_iter (path))) {
696 TimeAxisView* tv = (*iter)[_columns.tv];
698 bool visible = (*iter)[_columns.visible];
700 if (tv->set_marked_for_display (!visible)) {
701 update_visibility ();
708 EditorRoutes::active_changed (std::string const & path)
710 if (_session && _session->deletion_in_progress ()) {
714 Gtk::TreeModel::Row row = *_model->get_iter (path);
715 boost::shared_ptr<Stripable> stripable = row[_columns.stripable];
716 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
718 bool const active = row[_columns.active];
719 route->set_active (!active, this);
724 EditorRoutes::time_axis_views_added (list<TimeAxisView*> tavs)
726 PBD::Unwinder<bool> at (_adding_routes, true);
727 bool from_scratch = (_model->children().size() == 0);
728 Gtk::TreeModel::Children::iterator insert_iter = _model->children().end();
730 for (Gtk::TreeModel::Children::iterator it = _model->children().begin(); it != _model->children().end(); ++it) {
732 boost::shared_ptr<Stripable> r = (*it)[_columns.stripable];
734 if (r->presentation_info().order() == (tavs.front()->stripable()->presentation_info().order() + tavs.size())) {
740 _display.set_model (Glib::RefPtr<ListStore>());
742 for (list<TimeAxisView*>::iterator x = tavs.begin(); x != tavs.end(); ++x) {
744 VCATimeAxisView* vtav = dynamic_cast<VCATimeAxisView*> (*x);
745 RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*> (*x);
747 TreeModel::Row row = *(_model->insert (insert_iter));
749 boost::shared_ptr<Stripable> stripable;
750 boost::shared_ptr<MidiTrack> midi_trk;
754 stripable = vtav->vca();
756 row[_columns.is_track] = false;
757 row[_columns.is_input_active] = false;
758 row[_columns.is_midi] = false;
762 stripable = rtav->route ();
763 midi_trk= boost::dynamic_pointer_cast<MidiTrack> (stripable);
765 row[_columns.is_track] = (boost::dynamic_pointer_cast<Track> (stripable) != 0);
769 row[_columns.is_input_active] = midi_trk->input_active ();
770 row[_columns.is_midi] = true;
772 row[_columns.is_input_active] = false;
773 row[_columns.is_midi] = false;
781 row[_columns.text] = stripable->name();
782 row[_columns.visible] = (*x)->marked_for_display();
783 row[_columns.active] = true;
784 row[_columns.tv] = *x;
785 row[_columns.stripable] = stripable;
786 row[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
787 row[_columns.solo_state] = RouteUI::solo_active_state (stripable);
788 row[_columns.solo_visible] = true;
789 row[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable);
790 row[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable);
791 row[_columns.name_editable] = true;
793 boost::weak_ptr<Stripable> ws (stripable);
795 /* for now, we need both of these. PropertyChanged covers on
796 * pre-defined, "global" things of interest to a
797 * UI. gui_changed covers arbitrary, un-enumerated, un-typed
798 * changes that may only be of interest to a particular
799 * UI (e.g. track-height is not of any relevant to OSC)
802 stripable->gui_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::handle_gui_changes, this, _1, _2), gui_context());
803 stripable->PropertyChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::route_property_changed, this, _1, ws), gui_context());
805 if (boost::dynamic_pointer_cast<Track> (stripable)) {
806 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (stripable);
807 t->rec_enable_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
808 t->rec_safe_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
812 midi_trk->StepEditStatusChange.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context());
813 midi_trk->InputActiveChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_input_active_display, this), gui_context());
816 boost::shared_ptr<AutomationControl> ac;
818 if ((ac = stripable->mute_control()) != 0) {
819 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_mute_display, this), gui_context());
821 if ((ac = stripable->solo_control()) != 0) {
822 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_display, this), gui_context());
824 if ((ac = stripable->solo_isolate_control()) != 0) {
825 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_isolate_display, this), gui_context());
827 if ((ac = stripable->solo_safe_control()) != 0) {
828 ac->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_safe_display, this), gui_context());
832 rtav->route()->active_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_active_display, this), gui_context ());
836 update_rec_display ();
837 update_mute_display ();
838 update_solo_display ();
839 update_solo_isolate_display ();
840 update_solo_safe_display ();
841 update_input_active_display ();
842 update_active_display ();
844 _display.set_model (_model);
846 /* now update route order keys from the treeview/track display order */
849 sync_presentation_info_from_treeview ();
856 EditorRoutes::handle_gui_changes (string const & what, void*)
858 if (_adding_routes) {
862 if (what == "track_height") {
863 /* Optional :make tracks change height while it happens, instead
869 if (what == "visible_tracks") {
875 EditorRoutes::route_removed (TimeAxisView *tv)
877 ENSURE_GUI_THREAD (*this, &EditorRoutes::route_removed, tv)
879 TreeModel::Children rows = _model->children();
880 TreeModel::Children::iterator ri;
882 for (ri = rows.begin(); ri != rows.end(); ++ri) {
883 if ((*ri)[_columns.tv] == tv) {
884 PBD::Unwinder<bool> uw (_route_deletion_in_progress, true);
890 /* the deleted signal for the treeview/model will take
896 EditorRoutes::route_property_changed (const PropertyChange& what_changed, boost::weak_ptr<Stripable> s)
898 if (_adding_routes) {
902 if (what_changed.contains (ARDOUR::Properties::name)) {
904 boost::shared_ptr<Stripable> stripable = s.lock ();
910 TreeModel::Children rows = _model->children();
911 TreeModel::Children::iterator i;
913 for (i = rows.begin(); i != rows.end(); ++i) {
914 boost::shared_ptr<Stripable> ss = (*i)[_columns.stripable];
915 if (ss == stripable) {
916 (*i)[_columns.text] = stripable->name();
924 EditorRoutes::update_active_display ()
926 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
927 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
932 EditorRoutes::update_visibility ()
934 TreeModel::Children rows = _model->children();
935 TreeModel::Children::iterator i;
939 for (i = rows.begin(); i != rows.end(); ++i) {
940 TimeAxisView *tv = (*i)[_columns.tv];
941 (*i)[_columns.visible] = tv->marked_for_display ();
944 /* force route order keys catch up with visibility changes
947 sync_presentation_info_from_treeview ();
951 EditorRoutes::hide_track_in_display (TimeAxisView& tv)
953 TreeModel::Children rows = _model->children();
954 TreeModel::Children::iterator i;
956 for (i = rows.begin(); i != rows.end(); ++i) {
957 if ((*i)[_columns.tv] == &tv) {
958 tv.set_marked_for_display (false);
959 (*i)[_columns.visible] = false;
967 EditorRoutes::show_track_in_display (TimeAxisView& tv)
969 TreeModel::Children rows = _model->children();
970 TreeModel::Children::iterator i;
973 for (i = rows.begin(); i != rows.end(); ++i) {
974 if ((*i)[_columns.tv] == &tv) {
975 tv.set_marked_for_display (true);
976 (*i)[_columns.visible] = true;
984 EditorRoutes::sync_presentation_info_from_treeview ()
986 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
990 TreeModel::Children rows = _model->children();
996 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync presentation info from treeview\n");
998 TreeModel::Children::iterator ri;
1000 PresentationInfo::order_t order = 0;
1002 for (ri = rows.begin(); ri != rows.end(); ++ri) {
1004 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1005 bool visible = (*ri)[_columns.visible];
1007 /* Monitor and Auditioner do not get their presentation
1011 if (stripable->is_monitor() || stripable->is_auditioner()) {
1015 stripable->presentation_info().set_hidden (!visible);
1017 if (order != stripable->presentation_info().order()) {
1018 stripable->set_presentation_order_explicit (order);
1026 DEBUG_TRACE (DEBUG::OrderKeys, "... notify PI change from editor GUI\n");
1027 _session->notify_presentation_info_change ();
1032 EditorRoutes::sync_treeview_from_presentation_info ()
1034 /* Some route order key(s) have been changed, make sure that
1035 we update out tree/list model and GUI to reflect the change.
1038 if (_ignore_reorder || !_session || _session->deletion_in_progress()) {
1042 DEBUG_TRACE (DEBUG::OrderKeys, "editor sync model from presentation info.\n");
1044 vector<int> neworder;
1045 TreeModel::Children rows = _model->children();
1046 uint32_t old_order = 0;
1047 bool changed = false;
1053 OrderingKeys sorted;
1055 for (TreeModel::Children::iterator ri = rows.begin(); ri != rows.end(); ++ri, ++old_order) {
1056 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1057 /* use global order */
1058 sorted.push_back (OrderKeys (old_order, stripable->presentation_info().order()));
1061 SortByNewDisplayOrder cmp;
1063 sort (sorted.begin(), sorted.end(), cmp);
1064 neworder.assign (sorted.size(), 0);
1068 for (OrderingKeys::iterator sr = sorted.begin(); sr != sorted.end(); ++sr, ++n) {
1070 neworder[n] = sr->old_display_order;
1072 if (sr->old_display_order != n) {
1078 Unwinder<bool> uw (_ignore_reorder, true);
1079 _model->reorder (neworder);
1086 EditorRoutes::hide_all_tracks (bool /*with_select*/)
1088 TreeModel::Children rows = _model->children();
1089 TreeModel::Children::iterator i;
1091 DisplaySuspender ds;
1093 for (i = rows.begin(); i != rows.end(); ++i) {
1095 TreeModel::Row row = (*i);
1096 TimeAxisView *tv = row[_columns.tv];
1102 row[_columns.visible] = false;
1107 EditorRoutes::set_all_tracks_visibility (bool yn)
1109 TreeModel::Children rows = _model->children();
1110 TreeModel::Children::iterator i;
1112 DisplaySuspender ds;
1114 for (i = rows.begin(); i != rows.end(); ++i) {
1116 TreeModel::Row row = (*i);
1117 TimeAxisView* tv = row[_columns.tv];
1123 tv->set_marked_for_display (yn);
1124 (*i)[_columns.visible] = yn;
1127 /* force route order keys catch up with visibility changes
1130 sync_presentation_info_from_treeview ();
1134 EditorRoutes::set_all_audio_midi_visibility (int tracks, bool yn)
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];
1146 AudioTimeAxisView* atv;
1147 MidiTimeAxisView* mtv;
1153 if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) {
1156 atv->set_marked_for_display (yn);
1157 (*i)[_columns.visible] = yn;
1161 if (atv->is_audio_track()) {
1162 atv->set_marked_for_display (yn);
1163 (*i)[_columns.visible] = yn;
1168 if (!atv->is_audio_track()) {
1169 atv->set_marked_for_display (yn);
1170 (*i)[_columns.visible] = yn;
1175 else if ((mtv = dynamic_cast<MidiTimeAxisView*>(tv)) != 0) {
1178 mtv->set_marked_for_display (yn);
1179 (*i)[_columns.visible] = yn;
1183 if (mtv->is_midi_track()) {
1184 mtv->set_marked_for_display (yn);
1185 (*i)[_columns.visible] = yn;
1192 /* force route order keys catch up with visibility changes
1195 sync_presentation_info_from_treeview ();
1199 EditorRoutes::hide_all_routes ()
1201 set_all_tracks_visibility (false);
1205 EditorRoutes::show_all_routes ()
1207 set_all_tracks_visibility (true);
1211 EditorRoutes::show_all_audiotracks()
1213 set_all_audio_midi_visibility (1, true);
1216 EditorRoutes::hide_all_audiotracks ()
1218 set_all_audio_midi_visibility (1, false);
1222 EditorRoutes::show_all_audiobus ()
1224 set_all_audio_midi_visibility (2, true);
1227 EditorRoutes::hide_all_audiobus ()
1229 set_all_audio_midi_visibility (2, false);
1233 EditorRoutes::show_all_miditracks()
1235 set_all_audio_midi_visibility (3, true);
1238 EditorRoutes::hide_all_miditracks ()
1240 set_all_audio_midi_visibility (3, false);
1244 EditorRoutes::key_press (GdkEventKey* ev)
1246 TreeViewColumn *col;
1247 boost::shared_ptr<RouteList> rl (new RouteList);
1250 switch (ev->keyval) {
1252 case GDK_ISO_Left_Tab:
1254 /* If we appear to be editing something, leave that cleanly and appropriately. */
1255 if (name_editable) {
1256 name_editable->editing_done ();
1260 col = _display.get_column (_name_column); // select&focus on name column
1262 if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
1263 treeview_select_previous (_display, _model, col);
1265 treeview_select_next (_display, _model, col);
1272 if (get_relevant_routes (rl)) {
1273 _session->set_controls (route_list_to_control_list (rl, &Stripable::mute_control), rl->front()->muted() ? 0.0 : 1.0, Controllable::NoGroup);
1279 if (get_relevant_routes (rl)) {
1280 _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), rl->front()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
1286 if (get_relevant_routes (rl)) {
1287 for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
1288 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*r);
1290 _session->set_controls (route_list_to_control_list (rl, &Stripable::rec_enable_control), !t->rec_enable_control()->get_value(), Controllable::NoGroup);
1305 EditorRoutes::get_relevant_routes (boost::shared_ptr<RouteList> rl)
1308 RouteTimeAxisView* rtv;
1309 RefPtr<TreeSelection> selection = _display.get_selection();
1313 if (selection->count_selected_rows() != 0) {
1317 RefPtr<TreeModel> tm = RefPtr<TreeModel>::cast_dynamic (_model);
1318 iter = selection->get_selected (tm);
1321 /* use mouse pointer */
1326 _display.get_pointer (x, y);
1327 _display.convert_widget_to_bin_window_coords (x, y, bx, by);
1329 if (_display.get_path_at_pos (bx, by, path)) {
1330 iter = _model->get_iter (path);
1335 tv = (*iter)[_columns.tv];
1337 rtv = dynamic_cast<RouteTimeAxisView*>(tv);
1339 rl->push_back (rtv->route());
1344 return !rl->empty();
1348 EditorRoutes::button_press (GdkEventButton* ev)
1350 if (Keyboard::is_context_menu_event (ev)) {
1355 TreeModel::Path path;
1356 TreeViewColumn *tvc;
1360 if (!_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, tvc, cell_x, cell_y)) {
1361 /* cancel selection */
1362 _display.get_selection()->unselect_all ();
1363 /* end any editing by grabbing focus */
1364 _display.grab_focus ();
1368 //Scroll editor canvas to selected track
1369 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1371 Gtk::TreeModel::Row row = *_model->get_iter (path);
1372 TimeAxisView *tv = row[_columns.tv];
1375 _editor->ensure_time_axis_view_is_visible (*tv, true);
1383 EditorRoutes::selection_changed ()
1385 _editor->begin_reversible_selection_op (X_("Select Track from Route List"));
1387 if (_display.get_selection()->count_selected_rows() > 0) {
1390 TreeView::Selection::ListHandle_Path rows = _display.get_selection()->get_selected_rows ();
1391 TrackViewList selected;
1393 _editor->get_selection().clear_regions ();
1395 for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
1397 if ((iter = _model->get_iter (*i))) {
1399 TimeAxisView* tv = (*iter)[_columns.tv];
1400 selected.push_back (tv);
1405 _editor->get_selection().set (selected);
1406 _editor->ensure_time_axis_view_is_visible (*(selected.front()), true);
1409 _editor->get_selection().clear_tracks ();
1412 _editor->commit_reversible_selection_op ();
1416 EditorRoutes::selection_filter (Glib::RefPtr<TreeModel> const &, TreeModel::Path const&, bool /*selected*/)
1418 if (selection_countdown) {
1419 if (--selection_countdown == 0) {
1422 /* no selection yet ... */
1429 struct PresentationInfoRouteSorter
1431 bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
1432 if (a->is_master()) {
1433 /* master before everything else */
1435 } else if (b->is_master()) {
1436 /* everything else before master */
1439 return a->presentation_info().order () < b->presentation_info().order ();
1443 struct PresentationInfoVCASorter
1445 bool operator() (boost::shared_ptr<VCA> a, boost::shared_ptr<VCA> b) {
1446 return a->presentation_info().order () < b->presentation_info().order ();
1451 EditorRoutes::initial_display ()
1453 DisplaySuspender ds;
1462 RouteList r (*_session->get_routes());
1463 for (RouteList::iterator ri = r.begin(); ri != r.end(); ++ri) {
1467 VCAList v (_session->vca_manager().vcas());
1468 for (VCAList::iterator vi = v.begin(); vi != v.end(); ++vi) {
1472 _editor->add_stripables (s);
1476 EditorRoutes::display_drag_data_received (const RefPtr<Gdk::DragContext>& context,
1478 const SelectionData& data,
1479 guint info, guint time)
1481 if (data.get_target() == "GTK_TREE_MODEL_ROW") {
1482 _display.on_drag_data_received (context, x, y, data, info, time);
1486 context->drag_finish (true, false, time);
1489 struct ViewStripable {
1491 boost::shared_ptr<Stripable> stripable;
1494 ViewStripable (TimeAxisView* t, boost::shared_ptr<Stripable> s, uint32_t n)
1495 : tav (t), stripable (s), old_order (n) {}
1499 EditorRoutes::move_selected_tracks (bool up)
1501 if (_editor->selection->tracks.empty()) {
1505 std::list<ViewStripable> view_stripables;
1506 std::vector<int> neworder;
1507 TreeModel::Children rows = _model->children();
1508 TreeModel::Children::iterator ri;
1509 TreeModel::Children::size_type n;
1511 for (n = 0, ri = rows.begin(); ri != rows.end(); ++ri, ++n) {
1512 TimeAxisView* tv = (*ri)[_columns.tv];
1513 boost::shared_ptr<Stripable> stripable = (*ri)[_columns.stripable];
1514 view_stripables.push_back (ViewStripable (tv, stripable, n));
1517 list<ViewStripable>::iterator trailing;
1518 list<ViewStripable>::iterator leading;
1522 trailing = view_stripables.begin();
1523 leading = view_stripables.begin();
1527 while (leading != view_stripables.end()) {
1528 if (_editor->selection->selected (leading->tav)) {
1529 view_stripables.insert (trailing, ViewStripable (*leading));
1530 leading = view_stripables.erase (leading);
1539 /* if we could use reverse_iterator in list::insert, this code
1540 would be a beautiful reflection of the code above. but we can't
1541 and so it looks like a bit of a mess.
1544 trailing = view_stripables.end();
1545 leading = view_stripables.end();
1547 --leading; if (leading == view_stripables.begin()) { return; }
1553 if (_editor->selection->selected (leading->tav)) {
1554 list<ViewStripable>::iterator tmp;
1556 /* need to insert *after* trailing, not *before* it,
1557 which is what insert (iter, val) normally does.
1563 view_stripables.insert (tmp, ViewStripable (*leading));
1565 /* can't use iter = cont.erase (iter); form here, because
1566 we need iter to move backwards.
1574 if (leading == view_stripables.begin()) {
1575 /* the one we've just inserted somewhere else
1576 was the first in the list. erase this copy,
1577 and then break, because we're done.
1582 view_stripables.erase (leading);
1591 if (leading == view_stripables.begin()) {
1600 for (leading = view_stripables.begin(); leading != view_stripables.end(); ++leading) {
1601 neworder.push_back (leading->old_order);
1603 if (leading->old_order != neworder.size() - 1) {
1604 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("move %1 to %2\n", leading->old_order, neworder.size() - 1));
1610 DEBUG_TRACE (DEBUG::OrderKeys, "New order after moving tracks:\n");
1611 for (vector<int>::iterator i = neworder.begin(); i != neworder.end(); ++i) {
1612 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("\t%1\n", *i));
1614 DEBUG_TRACE (DEBUG::OrderKeys, "-------\n");
1618 _model->reorder (neworder);
1622 EditorRoutes::update_input_active_display ()
1624 TreeModel::Children rows = _model->children();
1625 TreeModel::Children::iterator i;
1627 for (i = rows.begin(); i != rows.end(); ++i) {
1628 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1630 if (boost::dynamic_pointer_cast<Track> (stripable)) {
1631 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (stripable);
1634 (*i)[_columns.is_input_active] = mt->input_active();
1641 EditorRoutes::update_rec_display ()
1643 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1644 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1649 EditorRoutes::idle_update_mute_rec_solo_etc()
1651 g_atomic_int_set (const_cast<gint*>(&_queue_tv_update), 0);
1652 TreeModel::Children rows = _model->children();
1653 TreeModel::Children::iterator i;
1655 for (i = rows.begin(); i != rows.end(); ++i) {
1656 boost::shared_ptr<Stripable> stripable = (*i)[_columns.stripable];
1657 boost::shared_ptr<Route> route = boost::dynamic_pointer_cast<Route> (stripable);
1658 (*i)[_columns.mute_state] = RouteUI::mute_active_state (_session, stripable);
1659 (*i)[_columns.solo_state] = RouteUI::solo_active_state (stripable);
1660 (*i)[_columns.solo_isolate_state] = RouteUI::solo_isolate_active_state (stripable) ? 1 : 0;
1661 (*i)[_columns.solo_safe_state] = RouteUI::solo_safe_active_state (stripable) ? 1 : 0;
1663 (*i)[_columns.active] = route->active ();
1665 (*i)[_columns.active] = true;
1668 boost::shared_ptr<Track> trk (boost::dynamic_pointer_cast<Track>(route));
1671 boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
1673 if (trk->rec_enable_control()->get_value()) {
1674 if (_session->record_status() == Session::Recording) {
1675 (*i)[_columns.rec_state] = 1;
1677 (*i)[_columns.rec_state] = 2;
1679 } else if (mt && mt->step_editing()) {
1680 (*i)[_columns.rec_state] = 3;
1682 (*i)[_columns.rec_state] = 0;
1685 (*i)[_columns.rec_safe] = trk->rec_safe_control()->get_value();
1686 (*i)[_columns.name_editable] = !trk->rec_enable_control()->get_value();
1690 return false; // do not call again (until needed)
1695 EditorRoutes::update_mute_display ()
1697 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1698 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1703 EditorRoutes::update_solo_display ()
1705 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1706 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1711 EditorRoutes::update_solo_isolate_display ()
1713 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1714 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1719 EditorRoutes::update_solo_safe_display ()
1721 if (g_atomic_int_compare_and_exchange (const_cast<gint*>(&_queue_tv_update), 0, 1)) {
1722 Glib::signal_idle().connect (sigc::mem_fun (*this, &EditorRoutes::idle_update_mute_rec_solo_etc));
1727 EditorRoutes::views () const
1729 list<TimeAxisView*> v;
1730 for (TreeModel::Children::iterator i = _model->children().begin(); i != _model->children().end(); ++i) {
1731 v.push_back ((*i)[_columns.tv]);
1738 EditorRoutes::clear ()
1740 _display.set_model (Glib::RefPtr<Gtk::TreeStore> (0));
1742 _display.set_model (_model);
1746 EditorRoutes::name_edit_started (CellEditable* ce, const Glib::ustring&)
1750 /* give it a special name */
1752 Gtk::Entry *e = dynamic_cast<Gtk::Entry*> (ce);
1755 e->set_name (X_("RouteNameEditorEntry"));
1760 EditorRoutes::name_edit (std::string const & path, std::string const & new_text)
1764 TreeIter iter = _model->get_iter (path);
1770 boost::shared_ptr<Stripable> stripable = (*iter)[_columns.stripable];
1772 if (stripable && stripable->name() != new_text) {
1773 stripable->set_name (new_text);
1778 EditorRoutes::solo_changed_so_update_mute ()
1780 update_mute_display ();
1784 EditorRoutes::show_tracks_with_regions_at_playhead ()
1786 boost::shared_ptr<RouteList> const r = _session->get_routes_with_regions_at (_session->transport_frame ());
1788 set<TimeAxisView*> show;
1789 for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
1790 TimeAxisView* tav = _editor->axis_view_from_route (*i);
1796 DisplaySuspender ds;
1798 TreeModel::Children rows = _model->children ();
1799 for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
1800 TimeAxisView* tv = (*i)[_columns.tv];
1801 bool to_show = (show.find (tv) != show.end());
1803 tv->set_marked_for_display (to_show);
1804 (*i)[_columns.visible] = to_show;
1807 /* force route order keys catch up with visibility changes
1810 sync_presentation_info_from_treeview ();
1814 EditorRoutes::plugin_setup (boost::shared_ptr<Route> r, boost::shared_ptr<PluginInsert> pi, ARDOUR::Route::PluginSetupOptions flags)
1816 PluginSetupDialog psd (r, pi, flags);