示例#1
0
void ProjectTreeViewBase::itemDropped (const DragAndDropTarget::SourceDetails& dragSourceDetails, int insertIndex)
{
    OwnedArray <Project::Item> selectedNodes;
    getAllSelectedNodesInTree (dragSourceDetails.sourceComponent, selectedNodes);

    if (selectedNodes.size() > 0)
    {
        TreeView* tree = getOwnerView();
        ScopedPointer <XmlElement> oldOpenness (tree->getOpennessState (false));

        moveSelectedItemsTo (selectedNodes, insertIndex);

        if (oldOpenness != nullptr)
            tree->restoreOpennessState (*oldOpenness, false);
    }
}
示例#2
0
    void reorderChildren (const OwnedArray<ValueTree>& newOrder, UndoManager* undoManager)
    {
        jassert (newOrder.size() == children.size());

        for (int i = 0; i < children.size(); ++i)
        {
            SharedObject* const child = newOrder.getUnchecked(i)->object;

            if (children.getObjectPointerUnchecked (i) != child)
            {
                const int oldIndex = children.indexOf (child);
                jassert (oldIndex >= 0);
                moveChild (oldIndex, i, undoManager);
            }
        }
    }
示例#3
0
//==============================================================================
void AudioDeviceManager::createDeviceTypesIfNeeded()
{
    if (availableDeviceTypes.size() == 0)
    {
        OwnedArray<AudioIODeviceType> types;
        createAudioDeviceTypes (types);

        for (int i = 0; i < types.size(); ++i)
            addAudioDeviceType (types.getUnchecked(i));

        types.clear (false);

        if (AudioIODeviceType* first = availableDeviceTypes.getFirst())
            currentDeviceType = first->getTypeName();
    }
}
示例#4
0
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");
}
示例#5
0
void ThreadPool::addToDeleteList (OwnedArray<ThreadPoolJob>& deletionList, ThreadPoolJob* const job) const
{
    job->shouldStop = true;
    job->pool = nullptr;

    if (job->shouldBeDeleted)
        deletionList.add (job);
}
示例#6
0
	void run()
	{	
		OwnedArray<ImageItem> images;
		bool res = smugmug->getImages(images, ur->getAlbumId());

		smugmug->lock.enter();
		if (res)
		{
			for (int i = ur->getNumImages() - 1; i >= 0; i--)
			{
				for (int j = 0; j < images.size(); j++)
				{
					if (ur->getImageFile(i).getFileName() == images[j]->filename)
					{
						ur->getImageFileInfo(i).status = UploadFile::Duplicate;
					}
				}
			}
		}

		for (int i = 0; i < smugmug->uploadQueue.size(); i++)
		{
			if (smugmug->uploadQueue[i]->getAlbumId().id == ur->getAlbumId().id)
			{
				for (int j = 0; j < smugmug->uploadQueue[i]->getNumImages(); j++)
				{
					for (int k = 0; k < ur->getNumImages(); k++)
					{
						if (ur->getImageFile(k).getFileName() == smugmug->uploadQueue[i]->getImageFile(j).getFileName())
						{
							ur->getImageFileInfo(k).status = UploadFile::Duplicate;
						}
					}
				}
			}
		}
		smugmug->lock.exit();

		smugmug->uploadImages(ur, false);		

		smugmug->lock.enter();
		smugmug->dupeThreads.removeFirstMatchingValue(this);
		smugmug->lock.exit();

        triggerAsyncUpdate();
	}
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);

        for (int i = 0; i < numExistingChildComps; ++i)
            existingComponents.add (parent.getChildComponent (i));

        const int newNumChildren = children.getNumChildren();
        for (int i = 0; i < newNumChildren; ++i)
        {
            const ValueTree childState (children.getChild (i));
            Component* c = removeComponentWithID (existingComponents, getStateId (childState));

            if (c == nullptr)
            {
                if (TypeHandler* const type = getHandlerForState (childState))
                    c = ComponentBuilderHelpers::createNewComponent (*type, childState, &parent);
                else
                    jassertfalse;
            }

            if (c != nullptr)
                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));
    }
}
示例#8
0
void MixerAudioSource::removeAllInputs()
{
    OwnedArray<AudioSource> toDelete;

    {
        const ScopedLock sl (lock);

        for (int i = inputs.size(); --i >= 0;)
            if (inputsToDelete[i])
                toDelete.add (inputs.getUnchecked(i));

        inputs.clear();
    }

    for (int i = toDelete.size(); --i >= 0;)
        toDelete.getUnchecked(i)->releaseResources();
}
示例#9
0
//==============================================================================
static int countTotalChannels (const OwnedArray<AudioProcessor::Bus>& buses) noexcept
{
    int n = 0;

    for (int i = 0; i < buses.size(); ++i)
        n += buses[i]->getNumberOfChannels();

    return n;
}
示例#10
0
int SAMCompiler::containsWgRef(const OwnedArray<WgWithSuffixes>& wws, const String& wId)
{
    for (int i = 0; i < wws.size(); ++i)
    {
        WgWithSuffixes* w = wws[i];
        if (w->wgId.compare(wId) == 0)
            return i;
    }
    return -1;
}
示例#11
0
void EnabledModuleList::createRequiredModules (OwnedArray<LibraryModule>& modules)
{
    for (int i = 0; i < getNumModules(); ++i)
    {
        ModuleDescription info (getModuleInfo (getModuleID (i)));

        if (info.isValid())
            modules.add (new LibraryModule (info));
    }
}
示例#12
0
int SAMCompiler::containsMassLinkRef(const OwnedArray<MassLinkRef>& mlf, const String& mId)
{
    for (int i = 0; i < mlf.size(); ++i)
    {
        MassLinkRef* m = mlf[i];
        if (m->massId.compare(mId) == 0)
            return i;
    }
    return -1;
}
示例#13
0
void ProjectExporter::createPropertyEditors (PropertyListBuilder& props)
{
    props.add (new TextPropertyComponent (getTargetLocationValue(), "Target Project Folder", 1024, false),
               "The location of the folder in which the " + name + " project will be created. "
               "This path can be absolute, but it's much more sensible to make it relative to the jucer project directory.");

    OwnedArray<LibraryModule> modules;
    project.getModules().createRequiredModules (modules);

    for (int i = 0; i < modules.size(); ++i)
        modules.getUnchecked(i)->createPropertyEditors (*this, props);

    props.add (new TextPropertyComponent (getExporterPreprocessorDefs(), "Extra Preprocessor Definitions", 32768, true),
               "Extra preprocessor definitions. Use the form \"NAME1=value NAME2=value\", using whitespace, commas, "
               "or new-lines to separate the items - to include a space or comma in a definition, precede it with a backslash.");

    props.add (new TextPropertyComponent (getExtraCompilerFlags(), "Extra compiler flags", 2048, true),
               "Extra command-line flags to be passed to the compiler. This string can contain references to preprocessor definitions in the "
               "form ${NAME_OF_DEFINITION}, which will be replaced with their values.");

    props.add (new TextPropertyComponent (getExtraLinkerFlags(), "Extra linker flags", 2048, true),
               "Extra command-line flags to be passed to the linker. You might want to use this for adding additional libraries. "
               "This string can contain references to preprocessor definitions in the form ${NAME_OF_VALUE}, which will be replaced with their values.");

    props.add (new TextPropertyComponent (getExternalLibraries(), "External libraries to link", 2048, true),
               "Additional libraries to link (one per line). You should not add any platform specific decoration to these names. "
               "This string can contain references to preprocessor definitions in the form ${NAME_OF_VALUE}, which will be replaced with their values.");

    {
        OwnedArray<Project::Item> images;
        project.findAllImageItems (images);

        StringArray choices;
        Array<var> ids;

        choices.add ("<None>");
        ids.add (var::null);
        choices.add (String::empty);
        ids.add (var::null);

        for (int i = 0; i < images.size(); ++i)
        {
            choices.add (images.getUnchecked(i)->getName());
            ids.add (images.getUnchecked(i)->getID());
        }

        props.add (new ChoicePropertyComponent (getSmallIconImageItemID(), "Icon (small)", choices, ids),
                   "Sets an icon to use for the executable.");

        props.add (new ChoicePropertyComponent (getBigIconImageItemID(), "Icon (large)", choices, ids),
                   "Sets an icon to use for the executable.");
    }

    createExporterProperties (props);

    props.add (new TextPropertyComponent (getUserNotes(), "Notes", 32768, true),
               "Extra comments: This field is not used for code or project generation, it's just a space where you can express your thoughts.");
}
    const KnownTypeface* matchTypeface (const String& familyName, const String& style) const noexcept
    {
        std::clog << "matchTypeface: " << familyName << " " << style << std::endl;

        for (int i = 0; i < faces.size(); ++i)
        {
            const KnownTypeface* const face = faces.getUnchecked(i);

            std::clog << "  matchTypeface: " << face->family << " " << face->style << std::endl;

            if ((face->family == familyName || familyName.isEmpty())
                  && (face->style.equalsIgnoreCase (style) || style.isEmpty()))
                return face;
        }

        std::cout << "NO MATCHING FONT FOUND" << std::endl;

        return nullptr;
    }
