Implement viewport selection (#178)

* Begin implementing viewport selection

* Implement viewport click and drag selection for ellipse and rectangle

* Begin implementing line selection

* Remove debug prints

* Run cargo format

* Use DVec2 instead of kurbo::Point

* Line and polyline intersection

* Run cargo format

* Add fix for missing layer panel update

* Replace point selection with box selection

* Formatting

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Paul Kupper
2021-07-05 01:05:12 +02:00
committed by GitHub
parent 20420c1286
commit ad064602a5
13 changed files with 293 additions and 25 deletions

View File

@@ -1,3 +1,5 @@
use glam::DVec2;
use crate::{DocumentError, LayerId};
use super::{style, Layer, LayerData, LayerDataTypes};
@@ -13,6 +15,10 @@ pub struct Folder {
}
impl LayerData for Folder {
fn to_kurbo_path(&self, _: glam::DAffine2, _: style::PathStyle) -> kurbo::BezPath {
unimplemented!()
}
fn render(&mut self, svg: &mut String, transform: glam::DAffine2, _style: style::PathStyle) {
let _ = writeln!(svg, r#"<g transform="matrix("#);
transform.to_cols_array().iter().enumerate().for_each(|(i, f)| {
@@ -26,8 +32,12 @@ impl LayerData for Folder {
let _ = writeln!(svg, "</g>");
}
fn to_kurbo_path(&mut self, _: glam::DAffine2, _: style::PathStyle) -> kurbo::BezPath {
unimplemented!()
fn intersects_quad(&self, quad: [DVec2; 4], path: &mut Vec<LayerId>, intersections: &mut Vec<Vec<LayerId>>, _style: style::PathStyle) {
for (layer, layer_id) in self.layers().iter().zip(&self.layer_ids) {
path.push(*layer_id);
layer.intersects_quad(quad, path, intersections);
path.pop();
}
}
}