From 4faef1e10c9d1177eae6350b4471206e91afaff8 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 2 Apr 2014 12:59:48 +0200 Subject: Add drag-resize to uiTemplatePreview (mat/tex/etc. preview widget). This is done by adding a new button type, GRIP, similar to other numbuttons (scroll, slider, ...), which here controls the preview height. Then, we add a new DNA struct to be able to save that height in Blend files (note I choose not to use Panel struct for this, because we would then have the same limitation we used to have with uiLists, only one preview per panel and no preview outside panel). This implies a change to template_preview UI RNA/py API (each preview needs an ID), but this is backward compatible, as by default datablock type will be used if no ID is given (which means e.g. all material previews with no ID will have same height). Reviewers: brecht Reviewed By: brecht Differential Revision: https://developer.blender.org/D342 --- source/blender/makesrna/intern/rna_ui_api.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/makesrna/intern/rna_ui_api.c') diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 7f9b5eb8850..3cdff730b00 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -683,12 +683,16 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_return(func, parm); func = RNA_def_function(srna, "template_preview", "uiTemplatePreview"); - RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lamps, etc"); + RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lamps or worlds"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); parm = RNA_def_pointer(func, "id", "ID", "", "ID datablock"); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_boolean(func, "show_buttons", true, "", "Show preview buttons?"); RNA_def_pointer(func, "parent", "ID", "", "ID datablock"); RNA_def_pointer(func, "slot", "TextureSlot", "", "Texture slot"); + RNA_def_string(func, "preview_id", NULL, 0, "", + "Identifier of this preview widget, if not set the ID type will be used " + "(i.e. all previews of materials without explicit ID will have the same size...)"); func = RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping"); RNA_def_function_ui_description(func, "Item. A curve mapping widget used for e.g falloff curves for lamps"); -- cgit v1.2.3