nodePortPropertyComponent.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import * as React from "react";
  2. import { LineContainerComponent } from '../../sharedComponents/lineContainerComponent';
  3. import { GlobalState } from '../../globalState';
  4. import { TextInputLineComponent } from '../../sharedComponents/textInputLineComponent';
  5. import { GraphFrame } from '../graphFrame';
  6. import { Nullable } from 'babylonjs/types';
  7. import { Observer } from 'babylonjs/Misc/observable';
  8. import { NodePort } from '../nodePort';
  9. import { GraphNode } from '../graphNode';
  10. import { NodeLink } from '../nodeLink';
  11. import { FramePortData } from '../graphCanvas';
  12. import { CheckBoxLineComponent } from '../../sharedComponents/checkBoxLineComponent';
  13. import { TextLineComponent } from '../../sharedComponents/textLineComponent';
  14. export interface IFrameNodePortPropertyTabComponentProps {
  15. globalState: GlobalState
  16. nodePort: NodePort;
  17. }
  18. export class NodePortPropertyTabComponent extends React.Component<IFrameNodePortPropertyTabComponentProps> {
  19. private _onSelectionChangedObserver: Nullable<Observer<Nullable<GraphFrame | NodePort | GraphNode | NodeLink | FramePortData>>>;
  20. constructor(props: IFrameNodePortPropertyTabComponentProps) {
  21. super(props);
  22. }
  23. componentWillUnmount() {
  24. this.props.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver);
  25. }
  26. toggleExposeOnFrame(value: boolean){
  27. this.props.nodePort.exposedOnFrame = value;
  28. this.props.globalState.onExposePortOnFrameObservable.notifyObservers(this.props.nodePort.node);
  29. }
  30. render() {
  31. let info = this.props.nodePort.hasLabel() ?
  32. <>
  33. {this.props.nodePort.hasLabel() && <TextInputLineComponent globalState={this.props.globalState} label="Port Label" propertyName="portName" target={this.props.nodePort} />}
  34. {this.props.nodePort.node.enclosingFrameId !== -1 && <CheckBoxLineComponent label= "Expose Port on Frame" target={this.props.nodePort} isSelected={() => this.props.nodePort.exposedOnFrame} onSelect={(value: boolean) => this.toggleExposeOnFrame(value)} propertyName="exposedOnFrame" disabled={this.props.nodePort.disabled} />}
  35. </> :
  36. <TextLineComponent label="This node is a constant input node and cannot be exposed to the frame." value=" " ></TextLineComponent>
  37. return (
  38. <div id="propertyTab">
  39. <div id="header">
  40. <img id="logo" src="https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png" />
  41. <div id="title">
  42. NODE MATERIAL EDITOR
  43. </div>
  44. </div>
  45. <div>
  46. <LineContainerComponent title="GENERAL">
  47. {info}
  48. </LineContainerComponent>
  49. </div>
  50. </div>
  51. );
  52. }
  53. }