static void getValueTreePath (ValueTree v, const ValueTree& topLevelTree, Array<int>& path) { while (v != topLevelTree) { ValueTree parent (v.getParent()); if (! parent.isValid()) break; path.add (parent.indexOf (v)); v = parent; } }
static void sortGroup (ValueTree& state, bool keepGroupsAtStart, UndoManager* undoManager) { if (keepGroupsAtStart) { ItemSorterWithGroupsAtStart sorter; state.sort (sorter, undoManager, true); } else { ItemSorter sorter; state.sort (sorter, undoManager, true); } }
ValueTree AudioProcessorValueTreeState::getOrCreateChildValueTree (const String& paramID) { ValueTree v (state.getChildWithProperty (idPropertyID, paramID)); if (! v.isValid()) { v = ValueTree (valueType); v.setProperty (idPropertyID, paramID, undoManager); state.addChild (v, -1, undoManager); } return v; }
void StoredSettings::RestoreProperty(const Identifier& CategoryName, const Identifier& PropertyName, Value& Val) { ValueTree tree = (CategoryName == Identifiers::Category1) ? tree_root : tree_root.getOrCreateChildWithName(CategoryName, nullptr); if(!tree.hasProperty(PropertyName)){ //If there isn't one then set a new one. //プロパティーが存在しなければ、設定する tree.setProperty(PropertyName, Val, nullptr); }else{ //If the property already exists then just return it. //存在していれば、そのプロパティーを参照する Val.referTo(tree.getPropertyAsValue(PropertyName, nullptr)); } }
void TrackInfo::loadTrackInfo(ValueTree tags) { if (tags.hasType("ITEM")) { title.setText (tags.getProperty(MusicColumns::columnNames[MusicColumns::Song].toString(), 0),dontSendNotification); artist.setText (tags.getProperty(MusicColumns::columnNames[MusicColumns::Artist].toString(), 0),dontSendNotification); album.setText (tags.getProperty(MusicColumns::columnNames[MusicColumns::Album].toString(), 0),dontSendNotification); } else { title.setText ("Song Title",dontSendNotification); artist.setText ("Artist",dontSendNotification); album.setText("Album", dontSendNotification); } }
ApiCollection::ClassCollection::ClassCollection(const ValueTree &api) : classApi(api), name(api.getType().toString()) { for (int i = 0; i < api.getNumChildren(); i++) { items.add(new MethodItem(api.getChild(i), name)); addAndMakeVisible(items.getLast()); } }
Value AppearanceSettings::getColourValue (const String& colourName) { ValueTree c (settings.getChildWithProperty (Ids::name, colourName)); if (! c.isValid()) { c = ValueTree ("COLOUR"); c.setProperty (Ids::name, colourName, nullptr); settings.addChild (c, -1, nullptr); } return c.getPropertyAsValue (Ids::colour, nullptr); }
void UnityProjectBuilder::parseFile (ValueTree file, const File& sourceDir) { const String path (file.getProperty (Ids::fileProp).toString()); const File sourceFile (projectFile.getSiblingFile (path)); const bool compile = bool (file.getProperty (Ids::compileProp)); if (compile && isValidSourceFile (sourceFile)) { file.setProperty (Ids::compileProp, false, nullptr); filesToAdd.add (sourceFile.getRelativePathFrom (sourceDir)); logOutput ("Adding file \"" + path + "\"..."); } }
void ScopeSync::applyConfiguration() { DBG("ScopeSync::applyConfiguration"); #ifdef __DLL_EFFECT__ scopeSyncAsync.toggleUpdateProcessing(false); #endif parameterController->toggleAsyncUpdates(false); setGUIEnabled(false); parameterController->endAllParameterChangeGestures(); systemError = String::empty; systemErrorDetails = String::empty; if (ScopeSyncApplication::inPluginContext()) parameterController->storeParameterValues(); parameterController->reset(); // Firstly create the BCMParameter entries for each of the Host Parameters ValueTree parameterTree = configuration->getParameters(); for (int i = 0; i < parameterTree.getNumChildren(); i++) parameterController->addParameter(parameterTree.getChild(i)); parameterController->setupHostParameters(); #ifndef __DLL_EFFECT__ pluginProcessor->updateHostDisplay(); #endif // __DLL_EFFECT__ #ifndef __DLL_EFFECT__ parameterController->restoreParameterValues(); #else scopeSyncAsync.snapshot(); scopeSyncAsync.toggleUpdateProcessing(true); #endif // __DLL_EFFECT__ UserSettings::getInstance()->updateConfigurationLibraryEntry(getConfigurationFile().getFullPathName(), getConfigurationFile().getFileName(), getConfigurationRoot()); setGUIReload(true); if (configurationManagerWindow != nullptr) { configurationManagerWindow->refreshContent(); configurationManagerWindow->restoreWindowPosition(); } parameterController->toggleAsyncUpdates(true); }
ValueTree SAMCompiler::getWgForJunct(ValueTree waveguides, ValueTree j) { ValueTree wgs(Objects::waveguides); for (int i = 0; i < waveguides.getNumChildren(); ++i) { ValueTree w = waveguides.getChild(i); if (w[Ids::startVertex] == j[Ids::identifier] || w[Ids::endVertex] == j[Ids::identifier]) { wgs.addChild(w.createCopy(), -1, nullptr); } } return wgs; }
void CtrlrPanelCanvas::replaceComponent (CtrlrModulator &modulator, const String &targetComponentType) { CtrlrComponent *oldComponent = modulator.getComponent(); CtrlrComponent *newComponent = nullptr; /* detach the existing component so it doesn't get notified about anything, the pointer will be invalid */ if (getOwner().getSelection()) { getOwner().getSelection()->deselectAll(); getOwner().getSelection()->dispatchPendingMessages(); getOwner().getSelection()->removeChangeListener(oldComponent); } if (oldComponent) { /* keep a copy of the old properties, we need to find out if the component is in a group */ ValueTree oldComponentProperties = oldComponent->getObjectTree().createCopy(); modulator.setComponentType(targetComponentType, false); /* get the new component pointer and attach it */ newComponent = modulator.getComponent(); if (getOwner().getSelection()) getOwner().getSelection()->addChangeListener (newComponent); addAndMakeVisibleNg (modulator.getComponent(), nullptr, true); /* attach the new component to any group components the old component was int */ if (oldComponentProperties.hasProperty(Ids::componentGroupName)) { CtrlrGroup *group = dynamic_cast<CtrlrGroup*>(owner.getOwner().getComponent(oldComponentProperties.getProperty(Ids::componentGroupName))); if (group) { group->setOwned (newComponent, true); } } if (oldComponentProperties.hasProperty(Ids::componentTabName)) { CtrlrTabsComponent *tabs = dynamic_cast<CtrlrTabsComponent*>(owner.getOwner().getComponent(oldComponentProperties.getProperty(Ids::componentTabName))); if (tabs) { tabs->setOwned (newComponent, oldComponentProperties.getProperty(Ids::componentTabId), true); } } /* copy any old properties to the new component */ for (int i=0; i<oldComponentProperties.getNumProperties(); i++) { const Identifier propName = oldComponentProperties.getPropertyName(i); const var propValue = oldComponentProperties.getProperty(propName); if (propName != Ids::uiType) { if (newComponent->getObjectTree().hasProperty(propName)) newComponent->setProperty (propName, propValue); } } } }
ValueTree ScannerManagerComponent::getForDocument() { ValueTree data ("SCANNERS"); for (unsigned i = 0; i < cues.size(); i++) { ValueTree cue ("CUE"); cue.setProperty ("x", cues[i]->getPosition(), nullptr); data.addChild (cue, i, nullptr); } return data; }
void Project::removeDefunctExporters() { ValueTree exporters (projectRoot.getChildWithName (Tags::exporters)); for (;;) { ValueTree oldVC6Exporter (exporters.getChildWithName ("MSVC6")); if (oldVC6Exporter.isValid()) exporters.removeChild (oldVC6Exporter, nullptr); else break; } }
bool MDLHelper::addOutputDSPVarIfNotExists(const MDLFile& mdlFile) { ValueTree mdlRoot = mdlFile.getMDLRoot(); bool outputDSPExists = false; ValueTree fcb = mdlRoot.getOrCreateChildWithName(Objects::faustcodeblock, nullptr); for (int i = 0; i < fcb.getNumChildren(); ++i) { ValueTree fc = fcb.getChild(i); if (fc.hasProperty(Ids::value)) { String fcStr = fc[Ids::value].toString(); if (fcStr.startsWith("outputDSP")) { outputDSPExists = true; break; } } } if (!outputDSPExists) { ValueTree fc(Ids::faustcode); fc.setProperty(Ids::value, "outputDSP=SAMlimiter:highpass(4,20.0);", nullptr); fcb.addChild(fc, -1, nullptr); return true; } return false; }
StringArray AppearanceSettings::getColourNames() const { StringArray s; for (int i = 0; i < settings.getNumChildren(); ++i) { const ValueTree c (settings.getChild(i)); if (c.hasType ("COLOUR")) s.add (c [Ids::name]); } return s; }
void CtrlrComponent::restoreState (const ValueTree &savedState) { restoreStateInProgress = true; restoreProperties (savedState, componentTree, nullptr); for (int i=0; i<savedState.getNumChildren(); i++) { componentTree.addChild (savedState.getChild(i).createCopy(), -1, 0); } restoreStateInProgress = false; resized(); }
ValueTree CtrlrMIDILibrary::scanChildrenForMenuIndex(ValueTree item, int itemIndexToFind, int ¤tIndex) { _DBG("CtrlrMIDILibrary::scanChildrenForMenuIndex"); if (isContainer (item)) { _DBG("\tcontainer ["+item.getType().toString()+"]"); ValueTree child; for (int topLevelIndex=0; topLevelIndex<item.getNumChildren(); topLevelIndex++) { child = scanChildrenForMenuIndex (item.getChild(topLevelIndex), itemIndexToFind, currentIndex); if (child.isValid()) { _DBG("\t\tvalid child found ["+child.getType().toString()+"] parent:["+child.getParent().getType().toString()+"]"); return (child); } currentIndex++; } } if (itemIndexToFind == currentIndex) { _DBG("\t\titemIndexToFind == currentIndex ["+item.getType().toString()+"]"); return (item); } else { return (ValueTree()); } }
void CtrlrMIDILibrary::addNewProgram (const String programName, const int number, ValueTree unitToAddTo) { ValueTree program = createEmptyProgramTree(); program.addChild (owner.getProgram(), -1, nullptr); program.setProperty (Ids::name, getDefaultProgramName(programName), nullptr); program.setProperty (Ids::description, String::empty, nullptr); program.setProperty (Ids::number, getCurrentProgramMIDINumber(number), nullptr); program.setProperty (Ids::uuid, Uuid().toString(), nullptr); if (unitToAddTo.isValid()) { unitToAddTo.addChild (program, -1, 0); } else { if (isBank(getCurrentBank())) { getCurrentBank().addChild (program, -1, 0); } else { getRoot().addChild (program, -1, 0); } } listeners.call (&CtrlrMIDILibrary::Listener::programListChanged); }
const bool CtrlrLuaMethodEditor::canBeRenamed(const ValueTree &item) const { if ( item.getType() == Ids::luaMethod && ((int)item.getProperty(Ids::luaMethodSource) == CtrlrLuaMethod::codeInProperty) ) { return (true); } if (item.getType() == Ids::luaMethodGroup) { return (true); } return (false); }
LayerItem KeyItem::addLayer (const File& file) { const int layerIndex = countLayers(); ValueTree layerNode (Tags::layer); layerNode.setProperty (Slugs::index, layerIndex, nullptr); layerNode.setProperty (Slugs::file, file.getFullPathName(), nullptr); layerNode.setProperty (Slugs::name, file.getFileNameWithoutExtension(), nullptr); layerNode.setProperty (Slugs::note, getNote(), nullptr); LayerItem layer (layerNode); objectData.addChild (layerNode, layerIndex, nullptr); return layer; }
void CtrlrMIDILibrary::deleteCurrentSnapshot() { if (getCurrentSnapshot().isValid()) { ValueTree parent = getCurrentSnapshot().getParent(); if (parent.isValid()) { parent.removeChild (getCurrentSnapshot(), nullptr); currentSnapshot = ValueTree(); } listeners.call (&CtrlrMIDILibrary::Listener::programListChanged); } }
void CtrlrMIDILibrary::deleteCurrentBank() { if (isBank (getCurrentBank()) && getRoot() != getCurrentBank()) { ValueTree parent = getCurrentBank().getParent(); if (parent.isValid()) { parent.removeChild (getCurrentBank(), nullptr); setProperty (Ids::midiLibraryBank, String::empty, false); } listeners.call (&CtrlrMIDILibrary::Listener::programListChanged); } }
StaticStreamViewport::ContentComponent::ContentComponent(ValueTree tree_,CriticalSection &lock_, WorkbenchClient* client_) : tree(tree_), lock(lock_) { int i; setOpaque(true); for (i = 0; i < tree_.getNumChildren(); ++i) { StaticStreamComponent* comp = new StaticStreamComponent(tree_.getChild(i), lock_, this, client_); addAndMakeVisible(comp); streamBoxes.add(comp); } }
void CtrlrLuaMethodEditor::renameGroup(ValueTree parentGroup) { AlertWindow w ("Rename group", "", AlertWindow::QuestionIcon, this); w.addTextEditor("name", parentGroup.getProperty (Ids::name).toString()); w.addButton ("OK", 1, KeyPress(KeyPress::returnKey)); w.addButton ("Cancel", 0, KeyPress(KeyPress::escapeKey)); if (w.runModalLoop()) { parentGroup.setProperty (Ids::name, w.getTextEditorContents("name"), nullptr); updateRootItem(); } saveSettings(); // save settings }
string& ValueTree::insertValue(const string& spec) { size_t dotPos = spec.find_last_of('.'); ValueTree* tree = this; string key = spec; if(dotPos != string::npos) { tree = insertSubTree(spec.substr(0, dotPos)); key = spec.substr(dotPos+1); } StrList& list = tree->attr(key); if(!list.size()) list.push_back(""); return list[0]; }
void ComponentBuilder::updateChildComponents (Component& parent, const ValueTree& children) { using namespace ComponentBuilderHelpers; const int numExistingChildComps = parent.getNumChildComponents(); Array <Component*> componentsInOrder; componentsInOrder.ensureStorageAllocated (numExistingChildComps); { OwnedArray<Component> existingComponents; existingComponents.ensureStorageAllocated (numExistingChildComps); int i; for (i = 0; i < numExistingChildComps; ++i) existingComponents.add (parent.getChildComponent (i)); const int newNumChildren = children.getNumChildren(); for (i = 0; i < newNumChildren; ++i) { const ValueTree childState (children.getChild (i)); ComponentBuilder::TypeHandler* const type = getHandlerForState (childState); jassert (type != nullptr); if (type != nullptr) { Component* c = findComponentWithID (existingComponents, getStateId (childState)); if (c == nullptr) c = createNewComponent (*type, childState, &parent); componentsInOrder.add (c); } } // (remaining unused items in existingComponents get deleted here as it goes out of scope) } // Make sure the z-order is correct.. if (componentsInOrder.size() > 0) { componentsInOrder.getLast()->toFront (false); for (int i = componentsInOrder.size() - 1; --i >= 0;) componentsInOrder.getUnchecked(i)->toBehind (componentsInOrder.getUnchecked (i + 1)); } }
void Project::addModule (const String& moduleID, bool shouldCopyFilesLocally) { if (! isModuleEnabled (moduleID)) { ValueTree module (Tags::module); module.setProperty (Ids::ID, moduleID, nullptr); ValueTree modules (getModulesNode()); modules.addChild (module, -1, getUndoManagerFor (modules)); shouldShowAllModuleFilesInProject (moduleID) = true; } if (shouldCopyFilesLocally) shouldCopyModuleFilesLocally (moduleID) = true; }
Array<int> ObjController::checkIfObjectHasLinks(const ValueTree& objTree) const { Array<int> linkIndices; for (int i = 0; i < links.size(); i++) { const ValueTree linkTree = links.getUnchecked(i)->getData(); if(linkTree.getProperty(Ids::startVertex) == objTree.getProperty(Ids::identifier) || linkTree.getProperty(Ids::endVertex) == objTree.getProperty(Ids::identifier)) { linkIndices.add(i); } } return linkIndices; }
void Mixer::pruneRemotes(ValueTree active_users) { // find GUI elements for parted users for (int user_n = GUI::FIRST_REMOTE_IDX ; user_n < getNumDynamicMixers() ; ++user_n) { RemoteChannels* channels = (RemoteChannels*)getChildComponent(user_n) ; Identifier user_id = Identifier(channels->getComponentID()) ; Array<var>* active_channels = active_users[user_id].getArray() ; if (active_users.hasProperty(user_id)) { // find GUI elements for removed channels of active user (first is master) for (int channel_n = 1 ; channel_n < channels->getNumChannels() ; ++channel_n) { Component* channel = channels->getChildComponent(channel_n) ; var channel_id = var(channel->getComponentID()) ; if (active_channels->contains(channel_id)) continue ; // delete orphaned GUI elements for removed channel removeChannel(user_id , Identifier(channel_id.toString())) ; --channel_n ; } } // delete orphaned GUI elements for parted user else { removeChannels(channels) ; --user_n ; } } }
bool CtrlrMIDILibrary::isTransaction(const ValueTree item) { if (item.hasType(Ids::trans)) return (true); return (false); }