static void createFileCreationOptionComboBox (Component& setupComp, OwnedArray<Component>& itemsCreated, const char** fileOptions) { ComboBox* c = new ComboBox(); itemsCreated.add (c); setupComp.addChildAndSetID (c, "filesToCreate"); c->addItemList (StringArray (fileOptions), 1); c->setSelectedId (1, false); Label* l = new Label (String::empty, "Files to Auto-Generate:"); l->attachToComponent (c, true); itemsCreated.add (l); c->setBounds ("parent.width / 2 + 160, 10, parent.width - 10, top + 22"); }
BEGIN_JUCE_NAMESPACE #include "juce_FileBrowserComponent.h" #include "../lookandfeel/juce_LookAndFeel.h" #include "../../graphics/drawables/juce_DrawablePath.h" #include "../../../text/juce_LocalisedStrings.h" #include "../../../core/juce_SystemStats.h" #include "juce_FileListComponent.h" #include "juce_FileTreeComponent.h" //============================================================================== FileBrowserComponent::FileBrowserComponent (int flags_, const File& initialFileOrDirectory, const FileFilter* fileFilter_, FilePreviewComponent* previewComp_) : FileFilter (String::empty), fileFilter (fileFilter_), flags (flags_), previewComp (previewComp_), thread ("Juce FileBrowser") { // You need to specify one or other of the open/save flags.. jassert ((flags & (saveMode | openMode)) != 0); jassert ((flags & (saveMode | openMode)) != (saveMode | openMode)); // You need to specify at least one of these flags.. jassert ((flags & (canSelectFiles | canSelectDirectories)) != 0); String filename; if (initialFileOrDirectory == File::nonexistent) { currentRoot = File::getCurrentWorkingDirectory(); } else if (initialFileOrDirectory.isDirectory()) { currentRoot = initialFileOrDirectory; } else { chosenFiles.add (new File (initialFileOrDirectory)); currentRoot = initialFileOrDirectory.getParentDirectory(); filename = initialFileOrDirectory.getFileName(); } fileList = new DirectoryContentsList (this, thread); if ((flags & useTreeView) != 0) { FileTreeComponent* const tree = new FileTreeComponent (*fileList); if ((flags & canSelectMultipleItems) != 0) tree->setMultiSelectEnabled (true); addAndMakeVisible (tree); fileListComponent = tree; } else { FileListComponent* const list = new FileListComponent (*fileList); list->setOutlineThickness (1); if ((flags & canSelectMultipleItems) != 0) list->setMultipleSelectionEnabled (true); addAndMakeVisible (list); fileListComponent = list; } fileListComponent->addListener (this); addAndMakeVisible (currentPathBox = new ComboBox ("path")); currentPathBox->setEditableText (true); StringArray rootNames, rootPaths; const BitArray separators (getRoots (rootNames, rootPaths)); for (int i = 0; i < rootNames.size(); ++i) { if (separators [i]) currentPathBox->addSeparator(); currentPathBox->addItem (rootNames[i], i + 1); } currentPathBox->addSeparator(); currentPathBox->addListener (this); addAndMakeVisible (filenameBox = new TextEditor()); filenameBox->setMultiLine (false); filenameBox->setSelectAllWhenFocused (true); filenameBox->setText (filename, false); filenameBox->addListener (this); filenameBox->setReadOnly ((flags & (filenameBoxIsReadOnly | canSelectMultipleItems)) != 0); Label* label = new Label ("f", TRANS("file:")); addAndMakeVisible (label); label->attachToComponent (filenameBox, true); addAndMakeVisible (goUpButton = getLookAndFeel().createFileBrowserGoUpButton()); goUpButton->addButtonListener (this); goUpButton->setTooltip (TRANS ("go up to parent directory")); if (previewComp != 0) addAndMakeVisible (previewComp); setRoot (currentRoot); thread.startThread (4); }
uint32_t TmpSndDawAudioProcessorEditor::InitializeParams() { Array<Parameter*, CriticalSection>* p = mProcessor->GetParametersArray(); String currentInstName; mInstLabels.clear(); mParamLabels.clear(); mSliders.clear(); mInstructions = nullptr; mLogoComponent = new ImageComponent(); mLogoComponent->setImage(mLogo); addAndMakeVisible(mLogoComponent); uint32_t currentParamCount = 0; uint32_t maxParams = 0; // params are ordered by instruments in the array, because they come form the // json. we keep the current instrument index, so we can then map params to // instrument to do the layout properly. uint32_t currentInstIndex = -1; for (uint32_t i = 0; i < p->size(); i++) { // sliders Slider* s = new Slider(); s->setSliderStyle(Slider::LinearHorizontal); s->setRange((*p)[i]->mMin,(*p)[i]->mMax, (*p)[i]->mStep); // text size: letter width * log(max) + log(1/step) ? s->setTextBoxStyle (Slider::TextBoxRight, false, 30, 20); s->setValue((*p)[i]->mDefault); s->addListener(new SliderValueListener(this)); s->setLookAndFeel(mLookAndFeel); // instrument label uint32_t index_param = (*p)[i]->mName.indexOfChar(' '); String instName = (*p)[i]->mName.substring(0, index_param); if (instName != currentInstName) { currentInstIndex++; Label* l = new Label(); currentInstName = instName; l->setText(currentInstName, dontSendNotification); addAndMakeVisible(l); mInstLabels.add(l); if (currentParamCount > maxParams) { maxParams = currentParamCount; currentParamCount = 0; } } // parameters label String paramName = (*p)[i]->mName.substring(index_param); Label* l = new Label(); l->setText(paramName, dontSendNotification); l->attachToComponent(s, false); mInstMapping.add(currentInstIndex); addAndMakeVisible(l); addAndMakeVisible(s); mSliders.add(s); mParamLabels.add(l); currentParamCount++; } // we haven't received configuration data now, display a friendly message // with instructions if (maxParams == 0 && p->size() == 0) { mInstructions = new Label(); mInstructions->setText(INSTRUCTIONS, dontSendNotification); addAndMakeVisible(mInstructions); } return maxParams; }