Squashed 'deps/nostalgia/' changes from 312097a7..8419b137

8419b137 [turbine,studio] Fix some popup window resize weirdness, cleanup some function names
ed1160ec [nostalgia] Update release notes
1e217780 [nostalgia/gfx/studio/tilesheet] Ensure config file has a Claw header
78379f58 [studio] Add ability to remember recent projects in config
4322f720 [keel] Fix ox::Result<DstType> convert(Context &ctx, ox::BufferView const&src)
26f1a605 [ox/std] Make Vector::remove take a MaybeView_t
c4c1d477 [keel] Cleanup ox::Error(0) instance
fab012d3 [ox] Cleanup all ox::Error(0) instances

git-subtree-dir: deps/nostalgia
git-subtree-split: 8419b137e5dec1dabc15a0d34c7ce729970c3b7f
This commit is contained in:
2025-05-24 01:44:07 -05:00
parent e90dd88747
commit 08236fc790
39 changed files with 388 additions and 202 deletions

View File

@@ -49,6 +49,19 @@ ox::Error setWindowBounds(Context &ctx, ox::Bounds const&bnds) noexcept;
* @param ctx - Context
* @param ms - milliseconds
*/
void setRefreshWithin(Context &ctx, int ms) noexcept;
void requireRefreshWithin(Context &ctx, int ms) noexcept;
/**
* Stimulates screen to draw for a period of a short period of
* time (168 ms on GLFW implementation).
* @param ctx - Context
*/
void requireRefresh(Context &ctx) noexcept;
/**
* Stimulates screen to draw for a specified period of time.
* @param ctx - Context
*/
void requireRefreshFor(Context &ctx, int ms) noexcept;
}

View File

@@ -155,6 +155,10 @@ static ox::Result<IconData> toGlfwImgPixels(ox::SpanView<uint8_t> const &iconPng
return out;
}
static void setMandatoryRefreshPeriod(Context &ctx, TimeMs const newVal) {
ctx.mandatoryRefreshPeriodEnd = ox::max(ctx.mandatoryRefreshPeriodEnd, newVal);
}
ox::Error setWindowIcon(Context &ctx, ox::SpanView<ox::SpanView<uint8_t>> const &iconPngs) noexcept {
if constexpr(ox::defines::OS != ox::OS::Darwin) {
ox::Vector<IconData, 8> src;
@@ -216,10 +220,19 @@ ox::Error setWindowBounds(Context &ctx, ox::Bounds const&bnds) noexcept {
return {};
}
void setRefreshWithin(Context &ctx, int ms) noexcept {
void requireRefreshWithin(Context &ctx, int const ms) noexcept {
ctx.refreshWithinMs = ox::min(ms, ctx.refreshWithinMs);
}
void requireRefresh(Context &ctx) noexcept {
setMandatoryRefreshPeriod(ctx, ticksMs(ctx) + config::MandatoryRefreshPeriod);
}
void requireRefreshFor(Context &ctx, int ms) noexcept {
ms = ox::max(0, ms);
setMandatoryRefreshPeriod(ctx, ticksMs(ctx) + static_cast<TimeMs>(ms));
}
static void draw(Context &ctx) noexcept {
// draw start
#if TURBINE_USE_IMGUI
@@ -288,12 +301,12 @@ static void handleGlfwCursorPosEvent(GLFWwindow*, double, double) noexcept {
static void handleGlfwMouseButtonEvent(GLFWwindow *window, int, int, int) noexcept {
auto &ctx = *static_cast<Context*>(glfwGetWindowUserPointer(window));
ctx.mandatoryRefreshPeriodEnd = ticksMs(ctx) + config::MandatoryRefreshPeriod;
setMandatoryRefreshPeriod(ctx, ticksMs(ctx) + config::MandatoryRefreshPeriod);
}
static void handleGlfwKeyEvent(GLFWwindow *window, int const key, int, int const action, int) noexcept {
auto &ctx = *static_cast<Context*>(glfwGetWindowUserPointer(window));
ctx.mandatoryRefreshPeriodEnd = ticksMs(ctx) + config::MandatoryRefreshPeriod;
setMandatoryRefreshPeriod(ctx, ticksMs(ctx) + config::MandatoryRefreshPeriod);
if (action == GLFW_PRESS) {
handleKeyPress(ctx, key, true);
} else if (action == GLFW_RELEASE) {
@@ -303,7 +316,7 @@ static void handleGlfwKeyEvent(GLFWwindow *window, int const key, int, int const
static void handleGlfwWindowCloseEvent(GLFWwindow *window) noexcept {
auto &ctx = *static_cast<Context*>(glfwGetWindowUserPointer(window));
ctx.mandatoryRefreshPeriodEnd = ticksMs(ctx) + config::MandatoryRefreshPeriod;
setMandatoryRefreshPeriod(ctx, ticksMs(ctx) + config::MandatoryRefreshPeriod);
ctx.running = ctx.shutdownHandler ? !ctx.shutdownHandler(ctx) : false;
glfwSetWindowShouldClose(window, !ctx.running);
glfwPostEmptyEvent();
@@ -316,7 +329,7 @@ ox::Result<ox::UPtr<Context>> init(
using namespace std::chrono;
ctx->startTime = static_cast<TimeMs>(
duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count());
ctx->mandatoryRefreshPeriodEnd = ticksMs(*ctx) + config::MandatoryRefreshPeriod;
setMandatoryRefreshPeriod(*ctx, ticksMs(*ctx) + config::MandatoryRefreshPeriod);
// init GLFW context
glfwInit();
glfwSetErrorCallback(handleGlfwError);