move logic of track/bus duplication into DuplicateRouteDialog
This commit is contained in:
parent
fb96170178
commit
ef810eacd8
@ -3757,98 +3757,10 @@ ARDOUR_UI::start_duplicate_routes ()
|
|||||||
{
|
{
|
||||||
if (!duplicate_routes_dialog) {
|
if (!duplicate_routes_dialog) {
|
||||||
duplicate_routes_dialog = new DuplicateRouteDialog;
|
duplicate_routes_dialog = new DuplicateRouteDialog;
|
||||||
duplicate_routes_dialog->signal_response().connect (sigc::mem_fun (*this, &ARDOUR_UI::finish_duplicate_routes));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackSelection& tracks (editor->get_selection().tracks);
|
if (duplicate_routes_dialog->restart ()) {
|
||||||
uint32_t ntracks = 0;
|
|
||||||
uint32_t nbusses = 0;
|
|
||||||
|
|
||||||
for (TrackSelection::iterator t = tracks.begin(); t != tracks.end(); ++t) {
|
|
||||||
|
|
||||||
RouteUI* rui = dynamic_cast<RouteUI*> (*t);
|
|
||||||
|
|
||||||
if (!rui) {
|
|
||||||
/* some other type of timeaxis view, not a route */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_ptr<Route> r (rui->route());
|
|
||||||
|
|
||||||
if (boost::dynamic_pointer_cast<Track> (r)) {
|
|
||||||
ntracks++;
|
|
||||||
} else {
|
|
||||||
if (!r->is_master() && !r->is_monitor()) {
|
|
||||||
nbusses++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ntracks == 0 && nbusses == 0) {
|
|
||||||
cerr << "You can't do this\n";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
duplicate_routes_dialog->setup (ntracks, nbusses);
|
|
||||||
duplicate_routes_dialog->present ();
|
duplicate_routes_dialog->present ();
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ARDOUR_UI::finish_duplicate_routes (int response)
|
|
||||||
{
|
|
||||||
if (!duplicate_routes_dialog) {
|
|
||||||
/* how could this happen? */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
duplicate_routes_dialog->hide ();
|
|
||||||
|
|
||||||
if (response != Gtk::RESPONSE_OK) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ARDOUR::PlaylistDisposition playlist_disposition = duplicate_routes_dialog->playlist_disposition ();
|
|
||||||
uint32_t count = duplicate_routes_dialog->count ();
|
|
||||||
|
|
||||||
/* Copy the track selection because it will/may change as we add new ones */
|
|
||||||
TrackSelection tracks (editor->get_selection().tracks);
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
for (TrackSelection::iterator t = tracks.begin(); t != tracks.end(); ++t) {
|
|
||||||
|
|
||||||
RouteUI* rui = dynamic_cast<RouteUI*> (*t);
|
|
||||||
|
|
||||||
if (!rui) {
|
|
||||||
/* some other type of timeaxis view, not a route */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rui->route()->is_master() || rui->route()->is_monitor()) {
|
|
||||||
/* no option to duplicate these */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
XMLNode& state (rui->route()->get_state());
|
|
||||||
RouteList rl = _session->new_route_from_template (count, state, string(), playlist_disposition);
|
|
||||||
|
|
||||||
/* normally the state node would be added to a parent, and
|
|
||||||
* ownership would transfer. Because we don't do that here,
|
|
||||||
* we need to delete the node ourselves.
|
|
||||||
*/
|
|
||||||
|
|
||||||
delete &state;
|
|
||||||
|
|
||||||
if (rl.empty()) {
|
|
||||||
err++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
MessageDialog msg (_("1 or more tracks/busses could not be duplicated"),
|
|
||||||
true, MESSAGE_ERROR, BUTTONS_OK, true);
|
|
||||||
msg.set_position (WIN_POS_MOUSE);
|
|
||||||
msg.run ();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,10 +19,18 @@
|
|||||||
|
|
||||||
#include "gtkmm/stock.h"
|
#include "gtkmm/stock.h"
|
||||||
|
|
||||||
|
#include "ardour/route.h"
|
||||||
|
#include "ardour/session.h"
|
||||||
|
|
||||||
|
#include "editor.h"
|
||||||
#include "duplicate_routes_dialog.h"
|
#include "duplicate_routes_dialog.h"
|
||||||
|
#include "selection.h"
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
using namespace ARDOUR;
|
||||||
|
using namespace Gtk;
|
||||||
|
|
||||||
DuplicateRouteDialog::DuplicateRouteDialog ()
|
DuplicateRouteDialog::DuplicateRouteDialog ()
|
||||||
: ArdourDialog (_("Duplicate Tracks & Busses"), false, false)
|
: ArdourDialog (_("Duplicate Tracks & Busses"), false, false)
|
||||||
, copy_playlists_button (playlist_button_group, _("Copy playlists"))
|
, copy_playlists_button (playlist_button_group, _("Copy playlists"))
|
||||||
@ -43,17 +51,42 @@ DuplicateRouteDialog::DuplicateRouteDialog ()
|
|||||||
|
|
||||||
get_vbox()->show_all ();
|
get_vbox()->show_all ();
|
||||||
|
|
||||||
add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
||||||
add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
|
add_button (Stock::OK, RESPONSE_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
DuplicateRouteDialog::~DuplicateRouteDialog ()
|
int
|
||||||
|
DuplicateRouteDialog::restart ()
|
||||||
{
|
{
|
||||||
}
|
TrackSelection& tracks (PublicEditor::instance().get_selection().tracks);
|
||||||
|
uint32_t ntracks = 0;
|
||||||
|
uint32_t nbusses = 0;
|
||||||
|
|
||||||
|
for (TrackSelection::iterator t = tracks.begin(); t != tracks.end(); ++t) {
|
||||||
|
|
||||||
|
RouteUI* rui = dynamic_cast<RouteUI*> (*t);
|
||||||
|
|
||||||
|
if (!rui) {
|
||||||
|
/* some other type of timeaxis view, not a route */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<Route> r (rui->route());
|
||||||
|
|
||||||
|
if (boost::dynamic_pointer_cast<Track> (r)) {
|
||||||
|
ntracks++;
|
||||||
|
} else {
|
||||||
|
if (!r->is_master() && !r->is_monitor()) {
|
||||||
|
nbusses++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ntracks == 0 && nbusses == 0) {
|
||||||
|
std::cerr << "You can't do this\n";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
|
||||||
DuplicateRouteDialog::setup (uint32_t ntracks, uint32_t nbusses)
|
|
||||||
{
|
|
||||||
/* XXX grrr. Gtk Boxes do not shrink when children are removed,
|
/* XXX grrr. Gtk Boxes do not shrink when children are removed,
|
||||||
which is what we really want to happen here.
|
which is what we really want to happen here.
|
||||||
*/
|
*/
|
||||||
@ -63,6 +96,8 @@ DuplicateRouteDialog::setup (uint32_t ntracks, uint32_t nbusses)
|
|||||||
} else {
|
} else {
|
||||||
get_vbox()->pack_end (playlist_button_box, false, false);
|
get_vbox()->pack_end (playlist_button_box, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
@ -82,3 +117,57 @@ DuplicateRouteDialog::playlist_disposition() const
|
|||||||
|
|
||||||
return ARDOUR::SharePlaylist;
|
return ARDOUR::SharePlaylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DuplicateRouteDialog::on_response (int response)
|
||||||
|
{
|
||||||
|
hide ();
|
||||||
|
|
||||||
|
if (response != RESPONSE_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ARDOUR::PlaylistDisposition playlist_action = playlist_disposition ();
|
||||||
|
uint32_t cnt = count ();
|
||||||
|
|
||||||
|
/* Copy the track selection because it will/may change as we add new ones */
|
||||||
|
TrackSelection tracks (PublicEditor::instance().get_selection().tracks);
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
for (TrackSelection::iterator t = tracks.begin(); t != tracks.end(); ++t) {
|
||||||
|
|
||||||
|
RouteUI* rui = dynamic_cast<RouteUI*> (*t);
|
||||||
|
|
||||||
|
if (!rui) {
|
||||||
|
/* some other type of timeaxis view, not a route */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rui->route()->is_master() || rui->route()->is_monitor()) {
|
||||||
|
/* no option to duplicate these */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMLNode& state (rui->route()->get_state());
|
||||||
|
RouteList rl = _session->new_route_from_template (cnt, state, std::string(), playlist_action);
|
||||||
|
|
||||||
|
/* normally the state node would be added to a parent, and
|
||||||
|
* ownership would transfer. Because we don't do that here,
|
||||||
|
* we need to delete the node ourselves.
|
||||||
|
*/
|
||||||
|
|
||||||
|
delete &state;
|
||||||
|
|
||||||
|
if (rl.empty()) {
|
||||||
|
err++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
MessageDialog msg (_("1 or more tracks/busses could not be duplicated"),
|
||||||
|
true, MESSAGE_ERROR, BUTTONS_OK, true);
|
||||||
|
msg.set_position (WIN_POS_MOUSE);
|
||||||
|
msg.run ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -38,10 +38,7 @@ class DuplicateRouteDialog : public ArdourDialog
|
|||||||
DuplicateRouteDialog ();
|
DuplicateRouteDialog ();
|
||||||
~DuplicateRouteDialog ();
|
~DuplicateRouteDialog ();
|
||||||
|
|
||||||
void setup (uint32_t ntracks, uint32_t nbusses);
|
int restart ();
|
||||||
|
|
||||||
uint32_t count() const;
|
|
||||||
ARDOUR::PlaylistDisposition playlist_disposition() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Gtk::Entry name_template_entry;
|
Gtk::Entry name_template_entry;
|
||||||
@ -54,6 +51,11 @@ class DuplicateRouteDialog : public ArdourDialog
|
|||||||
Gtk::SpinButton count_spinner;
|
Gtk::SpinButton count_spinner;
|
||||||
Gtk::HBox count_box;
|
Gtk::HBox count_box;
|
||||||
Gtk::Label count_label;
|
Gtk::Label count_label;
|
||||||
|
|
||||||
|
void on_response (int);
|
||||||
|
|
||||||
|
uint32_t count() const;
|
||||||
|
ARDOUR::PlaylistDisposition playlist_disposition() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __gtk_ardour_duplicate_route_dialog_h__ */
|
#endif /* __gtk_ardour_duplicate_route_dialog_h__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user