Squashed 'deps/nostalgia/' changes from e78c4050..857587c1

857587c1 [studio] Cleanup
eb3d53c9 [studio] Cleanup
14d58f3f [studio] Fix Navigation shortcuts for non-Mac systems
5f239790 [studio,nostalgia/gfx/studio/tilesheet] Fix copy/cut/paste enablement when there is no selection
58e0ecb4 [studio] Make FilePickerPopup accept on double click of a file
8838bf42 [studio] Fix to properly copy file that has the same name as deleted file
bddc544d [nostalgia] Update release notes
a9437191 [studio,turbine] Add support for mouse back/forward buttons
9d8da7cc [ox/std] Make strToInt return error for empty string
394b568e [studio] Add Back/Forward navigation
78e9f70d [nostalgia] Update release notes
12e5623f [ox/logconn] Add exception handling for logger thread
cfdfb0a8 [studio] Fix file deletion to close file even if not active
56e66530 [studio] Cleanup
7415ce4b [nostalgia/gfx/studio] Cleanup
05f42150 [olympic] Add new loc command to Makefile
8ea2bc69 [nostalgia] Update release notes
c7809241 [studio] Add [DEBUG] tag to About in debug builds
8c538560 [nostalgia/gfx/studio/palette] Make RGB key shortcuts work when color channel inputs are focused
c3e75bdb [nostalgia/gfx/studio/tilesheet] Cleanup

git-subtree-dir: deps/nostalgia
git-subtree-split: 857587c18b4695eacd31457e3c30b4971b4e46e8
This commit is contained in:
2025-06-21 08:48:13 -05:00
parent 7688c05bac
commit 7371df4295
38 changed files with 528 additions and 216 deletions

View File

@@ -79,11 +79,14 @@ enum Key {
};
using KeyEventHandler = void(*)(Context&, Key, bool);
using MouseButtonEventHandler = void(*)(Context&, int btn, bool);
void setKeyEventHandler(Context &ctx, KeyEventHandler h) noexcept;
void setMouseButtonEventHandler(Context &ctx, MouseButtonEventHandler h) noexcept;
[[nodiscard]]
KeyEventHandler keyEventHandler(Context &ctx) noexcept;
KeyEventHandler keyEventHandler(Context const &ctx) noexcept;
[[nodiscard]]
bool buttonDown(Context const&ctx, Key) noexcept;

View File

@@ -133,7 +133,9 @@ void setKeyEventHandler(Context &ctx, KeyEventHandler h) noexcept {
ctx.keyEventHandler = h;
}
KeyEventHandler keyEventHandler(Context &ctx) noexcept {
void setMouseButtonEventHandler(Context&, MouseButtonEventHandler) noexcept {}
KeyEventHandler keyEventHandler(Context const &ctx) noexcept {
return ctx.keyEventHandler;
}

View File

@@ -16,6 +16,7 @@ class Context {
UpdateHandler updateHandler = [](Context&) -> int {return -1;};
keel::Context keelCtx;
KeyEventHandler keyEventHandler = nullptr;
MouseButtonEventHandler mouseButtonEventHandler = nullptr;
ox::AnyPtr applicationData;
// GLFW impl data ////////////////////////////////////////////////////////

View File

@@ -299,9 +299,14 @@ static void handleKeyPress(Context &ctx, int const key, bool const down) noexcep
static void handleGlfwCursorPosEvent(GLFWwindow*, double, double) noexcept {
}
static void handleGlfwMouseButtonEvent(GLFWwindow *window, int, int, int) noexcept {
static void handleGlfwMouseButtonEvent(
GLFWwindow *window,
int const btn,
int const action,
int) noexcept {
auto &ctx = *static_cast<Context*>(glfwGetWindowUserPointer(window));
setMandatoryRefreshPeriod(ctx, ticksMs(ctx) + config::MandatoryRefreshPeriod);
ctx.mouseButtonEventHandler(ctx, btn, action == 1);
}
static void handleGlfwKeyEvent(GLFWwindow *window, int const key, int, int const action, int) noexcept {
@@ -339,7 +344,8 @@ ox::Result<ox::UPtr<Context>> init(
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
constexpr auto Scale = 5;
ctx->window = glfwCreateWindow(240 * Scale, 160 * Scale, ctx->keelCtx.appName.c_str(), nullptr, nullptr);
ctx->window = glfwCreateWindow(
240 * Scale, 160 * Scale, ctx->keelCtx.appName.c_str(), nullptr, nullptr);
//ctx.window = glfwCreateWindow(876, 743, ctx.keelCtx.appName.c_str(), nullptr, nullptr);
if (ctx->window == nullptr) {
return ox::Error(1, "Could not open GLFW window");
@@ -402,14 +408,14 @@ ox::Error run(Context &ctx) noexcept {
glfwPollEvents();
auto const ticks = ticksMs(ctx);
if (ctx.wakeupTime <= ticks) {
auto const st = ctx.updateHandler(ctx);
if (st >= 0) {
ctx.wakeupTime = ticks + static_cast<unsigned>(st);
sleepTime = static_cast<uint64_t>(st);
} else {
ctx.wakeupTime = ~uint64_t{0};
sleepTime = ctx.wakeupTime - ticks;
}
auto const st = ctx.updateHandler(ctx);
if (st >= 0) {
ctx.wakeupTime = ticks + static_cast<unsigned>(st);
sleepTime = static_cast<uint64_t>(st);
} else {
ctx.wakeupTime = ~uint64_t{0};
sleepTime = ctx.wakeupTime - ticks;
}
} else {
sleepTime = ctx.wakeupTime - ticks;
}
@@ -447,15 +453,19 @@ void setShutdownHandler(Context &ctx, ShutdownHandler const handler) noexcept {
ctx.shutdownHandler = handler;
}
void setUpdateHandler(Context &ctx, UpdateHandler h) noexcept {
void setUpdateHandler(Context &ctx, UpdateHandler const h) noexcept {
ctx.updateHandler = h;
}
void setKeyEventHandler(Context &ctx, KeyEventHandler h) noexcept {
void setKeyEventHandler(Context &ctx, KeyEventHandler const h) noexcept {
ctx.keyEventHandler = h;
}
KeyEventHandler keyEventHandler(Context &ctx) noexcept {
void setMouseButtonEventHandler(Context &ctx, MouseButtonEventHandler const h) noexcept {
ctx.mouseButtonEventHandler = h;
}
KeyEventHandler keyEventHandler(Context const &ctx) noexcept {
return ctx.keyEventHandler;
}