diff --git a/crates/render/src/ui/planet.rs b/crates/render/src/ui/planet.rs index 0423d13..943844f 100644 --- a/crates/render/src/ui/planet.rs +++ b/crates/render/src/ui/planet.rs @@ -117,9 +117,11 @@ impl Planet { self.reflow(planet, state); } - self.button.step(input, state); - self.landscape.step(input, state); - self.frame.step(input, state); + self.button + .step(input, state, Some(self.frame.get_rect(input))); + self.landscape + .step(input, state, Some(self.frame.get_rect(input))); + self.frame.step(input, state, None); // Draw elements self.button diff --git a/crates/render/src/ui/util/sprite.rs b/crates/render/src/ui/util/sprite.rs index a4d2b3d..170946a 100644 --- a/crates/render/src/ui/util/sprite.rs +++ b/crates/render/src/ui/util/sprite.rs @@ -39,16 +39,14 @@ impl UiSprite { }; } - pub fn step(&mut self, input: &RenderInput, state: &RenderState) { - if self.contains_mouse(input, state, Some(self.get_rect(input))) + pub fn step(&mut self, input: &RenderInput, state: &RenderState, parent: Option) { + if self.contains_mouse(input, state, parent) && !self.has_mouse && self.on_mouse_enter.is_some() { self.has_mouse = true; self.anim.jump_to(input.ct, self.on_mouse_enter.unwrap()) - } - - if !self.contains_mouse(input, state, Some(self.get_rect(input))) + } else if !self.contains_mouse(input, state, parent) && self.has_mouse && self.on_mouse_leave.is_some() {