| 1235 | } |
| 1236 | |
| 1237 | void NodeComponent::PopupHelpers::wrapIntoChain(NodeBase* node, MenuActions result, String idToUse) |
| 1238 | { |
| 1239 | #if USE_BACKEND |
| 1240 | auto framePath = "container.frame" + String(node->getCurrentChannelAmount()) + "_block"; |
| 1241 | |
| 1242 | StringArray ids = { "container.chain", "container.split", "container.multi", |
| 1243 | framePath, "container.fix32_block", "container.midichain", "container.no_midi", "container.clone", "container.soft_bypass", "container.oversample4x"}; |
| 1244 | |
| 1245 | int idIndex = (int)result - (int)MenuActions::WrapIntoChain; |
| 1246 | |
| 1247 | auto path = ids[idIndex]; |
| 1248 | |
| 1249 | int index = 1; |
| 1250 | |
| 1251 | if (idToUse.isEmpty()) |
| 1252 | { |
| 1253 | idToUse = "wrap" + node->getId() + String(index); |
| 1254 | } |
| 1255 | |
| 1256 | auto network = node->getRootNetwork(); |
| 1257 | |
| 1258 | while (network->get(idToUse).isObject()) |
| 1259 | { |
| 1260 | index++; |
| 1261 | idToUse = "wrap" + node->getId() + String(index); |
| 1262 | } |
| 1263 | |
| 1264 | auto newNode = node->getRootNetwork()->create(path, idToUse); |
| 1265 | |
| 1266 | if (auto newContainer = dynamic_cast<NodeBase*>(newNode.getObject())) |
| 1267 | { |
| 1268 | auto containerTree = newContainer->getValueTree(); |
| 1269 | |
| 1270 | newContainer->setValueTreeProperty(PropertyIds::NodeColour, node->getValueTree()[PropertyIds::NodeColour]); |
| 1271 | |
| 1272 | auto um = node->getUndoManager(); |
| 1273 | |
| 1274 | auto selection = network->getSelection(); |
| 1275 | |
| 1276 | if (selection.isEmpty() || !selection.contains(node)) |
| 1277 | { |
| 1278 | auto nodeTree = node->getValueTree(); |
| 1279 | auto parent = nodeTree.getParent(); |
| 1280 | auto nIndex = parent.indexOf(nodeTree); |
| 1281 | |
| 1282 | |
| 1283 | |
| 1284 | parent.removeChild(nodeTree, um); |
| 1285 | containerTree.getChildWithName(PropertyIds::Nodes).addChild(nodeTree, -1, um); |
| 1286 | |
| 1287 | jassert(!containerTree.getParent().isValid()); |
| 1288 | |
| 1289 | parent.addChild(containerTree, nIndex, um); |
| 1290 | } |
| 1291 | else |
| 1292 | { |
| 1293 | auto parent = selection.getFirst()->getValueTree().getParent(); |
| 1294 | auto nIndex = parent.indexOf(selection.getFirst()->getValueTree()); |
nothing calls this directly
no test coverage detected