Fix: use natural string sorting for attribute names
This commit is contained in:
parent
c2751f8a11
commit
26afa23b3b
|
@ -1703,14 +1703,25 @@ static char *named_attribute_tooltip(bContext *UNUSED(C), void *argN, const char
|
|||
|
||||
std::stringstream ss;
|
||||
ss << TIP_("Accessed attribute names:\n");
|
||||
Vector<std::pair<StringRefNull, NamedAttributeUsage>> sorted_used_attribute;
|
||||
|
||||
struct NameWithUsage {
|
||||
StringRefNull name;
|
||||
NamedAttributeUsage usage;
|
||||
};
|
||||
|
||||
Vector<NameWithUsage> sorted_used_attribute;
|
||||
for (auto &&item : arg.usage_by_attribute.items()) {
|
||||
sorted_used_attribute.append({item.key, item.value});
|
||||
}
|
||||
std::sort(sorted_used_attribute.begin(), sorted_used_attribute.end());
|
||||
for (const std::pair<StringRefNull, NamedAttributeUsage> &attribute : sorted_used_attribute) {
|
||||
const StringRefNull name = attribute.first;
|
||||
const NamedAttributeUsage usage = attribute.second;
|
||||
std::sort(sorted_used_attribute.begin(),
|
||||
sorted_used_attribute.end(),
|
||||
[](const NameWithUsage &a, const NameWithUsage &b) {
|
||||
return BLI_strcasecmp_natural(a.name.c_str(), b.name.c_str()) <= 0;
|
||||
});
|
||||
|
||||
for (const NameWithUsage &attribute : sorted_used_attribute) {
|
||||
const StringRefNull name = attribute.name;
|
||||
const NamedAttributeUsage usage = attribute.usage;
|
||||
ss << " \u2022 \"" << name << "\": ";
|
||||
Vector<std::string> usages;
|
||||
if ((usage & NamedAttributeUsage::Read) != NamedAttributeUsage::None) {
|
||||
|
|
|
@ -1648,15 +1648,24 @@ static void used_attributes_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
return;
|
||||
}
|
||||
|
||||
Vector<std::pair<StringRefNull, NamedAttributeUsage>> sorted_used_attribute;
|
||||
struct NameWithUsage {
|
||||
StringRefNull name;
|
||||
NamedAttributeUsage usage;
|
||||
};
|
||||
|
||||
Vector<NameWithUsage> sorted_used_attribute;
|
||||
for (auto &&item : usage_by_attribute.items()) {
|
||||
sorted_used_attribute.append({item.key, item.value});
|
||||
}
|
||||
std::sort(sorted_used_attribute.begin(), sorted_used_attribute.end());
|
||||
std::sort(sorted_used_attribute.begin(),
|
||||
sorted_used_attribute.end(),
|
||||
[](const NameWithUsage &a, const NameWithUsage &b) {
|
||||
return BLI_strcasecmp_natural(a.name.c_str(), b.name.c_str()) <= 0;
|
||||
});
|
||||
|
||||
for (const auto &pair : sorted_used_attribute) {
|
||||
const StringRefNull attribute_name = pair.first;
|
||||
const NamedAttributeUsage usage = pair.second;
|
||||
for (const NameWithUsage &attribute : sorted_used_attribute) {
|
||||
const StringRefNull attribute_name = attribute.name;
|
||||
const NamedAttributeUsage usage = attribute.usage;
|
||||
|
||||
/* #uiLayoutRowWithHeading doesn't seem to work in this case. */
|
||||
uiLayout *split = uiLayoutSplit(layout, 0.4f, false);
|
||||
|
|
Loading…
Reference in New Issue