Implement bounding box for selected layers (#349)

* Implement bounding box for selected layers

* Add shift modifier for multi selection
This commit is contained in:
TrueDoctor
2021-08-20 09:57:00 +02:00
committed by Keavon Chambers
parent 7c64e1a816
commit 68d8ae4804
10 changed files with 159 additions and 72 deletions
+5 -3
View File
@@ -33,7 +33,7 @@ fn split_path(path: &[LayerId]) -> Result<(&[LayerId], LayerId), DocumentError>
}
impl Document {
pub fn with_content(serialized_content: &String) -> Result<Self, DocumentError> {
pub fn with_content(serialized_content: &str) -> Result<Self, DocumentError> {
serde_json::from_str(serialized_content).map_err(|e| DocumentError::InvalidFile(e.to_string()))
}
@@ -289,8 +289,10 @@ impl Document {
Operation::AddBoundingBox { path, transform, style } => {
let mut rect = Shape::rectangle(*style);
rect.render_index = -1;
self.set_layer(path, Layer::new(LayerDataType::Shape(rect), *transform), -1)?;
Some(vec![DocumentResponse::DocumentChanged])
let mut layer = Layer::new(LayerDataType::Shape(rect), *transform);
layer.overlay = true;
self.set_layer(path, layer, -1)?;
Some(vec![DocumentResponse::DocumentChanged, DocumentResponse::CreatedLayer { path: path.clone() }])
}
Operation::AddShape {
path,