looper/backends/ui/haiku/utils.h

34 lines
904 B
C
Raw Normal View History

2024-11-12 14:53:44 -08:00
#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;
}
2024-11-21 10:22:34 -08:00
#define CLASS(name) class Haiku##name