Migrate the Select tool to the document graph (#1433)

* function for accessing document metadata

* Better select tool

* Fix render

* Fix transforms

* Fix loading saved documents

* Populate graph UI when loading autosave

* Multiple transform nodes

* Fix deep select

* Graph tooltips

* Fix flip axis icon

* Show disabled widgets

* Stop select tool from selecting artboards

* Disable (not hide) the pivot widget; remove Deep/Shallow select for now

* Code review changes

* Fix pivot position with select tool

* Fix incorrectly selected layers when shift clicking

---------

Co-authored-by: Dennis Kobert <dennis@kobert.dev>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2023-10-17 18:59:30 +01:00
committed by Keavon Chambers
parent e1cdb2242d
commit 5827e989dc
46 changed files with 1041 additions and 1215 deletions

View File

@@ -47,13 +47,13 @@ impl Subpath {
}
/// Convert to the legacy Subpath from the `bezier_rs::Subpath`.
pub fn from_bezier_rs(value: &[bezier_rs::Subpath<ManipulatorGroupId>]) -> Self {
pub fn from_bezier_rs<'a, Subpath: core::borrow::Borrow<&'a bezier_rs::Subpath<ManipulatorGroupId>>>(value: impl IntoIterator<Item = Subpath>) -> Self {
let mut groups = IdBackedVec::new();
for subpath in value {
for group in subpath.manipulator_groups() {
for subpath in value.into_iter() {
for group in subpath.borrow().manipulator_groups() {
groups.push(ManipulatorGroup::new_with_handles(group.anchor, group.in_handle, group.out_handle));
}
if subpath.closed() {
if subpath.borrow().closed() {
groups.push(ManipulatorGroup::closed());
}
}

View File

@@ -59,8 +59,7 @@ impl DocumentNode {
fn resolve_proto_node(mut self) -> ProtoNode {
assert!(!self.inputs.is_empty() || self.manual_composition.is_some(), "Resolving document node {:#?} with no inputs", self);
let DocumentNodeImplementation::Unresolved(fqn) = self.implementation
else {
let DocumentNodeImplementation::Unresolved(fqn) = self.implementation else {
unreachable!("tried to resolve not flattened node on resolved node {:?}", self);
};
let (input, mut args) = if let Some(ty) = self.manual_composition {
@@ -245,6 +244,13 @@ impl NodeInput {
None
}
}
pub fn as_node(&self) -> Option<NodeId> {
if let NodeInput::Node { node_id, .. } = self {
Some(*node_id)
} else {
None
}
}
}
#[derive(Clone, Debug, PartialEq, Hash, DynAny)]
@@ -905,22 +911,22 @@ impl NodeNetwork {
/// Create a [`RecursiveNodeIter`] that iterates over all [`DocumentNode`]s, including ones that are deeply nested.
pub fn recursive_nodes(&self) -> RecursiveNodeIter {
let nodes = self.nodes.values().collect();
let nodes = self.nodes.iter().collect();
RecursiveNodeIter { nodes }
}
}
/// An iterator over all [`DocumentNode`]s, including ones that are deeply nested.
pub struct RecursiveNodeIter<'a> {
nodes: Vec<&'a DocumentNode>,
nodes: Vec<(&'a NodeId, &'a DocumentNode)>,
}
impl<'a> Iterator for RecursiveNodeIter<'a> {
type Item = &'a DocumentNode;
type Item = (&'a NodeId, &'a DocumentNode);
fn next(&mut self) -> Option<Self::Item> {
let node = self.nodes.pop()?;
if let DocumentNodeImplementation::Network(network) = &node.implementation {
self.nodes.extend(network.nodes.values());
if let DocumentNodeImplementation::Network(network) = &node.1.implementation {
self.nodes.extend(network.nodes.iter());
}
Some(node)
}

View File

@@ -359,6 +359,6 @@ async fn render_node<'a: 'input, F: Future<Output = GraphicGroup>>(
};
RenderOutput::CanvasFrame(frame.into())
}
_ => todo!("Non svg render output"),
_ => todo!("Non svg render output for {output_format:?}"),
}
}

View File

@@ -328,6 +328,7 @@ fn node_registry() -> HashMap<NodeIdentifier, HashMap<NodeIOTypes, NodeConstruct
)],
register_node!(graphene_std::raster::EmptyImageNode<_, _>, input: DAffine2, params: [Color]),
register_node!(graphene_core::memo::MonitorNode<_>, input: ImageFrame<Color>, params: []),
register_node!(graphene_core::memo::MonitorNode<_>, input: VectorData, params: []),
register_node!(graphene_core::memo::MonitorNode<_>, input: graphene_core::GraphicElementData, params: []),
async_node!(graphene_std::wasm_application_io::LoadResourceNode<_>, input: WasmEditorApi, output: Arc<[u8]>, params: [String]),
register_node!(graphene_std::wasm_application_io::DecodeImageNode, input: Arc<[u8]>, params: []),