MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / addChild

Function addChild

JUCE/modules/juce_data_structures/values/juce_ValueTree.cpp:247–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245 }
246
247 void addChild (SharedObject* child, int index, UndoManager* undoManager)
248 {
249 if (child != nullptr && child->parent != this)
250 {
251 if (child != this && ! isAChildOf (child))
252 {
253 // You should always make sure that a child is removed from its previous parent before
254 // adding it somewhere else - otherwise, it's ambiguous as to whether a different
255 // undomanager should be used when removing it from its current parent..
256 jassert (child->parent == nullptr);
257
258 if (child->parent != nullptr)
259 {
260 jassert (child->parent->children.indexOf (child) >= 0);
261 child->parent->removeChild (child->parent->children.indexOf (child), undoManager);
262 }
263
264 if (undoManager == nullptr)
265 {
266 children.insert (index, child);
267 child->parent = this;
268 sendChildAddedMessage (ValueTree (*child));
269 child->sendParentChangeMessage();
270 }
271 else
272 {
273 if (! isPositiveAndBelow (index, children.size()))
274 index = children.size();
275
276 undoManager->perform (new AddOrRemoveChildAction (*this, index, child));
277 }
278 }
279 else
280 {
281 // You're attempting to create a recursive loop! A node
282 // can't be a child of one of its own children!
283 jassertfalse;
284 }
285 }
286 }
287
288 void removeChild (int childIndex, UndoManager* undoManager)
289 {

Callers 8

addChildMethod · 0.85
getOrCreateChildWithNameFunction · 0.85
ValueTreeMethod · 0.85
addNewSubGroupMethod · 0.85
addFileUncheckedMethod · 0.85
addRelativeFileMethod · 0.85

Calls 7

isAChildOfFunction · 0.85
sendChildAddedMessageFunction · 0.85
isPositiveAndBelowFunction · 0.85
indexOfMethod · 0.45
insertMethod · 0.45
sizeMethod · 0.45
performMethod · 0.45

Tested by

no test coverage detected