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

55 lines
1.5 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 ScrollingRect.hpp
/// @desc Scrolling Rectangle Widget
/// @edit 2024-10-11
#pragma once
#include <J3ML/LinearAlgebra/Vector2.hpp>
#include <JUI/Base/Widget.hpp>
#include "Hoverable.hpp"
namespace JUI {
struct ClickEventArgs {
public:
protected:
private:
};
struct ReleaseEventArgs {
public:
protected:
private:
};
/// A mixin helper class that provides behavior and events for clickable widgets.
class Clickable {
public:
Event<std::optional<ClickEventArgs>> Clicked;
Event<ReleaseEventArgs> Released;
Event<Vector2, MouseButton> OnClickEvent;
Event<Vector2, MouseButton, bool> OnReleaseEvent;
public:
[[nodiscard]] bool IsClicked() const { return clicked; };
void SetClicked(bool manual_click);
public:
virtual void OnClick(const Vector2& MousePos, const MouseButton& MouseButton);;
virtual void OnRelease(const Vector2& MousePos, const MouseButton& MouseButton, bool MouseStillOver);;
void Update(const Vector2& mpos, const MouseButton& btn, bool hovering);
protected:
bool clicked = false;
bool click_debounce = false;
};
}