Elements detect when children are hovered over

This commit is contained in:
Yousef Khadadeh 2026-04-02 21:57:26 +03:00
parent e3af067972
commit 031c61146b
33 changed files with 153 additions and 185 deletions

View file

@ -34,25 +34,23 @@ float RotateWheel::wheel_end() {
return boundingBox.value().width() * 0.5f;
}
void RotateWheel::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
isHovering = mouseHovering;
isHeld = isHovering && button.button == InputManager::MouseButton::LEFT && button.down;
void RotateWheel::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button) {
isHeld = mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down;
update_rotate_wheel_mouse_hover(button.pos);
isRotateBarHeld = isRotateBarHovered && isHeld;
update_rotate_wheel_mouse(button.pos);
Element::input_mouse_button_callback(button, mouseHovering);
Element::input_mouse_button_callback(button);
}
void RotateWheel::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
isHovering = mouseHovering;
void RotateWheel::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion) {
update_rotate_wheel_mouse_hover(motion.pos);
update_rotate_wheel_mouse(motion.pos);
Element::input_mouse_motion_callback(motion, mouseHovering);
Element::input_mouse_motion_callback(motion);
}
void RotateWheel::update_rotate_wheel_mouse_hover(const Vector2f& p) {
float distFromCenter = vec_distance(p, boundingBox.value().center());
isRotateBarHovered = isHovering && distFromCenter > wheel_start() && distFromCenter < wheel_end();
isRotateBarHovered = mouseHovering && distFromCenter > wheel_start() && distFromCenter < wheel_end();
}
void RotateWheel::update_rotate_wheel_mouse(const Vector2f& p) {