Generalize layers as merge nodes to enable adjustment layers (#1712)

* WIP, backward traversal issues

* Fix some tool issues

* Remove debugging

* Change some indices

* WIP: new artboard node

* WIP: add artboard node

* WIP: Artboard node and create_artboard

* WIP: Artboard node implementation complete

* WIP: Artboards input for output node

* Complete Artboard node

* Generalize LayerNodeIdentifier,  monitor_nodes support for Artboard node, adjust ResizeArtboard/ClearArtboards, move alias validation to Rust

* Fix misaligned artboard click targets

* Generalize/clarify create_layer and insert_between

* non-negative dimensions for resize_artboard

* Show artboards in layer panel

* Generalize create_layer for layer output node

* Generalize delete_layer/delete_artboard to NodeGraphMessage::DeleteNodes. Fixed upstream flow Iter

* remove old primary_input function

* Vertical node visuals, remove is_layer function, rename Layer node to Merge node, toggle display as layer

exposed_value_count type fix

Vertical node visuals, remove is_layer function, rename Layer node to Merge node, toggle display as layer

* Fix demo artwork

* Layer display context menu

* Automatically select artboard, fix warnings

* Improvements to context menu and layer invariant enforcement

* Remove display_as_layer and update load_structure

* Improve load_structure to show more layers, improve FlowIter, improve layer naming, layer rearrangement validation.

* Clean up demo artwork using generalized layers

* Improve design of Layers panel and graph nodes

* MoveSelectedLayersTo rewrite to support generalized layer nodes

* Include artboards in deepest_common_ancestor, fix resize_artboard/delete_artboard, sync artboard tool to layer panel

* MoveSelectedLayersTo adjustments

* Sync non layer node visibility with metadata

* Include non layer nodes when moving/creating layer

* Fix group layers and get_post_node_with_index

* Include non layer nodes in UngroupSelectedLayers

* GroupSelected for all selected nodes, UnGroupSelected position adjustments

* Add grouping for layers in different folders

* Fix hidden layers

* Prevent node from connecting to itself, fix undo automatic node insertion,

* Fix undo CreateEmptyFolder, fix grouping nested layer nodes

* Formatting

* Remove test and check if node is layer from network

* Fix undo group layers

* Check off roadmap

* MoveUpstreamSiblingsToChild adjustments

* Replace tabs with spaces, remove mut from argument

* Final code review pass

---------

Co-authored-by: 0hypercube <0hypercube@gmail.com>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
adamgerhant
2024-04-30 23:03:42 -07:00
committed by GitHub
parent beb88d280c
commit 8d83fa7079
41 changed files with 1712 additions and 825 deletions

View File

@@ -106,6 +106,34 @@ impl Artboard {
}
}
/// Contains multiple artboards.
#[derive(Clone, Default, Debug, Hash, PartialEq, DynAny)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ArtboardGroup {
pub artboards: Vec<Artboard>,
}
impl ArtboardGroup {
pub const EMPTY: Self = Self { artboards: Vec::new() };
pub fn new() -> Self {
Default::default()
}
fn add_artboard(&mut self, artboard: Artboard) {
self.artboards.push(artboard);
}
pub fn get_graphic_group(&self) -> GraphicGroup {
let mut graphic_group = GraphicGroup::EMPTY;
for artboard in self.artboards.clone() {
let graphic_element: GraphicElement = artboard.into();
graphic_group.push(graphic_element);
}
graphic_group
}
}
pub struct ConstructLayerNode<GraphicElement, Stack> {
graphic_element: GraphicElement,
stack: Stack,
@@ -157,6 +185,24 @@ async fn construct_artboard<Fut: Future<Output = GraphicGroup>>(
clip,
}
}
pub struct AddArtboardNode<Artboard, ArtboardGroup> {
artboard: Artboard,
artboards: ArtboardGroup,
}
#[node_fn(AddArtboardNode)]
async fn add_artboard<Data: Into<Artboard>, Fut1: Future<Output = Data>, Fut2: Future<Output = ArtboardGroup>>(
footprint: Footprint,
artboard: impl Node<Footprint, Output = Fut1>,
mut artboards: impl Node<Footprint, Output = Fut2>,
) -> ArtboardGroup {
let artboard = self.artboard.eval(footprint).await;
let mut artboards = self.artboards.eval(footprint).await;
artboards.add_artboard(artboard.into());
artboards
}
impl From<ImageFrame<Color>> for GraphicElement {
fn from(mut image_frame: ImageFrame<Color>) -> Self {

View File

@@ -447,7 +447,7 @@ impl GraphicElementRendered for Artboard {
}
fn add_click_targets(&self, click_targets: &mut Vec<ClickTarget>) {
let subpath = Subpath::new_rect(DVec2::ZERO, self.dimensions.as_dvec2());
let subpath = Subpath::new_rect(self.location.as_dvec2(), self.location.as_dvec2() + self.dimensions.as_dvec2());
click_targets.push(ClickTarget { stroke_width: 0., subpath });
}
@@ -456,6 +456,23 @@ impl GraphicElementRendered for Artboard {
}
}
impl GraphicElementRendered for crate::ArtboardGroup {
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
self.get_graphic_group().render_svg(render, render_params);
}
fn bounding_box(&self, transform: DAffine2) -> Option<[DVec2; 2]> {
self.get_graphic_group().bounding_box(transform)
}
fn add_click_targets(&self, click_targets: &mut Vec<ClickTarget>) {
self.get_graphic_group().add_click_targets(click_targets);
}
fn contains_artboard(&self) -> bool {
true
}
}
impl GraphicElementRendered for ImageFrame<Color> {
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams) {
let transform: String = format_transform_matrix(self.transform * render.transform);