looper/backends/ui/haiku/utils.h
Zachary Hall da9b7322f2
Some checks failed
Build / get-source-code (push) Blocked by required conditions
Build / build-appimage (push) Blocked by required conditions
Build / build-android (push) Blocked by required conditions
Build / build-windows (push) Blocked by required conditions
Build / build-gentoo (push) Failing after 1m14s
Build / download-system-deps (push) Has been cancelled
Fix combined Haiku/Qt backend build
2024-11-21 10:35:57 -08:00

34 lines
No EOL
904 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;
}
#define CLASS(name) class Haiku##name