mirror of https://codeberg.org/topola/topola.git
overlay: toggle selection only if clicked inside the shape
This commit is contained in:
parent
4a9322d694
commit
87f5f4e8c0
|
|
@ -2,7 +2,7 @@
|
|||
mod geometry;
|
||||
pub mod compound;
|
||||
pub mod primitive;
|
||||
mod shape;
|
||||
pub mod shape;
|
||||
pub mod with_rtree;
|
||||
|
||||
pub use geometry::*;
|
||||
|
|
|
|||
|
|
@ -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,9 +32,20 @@ impl Overlay {
|
|||
[at.x(), at.y(), f64::INFINITY],
|
||||
),
|
||||
) {
|
||||
match geom.data {
|
||||
Node::Primitive(primitive) => {
|
||||
if primitive
|
||||
.primitive(layout.drawing())
|
||||
.shape()
|
||||
.contains_point(at)
|
||||
{
|
||||
self.toggle_selection(geom.data);
|
||||
}
|
||||
}
|
||||
Node::Compound(compound) => (), // TODO.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_selection(&mut self, node: Node<PrimitiveIndex, GenericIndex<ZoneWeight>>) {
|
||||
if !self.selection.insert(node) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue