void Project::updateOldStyleConfigList() { ValueTree deprecatedConfigsList (projectRoot.getChildWithName (ProjectExporter::configurations)); if (deprecatedConfigsList.isValid()) { projectRoot.removeChild (deprecatedConfigsList, nullptr); for (Project::ExporterIterator exporter (*this); exporter.next();) { if (exporter->getNumConfigurations() == 0) { ValueTree newConfigs (deprecatedConfigsList.createCopy()); if (! exporter->isXcode()) { for (int j = newConfigs.getNumChildren(); --j >= 0;) { ValueTree config (newConfigs.getChild(j)); config.removeProperty (Ids::osxSDK, nullptr); config.removeProperty (Ids::osxCompatibility, nullptr); config.removeProperty (Ids::osxArchitecture, nullptr); } } exporter->settings.addChild (newConfigs, 0, nullptr); } } } }
void StoredSettings::AddRecentString(const Identifier& Type, const String& Str) { ValueTree tree = GetProperty(Type); if(tree.getNumProperties() >= MAX_RECENT_STRINGS){ //If we have more strings in the history over the range, remove the oldest one from it. tree.removeProperty(tree.getPropertyName(0), nullptr); } tree.setProperty(Identifier(String(Str.hashCode64())), var(Str), nullptr); }
void Project::sanitiseConfigFlags() { ValueTree configNode (getConfigNode()); for (int i = configNode.getNumProperties(); --i >= 0;) { const var value (configNode [configNode.getPropertyName(i)]); if (value != configFlagEnabled && value != configFlagDisabled) configNode.removeProperty (configNode.getPropertyName(i), getUndoManagerFor (configNode)); } }
void CtrlrPanelCanvas::copyWithChildren(CtrlrComponent *c) { if (c) { ValueTree clipboardTree("groupTree"); ValueTree groupTree = c->getOwner().getObjectTree().createCopy(); Array<CtrlrComponent*> children = c->getOwnedChildren(); for (int i=0; i<children.size(); i++) { ValueTree childTreeCopy = children[i]->getOwner().getObjectTree().createCopy(); childTreeCopy.removeProperty(Ids::vstIndex, nullptr); groupTree.addChild (childTreeCopy, -1, 0); } clipboardTree.addChild (groupTree, -1, 0); SystemClipboard::copyTextToClipboard (XML2STR(clipboardTree)); } }
void DrawableShape::RelativeFillType::writeTo (ValueTree& v, ComponentBuilder::ImageProvider* imageProvider, UndoManager* undoManager) const { if (fill.isColour()) { v.setProperty (FillAndStrokeState::type, "solid", undoManager); v.setProperty (FillAndStrokeState::colour, String::toHexString ((int) fill.colour.getARGB()), undoManager); } else if (fill.isGradient()) { v.setProperty (FillAndStrokeState::type, "gradient", undoManager); v.setProperty (FillAndStrokeState::gradientPoint1, gradientPoint1.toString(), undoManager); v.setProperty (FillAndStrokeState::gradientPoint2, gradientPoint2.toString(), undoManager); v.setProperty (FillAndStrokeState::gradientPoint3, gradientPoint3.toString(), undoManager); const ColourGradient& cg = *fill.gradient; v.setProperty (FillAndStrokeState::radial, cg.isRadial, undoManager); String s; for (int i = 0; i < cg.getNumColours(); ++i) s << ' ' << cg.getColourPosition (i) << ' ' << String::toHexString ((int) cg.getColour(i).getARGB()); v.setProperty (FillAndStrokeState::colours, s.trimStart(), undoManager); } else if (fill.isTiledImage()) { v.setProperty (FillAndStrokeState::type, "image", undoManager); if (imageProvider != nullptr) v.setProperty (FillAndStrokeState::imageId, imageProvider->getIdentifierForImage (fill.image), undoManager); if (fill.getOpacity() < 1.0f) v.setProperty (FillAndStrokeState::imageOpacity, fill.getOpacity(), undoManager); else v.removeProperty (FillAndStrokeState::imageOpacity, undoManager); } else { jassertfalse; } }
bool ValueTreeSynchroniser::applyChange (ValueTree& root, const void* data, size_t dataSize, UndoManager* undoManager) { MemoryInputStream input (data, dataSize, false); const ValueTreeSynchroniserHelpers::ChangeType type = (ValueTreeSynchroniserHelpers::ChangeType) input.readByte(); if (type == ValueTreeSynchroniserHelpers::fullSync) { root = ValueTree::readFromStream (input); return true; } ValueTree v (ValueTreeSynchroniserHelpers::readSubTreeLocation (input, root)); if (! v.isValid()) return false; switch (type) { case ValueTreeSynchroniserHelpers::propertyChanged: { Identifier property (input.readString()); v.setProperty (property, var::readFromStream (input), undoManager); return true; } case ValueTreeSynchroniserHelpers::propertyRemoved: { Identifier property (input.readString()); v.removeProperty (property, undoManager); return true; } case ValueTreeSynchroniserHelpers::childAdded: { const int index = input.readCompressedInt(); v.addChild (ValueTree::readFromStream (input), index, undoManager); return true; } case ValueTreeSynchroniserHelpers::childRemoved: { const int index = input.readCompressedInt(); if (isPositiveAndBelow (index, v.getNumChildren())) { v.removeChild (index, undoManager); return true; } jassertfalse; // Either received some corrupt data, or the trees have drifted out of sync break; } case ValueTreeSynchroniserHelpers::childMoved: { const int oldIndex = input.readCompressedInt(); const int newIndex = input.readCompressedInt(); if (isPositiveAndBelow (oldIndex, v.getNumChildren()) && isPositiveAndBelow (newIndex, v.getNumChildren())) { v.moveChild (oldIndex, newIndex, undoManager); return true; } jassertfalse; // Either received some corrupt data, or the trees have drifted out of sync break; } default: jassertfalse; // Seem to have received some corrupt data? break; } return false; }