mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
* Do not select layer immediatly on drag * Add LayerReferenceInput MVP widget * Properties Panel * Fix dragging marker flicker * Change mask shape to outline * Add mask rendering * Simplify select code * Remove colours * Fix inpaint/outpaint and rearrage widget UX * Add mask blur and mask starting fill parameters * Guard for the case when the layer is missing * Add icon to LayerReferenceInput to finalize its UI Co-authored-by: Keavon Chambers <keavon@keavon.com>
28 lines
990 B
TypeScript
28 lines
990 B
TypeScript
import { reactive, readonly } from "vue";
|
|
|
|
import { type Editor } from "@/wasm-communication/editor";
|
|
import { type FrontendNode, type FrontendNodeLink, type FrontendNodeType, UpdateNodeGraph, UpdateNodeTypes } from "@/wasm-communication/messages";
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
export function createNodeGraphState(editor: Editor) {
|
|
const state = reactive({
|
|
nodes: [] as FrontendNode[],
|
|
links: [] as FrontendNodeLink[],
|
|
nodeTypes: [] as FrontendNodeType[],
|
|
});
|
|
|
|
// Set up message subscriptions on creation
|
|
editor.subscriptions.subscribeJsMessage(UpdateNodeGraph, (updateNodeGraph) => {
|
|
state.nodes = updateNodeGraph.nodes;
|
|
state.links = updateNodeGraph.links;
|
|
});
|
|
editor.subscriptions.subscribeJsMessage(UpdateNodeTypes, (updateNodeTypes) => {
|
|
state.nodeTypes = updateNodeTypes.nodeTypes;
|
|
});
|
|
|
|
return {
|
|
state: readonly(state) as typeof state,
|
|
};
|
|
}
|
|
export type NodeGraphState = ReturnType<typeof createNodeGraphState>;
|