diff --git a/source/blender/editors/include/UI_interface_icons.hh b/source/blender/editors/include/UI_interface_icons.hh index 130c767ab45..299cb3a455b 100644 --- a/source/blender/editors/include/UI_interface_icons.hh +++ b/source/blender/editors/include/UI_interface_icons.hh @@ -54,7 +54,7 @@ enum eAlertIcon { ALERT_ICON_MAX, }; -ImBuf *UI_icon_alert_imbuf_get(eAlertIcon icon); +ImBuf *UI_icon_alert_imbuf_get(eAlertIcon icon, float size); /** * Resizable Icons for Blender diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 5fcc0f58013..ccb6c92f245 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -4785,10 +4785,10 @@ uiBut *uiDefButImage( uiBut *uiDefButAlert(uiBlock *block, int icon, int x, int y, short width, short height) { - ImBuf *ibuf = UI_icon_alert_imbuf_get((eAlertIcon)icon); + ImBuf *ibuf = UI_icon_alert_imbuf_get((eAlertIcon)icon, float(width)); if (ibuf) { bTheme *btheme = UI_GetTheme(); - return uiDefButImage(block, ibuf, x, y, width, height, btheme->tui.wcol_menu_back.text); + return uiDefButImage(block, ibuf, x, y, ibuf->x, ibuf->y, btheme->tui.wcol_menu_back.text); } return nullptr; } diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index b4d2a6266d8..cbe93826edc 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -2612,25 +2612,41 @@ void UI_icon_text_overlay_init_from_count(IconTextOverlay *text_overlay, /* ********** Alert Icons ********** */ -ImBuf *UI_icon_alert_imbuf_get(eAlertIcon icon) +ImBuf *UI_icon_alert_imbuf_get(eAlertIcon icon, float size) { #ifdef WITH_HEADLESS - UNUSED_VARS(icon); + UNUSED_VARS(icon, size); return nullptr; #else - if (icon == ALERT_ICON_NONE) { + + int icon_id = ICON_NONE; + switch (icon) { + case ALERT_ICON_WARNING: + icon_id = ICON_WARNING_LARGE; + break; + case ALERT_ICON_QUESTION: + icon_id = ICON_QUESTION_LARGE; + break; + case ALERT_ICON_ERROR: + icon_id = ICON_CANCEL_LARGE; + break; + case ALERT_ICON_INFO: + icon_id = ICON_INFO_LARGE; + break; + } + + if (icon_id == ICON_NONE) { return nullptr; } - const int ALERT_IMG_SIZE = 256; - icon = eAlertIcon(std::min(icon, ALERT_ICON_MAX - 1)); - const int left = icon * ALERT_IMG_SIZE; - const rcti crop = {left, left + ALERT_IMG_SIZE - 1, 0, ALERT_IMG_SIZE - 1}; - ImBuf *ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_alert_icons_png, - datatoc_alert_icons_png_size, - IB_rect, - nullptr, - "alert_icon"); - IMB_rect_crop(ibuf, &crop); + + int width; + int height; + blender::Array bitmap = BLF_svg_icon_bitmap(icon_id, size, &width, &height); + if (bitmap.is_empty()) { + return nullptr; + } + ImBuf *ibuf = IMB_allocFromBuffer(bitmap.data(), nullptr, width, height, 4); + IMB_flipy(ibuf); IMB_premultiply_alpha(ibuf); return ibuf; #endif