Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2019-11-25 21:41:30 +0300
committerJulian Eisel <eiseljulian@gmail.com>2019-11-25 21:50:34 +0300
commit5bcb0c9935033d9d9983838bd4f5ed226627c2e9 (patch)
tree4923d38f4ba23209dc07eab80562dd0bad59c0d5 /source/blender/makesrna/intern/rna_ui_api.c
parent03cdfc2ff6df61a247b90c4ad8bb1b26034b4505 (diff)
UI: Allow label for Template-ID (respecting property split layout)
Adds a `text` parameter to `bpy.types.uiLayout.template_ID()` which causes a label to be added, as usual. Adding the label also makes the template respect the `bpy.types.uiLayout.use_property_split` option. Also fixes wrong layout being used in the template-ID, although I think that didn't cause issues in practice. Sergey requested this for usage in the Movie Clip Editor.
Diffstat (limited to 'source/blender/makesrna/intern/rna_ui_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index c734720fdcd..527df695f5b 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -435,6 +435,32 @@ static void rna_uiItemPopoverPanelFromGroup(uiLayout *layout,
uiItemPopoverPanelFromGroup(layout, C, space_id, region_id, context, category);
}
+static void rna_uiTemplateID(uiLayout *layout,
+ bContext *C,
+ PointerRNA *ptr,
+ const char *propname,
+ const char *newop,
+ const char *openop,
+ const char *unlinkop,
+ int filter,
+ const bool live_icon,
+ const char *name,
+ const char *text_ctxt,
+ bool translate)
+{
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
+
+ if (!prop) {
+ RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
+ return;
+ }
+
+ /* Get translated name (label). */
+ name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
+
+ uiTemplateID(layout, C, ptr, propname, newop, openop, unlinkop, filter, live_icon, name);
+}
+
static void rna_uiTemplateAnyID(uiLayout *layout,
PointerRNA *ptr,
const char *propname,
@@ -1014,7 +1040,7 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Inserts common Space header UI (editor type selector)");
- func = RNA_def_function(srna, "template_ID", "uiTemplateID");
+ func = RNA_def_function(srna, "template_ID", "rna_uiTemplateID");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
api_ui_item_rna_common(func);
RNA_def_string(func, "new", NULL, 0, "", "Operator identifier to create a new ID block");
@@ -1028,6 +1054,7 @@ void RNA_api_ui_layout(StructRNA *srna)
"",
"Optionally limit the items which can be selected");
RNA_def_boolean(func, "live_icon", false, "", "Show preview instead of fixed icon");
+ api_ui_item_common_text(func);
func = RNA_def_function(srna, "template_ID_preview", "uiTemplateIDPreview");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);