[Bf-blender-cvs] [2f658677c60] ui-asset-view-template: Fix items not showing up if the preview is missing

Julian Eisel noreply at git.blender.org
Thu Mar 4 16:31:19 CET 2021


Commit: 2f658677c6095449e297c80ce50e449e0130bc66
Author: Julian Eisel
Date:   Thu Mar 4 16:29:30 2021 +0100
Branches: ui-asset-view-template
https://developer.blender.org/rB2f658677c6095449e297c80ce50e449e0130bc66

Fix items not showing up if the preview is missing

No reason to skip adding the UI elements just because the preview is missing.
We can still show the text and allow dragging. Also makes it feel more
interactive while the previews load in a background thread.

===================================================================

M	source/blender/editors/interface/interface_template_asset_view.cc

===================================================================

diff --git a/source/blender/editors/interface/interface_template_asset_view.cc b/source/blender/editors/interface/interface_template_asset_view.cc
index 81db25b55bc..27b5aeb902e 100644
--- a/source/blender/editors/interface/interface_template_asset_view.cc
+++ b/source/blender/editors/interface/interface_template_asset_view.cc
@@ -94,28 +94,26 @@ static void asset_view_draw_item(uiList *ui_list,
 
   FileDirEntry *file = (FileDirEntry *)itemptr->data;
   uiBlock *block = uiLayoutGetBlock(layout);
-  if (file->preview_icon_id) {
-    /* TODO ED_fileselect_init_layout(). Share somehow? */
-    float size_x = (96.0f / 20.0f) * UI_UNIT_X;
-    float size_y = (96.0f / 20.0f) * UI_UNIT_Y;
-    uiBut *but = uiDefIconTextBut(block,
-                                  UI_BTYPE_PREVIEW_TILE,
-                                  0,
-                                  file->preview_icon_id,
-                                  file->name,
-                                  0,
-                                  0,
-                                  size_x,
-                                  size_y,
-                                  nullptr,
-                                  0,
-                                  0,
-                                  0,
-                                  0,
-                                  "");
-    ui_def_but_icon(but, file->preview_icon_id, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
-    asset_view_item_but_drag_set(but, list_data, file);
-  }
+  /* TODO ED_fileselect_init_layout(). Share somehow? */
+  float size_x = (96.0f / 20.0f) * UI_UNIT_X;
+  float size_y = (96.0f / 20.0f) * UI_UNIT_Y;
+  uiBut *but = uiDefIconTextBut(block,
+                                UI_BTYPE_PREVIEW_TILE,
+                                0,
+                                file->preview_icon_id,
+                                file->name,
+                                0,
+                                0,
+                                size_x,
+                                size_y,
+                                nullptr,
+                                0,
+                                0,
+                                0,
+                                0,
+                                "");
+  ui_def_but_icon(but, file->preview_icon_id, UI_HAS_ICON | UI_BUT_ICON_PREVIEW);
+  asset_view_item_but_drag_set(but, list_data, file);
 }
 
 static uiListType *UI_UL_asset_view(void)



More information about the Bf-blender-cvs mailing list