Esempio n. 1
0
var CtrlrValueTreeEditorItem::getDragSourceDescription ()
{
	Array <ValueTree> selectedTreeItems;
	String returnValue;

	if (getOwnerView())
	{
		for (int i=0; i<getOwnerView()->getNumSelectedItems(); i++)
		{
			CtrlrValueTreeEditorItem *item = dynamic_cast<CtrlrValueTreeEditorItem*>(getOwnerView()->getSelectedItem(i));
			selectedTreeItems.add (item->getTree());
		}
	}

	if ((returnValue = provider.getDragSourceDescription(selectedTreeItems)) != String::empty)
	{
		return (returnValue);
	}
	else
	{
		for (int i=0; i<selectedTreeItems.size(); i++)
		{
			returnValue << selectedTreeItems[i].getType().toString() + ";";
		}
	}

	return (returnValue);
}
Esempio n. 2
0
Colour JucerTreeViewBase::getBackgroundColour() const
{
    Colour background (getOwnerView()->findColour (mainBackgroundColourId));

    if (isSelected())
        background = background.overlaidWith (getOwnerView()->findColour (TreeView::selectedItemBackgroundColourId));

    return background;
}
Esempio n. 3
0
Colour JucerTreeViewBase::getContentColour (bool isIcon) const
{
    if (isMissing())
        return Colours::red;

    if (isSelected())
        return getOwnerView()->findColour (defaultHighlightedTextColourId);

    return getOwnerView()->findColour (isIcon ? treeIconColourId : defaultTextColourId);
}
//==============================================================================
void ProjectTreeViewBase::triggerAsyncRename (const Project::Item& itemToRename)
{
    class RenameMessage  : public CallbackMessage
    {
    public:
        RenameMessage (TreeView* const tree_, const Project::Item& itemToRename_)
            : tree (tree_), itemToRename (itemToRename_)  {}

        void messageCallback()
        {
            if (tree != nullptr)
            {
                ProjectTreeViewBase* pg = dynamic_cast <ProjectTreeViewBase*> (tree->getRootItem());

                if (pg != nullptr)
                {
                    pg = pg->findTreeViewItem (itemToRename);

                    if (pg != nullptr)
                        pg->showRenameBox();
                }
            }
        }

    private:
        Component::SafePointer<TreeView> tree;
        Project::Item itemToRename;
    };

    (new RenameMessage (getOwnerView(), itemToRename))->post();
}
Esempio n. 5
0
void JucerTreeViewBase::showRenameBox()
{
    Rectangle<int> r (getItemPosition (true));
    r.setLeft (r.getX() + textX);
    r.setHeight (getItemHeight());

    new RenameTreeItemCallback (*this, *getOwnerView(), r);
}
Esempio n. 6
0
ProjectContentComponent* JucerTreeViewBase::getProjectContentComponent() const
{
    for (Component* c = getOwnerView(); c != nullptr; c = c->getParentComponent())
        if (ProjectContentComponent* pcc = dynamic_cast<ProjectContentComponent*> (c))
            return pcc;

    return nullptr;
}
Esempio n. 7
0
Colour
TreeItemBase::getBackgroundColour() const
{
#if 0
    Colour background (getOwnerView()->findColour (gui::mainBackgroundColourId));

    if (isSelected())
        background = background.overlaidWith (getOwnerView()->findColour (gui::treeviewHighlightColourId));
#else
    Colour background (Colours::transparentBlack);

    if (isSelected())
        background = background.overlaidWith (Colours::aqua.darker());

#endif
    return background;
}
Esempio n. 8
0
void JucerTreeViewBase::paintItem (Graphics& g, int width, int height)
{
    ignoreUnused (width, height);

    auto bounds = g.getClipBounds().withY (0).withHeight (height).toFloat();

    g.setColour (getOwnerView()->findColour (treeIconColourId).withMultipliedAlpha (0.4f));
    g.fillRect (bounds.removeFromBottom (0.5f).reduced (5, 0));
}
Esempio n. 9
0
void JucerTreeViewBase::itemClicked (const MouseEvent& e)
{
    if (e.mods.isPopupMenu())
    {
        if (getOwnerView()->getNumSelectedItems() > 1)
            showMultiSelectionPopupMenu();
        else
            showPopupMenu();
    }
}
Esempio n. 10
0
 virtual void paintItem(Graphics &g, int width, int height) override
 {
     auto &lookAndFeel = LookAndFeel::getDefaultLookAndFeel();
     const int fontHeight = 14;
     g.setFont(fontHeight);
     g.setColour(lookAndFeel.findColour(mainTextColourId));
     Rectangle<int> area(height, 0, width - height, height);
     String text = _property->name();
     g.drawFittedText(text, area.reduced(4, 2), Justification::left, area.getHeight() / fontHeight);
     auto state = _property->selectedState();
     lookAndFeel.drawTickBox(g, *getOwnerView(), 2, 2, height - 4, height - 4, state != RC505::Property::Unselected, state !=  RC505::Property::PartiallySelected, false, false);
 }
