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
1 changed files with 21 additions and 17 deletions
Showing only changes of commit 705f23eb91 - Show all commits

View File

@ -367,6 +367,7 @@ static void file_draw_preview(const FileDirEntry *file,
bool show_outline = !is_icon &&
(file->typeflag & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_BLENDER));
const bool is_offline = (file->attributes & FILE_ATTR_OFFLINE);
const bool is_loading = file->flags & FILE_ENTRY_PREVIEW_LOADING;
BLI_assert(imb != nullptr);
@ -412,7 +413,7 @@ static void file_draw_preview(const FileDirEntry *file,
UI_GetThemeColor4fv(TH_ICON_FOLDER, document_img_col);
}
else {
UI_GetThemeColor4fv(TH_TEXT, document_img_col);
UI_GetThemeColor4fv(is_loading ? TH_BACK : TH_TEXT, document_img_col);
Harley marked this conversation as resolved Outdated

This seems wrong. It's repurposing document_img_col for when there is no document image, and it's not clear what this has to do with the loading state.

This seems wrong. It's repurposing `document_img_col` for when there is no document image, and it's not clear what this has to do with the loading state.
}
}
else if (file->typeflag & FILE_TYPE_FTFONT) {
@ -428,20 +429,23 @@ static void file_draw_preview(const FileDirEntry *file,
GPU_blend(GPU_BLEND_ALPHA_PREMULT);
}
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_3D_IMAGE_COLOR);
immDrawPixelsTexTiled_scaling(&state,
float(xco),
float(yco),
imb->x,
imb->y,
GPU_RGBA8,
true,
imb->byte_buffer.data,
scale,
scale,
1.0f,
1.0f,
document_img_col);
if (!is_loading) {
/* Don't show outer document image if loading - too flashy. */
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_3D_IMAGE_COLOR);
immDrawPixelsTexTiled_scaling(&state,
float(xco),
float(yco),
imb->x,
imb->y,
GPU_RGBA8,
true,
imb->byte_buffer.data,
scale,
scale,
1.0f,
1.0f,
document_img_col);
}
GPU_blend(GPU_BLEND_ALPHA);
@ -460,7 +464,7 @@ static void file_draw_preview(const FileDirEntry *file,
icon_y = yco + (ey / 2.0f) - (icon_size * ((file->typeflag & FILE_TYPE_DIR) ? 0.78f : 0.75f));
UI_icon_draw_ex(icon_x,
icon_y,
icon,
is_loading ? ICON_TEMP : icon,
icon_aspect / UI_SCALE_FAC,
icon_opacity,
0.0f,
@ -515,7 +519,7 @@ static void file_draw_preview(const FileDirEntry *file,
UI_NO_ICON_OVERLAY_TEXT);
}
}
else if (icon && !is_icon && !(file->typeflag & FILE_TYPE_FTFONT)) {
else if (icon && ((!is_icon && !(file->typeflag & FILE_TYPE_FTFONT)) || is_loading)) {
/* Smaller, fainter icon at bottom-left for preview image thumbnail, but not for fonts. */
float icon_x, icon_y;
const uchar dark[4] = {0, 0, 0, 255};