mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 13:48:12 +08:00
Improve type compatibility and clean up new node macro usages (#2002)
* Improve type compatibility * More
This commit is contained in:
@@ -232,13 +232,25 @@ impl ArtboardGroup {
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""))]
|
||||
async fn layer<F: 'n + Copy + Send>(
|
||||
#[implementations((), Footprint)] footprint: F,
|
||||
#[implementations(() -> GraphicGroup, Footprint -> GraphicGroup)] stack: impl Node<F, Output = GraphicGroup>,
|
||||
#[implementations(() -> GraphicElement, Footprint -> GraphicElement)] graphic_element: impl Node<F, Output = GraphicElement>,
|
||||
async fn layer<F: 'n + Send + Copy>(
|
||||
#[implementations(
|
||||
(),
|
||||
Footprint,
|
||||
)]
|
||||
footprint: F,
|
||||
#[implementations(
|
||||
() -> GraphicGroup,
|
||||
Footprint -> GraphicGroup,
|
||||
)]
|
||||
stack: impl Node<F, Output = GraphicGroup>,
|
||||
#[implementations(
|
||||
() -> GraphicElement,
|
||||
Footprint -> GraphicElement,
|
||||
)]
|
||||
element: impl Node<F, Output = GraphicElement>,
|
||||
node_path: Vec<NodeId>,
|
||||
) -> GraphicGroup {
|
||||
let mut element = graphic_element.eval(footprint).await;
|
||||
let mut element = element.eval(footprint).await;
|
||||
let mut stack = stack.eval(footprint).await;
|
||||
if stack.transform.matrix2.determinant() != 0. {
|
||||
*element.transform_mut() = stack.transform.inverse() * element.transform();
|
||||
@@ -255,16 +267,23 @@ async fn layer<F: 'n + Copy + Send>(
|
||||
|
||||
#[node_macro::node(category("Debug"))]
|
||||
async fn to_element<F: 'n + Send, Data: Into<GraphicElement> + 'n>(
|
||||
#[implementations((), (), (), (), Footprint)] footprint: F,
|
||||
#[implementations(
|
||||
() -> VectorData,
|
||||
() -> ImageFrame<Color>,
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
Footprint,
|
||||
)]
|
||||
footprint: F,
|
||||
#[implementations(
|
||||
() -> GraphicGroup,
|
||||
() -> TextureFrame,
|
||||
Footprint -> VectorData,
|
||||
() -> VectorData,
|
||||
() -> ImageFrame<Color>,
|
||||
() -> TextureFrame,
|
||||
Footprint -> GraphicGroup,
|
||||
Footprint -> VectorData,
|
||||
Footprint -> ImageFrame<Color>,
|
||||
Footprint -> GraphicGroup,
|
||||
Footprint -> TextureFrame,
|
||||
Footprint -> TextureFrame,
|
||||
)]
|
||||
data: impl Node<F, Output = Data>,
|
||||
) -> GraphicElement {
|
||||
@@ -273,15 +292,22 @@ async fn to_element<F: 'n + Send, Data: Into<GraphicElement> + 'n>(
|
||||
|
||||
#[node_macro::node(category("General"))]
|
||||
async fn to_group<F: 'n + Send, Data: Into<GraphicGroup> + 'n>(
|
||||
#[implementations((), (), (), (), Footprint)] footprint: F,
|
||||
#[implementations(
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
Footprint,
|
||||
)]
|
||||
footprint: F,
|
||||
#[implementations(
|
||||
() -> GraphicGroup,
|
||||
() -> VectorData,
|
||||
() -> ImageFrame<Color>,
|
||||
() -> GraphicGroup,
|
||||
() -> TextureFrame,
|
||||
Footprint -> GraphicGroup,
|
||||
Footprint -> VectorData,
|
||||
Footprint -> ImageFrame<Color>,
|
||||
Footprint -> GraphicGroup,
|
||||
Footprint -> TextureFrame,
|
||||
)]
|
||||
element: impl Node<F, Output = Data>,
|
||||
@@ -290,9 +316,26 @@ async fn to_group<F: 'n + Send, Data: Into<GraphicGroup> + 'n>(
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""))]
|
||||
async fn to_artboard<F: 'n + Copy + Send + ApplyTransform>(
|
||||
#[implementations((), Footprint)] mut footprint: F,
|
||||
#[implementations(() -> GraphicGroup, Footprint -> GraphicGroup)] contents: impl Node<F, Output = GraphicGroup>,
|
||||
async fn to_artboard<F: 'n + Send + ApplyTransform, Data: Into<GraphicGroup> + 'n>(
|
||||
#[implementations(
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
Footprint,
|
||||
)]
|
||||
mut footprint: F,
|
||||
#[implementations(
|
||||
() -> GraphicGroup,
|
||||
() -> VectorData,
|
||||
() -> ImageFrame<Color>,
|
||||
() -> TextureFrame,
|
||||
Footprint -> GraphicGroup,
|
||||
Footprint -> VectorData,
|
||||
Footprint -> ImageFrame<Color>,
|
||||
Footprint -> TextureFrame,
|
||||
)]
|
||||
contents: impl Node<F, Output = Data>,
|
||||
label: String,
|
||||
location: IVec2,
|
||||
dimensions: IVec2,
|
||||
@@ -303,7 +346,7 @@ async fn to_artboard<F: 'n + Copy + Send + ApplyTransform>(
|
||||
let graphic_group = contents.eval(footprint).await;
|
||||
|
||||
Artboard {
|
||||
graphic_group,
|
||||
graphic_group: graphic_group.into(),
|
||||
label,
|
||||
location: location.min(location + dimensions),
|
||||
dimensions: dimensions.abs(),
|
||||
@@ -311,11 +354,24 @@ async fn to_artboard<F: 'n + Copy + Send + ApplyTransform>(
|
||||
clip,
|
||||
}
|
||||
}
|
||||
|
||||
#[node_macro::node(category(""))]
|
||||
async fn append_artboard<F: 'n + Copy + Send>(
|
||||
#[implementations((), Footprint)] footprint: F,
|
||||
#[implementations(() -> ArtboardGroup, Footprint -> ArtboardGroup)] artboards: impl Node<F, Output = ArtboardGroup>,
|
||||
#[implementations(() -> Artboard, Footprint -> Artboard)] artboard: impl Node<F, Output = Artboard>,
|
||||
async fn append_artboard<F: 'n + Send + Copy>(
|
||||
#[implementations(
|
||||
(),
|
||||
Footprint,
|
||||
)]
|
||||
footprint: F,
|
||||
#[implementations(
|
||||
() -> ArtboardGroup,
|
||||
Footprint -> ArtboardGroup,
|
||||
)]
|
||||
artboards: impl Node<F, Output = ArtboardGroup>,
|
||||
#[implementations(
|
||||
() -> Artboard,
|
||||
Footprint -> Artboard,
|
||||
)]
|
||||
artboard: impl Node<F, Output = Artboard>,
|
||||
node_path: Vec<NodeId>,
|
||||
) -> ArtboardGroup {
|
||||
let artboard = artboard.eval(footprint).await;
|
||||
|
||||
Reference in New Issue
Block a user