diff options
author | Fabian Schempp <fabianschempp@googlemail.com> | 2021-06-25 08:57:24 +0300 |
---|---|---|
committer | Fabian Schempp <fabianschempp@googlemail.com> | 2021-06-25 08:57:24 +0300 |
commit | ae085e301c2aac0d6956609bfe93a90a19f0e235 (patch) | |
tree | 38b86749807915a6b6d46504a2acb90e41a4a77a /source/blender/blenlib/intern | |
parent | 841df831e89dfc4011c323203c2efb8265dc1878 (diff) |
Spreadsheet: Dataset region for spreadsheet editor
This patch adds a left aligned sidebar to the spreadsheet editor. This
Sidebar can be used to navigate the geometry component types and
attribute domains. It also provides a quick overview of domain sizes.
It replaces the two dropdowns in the regions header.
Next step will be to add the domain cycling shortcut
using the CTRL + mouse wheel.
Reviewer: Dalai Felinto (dfelinto), Julian Eisel (Severin),
Hans Goudey (HooglyBoogly).
Differential Revision: https://developer.blender.org/D11046
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/string.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 3d40c6ef146..cadee2bfe12 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -1230,6 +1230,44 @@ void BLI_str_format_byte_unit(char dst[15], long long int bytes, const bool base } /** + * Format a attribute domain to a up to 6 places (plus '\0' terminator) string using long number names abbreviations. + * This function is designed to produce a compact representation of large numbers. + * 1 -> 1 + * 15 -> 15 + * 155 -> 155 + * 1555 -> 1.6K + * 15555 -> 15.6K + * 155555 -> 156K + * 1555555 -> 1.6M + * 15555555 -> 15.6M + * 155555555 -> 156M + * 1000000000 -> 1B + * ... + * Dimension of 7 is the maximum length of the resulting string + * A combination with 7 places would be -15.5K\0 + */ +void BLI_str_format_attribute_domain_size(char dst[7], int number_to_format) +{ + float number_to_format_converted = number_to_format; + int order = 0; + const float base = 1000; + const char *units[] = {"", "K", "M", "B"}; + const int tot_units = ARRAY_SIZE(units); + + while ((fabsf(number_to_format_converted) >= base) && ((order + 1) < tot_units)) { + number_to_format_converted /= base; + order++; + } + + const size_t dst_len = 7; + int decimals = 0; + if ((order > 0) && fabsf(number_to_format_converted) < 100.0f) { + decimals = 1; + } + BLI_snprintf(dst, dst_len, "%.*f%s", decimals, number_to_format_converted, units[order]); +} + +/** * Find the ranges needed to split \a str into its individual words. * * \param str: The string to search for words. |