Changes to PlaylistSelector

Users should be able to see the playlist they're about to switch to
while the dialog is up. Additionally, if the user cancels, the change
should be nullified and the original playlist used.
This commit is contained in:
Nikolaus Gullotta 2020-09-09 15:08:13 -05:00
parent bdebac8bec
commit 8e22c4811e
No known key found for this signature in database
GPG key ID: C1580877951565A3
2 changed files with 29 additions and 5 deletions

View file

@ -26,7 +26,6 @@
#include "ardour/audioplaylist.h"
#include "ardour/midi_playlist.h"
#include "ardour/playlist.h"
#include "ardour/session_playlist.h"
#include <gtkmm2ext/gtk_ui.h>
@ -65,8 +64,10 @@ PlaylistSelector::PlaylistSelector ()
get_vbox()->pack_start (scroller);
Button* b = add_button (_("Close"), RESPONSE_CANCEL);
b->signal_clicked().connect (sigc::mem_fun(*this, &PlaylistSelector::close_button_click));
Button* close_btn = add_button (_("Close"), RESPONSE_CANCEL);
Button* ok_btn = add_button (_("OK"), RESPONSE_OK);
close_btn->signal_clicked().connect (sigc::mem_fun(*this, &PlaylistSelector::close_button_click));
ok_btn->signal_clicked().connect (sigc::mem_fun(*this, &PlaylistSelector::ok_button_click));
}
@ -119,6 +120,10 @@ PlaylistSelector::show_for (RouteUI* ruix)
boost::shared_ptr<Playlist> proxy = others[columns.playlist];
proxy.reset ();
if (this_track->playlist()) {
current_playlist = this_track->playlist();
}
for (TrackPlaylistMap::iterator x = trpl_map.begin(); x != trpl_map.end(); ++x) {
boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (_session->route_by_id (x->first));
@ -238,10 +243,26 @@ PlaylistSelector::add_playlist_to_map (boost::shared_ptr<Playlist> pl)
void
PlaylistSelector::close_button_click ()
{
if (rui && current_playlist) {
rui->track ()->use_playlist (rui->is_audio_track () ? DataType::AUDIO : DataType::MIDI, current_playlist);
}
rui = 0;
hide ();
}
void
PlaylistSelector::ok_button_click()
{
rui = 0;
hide();
}
bool PlaylistSelector::on_delete_event (GdkEventAny*)
{
close_button_click();
return false;
}
void
PlaylistSelector::selection_changed ()
{
@ -264,7 +285,5 @@ PlaylistSelector::selection_changed ()
}
rui->track ()->use_playlist (rui->is_audio_track () ? DataType::AUDIO : DataType::MIDI, pl);
hide ();
}
}

View file

@ -30,6 +30,7 @@
#include <gtkmm/treestore.h>
#include "ardour_dialog.h"
#include "ardour/playlist.h"
#include "ardour/session_handle.h"
namespace ARDOUR {
@ -63,7 +64,9 @@ private:
void add_playlist_to_map (boost::shared_ptr<ARDOUR::Playlist>);
void clear_map ();
void close_button_click ();
void ok_button_click ();
void selection_changed ();
bool on_delete_event (GdkEventAny*);
struct ModelColumns : public Gtk::TreeModel::ColumnRecord
{
@ -78,6 +81,8 @@ private:
ModelColumns columns;
Glib::RefPtr<Gtk::TreeStore> model;
Gtk::TreeView tree;
boost::shared_ptr<ARDOUR::Playlist> current_playlist;
};
#endif // __ardour_playlist_selector_h__