forked from qt-creator/qt-creator
Enable/disable node pins
Change-Id: Ibd0b41b534cd59ab99692c27e1e9588e5d72616e Reviewed-by: Karol Herda <khe@spyro-soft.com>
This commit is contained in:
@@ -293,6 +293,15 @@ Item {
|
||||
}
|
||||
onRightClicked: function (pos) {
|
||||
if (NodeGraphEditorBackend.nodeGraphEditorModel.currentFileName !== "") {
|
||||
var selectedNodes = graphView.graph.selectedNodes;
|
||||
if (selectedNodes) {
|
||||
if (selectedNodes.length > 0)
|
||||
contextMenu.node = selectedNodes.at(0);
|
||||
else
|
||||
contextMenu.node = null;
|
||||
} else
|
||||
contextMenu.node = null;
|
||||
|
||||
contextMenu.popup();
|
||||
}
|
||||
}
|
||||
|
@@ -14,9 +14,18 @@ StudioControls.Menu {
|
||||
id: contextMenu
|
||||
|
||||
required property var graph
|
||||
property var inputsModel: []
|
||||
property var node
|
||||
|
||||
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
|
||||
|
||||
onAboutToShow: {
|
||||
if (node && node.item)
|
||||
contextMenu.inputsModel = node.item.portsMetaData;
|
||||
else
|
||||
contextMenu.inputsModel = null;
|
||||
}
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("BaseColor")
|
||||
|
||||
@@ -88,4 +97,32 @@ StudioControls.Menu {
|
||||
contextMenu.graph.insertNode(Nodes.Components.texture);
|
||||
}
|
||||
}
|
||||
|
||||
StudioControls.MenuSeparator {
|
||||
height: implicitHeight
|
||||
style: StudioTheme.Values.controlStyle
|
||||
}
|
||||
|
||||
StudioControls.Menu {
|
||||
enabled: node !== null
|
||||
title: "Pins"
|
||||
|
||||
Repeater {
|
||||
id: pinRepeater
|
||||
|
||||
model: contextMenu.inputsModel ? contextMenu.inputsModel.pin : null
|
||||
|
||||
delegate: StudioControls.CheckBox {
|
||||
actionIndicator.visible: false
|
||||
checkState: (modelData.enabled === undefined || modelData.enabled === true) ? Qt.Checked : Qt.UnChecked
|
||||
text: "pin: " + modelData.name
|
||||
width: implicitWidth + StudioTheme.Values.toolbarHorizontalMargin
|
||||
|
||||
onToggled: {
|
||||
contextMenu.node.item.switchPin(modelData.id);
|
||||
contextMenu.node.item.updatePinVisibility(modelData.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ Qan.NodeItem {
|
||||
// alias: "",
|
||||
// name: "",
|
||||
// type: "",
|
||||
// enabled: true,
|
||||
// binding: (values) => {}
|
||||
// }
|
||||
property var pin: []
|
||||
@@ -26,6 +27,29 @@ Qan.NodeItem {
|
||||
property string type
|
||||
property string uuid: NodeGraphEditorBackend.widget.generateUUID()
|
||||
|
||||
function switchPin(pin_id) {
|
||||
root.portsMetaData.pin.forEach(data => {
|
||||
if (data.id == pin_id) {
|
||||
if (data.enabled === false)
|
||||
data.enabled = true;
|
||||
else
|
||||
data.enabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updatePinVisibility(pin_id) {
|
||||
internal.createdPorts.forEach(data => {
|
||||
if (data.dataId === pin_id) {
|
||||
root.portsMetaData.pin.forEach(data2 => {
|
||||
if (data2.id === pin_id) {
|
||||
data.visible = data2.enabled;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Layout.preferredHeight: 60
|
||||
Layout.preferredWidth: 100
|
||||
connectable: Qan.NodeItem.UnConnectable
|
||||
@@ -56,6 +80,8 @@ Qan.NodeItem {
|
||||
QtObject {
|
||||
id: internal
|
||||
|
||||
property var createdPorts: []
|
||||
|
||||
function configurePorts(graph) {
|
||||
const initPort = (portItem, data) => {
|
||||
if (data.binding) {
|
||||
@@ -65,15 +91,27 @@ Qan.NodeItem {
|
||||
portItem.dataType = data.type;
|
||||
portItem.dataId = data.id;
|
||||
};
|
||||
for (var i = 0; i < createdPorts.length; i++) {
|
||||
graph.removePort(root.node, createdPorts[i]);
|
||||
}
|
||||
createdPorts = [];
|
||||
|
||||
root.node.item.ports.clear();
|
||||
|
||||
root.portsMetaData.pin.forEach(data => {
|
||||
const portItem = graph.insertPort(root.node, Qan.NodeItem.Left, Qan.PortItem.In, `${data.name} (${data.type})`, data.id);
|
||||
initPort(portItem, data);
|
||||
|
||||
if (data.enabled != undefined && data.enabled === false) {
|
||||
portItem.visible = false;
|
||||
}
|
||||
createdPorts.push(portItem);
|
||||
});
|
||||
|
||||
root.portsMetaData.pout.forEach(data => {
|
||||
const portItem = graph.insertPort(root.node, Qan.NodeItem.Right, Qan.PortItem.Out, `${data.name}`, data.id);
|
||||
initPort(portItem, data);
|
||||
createdPorts.push(portItem);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -30,18 +30,21 @@ Base {
|
||||
id: "metalness_in_metalness",
|
||||
alias: "metalness",
|
||||
name: "Metalness",
|
||||
enabled: true,
|
||||
type: "real"
|
||||
},
|
||||
{
|
||||
id: "metalness_in_metalnessChannel",
|
||||
alias: "channel",
|
||||
name: "Channel",
|
||||
enabled: true,
|
||||
type: "QQuick3DMaterial::TextureChannelMapping"
|
||||
},
|
||||
{
|
||||
id: "metalness_in_metalnessMap ",
|
||||
alias: "map",
|
||||
name: "Map",
|
||||
enabled: false,
|
||||
type: "Texture"
|
||||
},
|
||||
]
|
||||
@@ -50,6 +53,7 @@ Base {
|
||||
id: "metalness_out",
|
||||
alias: "",
|
||||
name: "OUT",
|
||||
enabled: true,
|
||||
type: "nge::Metalness"
|
||||
},
|
||||
]
|
||||
|
Reference in New Issue
Block a user