Commit: ae085e301c2aac0d6956609bfe93a90a19f0e235 Author: Fabian Schempp Date: Fri Jun 25 07:57:24 2021 +0200 Branches: master https://developer.blender.org/rBae085e301c2aac0d6956609bfe93a90a19f0e235
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 =================================================================== M release/datafiles/userdef/userdef_default_theme.c M release/scripts/presets/keyconfig/keymap_data/blender_default.py M release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py M release/scripts/startup/bl_ui/space_spreadsheet.py M source/blender/blenkernel/BKE_attribute.h M source/blender/blenkernel/BKE_blender_version.h M source/blender/blenlib/BLI_string.h M source/blender/blenlib/intern/string.c M source/blender/blenlib/tests/BLI_string_test.cc M source/blender/blenloader/intern/versioning_300.c M source/blender/blenloader/intern/versioning_userdef.c M source/blender/editors/include/ED_spreadsheet.h M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface.c M source/blender/editors/interface/interface_handlers.c M source/blender/editors/interface/interface_intern.h M source/blender/editors/interface/interface_query.c M source/blender/editors/interface/interface_widgets.c M source/blender/editors/space_spreadsheet/CMakeLists.txt M source/blender/editors/space_spreadsheet/space_spreadsheet.cc M source/blender/editors/space_spreadsheet/spreadsheet_context.cc M source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.cc A source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.cc A source/blender/editors/space_spreadsheet/spreadsheet_dataset_draw.hh A source/blender/editors/space_spreadsheet/spreadsheet_dataset_layout.cc A source/blender/editors/space_spreadsheet/spreadsheet_dataset_layout.hh M source/blender/editors/space_spreadsheet/spreadsheet_intern.hh M source/blender/editors/space_spreadsheet/spreadsheet_ops.cc M source/blender/makesrna/intern/rna_space.c M source/blender/makesrna/intern/rna_userdef.c =================================================================== diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c index 48e675492f9..441a92127ea 100644 --- a/release/datafiles/userdef/userdef_default_theme.c +++ b/release/datafiles/userdef/userdef_default_theme.c @@ -1041,6 +1041,11 @@ const bTheme U_theme_default = { .active_object = RGBA(0xffaf29ff), .edited_object = RGBA(0x00806266), .row_alternate = RGBA(0xffffff07), + .list = RGBA(0x424242ff), + .list_title = RGBA(0xc3c3c3ff), + .list_text = RGBA(0xc3c3c3ff), + .list_text_hi = RGBA(0xffffff), + .hilite = RGBA(0x80808080), }, .tarm = { { diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index bd14b2c532c..7f1039a975b 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -187,7 +187,7 @@ def _template_items_context_panel(menu, key_args_primary): ] -def _template_space_region_type_toggle(*, toolbar_key=None, sidebar_key=None): +def _template_space_region_type_toggle(*, toolbar_key=None, sidebar_key=None, channels_key=None): items = [] if toolbar_key is not None: items.append( @@ -199,6 +199,12 @@ def _template_space_region_type_toggle(*, toolbar_key=None, sidebar_key=None): ("wm.context_toggle", sidebar_key, {"properties": [("data_path", 'space_data.show_region_ui')]}), ) + if channels_key is not None: + items.append( + ("wm.context_toggle", channels_key, + {"properties": [("data_path", 'space_data.show_region_channels')]}), + ) + return items @@ -3021,6 +3027,7 @@ def km_spreadsheet_generic(_params): items.extend([ *_template_space_region_type_toggle( sidebar_key={"type": 'N', "value": 'PRESS'}, + channels_key={"type": 'T', "value": 'PRESS'}, ), ]) diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py index e56783fcc21..b0144672745 100644 --- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py +++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py @@ -2143,6 +2143,21 @@ def km_clip_dopesheet_editor(_params): return keymap +def km_spreadsheet_generic(_params): + items = [] + keymap = ( + "Spreadsheet Generic", + {"space_type": 'SPREADSHEET', "region_type": 'WINDOW'}, + {"items": items}, + ) + + items.extend([ + *_template_space_region_type_toggle( + channels_key={"type": 'T', "value": 'PRESS'}, + ), + ]) + + return keymap # ------------------------------------------------------------------------------ # Animation diff --git a/release/scripts/startup/bl_ui/space_spreadsheet.py b/release/scripts/startup/bl_ui/space_spreadsheet.py index 360849a0c7a..178be9ef0b7 100644 --- a/release/scripts/startup/bl_ui/space_spreadsheet.py +++ b/release/scripts/startup/bl_ui/space_spreadsheet.py @@ -41,10 +41,6 @@ class SPREADSHEET_HT_header(bpy.types.Header): return layout.prop(space, "object_eval_state", text="") - if space.object_eval_state != 'ORIGINAL': - layout.prop(space, "geometry_component_type", text="") - if space.geometry_component_type != 'INSTANCES': - layout.prop(space, "attribute_domain", text="") context_path = space.context_path if space.object_eval_state == 'ORIGINAL': diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h index 30a595dba8e..6a1f1feb14f 100644 --- a/source/blender/blenkernel/BKE_attribute.h +++ b/source/blender/blenkernel/BKE_attribute.h @@ -38,12 +38,16 @@ struct ID; struct ReportList; /* Attribute.domain */ +/** + * \warning: Careful when changing existing items. Arrays may be initialized from this (e.g. + * #DATASET_layout_hierarchy). + */ typedef enum AttributeDomain { ATTR_DOMAIN_AUTO = -1, /* Use for nodes to choose automatically based on other data. */ ATTR_DOMAIN_POINT = 0, /* Mesh, Hair or PointCloud Point */ ATTR_DOMAIN_EDGE = 1, /* Mesh Edge */ - ATTR_DOMAIN_CORNER = 2, /* Mesh Corner */ - ATTR_DOMAIN_FACE = 3, /* Mesh Face */ + ATTR_DOMAIN_FACE = 2, /* Mesh Face */ + ATTR_DOMAIN_CORNER = 3, /* Mesh Corner */ ATTR_DOMAIN_CURVE = 4, /* Hair Curve */ ATTR_DOMAIN_NUM diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 1767077fa45..bac982708bc 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -39,7 +39,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 4 +#define BLENDER_FILE_SUBVERSION 5 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 5a80680c350..f4a417dbe65 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -100,7 +100,7 @@ size_t BLI_str_format_int_grouped(char dst[16], int num) ATTR_NONNULL(); size_t BLI_str_format_uint64_grouped(char dst[16], uint64_t num) ATTR_NONNULL(); void BLI_str_format_byte_unit(char dst[15], long long int bytes, const bool base_10) ATTR_NONNULL(); - +void BLI_str_format_attribute_domain_size(char dst[4], int number_to_format) ATTR_NONNULL(); int BLI_strcaseeq(const char *a, const char *b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); char *BLI_strcasestr(const char *s, const char *find) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); char *BLI_strncasestr(const char *s, const char *find, size_t len) ATTR_WARN_UNUSED_RESULT 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 @@ -1229,6 +1229,44 @@ void BLI_str_format_byte_unit(char dst[15], long long int bytes, const bool base BLI_strncpy(dst + len, base_10 ? units_base_10[order] : units_base_2[order], dst_len - len); } +/** + * 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. * diff --git a/source/blender/blenlib/tests/BLI_string_test.cc b/source/blender/blenlib/tests/BLI_string_test.cc index 0b68ee8b93c..ccd2d01be98 100644 --- a/source/blender/blenlib/tests/BLI_string_test.cc +++ b/source/blender/blenlib/tests/BLI_string_test.cc @@ -420,6 +420,101 @@ TEST(string, StrFormatByteUnits) EXPECT_STREQ("-8191.8472 PiB", size_str); } +/* BLI_str_format_attribute_domain_size */ +TEST(string, StrFormatAttributeDomainSize) +{ + char size_str[7]; + int size; + + BLI_str_format_attribute_domain_size(size_str, size = 0); + EXPECT_STREQ("0", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 1); + EXPECT_STREQ("1", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 10); + EXPECT_STREQ("10", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 15); + EXPECT_STREQ("15", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 100); + EXPECT_STREQ("100", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 155); + EXPECT_STREQ("155", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 1000); + EXPECT_STREQ("1.0K", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 1555); + EXPECT_STREQ("1.6K", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 10000); + EXPECT_STREQ("10.0K", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 15555); + EXPECT_STREQ("15.6K", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 100000); + EXPECT_STREQ("100K", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 100000); + EXPECT_STREQ("100K", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 155555); + EXPECT_STREQ("156K", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 1000000); + EXPECT_STREQ("1.0M", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 1555555); + EXPECT_STREQ("1.6M", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 10000000); + EXPECT_STREQ("10.0M", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 15555555); + EXPECT_STREQ("15.6M", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 100000000); + EXPECT_STREQ("100M", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 155555555); + EXPECT_STREQ("156M", size_str); + BLI_str_format_attribute_domain_size(size_str, size = 1000000000); + EXPECT_STREQ( @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs