summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-02-27 01:59:04 +0000
committerCarl Hetherington <carl@carlh.net>2011-02-27 01:59:04 +0000
commit7590b859fd0f836c624394c674aac09f812b3cfb (patch)
tree0157c4f2bf1aa94b032ba60cb7e549c88d172377
parent90c69e71168d665abfa8c605a5e666fe9e4fdb5b (diff)
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
-rw-r--r--gtk2_ardour/add_route_dialog.cc53
-rw-r--r--gtk2_ardour/add_route_dialog.h1
-rw-r--r--gtk2_ardour/ardour_ui.cc24
-rw-r--r--gtk2_ardour/ardour_ui.h36
-rw-r--r--libs/ardour/ardour/session.h15
-rw-r--r--libs/ardour/session.cc53
6 files changed, 131 insertions, 51 deletions
diff --git a/gtk2_ardour/add_route_dialog.cc b/gtk2_ardour/add_route_dialog.cc
index 95ee556ebe..1f7239f6e9 100644
--- a/gtk2_ardour/add_route_dialog.cc
+++ b/gtk2_ardour/add_route_dialog.cc
@@ -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));
@@ -179,18 +190,34 @@ AddRouteDialog::~AddRouteDialog ()
}
void
-AddRouteDialog::track_type_chosen ()
+AddRouteDialog::maybe_update_name_template_entry ()
{
- 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());
+ 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 {
- mode_combo.set_sensitive (false);
+ name_template_entry.set_text (_("Bus"));
}
}
+void
+AddRouteDialog::track_type_chosen ()
+{
+ mode_combo.set_sensitive (track ());
+ maybe_update_name_template_entry ();
+}
+
bool
AddRouteDialog::track ()
{
diff --git a/gtk2_ardour/add_route_dialog.h b/gtk2_ardour/add_route_dialog.h
index bc0434e461..9d4d89906a 100644
--- a/gtk2_ardour/add_route_dialog.h
+++ b/gtk2_ardour/add_route_dialog.h
@@ -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 ();
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index d98be0ae7f..bfe8458b62 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -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);
}
}
}
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index 03eaf1379b..d38dabc085 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -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);
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 6b874d8041..3463c227f2 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -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,
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 734fad2d1b..b7d04c379f 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -1417,20 +1417,29 @@ 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
- * will be set to the ID.
+ * 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
+ * will be set to the ID.
*
- * \return false if a route name could not be found, and \a track_name
- * and \a id do not reflect a free route name.
+ * \return false if a route name could not be found, and \a track_name
+ * 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*/
}