Refactor the node macro and simply most of the node implementations (#1942)

* Add support structure for new node macro to gcore

* Fix compile issues and code generation

* Implement new node_fn macro

* Implement property translation

* Fix NodeIO type generation

* Start translating math nodes

* Move node implementation to outer scope to allow usage of local imports

* Add expose attribute to allow controlling the parameter exposure

* Add rust analyzer support for #[implementations] attribute

* Migrate logic nodes

* Handle where clause properly

* Implement argument ident pattern preservation

* Implement adjustment layer mapping

* Fix node registry types

* Fix module paths

* Improve demo artwork comptibility

* Improve macro error reporting

* Fix handling of impl node implementations

* Fix nodeio type computation

* Fix opacity node and graph type resolution

* Fix loading of demo artworks

* Fix eslint

* Fix typo in macro test

* Remove node definitions for Adjustment Nodes

* Fix type alias property generation and make adjustments footprint aware

* Convert vector nodes

* Implement path overrides

* Fix stroke node

* Fix painted dreams

* Implement experimental type level specialization

* Fix poisson disk sampling -> all demo artworks should work again

* Port text node + make node macro more robust by implementing lifetime substitution

* Fix vector node tests

* Fix red dress demo + ci

* Fix clippy warnings

* Code review

* Fix primary input issues

* Improve math nodes and audit others

* Set no_properties when no automatic properties are derived

* Port vector generator nodes (could not derive all definitions yet)

* Various QA changes and add min/max/mode_range to number parameters

* Add min and max for f64 and u32

* Convert gpu nodes and clean up unused nodes

* Partially port transform node

* Allow implementations on call arg

* Port path modify node

* Start porting graphic element nodes

* Transform nodes in graphic_element.rs

* Port brush node

* Port nodes in wasm_executior

* Rename node macro

* Fix formatting

* Fix Mandelbrot node

* Formatting

* Fix Load Image and Load Resource nodes, add scope input to node macro

* Remove unnecessary underscores

* Begin attemping to make nodes resolution-aware

* Infer a generic manual compositon type on generic call arg

* Various fixes and work towards merging

* Final changes for merge!

* Fix tests, probably

* More free line removals!

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Dennis Kobert
2024-09-20 03:50:30 -07:00
committed by GitHub
co-authored by Keavon Chambers
parent ca0d102296
commit e352c7fa71
92 changed files with 4250 additions and 7270 deletions
-1
View File
@@ -17,7 +17,6 @@ default = ["custom-protocol"]
# DO NOT remove this
custom-protocol = ["tauri/custom-protocol"]
gpu = ["graphite-editor/gpu"]
quantization = ["graphite-editor/quantization"]
[dependencies]
# Local dependencies
+17 -1
View File
@@ -461,6 +461,7 @@
<LayoutCol class="table">
{#if rulersVisible}
<LayoutRow class="ruler-or-scrollbar top-ruler">
<LayoutCol class="ruler-corner"></LayoutCol>
<RulerInput origin={rulerOrigin.x} majorMarkSpacing={rulerSpacing} numberInterval={rulerInterval} direction="Horizontal" bind:this={rulerHorizontal} />
</LayoutRow>
{/if}
@@ -653,8 +654,23 @@
flex: 0 0 auto;
}
.ruler-corner {
background: var(--color-2-mildblack);
width: 16px;
position: relative;
&::after {
content: "";
background: var(--color-5-dullgray);
position: absolute;
width: 1px;
height: 1px;
right: 0;
bottom: 0;
}
}
.top-ruler .ruler-input {
padding-left: 16px;
margin-right: 16px;
}
+1 -1
View File
@@ -99,7 +99,7 @@
});
});
const START_CATEGORIES_ORDER = ["General", "Value", "Math", "Style"];
const START_CATEGORIES_ORDER = ["UNCATEGORIZED", "General", "Value", "Math", "Style"];
const END_CATEGORIES_ORDER = ["Debug"];
return Array.from(categories)
.sort((a, b) => a[0].localeCompare(b[0]))
@@ -62,6 +62,8 @@
height: 0;
margin: 0;
opacity: 0;
// Firefox weirdly applies a 2px border which causes this element to take up a 4x4 square of space, so this removes it from the flow to prevent it from offsetting the label
position: absolute;
}
// Unchecked
@@ -116,16 +116,19 @@
<style lang="scss" global>
.ruler-input {
flex: 1 1 100%;
background: var(--color-4-dimgray);
background: var(--color-2-mildblack);
overflow: hidden;
position: relative;
box-sizing: border-box;
&.horizontal {
height: 16px;
border-bottom: 1px solid var(--color-5-dullgray);
}
&.vertical {
width: 16px;
border-right: 1px solid var(--color-5-dullgray);
svg text {
text-anchor: end;
@@ -137,7 +140,7 @@
path {
stroke-width: 1px;
stroke: var(--color-6-lowergray);
stroke: var(--color-5-dullgray);
}
text {
+5
View File
@@ -91,7 +91,12 @@ export function createDocumentState(editor: Editor) {
});
});
editor.subscriptions.subscribeJsMessage(TriggerDelayedZoomCanvasToFitAll, () => {
// TODO: This is horribly hacky
setTimeout(() => editor.handle.zoomCanvasToFitAll(), 0);
setTimeout(() => editor.handle.zoomCanvasToFitAll(), 1);
setTimeout(() => editor.handle.zoomCanvasToFitAll(), 10);
setTimeout(() => editor.handle.zoomCanvasToFitAll(), 50);
setTimeout(() => editor.handle.zoomCanvasToFitAll(), 100);
});
return {
+5 -1
View File
@@ -19,7 +19,11 @@ export async function initWasm() {
// Import the WASM module JS bindings and wrap them in the panic proxy
// eslint-disable-next-line import/no-cycle
await init();
const wasm = await init();
for (const [name, f] of Object.entries(wasm)) {
if (name.startsWith("__node_registry")) f();
}
wasmImport = await wasmMemory();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).imageCanvases = {};
+1 -1
View File
@@ -735,7 +735,7 @@ impl EditorHandle {
for node_id in nodes_to_upgrade {
document
.network_interface
.replace_implementation(&node_id, &[], DocumentNodeImplementation::proto("graphene_core::ConstructArtboardNode<_, _, _, _, _, _>"));
.replace_implementation(&node_id, &[], DocumentNodeImplementation::proto("graphene_core::ToArtboardNode"));
document
.network_interface
.add_input(&node_id, &[], TaggedValue::IVec2(glam::IVec2::default()), false, 2, "".to_string());