Elements detect when children are hovered over
This commit is contained in:
parent
e3af067972
commit
031c61146b
33 changed files with 153 additions and 185 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue