mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 04:48:11 +08:00
Replace the image layer type with an Image node (#948)
* Use builder pattern for widgets * Arguments to new function * Add node graph when dragging in image * Fix duplicate import * Skip processing under node graph frame if unused * Reduce node graph rerenders * DUPLICATE ALL frontend changes into other frontend * DUPLICATE more changes to another frontend * Code review * Allow importing SVG files as bitmaps Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Keavon Chambers
parent
66e8325362
commit
64e62699fc
@@ -488,21 +488,21 @@ impl Layer {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the Image element wrapped by the layer.
|
||||
/// This operation will fail if the [Layer type](Layer::data) is not `LayerDataType::Image`.
|
||||
pub fn as_image_mut(&mut self) -> Result<&mut ImageLayer, DocumentError> {
|
||||
/// Get a mutable reference to the NodeNetwork
|
||||
/// This operation will fail if the [Layer type](Layer::data) is not `LayerDataType::NodeGraphFrame`.
|
||||
pub fn as_node_graph_mut(&mut self) -> Result<&mut graph_craft::document::NodeNetwork, DocumentError> {
|
||||
match &mut self.data {
|
||||
LayerDataType::Image(img) => Ok(img),
|
||||
_ => Err(DocumentError::NotAnImage),
|
||||
LayerDataType::NodeGraphFrame(frame) => Ok(&mut frame.network),
|
||||
_ => Err(DocumentError::NotNodeGraph),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a reference to the Image element wrapped by the layer.
|
||||
/// This operation will fail if the [Layer type](Layer::data) is not `LayerDataType::Image`.
|
||||
pub fn as_image(&self) -> Result<&ImageLayer, DocumentError> {
|
||||
/// Get a reference to the NodeNetwork
|
||||
/// This operation will fail if the [Layer type](Layer::data) is not `LayerDataType::NodeGraphFrame`.
|
||||
pub fn as_node_graph(&self) -> Result<&graph_craft::document::NodeNetwork, DocumentError> {
|
||||
match &self.data {
|
||||
LayerDataType::Image(img) => Ok(img),
|
||||
_ => Err(DocumentError::NotAnImage),
|
||||
LayerDataType::NodeGraphFrame(frame) => Ok(&frame.network),
|
||||
_ => Err(DocumentError::NotNodeGraph),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -510,7 +510,7 @@ impl Layer {
|
||||
match &self.data {
|
||||
LayerDataType::Shape(s) => Ok(&s.style),
|
||||
LayerDataType::Text(t) => Ok(&t.path_style),
|
||||
_ => Err(DocumentError::NotAShape),
|
||||
_ => Err(DocumentError::NotShape),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,7 +518,7 @@ impl Layer {
|
||||
match &mut self.data {
|
||||
LayerDataType::Shape(s) => Ok(&mut s.style),
|
||||
LayerDataType::Text(t) => Ok(&mut t.path_style),
|
||||
_ => Err(DocumentError::NotAShape),
|
||||
_ => Err(DocumentError::NotShape),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user