Esempio n. 11
0
void JucerTreeViewBase::paintOpenCloseButton (Graphics& g, int width, int height, bool isMouseOver)
{
    Path p;

    if (isOpen())
        p.addTriangle (width * 0.2f,  height * 0.25f, width * 0.8f, height * 0.25f, width * 0.5f, height * 0.75f);
    else
        p.addTriangle (width * 0.25f, height * 0.25f, width * 0.8f, height * 0.5f,  width * 0.25f, height * 0.75f);

    g.setColour (getOwnerView()->findColour (mainBackgroundColourId).contrasting (0.3f));
    g.fillPath (p);
}
Esempio n. 12
0
 virtual Component *createItemComponent() override
 {
     PropertyTreeView *treeView = static_cast<PropertyTreeView *>(getOwnerView());
     if (RC505::BoolProperty *boolProperty = dynamic_cast<RC505::BoolProperty *>(_property)) {
         return new PropertyTreeViewComponent<RC505::BoolProperty, BoolPropertyView>(treeView, boolProperty);
     } else if (RC505::IntProperty *intProperty = dynamic_cast<RC505::IntProperty *>(_property)) {
         return new PropertyTreeViewComponent<RC505::IntProperty, IntPropertyView>(treeView, intProperty);
     } else  if (RC505::EnumProperty *enumProperty = dynamic_cast<RC505::EnumProperty *>(_property)) {
         return new PropertyTreeViewComponent<RC505::EnumProperty, EnumPropertyView>(treeView, enumProperty);
     } else  if (RC505::NameProperty *nameProperty = dynamic_cast<RC505::NameProperty *>(_property)) {
         return new PropertyTreeViewComponent<RC505::NameProperty, NamePropertyView>(treeView, nameProperty);
     } else  if (RC505::ValueProperty *valueProperty = dynamic_cast<RC505::ValueProperty *>(_property)) {
         return new PropertyTreeViewComponent<RC505::ValueProperty, ValuePropertyView>(treeView, valueProperty);
     }
     return nullptr;
 }
