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) {
|
onRightClicked: function (pos) {
|
||||||
if (NodeGraphEditorBackend.nodeGraphEditorModel.currentFileName !== "") {
|
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();
|
contextMenu.popup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,9 +14,18 @@ StudioControls.Menu {
|
|||||||
id: contextMenu
|
id: contextMenu
|
||||||
|
|
||||||
required property var graph
|
required property var graph
|
||||||
|
property var inputsModel: []
|
||||||
|
property var node
|
||||||
|
|
||||||
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
|
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
|
||||||
|
|
||||||
|
onAboutToShow: {
|
||||||
|
if (node && node.item)
|
||||||
|
contextMenu.inputsModel = node.item.portsMetaData;
|
||||||
|
else
|
||||||
|
contextMenu.inputsModel = null;
|
||||||
|
}
|
||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: qsTr("BaseColor")
|
text: qsTr("BaseColor")
|
||||||
|
|
||||||
@@ -88,4 +97,32 @@ StudioControls.Menu {
|
|||||||
contextMenu.graph.insertNode(Nodes.Components.texture);
|
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: "",
|
// alias: "",
|
||||||
// name: "",
|
// name: "",
|
||||||
// type: "",
|
// type: "",
|
||||||
|
// enabled: true,
|
||||||
// binding: (values) => {}
|
// binding: (values) => {}
|
||||||
// }
|
// }
|
||||||
property var pin: []
|
property var pin: []
|
||||||
@@ -26,6 +27,29 @@ Qan.NodeItem {
|
|||||||
property string type
|
property string type
|
||||||
property string uuid: NodeGraphEditorBackend.widget.generateUUID()
|
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.preferredHeight: 60
|
||||||
Layout.preferredWidth: 100
|
Layout.preferredWidth: 100
|
||||||
connectable: Qan.NodeItem.UnConnectable
|
connectable: Qan.NodeItem.UnConnectable
|
||||||
@@ -56,6 +80,8 @@ Qan.NodeItem {
|
|||||||
QtObject {
|
QtObject {
|
||||||
id: internal
|
id: internal
|
||||||
|
|
||||||
|
property var createdPorts: []
|
||||||
|
|
||||||
function configurePorts(graph) {
|
function configurePorts(graph) {
|
||||||
const initPort = (portItem, data) => {
|
const initPort = (portItem, data) => {
|
||||||
if (data.binding) {
|
if (data.binding) {
|
||||||
@@ -65,15 +91,27 @@ Qan.NodeItem {
|
|||||||
portItem.dataType = data.type;
|
portItem.dataType = data.type;
|
||||||
portItem.dataId = data.id;
|
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 => {
|
root.portsMetaData.pin.forEach(data => {
|
||||||
const portItem = graph.insertPort(root.node, Qan.NodeItem.Left, Qan.PortItem.In, `${data.name} (${data.type})`, data.id);
|
const portItem = graph.insertPort(root.node, Qan.NodeItem.Left, Qan.PortItem.In, `${data.name} (${data.type})`, data.id);
|
||||||
initPort(portItem, data);
|
initPort(portItem, data);
|
||||||
|
|
||||||
|
if (data.enabled != undefined && data.enabled === false) {
|
||||||
|
portItem.visible = false;
|
||||||
|
}
|
||||||
|
createdPorts.push(portItem);
|
||||||
});
|
});
|
||||||
|
|
||||||
root.portsMetaData.pout.forEach(data => {
|
root.portsMetaData.pout.forEach(data => {
|
||||||
const portItem = graph.insertPort(root.node, Qan.NodeItem.Right, Qan.PortItem.Out, `${data.name}`, data.id);
|
const portItem = graph.insertPort(root.node, Qan.NodeItem.Right, Qan.PortItem.Out, `${data.name}`, data.id);
|
||||||
initPort(portItem, data);
|
initPort(portItem, data);
|
||||||
|
createdPorts.push(portItem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,18 +30,21 @@ Base {
|
|||||||
id: "metalness_in_metalness",
|
id: "metalness_in_metalness",
|
||||||
alias: "metalness",
|
alias: "metalness",
|
||||||
name: "Metalness",
|
name: "Metalness",
|
||||||
|
enabled: true,
|
||||||
type: "real"
|
type: "real"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "metalness_in_metalnessChannel",
|
id: "metalness_in_metalnessChannel",
|
||||||
alias: "channel",
|
alias: "channel",
|
||||||
name: "Channel",
|
name: "Channel",
|
||||||
|
enabled: true,
|
||||||
type: "QQuick3DMaterial::TextureChannelMapping"
|
type: "QQuick3DMaterial::TextureChannelMapping"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "metalness_in_metalnessMap ",
|
id: "metalness_in_metalnessMap ",
|
||||||
alias: "map",
|
alias: "map",
|
||||||
name: "Map",
|
name: "Map",
|
||||||
|
enabled: false,
|
||||||
type: "Texture"
|
type: "Texture"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -50,6 +53,7 @@ Base {
|
|||||||
id: "metalness_out",
|
id: "metalness_out",
|
||||||
alias: "",
|
alias: "",
|
||||||
name: "OUT",
|
name: "OUT",
|
||||||
|
enabled: true,
|
||||||
type: "nge::Metalness"
|
type: "nge::Metalness"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user