diff options
author | Campbell Barton <campbell@blender.org> | 2022-05-20 07:30:17 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-05-26 05:16:35 +0300 |
commit | 3f3d82cfe9cefe4bfd9da3d283dec4a1923ec22d (patch) | |
tree | 532de0110686d29f63c550c4784f8d2acc86e110 /source/blender/makesrna/RNA_access.h | |
parent | 11480763b62e6ca72ae869391b8e5495e57410a6 (diff) |
UI support for showing candidates for string properties
Currently strings are used for cases where a list of identifiers would
be useful to show.
Add support for string properties to reference a callback to populate
candidates to show when editing a string. The user isn't prevented from
typing in text not found in this list, it's just useful as a reference.
Support for expanding the following strings has been added:
- Operator, menu & panel identifiers in the keymap editor.
- WM operators that reference data-paths expand using the
Python-consoles auto-complete functionality.
- Names of keying sets for insert/delete keyframe operators.
Details:
- `bpy.props.StringProperty` takes an option `search` callback.
- A new string callback has been added, set via
`RNA_def_property_string_search_func` or
`RNA_def_property_string_search_func_runtime`.
- Addresses usability issue highlighted by T89560,
where setting keying set identifiers as strings isn't practical.
- Showing additional right-aligned text in the search results is
supported but disabled by default as the text is too cramped in most
string search popups where the feature would make sense. It could be
enabled as part of other layout tweaks.
Reviewed By: brecht
Ref D14986
Diffstat (limited to 'source/blender/makesrna/RNA_access.h')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index f0a60929431..4267ce47d81 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -358,6 +358,21 @@ char *RNA_property_string_get_alloc( PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len); void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value); void RNA_property_string_set_bytes(PointerRNA *ptr, PropertyRNA *prop, const char *value, int len); + +eStringPropertySearchFlag RNA_property_string_search_flag(PropertyRNA *prop); +/** + * Search candidates for string `prop` by calling `visit_fn` with each string. + * Typically these strings are collected in `visit_user_data` in a format defined by the caller. + * + * See #PropStringSearchFunc for details. + */ +void RNA_property_string_search(const struct bContext *C, + PointerRNA *ptr, + PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data); + /** * \return the length without `\0` terminator. */ |