//==============================================================================
void MidiMessageSequence::createControllerUpdatesForTime (const int channelNumber,
                                                          const double time,
                                                          OwnedArray<MidiMessage>& dest)
{
    bool doneProg = false;
    bool donePitchWheel = false;
    Array<int> doneControllers;
    doneControllers.ensureStorageAllocated (32);

    for (int i = list.size(); --i >= 0;)
    {
        const MidiMessage& mm = list.getUnchecked(i)->message;

        if (mm.isForChannel (channelNumber) && mm.getTimeStamp() <= time)
        {
            if (mm.isProgramChange())
            {
                if (! doneProg)
                {
                    dest.add (new MidiMessage (mm, 0.0));
                    doneProg = true;
                }
            }
            else if (mm.isController())
            {
                if (! doneControllers.contains (mm.getControllerNumber()))
                {
                    dest.add (new MidiMessage (mm, 0.0));
                    doneControllers.add (mm.getControllerNumber());
                }
            }
            else if (mm.isPitchWheel())
            {
                if (! donePitchWheel)
                {
                    dest.add (new MidiMessage (mm, 0.0));
                    donePitchWheel = true;
                }
            }
        }
    }
}
示例#16
0
void ProjectTreeViewBase::moveItems (OwnedArray <Project::Item>& selectedNodes,
                                     Project::Item destNode, int insertIndex)
{
    for (int i = selectedNodes.size(); --i >= 0;)
    {
        Project::Item* const n = selectedNodes.getUnchecked(i);

        if (destNode == *n || destNode.state.isAChildOf (n->state)) // Check for recursion.
            return;

        if (! destNode.canContain (*n))
            selectedNodes.remove (i);
    }

    // Don't include any nodes that are children of other selected nodes..
    for (int i = selectedNodes.size(); --i >= 0;)
    {
        Project::Item* const n = selectedNodes.getUnchecked(i);

        for (int j = selectedNodes.size(); --j >= 0;)
        {
            if (j != i && n->state.isAChildOf (selectedNodes.getUnchecked(j)->state))
            {
                selectedNodes.remove (i);
                break;
            }
        }
    }

    // Remove and re-insert them one at a time..
    for (int i = 0; i < selectedNodes.size(); ++i)
    {
        Project::Item* selectedNode = selectedNodes.getUnchecked(i);

        if (selectedNode->state.getParent() == destNode.state
              && indexOfNode (destNode.state, selectedNode->state) < insertIndex)
            --insertIndex;

        selectedNode->removeItemFromProject();
        destNode.addChild (*selectedNode, insertIndex++);
    }
}
示例#17
0
void ColumnFileBrowserContents::removeColumn (int numColumns)
{
	for (int i = numColumns; i <= 0; i--) 
    {
		columns[i]->removeListener (this);
		columns[i]->removeChangeListener (this);
		columns[i]->removeComponentListener (this);
	}
    
	columns.removeLast (numColumns - 1);
}
    static void replaceTabsWithSpaces (OwnedArray <SyntaxToken>& tokens, const int spacesPerTab) throw()
    {
        int x = 0;
        for (int i = 0; i < tokens.size(); ++i)
        {
            SyntaxToken* const t = tokens.getUnchecked(i);

            for (;;)
            {
                int tabPos = t->text.indexOfChar (T('\t'));
                if (tabPos < 0)
                    break;

                const int spacesNeeded = spacesPerTab - ((tabPos + x) % spacesPerTab);
                t->text = t->text.replaceSection (tabPos, 1, String::repeatedString (T(" "), spacesNeeded));
            }

            x += t->text.length();
        }
    }
