Squashed 'deps/nostalgia/' changes from ab11b885..3fe62464

3fe62464 [nostalgia/sample_project] Add NS_Logo32
db55fc72 [nostalgia/player] Cleanup
20944508 [studio] Cleanup
889bec04 [nostalgia/gfx/studio/tilesheet] Cleanup
ac1e34d4 [nostalgia] Update release notes
55ed75f4 [nostalgia/gfx/studio/tilesheet] Fix selection clearing to work when clicking outside image
2751872c [nostalgia] Cleanup file-to-cpp output
2a3cd35c [nostalgia] Fix release notes version, add d2025.02.1
b66f459f [nostalgia] Cleanup icon rsrc generation
3910f4e7 [nostalgia] Fix debug and gba-run commands in Makefile
c0e96216 [turbine] Make accessor functions take const ref to Context
f9512d72 [turbine/glfw] Fix implicit conversion
b7f2c169 [nostalgia/studio/gfx] Fix typo
1e5057d6 [nostalgia] Add app icon note to release notes
c6255e32 [nostalgia/studio] Add icon 16 src
02230ef6 [turbine,studio,nostalgia/studio] Add support for window icon scaling, expand icons sizes for Nostalgia Studio
9b6b60e4 [turbine] Cleanup
b9a26ab6 [turbine] Fix GLFWimage member init order
a521887d [studio,turbine] Add support for window icons
5ca7e2f2 [ox/fs] Cleanup
125a235d [ox/fs] Cleanup
91a7129f [nostalgia/gfx/keel] Cleanup
df48a232 [nostalgia/studio] Add icon to Windows executable

git-subtree-dir: deps/nostalgia
git-subtree-split: 3fe62464c3ee45055e8c732840f949cdf373ae2a
This commit is contained in:
2025-04-16 19:48:37 -05:00
parent 6bcd6deb76
commit 09b4a705a9
32 changed files with 3065 additions and 87 deletions

View File

@@ -32,11 +32,15 @@ static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down)
sctx->ui.handleKeyEvent(key, down);
}
[[nodiscard]]
ox::Vector<ox::SpanView<uint8_t>> WindowIcons() noexcept;
static ox::Error runApp(
ox::StringViewCR appName,
ox::StringViewCR projectDataDir,
ox::UPtr<ox::FileSystem> &&fs) noexcept {
OX_REQUIRE_M(ctx, turbine::init(std::move(fs), appName));
oxLogError(turbine::setWindowIcon(*ctx, WindowIcons()));
turbine::setWindowTitle(*ctx, keelCtx(*ctx).appName);
turbine::setKeyEventHandler(*ctx, keyEventHandler);
turbine::setRefreshWithin(*ctx, 0);

View File

@@ -71,12 +71,6 @@ class SelectionTracker {
return m_selectionOngoing;
}
constexpr void startSelection(ox::Point cursor) noexcept {
m_pointA = cursor;
m_pointB = cursor;
m_selectionOngoing = true;
}
/**
*
* @param cursor

View File

@@ -26,20 +26,22 @@ void removeDrawer(Context &ctx, Drawer *cd) noexcept;
ox::Error initGfx(Context &ctx) noexcept;
ox::Error setWindowIcon(Context &ctx, ox::SpanView<ox::SpanView<uint8_t>> const &iconPngs) noexcept;
void setWindowTitle(Context &ctx, ox::StringViewCR title) noexcept;
void focusWindow(Context &ctx) noexcept;
[[nodiscard]]
int getScreenWidth(Context &ctx) noexcept;
int getScreenWidth(Context const &ctx) noexcept;
[[nodiscard]]
int getScreenHeight(Context &ctx) noexcept;
int getScreenHeight(Context const &ctx) noexcept;
[[nodiscard]]
ox::Size getScreenSize(Context &ctx) noexcept;
ox::Size getScreenSize(Context const &ctx) noexcept;
ox::Bounds getWindowBounds(Context &ctx) noexcept;
ox::Bounds getWindowBounds(Context const &ctx) noexcept;
ox::Error setWindowBounds(Context &ctx, ox::Bounds const&bnds) noexcept;

View File

@@ -27,19 +27,19 @@ ox::Error initGfx(Context&) noexcept {
void setWindowTitle(Context&, ox::StringViewCR) noexcept {
}
int getScreenWidth(Context&) noexcept {
int getScreenWidth(Context const&) noexcept {
return 240;
}
int getScreenHeight(Context&) noexcept {
int getScreenHeight(Context const&) noexcept {
return 160;
}
ox::Size getScreenSize(Context&) noexcept {
ox::Size getScreenSize(Context const&) noexcept {
return {240, 160};
}
ox::Bounds getWindowBounds(Context&) noexcept {
ox::Bounds getWindowBounds(Context const&) noexcept {
return {0, 0, 240, 160};
}

View File

@@ -21,4 +21,5 @@ target_link_libraries(
glad
glfw
imgui
lodepng
)

View File

@@ -4,6 +4,7 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <lodepng.h>
#if TURBINE_USE_IMGUI
#include <imgui_impl_glfw.h>
#include <imgui_impl_opengl3.h>
@@ -228,6 +229,39 @@ ox::Error initGfx(Context &ctx) noexcept {
return {};
}
struct IconData {
std::vector<uint8_t> pixels;
int w{}, h{};
};
[[nodiscard]]
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(), iconPng.size())) {
return ox::Error{1, "unable to decode window icon PNG data"};
}
out.value.w = static_cast<int>(w);
out.value.h = static_cast<int>(h);
return out;
}
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, static_cast<int>(imgs.size()), imgs.data());
return {};
}
void setWindowTitle(Context &ctx, ox::StringViewCR title) noexcept {
auto cstr = ox_malloca(title.bytes() + 1, char);
ox::strncpy(cstr.get(), title.data(), title.bytes());
@@ -238,25 +272,25 @@ void focusWindow(Context &ctx) noexcept {
glfwFocusWindow(ctx.window);
}
int getScreenWidth(Context &ctx) noexcept {
int getScreenWidth(Context const &ctx) noexcept {
int w = 0, h = 0;
glfwGetFramebufferSize(ctx.window, &w, &h);
return w;
}
int getScreenHeight(Context &ctx) noexcept {
int getScreenHeight(Context const &ctx) noexcept {
int w = 0, h = 0;
glfwGetFramebufferSize(ctx.window, &w, &h);
return h;
}
ox::Size getScreenSize(Context &ctx) noexcept {
ox::Size getScreenSize(Context const &ctx) noexcept {
int w = 0, h = 0;
glfwGetFramebufferSize(ctx.window, &w, &h);
return {w, h};
}
ox::Bounds getWindowBounds(Context &ctx) noexcept {
ox::Bounds getWindowBounds(Context const &ctx) noexcept {
ox::Bounds bnds;
glfwGetWindowPos(ctx.window, &bnds.x, &bnds.y);
glfwGetWindowSize(ctx.window, &bnds.width, &bnds.height);