summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/route_time_axis.cc3
-rw-r--r--libs/ardour/ardour/region_factory.h1
-rw-r--r--libs/ardour/region_factory.cc36
3 files changed, 33 insertions, 7 deletions
diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc
index 16e1d72d53..296251a859 100644
--- a/gtk2_ardour/route_time_axis.cc
+++ b/gtk2_ardour/route_time_axis.cc
@@ -53,6 +53,7 @@
#include "ardour/playlist.h"
#include "ardour/processor.h"
#include "ardour/profile.h"
+#include "ardour/region_factory.h"
#include "ardour/route_group.h"
#include "ardour/session.h"
#include "ardour/session_playlist.h"
@@ -2500,7 +2501,7 @@ RouteTimeAxisView::combine_regions ()
_view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions, &max_level));
- string name = string_compose (_("%1 compound-%2 (%3)"), playlist->name(), playlist->combine_ops()+1, max_level+1);
+ string name = RegionFactory::compound_region_name (playlist->name(), playlist->combine_ops(), max_level);
playlist->clear_changes ();
playlist->combine (selected_regions, name);
diff --git a/libs/ardour/ardour/region_factory.h b/libs/ardour/ardour/region_factory.h
index 979b499b3a..7feca25495 100644
--- a/libs/ardour/ardour/region_factory.h
+++ b/libs/ardour/ardour/region_factory.h
@@ -91,6 +91,7 @@ public:
static int region_name (std::string &, std::string, bool new_level = false);
static std::string new_region_name (std::string);
+ static std::string compound_region_name (const std::string& playlist, uint32_t compound_ops, uint32_t depth);
/* when we make a compound region, for every region involved there
* are two "instances" - the original, which is removed from this
diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc
index 513ec7301b..9dbd0ded37 100644
--- a/libs/ardour/region_factory.cc
+++ b/libs/ardour/region_factory.cc
@@ -488,25 +488,49 @@ RegionFactory::region_name (string& result, string base, bool newlevel)
}
string
+RegionFactory::compound_region_name (const string& playlist, uint32_t compound_ops, uint32_t depth)
+{
+ return string_compose (_("%1 compound-%2.1 (%3)"), playlist, compound_ops+1, depth+1);
+}
+
+string
RegionFactory::new_region_name (string old)
{
string::size_type last_period;
uint32_t number;
string::size_type len = old.length() + 64;
+ string remainder;
char buf[len];
if ((last_period = old.find_last_of ('.')) == string::npos) {
-
+
/* no period present - add one explicitly */
-
+
old += '.';
last_period = old.length() - 1;
number = 0;
-
+
} else {
+
+ if (last_period < old.length() - 1) {
+
+ string period_to_end = old.substr (last_period+1);
+
+ /* extra material after the period */
+
+ string::size_type numerals_end = period_to_end.find_first_not_of ("0123456789");
+
+ number = atoi (period_to_end);
+
+ if (numerals_end < period_to_end.length() - 1) {
+ /* extra material after the end of the digits */
+ remainder = period_to_end.substr (numerals_end);
+ }
- number = atoi (old.substr (last_period+1).c_str());
-
+ } else {
+ last_period = old.length();
+ number = 0;
+ }
}
while (number < (UINT_MAX-1)) {
@@ -517,7 +541,7 @@ RegionFactory::new_region_name (string old)
number++;
- snprintf (buf, len, "%s%" PRIu32, old.substr (0, last_period + 1).c_str(), number);
+ snprintf (buf, len, "%s%" PRIu32 "%s", old.substr (0, last_period + 1).c_str(), number, remainder.c_str());
sbuf = buf;
for (i = regions.begin(); i != regions.end(); ++i) {