Cleanup: Explicitly pass icon size to generation function, not just bool
* This way you don't have to look up the function declaration to know what the boolean value means. * You can call the function in a loop over the available sizes and pass the index as size. * Makes it easier to add a new size in future if needed.
This commit is contained in:
parent
057a8afb87
commit
0330b0552b
|
@ -45,7 +45,7 @@ bool ED_asset_mark_id(const bContext *C, ID *id)
|
|||
|
||||
id->asset_data = BKE_asset_metadata_create();
|
||||
|
||||
UI_icon_render_id(C, NULL, id, true, true);
|
||||
UI_icon_render_id(C, NULL, id, ICON_SIZE_PREVIEW, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ bool UI_icon_get_theme_color(int icon_id, unsigned char color[4]);
|
|||
void UI_icon_render_id(const struct bContext *C,
|
||||
struct Scene *scene,
|
||||
struct ID *id,
|
||||
const bool big,
|
||||
const enum eIconSizes size,
|
||||
const bool use_job);
|
||||
int UI_icon_preview_to_render_size(enum eIconSizes size);
|
||||
|
||||
|
|
|
@ -1955,7 +1955,8 @@ static void ui_id_preview_image_render_size(
|
|||
/**
|
||||
* Note that if an ID doesn't support jobs for preview creation, \a use_job will be ignored.
|
||||
*/
|
||||
void UI_icon_render_id(const bContext *C, Scene *scene, ID *id, const bool big, const bool use_job)
|
||||
void UI_icon_render_id(
|
||||
const bContext *C, Scene *scene, ID *id, const enum eIconSizes size, const bool use_job)
|
||||
{
|
||||
PreviewImage *pi = BKE_previewimg_id_ensure(id);
|
||||
|
||||
|
@ -1963,14 +1964,7 @@ void UI_icon_render_id(const bContext *C, Scene *scene, ID *id, const bool big,
|
|||
return;
|
||||
}
|
||||
|
||||
if (big) {
|
||||
/* bigger preview size */
|
||||
ui_id_preview_image_render_size(C, scene, id, pi, ICON_SIZE_PREVIEW, use_job);
|
||||
}
|
||||
else {
|
||||
/* icon size */
|
||||
ui_id_preview_image_render_size(C, scene, id, pi, ICON_SIZE_ICON, use_job);
|
||||
}
|
||||
ui_id_preview_image_render_size(C, scene, id, pi, size, use_job);
|
||||
}
|
||||
|
||||
static void ui_id_icon_render(const bContext *C, ID *id, bool use_jobs)
|
||||
|
@ -2170,7 +2164,7 @@ int ui_id_icon_get(const bContext *C, ID *id, const bool big)
|
|||
case ID_LA: /* fall through */
|
||||
iconid = BKE_icon_id_ensure(id);
|
||||
/* checks if not exists, or changed */
|
||||
UI_icon_render_id(C, NULL, id, big, true);
|
||||
UI_icon_render_id(C, NULL, id, big ? ICON_SIZE_PREVIEW : ICON_SIZE_ICON, true);
|
||||
break;
|
||||
case ID_SCR:
|
||||
iconid = ui_id_screen_get_icon(C, id);
|
||||
|
|
|
@ -131,7 +131,7 @@ static int lib_id_generate_preview_exec(bContext *C, wmOperator *UNUSED(op))
|
|||
if (preview) {
|
||||
BKE_previewimg_clear(preview);
|
||||
}
|
||||
UI_icon_render_id(C, NULL, id, true, true);
|
||||
UI_icon_render_id(C, NULL, id, ICON_SIZE_PREVIEW, true);
|
||||
|
||||
WM_event_add_notifier(C, NC_ASSET, NULL);
|
||||
|
||||
|
|
|
@ -3314,8 +3314,8 @@ static void previews_id_ensure(bContext *C, Scene *scene, ID *id)
|
|||
/* Only preview non-library datablocks, lib ones do not pertain to this .blend file!
|
||||
* Same goes for ID with no user. */
|
||||
if (!ID_IS_LINKED(id) && (id->us != 0)) {
|
||||
UI_icon_render_id(C, scene, id, false, false);
|
||||
UI_icon_render_id(C, scene, id, true, false);
|
||||
UI_icon_render_id(C, scene, id, ICON_SIZE_ICON, false);
|
||||
UI_icon_render_id(C, scene, id, ICON_SIZE_PREVIEW, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue