mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-16 11:10:13 +00:00
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:
parent
e1cdb2242d
commit
5827e989dc
46 changed files with 1041 additions and 1215 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue