diff options
Diffstat (limited to 'source/blender/makesrna/RNA_types.h')
-rw-r--r-- | source/blender/makesrna/RNA_types.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 3ebcae5f947..75b514cdb13 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -515,6 +515,55 @@ typedef int (*StringPropertyLengthFunc)(struct PointerRNA *ptr, struct PropertyR typedef void (*StringPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, const char *value); + +typedef struct StringPropertySearchVisitParams { + /** Text being searched for (never NULL). */ + const char *text; + /** Additional information to display (optional, may be NULL). */ + const char *info; +} StringPropertySearchVisitParams; + +typedef enum eStringPropertySearchFlag { + /** + * Used so the result of #RNA_property_string_search_flag can be used to check + * if search is supported. + */ + PROP_STRING_SEARCH_SUPPORTED = (1 << 0), + /** Items resulting from the search must be sorted. */ + PROP_STRING_SEARCH_SORT = (1 << 1), + /** + * Allow members besides the ones listed to be entered. + * + * \warning disabling this options causes the search callback to run on redraw and should + * only be enabled this doesn't cause performance issues. + */ + PROP_STRING_SEARCH_SUGGESTION = (1 << 2), +} eStringPropertySearchFlag; + +/** + * Visit string search candidates, `text` may be freed once this callback has finished, + * so references to it should not be held. + */ +typedef void (*StringPropertySearchVisitFunc)(void *visit_user_data, + const StringPropertySearchVisitParams *params); +/** + * \param C: context, may be NULL (in this case all available items should be shown). + * \param ptr: RNA pointer. + * \param prop: RNA property. This must have it's #StringPropertyRNA.search callback set, + * to check this use `RNA_property_string_search_flag(prop) & PROP_STRING_SEARCH_SUPPORTED`. + * \param edit_text: Optionally use the string being edited by the user as a basis + * for the search results (auto-complete Python attributes for e.g.). + * \param visit_fn: This function is called with every search candidate and is typically + * responsible for storing the search results. + * \param visit_user_data: Caller defined data, passed to `visit_fn`. + */ +typedef void (*StringPropertySearchFunc)(const struct bContext *C, + struct PointerRNA *ptr, + struct PropertyRNA *prop, + const char *edit_text, + StringPropertySearchVisitFunc visit_fn, + void *visit_user_data); + typedef int (*EnumPropertyGetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop); typedef void (*EnumPropertySetFunc)(struct PointerRNA *ptr, struct PropertyRNA *prop, int value); /* same as PropEnumItemFunc */ |