13
0

rationalize and improve region naming conventions to cover compound regions

git-svn-id: svn://localhost/ardour2/branches/3.0@9569 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-05-22 21:28:25 +00:00
parent 4df8531289
commit fab94b8495
3 changed files with 32 additions and 6 deletions

View File

@ -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);

View File

@ -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

View File

@ -487,26 +487,50 @@ RegionFactory::region_name (string& result, string base, bool newlevel)
return 0;
}
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) {
number = atoi (old.substr (last_period+1).c_str());
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);
}
} 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) {