2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
|
|
|
|
* Copyright (C) 2006-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm/button.h>
|
2021-07-21 19:18:14 -04:00
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
|
|
|
|
#include "pbd/unwind.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/audioplaylist.h"
|
2020-08-25 17:13:22 -04:00
|
|
|
#include "ardour/midi_playlist.h"
|
2020-09-11 14:10:30 -04:00
|
|
|
#include "ardour/playlist_factory.h"
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/session_playlist.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2021-06-06 10:11:13 -04:00
|
|
|
#include "ardour_ui.h"
|
2021-07-21 19:18:14 -04:00
|
|
|
#include "gui_thread.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "playlist_selector.h"
|
2021-07-21 19:18:14 -04:00
|
|
|
#include "public_editor.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "route_ui.h"
|
2021-06-06 10:06:11 -04:00
|
|
|
#include "utils.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Gtk;
|
2007-03-18 12:45:43 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
PlaylistSelector::PlaylistSelector ()
|
2010-05-02 19:54:25 -04:00
|
|
|
: ArdourDialog (_("Playlists"))
|
2021-07-21 19:18:14 -04:00
|
|
|
, _rui (0)
|
|
|
|
, _mode (plSelect)
|
|
|
|
, _ignore_selection (false)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
set_name ("PlaylistSelectorWindow");
|
2021-07-21 19:18:14 -04:00
|
|
|
set_modal (false);
|
|
|
|
add_events (Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
|
2021-07-16 15:15:23 -04:00
|
|
|
set_size_request (500, 250);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-28 12:22:43 -04:00
|
|
|
model = TreeStore::create (columns);
|
|
|
|
tree.set_model (model);
|
2021-07-16 15:15:23 -04:00
|
|
|
int name_column_n = tree.append_column (_("Name"), columns.text);
|
|
|
|
tree.append_column (_("Group ID"), columns.pgrp);
|
|
|
|
tree.set_headers_visible (true);
|
|
|
|
|
|
|
|
TreeViewColumn* name_column = tree.get_column (name_column_n);
|
2021-07-21 19:18:14 -04:00
|
|
|
name_column->set_sizing (TREE_VIEW_COLUMN_FIXED);
|
|
|
|
name_column->set_expand (true);
|
|
|
|
name_column->set_min_width (250);
|
|
|
|
|
|
|
|
Gtk::ScrolledWindow* scroller = manage (new Gtk::ScrolledWindow);
|
|
|
|
scroller->add (tree);
|
|
|
|
scroller->set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
|
2005-09-28 12:22:43 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
Gtk::Frame* scroller_frame = manage (new Frame ());
|
|
|
|
scroller_frame->add (*scroller);
|
2021-07-16 15:15:23 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
Gtk::Label* scope_label = manage (new Gtk::Label (_("Scope: ")));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2021-06-27 10:49:51 -04:00
|
|
|
Gtk::RadioButtonGroup scope_group;
|
|
|
|
_scope_grp_radio = manage (new RadioButton (scope_group, _("Only this track/group")));
|
2021-07-16 15:15:23 -04:00
|
|
|
_scope_rec_radio = manage (new RadioButton (scope_group, _("Rec-armed tracks")));
|
|
|
|
_scope_all_radio = manage (new RadioButton (scope_group, _("ALL tracks")));
|
2021-06-27 10:49:51 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
_scope_box = manage (new HBox ());
|
|
|
|
_scope_box->set_spacing (4);
|
|
|
|
_scope_box->set_border_width (2);
|
|
|
|
_scope_box->pack_start (*_scope_grp_radio, false, false);
|
|
|
|
_scope_box->pack_start (*_scope_rec_radio, false, false);
|
|
|
|
_scope_box->pack_start (*_scope_all_radio, false, false);
|
|
|
|
Gtk::Frame* scope_frame = manage (new Frame ());
|
|
|
|
scope_frame->add (*_scope_box);
|
2021-07-16 15:15:23 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
_button_box.set_spacing (6);
|
|
|
|
_button_box.pack_start (_btn_new_plist);
|
|
|
|
_button_box.pack_start (_btn_copy_plist);
|
2021-07-20 11:26:30 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
_scope_container.pack_start (*scope_label);
|
|
|
|
_scope_container.pack_start (*scope_frame);
|
2021-07-16 15:15:23 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
Gtk::Table* table = manage (new Gtk::Table ());
|
2021-07-16 15:15:23 -04:00
|
|
|
table->set_border_width (6);
|
2021-07-21 19:18:14 -04:00
|
|
|
table->attach (*scroller_frame, 0, 2, 0, 1, EXPAND | FILL, EXPAND | FILL, 0, 4);
|
|
|
|
table->attach (_scope_container, 0, 2, 1, 2, EXPAND | FILL, SHRINK, 0, 6);
|
|
|
|
table->attach (_button_box, 0, 2, 2, 3, EXPAND | FILL, SHRINK, 0, 0);
|
2021-07-16 15:15:23 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
get_vbox ()->pack_start (*table, true, true);
|
|
|
|
get_vbox ()->show_all ();
|
2020-09-11 14:10:30 -04:00
|
|
|
|
2021-07-16 15:15:23 -04:00
|
|
|
_btn_new_plist.set_name ("generic button");
|
|
|
|
_btn_new_plist.set_text ("New Playlist(s)");
|
|
|
|
_btn_new_plist.signal_clicked.connect (sigc::mem_fun (*this, &PlaylistSelector::new_plist_button_clicked));
|
|
|
|
|
|
|
|
_btn_copy_plist.set_name ("generic button");
|
|
|
|
_btn_copy_plist.set_text ("Copy Playlist(s)");
|
|
|
|
_btn_copy_plist.signal_clicked.connect (sigc::mem_fun (*this, &PlaylistSelector::copy_plist_button_clicked));
|
2021-06-27 10:37:15 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
tree.get_selection ()->signal_changed ().connect (sigc::mem_fun (*this, &PlaylistSelector::selection_changed));
|
2021-06-27 10:37:15 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
_scope_grp_radio->set_active (true);
|
2020-09-10 14:00:56 -04:00
|
|
|
}
|
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
void
|
|
|
|
PlaylistSelector::new_plist_button_clicked ()
|
2021-07-16 15:15:23 -04:00
|
|
|
{
|
2021-07-21 19:18:14 -04:00
|
|
|
if (_scope_all_radio->get_active ()) {
|
|
|
|
PublicEditor::instance ().new_playlists_for_all_tracks (false);
|
|
|
|
} else if (_scope_rec_radio->get_active ()) {
|
|
|
|
PublicEditor::instance ().new_playlists_for_armed_tracks (false);
|
2021-07-16 15:15:23 -04:00
|
|
|
} else {
|
2021-07-21 19:18:14 -04:00
|
|
|
PublicEditor::instance ().new_playlists_for_grouped_tracks (_rui, false);
|
2021-07-16 15:15:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
void
|
|
|
|
PlaylistSelector::copy_plist_button_clicked ()
|
2021-07-16 15:15:23 -04:00
|
|
|
{
|
2021-07-21 19:18:14 -04:00
|
|
|
if (_scope_all_radio->get_active ()) {
|
|
|
|
PublicEditor::instance ().new_playlists_for_all_tracks (true);
|
|
|
|
} else if (_scope_rec_radio->get_active ()) {
|
|
|
|
PublicEditor::instance ().new_playlists_for_armed_tracks (true);
|
2021-07-16 15:15:23 -04:00
|
|
|
} else {
|
2021-07-21 19:18:14 -04:00
|
|
|
PublicEditor::instance ().new_playlists_for_grouped_tracks (_rui, true);
|
2021-07-16 15:15:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
void
|
|
|
|
PlaylistSelector::prepare (RouteUI* ruix, plMode mode)
|
2020-09-10 14:00:56 -04:00
|
|
|
{
|
2020-09-11 14:10:30 -04:00
|
|
|
_mode = mode;
|
2021-07-21 19:18:14 -04:00
|
|
|
|
2021-07-20 11:26:30 -04:00
|
|
|
if (_rui != ruix) {
|
|
|
|
_rui = ruix;
|
2021-07-21 19:18:14 -04:00
|
|
|
_track_connections.drop_connections ();
|
2021-07-20 11:26:30 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Track> this_track = _rui->track ();
|
2021-07-20 11:26:30 -04:00
|
|
|
|
|
|
|
if (this_track) {
|
2021-07-21 19:18:14 -04:00
|
|
|
this_track->PlaylistChanged.connect (
|
|
|
|
_track_connections,
|
|
|
|
invalidator (*this),
|
|
|
|
boost::bind (&PlaylistSelector::redisplay, this),
|
|
|
|
gui_context ());
|
|
|
|
|
|
|
|
this_track->PlaylistAdded.connect (
|
|
|
|
_track_connections,
|
|
|
|
invalidator (*this),
|
|
|
|
boost::bind (&PlaylistSelector::redisplay, this),
|
|
|
|
gui_context ());
|
|
|
|
|
|
|
|
this_track->DropReferences.connect (
|
|
|
|
_track_connections,
|
|
|
|
invalidator (*this),
|
|
|
|
boost::bind (&PlaylistSelector::ok_button_click, this),
|
|
|
|
gui_context ());
|
2021-07-20 11:26:30 -04:00
|
|
|
}
|
2020-09-10 14:00:56 -04:00
|
|
|
}
|
2021-07-21 19:18:14 -04:00
|
|
|
|
|
|
|
redisplay ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
PlaylistSelector::~PlaylistSelector ()
|
|
|
|
{
|
2021-07-21 19:18:14 -04:00
|
|
|
clear_map ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2021-06-07 20:19:09 -04:00
|
|
|
void
|
|
|
|
PlaylistSelector::clear_map ()
|
2006-12-14 09:15:43 -05:00
|
|
|
{
|
2021-07-21 19:18:14 -04:00
|
|
|
for (TrackPlaylistMap::iterator x = _trpl_map.begin (); x != _trpl_map.end (); ++x) {
|
2021-06-07 20:19:09 -04:00
|
|
|
delete x->second;
|
2006-12-14 09:15:43 -05:00
|
|
|
}
|
2021-07-21 19:18:14 -04:00
|
|
|
_trpl_map.clear ();
|
2006-12-14 09:15:43 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2021-07-21 19:18:14 -04:00
|
|
|
PlaylistSelector::redisplay ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2021-07-21 19:18:14 -04:00
|
|
|
if (!_rui) {
|
2020-09-11 14:10:30 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-27 10:49:51 -04:00
|
|
|
if (_mode == plSelect) {
|
2021-07-21 19:18:14 -04:00
|
|
|
_scope_container.show ();
|
|
|
|
_button_box.show ();
|
2021-06-27 10:49:51 -04:00
|
|
|
} else {
|
2021-07-21 19:18:14 -04:00
|
|
|
_scope_container.hide ();
|
|
|
|
_button_box.hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (_mode) {
|
|
|
|
case plSelect:
|
|
|
|
set_title (string_compose (_("Select a Playlist for: %1"), _rui->route ()->name ()));
|
|
|
|
break;
|
|
|
|
case plCopy:
|
|
|
|
set_title (string_compose (_("Copy a Playlist for: %1"), _rui->route ()->name ()));
|
|
|
|
break;
|
|
|
|
case plShare:
|
|
|
|
set_title (string_compose (_("Share a Playlist for: %1"), _rui->route ()->name ()));
|
|
|
|
break;
|
|
|
|
case plSteal:
|
|
|
|
set_title (string_compose (_("Steal a Playlist for: %1"), _rui->route ()->name ()));
|
|
|
|
break;
|
2021-06-27 10:49:51 -04:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
clear_map ();
|
2021-06-07 20:19:09 -04:00
|
|
|
if (model) {
|
|
|
|
model->clear ();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
_playlist_connections.drop_connections ();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
_session->playlists ()->foreach (this, &PlaylistSelector::add_playlist_to_map);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Track> this_track = _rui->track ();
|
2020-09-09 16:08:13 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
TreeModel::Row selected_row;
|
|
|
|
bool have_selected = false;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
for (TrackPlaylistMap::iterator x = _trpl_map.begin (); x != _trpl_map.end (); ++x) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Track> tr = std::dynamic_pointer_cast<Track> (_session->route_by_id (x->first));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
/* add a node for the track */
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-28 12:22:43 -04:00
|
|
|
string nodename;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
if (!tr || tr->name ().empty ()) {
|
2005-09-28 12:22:43 -04:00
|
|
|
nodename = _("unassigned");
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2021-07-21 19:18:14 -04:00
|
|
|
nodename = tr->name ().c_str ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2005-09-28 12:22:43 -04:00
|
|
|
TreeModel::Row row;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
/* make a heading for each other track, if needed */
|
2021-07-20 14:09:41 -04:00
|
|
|
if (_mode != plSelect) {
|
2021-07-21 19:18:14 -04:00
|
|
|
row = *(model->prepend ());
|
2005-09-28 12:22:43 -04:00
|
|
|
row[columns.text] = nodename;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2005-09-28 12:22:43 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* Now insert all the playlists for this diskstream/track in a subtree */
|
2023-02-16 18:33:28 -05:00
|
|
|
vector<std::shared_ptr<Playlist> > pls = *(x->second);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-09-11 14:10:30 -04:00
|
|
|
/* sort the playlists to match the order they appear in the track menu */
|
|
|
|
PlaylistSorterByID cmp;
|
2021-07-21 19:18:14 -04:00
|
|
|
sort (pls.begin (), pls.end (), cmp);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
for (vector<std::shared_ptr<Playlist> >::iterator p = pls.begin (); p != pls.end (); ++p) {
|
2021-07-21 19:18:14 -04:00
|
|
|
(*p)->PropertyChanged.connect (_playlist_connections, invalidator (*this), boost::bind (&PlaylistSelector::pl_property_changed, this, _1), gui_context ());
|
2021-06-07 20:19:09 -04:00
|
|
|
|
2005-09-28 12:22:43 -04:00
|
|
|
TreeModel::Row child_row;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
if (tr == this_track && _mode == plSelect) {
|
|
|
|
child_row = *(model->append ());
|
2021-07-20 17:10:40 -04:00
|
|
|
} else if (_mode != plSelect) {
|
2021-07-21 19:18:14 -04:00
|
|
|
child_row = *(model->append (row.children ()));
|
2020-09-11 14:10:30 -04:00
|
|
|
}
|
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
if (!child_row) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
child_row[columns.text] = (*p)->name ();
|
|
|
|
child_row[columns.pgrp] = (*p)->pgroup_id ();
|
|
|
|
child_row[columns.playlist] = *p;
|
|
|
|
|
|
|
|
if (*p == this_track->playlist ()) {
|
|
|
|
selected_row = child_row;
|
|
|
|
have_selected = true;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-11 14:10:30 -04:00
|
|
|
if (_mode != plSelect) {
|
|
|
|
// Add unassigned (imported) playlists to the list
|
2023-02-16 18:33:28 -05:00
|
|
|
list<std::shared_ptr<Playlist> > unassigned;
|
2021-07-21 19:18:14 -04:00
|
|
|
_session->playlists ()->unassigned (unassigned);
|
2020-09-11 14:10:30 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
if (unassigned.begin () != unassigned.end ()) {
|
|
|
|
TreeModel::Row row = *(model->append ());
|
|
|
|
row[columns.text] = _("Imported");
|
2020-09-11 14:10:30 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
for (list<std::shared_ptr<Playlist> >::iterator p = unassigned.begin (); p != unassigned.end (); ++p) {
|
2020-09-11 14:10:30 -04:00
|
|
|
TreeModel::Row child_row;
|
2008-09-26 04:29:30 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
child_row = *(model->append (row.children ()));
|
|
|
|
|
|
|
|
child_row[columns.text] = (*p)->name ();
|
|
|
|
child_row[columns.pgrp] = (*p)->pgroup_id ();
|
2020-09-11 14:10:30 -04:00
|
|
|
child_row[columns.playlist] = *p;
|
2008-09-26 04:29:30 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
if (*p == this_track->playlist ()) {
|
|
|
|
selected_row = child_row;
|
2020-09-11 14:10:30 -04:00
|
|
|
have_selected = true;
|
|
|
|
}
|
|
|
|
}
|
2008-09-26 04:29:30 -04:00
|
|
|
}
|
2021-07-21 19:18:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (have_selected) {
|
|
|
|
PBD::Unwinder<bool> uw (_ignore_selection, true);
|
|
|
|
|
|
|
|
TreeIter parent = selected_row.parent ();
|
|
|
|
while (parent) {
|
|
|
|
tree.expand_row (TreePath (parent), false);
|
|
|
|
parent = parent->parent ();
|
|
|
|
}
|
|
|
|
tree.get_selection ()->select (selected_row);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2021-06-07 20:19:09 -04:00
|
|
|
void
|
2021-07-21 19:18:14 -04:00
|
|
|
PlaylistSelector::pl_property_changed (PBD::PropertyChange const& what_changed)
|
2021-06-07 20:19:09 -04:00
|
|
|
{
|
2021-07-21 19:18:14 -04:00
|
|
|
redisplay ();
|
2021-06-07 20:19:09 -04:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
PlaylistSelector::add_playlist_to_map (std::shared_ptr<Playlist> pl)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2021-07-21 19:18:14 -04:00
|
|
|
if (pl->frozen ()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2021-06-07 20:19:09 -04:00
|
|
|
if (!_rui) {
|
2020-09-10 14:00:56 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-07 20:19:09 -04:00
|
|
|
if (_rui->is_midi_track ()) {
|
2023-02-16 18:33:28 -05:00
|
|
|
if (std::dynamic_pointer_cast<MidiPlaylist> (pl) == 0) {
|
2020-08-25 17:13:22 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2021-06-07 20:19:09 -04:00
|
|
|
assert (_rui->is_audio_track ());
|
2023-02-16 18:33:28 -05:00
|
|
|
if (std::dynamic_pointer_cast<AudioPlaylist> (pl) == 0) {
|
2020-08-25 17:13:22 -04:00
|
|
|
return;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2010-04-21 16:42:22 -04:00
|
|
|
TrackPlaylistMap::iterator x;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
if ((x = _trpl_map.find (pl->get_orig_track_id ())) == _trpl_map.end ()) {
|
2023-02-16 18:33:28 -05:00
|
|
|
x = _trpl_map.insert (_trpl_map.end (), make_pair (pl->get_orig_track_id (), new vector<std::shared_ptr<Playlist> >));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
x->second->push_back (pl);
|
|
|
|
}
|
|
|
|
|
2020-09-09 16:08:13 -04:00
|
|
|
void
|
2021-07-21 19:18:14 -04:00
|
|
|
PlaylistSelector::ok_button_click ()
|
2020-09-09 16:08:13 -04:00
|
|
|
{
|
2021-07-21 19:18:14 -04:00
|
|
|
hide ();
|
2020-09-09 16:08:13 -04:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2005-09-28 12:22:43 -04:00
|
|
|
PlaylistSelector::selection_changed ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2021-06-27 10:37:15 -04:00
|
|
|
if (_ignore_selection) {
|
|
|
|
/* selection came from libardour, not the user's action */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-21 19:18:14 -04:00
|
|
|
TreeModel::iterator iter = tree.get_selection ()->get_selected ();
|
2005-09-28 12:22:43 -04:00
|
|
|
|
2021-06-07 20:19:09 -04:00
|
|
|
if (!iter || _rui == 0) {
|
2005-09-28 12:22:43 -04:00
|
|
|
/* nothing selected */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Playlist> pl;
|
2020-08-25 17:13:22 -04:00
|
|
|
if ((pl = ((*iter)[columns.playlist])) != 0) {
|
2023-02-16 18:33:28 -05:00
|
|
|
if (_rui->is_audio_track () && std::dynamic_pointer_cast<AudioPlaylist> (pl) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
2023-02-16 18:33:28 -05:00
|
|
|
if (_rui->is_midi_track () && std::dynamic_pointer_cast<MidiPlaylist> (pl) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2023-06-09 11:22:55 -04:00
|
|
|
XMLNode* before = &_rui->track ()->playlist_state ();
|
2020-09-11 14:10:30 -04:00
|
|
|
switch (_mode) {
|
2021-07-21 19:18:14 -04:00
|
|
|
/* @Robin: I dont see a way to undo these playlist actions
|
|
|
|
* @Ben: me neither :)
|
2023-06-09 11:22:55 -04:00
|
|
|
* @Robin: Now I do.
|
2021-07-21 19:18:14 -04:00
|
|
|
*/
|
|
|
|
case plCopy:
|
|
|
|
{
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Playlist> playlist = PlaylistFactory::create (pl, string_compose ("%1.1", pl->name ()));
|
2020-09-11 14:10:30 -04:00
|
|
|
/* playlist->reset_shares (); @Robin is this needed? */
|
2021-06-07 20:19:09 -04:00
|
|
|
_rui->track ()->use_playlist (_rui->is_audio_track () ? DataType::AUDIO : DataType::MIDI, playlist);
|
2021-07-21 19:18:14 -04:00
|
|
|
}
|
|
|
|
break;
|
2020-09-11 14:10:30 -04:00
|
|
|
case plShare:
|
2021-07-21 19:18:14 -04:00
|
|
|
/* share pl but do NOT set me as the owner */
|
|
|
|
_rui->track ()->use_playlist (_rui->is_audio_track () ? DataType::AUDIO : DataType::MIDI, pl, false);
|
2020-09-11 14:10:30 -04:00
|
|
|
break;
|
|
|
|
case plSteal:
|
2021-07-21 19:18:14 -04:00
|
|
|
/* share the playlist and set ME as the owner */
|
|
|
|
_rui->track ()->use_playlist (_rui->is_audio_track () ? DataType::AUDIO : DataType::MIDI, pl);
|
2020-09-11 14:10:30 -04:00
|
|
|
break;
|
|
|
|
case plSelect:
|
2021-07-21 19:18:14 -04:00
|
|
|
if (_scope_all_radio->get_active ()) {
|
|
|
|
PublicEditor::instance ().mapover_all_routes (sigc::bind (sigc::mem_fun (PublicEditor::instance (), &PublicEditor::mapped_select_playlist_matching), pl));
|
|
|
|
} else if (_scope_rec_radio->get_active ()) {
|
|
|
|
PublicEditor::instance ().mapover_armed_routes (sigc::bind (sigc::mem_fun (PublicEditor::instance (), &PublicEditor::mapped_select_playlist_matching), pl));
|
2021-06-27 10:49:51 -04:00
|
|
|
} else {
|
2021-07-21 19:18:14 -04:00
|
|
|
PublicEditor::instance ().mapover_grouped_routes (sigc::bind (sigc::mem_fun (PublicEditor::instance (), &PublicEditor::mapped_select_playlist_matching), pl), _rui, ARDOUR::Properties::group_select.property_id);
|
2021-06-27 10:49:51 -04:00
|
|
|
}
|
2020-09-11 14:10:30 -04:00
|
|
|
break;
|
|
|
|
}
|
2023-06-09 11:22:55 -04:00
|
|
|
|
|
|
|
XMLNode* after = &_rui->track ()->playlist_state ();
|
|
|
|
if (*before != *after) {
|
|
|
|
_session->begin_reversible_command (string_compose (_("Switch Playlist for track %1"), _rui->track ()->name ()));
|
|
|
|
_session->commit_reversible_command (new MementoCommand<Track>(*_rui->track (), before, after));
|
|
|
|
} else {
|
|
|
|
delete before;
|
|
|
|
delete after;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2021-06-06 10:06:11 -04:00
|
|
|
|
|
|
|
bool
|
|
|
|
PlaylistSelector::on_key_press_event (GdkEventKey* ev)
|
|
|
|
{
|
|
|
|
switch (ev->keyval) {
|
2021-07-21 19:18:14 -04:00
|
|
|
case GDK_Up:
|
|
|
|
case GDK_Down:
|
|
|
|
/* Allow these keys to have their in-dialog effect */
|
|
|
|
return ArdourDialog::on_key_press_event (ev);
|
|
|
|
default:
|
|
|
|
break;
|
2021-06-06 10:06:11 -04:00
|
|
|
}
|
|
|
|
|
Fix typos in gtk2_ardour/ directory
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sur,te,trough,ue`
2022-01-26 12:35:38 -05:00
|
|
|
/* Don't just forward the key press ... make it act as if it occurred in
|
2021-07-21 19:18:14 -04:00
|
|
|
* whatever the main window currently is.
|
|
|
|
*/
|
|
|
|
Gtk::Window& main_window (ARDOUR_UI::instance ()->main_window ());
|
2021-06-06 10:11:13 -04:00
|
|
|
return ARDOUR_UI_UTILS::relay_key_press (ev, &main_window);
|
2021-06-06 10:06:11 -04:00
|
|
|
}
|