diff options
author | Ben Loftis <ben@glw.com> | 2009-12-08 20:42:52 +0000 |
---|---|---|
committer | Ben Loftis <ben@glw.com> | 2009-12-08 20:42:52 +0000 |
commit | 360b97a763c43c26c6423cf2e3df438927ecb8ae (patch) | |
tree | d643f87b64633b246f54b051adb7da0da3415658 | |
parent | c1a10ef31f5df38a8e2d0501be6dd22c4d3372fc (diff) |
backport feature to show only tracks with regions under the playhead (thanks Carl) and fix Save As function (thanks Paul)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6327 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/editor_route_list.cc | 28 | ||||
-rw-r--r-- | gtk2_ardour/mixer_ui.cc | 27 | ||||
-rw-r--r-- | gtk2_ardour/mixer_ui.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/playlist.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 2 | ||||
-rw-r--r-- | libs/ardour/playlist.cc | 13 | ||||
-rw-r--r-- | libs/ardour/session.cc | 31 |
9 files changed, 104 insertions, 4 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index cef6ed33f8..a0f3e46df2 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -2020,7 +2020,7 @@ ARDOUR_UI::snapshot_session (bool switch_to_it) void ARDOUR_UI::save_state (const string & name, bool switch_to_it) { - (void) save_state_canfail (name); + (void) save_state_canfail (name, switch_to_it); } int diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index e85bf0363f..626fd97870 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1789,6 +1789,7 @@ public: void hide_all_routes (); void show_all_audiotracks (); void hide_all_audiotracks (); + void show_tracks_with_regions_at_playhead (); void show_all_audiobus (); void hide_all_audiobus (); diff --git a/gtk2_ardour/editor_route_list.cc b/gtk2_ardour/editor_route_list.cc index b5e2a29e3b..583b6ec8e7 100644 --- a/gtk2_ardour/editor_route_list.cc +++ b/gtk2_ardour/editor_route_list.cc @@ -422,7 +422,7 @@ Editor::build_route_list_menu () items.push_back (MenuElem (_("Hide All Audio Tracks"), mem_fun(*this, &Editor::hide_all_audiotracks))); items.push_back (MenuElem (_("Show All Audio Busses"), mem_fun(*this, &Editor::show_all_audiobus))); items.push_back (MenuElem (_("Hide All Audio Busses"), mem_fun(*this, &Editor::hide_all_audiobus))); - + items.push_back (MenuElem (_("Show Tracks With Regions Under Playhead"), mem_fun (*this, &Editor::show_tracks_with_regions_at_playhead))); } void @@ -525,6 +525,32 @@ Editor::hide_all_audiotracks () set_all_audio_visibility (1, false); } +void +Editor::show_tracks_with_regions_at_playhead () +{ + boost::shared_ptr<Session::RouteList> const regions = session->get_routes_with_regions_at (session->transport_frame ()); + + //suspend_redisplay (); + + TreeModel::Children rows = route_display_model->children (); + for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) { + boost::shared_ptr<Route> route = (*i)[route_display_columns.route]; + + bool found = false; + for (Session::RouteList::iterator x = (*regions).begin(); x != (*regions).end(); ++x) { + if ((*x) == route) + found = true; + } + + (*i)[route_display_columns.visible] = found; + } + + no_route_list_redisplay = false; + redisplay_route_list (); + + //resume_redisplay (); +} + bool Editor::route_list_display_button_press (GdkEventButton* ev) { diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index e2946f823b..59bba9aea0 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -639,6 +639,7 @@ Mixer_UI::show_all_audiotracks() { set_all_audio_visibility (1, true); } + void Mixer_UI::hide_all_audiotracks () { @@ -646,6 +647,29 @@ Mixer_UI::hide_all_audiotracks () } void +Mixer_UI::show_tracks_with_regions_at_playhead () +{ + boost::shared_ptr<Session::RouteList> const regions = session->get_routes_with_regions_at (session->transport_frame ()); + + TreeModel::Children rows = track_model->children (); + for (TreeModel::Children::iterator i = rows.begin(); i != rows.end(); ++i) { + boost::shared_ptr<Route> route = (*i)[track_columns.route]; + + bool found = false; + for (Session::RouteList::iterator x = (*regions).begin(); x != (*regions).end(); ++x) { + if ((*x) == route) + found = true; + } + + (*i)[track_columns.visible] = found; + } + + strip_redisplay_does_not_sync_order_keys = true; + redisplay_track_list (); + strip_redisplay_does_not_sync_order_keys = false; +} + +void Mixer_UI::track_list_reorder (const TreeModel::Path& path, const TreeModel::iterator& iter, int* new_order) { strip_redisplay_does_not_sync_order_keys = true; @@ -944,7 +968,8 @@ Mixer_UI::build_track_menu () items.push_back (MenuElem (_("Hide All Audio Tracks"), mem_fun(*this, &Mixer_UI::hide_all_audiotracks))); items.push_back (MenuElem (_("Show All Audio Busses"), mem_fun(*this, &Mixer_UI::show_all_audiobus))); items.push_back (MenuElem (_("Hide All Audio Busses"), mem_fun(*this, &Mixer_UI::hide_all_audiobus))); - + items.push_back (MenuElem (_("Hide All Audio Busses"), mem_fun(*this, &Mixer_UI::hide_all_audiobus))); + items.push_back (MenuElem (_("Show Tracks With Regions Under Playhead"), mem_fun (*this, &Mixer_UI::show_tracks_with_regions_at_playhead))); } void diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index 809e7a759c..6cc21aadd3 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -175,6 +175,7 @@ class Mixer_UI : public Gtk::Window void hide_all_audiobus (); void show_all_audiotracks(); void hide_all_audiotracks (); + void show_tracks_with_regions_at_playhead (); Gtk::Menu* mix_group_context_menu; bool in_group_row_change; diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 4848573f1e..54e081a403 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -112,7 +112,8 @@ class Playlist : public PBD::StatefulDestructible, public boost::enable_shared_f 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); template<class T> void foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>, void *), void *arg); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index ad02c1f6f9..1d8ef51453 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -312,6 +312,8 @@ class Session : public PBD::StatefulDestructible return routes.reader (); } + 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 e8f51d361a..20a2aabe43 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -893,6 +893,19 @@ Playlist::partition_internal (nframes_t start, nframes_t end, bool cutting, Regi } } +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()); +} + boost::shared_ptr<Playlist> Playlist::cut_copy (boost::shared_ptr<Playlist> (Playlist::*pmf)(nframes_t, nframes_t,bool), list<AudioRange>& ranges, bool result_is_hidden) { diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 2b235dae28..d511897b3b 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -1001,6 +1001,36 @@ Session::hookup_io () catch_up_on_solo(); } +boost::shared_ptr<Session::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; +} + void Session::playlist_length_changed () { @@ -1673,6 +1703,7 @@ Session::resort_routes () } } + void Session::resort_routes_using (shared_ptr<RouteList> r) { |