light/modules/ui/public/system.hpp
light7734 63cb6dfe92
Some checks are pending
continuous-integration/drone/push Build is running
wip: convert from include style to module import style :D
2025-11-04 18:50:59 +03:30

43 lines
774 B
C++

#pragma once
#include <app/system.hpp>
#include <ecs/registry.hpp>
#include <input/components.hpp>
#include <input/system.hpp>
#include <memory/reference.hpp>
namespace lt::ui {
struct ButtonComponent
{
std::function<void()> on_activate;
std::function<void(bool)> on_hover;
};
struct TransformComponent
{
float x, y;
float w, h;
};
class System: public app::ISystem
{
public:
System(memory::Ref<ecs::Registry> registry): m_registry(std::move(registry))
{
m_registry->each<ButtonComponent, TransformComponent>(
[](auto id, auto &button, auto &transform) {
// trigger `button`'s callbacksbased on input's state...
}
);
}
private:
memory::Ref<ecs::Registry> m_registry;
input::InputAction button_press_action;
};
} // namespace lt::ui