78 lines
2.0 KiB
C++
78 lines
2.0 KiB
C++
/// Josh's User Interface Library
|
|
/// A C++20 Library for creating, styling, and rendering of a UI/UX widgets.
|
|
/// Developed and Maintained by Josh O'Leary @ Redacted Software.
|
|
/// Special Thanks to William Tomasine II and Maxine Hayes.
|
|
/// (c) 2024 Redacted Software
|
|
/// This work is dedicated to the public domain.
|
|
|
|
/// @file UDim2.hpp
|
|
/// @desc Universal Dimensions 2D Class
|
|
/// @edit 2024-07-10
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <J3ML/LinearAlgebra.hpp>
|
|
#include <JUI/UDim.hpp>
|
|
|
|
namespace JUI
|
|
{
|
|
using namespace J3ML::LinearAlgebra;
|
|
|
|
/// Funky Coordinate system purpose-built for screen positioning
|
|
/// Contains an X and Y UDim, each containing an integer "Pixels", and fractional "Scale" (0-1) value.
|
|
/// GUI Elements use this type to describe their sizing in relation to their parent.
|
|
/// @see UDim.hpp
|
|
class UDim2
|
|
{
|
|
public: // Constants
|
|
static const UDim2 Center;
|
|
static const UDim2 TopLeft;
|
|
static const UDim2 BottomRight;
|
|
static const UDim2 BottomLeft;
|
|
static const UDim2 TopRight;
|
|
|
|
static const UDim2 TopCenter;
|
|
static const UDim2 LeftCenter;
|
|
static const UDim2 BottomCenter;
|
|
static const UDim2 RightCenter;
|
|
public: // Properties
|
|
UDim X;
|
|
UDim Y;
|
|
public: // Constructors
|
|
UDim2();
|
|
|
|
UDim2(int px, int py, float sx, float sy);
|
|
|
|
UDim2(Vector2 pixels, Vector2 scale);
|
|
|
|
UDim2(UDim x, UDim y);
|
|
|
|
static UDim2 FromPixels(int x, int y);
|
|
|
|
static UDim2 FromScale(float x, float y);
|
|
|
|
UDim2 Lerp(const UDim2& goal, float t);
|
|
|
|
bool Equals(const UDim2& rhs, float epsilon = 1e-3f);
|
|
|
|
public: // Operators
|
|
UDim2 operator +(const UDim2& rhs) const;
|
|
|
|
UDim2 operator -(const UDim2& rhs) const;
|
|
|
|
UDim2 operator *(float rhs) const;
|
|
|
|
UDim2 operator /(float rhs) const;
|
|
|
|
UDim2 &operator=(const UDim2 &) = default;
|
|
public: // Methods
|
|
[[nodiscard]] Vector2 GetScale() const;
|
|
|
|
[[nodiscard]] Vector2 GetPixels() const;
|
|
|
|
protected:
|
|
private:
|
|
};
|
|
|
|
} |