overlay: toggle selection only if clicked inside the shape

This commit is contained in:
Mikolaj Wielgus 2024-04-16 13:38:19 +00:00
parent 4a9322d694
commit 87f5f4e8c0
2 changed files with 19 additions and 4 deletions

View File

@ -2,7 +2,7 @@
mod geometry;
pub mod compound;
pub mod primitive;
mod shape;
pub mod shape;
pub mod with_rtree;
pub use geometry::*;

View File

@ -4,8 +4,12 @@ use geo::Point;
use rstar::AABB;
use crate::{
drawing::{graph::PrimitiveIndex, rules::RulesTrait},
geometry::Node,
drawing::{
graph::{MakePrimitive, PrimitiveIndex},
primitive::MakeShape,
rules::RulesTrait,
},
geometry::{shape::ShapeTrait, Node},
graph::GenericIndex,
layout::{zone::ZoneWeight, Layout},
};
@ -28,7 +32,18 @@ impl Overlay {
[at.x(), at.y(), f64::INFINITY],
),
) {
self.toggle_selection(geom.data);
match geom.data {
Node::Primitive(primitive) => {
if primitive
.primitive(layout.drawing())
.shape()
.contains_point(at)
{
self.toggle_selection(geom.data);
}
}
Node::Compound(compound) => (), // TODO.
}
}
}