Browse Source

Updated which node ports are shown on frames by default

Kyle Belfort 5 years ago
parent
commit
25538a36fe

+ 1 - 0
dist/preview release/what's new.md

@@ -27,6 +27,7 @@
 - Frames are now resizable from the corners ([belfortk](https://github.com/belfortk)
 - Frames are now resizable from the corners ([belfortk](https://github.com/belfortk)
 - Can now rename and re-order frame inputs and outputs ([belfortk](https://github.com/belfortk)
 - Can now rename and re-order frame inputs and outputs ([belfortk](https://github.com/belfortk)
 - Can now edit Node port names ([belfortk](https://github.com/belfortk)
 - Can now edit Node port names ([belfortk](https://github.com/belfortk)
+- Updated which node ports are shown on frames by default so that only node ports connected to outside nodes are by default exposed on the frame ([belfortk](https://github.com/belfortk)
 
 
 ### Inspector
 ### Inspector
 
 

+ 11 - 0
nodeEditor/src/components/propertyTab/propertyTab.scss

@@ -486,6 +486,17 @@
                 background: rgb(22, 73, 117);
                 background: rgb(22, 73, 117);
             }
             }
 
 
+            .cbx:checked ~ label.disabled { 
+                background: rgb(22, 73, 117);
+                cursor: pointer;
+            }
+
+            .cbx:checked ~ label.disabled:after {
+                left: 20px;
+                background: rgb(85, 85, 85);
+                cursor: pointer;
+            }
+
             .hidden { 
             .hidden { 
                 display: none; 
                 display: none; 
             }               
             }               

+ 5 - 1
nodeEditor/src/diagram/frameNodePort.ts

@@ -72,7 +72,11 @@ export class FrameNodePort extends NodePort {
         if (!displayManager || displayManager.shouldDisplayPortLabels(block)) {
         if (!displayManager || displayManager.shouldDisplayPortLabels(block)) {
             let portLabel = root.ownerDocument!.createElement("div");
             let portLabel = root.ownerDocument!.createElement("div");
             portLabel.classList.add("port-label");
             portLabel.classList.add("port-label");
-            portLabel.innerHTML = connectionPoint.displayName || connectionPoint.name;        
+            let portName = connectionPoint.displayName || connectionPoint.name;
+            if (portName === "output") {
+                portName = node.name;
+            }
+            portLabel.innerHTML = portName;       
             portContainer.appendChild(portLabel);
             portContainer.appendChild(portLabel);
         }
         }
 
 

+ 3 - 3
nodeEditor/src/diagram/graphFrame.ts

@@ -126,12 +126,11 @@ export class GraphFrame {
                                 this._controlledPorts.push(port);
                                 this._controlledPorts.push(port);
                             }
                             }
                         }
                         }
-                    } else {
+                    } else if(port.exposedOnFrame) {
                         let localPort = FrameNodePort.CreateFrameNodePortElement(port.connectionPoint, node, this._outputPortContainer, null, this._ownerCanvas.globalState, false, GraphFrame._FramePortCounter++, this.id);
                         let localPort = FrameNodePort.CreateFrameNodePortElement(port.connectionPoint, node, this._outputPortContainer, null, this._ownerCanvas.globalState, false, GraphFrame._FramePortCounter++, this.id);
                         this._frameOutPorts.push(localPort);
                         this._frameOutPorts.push(localPort);
                         port.delegatedPort = localPort;
                         port.delegatedPort = localPort;
                         this._controlledPorts.push(port);
                         this._controlledPorts.push(port);
-
                     }
                     }
                 }
                 }
 
 
@@ -143,7 +142,7 @@ export class GraphFrame {
                                 link.isVisible = true;
                                 link.isVisible = true;
                             }
                             }
                         }
                         }
-                    } else {
+                    } else if(port.exposedOnFrame) {
                         this._createInputPort(port, node);
                         this._createInputPort(port, node);
                     }
                     }
                 }
                 }
