[Bf-blender-cvs] [5d898d0bfba] temp-asset-template-extra-options: Support drawing preview tiles without text
Julian Eisel
noreply at git.blender.org
Mon Sep 13 19:04:56 CEST 2021
Commit: 5d898d0bfbadf774fbc842f5686d3740b1cadf22
Author: Julian Eisel
Date: Mon Sep 13 19:04:30 2021 +0200
Branches: temp-asset-template-extra-options
https://developer.blender.org/rB5d898d0bfbadf774fbc842f5686d3740b1cadf22
Support drawing preview tiles without text
===================================================================
M 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]);
More information about the Bf-blender-cvs
mailing list