Playlist UI tweaks: rationalize playlist functions in Editor::
* new global playlist functions for {all | rec-armed | selected} tracks. * new API passes (bool copy) arg instead of separate functions for copy_X. * consistently use mapover_X functions to consolidate code * update Lua bindings to match
This commit is contained in:
parent
cf999ecaa9
commit
a8395718bc
|
@ -4353,20 +4353,21 @@ Editor::restore_editing_space ()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make new playlists for a given track and also any others that belong
|
||||
* to the same active route group with the `select' property.
|
||||
* @param v Track.
|
||||
*/
|
||||
|
||||
void
|
||||
Editor::new_playlists (RouteUI* rui)
|
||||
bool
|
||||
Editor::stamp_new_playlist (string &name, string &pgroup)
|
||||
{
|
||||
time_t now;
|
||||
time (&now);
|
||||
Glib::DateTime tm (Glib::DateTime::create_now_local (now));
|
||||
string gid (tm.format ("%F %H.%M.%S"));
|
||||
string name(gid);
|
||||
pgroup = gid;
|
||||
|
||||
if (name.length()==0) {
|
||||
name = _("Take.1");
|
||||
if (_session->playlists()->by_name (name)) {
|
||||
name = Playlist::bump_name (name, *_session);
|
||||
}
|
||||
}
|
||||
|
||||
Prompter prompter (true);
|
||||
prompter.set_title (_("New Playlist"));
|
||||
|
@ -4378,7 +4379,7 @@ Editor::new_playlists (RouteUI* rui)
|
|||
|
||||
while (true) {
|
||||
if (prompter.run () != Gtk::RESPONSE_ACCEPT) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
prompter.get_result (name);
|
||||
if (name.length()) {
|
||||
|
@ -4391,56 +4392,7 @@ Editor::new_playlists (RouteUI* rui)
|
|||
}
|
||||
}
|
||||
|
||||
/* begin_reversible_command (_("new playlists")); */ /* ToDo: this does not work */
|
||||
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
|
||||
_session->playlists()->get (playlists);
|
||||
mapover_routes (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_new_playlist), name, gid, playlists), rui, ARDOUR::Properties::group_select.property_id);
|
||||
/* commit_reversible_command (); */
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a copy of the current playlist for a given track and also any others that belong
|
||||
* to the same active route group with the `select' property.
|
||||
* @param v Track.
|
||||
*/
|
||||
|
||||
void
|
||||
Editor::copy_playlists (RouteUI* rui)
|
||||
{
|
||||
time_t now;
|
||||
time (&now);
|
||||
Glib::DateTime tm (Glib::DateTime::create_now_local (now));
|
||||
string gid (tm.format ("%F %H.%M.%S"));
|
||||
string name(gid);
|
||||
|
||||
Prompter prompter (true);
|
||||
prompter.set_title (_("New Playlist"));
|
||||
prompter.set_prompt (_("Name for new playlist:"));
|
||||
prompter.set_initial_text (name);
|
||||
prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
|
||||
prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
|
||||
prompter.show_all ();
|
||||
|
||||
while (true) {
|
||||
if (prompter.run () != Gtk::RESPONSE_ACCEPT) {
|
||||
return;
|
||||
}
|
||||
prompter.get_result (name);
|
||||
if (name.length()) {
|
||||
if (_session->playlists()->by_name (name)) {
|
||||
prompter.set_prompt (_("That name is already in use. Use this instead?"));
|
||||
prompter.set_initial_text (Playlist::bump_name (name, *_session));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* begin_reversible_command (_("copy playlists")); */ /* ToDo: this does not work */
|
||||
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
|
||||
_session->playlists()->get (playlists);
|
||||
mapover_routes (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_copy_playlist), name, gid, playlists), rui, ARDOUR::Properties::group_select.property_id);
|
||||
/* commit_reversible_command (); */
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Clear the current playlist for a given track and also any others that belong
|
||||
|
@ -4449,33 +4401,71 @@ Editor::copy_playlists (RouteUI* rui)
|
|||
*/
|
||||
|
||||
void
|
||||
Editor::clear_playlists (RouteUI* rui)
|
||||
Editor::clear_grouped_playlists (RouteUI* rui)
|
||||
{
|
||||
begin_reversible_command (_("clear playlists"));
|
||||
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
|
||||
_session->playlists()->get (playlists);
|
||||
mapover_routes (sigc::mem_fun (*this, &Editor::mapped_clear_playlist), rui, ARDOUR::Properties::group_select.property_id);
|
||||
mapover_grouped_routes (sigc::mem_fun (*this, &Editor::mapped_clear_playlist), rui, ARDOUR::Properties::group_select.property_id);
|
||||
commit_reversible_command ();
|
||||
}
|
||||
|
||||
void
|
||||
Editor::mapped_use_new_playlist (RouteUI& rui, uint32_t sz, std::string name, string gid, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
|
||||
Editor::mapped_use_new_playlist (RouteUI& rui, std::string name, string gid, bool copy, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
|
||||
{
|
||||
rui.use_new_playlist (name, gid, playlists, false);
|
||||
rui.use_new_playlist (name, gid, playlists, copy);
|
||||
}
|
||||
|
||||
void
|
||||
Editor::mapped_use_copy_playlist (RouteUI& rui, uint32_t sz, std::string name, string gid, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
|
||||
{
|
||||
rui.use_new_playlist (name, gid, playlists, true);
|
||||
}
|
||||
|
||||
void
|
||||
Editor::mapped_clear_playlist (RouteUI& rui, uint32_t /*sz*/)
|
||||
Editor::mapped_clear_playlist (RouteUI& rui)
|
||||
{
|
||||
rui.clear_playlist ();
|
||||
}
|
||||
|
||||
void
|
||||
Editor::new_playlists_for_all_tracks (bool copy)
|
||||
{
|
||||
string name, gid;
|
||||
stamp_new_playlist(name,gid);
|
||||
|
||||
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
|
||||
_session->playlists()->get (playlists);
|
||||
mapover_all_routes (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_new_playlist), name, gid, copy, playlists));
|
||||
}
|
||||
|
||||
void
|
||||
Editor::new_playlists_for_grouped_tracks (RouteUI* rui, bool copy)
|
||||
{
|
||||
string name, gid;
|
||||
stamp_new_playlist(name,gid);
|
||||
|
||||
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
|
||||
_session->playlists()->get (playlists);
|
||||
mapover_grouped_routes (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_new_playlist), name, gid, copy, playlists), rui, ARDOUR::Properties::group_select.property_id);
|
||||
}
|
||||
|
||||
void
|
||||
Editor::new_playlists_for_selected_tracks (bool copy)
|
||||
{
|
||||
string name, gid;
|
||||
stamp_new_playlist(name,gid);
|
||||
|
||||
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
|
||||
_session->playlists()->get (playlists);
|
||||
mapover_selected_routes (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_new_playlist), name, gid, copy, playlists));
|
||||
}
|
||||
|
||||
void
|
||||
Editor::new_playlists_for_armed_tracks (bool copy)
|
||||
{
|
||||
string name, gid;
|
||||
stamp_new_playlist(name,gid);
|
||||
|
||||
vector<boost::shared_ptr<ARDOUR::Playlist> > playlists;
|
||||
_session->playlists()->get (playlists);
|
||||
mapover_armed_routes (sigc::bind (sigc::mem_fun (*this, &Editor::mapped_use_new_playlist), name, gid, copy, playlists));
|
||||
}
|
||||
|
||||
double
|
||||
Editor::get_y_origin () const
|
||||
{
|
||||
|
|
|
@ -334,9 +334,7 @@ public:
|
|||
PlaylistSelector& playlist_selector() const;
|
||||
void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>);
|
||||
|
||||
void new_playlists (RouteUI* v);
|
||||
void copy_playlists (RouteUI* v);
|
||||
void clear_playlists (RouteUI* v);
|
||||
void clear_grouped_playlists (RouteUI* v);
|
||||
|
||||
void get_onscreen_tracks (TrackViewList&);
|
||||
|
||||
|
@ -779,14 +777,21 @@ private:
|
|||
RegionView* regionview_from_region (boost::shared_ptr<ARDOUR::Region>) const;
|
||||
RouteTimeAxisView* rtav_from_route (boost::shared_ptr<ARDOUR::Route>) const;
|
||||
|
||||
|
||||
void mapover_tracks_with_unique_playlists (sigc::slot<void,RouteTimeAxisView&,uint32_t> sl, TimeAxisView*, PBD::PropertyID) const;
|
||||
void mapped_get_equivalent_regions (RouteTimeAxisView&, uint32_t, RegionView*, std::vector<RegionView*>*) const;
|
||||
|
||||
void mapover_routes (sigc::slot<void, RouteUI&, uint32_t> sl, RouteUI*, PBD::PropertyID) const;
|
||||
void mapped_use_new_playlist (RouteUI&, uint32_t, std::string name, std::string gid, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
|
||||
void mapped_use_copy_playlist (RouteUI&, uint32_t, std::string name, std::string gid, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
|
||||
void mapped_clear_playlist (RouteUI&, uint32_t);
|
||||
void mapover_grouped_routes (sigc::slot<void, RouteUI&> sl, RouteUI*, PBD::PropertyID) const;
|
||||
void mapover_armed_routes (sigc::slot<void, RouteUI&> sl) const;
|
||||
void mapover_selected_routes (sigc::slot<void, RouteUI&> sl) const;
|
||||
void mapover_all_routes (sigc::slot<void, RouteUI&> sl) const;
|
||||
|
||||
void mapped_use_new_playlist (RouteUI&, std::string name, std::string gid, bool copy, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
|
||||
void mapped_clear_playlist (RouteUI&);
|
||||
|
||||
void new_playlists_for_all_tracks(bool copy);
|
||||
void new_playlists_for_grouped_tracks(RouteUI* v, bool copy);
|
||||
void new_playlists_for_selected_tracks(bool copy);
|
||||
void new_playlists_for_armed_tracks(bool copy);
|
||||
|
||||
void button_selection (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_type);
|
||||
bool button_release_can_deselect;
|
||||
|
@ -1691,6 +1696,10 @@ private:
|
|||
|
||||
void initialize_canvas ();
|
||||
|
||||
/* playlist internal ops */
|
||||
|
||||
bool stamp_new_playlist (std::string &name, std::string &pgroup);
|
||||
|
||||
/* display control */
|
||||
|
||||
/// true if the editor should follow the playhead, otherwise false
|
||||
|
|
|
@ -406,10 +406,9 @@ Editor::get_onscreen_tracks (TrackViewList& tvl)
|
|||
*/
|
||||
|
||||
void
|
||||
Editor::mapover_routes (sigc::slot<void, RouteUI&, uint32_t> sl, RouteUI* basis, PBD::PropertyID prop) const
|
||||
Editor::mapover_grouped_routes (sigc::slot<void, RouteUI&> sl, RouteUI* basis, PBD::PropertyID prop) const
|
||||
{
|
||||
set<RouteUI*> routes;
|
||||
routes.insert (basis);
|
||||
|
||||
RouteGroup* group = basis->route()->route_group();
|
||||
|
||||
|
@ -427,10 +426,55 @@ Editor::mapover_routes (sigc::slot<void, RouteUI&, uint32_t> sl, RouteUI* basis,
|
|||
}
|
||||
|
||||
/* call the slots */
|
||||
uint32_t const sz = routes.size ();
|
||||
|
||||
for (set<RouteUI*>::iterator i = routes.begin(); i != routes.end(); ++i) {
|
||||
sl (**i, sz);
|
||||
sl (**i);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::mapover_armed_routes (sigc::slot<void, RouteUI&> sl) const
|
||||
{
|
||||
set<RouteUI*> routes;
|
||||
for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
||||
RouteUI* v = dynamic_cast<RouteUI*> (*i);
|
||||
if (v && v->route()->is_track()) {
|
||||
if ( v->track()->rec_enable_control()->get_value()) {
|
||||
routes.insert (v);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (set<RouteUI*>::iterator i = routes.begin(); i != routes.end(); ++i) {
|
||||
sl (**i);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::mapover_selected_routes (sigc::slot<void, RouteUI&> sl) const
|
||||
{
|
||||
set<RouteUI*> routes;
|
||||
for (TrackSelection::iterator i = selection->tracks.begin(); i != selection->tracks.end(); ++i) {
|
||||
RouteTimeAxisView* r = dynamic_cast<RouteTimeAxisView*> (*i);
|
||||
if (r) {
|
||||
routes.insert (r);
|
||||
}
|
||||
}
|
||||
for (set<RouteUI*>::iterator i = routes.begin(); i != routes.end(); ++i) {
|
||||
sl (**i);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::mapover_all_routes (sigc::slot<void, RouteUI&> sl) const
|
||||
{
|
||||
set<RouteUI*> routes;
|
||||
for (TrackViewList::const_iterator i = track_views.begin(); i != track_views.end(); ++i) {
|
||||
RouteTimeAxisView* r = dynamic_cast<RouteTimeAxisView*> (*i);
|
||||
if (r) {
|
||||
routes.insert (r);
|
||||
}
|
||||
}
|
||||
for (set<RouteUI*>::iterator i = routes.begin(); i != routes.end(); ++i) {
|
||||
sl (**i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -942,9 +942,12 @@ LuaInstance::register_classes (lua_State* L)
|
|||
.addFunction ("reset_zoom", &PublicEditor::reset_zoom)
|
||||
|
||||
.addFunction ("clear_playlist", &PublicEditor::clear_playlist)
|
||||
.addFunction ("new_playlists", &PublicEditor::new_playlists)
|
||||
.addFunction ("copy_playlists", &PublicEditor::copy_playlists)
|
||||
.addFunction ("clear_playlists", &PublicEditor::clear_playlists)
|
||||
.addFunction ("clear_grouped_playlists", &PublicEditor::clear_grouped_playlists)
|
||||
|
||||
.addFunction ("new_playlists_for_grouped_tracks", &PublicEditor::new_playlists_for_grouped_tracks)
|
||||
.addFunction ("new_playlists_for_all_tracks", &PublicEditor::new_playlists_for_all_tracks)
|
||||
.addFunction ("new_playlists_for_armed_tracks", &PublicEditor::new_playlists_for_armed_tracks)
|
||||
.addFunction ("new_playlists_for_selected_tracks", &PublicEditor::new_playlists_for_selected_tracks)
|
||||
|
||||
.addFunction ("select_all_visible_lanes", &PublicEditor::select_all_visible_lanes)
|
||||
.addFunction ("select_all_tracks", &PublicEditor::select_all_tracks)
|
||||
|
|
|
@ -290,9 +290,13 @@ public:
|
|||
virtual void reset_zoom (samplecnt_t) = 0;
|
||||
virtual PlaylistSelector& playlist_selector() const = 0;
|
||||
virtual void clear_playlist (boost::shared_ptr<ARDOUR::Playlist>) = 0;
|
||||
virtual void new_playlists (RouteUI*) = 0;
|
||||
virtual void copy_playlists (RouteUI*) = 0;
|
||||
virtual void clear_playlists (RouteUI*) = 0;
|
||||
virtual void clear_grouped_playlists (RouteUI*) = 0;
|
||||
|
||||
virtual void new_playlists_for_all_tracks(bool copy) = 0;
|
||||
virtual void new_playlists_for_grouped_tracks(RouteUI* rui, bool copy) = 0;
|
||||
virtual void new_playlists_for_selected_tracks(bool copy) = 0;
|
||||
virtual void new_playlists_for_armed_tracks(bool copy) = 0;
|
||||
|
||||
virtual void select_all_visible_lanes () = 0;
|
||||
virtual void select_all_tracks () = 0;
|
||||
virtual void deselect_all () = 0;
|
||||
|
|
|
@ -2522,18 +2522,18 @@ RouteUI::build_playlist_menu ()
|
|||
playlist_items.push_back (SeparatorElem());
|
||||
|
||||
if (!route_group() || !route_group()->is_active() || !route_group()->enabled_property (ARDOUR::Properties::group_select.property_id)) {
|
||||
playlist_items.push_back (MenuElem (_("New Playlist..."), sigc::bind(sigc::mem_fun(editor, &PublicEditor::new_playlists), this)));
|
||||
playlist_items.push_back (MenuElem (_("Copy Playlist..."), sigc::bind(sigc::mem_fun(editor, &PublicEditor::copy_playlists), this)));
|
||||
playlist_items.push_back (MenuElem (_("New Playlist..."), sigc::bind(sigc::mem_fun(editor, &PublicEditor::new_playlists_for_grouped_tracks), this, false)));
|
||||
playlist_items.push_back (MenuElem (_("Copy Playlist..."), sigc::bind(sigc::mem_fun(editor, &PublicEditor::new_playlists_for_grouped_tracks), this, true)));
|
||||
} else {
|
||||
playlist_items.push_back (MenuElem (_("New Playlist (for group)"), sigc::bind(sigc::mem_fun(editor, &PublicEditor::new_playlists), this)));
|
||||
playlist_items.push_back (MenuElem (_("Copy Playlist (for group)"), sigc::bind(sigc::mem_fun(editor, &PublicEditor::copy_playlists), this)));
|
||||
playlist_items.push_back (MenuElem (_("New Playlist (for group)"), sigc::bind(sigc::mem_fun(editor, &PublicEditor::new_playlists_for_grouped_tracks), this, false)));
|
||||
playlist_items.push_back (MenuElem (_("Copy Playlist (for group)"), sigc::bind(sigc::mem_fun(editor, &PublicEditor::new_playlists_for_grouped_tracks), this, true)));
|
||||
}
|
||||
|
||||
playlist_items.push_back (SeparatorElem());
|
||||
if (!route_group() || !route_group()->is_active() || !route_group()->enabled_property (ARDOUR::Properties::group_select.property_id)) {
|
||||
playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(editor, &PublicEditor::clear_playlists), this)));
|
||||
playlist_items.push_back (MenuElem (_("Clear Current"), sigc::bind(sigc::mem_fun(editor, &PublicEditor::clear_grouped_playlists), this)));
|
||||
} else {
|
||||
playlist_items.push_back (MenuElem (_("Clear Current (for group)"), sigc::bind(sigc::mem_fun(editor, &PublicEditor::clear_playlists), this)));
|
||||
playlist_items.push_back (MenuElem (_("Clear Current (for group)"), sigc::bind(sigc::mem_fun(editor, &PublicEditor::clear_grouped_playlists), this)));
|
||||
}
|
||||
playlist_items.push_back (SeparatorElem());
|
||||
|
||||
|
|
Loading…
Reference in New Issue