MCPcopy Create free account
hub / github.com/christophhart/HISE / wrapIntoChain

Method wrapIntoChain

hi_scripting/scripting/scriptnode/ui/NodeComponent.cpp:1237–1310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1235}
1236
1237void 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());

Callers

nothing calls this directly

Calls 15

getRootNetworkMethod · 0.80
setValueTreePropertyMethod · 0.80
getChildWithNameMethod · 0.80
StringClass · 0.50
isEmptyMethod · 0.45
getIdMethod · 0.45
isObjectMethod · 0.45
getMethod · 0.45
createMethod · 0.45
getObjectMethod · 0.45
getValueTreeMethod · 0.45

Tested by

no test coverage detected