@@ -1261,6 +1260,7 @@ export class GraphFrame {
 
 
                 if (node.length) {
                 if (node.length) {
                     newFrame.nodes.push(node[0]);
                     newFrame.nodes.push(node[0]);
+                    node[0].isEnclosedInAFrame = true;
                 }
                 }
             }
             }
         } else {
         } else {

+ 13 - 1
nodeEditor/src/diagram/graphNode.ts

@@ -39,6 +39,7 @@ export class GraphNode {
     private _isSelected: boolean;
     private _isSelected: boolean;
     private _displayManager: Nullable<IDisplayManager> = null;
     private _displayManager: Nullable<IDisplayManager> = null;
     private _isVisible = true;
     private _isVisible = true;
+    private _isEnclosedInAFrame: boolean;
 
 
     public get isVisible() {
     public get isVisible() {
         return this._isVisible;
         return this._isVisible;
@@ -144,6 +145,14 @@ export class GraphNode {
         return this._isSelected;
         return this._isSelected;
     }
     }
 
 
+    public get isEnclosedInAFrame() {
+        return this._isEnclosedInAFrame;
+    }
+
+    public set isEnclosedInAFrame(value: boolean) {
+        this._isEnclosedInAFrame = value;
+    }
+
     public set isSelected(value: boolean) {
     public set isSelected(value: boolean) {
         if (this._isSelected === value) {
         if (this._isSelected === value) {
             return;            
             return;            
@@ -211,10 +220,13 @@ export class GraphNode {
         rect1.width -= 5;
         rect1.width -= 5;
         rect1.height -= 5;
         rect1.height -= 5;
 
 
-        return !(rect1.right < rect2.left || 
+        const isOverlappingFrame = !(rect1.right < rect2.left || 
             rect1.left > rect2.right || 
             rect1.left > rect2.right || 
             rect1.bottom < rect2.top || 
             rect1.bottom < rect2.top || 
             rect1.top > rect2.bottom);
             rect1.top > rect2.bottom);
+
+        this._isEnclosedInAFrame = isOverlappingFrame;
+        return isOverlappingFrame;
     }
     }
 
 
     public getPortForConnectionPoint(point: NodeMaterialConnectionPoint) {
     public getPortForConnectionPoint(point: NodeMaterialConnectionPoint) {

+ 15 - 2
nodeEditor/src/diagram/nodePort.ts

@@ -18,7 +18,8 @@ export class NodePort {
     protected _globalState: GlobalState;
     protected _globalState: GlobalState;
     protected _portLabelElement: Element;
     protected _portLabelElement: Element;
     protected _onCandidateLinkMovedObserver: Nullable<Observer<Nullable<Vector2>>>;
     protected _onCandidateLinkMovedObserver: Nullable<Observer<Nullable<Vector2>>>;
-    protected _onSelectionChangedObserver: Nullable<Observer<Nullable<GraphFrame | GraphNode | NodeLink | NodePort | FramePortData>>>;  
+    protected _onSelectionChangedObserver: Nullable<Observer<Nullable<GraphFrame | GraphNode | NodeLink | NodePort | FramePortData>>>;
+    protected _exposedOnFrame = this.connectionPoint.isConnected || false;
     
     
     public delegatedPort: Nullable<FrameNodePort> = null;
     public delegatedPort: Nullable<FrameNodePort> = null;
 
 
@@ -31,7 +32,11 @@ export class NodePort {
     }
     }
 
 
     public get portName(){
     public get portName(){
-        return this.connectionPoint.displayName || this.connectionPoint.name;
+        let portName = this.connectionPoint.displayName || this.connectionPoint.name;
+        if (portName === "output") {
+            portName = this.node.name;
+        }
+        return portName
     }
     }
 
 
     public set portName(newName: string){
     public set portName(newName: string){
@@ -45,6 +50,14 @@ export class NodePort {
         return !!this._portLabelElement;
         return !!this._portLabelElement;
     }
     }
 
 
+    public get exposedOnFrame() {
+        return this._exposedOnFrame;
+    }
+
+    public set exposedOnFrame(value: boolean) {
+        this._exposedOnFrame = value;
+    }
+
     public refresh() {
     public refresh() {
         this._element.style.background = BlockTools.GetColorFromConnectionNodeType(this.connectionPoint.type);
         this._element.style.background = BlockTools.GetColorFromConnectionNodeType(this.connectionPoint.type);
         switch (this.connectionPoint.type) {
         switch (this.connectionPoint.type) {

+ 2 - 0
nodeEditor/src/diagram/properties/nodePortPropertyComponent.tsx

@@ -10,6 +10,7 @@ import { NodePort } from '../nodePort';
 import { GraphNode } from '../graphNode';
 import { GraphNode } from '../graphNode';
 import { NodeLink } from '../nodeLink';
 import { NodeLink } from '../nodeLink';
 import { FramePortData } from '../graphCanvas';
 import { FramePortData } from '../graphCanvas';
+import { CheckBoxLineComponent } from '../../sharedComponents/checkBoxLineComponent';
 
 
 export interface IFrameNodePortPropertyTabComponentProps {
 export interface IFrameNodePortPropertyTabComponentProps {
     globalState: GlobalState
     globalState: GlobalState
@@ -39,6 +40,7 @@ export class NodePortPropertyTabComponent extends React.Component<IFrameNodePort
                 <div>
                 <div>
                     <LineContainerComponent title="GENERAL">
                     <LineContainerComponent title="GENERAL">
                         {this.props.nodePort.hasLabel() && <TextInputLineComponent globalState={this.props.globalState} label="Port Label" propertyName="portName" target={this.props.nodePort} />}
                         {this.props.nodePort.hasLabel() && <TextInputLineComponent globalState={this.props.globalState} label="Port Label" propertyName="portName" target={this.props.nodePort} />}
+                        {this.props.nodePort.node.isEnclosedInAFrame && <CheckBoxLineComponent label= "Expose Port on Frame" target={this.props.nodePort} isSelected={() => this.props.nodePort.exposedOnFrame} onSelect={(value: boolean) => this.props.nodePort.exposedOnFrame = value}  propertyName="exposedOnFrame" disabled={this.props.nodePort.connectionPoint.isConnected} />}
                     </LineContainerComponent>
                     </LineContainerComponent>
                 </div>
                 </div>
             </div>
             </div>

+ 11 - 3
nodeEditor/src/sharedComponents/checkBoxLineComponent.tsx

@@ -10,6 +10,7 @@ export interface ICheckBoxLineComponentProps {
     onSelect?: (value: boolean) => void;
     onSelect?: (value: boolean) => void;
     onValueChanged?: () => void;
     onValueChanged?: () => void;
     onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
     onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
+    disabled?: boolean;
 }
 }
 
 
 export class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponentProps, { isSelected: boolean }> {
 export class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponentProps, { isSelected: boolean }> {
@@ -42,7 +43,7 @@ export class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponen
             this._localChange = false;
             this._localChange = false;
             return true;
             return true;
         }
         }
-        return nextProps.label !== this.props.label;
+        return nextProps.label !== this.props.label || nextProps.target !== this.props.target;
     }
     }
 
 
     onChange() {
     onChange() {
@@ -69,6 +70,13 @@ export class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponen
         this.setState({ isSelected: !this.state.isSelected });
         this.setState({ isSelected: !this.state.isSelected });
     }
     }
 
 
+    getDisabled() {
+        if (this.props.disabled) {
+            return this.props.disabled;
+        }
+        else return false;
+    }
+
     render() {
     render() {
         return (
         return (
             <div className="checkBoxLine">
             <div className="checkBoxLine">
@@ -76,8 +84,8 @@ export class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponen
                     {this.props.label}
                     {this.props.label}
                 </div>
                 </div>
                 <div className="checkBox">
                 <div className="checkBox">
-                    <input type="checkbox" id={"checkbox" + this._uniqueId} className="cbx hidden" checked={this.state.isSelected} onChange={() => this.onChange()} />
-                    <label htmlFor={"checkbox" + this._uniqueId} className="lbl"></label>
+                    <input type="checkbox" id={"checkbox" + this._uniqueId} className="cbx hidden" checked={this.state.isSelected} onChange={() => this.onChange()} disabled={this.getDisabled()}/>
+                    <label htmlFor={"checkbox" + this._uniqueId} className={`lbl${this.getDisabled() ? ' disabled' : ''}`}></label>
                 </div>
                 </div>
             </div>
             </div>
         );
         );

+ 1 - 1
src/Materials/Node/nodeMaterialBlockConnectionPoint.ts

@@ -178,7 +178,7 @@ export class NodeMaterialConnectionPoint {
      * Gets a boolean indicating that the current point is connected
      * Gets a boolean indicating that the current point is connected
      */
      */
     public get isConnected(): boolean {
     public get isConnected(): boolean {
-        return this.connectedPoint !== null;
+        return this.connectedPoint !== null || this.isConnectedInFragmentShader || this.isConnectedInVertexShader || this.isConnectedToInputBlock;
     }
     }
 
 
     /**
     /**