Files
ReJUI/include/JUI/Mixins/Resizable.hpp

35 lines
992 B
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 Resizable.hpp
/// @desc Resizable Mixin Helper class
/// @edit 2024-10-11
#pragma once
#include <Event.h>
#include <J3ML/LinearAlgebra/Vector2.hpp>
namespace JUI
{
/// A mixin helper class that enables a widget to be resized by the mouse.
class Resizable {
public:
Event<> OnDragBegan;
Event<> OnDragEnded;
[[nodiscard]] bool Resizing() const;
virtual void SetResize(bool b);
virtual void StartResizing(const Vector2& point);
virtual void StopResizing();
virtual void Update(float delta);
protected:
bool resizing = false;
Vector2 initial_resize_offset = {0, 0};
};
}