mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 13:08:11 +08:00
Migrate vector data and tools to use nodes (#1065)
* Add rendering to vector nodes * Add line, shape, rectange and freehand tool * Fix transforms, strokes and fills * Migrate spline tool * Remove blank lines * Fix test * Fix fill in properties * Select layers when filling * Properties panel transform around pivot * Fix select tool outlines * Select tool modifies node graph pivot * Add the pivot assist to the properties * Improve setting non existant fill UX * Cleanup hash function * Path and pen tools * Bug fixes * Disable boolean ops * Fix default handle smoothing on ellipses * Fix test and warnings --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Keavon Chambers
parent
639a24d8ad
commit
959e790cdf
@@ -8,8 +8,6 @@ use crate::layers::style::RenderData;
|
||||
use crate::layers::text_layer::{Font, TextLayer};
|
||||
use crate::{DocumentError, DocumentResponse, Operation};
|
||||
|
||||
use graphene_std::vector::subpath::Subpath;
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cell::RefCell;
|
||||
@@ -177,43 +175,6 @@ impl Document {
|
||||
Ok(shapes)
|
||||
}
|
||||
|
||||
/// Return a copy of all [Subpath]s currently in the document.
|
||||
pub fn all_subpaths(&self) -> Vec<Subpath> {
|
||||
self.root.iter().flat_map(|layer| layer.as_subpath_copy()).collect::<Vec<Subpath>>()
|
||||
}
|
||||
|
||||
/// Returns references to all [Subpath]s currently in the document.
|
||||
pub fn all_subpaths_ref(&self) -> Vec<&Subpath> {
|
||||
self.root.iter().flat_map(|layer| layer.as_subpath()).collect::<Vec<&Subpath>>()
|
||||
}
|
||||
|
||||
/// Returns a reference to the requested [Subpath] by providing a path to its owner layer.
|
||||
pub fn subpath_ref<'a>(&'a self, path: &[LayerId]) -> Option<&'a Subpath> {
|
||||
self.layer(path).ok()?.as_subpath()
|
||||
}
|
||||
|
||||
/// Returns a mutable reference of the requested [Subpath] by providing a path to its owner layer.
|
||||
pub fn subpath_mut<'a>(&'a mut self, path: &'a [LayerId]) -> Option<&'a mut Subpath> {
|
||||
self.layer_mut(path).ok()?.as_subpath_mut()
|
||||
}
|
||||
|
||||
/// Set a [Subpath] at the specified path.
|
||||
pub fn set_subpath(&mut self, path: &[LayerId], shape: Subpath) {
|
||||
let layer = self.layer_mut(path);
|
||||
if let Ok(layer) = layer {
|
||||
if let LayerDataType::Shape(shape_layer) = &mut layer.data {
|
||||
shape_layer.shape = shape;
|
||||
// Is this needed?
|
||||
layer.cache_dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Set [Subpath]s for multiple paths at once.
|
||||
pub fn set_subpaths<'a>(&'a mut self, paths: impl Iterator<Item = &'a [LayerId]>, shapes: Vec<Subpath>) {
|
||||
paths.zip(shapes).for_each(|(path, shape)| self.set_subpath(path, shape));
|
||||
}
|
||||
|
||||
pub fn common_layer_path_prefix<'a>(&self, layers: impl Iterator<Item = &'a [LayerId]>) -> &'a [LayerId] {
|
||||
layers.reduce(|a, b| &a[..a.iter().zip(b.iter()).take_while(|&(a, b)| a == b).count()]).unwrap_or_default()
|
||||
}
|
||||
@@ -865,6 +826,12 @@ impl Document {
|
||||
}
|
||||
Some(vec![DocumentChanged, LayerChanged { path }])
|
||||
}
|
||||
Operation::SetVectorData { path, vector_data } => {
|
||||
if let LayerDataType::NodeGraphFrame(graph) = &mut self.layer_mut(&path)?.data {
|
||||
graph.vector_data = Some(vector_data);
|
||||
}
|
||||
Some(Vec::new())
|
||||
}
|
||||
Operation::InsertManipulatorGroup {
|
||||
layer_path,
|
||||
manipulator_group,
|
||||
|
||||
Reference in New Issue
Block a user