1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-20 01:14:20 +00:00

Projucer: The GUI editor now generates paint code containing extra variables for the coordinates, so that these can be overridden individually in custom code blocks

This commit is contained in:
jules 2017-05-05 09:57:10 +01:00
parent 457e838971
commit 730e603b02
21 changed files with 503 additions and 305 deletions

View file

@ -293,16 +293,9 @@ void PaintRoutine::copySelectedToClipboard()
XmlElement clip (clipboardXmlTag);
for (int i = 0; i < elements.size(); ++i)
{
PaintElement* const pe = elements.getUnchecked(i);
for (auto* pe : elements)
if (selectedElements.isSelected (pe))
{
XmlElement* const e = pe->createXml();
clip.addChildElement (e);
}
}
clip.addChildElement (pe->createXml());
SystemClipboard::copyTextToClipboard (clip.createDocument ("", false, false));
}
@ -325,8 +318,8 @@ void PaintRoutine::paste()
void PaintRoutine::deleteSelected()
{
const SelectedItemSet <PaintElement*> temp1 (selectedElements);
const SelectedItemSet <PathPoint*> temp2 (selectedPoints);
const SelectedItemSet<PaintElement*> temp1 (selectedElements);
const SelectedItemSet<PathPoint*> temp2 (selectedPoints);
if (temp2.getNumSelected() > 0)
{
@ -369,7 +362,7 @@ void PaintRoutine::selectAll()
void PaintRoutine::selectedToFront()
{
const SelectedItemSet <PaintElement*> temp (selectedElements);
const SelectedItemSet<PaintElement*> temp (selectedElements);
for (int i = temp.getNumSelected(); --i >= 0;)
elementToFront (temp.getSelectedItem(i), true);
@ -377,7 +370,7 @@ void PaintRoutine::selectedToFront()
void PaintRoutine::selectedToBack()
{
const SelectedItemSet <PaintElement*> temp (selectedElements);
const SelectedItemSet<PaintElement*> temp (selectedElements);
for (int i = 0; i < temp.getNumSelected(); ++i)
elementToBack (temp.getSelectedItem(i), true);
@ -399,11 +392,9 @@ void PaintRoutine::ungroupSelected()
void PaintRoutine::bringLostItemsBackOnScreen (const Rectangle<int>& parentArea)
{
for (int i = 0; i < elements.size(); ++i)
for (auto* c : elements)
{
PaintElement* const c = elements[i];
Rectangle<int> r (c->getCurrentBounds (parentArea));
auto r = c->getCurrentBounds (parentArea);
if (! r.intersects (parentArea))
{
@ -415,11 +406,9 @@ void PaintRoutine::bringLostItemsBackOnScreen (const Rectangle<int>& parentArea)
void PaintRoutine::startDragging (const Rectangle<int>& parentArea)
{
for (int i = 0; i < elements.size(); ++i)
for (auto* c : elements)
{
PaintElement* const c = elements[i];
Rectangle<int> r (c->getCurrentBounds (parentArea));
auto r = c->getCurrentBounds (parentArea);
c->getProperties().set ("xDragStart", r.getX());
c->getProperties().set ("yDragStart", r.getY());
@ -490,8 +479,8 @@ void PaintRoutine::drawElements (Graphics& g, const Rectangle<int>& relativeTo)
Component temp;
temp.setBounds (relativeTo);
for (int i = 0; i < elements.size(); ++i)
elements.getUnchecked (i)->draw (g, getDocument()->getComponentLayout(), relativeTo);
for (auto* e : elements)
e->draw (g, getDocument()->getComponentLayout(), relativeTo);
}
//==============================================================================
@ -501,17 +490,16 @@ void PaintRoutine::dropImageAt (const File& f, int x, int y)
if (d != nullptr)
{
Rectangle<float> bounds (d->getDrawableBounds());
auto bounds = d->getDrawableBounds();
d = nullptr;
PaintElement* newElement
= addNewElement (ObjectTypes::createNewImageElement (this), -1, true);
auto* newElement = addNewElement (ObjectTypes::createNewImageElement (this), -1, true);
if (PaintElementImage* pei = dynamic_cast<PaintElementImage*> (newElement))
if (auto* pei = dynamic_cast<PaintElementImage*> (newElement))
{
String resourceName (getDocument()->getResources().findUniqueName (f.getFileName()));
if (const BinaryResources::BinaryResource* existingResource = getDocument()->getResources().getResourceForFile (f))
if (auto* existingResource = getDocument()->getResources().getResourceForFile (f))
{
resourceName = existingResource->name;
}
@ -546,12 +534,11 @@ const char* PaintRoutine::xmlTagName = "BACKGROUND";
XmlElement* PaintRoutine::createXml() const
{
XmlElement* const xml = new XmlElement (xmlTagName);
auto* xml = new XmlElement (xmlTagName);
xml->setAttribute ("backgroundColour", backgroundColour.toString());
for (int i = 0; i < elements.size(); ++i)
xml->addChildElement (elements.getUnchecked (i)->createXml());
for (auto* e : elements)
xml->addChildElement (e->createXml());
return xml;
}
@ -565,7 +552,7 @@ bool PaintRoutine::loadFromXml (const XmlElement& xml)
clear();
forEachXmlChildElement (xml, e)
if (PaintElement* const newElement = ObjectTypes::createElementForXml (e, this))
if (auto* newElement = ObjectTypes::createElementForXml (e, this))
elements.add (newElement);
return true;
@ -579,6 +566,12 @@ void PaintRoutine::fillInGeneratedCode (GeneratedCode& code, String& paintMethod
if (! backgroundColour.isTransparent())
paintMethodCode << "g.fillAll (" << CodeHelpers::colourToCode (backgroundColour) << ");\n\n";
for (int i = 0; i < elements.size(); ++i)
elements[i]->fillInGeneratedCode (code, paintMethodCode);
for (auto* e : elements)
e->fillInGeneratedCode (code, paintMethodCode);
}
void PaintRoutine::applyCustomPaintSnippets (StringArray& snippets)
{
for (auto* e : elements)
e->applyCustomPaintSnippets (snippets);
}