egui: fix selecting nodes whose bboxes overlap other bboxes

This commit is contained in:
Mikolaj Wielgus 2024-06-21 07:11:41 +02:00
parent 169ddf7d80
commit d34554f075
1 changed files with 4 additions and 20 deletions

View File

@ -52,27 +52,15 @@ impl Overlay {
if let Some(geom) = geoms.iter().find(|&&geom| match geom.data {
NodeIndex::Primitive(primitive) => {
primitive.primitive(board.layout().drawing()).layer() == self.active_layer
&& self.contains_point(board, geom.data, at)
}
NodeIndex::Compound(compound) => false,
}) {
if self.toggle_selection_if_contains_point(board, geom.data, at) {
return;
}
}
for geom in geoms {
if self.toggle_selection_if_contains_point(board, geom.data, at) {
return;
}
self.selection.toggle_at_node(board, geom.data);
}
}
fn toggle_selection_if_contains_point(
&mut self,
board: &Board<impl MesadataTrait>,
node: NodeIndex,
p: Point,
) -> bool {
fn contains_point(&self, board: &Board<impl MesadataTrait>, node: NodeIndex, p: Point) -> bool {
let shape: Shape = match node {
NodeIndex::Primitive(primitive) => {
primitive.primitive(board.layout().drawing()).shape().into()
@ -99,11 +87,7 @@ impl Overlay {
}
};
if shape.contains_point(p) {
self.selection.toggle_at_node(board, node);
return true;
}
false
shape.contains_point(p)
}
pub fn ratsnest(&self) -> &Ratsnest {