Esempio n. 13
0
void TreeItemBase::paintOpenCloseButton (Graphics& g, const Rectangle<float>& area,
                                         Colour /* backgroundColour */, bool /* isMouseOver */)
{
    Path p;

    const float width = area.getWidth();
    const float height = area.getHeight();

    if (isOpen())
        p.addTriangle (width * 0.2f,  height * 0.25f, width * 0.8f, height * 0.25f, width * 0.5f, height * 0.75f);
    else
        p.addTriangle (width * 0.25f, height * 0.25f, width * 0.8f, height * 0.5f,  width * 0.25f, height * 0.75f);

    g.setColour (getOwnerView()->findColour (mainBackgroundColourId).contrasting (0.3f));
    g.fillPath (p);
}
Esempio n. 14
0
ProjectContentComponent* JucerTreeViewBase::getProjectContentComponent() const
{
    Component* c = getOwnerView();

    while (c != nullptr)
    {
        ProjectContentComponent* pcc = dynamic_cast <ProjectContentComponent*> (c);

        if (pcc != nullptr)
            return pcc;

        c = c->getParentComponent();
    }

    return nullptr;
}
Esempio n. 15
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);
    }
}
Esempio n. 16
0
//==============================================================================
void ProjectTreeViewBase::triggerAsyncRename (const Project::Item& itemToRename)
{
    class RenameMessage  : public CallbackMessage
    {
    public:
        RenameMessage (TreeView* const t, const Project::Item& i)
            : tree (t), itemToRename (i)  {}

        void messageCallback()
        {
            if (tree != nullptr)
                if (ProjectTreeViewBase* root = dynamic_cast <ProjectTreeViewBase*> (tree->getRootItem()))
                    if (ProjectTreeViewBase* found = root->findTreeViewItem (itemToRename))
                        found->showRenameBox();
        }

    private:
        Component::SafePointer<TreeView> tree;
        Project::Item itemToRename;
    };

    (new RenameMessage (getOwnerView(), itemToRename))->post();
}
Esempio n. 17
0
void JucerTreeViewBase::paintOpenCloseButton (Graphics& g, const Rectangle<float>& area, Colour /*backgroundColour*/, bool isMouseOver)
{
    g.setColour (getOwnerView()->findColour (isSelected() ? defaultHighlightedTextColourId : treeIconColourId));
    TreeViewItem::paintOpenCloseButton (g, area, getOwnerView()->findColour (defaultIconColourId), isMouseOver);
}
Esempio n. 18
0
void JucerTreeViewBase::paintItem (Graphics& g, int width, int height)
{
    if (isSelected())
        g.fillAll (getOwnerView()->findColour (treeviewHighlightColourId));
}
Esempio n. 19
0
void CtrlrValueTreeEditorItem::keyPressed (const KeyPress &key)
{
	if (key.getKeyCode() == 65649) // F2
	{
		if (!provider.canBeRenamed(treeToEdit))
			return;

		AlertWindow wnd("Rename item","Rename current item type: " + treeToEdit.getType().toString(), AlertWindow::QuestionIcon, getOwnerView());
		wnd.addTextEditor ("name", treeToEdit.getProperty(nameIdentifier), "Name:", false);
		wnd.addButton ("OK", 1, KeyPress(KeyPress::returnKey));
		wnd.addButton ("Cancel", 0, KeyPress(KeyPress::escapeKey));
		if (wnd.runModalLoop())
		{
			if (provider.renameItem (treeToEdit, wnd.getTextEditorContents("name")))
			{
				treeToEdit.setProperty (Ids::name, wnd.getTextEditorContents("name"), nullptr);
			}

			provider.triggerAsyncUpdate();
		}
	}
}
Esempio n. 20
0
void ProjectTreeViewBase::deleteAllSelectedItems()
{
    TreeView* tree = getOwnerView();
    const int numSelected = tree->getNumSelectedItems();
    OwnedArray <File> filesToTrash;
    OwnedArray <Project::Item> itemsToRemove;

    for (int i = 0; i < numSelected; ++i)
    {
        const ProjectTreeViewBase* const p = dynamic_cast <ProjectTreeViewBase*> (tree->getSelectedItem (i));

        if (p != nullptr)
        {
            itemsToRemove.add (new Project::Item (p->item));

            if (p->getFile().existsAsFile())
                filesToTrash.add (new File (p->getFile()));
        }
    }

    if (filesToTrash.size() > 0)
    {
        String fileList;
        const int maxFilesToList = 10;
        for (int i = jmin (maxFilesToList, filesToTrash.size()); --i >= 0;)
            fileList << filesToTrash.getUnchecked(i)->getFullPathName() << "\n";

        if (filesToTrash.size() > maxFilesToList)
            fileList << "\n...plus " << (filesToTrash.size() - maxFilesToList) << " more files...";

        int r = AlertWindow::showYesNoCancelBox (AlertWindow::NoIcon, "Delete Project Items",
                                                 "As well as removing the selected item(s) from the project, do you also want to move their files to the trash:\n\n"
                                                   + fileList,
                                                 "Just remove references",
                                                 "Also move files to Trash",
                                                 "Cancel",
                                                 tree->getTopLevelComponent());

        if (r == 0)
            return;

        if (r != 2)
            filesToTrash.clear();
    }

    ProjectTreeViewBase* treeRootItem = dynamic_cast <ProjectTreeViewBase*> (tree->getRootItem());
    jassert (treeRootItem != nullptr);

    if (treeRootItem != nullptr)
    {
        OpenDocumentManager& om = IntrojucerApp::getApp().openDocumentManager;

        for (int i = filesToTrash.size(); --i >= 0;)
        {
            const File f (*filesToTrash.getUnchecked(i));

            om.closeFile (f, false);

            if (! f.moveToTrash())
            {
                // xxx
            }
        }

        for (int i = itemsToRemove.size(); --i >= 0;)
        {
            ProjectTreeViewBase* itemToRemove = treeRootItem->findTreeViewItem (*itemsToRemove.getUnchecked(i));

            if (itemToRemove != nullptr)
            {
                om.closeFile (itemToRemove->getFile(), false);
                itemToRemove->deleteItem();
            }
        }
    }
}
Esempio n. 21
0
void JucerTreeViewBase::paintOpenCloseButton (Graphics& g, const Rectangle<float>& area, Colour /*backgroundColour*/, bool isMouseOver)
{
    TreeViewItem::paintOpenCloseButton (g, area, getOwnerView()->findColour (mainBackgroundColourId), isMouseOver);
}