From 3ff60bcad8cccd6c2f82ea44527f4e6ef619f0be Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Mon, 13 Sep 2021 18:40:21 +0200 Subject: Asset Template: Extra UI options This allow users to show/hide: * Library name / refresh. * Assets names. * Filter. To set them in Python use: display_options={'NO_NAMES', 'NO_FILTER', 'NO_LIBRARY'} With contributions by Julian Eisel. Differential Revision: https://developer.blender.org/D12476 --- source/blender/editors/interface/interface_widgets.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/interface/interface_widgets.c') diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index a2b86ccd947..0dc7c2d3f9a 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -5443,13 +5443,20 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle, rcti trect = *rect; const float text_size = UI_UNIT_Y; float font_dims[2] = {0.0f, 0.0f}; + const bool has_text = name && name[0]; - /* draw icon in rect above the space reserved for the label */ - rect->ymin += text_size; + if (has_text) { + /* draw icon in rect above the space reserved for the label */ + rect->ymin += text_size; + } GPU_blend(GPU_BLEND_ALPHA); widget_draw_preview(iconid, 1.0f, rect); GPU_blend(GPU_BLEND_NONE); + if (!has_text) { + return; + } + BLF_width_and_height( fstyle->uifont_id, name, BLF_DRAW_STR_DUMMY_MAX, &font_dims[0], &font_dims[1]); -- cgit v1.2.3