Skip to content

Commit 52b32dc

Browse files
committed
nuon: Take scissor_rect into account when bounds checking the mouse pos
1 parent 6dd517d commit 52b32dc

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

nuon/src/lib.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ impl LayerStack {
166166
self.layers.iter()
167167
}
168168

169+
pub fn current_scissor_rect(&self) -> Option<Rect> {
170+
let scissor_rect = self.current().scissor_rect;
171+
(!scissor_rect.is_empty()).then_some(scissor_rect)
172+
}
173+
174+
pub fn current(&self) -> &LayerData {
175+
&self.layers[self.curr]
176+
}
177+
169178
pub fn current_mut(&mut self) -> &mut LayerData {
170179
&mut self.layers[self.curr]
171180
}
@@ -736,7 +745,13 @@ impl ClickArea {
736745
}
737746

738747
fn check(ui: &mut Ui, id: Id, rect: Rect) -> ClickAreaEvent {
739-
let mouseover = rect.contains(ui.pointer_pos);
748+
let in_scissor_rect = ui
749+
.layers
750+
.current_scissor_rect()
751+
.map(|scissor_rect| scissor_rect.contains(ui.pointer_pos))
752+
.unwrap_or(true);
753+
754+
let mouseover = in_scissor_rect && rect.contains(ui.pointer_pos);
740755

741756
if mouseover {
742757
ui.hovered = Some(id);

0 commit comments

Comments
 (0)