Esempio n. 1
0
void CtrlrTabsComponent::itemDropped (const SourceDetails &dragSourceDetails)
{
	if (dragSourceDetails.description == "__ctrlr_component_selection")
	{
		if (owner.getOwner().getEditor() && owner.getOwner().getEditor()->getSelection())
		{
			AffineTransform trans = owner.getOwner().getEditor()->moveSelectionToPosition(dragSourceDetails.localPosition.getX(), dragSourceDetails.localPosition.getY()-ctrlrTabs->getTabBarDepth());

			for (int i=0; i<owner.getOwner().getEditor()->getSelection()->getNumSelected(); i++)
			{
				CtrlrComponent *c = owner.getOwner().getEditor()->getSelection()->getSelectedItem(i);

				if (c != nullptr)
				{
					if (c == this || isOwned(c) || (bool)c->getProperty(Ids::componentIsLocked) == true)
						continue;

					setOwned (c, ctrlrTabs->getCurrentTabIndex(), true);

					c->setBounds (c->getBounds().transformedBy(trans));
				}
			}
		}
	}
}
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 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);
			}
		}
	}
}
Esempio n. 4
0
void CtrlrTabsContentComponent::parentNameChanged(const String &newName)
{
	for (int i=0; i<getNumChildComponents(); i++)
	{
		CtrlrComponent *c = dynamic_cast<CtrlrComponent*>(getChildComponent(i));
		if (c!=0)
		{
			c->setProperty (Ids::componentTabName, newName);
		}
	}
}
Esempio n. 5
0
void CtrlrGroup::modulatorNameChanged (const String &newName)
{
	for (int i=0; i<content.getNumChildComponents(); i++)
	{
		CtrlrComponent *c = dynamic_cast<CtrlrComponent*>(content.getChildComponent(i));
		if (c!=0)
		{
			c->setProperty (Ids::componentGroupName, newName, true);
		}
	}
}
void CtrlrPanelCanvasLayer::setCustomLookAndFeel (LookAndFeelBase *customLookAndFeel)
{
    for (int i=0; i<getNumChildComponents(); i++)
    {
        CtrlrComponent *c = dynamic_cast<CtrlrComponent*>(getChildComponent(i));

        if (c != nullptr)
        {
            c->setCustomLookAndFeel (customLookAndFeel);
        }
    }
}
CtrlrComponent *CtrlrComponentTypeManager::createComponent (const ValueTree &savedState, CtrlrModulator &owner)
{
	if (savedState.hasProperty (Ids::uiType))
	{
		CtrlrComponent *c = createComponent(savedState.getProperty(Ids::uiType).toString(), owner);
		c->restoreState (savedState);
		return (c);
	}

	jassertfalse; // trying to restore a component with no type, can't do that
	return (0);
}
Esempio n. 8
0
void CtrlrGroupContentComponent::customLookAndFeelChanged(LookAndFeelBase *customLookAndFeel)
{
    for (int i=0; i<getNumChildComponents(); i++)
    {
        CtrlrComponent *c = dynamic_cast<CtrlrComponent*>(getChildComponent(i));

        if (c!=nullptr)
        {
            c->setCustomLookAndFeel (customLookAndFeel);
        }
    }
}
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);
				}
			}
		}
	}
}
Esempio n. 10
0
void CtrlrPanelUtilities::reloadContent()
{
    if ((owner.isVisible() && owner.getSelection()->getNumSelected() == 0) || owner.getSelection()->getNumSelected() > 1)
	{
		ScopedPointer <XmlElement> xml (owner.getOwner().getPanelTree().createXml());
		if (xml)
		{
			codeDocument.replaceAllContent (xml->createDocument(String::empty));
		}
	}
	else if (owner.isVisible() && owner.getSelection()->getNumSelected() == 1)
	{
		CtrlrComponent *c =  owner.getSelection()->getSelectedItem(0);
		if (c)
		{
			ScopedPointer <XmlElement> xml (c->getOwner().getModulatorTree().createXml());
			String doc = xml->createDocument(String::empty);
			if (doc.length() <= 8192)
			{
				codeDocument.replaceAllContent (doc);
			}
		}
	}
}
void CtrlrPanelCanvas::handleRightClickOnComponent(const MouseEvent &e)
{
	CtrlrComponent *c = findEventComponent(e);

	if (c == 0)
		return;

	if (dynamic_cast<ResizableBorderComponent*>(e.eventComponent) == 0 && getOwner().getSelection())
	{
		getOwner().getSelection()->selectOnly (c);
	}

	PopupMenu m;
	PopupMenu componentSubMenu = CtrlrComponentTypeManager::getComponentMenu(true);
	m.addSectionHeader ("Actions");
	m.addItem (512, "Export component");
	m.addItem (513, "Lock", true, c->getProperty(Ids::componentIsLocked));

	m.addSectionHeader ("Layout");
	m.addItem (1024, "Send to back");
	m.addItem (1025, "Send to front");
	m.addSubMenu ("Send to layer", getLayerMenu());
	m.addSeparator();
	m.addSubMenu ("Replace with", componentSubMenu, true);

	m.addSeparator();
	getEditMenu(m);

	m.addSeparator();
	if (CtrlrComponentTypeManager::isGroupingComponent(c))
	{
		m.addItem (1026, "Delete with children");
		m.addItem (1027, "Copy with children");
	}

	const int ret = m.show();

	if (ret == 512)
	{
		exportSelectedComponents();
	}
	else if (ret == 513)
	{
		c->setProperty (Ids::componentIsLocked, !c->getProperty(Ids::componentIsLocked));
	}
	if (ret == 1024)
	{
		c->toBack();
		c->setProperty (Ids::componentSentBack, true);
	}
	else if (ret == 1025)
	{
		c->toFront(false);
		c->setProperty (Ids::componentSentBack, false);
	}
	else if (ret == 1026)
	{
		deleteWithChildren (c);
	}
	else if (ret == 1027)
	{
		copyWithChildren (c);
	}
	else if (ret >= 2048 && ret < 4096)
	{
		handleEditMenu (ret, e);
	}
	else if (ret >= 4096 && ret < 8192)
    {
        handleLayerMenu (ret, e);
    }
	else if (ret < 1024 && ret > 10)
	{
		PopupMenu::MenuItemIterator iterator((const PopupMenu &)componentSubMenu);
		while (iterator.next())
		{
			if (iterator.getItem().subMenu)
			{
				PopupMenu::MenuItemIterator iterator2(*iterator.getItem().subMenu);
				while (iterator2.next())
				{
					if (iterator2.getItem().itemID == ret)
					{
						if (c)
						{
							replaceComponent (c->getOwner(), iterator2.getItem().text);
							return;
						}
					}
				}
			}
		}
	}
}