diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-05-12 02:42:42 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-05-12 02:47:55 +0300 |
commit | c20c203b82260c06888c2a535c08ec383923ee8a (patch) | |
tree | bc6dba9408a4c37d2105c9a91f4dd5d29f077424 /source/blender/makesrna/intern/rna_ui_api.c | |
parent | c8ab7d46566c4a65c6176cd2ebe27778512f7fef (diff) |
UI: Add template_search (version of template_ID for non-IDs)
Adds a version of template_ID that can be used for non-ID properties.
The property to search for and the collection to search in has to be
passed to it.
Like template_ID it also takes arguments to define a 'new' and 'unlink'
operator. They will be displayed as icon-only buttons then.
Also added a version that can display preview thumbnails.
Had to do some additional changes to make text-buttons support
displaying/modifying empty RNA properties.
This will be needed for workspaces, see D2451.
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D2666
Diffstat (limited to 'source/blender/makesrna/intern/rna_ui_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_ui_api.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 6ef4bc6a371..abad70a46d2 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -671,7 +671,31 @@ void RNA_api_ui_layout(StructRNA *srna) "Identifier of property in data giving the type of the ID-blocks to use"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); api_ui_item_common_text(func); - + + func = RNA_def_function(srna, "template_search", "uiTemplateSearch"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + api_ui_item_rna_common(func); + parm = RNA_def_pointer(func, "search_data", "AnyType", "", "Data from which to take collection to search in"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + parm = RNA_def_string(func, "search_property", NULL, 0, "", "Identifier of search collection property"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_string(func, "new", NULL, 0, "", "Operator identifier to create a new item for the collection"); + RNA_def_string(func, "unlink", NULL, 0, "", "Operator identifier to unlink or delete the active " + "item from the collection"); + + func = RNA_def_function(srna, "template_search_preview", "uiTemplateSearchPreview"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + api_ui_item_rna_common(func); + parm = RNA_def_pointer(func, "search_data", "AnyType", "", "Data from which to take collection to search in"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + parm = RNA_def_string(func, "search_property", NULL, 0, "", "Identifier of search collection property"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_string(func, "new", NULL, 0, "", "Operator identifier to create a new item for the collection"); + RNA_def_string(func, "unlink", NULL, 0, "", "Operator identifier to unlink or delete the active " + "item from the collection"); + RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX); + RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX); + func = RNA_def_function(srna, "template_path_builder", "rna_uiTemplatePathBuilder"); parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property"); RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); |