示例#19
0
static void findImages (const Project::Item& item, OwnedArray<Project::Item>& found)
{
    if (item.isImageFile())
    {
        found.add (new Project::Item (item));
    }
    else if (item.isGroup())
    {
        for (int i = 0; i < item.getNumChildren(); ++i)
            findImages (item.getChild (i), found);
    }
}
示例#20
0
bool SmugMug::getAlbumList(OwnedArray<Album>& albums)
{
	StringPairArray params;
	XmlElement* n = smugMugRequest(("smugmug.albums.get"), params);

	if (n)
	{
		XmlElement* a = n->getChildByName(("Albums"));
		if (a)
		{
			XmlElement* alb = a->getChildByName(("Album"));
			while (alb)
			{
				Album* album = new Album();
				album->id.id         = alb->getIntAttribute(("id"));
				album->id.key        = alb->getStringAttribute(("Key"));
				album->title         = alb->getStringAttribute(("Title"));

				XmlElement* cat = alb->getChildByName(("Category"));
				if (cat)
				{
					album->category   = cat->getStringAttribute(("Name"));
					album->categoryId = cat->getIntAttribute(("id"));
				}
				else
				{
					album->category   = String::empty;
					album->categoryId = -1;
				}

				XmlElement* subcat = alb->getChildByName(("SubCategory"));
				if (subcat)
				{
					album->subCategory   = subcat->getStringAttribute(("Name"));
					album->subCategoryId = subcat->getIntAttribute(("id"));
				}
				else
				{
					album->subCategory   = String::empty;
					album->subCategoryId = -1;
				}

				albums.add(album);

				alb = alb->getNextElementWithTagName(("Album"));
			}
		}
		delete n;
		return true;
	}
	return false;
}
示例#21
0
bool KnownPluginList::scanAndAddFile (const String& fileOrIdentifier,
                                      const bool dontRescanIfAlreadyInList,
                                      OwnedArray <PluginDescription>& typesFound,
                                      AudioPluginFormat& format)
{
    const ScopedLock sl (scanLock);

    if (dontRescanIfAlreadyInList
         && getTypeForFile (fileOrIdentifier) != nullptr)
    {
        bool needsRescanning = false;

        for (int i = types.size(); --i >= 0;)
        {
            const PluginDescription* const d = types.getUnchecked(i);

            if (d->fileOrIdentifier == fileOrIdentifier && d->pluginFormatName == format.getName())
            {
                if (format.pluginNeedsRescanning (*d))
                    needsRescanning = true;
                else
                    typesFound.add (new PluginDescription (*d));
            }
        }

        if (! needsRescanning)
            return false;
    }

    if (blacklist.contains (fileOrIdentifier))
        return false;

    OwnedArray <PluginDescription> found;

    {
        const ScopedUnlock sl2 (scanLock);

        if (scanner != nullptr)
        {
            if (! scanner->findPluginTypesFor (format, found, fileOrIdentifier))
                addToBlacklist (fileOrIdentifier);
        }
        else
        {
            format.findAllTypesForFile (found, fileOrIdentifier);
        }
    }

    for (int i = 0; i < found.size(); ++i)
    {
        PluginDescription* const desc = found.getUnchecked(i);
        jassert (desc != nullptr);

        addType (*desc);
        typesFound.add (new PluginDescription (*desc));
    }

    return found.size() > 0;
}
示例#22
0
void ColumnFileBrowserContents::changeListenerCallback (ChangeBroadcaster* changedComponent)
{
    BrowserColumn* changedColumn = static_cast<BrowserColumn*> (changedComponent);
    
    if (changedColumn->getHighlightedFile().getFileName().isNotEmpty()) 
    {
        columns[activeColumn]->setLookAndFeel (inactiveLookAndFeel);
        activeColumn = columns.indexOf (changedColumn);
        columns[activeColumn]->setLookAndFeel (activeLookAndFeel);
        
        selectedFileChanged (changedColumn->getHighlightedFile());
    }
}
示例#23
0
void ColumnFileBrowserContents::resized()
{
	int width = 0;
	const int height = getHeight();
	
	for (int i = 0; i < columns.size(); i++)
	{
		columns[i]->setBounds (width, 0, columns[i]->getWidth(), height);
		width += columns[i]->getWidth();
	}
	
	setSize (width, height);
}
示例#24
0
void MainHostWindow::filesDropped (const StringArray& files, int x, int y)
{
    GraphDocumentComponent* const graphEditor = getGraphEditor();

    if (graphEditor != nullptr)
    {
        if (files.size() == 1 && File (files[0]).hasFileExtension (filenameSuffix))
        {
            if (graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
                graphEditor->graph.loadFrom (File (files[0]), true);
        }
        else
        {
            OwnedArray <PluginDescription> typesFound;
            knownPluginList.scanAndAddDragAndDroppedFiles (formatManager, files, typesFound);

            Point<int> pos (graphEditor->getLocalPoint (this, Point<int> (x, y)));

            for (int i = 0; i < jmin (5, typesFound.size()); ++i)
                createPlugin (typesFound.getUnchecked(i), pos.getX(), pos.getY());
        }
    }
}
示例#25
0
static void initJuceDevicesIfNeeded()
{
    static AudioDeviceManager sDeviceManager;

    if (gDeviceTypes.size() != 0)
        return;

    sDeviceManager.createAudioDeviceTypes(gDeviceTypes);

    CARLA_SAFE_ASSERT_RETURN(gDeviceTypes.size() != 0,);

    new JuceCleanup();

    // remove JACK from device list
    for (int i=0, count=gDeviceTypes.size(); i < count; ++i)
    {
        if (gDeviceTypes[i]->getTypeName() == "JACK")
        {
            gDeviceTypes.remove(i, true);
            break;
        }
    }
}
示例#26
0
static void initJuceDevicesIfNeeded()
{
    static AudioDeviceManager sDeviceManager;
    static bool needsInit = true;

    if (! needsInit)
        return;

    needsInit = false;
    new JuceCleanup();

    sDeviceManager.createAudioDeviceTypes(gDeviceTypes);

    // remove JACK from device list
    for (int i=0, count=gDeviceTypes.size(); i < count; ++i)
    {
        if (gDeviceTypes[i]->getTypeName() == "JACK")
        {
            gDeviceTypes.remove(i, true);
            break;
        }
    }
}
示例#27
0
bool SmugMug::deleteDuplicates(SmugID albumId)
{
	OwnedArray<ImageItem> images;
	if (getImages(images, albumId))
	{
		OwnedArray<SmugID> duplicateIds;
		StringArray fileNames;

		for (int i = 0; i < images.size(); i++)
		{
			if (fileNames.contains(images[i]->filename))
				duplicateIds.add(new SmugID(images[i]->id));
			else
				fileNames.add(images[i]->filename);
		}

		for (int i = 0; i < duplicateIds.size(); i++)
			deleteImage(*duplicateIds[i]);

		return true;
	}
	return false;
}
//==============================================================================
//==============================================================================
void NonMember::printSlidersParams(const PluginProcessor& processor,
                        const OwnedArray<Slider>& sliders)
{
    String message;

    for (int i = 0; i < processor.numParams(); ++i) {
        jassert (i < sliders.size());
        jassert (sliders[i]);
        message << "Sliders["<<i<<"] " << sliders[i]->getValue()
                << " params["<<i<<"] " << processor.getParam(i).get() << "\n";
    }

    Logger::outputDebugString (message);
}
bool ColumnFileBrowserContents::addColumn (const File& rootDirectory)
{
	if (rootDirectory.isDirectory() && rootDirectory.exists())
	{
        const int startingWidth = columns.getLast()->getWidth();
        
        BrowserColumn* newColumn = new BrowserColumn (filesToDisplay);
        newColumn->setLookAndFeel (inactiveLookAndFeel);
		newColumn->setRoot (rootDirectory);
		newColumn->setSize (startingWidth, 50);
		newColumn->addListener (this);
		newColumn->addChangeListener (this);
		newColumn->addComponentListener (this);
		columns.add (newColumn);
		addAndMakeVisible (newColumn);
		
		resized();
		
		return true;
	}
	
	return false;
}
示例#30
0
void ColumnFileBrowserContents::selectedFileChanged (const File& file)
{
    // if last column clicked add new column
	if (columns[activeColumn] == columns.getLast())
	{
		addColumn (file);
	}
	else        // otherwise remove uneeded columns and change last
	{
		for (int i = 0; i < columns.size(); i++)
		{
			if (columns[activeColumn] == columns[i])
            {
                const int numColumnsToRemove = columns.size() - i - (file.isDirectory() ? 1 : 0);
				removeColumn (numColumnsToRemove);
				
				if (file.isDirectory())
					columns.getLast()->setRoot (file);
                
                break;
			}
		}
		
		resized();
	}
	
	// stick to edges of viewport
	if (getWidth() < viewport->getWidth())
    {
		viewport->setViewPosition (0, 0);
    }
	else if (file.exists() || (getRight() < viewport->getRight()))
	{
		const int ammountToSubtract = viewport->getRight() - getRight();
		viewport->setViewPosition (viewport->getViewPositionX() - ammountToSubtract, 0);
	}
}