Implement Tween class interface.

This commit is contained in:
2025-02-08 15:35:01 -05:00
parent 97edc67fad
commit 2aaba5c1f7
4 changed files with 43 additions and 22 deletions

View File

@@ -20,31 +20,12 @@
#include <Color4.hpp>
#include <JGL/JGL.h>
#include <ReWindow/types/Key.h>
#include <JUI/Tween.hpp>
#include <JUI/JUI.hpp>
using namespace JGL;
namespace JUI
{
class Tween
{
public:
std::function<void(float)> tick;
float lifetime = 5;
float progress = 0;
};
/// Support Lerp/Tween of the following types:
/// int, float, UDim, UDim2, Color4, Vector2,
/// An enumeration for mouse buttons, used by JUI to decouple from external systems.
/// Some boilerplate is required in order to get input mechanisms up and running. See the demo files for reference.
enum class MouseButton {
Left = 1,
Middle = 2,
Right = 3
};
namespace JUI {
using namespace J3ML::Math;
using namespace J3ML::LinearAlgebra;

View File

@@ -5,4 +5,12 @@
namespace JUI
{
extern jlog::GenericLogger UILogs;
/// An enumeration for mouse buttons, used by JUI to decouple from external systems.
/// Some boilerplate is required in order to get input mechanisms up and running. See the demo files for reference.
enum class MouseButton {
Left = 1,
Middle = 2,
Right = 3
};
}

25
include/JUI/Tween.hpp Normal file
View File

@@ -0,0 +1,25 @@
#include <functional>
#pragma once
namespace JUI
{
/// A class that represents an animation-in-action.
class Tween {
public:
std::function<void(float)> tick;
float lifetime = 5;
float progress = 0;
bool alive = true;
bool paused = false;
bool completed = false;
void Pause() { paused = true; }
void Resume() { paused = false; }
bool Paused() const { return paused; }
bool Completed() const { return completed; }
};
}

7
src/JUI/Tween.cpp Normal file
View File

@@ -0,0 +1,7 @@
#include <JUI/Tween.hpp>
namespace JUI
{
}