23#include "guillaume/systems/mouse_button.hpp"
53 if (!mouseButtonEvent)
56 this->getLogger().info()
57 <<
"MouseButton::update: event received: " << *mouseButtonEvent;
59 const auto button = mouseButtonEvent->getButton();
60 if (button == utility::event::MouseButtonEvent::Button::Unknown)
63 const auto &position = mouseButtonEvent->getPosition();
65 utility::graphic::RayF ray;
67 ray = _engine.getView().viewPointToRay(position);
68 }
catch (
const std::out_of_range &exception) {
69 this->getLogger().warning()
70 <<
"MouseButton::update: " << exception.what();
82 const bool isIntersecting =
85 ray, transform.getPose(), bound,
87 const bool isButtonPressed = mouseButtonEvent->isButtonPressed();
89 if (isButtonPressed && isIntersecting) {
90 interaction.setButtonPressed(button,
true);
91 const auto &handler = interaction.getOnButtonPressHandler(button);
95 }
else if (!isButtonPressed && interaction.isButtonPressed(button)
97 interaction.setButtonPressed(button,
false);
98 const auto &handler = interaction.getOnButtonReleaseHandler(button);
102 }
else if (!isButtonPressed) {
103 interaction.setButtonPressed(button,
false);
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
SystemFiller(Phase phase)
ecs::ComponentRegistry & getComponentRegistry(void)
Get the component registry of the scene being processed.
ComponentType & getComponent(const ecs::Entity::Identifier &entityIdentifier)
Get a component of an entity from the bound registry, to read or modify it.
Hands each engine event to the listeners subscribed to its type.
void consumeNextEvent(void)
EventManager(EventBus &eventBus)
std::shared_ptr< EventType > getLastEvent(void)
Free functions the input systems share to decide whether a pointer or hand ray hits an entity.
State. Every class here is plain data attached to an entity.
The entity-component-system core, independent of any widget.
Delivery of engine events to the systems that subscribed to them.
Rules. Every class here runs each frame on the entities that have the components it declares.
bool hitTest(const utility::graphic::RayF &ray, const utility::graphic::PoseF &pose, const components::Bound &bound, const utility::math::Vector2F &margin)
Whether a ray crosses the rectangle of an entity, grown by a margin.
utility::math::Vector2F hitMargin(const ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &entityIdentifier)
Extra hit area of an entity around its Bound, in dp.
bool isInteractive(const ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &entityIdentifier)
Whether an entity accepts input.