This repository has been archived by the owner on Feb 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add simple node linking * Add simple node linking
- Loading branch information
Showing
9 changed files
with
240 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,50 @@ | ||
import React from "react"; | ||
import { NodeOutput } from "../../nodes/Node"; | ||
import Graph from "./Graph"; | ||
import "./GraphNodeOutput.css"; | ||
import { BaseGraphNodeProperty } from "./GraphNodeProperties"; | ||
|
||
interface IGraphNodeOutputProperties<T> { | ||
name: string; | ||
output: NodeOutput<T>; | ||
graph: Graph; | ||
} | ||
|
||
export default class GraphNodeOutput<T> extends React.Component<IGraphNodeOutputProperties<T>> { | ||
|
||
private _userSelectionRef: React.RefObject<any> | null = null; | ||
|
||
constructor(props: any) { | ||
super(props); | ||
this._userSelectionRef = React.createRef(); | ||
} | ||
|
||
private onMouseDown(): void { | ||
this.props.graph.selectedGraphNodeIO = this; | ||
this.props.graph.isMoveable = false; | ||
} | ||
|
||
private onMouseUp(): void { | ||
if (this.props.graph.selectedGraphNodeIO instanceof BaseGraphNodeProperty) { | ||
this.props.graph.selectedGraphNodeIO.props.property.trySetLinkedOutput(this.props.output); | ||
this.props.graph.selectedGraphNodeIO = null; | ||
this.props.graph.isMoveable = true; | ||
} | ||
if (this.props.graph.selectedGraphNodeIO === this) { | ||
this.props.graph.selectedGraphNodeIO = null; | ||
this.props.graph.isMoveable = true; | ||
} | ||
} | ||
|
||
public componentDidMount(): void { | ||
if (!this._userSelectionRef) return; | ||
this.props.output.userSelector = this._userSelectionRef.current; | ||
} | ||
|
||
public render(): JSX.Element { | ||
return (<div className="graph-node-output"> | ||
return (<div className="graph-node-output" onMouseDown={this.onMouseDown.bind(this)} onMouseUp={this.onMouseUp.bind(this)}> | ||
<span>{this.props.name}</span> | ||
<div className="user-selection"/> | ||
<div className="user-selection" ref={this._userSelectionRef}/> | ||
</div>); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.