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); } } } }
void CtrlrPanelComponentProperties::refreshTargetModulationPropertyList (const ValueTree &sourceModulationTree) { CtrlrModulator *target = owner.getOwner().getModulator (sourceModulationTree.getProperty (Ids::modulatorLinkedToModulator)); if (target) { modulatorPropertyList.clear(); modulatorPropertyList.add (COMBO_NONE_ITEM); if ((bool)sourceModulationTree.getProperty (Ids::modulatorLinkedToComponent) == true) { CtrlrComponent *c = target->getComponent(); if (c) { for (int i=0; i<c->getComponentTree().getNumProperties(); i++) { modulatorPropertyList.add (c->getComponentTree().getPropertyName(i).toString()); } } } else { for (int i=0; i<target->getModulatorTree().getNumProperties(); i++) { modulatorPropertyList.add (target->getModulatorTree().getPropertyName(i).toString()); } } } }
void CtrlrPanelMIDISnapshot::gatherSnapshotData() { buffer.clear(); for (int i=0; i<owner.getModulators().size(); i++) { CtrlrModulator *m = owner.getModulators()[i]; if (m->getMidiMessagePtr()) { if (m->getComponent()) { if ((int)m->getComponent()->getProperty(Ids::componentRadioGroupId) > 0) { if (m->getComponent()->getToggleState() == false) continue; else if (!(bool)m->getProperty(Ids::modulatorExcludeFromSnapshot)) addCtrlrMidiMessageToBuffer (buffer, m->getMidiMessage()); } else if (!(bool)m->getProperty(Ids::modulatorExcludeFromSnapshot)) { addCtrlrMidiMessageToBuffer (buffer, m->getMidiMessage()); } } } } }
void CtrlrComponent::removeFromTab () { CtrlrModulator *tabsModulator = owner.getOwner().getModulator(getProperty(Ids::componentTabName)); if (tabsModulator) { CtrlrTabsComponent *tabsComponent = dynamic_cast<CtrlrTabsComponent*>(tabsModulator->getComponent()); if (tabsComponent) { tabsComponent->setOwned (this, getProperty(Ids::componentTabId), false); } } }
float CtrlrProcessor::getParameter (int index) { CtrlrModulator *m = ctrlrManager->getModulatorByVstIndex (index); if (m) { return (m->getProcessor().getValueForHost()); } else { return 0.0f; } }
int CtrlrManager::getModulatorVstIndexByName(const String &modulatorName) { CtrlrModulator *m = getModulator(modulatorName); if (m) { return (m->getVstIndex()); } else { return (-1); } }
//============================================================================== CtrlrLCDLabel::CtrlrLCDLabel (CtrlrModulator &owner) : CtrlrComponent(owner), ctrlrLabel (0) { addAndMakeVisible (ctrlrLabel = new Label ("ctrlrLabel", "LCD TEST")); ctrlrLabel->setFont (Font (16.0000f, Font::plain)); ctrlrLabel->setJustificationType (Justification::centred); ctrlrLabel->setEditable (false, false, false); ctrlrLabel->setColour (Label::backgroundColourId, Colour (0x0)); ctrlrLabel->setColour (Label::textColourId, Colours::black); ctrlrLabel->setColour (TextEditor::textColourId, Colours::black); ctrlrLabel->setColour (TextEditor::backgroundColourId, Colour (0x0)); //[UserPreSize] setBufferedToImage (true); ctrlrLabel->setBufferedToImage (true); owner.setProperty (Ids::modulatorIsStatic, true); owner.setProperty (Ids::modulatorVstExported, false); setProperty (Ids::uiLabelBgColour, "0xff000000"); setProperty (Ids::uiLabelTextColour, "0xff56c312"); setProperty (Ids::uiLabelOutline, 0); setProperty (Ids::uiLabelOutlineColour, "0x00000000"); setProperty (Ids::uiLabelJustification, "centred"); setProperty (Ids::uiLabelFitFont, false); setProperty (Ids::uiLCDLabelFont, 5); setProperty (Ids::uiLCDLabelFontHeight, 18); setProperty (Ids::uiLabelText, "Label text"); setProperty (Ids::uiLabelDisplaysAllValues, false); setProperty (Ids::uiLabelDisplayFormat, "%n(%N) = %v(%h)"); setProperty (Ids::uiLabelInputHighlightTextColour, "0xffffffff"); setProperty (Ids::uiLabelInputHighlightColour, "0xff0000ff"); setProperty (Ids::uiLabelEditOnSingleClick, false); setProperty (Ids::uiLabelEditOnDoubleClick, false); setProperty (Ids::uiLabelEditFocusDiscardsChanges, true); setProperty (Ids::uiLabelInputAllowedChars, ""); setProperty (Ids::uiLabelInputAllowedChars, ""); setProperty (Ids::uiLabelInputMaxLength, 1024); setProperty (Ids::uiLabelChangedCbk, COMBO_NONE_ITEM); componentTree.addListener (this); //[/UserPreSize] setSize (96, 32); //[Constructor] You can add your own custom stuff here.. //[/Constructor] }
//============================================================================== CtrlrToggleButton::CtrlrToggleButton (CtrlrModulator &owner) : CtrlrComponent(owner), ctrlrButton (0) { addAndMakeVisible (ctrlrButton = new ToggleButton ("ctrlrButton")); ctrlrButton->setButtonText ("Button"); ctrlrButton->addListener (this); //[UserPreSize] ctrlrButton->setBufferedToImage (true); setProperty (Ids::uiButtonTextColourOn, "0xff000000"); setProperty (Ids::uiToggleButtonFocusOutline, "0x00000000"); setProperty (Ids::uiToggleButtonText, "Button"); setProperty (Ids::uiButtonTrueValue, 1); setProperty (Ids::uiButtonFalseValue, 0); setProperty (Ids::uiButtonColourOff, "0xff0000ff"); owner.setProperty (Ids::modulatorMax, 1); owner.setProperty (Ids::modulatorMin, 0); //[/UserPreSize] setSize (88, 32); //[Constructor] You can add your own custom stuff here.. //owner.getProcessor().setValueFromGUI (0, true); //[/Constructor] }
CtrlrMidiKeyboard::CtrlrMidiKeyboard (CtrlrModulator &owner) : CtrlrComponent(owner), midiKeyboard (0) { addAndMakeVisible (midiKeyboard = new MidiKeyboardComponent (keyboardState, MidiKeyboardComponent::horizontalKeyboard )); midiKeyboard->setName ("midiKeyboard"); keyboardState.addListener (this); setProperty (Ids::uiMidiKeyboardOrientation, "horizontalKeyboard"); setProperty (Ids::uiMidiKeyboardWhiteButtonColour, "0xffffffff"); setProperty (Ids::uiMidiKeyboardBlackButtonColour, "0xff000000"); setProperty (Ids::uiMidiKeyboardSeparatorLineColour, "0xff000000"); setProperty (Ids::uiMidiKeyboardMouseOverColour, "0xffff0000"); setProperty (Ids::uiMidiKeyboardMouseDownColour, "0xff0000ff"); setProperty (Ids::uiMidiKeyboardTextLabelColour, "0xff000000"); setProperty (Ids::uiMidiKeyboardButtonBackgroundColour, "0xff0f0f0f"); setProperty (Ids::uiMidiKeyboardButtonArrowColour, "0xff000000"); setProperty (Ids::uiMidiKeyboardLowestVisibleKey, 48); setProperty (Ids::uiMidiKeyboardBaseOctaveKeyPress, 0); setProperty (Ids::uiMidiKeyboardOctaveFroMiddleC, 3); setProperty (Ids::uiMidiKeyboardMapToNoteNumber, false); setSize (256, 64); owner.getOwnerPanel().addPanelListener (this); midiKeyboard->setKeyPressBaseOctave( 5 ); midiKeyboard->setOctaveForMiddleC( 4 ); }
void CtrlrProcessor::setParameter (int index, float newValue) { CtrlrModulator *m = ctrlrManager->getModulatorByVstIndex (index); if (m == nullptr) { return; } else if (newValue > 1.0f || newValue < 0.000000f) { return; } else { return (m->getProcessor().setValueFromHost(newValue)); } }
//============================================================================== CtrlrGroup::CtrlrGroup (CtrlrModulator &owner) : CtrlrComponent(owner), content(*this), label (0) { addAndMakeVisible (label = new Label ("new label", "Group Text")); label->setFont (Font (14.0000f, Font::bold)); label->setJustificationType (Justification::centred); label->setEditable (false, false, false); label->setColour (TextEditor::textColourId, Colours::black); label->setColour (TextEditor::backgroundColourId, Colour (0x0)); //[UserPreSize] addAndMakeVisible(&content); componentTree.addListener (this); owner.setProperty (Ids::modulatorIsStatic, true); owner.setProperty (Ids::modulatorVstExported, false); setProperty (Ids::uiGroupText, "Group Text"); setProperty (Ids::uiGroupTextColour, "0xff000000"); setProperty (Ids::uiGroupOutlineColour1, "0xffa3a3a3"); setProperty (Ids::uiGroupOutlineColour2, "0xffffffff"); setProperty (Ids::uiGroupBackgroundColour1, "0xffa3a3a3"); setProperty (Ids::uiGroupBackgroundColour2, "0xffffffff"); setProperty (Ids::uiGroupOutlineGradientType, "Vertical"); setProperty (Ids::uiGroupBackgroundGradientType, 1); setProperty (Ids::uiGroupBackgroundImage, ""); setProperty (Ids::uiGroupBackgroundImageLayout, 36); setProperty (Ids::uiGroupBackgroundImageAlpha, 255); setProperty (Ids::uiGroupTextPlacement, "top"); setProperty (Ids::uiGroupTextFont, FONT2STR (Font(14))); setProperty (Ids::uiGroupOutlineThickness, 2.0); setProperty (Ids::uiGroupOutlineRoundAngle, 8.0); setProperty (Ids::uiGroupTextMargin, 0); setProperty (Ids::componentLabelVisible, false); owner.getModulatorTree().addListener (this); //[/UserPreSize] setSize (128, 128); //[Constructor] You can add your own custom stuff here.. //[/Constructor] }
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(); } }
CtrlrModulator *CtrlrPanel::createNewModulator(const Identifier &guiType) { CtrlrModulator *newModulator = nullptr; if (CtrlrComponentTypeManager::isStatic(guiType)) { newModulator = new CtrlrModulator (*this); } else { newModulator = new CtrlrModulator (*this, owner.getNextVstIndex()); } newModulator->setProperty (Ids::name, getUniqueModulatorName("modulator-1")); addModulator (newModulator); return (newModulator); }
void CtrlrPanelMIDISnapshot::gatherSnapshotData() { buffer.clear(); for (int i=0; i<owner.getModulators().size(); i++) { CtrlrModulator *m = owner.getModulators()[i]; if (m->getMidiMessagePtr()) { if (m->getComponent()) { if ((int)m->getComponent()->getProperty(Ids::componentRadioGroupId) > 0) { if (m->getComponent()->getToggleState() == false) continue; else if (!(bool)m->getProperty(Ids::modulatorExcludeFromSnapshot)) addCtrlrMidiMessageToBuffer (buffer, m->getMidiMessage()); } else if (!(bool)m->getProperty(Ids::modulatorExcludeFromSnapshot)) { addCtrlrMidiMessageToBuffer (buffer, m->getMidiMessage()); } } } } showDialog = owner.getProperty(Ids::panelMidiSnapshotShowProgress); if (showDialog) { if (alertWindow == nullptr) alertWindow = LookAndFeel::getDefaultLookAndFeel().createAlertWindow ("MIDI Snapshot", String(), "Stop", String(), String(), AlertWindow::NoIcon, 1, nullptr); alertWindow->setEscapeKeyCancels (false); alertWindow->addProgressBarComponent (progress); } else { alertWindow = nullptr; } if (luaPanelMidiSnapshotPreCbk && !luaPanelMidiSnapshotPreCbk.wasObjectDeleted()) { if (luaPanelMidiSnapshotPreCbk->isValid()) { owner.getCtrlrLuaManager().getMethodManager().call (luaPanelMidiSnapshotPreCbk, &buffer); } } }
ValueTree CtrlrPanel::getProgram(ValueTree treeToWriteTo) { if (treeToWriteTo.isValid()) { treeToWriteTo.removeAllChildren(0); } ValueTree program(Ids::panelState); program.setProperty (Ids::panelVersionMajor, getProperty(Ids::panelVersionMajor), 0); program.setProperty (Ids::panelVersionMinor, getProperty(Ids::panelVersionMinor), 0); program.setProperty (Ids::time, Time::getCurrentTime().currentTimeMillis(), 0); for (int i=0; i<ctrlrModulators.size(); i++) { CtrlrModulator *m = ctrlrModulators[i]; ValueTree v(Ids::value); if ((bool)m->getProperty (Ids::modulatorIsStatic) == true) continue; v.setProperty(Ids::name, m->getName(),0); v.setProperty(Ids::value, m->getModulatorValue(),0); if (treeToWriteTo.isValid()) { treeToWriteTo.addChild (v,-1,0); } else { program.addChild (v,-1,0); } } return (program); }
//============================================================================== CtrlrTabsComponent::CtrlrTabsComponent (CtrlrModulator &owner) : CtrlrComponent(owner), lf(*this), ctrlrTabs (0) { addAndMakeVisible (ctrlrTabs = new CtrlrTabsInternal (*this)); ctrlrTabs->setName (L"ctrlrTabs"); //[UserPreSize] ctrlrTabs->setLookAndFeel (&lf); owner.setProperty (Ids::modulatorVstExported, false); setProperty (Ids::uiTabsCurrentTabChanged, ""); setProperty (Ids::uiTabsDepth, 24); setProperty (Ids::uiTabsOutlineThickness, 2); setProperty (Ids::uiTabsFrontTabOutline, 1.0f); setProperty (Ids::uiTabsTabOutline, 0.5f); setProperty (Ids::uiTabsIndentThickness, 0); setProperty (Ids::uiTabsOrientation, 0); setProperty (Ids::uiTabsFrontTabFont, FONT2STR(Font(16))); setProperty (Ids::uiTabsTabFont, FONT2STR(Font(16))); setProperty (Ids::uiTabsOutlineGlobalColour, "0x00000000"); setProperty (Ids::uiTabsOutlineGlobalBackgroundColour, "0x67000000"); setProperty (Ids::uiTabsOutlineTabColour, "0xff303030"); setProperty (Ids::uiTabsTextTabColour, "0xff909090"); setProperty (Ids::uiTabsFrontTabOutlineColour, "0xff000000"); setProperty (Ids::uiTabsFrontTabTextColour, "0xff000000"); setProperty (Ids::uiTabsAddTab, 0); setProperty (Ids::uiTabsRemoveTab, 0); //[/UserPreSize] setSize (256, 256); //[Constructor] You can add your own custom stuff here.. //[/Constructor] }
CtrlrWaveform::CtrlrWaveform (CtrlrModulator &owner) : CtrlrComponent(owner), audioThumbnail(nullptr), audioBufferCopy(1,0), qualityForAudioFiles(0) { audioThumbnail = new AudioThumbnail (1, owner.getOwner().getOwner().getAudioFormatManager(), owner.getOwner().getOwner().getAudioThumbnailCache()); audioThumbnail->addChangeListener (this); setProperty (Ids::uiWaveformColour, "0xff000000"); setProperty (Ids::uiWaveformBackgroundColour1, "0x79ffffff"); setProperty (Ids::uiWaveformBackgroundColour2, "0x79a0a0a0"); setProperty (Ids::uiWaveformOutlineColour, "0xff000000"); setProperty (Ids::uiWaveformOutlineThickness, 1); setProperty (Ids::uiWaveformSourceSamplesPerThumbnailSample, 1); setProperty (Ids::uiWaveFormVeritcalZoomFactor, 1.0); setProperty (Ids::uiWaveFormDrawSecondsStart, 0.0); setProperty (Ids::uiWaveFormDrawSecondsEnd, 1.0); setProperty (Ids::uiWaveFormThumbnailChangedCallback, COMBO_NONE_ITEM); setProperty (Ids::uiWaveFormSourceChangedCallback, COMBO_NONE_ITEM); setProperty (Ids::uiWaveFormFilesDroppedCallback, COMBO_NONE_ITEM); setSize (256, 128); }