mirror of https://codeberg.org/topola/topola.git
egui: fix selecting nodes whose bboxes overlap other bboxes
This commit is contained in:
parent
169ddf7d80
commit
d34554f075
|
|
@ -52,27 +52,15 @@ impl Overlay {
|
||||||
if let Some(geom) = geoms.iter().find(|&&geom| match geom.data {
|
if let Some(geom) = geoms.iter().find(|&&geom| match geom.data {
|
||||||
NodeIndex::Primitive(primitive) => {
|
NodeIndex::Primitive(primitive) => {
|
||||||
primitive.primitive(board.layout().drawing()).layer() == self.active_layer
|
primitive.primitive(board.layout().drawing()).layer() == self.active_layer
|
||||||
|
&& self.contains_point(board, geom.data, at)
|
||||||
}
|
}
|
||||||
NodeIndex::Compound(compound) => false,
|
NodeIndex::Compound(compound) => false,
|
||||||
}) {
|
}) {
|
||||||
if self.toggle_selection_if_contains_point(board, geom.data, at) {
|
self.selection.toggle_at_node(board, geom.data);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for geom in geoms {
|
fn contains_point(&self, board: &Board<impl MesadataTrait>, node: NodeIndex, p: Point) -> bool {
|
||||||
if self.toggle_selection_if_contains_point(board, geom.data, at) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn toggle_selection_if_contains_point(
|
|
||||||
&mut self,
|
|
||||||
board: &Board<impl MesadataTrait>,
|
|
||||||
node: NodeIndex,
|
|
||||||
p: Point,
|
|
||||||
) -> bool {
|
|
||||||
let shape: Shape = match node {
|
let shape: Shape = match node {
|
||||||
NodeIndex::Primitive(primitive) => {
|
NodeIndex::Primitive(primitive) => {
|
||||||
primitive.primitive(board.layout().drawing()).shape().into()
|
primitive.primitive(board.layout().drawing()).shape().into()
|
||||||
|
|
@ -99,11 +87,7 @@ impl Overlay {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if shape.contains_point(p) {
|
shape.contains_point(p)
|
||||||
self.selection.toggle_at_node(board, node);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ratsnest(&self) -> &Ratsnest {
|
pub fn ratsnest(&self) -> &Ratsnest {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue