Anim: Action editor, show slot user count if not equal to 1

In the Action editor, show the number of users for each slot.

- 1 user (the expected case): not shown
- multiple users: number is shown between parentheses, f.e. `(3)`
- none: shown as `(unassigned)` as I think that's clearer than `(0)`.

This PR doesn't technically depend on !122500, but having that landed
first will make testing this one quite a bit easier.

Pull Request: https://projects.blender.org/blender/blender/pulls/124337
This commit is contained in:
Sybren A. Stüvel
2024-07-09 12:56:33 +02:00
parent d44b96bf07
commit 1276680874

View File

@@ -1369,7 +1369,22 @@ static void acf_action_slot_name(bAnimListElem *ale, char *r_name)
return;
}
BLI_strncpy(r_name, slot->name_without_prefix().c_str(), ANIM_CHAN_NAME_SIZE);
BLI_assert(ale->bmain);
const int num_users = slot->users(*ale->bmain).size();
const char *display_name = slot->name_without_prefix().c_str();
BLI_assert(num_users >= 0);
switch (num_users) {
case 0:
BLI_snprintf(r_name, ANIM_CHAN_NAME_SIZE, "%s (unassigned)", display_name);
break;
case 1:
BLI_strncpy(r_name, display_name, ANIM_CHAN_NAME_SIZE);
break;
default:
BLI_snprintf(r_name, ANIM_CHAN_NAME_SIZE, "%s (%d)", display_name, num_users);
break;
}
}
static bool acf_action_slot_name_prop(bAnimListElem *ale, PointerRNA *r_ptr, PropertyRNA **r_prop)
{