UI: Improved Preview Feedback and Reduced Flickering #108486

Merged
Julian Eisel merged 5 commits from Harley/blender:BrowserWait into main 2023-06-19 12:24:50 +02:00
2 changed files with 11 additions and 5 deletions
Showing only changes of commit 5e7b8e63e1 - Show all commits

View File

@ -1627,8 +1627,15 @@ static void filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry
/* If we know this is an external ID without a preview, skip loading the preview. Can save quite
* some time in heavy files, because otherwise for each missing preview and for each preview
* reload, we'd reopen the .blend to look for the preview. */
if (entry->typeflag & FILE_TYPE_BLENDERLIB &&
((entry->flags & FILE_ENTRY_BLENDERLIB_NO_PREVIEW) || (entry->typeflag & FILE_TYPE_DIR)))
if ((entry->typeflag & FILE_TYPE_BLENDERLIB) &&
(entry->flags & FILE_ENTRY_BLENDERLIB_NO_PREVIEW))
Harley marked this conversation as resolved Outdated

This makes the if statement unnecessarily complex and the comment above has no relation to this. Try to make if statements check one coherent condition, not multiple ones. So better make this a separate if statement with its own return.

This makes the `if` statement unnecessarily complex and the comment above has no relation to this. Try to make `if` statements check one coherent condition, not multiple ones. So better make this a separate `if` statement with its own `return`.
{
return;
}
/* External ID that is also a directory is never previewed. */
if ((entry->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_DIR)) ==
(FILE_TYPE_BLENDERLIB | FILE_TYPE_DIR))
{
return;
}
@ -2605,7 +2612,6 @@ bool filelist_cache_previews_update(FileList *filelist)
/* Move ownership over icon. */
entry->preview_icon_id = preview->icon_id;
preview->icon_id = 0;
changed = true;
}
else {
/* We want to avoid re-processing this entry continuously!
@ -2614,6 +2620,7 @@ bool filelist_cache_previews_update(FileList *filelist)
entry->flags |= FILE_ENTRY_INVALID_PREVIEW;
}
entry->flags &= ~FILE_ENTRY_PREVIEW_LOADING;
changed = true;
}
else {
BKE_icon_delete(preview->icon_id);

View File

@ -358,8 +358,7 @@ static void file_listener(const wmSpaceTypeListenerParams *listener_params)
ED_area_tag_refresh(area);
break;
case ND_SPACE_FILE_PREVIEW:
if (sfile->files) {
filelist_cache_previews_update(sfile->files);
if (sfile->files && filelist_cache_previews_update(sfile->files)) {
ED_area_tag_refresh(area);
Harley marked this conversation as resolved Outdated

I would leave this where it is and simply set the changed bool in filelist_cache_previews_update() to true when removing the FILE_ENTRY_PREVIEW_LOADING flag. This can avoid a bunch of unnecessary redraws/refreshes.

I would leave this where it is and simply set the `changed` bool in `filelist_cache_previews_update()` to true when removing the `FILE_ENTRY_PREVIEW_LOADING` flag. This can avoid a bunch of unnecessary redraws/refreshes.
}
break;