From aafeb8d9ecf0391e6c19512e2a6e579c66a84e62 Mon Sep 17 00:00:00 2001 From: f0e <7321764+f0e@users.noreply.github.com> Date: Sat, 23 Nov 2024 06:30:23 +1000 Subject: [PATCH] fix: closing on windows, constexpr error --- src/gui/easing.h | 4 ++-- src/gui/gui.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gui/easing.h b/src/gui/easing.h index fdee6df..94a9371 100644 --- a/src/gui/easing.h +++ b/src/gui/easing.h @@ -1,9 +1,9 @@ #pragma once -constexpr inline double ease_out_quart(double x) { +const inline double ease_out_quart(double x) { return 1.f - pow(1.f - x, 4.f); } -constexpr inline double ease_out_expo(double x) { +const inline double ease_out_expo(double x) { return (x == 1) ? 1 : 1 - std::pow(2, -10 * x); } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index eba4e02..ca92a87 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -12,6 +12,8 @@ const int spacing = 4; const int pad_x = 24; const int pad_y = 35; +bool closing = false; + SkFont font; os::EventQueue* event_queue; @@ -80,6 +82,7 @@ bool processEvent(const os::Event& ev) { case os::Event::CloseApp: case os::Event::CloseWindow: + closing = true; return false; case os::Event::ResizeWindow: @@ -119,7 +122,7 @@ void gui::generate_messages_from_os_events() { // https://github.com/aseprite/as } void gui::event_loop() { - while (true) { + while (!closing) { generate_messages_from_os_events(); } } @@ -177,12 +180,9 @@ void gui::redraw_window(os::Window* window) { { // debug - static int x = 0; + static float x = 0; static bool right = true; - if (right) - x++; - else - x--; + x += 500.f * delta_time * (right ? 1 : -1); os::Paint paint; paint.color(gfx::rgba(255, 0, 0, 50)); s->drawRect(gfx::Rect(x, 100, 30, 30), paint);