Improve Source naming increment

This commit is contained in:
Bruno Herbelin
2022-04-17 11:22:32 +02:00
parent 0615f38a26
commit 0df3342757
2 changed files with 12 additions and 3 deletions

View File

@@ -55,8 +55,17 @@ std::string BaseToolkit::uniqueName(const std::string &basename, std::list<std::
++count;
}
if (count > 1)
tentativename = basename + "_" + std::to_string( count );
if (count > 1) {
// check if the name is ending by "_i", with i being a number
int i = 0;
size_t delim = tentativename.find_last_of('_');
if (delim != std::string::npos && BaseToolkit::is_a_number(tentativename.substr(++delim), &i) )
// keep same ending "_i" and increment i
tentativename = tentativename.substr(0, delim) + std::to_string(++i);
else
// add the "_i" ending
tentativename = basename + "_" + std::to_string( count );
}
else
tentativename += "_";

View File

@@ -5651,7 +5651,7 @@ void Navigator::RenderSourcePannel(Source *s)
ImGui::PopFont();
// index indicator
ImGui::SetCursorPos(ImVec2(pannel_width_ - 35.f, 15.f));
ImGui::SetCursorPos(ImVec2(pannel_width_ - 2 * ImGui::GetTextLineHeight(), 15.f));
ImGui::TextDisabled("#%d", Mixer::manager().indexCurrentSource());
// name