Allow naming of new tracks/busses in the add route dialogue (#3376).
git-svn-id: svn://localhost/ardour2/branches/3.0@8976 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
90c69e7116
commit
7590b859fd
@ -130,27 +130,37 @@ AddRouteDialog::AddRouteDialog (Session* s)
|
||||
l->set_padding (8, 0);
|
||||
table2->attach (*l, 0, 1, 0, 3, Gtk::FILL, Gtk::FILL, 0, 0);
|
||||
|
||||
int n = 0;
|
||||
|
||||
l = manage (new Label (_("Name:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
|
||||
table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
||||
table2->attach (name_template_entry, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
|
||||
++n;
|
||||
|
||||
/* Route configuration */
|
||||
|
||||
l = manage (new Label (_("Configuration:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
|
||||
table2->attach (*l, 1, 2, 0, 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
||||
table2->attach (channel_combo, 2, 3, 0, 1, Gtk::FILL, Gtk::EXPAND & Gtk::FILL, 0, 0);
|
||||
table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
||||
table2->attach (channel_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
|
||||
++n;
|
||||
|
||||
if (!ARDOUR::Profile->get_sae ()) {
|
||||
|
||||
/* Track mode */
|
||||
|
||||
mode_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
|
||||
table2->attach (mode_label, 1, 2, 1, 2, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
||||
table2->attach (mode_combo, 2, 3, 1, 2, Gtk::FILL, Gtk::EXPAND & Gtk::FILL, 0, 0);
|
||||
table2->attach (mode_label, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
||||
table2->attach (mode_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
|
||||
++n;
|
||||
|
||||
}
|
||||
|
||||
/* Group choice */
|
||||
|
||||
l = manage (new Label (_("Group:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
|
||||
table2->attach (*l, 1, 2, 2, 3, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
||||
table2->attach (route_group_combo, 2, 3, 2, 3, Gtk::FILL, Gtk::EXPAND & Gtk::FILL, 0, 0);
|
||||
table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
||||
table2->attach (route_group_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
|
||||
++n;
|
||||
|
||||
options_box->pack_start (*table2, false, true);
|
||||
vbox->pack_start (*options_box, false, true);
|
||||
@ -158,6 +168,7 @@ AddRouteDialog::AddRouteDialog (Session* s)
|
||||
get_vbox()->pack_start (*vbox, false, false);
|
||||
|
||||
track_bus_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::track_type_chosen));
|
||||
channel_combo.signal_changed().connect (sigc::mem_fun (*this, &AddRouteDialog::maybe_update_name_template_entry));
|
||||
channel_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::channel_separator));
|
||||
route_group_combo.set_row_separator_func (sigc::mem_fun (*this, &AddRouteDialog::route_separator));
|
||||
route_group_combo.signal_changed ().connect (sigc::mem_fun (*this, &AddRouteDialog::group_changed));
|
||||
@ -178,17 +189,33 @@ AddRouteDialog::~AddRouteDialog ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AddRouteDialog::maybe_update_name_template_entry ()
|
||||
{
|
||||
if (
|
||||
name_template_entry.get_text() != "" &&
|
||||
name_template_entry.get_text() != _("Audio") &&
|
||||
name_template_entry.get_text() != _("MIDI") &&
|
||||
name_template_entry.get_text() != _("Bus")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (track ()) {
|
||||
if (type () == DataType::MIDI) {
|
||||
name_template_entry.set_text (_("MIDI"));
|
||||
} else {
|
||||
name_template_entry.set_text (_("Audio"));
|
||||
}
|
||||
} else {
|
||||
name_template_entry.set_text (_("Bus"));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AddRouteDialog::track_type_chosen ()
|
||||
{
|
||||
if (track()) {
|
||||
mode_label.set_text (_("Track mode:"));
|
||||
set_popdown_strings (mode_combo, track_mode_strings);
|
||||
mode_combo.set_sensitive (true);
|
||||
mode_combo.set_active_text (track_mode_strings.front());
|
||||
} else {
|
||||
mode_combo.set_sensitive (false);
|
||||
}
|
||||
mode_combo.set_sensitive (track ());
|
||||
maybe_update_name_template_entry ();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -75,6 +75,7 @@ class AddRouteDialog : public ArdourDialog
|
||||
void group_changed ();
|
||||
bool channel_separator (const Glib::RefPtr<Gtk::TreeModel> &m, const Gtk::TreeModel::iterator &i);
|
||||
bool route_separator (const Glib::RefPtr<Gtk::TreeModel> &m, const Gtk::TreeModel::iterator &i);
|
||||
void maybe_update_name_template_entry ();
|
||||
|
||||
void reset_template_option_visibility ();
|
||||
|
||||
|
@ -1334,7 +1334,7 @@ ARDOUR_UI::open_session ()
|
||||
|
||||
|
||||
void
|
||||
ARDOUR_UI::session_add_midi_route (bool disk, RouteGroup* route_group, uint32_t how_many)
|
||||
ARDOUR_UI::session_add_midi_route (bool disk, RouteGroup* route_group, uint32_t how_many, string const & name_template)
|
||||
{
|
||||
list<boost::shared_ptr<MidiTrack> > tracks;
|
||||
|
||||
@ -1346,7 +1346,7 @@ ARDOUR_UI::session_add_midi_route (bool disk, RouteGroup* route_group, uint32_t
|
||||
try {
|
||||
if (disk) {
|
||||
|
||||
tracks = _session->new_midi_track (ARDOUR::Normal, route_group, how_many);
|
||||
tracks = _session->new_midi_track (ARDOUR::Normal, route_group, how_many, name_template);
|
||||
|
||||
if (tracks.size() != how_many) {
|
||||
if (how_many == 1) {
|
||||
@ -1374,7 +1374,15 @@ restart JACK with more ports."), PROGRAM_NAME));
|
||||
|
||||
|
||||
void
|
||||
ARDOUR_UI::session_add_audio_route (bool track, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, RouteGroup* route_group, uint32_t how_many)
|
||||
ARDOUR_UI::session_add_audio_route (
|
||||
bool track,
|
||||
int32_t input_channels,
|
||||
int32_t output_channels,
|
||||
ARDOUR::TrackMode mode,
|
||||
RouteGroup* route_group,
|
||||
uint32_t how_many,
|
||||
string const & name_template
|
||||
)
|
||||
{
|
||||
list<boost::shared_ptr<AudioTrack> > tracks;
|
||||
RouteList routes;
|
||||
@ -1386,7 +1394,7 @@ ARDOUR_UI::session_add_audio_route (bool track, int32_t input_channels, int32_t
|
||||
|
||||
try {
|
||||
if (track) {
|
||||
tracks = _session->new_audio_track (input_channels, output_channels, mode, route_group, how_many);
|
||||
tracks = _session->new_audio_track (input_channels, output_channels, mode, route_group, how_many, name_template);
|
||||
|
||||
if (tracks.size() != how_many) {
|
||||
if (how_many == 1) {
|
||||
@ -1399,7 +1407,7 @@ ARDOUR_UI::session_add_audio_route (bool track, int32_t input_channels, int32_t
|
||||
|
||||
} else {
|
||||
|
||||
routes = _session->new_audio_route (input_channels, output_channels, route_group, how_many);
|
||||
routes = _session->new_audio_route (input_channels, output_channels, route_group, how_many, name_template);
|
||||
|
||||
if (routes.size() != how_many) {
|
||||
if (how_many == 1) {
|
||||
@ -3219,7 +3227,7 @@ ARDOUR_UI::add_route (Gtk::Window* float_window)
|
||||
|
||||
if (add_route_dialog->type() == ARDOUR::DataType::MIDI) {
|
||||
if (track) {
|
||||
session_add_midi_track (route_group, count);
|
||||
session_add_midi_track (route_group, count, name_template);
|
||||
} else {
|
||||
MessageDialog msg (*editor,
|
||||
_("Sorry, MIDI Busses are not supported at this time."));
|
||||
@ -3228,9 +3236,9 @@ ARDOUR_UI::add_route (Gtk::Window* float_window)
|
||||
}
|
||||
} else {
|
||||
if (track) {
|
||||
session_add_audio_track (input_chan, output_chan, add_route_dialog->mode(), route_group, count);
|
||||
session_add_audio_track (input_chan, output_chan, add_route_dialog->mode(), route_group, count, name_template);
|
||||
} else {
|
||||
session_add_audio_bus (input_chan, output_chan, route_group, count);
|
||||
session_add_audio_bus (input_chan, output_chan, route_group, count, name_template);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,16 +204,36 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
||||
|
||||
void add_route (Gtk::Window* float_window);
|
||||
|
||||
void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode, ARDOUR::RouteGroup* route_group, uint32_t how_many) {
|
||||
session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many);
|
||||
void session_add_audio_track (
|
||||
int input_channels,
|
||||
int32_t output_channels,
|
||||
ARDOUR::TrackMode mode,
|
||||
ARDOUR::RouteGroup* route_group,
|
||||
uint32_t how_many,
|
||||
std::string const & name_template
|
||||
) {
|
||||
|
||||
session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
|
||||
}
|
||||
|
||||
void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group, uint32_t how_many) {
|
||||
session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many);
|
||||
void session_add_audio_bus (
|
||||
int input_channels,
|
||||
int32_t output_channels,
|
||||
ARDOUR::RouteGroup* route_group,
|
||||
uint32_t how_many,
|
||||
std::string const & name_template
|
||||
) {
|
||||
|
||||
session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
|
||||
}
|
||||
|
||||
void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many) {
|
||||
session_add_midi_route (true, route_group, how_many);
|
||||
void session_add_midi_track (
|
||||
ARDOUR::RouteGroup* route_group,
|
||||
uint32_t how_many,
|
||||
std::string const & name_template
|
||||
) {
|
||||
|
||||
session_add_midi_route (true, route_group, how_many, name_template);
|
||||
}
|
||||
|
||||
/*void session_add_midi_bus () {
|
||||
@ -549,8 +569,8 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
||||
void edit_metadata ();
|
||||
void import_metadata ();
|
||||
|
||||
void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, ARDOUR::RouteGroup *, uint32_t how_many);
|
||||
void session_add_midi_route (bool disk, ARDOUR::RouteGroup *, uint32_t how_many);
|
||||
void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
|
||||
void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &);
|
||||
|
||||
void set_transport_sensitivity (bool);
|
||||
|
||||
|
@ -415,13 +415,20 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
||||
/* fundamental operations. duh. */
|
||||
|
||||
std::list<boost::shared_ptr<AudioTrack> > new_audio_track (
|
||||
int input_channels, int output_channels, TrackMode mode = Normal, RouteGroup* route_group = 0, uint32_t how_many = 1
|
||||
int input_channels,
|
||||
int output_channels,
|
||||
TrackMode mode = Normal,
|
||||
RouteGroup* route_group = 0,
|
||||
uint32_t how_many = 1,
|
||||
std::string name_template = ""
|
||||
);
|
||||
|
||||
RouteList new_audio_route (int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many);
|
||||
RouteList new_audio_route (
|
||||
int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many, std::string name_template = ""
|
||||
);
|
||||
|
||||
std::list<boost::shared_ptr<MidiTrack> > new_midi_track (
|
||||
TrackMode mode = Normal, RouteGroup* route_group = 0, uint32_t how_many = 1
|
||||
TrackMode mode = Normal, RouteGroup* route_group = 0, uint32_t how_many = 1, std::string name_template = ""
|
||||
);
|
||||
|
||||
void remove_route (boost::shared_ptr<Route>);
|
||||
@ -1206,7 +1213,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
||||
|
||||
void route_processors_changed (RouteProcessorChange);
|
||||
|
||||
bool find_route_name (const char* base, uint32_t& id, char* name, size_t name_len);
|
||||
bool find_route_name (std::string const &, uint32_t& id, char* name, size_t name_len, bool);
|
||||
void count_existing_route_channels (ChanCount& in, ChanCount& out);
|
||||
void auto_connect_route (
|
||||
Route* route,
|
||||
|
@ -1417,7 +1417,10 @@ Session::resort_routes_using (boost::shared_ptr<RouteList> r)
|
||||
|
||||
}
|
||||
|
||||
/** Find the route name starting with \a base with the lowest \a id.
|
||||
/** Find a route name starting with \a base, maybe followed by the
|
||||
* lowest \a id. \a id will always be added if \a definitely_add_number
|
||||
* is true on entry; otherwise it will only be added if required
|
||||
* to make the name unique.
|
||||
*
|
||||
* Names are constructed like e.g. "Audio 3" for base="Audio" and id=3.
|
||||
* The available route name with the lowest ID will be used, and \a id
|
||||
@ -1427,10 +1430,16 @@ Session::resort_routes_using (boost::shared_ptr<RouteList> r)
|
||||
* and \a id do not reflect a free route name.
|
||||
*/
|
||||
bool
|
||||
Session::find_route_name (const char* base, uint32_t& id, char* name, size_t name_len)
|
||||
Session::find_route_name (string const & base, uint32_t& id, char* name, size_t name_len, bool definitely_add_number)
|
||||
{
|
||||
if (!definitely_add_number && route_by_name (base) == 0) {
|
||||
/* juse use the base */
|
||||
snprintf (name, name_len, "%s", base.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
do {
|
||||
snprintf (name, name_len, "%s %" PRIu32, base, id);
|
||||
snprintf (name, name_len, "%s %" PRIu32, base.c_str(), id);
|
||||
|
||||
if (route_by_name (name) == 0) {
|
||||
return true;
|
||||
@ -1458,9 +1467,11 @@ Session::count_existing_route_channels (ChanCount& in, ChanCount& out)
|
||||
}
|
||||
}
|
||||
|
||||
/** Caller must not hold process lock */
|
||||
/** Caller must not hold process lock
|
||||
* @param name_template string to use for the start of the name, or "" to use "Midi".
|
||||
*/
|
||||
list<boost::shared_ptr<MidiTrack> >
|
||||
Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_many)
|
||||
Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template)
|
||||
{
|
||||
char track_name[32];
|
||||
uint32_t track_id = 0;
|
||||
@ -1476,7 +1487,7 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m
|
||||
control_id = ntracks() + nbusses();
|
||||
|
||||
while (how_many) {
|
||||
if (!find_route_name ("Midi", ++track_id, track_name, sizeof(track_name))) {
|
||||
if (!find_route_name (name_template.empty() ? _("Midi") : name_template, ++track_id, track_name, sizeof(track_name), false)) {
|
||||
error << "cannot find name for new midi track" << endmsg;
|
||||
goto failed;
|
||||
}
|
||||
@ -1626,9 +1637,13 @@ Session::auto_connect_route (
|
||||
existing_outputs += route->n_outputs();
|
||||
}
|
||||
|
||||
/** Caller must not hold process lock */
|
||||
/** Caller must not hold process lock
|
||||
* @param name_template string to use for the start of the name, or "" to use "Audio".
|
||||
*/
|
||||
list< boost::shared_ptr<AudioTrack> >
|
||||
Session::new_audio_track (int input_channels, int output_channels, TrackMode mode, RouteGroup* route_group, uint32_t how_many)
|
||||
Session::new_audio_track (
|
||||
int input_channels, int output_channels, TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template
|
||||
)
|
||||
{
|
||||
char track_name[32];
|
||||
uint32_t track_id = 0;
|
||||
@ -1644,7 +1659,7 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
|
||||
control_id = ntracks() + nbusses() + 1;
|
||||
|
||||
while (how_many) {
|
||||
if (!find_route_name ("Audio", ++track_id, track_name, sizeof(track_name))) {
|
||||
if (!find_route_name (name_template.empty() ? _("Audio") : name_template, ++track_id, track_name, sizeof(track_name), false)) {
|
||||
error << "cannot find name for new audio track" << endmsg;
|
||||
goto failed;
|
||||
}
|
||||
@ -1748,9 +1763,11 @@ Session::set_remote_control_ids ()
|
||||
}
|
||||
}
|
||||
|
||||
/** Caller must not hold process lock */
|
||||
/** Caller must not hold process lock.
|
||||
* @param name_template string to use for the start of the name, or "" to use "Bus".
|
||||
*/
|
||||
RouteList
|
||||
Session::new_audio_route (int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many)
|
||||
Session::new_audio_route (int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many, string name_template)
|
||||
{
|
||||
char bus_name[32];
|
||||
uint32_t bus_id = 0;
|
||||
@ -1765,7 +1782,7 @@ Session::new_audio_route (int input_channels, int output_channels, RouteGroup* r
|
||||
control_id = ntracks() + nbusses() + 1;
|
||||
|
||||
while (how_many) {
|
||||
if (!find_route_name ("Bus", ++bus_id, bus_name, sizeof(bus_name))) {
|
||||
if (!find_route_name (name_template.empty () ? _("Bus") : name_template, ++bus_id, bus_name, sizeof(bus_name), false)) {
|
||||
error << "cannot find name for new audio bus" << endmsg;
|
||||
goto failure;
|
||||
}
|
||||
@ -1860,7 +1877,7 @@ Session::new_route_from_template (uint32_t how_many, const std::string& template
|
||||
std::string node_name = IO::name_from_state (*node_copy.children().front());
|
||||
|
||||
/* generate a new name by adding a number to the end of the template name */
|
||||
if (!find_route_name (node_name.c_str(), ++number, name, sizeof(name))) {
|
||||
if (!find_route_name (node_name.c_str(), ++number, name, sizeof(name), true)) {
|
||||
fatal << _("Session: UINT_MAX routes? impossible!") << endmsg;
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user