Zachary Hall
8fdf30878b
Some checks failed
Build / build-gentoo (push) Successful in 1m22s
Build / download-system-deps (push) Successful in 1m37s
Build / get-source-code (push) Successful in 4m30s
Build / build-appimage (push) Successful in 1m15s
Build / build-android (push) Failing after 4m34s
Build / build-windows (push) Failing after 4m33s
32 lines
866 B
C
32 lines
866 B
C
#pragma once
|
|
#include <Bitmap.h>
|
|
#include <Rect.h>
|
|
#include <Application.h>
|
|
#include <IconUtils.h>
|
|
#include <SupportDefs.h>
|
|
#include <TypeConstants.h>
|
|
#include <Resources.h>
|
|
inline BBitmap *load_icon(int32 id, BRect rect = BRect(0, 0, 16, 16)) {
|
|
const void *data = NULL;
|
|
size_t size = 0;
|
|
data = BApplication::AppResources()->LoadResource(B_VECTOR_ICON_TYPE, id, &size);
|
|
if (data != NULL) {
|
|
BBitmap *icon = new BBitmap(rect, B_RGBA32);
|
|
if (icon->InitCheck() == B_OK && BIconUtils::GetVectorIcon((const uint8 *)data, size, icon) == B_OK) {
|
|
return icon;
|
|
} else {
|
|
delete icon;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
inline BBitmap *make_empty_icon() {
|
|
return new BBitmap(BRect(0, 0, 0, 0), B_RGBA32);
|
|
}
|
|
inline BBitmap *get_empty_icon() {
|
|
static BBitmap *empty_icon = nullptr;
|
|
if (empty_icon == nullptr) {
|
|
empty_icon = make_empty_icon();
|
|
}
|
|
return empty_icon;
|
|
}
|