[turbine,studio,nostalgia/studio] Add support for window icon scaling, expand icons sizes for Nostalgia Studio
Some checks are pending
Build / build (push) Waiting to run
Some checks are pending
Build / build (push) Waiting to run
This commit is contained in:
@ -26,7 +26,7 @@ void removeDrawer(Context &ctx, Drawer *cd) noexcept;
|
||||
|
||||
ox::Error initGfx(Context &ctx) noexcept;
|
||||
|
||||
ox::Error setWindowIcon(Context &ctx, ox::SpanView<uint8_t> const &iconPng) noexcept;
|
||||
ox::Error setWindowIcon(Context &ctx, ox::SpanView<ox::SpanView<uint8_t>> const &iconPngs) noexcept;
|
||||
|
||||
void setWindowTitle(Context &ctx, ox::StringViewCR title) noexcept;
|
||||
|
||||
|
@ -238,7 +238,7 @@ struct IconData {
|
||||
static ox::Result<IconData> toGlfwImgPixels(ox::SpanView<uint8_t> const &iconPng) noexcept {
|
||||
ox::Result<IconData> out;
|
||||
unsigned w{}, h{};
|
||||
if (lodepng::decode(out.value.pixels, w, h, iconPng.data(), LodePNGColorType::LCT_RGBA)) {
|
||||
if (lodepng::decode(out.value.pixels, w, h, iconPng.data(), iconPng.size())) {
|
||||
return ox::Error{1, "unable to decode window icon PNG data"};
|
||||
}
|
||||
out.value.w = static_cast<int>(w);
|
||||
@ -246,14 +246,19 @@ static ox::Result<IconData> toGlfwImgPixels(ox::SpanView<uint8_t> const &iconPng
|
||||
return out;
|
||||
}
|
||||
|
||||
ox::Error setWindowIcon(Context &ctx, ox::SpanView<uint8_t> const &iconPng) noexcept {
|
||||
OX_REQUIRE_M(icon, toGlfwImgPixels(iconPng));
|
||||
GLFWimage const img {
|
||||
.width = icon.w,
|
||||
.height = icon.h,
|
||||
.pixels = icon.pixels.data(),
|
||||
};
|
||||
glfwSetWindowIcon(ctx.window, 1, &img);
|
||||
ox::Error setWindowIcon(Context &ctx, ox::SpanView<ox::SpanView<uint8_t>> const &iconPngs) noexcept {
|
||||
ox::Vector<IconData, 8> src;
|
||||
ox::Vector<GLFWimage, 8> imgs;
|
||||
for (auto const &iconPng : iconPngs) {
|
||||
OX_RETURN_ERROR(toGlfwImgPixels(iconPng).moveTo(src.emplace_back()));
|
||||
auto &icon = *src.back().unwrap();
|
||||
imgs.emplace_back(GLFWimage{
|
||||
.width = icon.w,
|
||||
.height = icon.h,
|
||||
.pixels = icon.pixels.data(),
|
||||
});
|
||||
}
|
||||
glfwSetWindowIcon(ctx.window, imgs.size(), imgs.data());
|
||||
return {};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user