summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-11-29 12:47:59 +0000
committerCarl Hetherington <carl@carlh.net>2009-11-29 12:47:59 +0000
commit515d19c74519599c53d6fc85c1af2647f390d95f (patch)
tree1f1dbbe3beccbe37872bf1ec565bc7aa7c6a240c
parentb88e7fdcca8ef8fa4c22f93c2934b30713ab4716 (diff)
Implement 2532: option to show tracks with regions under the playhead.
git-svn-id: svn://localhost/ardour2/branches/3.0@6207 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/editor_routes.cc28
-rw-r--r--gtk2_ardour/editor_routes.h1
-rw-r--r--libs/ardour/ardour/playlist.h2
-rw-r--r--libs/ardour/ardour/session.h2
-rw-r--r--libs/ardour/playlist.cc14
-rw-r--r--libs/ardour/session.cc32
6 files changed, 78 insertions, 1 deletions
diff --git a/gtk2_ardour/editor_routes.cc b/gtk2_ardour/editor_routes.cc
index 32dfa77f48..929240eca4 100644
--- a/gtk2_ardour/editor_routes.cc
+++ b/gtk2_ardour/editor_routes.cc
@@ -219,7 +219,7 @@ EditorRoutes::build_menu ()
items.push_back (MenuElem (_("Hide All Audio Tracks"), mem_fun (*this, &EditorRoutes::hide_all_audiotracks)));
items.push_back (MenuElem (_("Show All Audio Busses"), mem_fun (*this, &EditorRoutes::show_all_audiobus)));
items.push_back (MenuElem (_("Hide All Audio Busses"), mem_fun (*this, &EditorRoutes::hide_all_audiobus)));
-
+ items.push_back (MenuElem (_("Show Tracks With Regions Under Playhead"), mem_fun (*this, &EditorRoutes::show_tracks_with_regions_at_playhead)));
}
void
@@ -968,3 +968,29 @@ EditorRoutes::solo_changed_so_update_mute ()
update_mute_display (this);
}
+
+void
+EditorRoutes::show_tracks_with_regions_at_playhead ()
+{
+ boost::shared_ptr<RouteList> const r = _session->get_routes_with_regions_at (_session->transport_frame ());
+
+ set<TimeAxisView*> show;
+ for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
+ cout << "show " << (*i)->name() << "\n";
+ TimeAxisView* tav = _editor->axis_view_from_route (i->get ());
+ if (tav) {
+ show.insert (tav);
+ }
+ }
+
+ suspend_redisplay ();
+
+ TreeModel::Children rows = _model->children ();
+ for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) {
+ TimeAxisView* tv = (*i)[_columns.tv];
+ (*i)[_columns.visible] = (show.find (tv) != show.end());
+ }
+
+ resume_redisplay ();
+
+}
diff --git a/gtk2_ardour/editor_routes.h b/gtk2_ardour/editor_routes.h
index 454f850c52..e2e9f0110e 100644
--- a/gtk2_ardour/editor_routes.h
+++ b/gtk2_ardour/editor_routes.h
@@ -75,6 +75,7 @@ private:
void hide_all_audiotracks ();
void show_all_audiobus ();
void hide_all_audiobus ();
+ void show_tracks_with_regions_at_playhead ();
void display_drag_data_received (
Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 693b2de2dd..3ed32f0984 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -120,6 +120,8 @@ class Playlist : public SessionObject,
boost::shared_ptr<Region> find_next_region (nframes_t frame, RegionPoint point, int dir);
nframes64_t find_next_region_boundary (nframes64_t frame, int dir);
bool region_is_shuffle_constrained (boost::shared_ptr<Region>);
+ bool has_region_at (nframes64_t const) const;
+
nframes64_t find_next_transient (nframes64_t position, int dir);
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 48a7ce7a39..bfbbabe877 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -322,6 +322,8 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
boost::shared_ptr<RouteList> get_routes_with_internal_returns() const;
+ boost::shared_ptr<RouteList> get_routes_with_regions_at (nframes64_t const) const;
+
uint32_t nroutes() const { return routes.reader()->size(); }
uint32_t ntracks () const;
uint32_t nbusses () const;
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index aa41bf65d1..bcc4c6061d 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -2521,3 +2521,17 @@ Playlist::set_explicit_relayering (bool e)
_explicit_relayering = e;
}
+
+
+bool
+Playlist::has_region_at (nframes64_t const p) const
+{
+ RegionLock (const_cast<Playlist *> (this));
+
+ RegionList::const_iterator i = regions.begin ();
+ while (i != regions.end() && !(*i)->covers (p)) {
+ ++i;
+ }
+
+ return (i != regions.end());
+}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index f7dfd2111d..598d9b01b5 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -4513,3 +4513,35 @@ Session::get_available_sync_options () const
return ret;
}
+
+boost::shared_ptr<RouteList>
+Session::get_routes_with_regions_at (nframes64_t const p) const
+{
+ shared_ptr<RouteList> r = routes.reader ();
+ shared_ptr<RouteList> rl (new RouteList);
+
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
+ if (!tr) {
+ continue;
+ }
+
+ boost::shared_ptr<Diskstream> ds = tr->diskstream ();
+ if (!ds) {
+ continue;
+ }
+
+ boost::shared_ptr<Playlist> pl = ds->playlist ();
+ if (!pl) {
+ continue;
+ }
+
+ if (pl->has_region_at (p)) {
+ rl->push_back (*i);
+ }
+ }
+
+ return rl;
+}
+
+