Image CtrlrLuaMethodEditor::getIconForItem (const ValueTree &item) const { if (item.hasType (Ids::luaMethod)) { if ((int)item.getProperty (Ids::luaMethodSource) == (int)CtrlrLuaMethod::codeInProperty) { return (IMAGE(ico_unit_png)); } if ((int)item.getProperty (Ids::luaMethodSource) == (int)CtrlrLuaMethod::codeInFile) { if (File(item.getProperty(Ids::luaMethodSourcePath)).existsAsFile()) { return (IMAGE(ico_file_png)); } else { return (IMAGE(ico_unknown_png)); } } } else if (item.hasType (Ids::luaMethodGroup)) { return (IMAGE(ico_folder_png)); } else if (item.hasType (Ids::luaManagerMethods)) { return (IMAGE(ico_box_png)); } return (IMAGE(ico_unknown_png)); }
void CtrlrMIDILibrary::valueTreePropertyChanged (ValueTree &treeWhosePropertyHasChanged, const Identifier &property) { if (!treeWhosePropertyHasChanged.hasType(Ids::midiLibrary)) return; if (property == Ids::midiLibraryBank) { setCurrentBank(Uuid(getProperty(property))); } else if (property == Ids::midiLibraryProgram) { setCurrentProgram (Uuid(getProperty(property)), InheritFromLibrary); } else if (property == Ids::midiLibrarySnapshot) { setCurrentSnapshot (Uuid(getProperty(property)), InheritFromLibrary); } else if ((property == Ids::lsb || property == Ids::msb) && treeWhosePropertyHasChanged.hasType (Ids::midiLibraryBank)) { BigInteger bi; bi.setBitRangeAsInt (0, 7, (int)treeWhosePropertyHasChanged.getProperty(Ids::lsb)); bi.setBitRangeAsInt (7, 7, (int)treeWhosePropertyHasChanged.getProperty(Ids::msb)); treeWhosePropertyHasChanged.setProperty (Ids::value, (int)bi.getBitRangeAsInt (0, 14), nullptr); } }
const Font CtrlrLuaMethodEditor::getItemFont(const ValueTree &item) const { if (item.hasType(Ids::luaManagerMethods) || item.hasType(Ids::luaMethodGroup)) { return (Font (14.0, Font::bold)); } return (Font(12.0f, Font::plain)); }
const bool CtrlrLuaMethodEditor::isInterestedInDragSource(const ValueTree &item, const DragAndDropTarget::SourceDetails &dragSourceDetails) const { if (item.hasType(Ids::luaMethodGroup) || item.hasType(Ids::luaManagerMethods)) { return (true); } return (false); }
static int compareElements (const ValueTree& first, const ValueTree& second) { const bool firstIsGroup = first.hasType (Ids::GROUP); const bool secondIsGroup = second.hasType (Ids::GROUP); if (firstIsGroup == secondIsGroup) return first [Ids::name].toString().compareNatural (second [Ids::name].toString()); return firstIsGroup ? -1 : 1; }
static int compareElements (const ValueTree& first, const ValueTree& second) { const bool firstIsGroup = first.hasType (Tags::group); const bool secondIsGroup = second.hasType (Tags::group); if (firstIsGroup == secondIsGroup) return first [Ids::name].toString().compareIgnoreCase (second [Ids::name].toString()); else return firstIsGroup ? -1 : 1; }
bool CtrlrMIDILibrary::isItem(const ValueTree item) { if (item.hasType (Ids::midiLibraryProgram) || item.hasType (Ids::midiLibraryData) || item.hasType (Ids::midiLibraryFirmware) || item.hasType (Ids::midiLibraryEditBuffer)) { return (true); } return (false); }
bool CtrlrMIDILibrary::isContainer(const ValueTree item) { if (item.hasType(Ids::midiLibrary) || item.hasType(Ids::midiLibraryBank) || item.hasType(Ids::midiLibrarySnapshots) || item.hasType(Ids::midiLibraryTransactions)) { return (true); } return (false); }
void CtrlrPanelCanvas::pasteGroupComponent(const ValueTree &groupTree, const int destinationX, const int destinationY) { if (groupTree.hasType ("groupTree")) { CtrlrComponent *parent = addNewComponent (groupTree.getChild(0), 0, true); if (destinationX >= 0 && destinationY >= 0) parent->setTopLeftPosition (destinationX, destinationY); else parent->setTopLeftPosition (parent->getX()+(parent->getWidth()/2), parent->getY()+(parent->getHeight()/2)); CtrlrGroup *group = dynamic_cast<CtrlrGroup*>(parent); CtrlrTabsComponent *tabs = dynamic_cast<CtrlrTabsComponent*>(parent); for (int i=0; i<groupTree.getChild(0).getNumChildren(); i++) { if (groupTree.getChild(0).getChild(i).hasType(Ids::modulator)) { CtrlrComponent *child = addNewComponent (groupTree.getChild(0).getChild(i), 0, true); if (group && child) { group->setOwned(child, true); } if (tabs && child) { tabs->setOwned(child, child->getProperty(Ids::componentTabId), true); } } } } }
void CtrlrPanel::setProgram(ValueTree programTree, const bool sendSnapshotNow) { ValueTree program; if (programTree.hasType(Ids::panelState)) { program = programTree; } else { if (programTree.getChildWithName(Ids::panelState).isValid()) { program = programTree.getChildWithName(Ids::panelState); } } setProgramState (true); if (program.isValid()) { for (int i=0; i<program.getNumChildren(); i++) { if (program.getChild(i).hasType(Ids::value)) { CtrlrModulator *m = getModulator (program.getChild(i).getProperty(Ids::name)); if (m) { m->setRestoreState (true); m->getProcessor().setValueFromGUI (program.getChild(i).getProperty(Ids::value), true); if (m->getComponent()) { m->getComponent()->setComponentValue (program.getChild(i).getProperty(Ids::value), false); } m->getProcessor().handleUpdateNowIfNeeded(); m->setRestoreState (false); } } } if ((bool)getProperty (Ids::panelMidiSnapshotAfterProgramChange) == true) { snapshot.sendSnapshot(); } if (luaPanelProgramChangedCbk && !luaPanelProgramChangedCbk.wasObjectDeleted()) { if (luaPanelProgramChangedCbk->isValid()) { getCtrlrLuaManager().getMethodManager().call (luaPanelProgramChangedCbk); } } } setProgramState (false); if (sendSnapshotNow) { _DBG("CtrlrPanel::setProgram sendSnapshotNow"); sendSnapshot(); } }
//============================================================================== void UnityProjectBuilder::recurseGroup (ValueTree group, const File& sourceDir) { logOutput ("Recursing group \"" + group.getProperty (Ids::nameProp).toString() + "\"..."); const int numChildren = group.getNumChildren(); for (int i = 0; i < numChildren; ++i) { ValueTree child (group.getChild (i)); if (child.hasType (Ids::group)) recurseGroup (child, sourceDir); else if (child.hasType (Ids::file)) parseFile (child, sourceDir); } }
//============================================================================== Result Project::loadDocument (const File& file) { ScopedPointer<XmlElement> xml (XmlDocument::parse (file)); if (xml == nullptr || ! xml->hasTagName (Ids::JUCERPROJECT.toString())) return Result::fail ("Not a valid Jucer project!"); ValueTree newTree (ValueTree::fromXml (*xml)); if (! newTree.hasType (Ids::JUCERPROJECT)) return Result::fail ("The document contains errors and couldn't be parsed!"); registerRecentFile (file); enabledModulesList = nullptr; projectRoot = newTree; removeDefunctExporters(); setMissingDefaultValues(); updateOldModulePaths(); setChangedFlag (false); if (! ProjucerApplication::getApp().isRunningCommandLine) warnAboutOldProjucerVersion(); return Result::ok(); }
bool CtrlrMIDILibrary::transactionCanHandle(const ValueTree &transactionState, const ValueTree transactionItem) { if (transactionState.isValid() && transactionState.hasType(Ids::trans)) { if (luaTransInfoCbk) { if (luaTransInfoCbk->isValid()) { const int ret = owner.getCtrlrLuaManager().getMethodManager().callWithRet (luaTransInfoCbk, transactionState, transactionItem); if (ret < 0) { _WRN("CtrlrMIDILibrary::transactionCanHandle luaTransInfoCbk defined but failed to execute"); } else { return (ret ? true : false); } } } else { return (transactionCanHandleType(transactionState, transactionItem)); } } return (false); }
bool CtrlrMIDILibrary::isTransaction(const ValueTree item) { if (item.hasType(Ids::trans)) return (true); return (false); }
void KeyItem::removeLayer (int index) { LayerItem layer (getLayer (index)); if (layer.isValid()) { const bool updateIndexes = (layer.index() < countLayers()); objectData.removeChild (layer.node(), nullptr); #if 1 if (updateIndexes) { int index = 0; for (int i = 0; i < objectData.getNumChildren(); ++i) { ValueTree v (objectData.getChild(i)); if (! v.hasType(Tags::layer)) continue; LayerItem l (v); if (l.isValid()) { if (l.index() != index) l.node().setProperty (Slugs::index, index, nullptr); ++index; } } } #endif } }
// Value tree GUI stuff const String CtrlrLuaMethodEditor::getUniqueName (const ValueTree &item) const { if (item.hasType (Ids::luaMethod)) { return (item.getProperty(Ids::luaMethodName).toString()); } if (item.hasType(Ids::luaMethodGroup)) { return (item.getProperty (Ids::name).toString()); } if (item.hasType(Ids::luaManagerMethods)) { return ("LUA"); } return ("Unknown"); }
Project::Item Project::Item::getOrCreateSubGroup (const String& name) { for (int i = state.getNumChildren(); --i >= 0;) { const ValueTree child (state.getChild (i)); if (child.getProperty (Ids::name) == name && child.hasType (Tags::group)) return Item (project, child); } return addNewSubGroup (name, -1); }
void KeyItem::clearLayers() { for (int32 i = getNumChildren(); --i >= 0;) { ValueTree vt = objectData.getChild (i); if (vt.hasType (Tags::layer)) { objectData.removeChild (vt, nullptr); } } }
void CtrlrManager::restoreState (const ValueTree &savedTree) { if (savedTree.isValid()) { ctrlrManagerRestoring = true; restoreProperties (savedTree, managerTree); if (owner->getOverrides().isValid()) { for (int i=0; i<owner->getOverrides().getNumProperties(); i++) { setProperty (owner->getOverrides().getPropertyName(i), owner->getOverrides().getPropertyAsValue(owner->getOverrides().getPropertyName(i), 0)); } } managerTree.removeAllChildren (0); managerTree.addChild (ctrlrMidiDeviceManager.getManagerTree(), -1, 0); managerTree.addChild (ctrlrWindowManager.getManagerTree(), -1, 0); if (savedTree.getChildWithName(Ids::midiDeviceManager).isValid()) { ctrlrMidiDeviceManager.restoreState (savedTree.getChildWithName(Ids::midiDeviceManager)); } if (savedTree.getChildWithName(Ids::uiWindowManager).isValid()) { ctrlrWindowManager.restoreState (savedTree.getChildWithName(Ids::uiWindowManager)); } if (getInstanceMode() != InstanceMulti && savedTree.hasType (Ids::panelState)) { restoreInstanceState (savedTree); return; } for (int i=0; i<savedTree.getNumChildren(); i++) { if (savedTree.getChild(i).hasType (Ids::panel)) { addPanel (savedTree.getChild(i)); } } if (ctrlrEditor) { restoreEditorState(); } ctrlrManagerRestoring = false; } }
void CtrlrLuaMethodEditor::itemDropped (ValueTree &targetItem, const DragAndDropTarget::SourceDetails &dragSourceDetails, int insertIndex) { if ( (targetItem.hasType(Ids::luaMethodGroup) || targetItem.hasType(Ids::luaManagerMethods)) && insertIndex == 0 ) { StringArray ar; ar.addTokens (dragSourceDetails.description.toString(), ";", "\"'"); for (int i=0; i<ar.size(); i++) { CtrlrValueTreeEditorItem *sourceItem = dynamic_cast<CtrlrValueTreeEditorItem*>(methodTree->findItemFromIdentifierString (ar[i])); if (sourceItem != nullptr) { ValueTree child = sourceItem->getTree(); ValueTree parent = child.getParent(); parent.removeChild (child, nullptr); targetItem.addChild (child, -1, nullptr); } } triggerAsyncUpdate(); } }
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); } }
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 CtrlrPanelComponentProperties::valueTreePropertyChanged (ValueTree &treeWhosePropertyHasChanged, const Identifier &property) { if (owner.getSelection() == nullptr) return; for (int i=0; i<owner.getSelection()->getNumSelected(); i++) { if (treeWhosePropertyHasChanged.hasType (Ids::modulator)) { owner.getSelection()->getSelectedItem(i)->getOwner().setProperty (property, treeWhosePropertyHasChanged.getPropertyAsValue(property, 0)); } if (treeWhosePropertyHasChanged.hasType (Ids::component)) { owner.getSelection()->getSelectedItem(i)->setProperty (property, treeWhosePropertyHasChanged.getPropertyAsValue(property, 0)); } if (treeWhosePropertyHasChanged.hasType (Ids::midi)) { if (owner.getSelection()->getSelectedItem(i)->getOwner().getMidiMessagePtr()) { owner.getSelection()->getSelectedItem(i)->getOwner().getMidiMessage().setProperty (property, treeWhosePropertyHasChanged.getPropertyAsValue(property, 0)); } } } }
void CtrlrPanel::setInstanceProperties(const ValueTree &instanceState) { // _DBG("CtrlrPanel::setInstanceProperties "+instanceState.getType().toString()); /* here we need to set all the MIDI properties for the instance */ if (instanceState.hasType (Ids::panelState)) { for (int i=0; i<instanceState.getNumProperties(); i++) { if (instanceState.getPropertyName(i).toString().startsWith ("panelMidi")) { // _DBG("\t"+instanceState.getPropertyName(i).toString()); setProperty (instanceState.getPropertyName(i), instanceState.getProperty(instanceState.getPropertyName(i))); } } } }
void CtrlrMIDILibrary::attachItemToPopupMenu(const ValueTree &itemToAttach, PopupMenu &m, int &itemOffset) { if (isContainer (itemToAttach)) { PopupMenu subMenu; for (int topLevelIndex=0; topLevelIndex<itemToAttach.getNumChildren(); topLevelIndex++) { attachItemToPopupMenu (itemToAttach.getChild(topLevelIndex), subMenu, itemOffset); } m.addSubMenu (itemToAttach.getProperty(Ids::name).toString(), subMenu, true); } else { m.addItem (itemOffset++, itemToAttach.getProperty(Ids::name).toString(), (!itemToAttach.hasType(Ids::midiLibraryData) && (bool)itemToAttach.getProperty(Ids::midiLibraryCanSendItem)), isCurrentProgram(itemToAttach)); } }
//============================================================================== const String Project::loadDocument (const File& file) { ScopedPointer <XmlElement> xml (XmlDocument::parse (file)); if (xml == nullptr || ! xml->hasTagName (Tags::projectRoot.toString())) return "Not a valid Jucer project!"; ValueTree newTree (ValueTree::fromXml (*xml)); if (! newTree.hasType (Tags::projectRoot)) return "The document contains errors and couldn't be parsed!"; StoredSettings::getInstance()->recentFiles.addFile (file); StoredSettings::getInstance()->flush(); projectRoot = newTree; setMissingDefaultValues(); return String::empty; }
Result Project::loadDocument (const File& file) { ScopedPointer <XmlElement> xml (XmlDocument::parse (file)); if (xml == nullptr || ! xml->hasTagName (Tags::projectRoot.toString())) return Result::fail ("Not a valid Jucer project!"); ValueTree newTree (ValueTree::fromXml (*xml)); if (! newTree.hasType (Tags::projectRoot)) return Result::fail ("The document contains errors and couldn't be parsed!"); registerRecentFile (file); projectRoot = newTree; removeDefunctExporters(); setMissingDefaultValues(); setChangedFlag (false); return Result::ok(); }
void CtrlrLuaMethodEditor::addNewGroup(ValueTree parentGroup) { AlertWindow wnd(GROUP_NEW, String::empty, AlertWindow::InfoIcon, this); wnd.addTextEditor ("groupName", "New Group", "Group name", false); wnd.addButton ("OK", 1, KeyPress(KeyPress::returnKey)); wnd.addButton ("Cancel", 0, KeyPress(KeyPress::escapeKey)); if (wnd.runModalLoop()) { if (parentGroup.hasType (Ids::luaMethodGroup)) { getMethodManager().addGroup (wnd.getTextEditorContents("groupName"), parentGroup.getProperty(Ids::uuid).toString()); } else { getMethodManager().addGroup (wnd.getTextEditorContents("groupName")); } } updateRootItem(); saveSettings(); // save settings }
void ZenAudioProcessorValueTreeState::valueTreeChildRemoved(ValueTree& parent, ValueTree& tree, int) { if (parent == state && tree.hasType(valueType)) updateParameterConnectionsToChildTrees(); }
void ZenAudioProcessorValueTreeState::valueTreePropertyChanged(ValueTree& tree, const Identifier& prop) { if (prop == idPropertyID && tree.hasType(valueType) && tree.getParent() == state) updateParameterConnectionsToChildTrees(); }