mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-08 07:18:01 +00:00
Artboard nodes (#1328)
* Create artboard nodes * Update node when resizing artboard * Render clipped artboards * More stable feature * Do not render old artboards * Fix some issues with transforms * Fix crash when drawing rectangle * Format * Allow renaming document from Properties panel * Adjust artboard label styling * Fix document graph refresh so artboards show up * Make "Clear Artboards" coming soon * Fix displaying an infinite canvas * Show document name in node graph options bar * info!() to debug!() * Fix Properties panel not being cleared when all docs closed * Remove dead code * Remove debug logs added in this branch --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
ad0dc3276e
commit
08f9be6aaf
26 changed files with 636 additions and 182 deletions
|
@ -496,34 +496,19 @@ impl NodeNetwork {
|
|||
///
|
||||
/// Used for the properties panel and tools.
|
||||
pub fn primary_flow(&self) -> impl Iterator<Item = (&DocumentNode, u64)> {
|
||||
struct FlowIter<'a> {
|
||||
stack: Vec<NodeId>,
|
||||
network: &'a NodeNetwork,
|
||||
}
|
||||
impl<'a> Iterator for FlowIter<'a> {
|
||||
type Item = (&'a DocumentNode, NodeId);
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
loop {
|
||||
let node_id = self.stack.pop()?;
|
||||
if let Some(document_node) = self.network.nodes.get(&node_id) {
|
||||
self.stack.extend(
|
||||
document_node
|
||||
.inputs
|
||||
.iter()
|
||||
.take(1) // Only show the primary input
|
||||
.filter_map(|input| if let NodeInput::Node { node_id: ref_id, .. } = input { Some(*ref_id) } else { None }),
|
||||
);
|
||||
return Some((document_node, node_id));
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
FlowIter {
|
||||
stack: self.outputs.iter().map(|output| output.node_id).collect(),
|
||||
network: self,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn primary_flow_from_opt(&self, id: Option<NodeId>) -> impl Iterator<Item = (&DocumentNode, u64)> {
|
||||
FlowIter {
|
||||
stack: id.map_or_else(|| self.outputs.iter().map(|output| output.node_id).collect(), |id| vec![id]),
|
||||
network: self,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_acyclic(&self) -> bool {
|
||||
let mut dependencies: HashMap<u64, Vec<u64>> = HashMap::new();
|
||||
for (node_id, node) in &self.nodes {
|
||||
|
@ -549,6 +534,29 @@ impl NodeNetwork {
|
|||
}
|
||||
}
|
||||
|
||||
struct FlowIter<'a> {
|
||||
stack: Vec<NodeId>,
|
||||
network: &'a NodeNetwork,
|
||||
}
|
||||
impl<'a> Iterator for FlowIter<'a> {
|
||||
type Item = (&'a DocumentNode, NodeId);
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
loop {
|
||||
let node_id = self.stack.pop()?;
|
||||
if let Some(document_node) = self.network.nodes.get(&node_id) {
|
||||
self.stack.extend(
|
||||
document_node
|
||||
.inputs
|
||||
.iter()
|
||||
.take(1) // Only show the primary input
|
||||
.filter_map(|input| if let NodeInput::Node { node_id: ref_id, .. } = input { Some(*ref_id) } else { None }),
|
||||
);
|
||||
return Some((document_node, node_id));
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Functions for compiling the network
|
||||
impl NodeNetwork {
|
||||
pub fn map_ids(&mut self, f: impl Fn(NodeId) -> NodeId + Copy) {
|
||||
|
@ -835,7 +843,7 @@ impl NodeNetwork {
|
|||
self.nodes.retain(|_, node| !matches!(node.implementation, DocumentNodeImplementation::Extract));
|
||||
|
||||
for (_, node) in &mut extraction_nodes {
|
||||
log::info!("extraction network: {:#?}", &self);
|
||||
log::debug!("extraction network: {:#?}", &self);
|
||||
if let DocumentNodeImplementation::Extract = node.implementation {
|
||||
assert_eq!(node.inputs.len(), 1);
|
||||
log::debug!("Resolving extract node {:?}", node);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue