mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 02:28:13 +08:00
Implement bounding box for selected layers (#349)
* Implement bounding box for selected layers * Add shift modifier for multi selection
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -83,6 +83,7 @@ pub struct Layer {
|
||||
pub cache_dirty: bool,
|
||||
pub blend_mode: BlendMode,
|
||||
pub opacity: f64,
|
||||
pub overlay: bool,
|
||||
}
|
||||
|
||||
impl Layer {
|
||||
@@ -97,6 +98,7 @@ impl Layer {
|
||||
cache_dirty: true,
|
||||
blend_mode: BlendMode::Normal,
|
||||
opacity: 1.,
|
||||
overlay: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +130,7 @@ impl Layer {
|
||||
}
|
||||
|
||||
pub fn intersects_quad(&self, quad: Quad, path: &mut Vec<LayerId>, intersections: &mut Vec<Vec<LayerId>>) {
|
||||
if !self.visible {
|
||||
if !self.visible || self.overlay {
|
||||
return;
|
||||
}
|
||||
let transformed_quad = self.transform.inverse() * quad;
|
||||
@@ -166,6 +168,7 @@ impl Clone for Layer {
|
||||
cache_dirty: true,
|
||||
blend_mode: self.blend_mode,
|
||||
opacity: self.opacity,
|
||||
overlay: self.overlay,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user