#include #include namespace psemek::ui { geom::box event_interceptor::size_constraints() const { if (child_) return child_->size_constraints(); return element::size_constraints(); } shape const & event_interceptor::shape() const { static const null_shape fallback_shape; if (child_) return child_->shape(); return fallback_shape; } void event_interceptor::reshape(geom::box const & bbox) { if (child_) child_->reshape(bbox); } void event_interceptor::on_mouse_move(std::function callback) { mouse_move_callback_ = std::move(callback); } void event_interceptor::on_mouse_click(std::function callback) { mouse_click_callback_ = std::move(callback); } void event_interceptor::on_mouse_wheel(std::function callback) { mouse_wheel_callback_ = std::move(callback); } void event_interceptor::on_key_press(std::function callback) { key_press_callback_ = std::move(callback); } bool event_interceptor::on_event(mouse_move const & event) { if (child_) mouseover_ = child_->shape().contains(geom::cast(event.position)); else mouseover_ = false; if (mouseover_ && mouse_move_callback_) return mouse_move_callback_(event); return false; } bool event_interceptor::on_event(mouse_click const & event) { if (mouseover_ && mouse_click_callback_) return mouse_click_callback_(event); return false; } bool event_interceptor::on_event(mouse_wheel const & event) { if (mouseover_ && mouse_wheel_callback_) return mouse_wheel_callback_(event); return false; } bool event_interceptor::on_event(key_press const & event) { if (key_press_callback_) return key_press_callback_(event); return false; } }