1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Projucer: Check if component position is relative to any other components when filling out the setBounds() code in the GUI builder

This commit is contained in:
ed 2018-12-13 10:12:50 +00:00
parent 166e1d1185
commit 7f4b094018
3 changed files with 11 additions and 1 deletions

View file

@ -572,7 +572,7 @@ void ComponentTypeHandler::fillInResizeCode (GeneratedCode& code, Component* com
r << memberVariableName << "->setBounds ("
<< x << ", " << y << ", " << w << ", " << h << ");\n";
if (pos.rect.isPositionAbsolute())
if (pos.rect.isPositionAbsolute() && ! code.document->getComponentLayout()->isComponentPositionRelative (component))
code.constructorCode += r + "\n";
else
code.getCallbackCode (String(), "void", "resized()", false) += r;

View file

@ -554,6 +554,15 @@ bool ComponentLayout::dependsOnComponentForRelativePos (Component* comp, Compone
return false;
}
bool ComponentLayout::isComponentPositionRelative (Component* comp) const
{
for (int i = 0; i < getNumComponents(); ++i)
if (dependsOnComponentForRelativePos (comp, getComponent (i)))
return true;
return false;
}
const int menuIdBase = 0x63240000;
PopupMenu ComponentLayout::getRelativeTargetMenu (Component* comp, int whichDimension) const

View file

@ -71,6 +71,7 @@ public:
void setComponentRelativeTarget (Component* comp, int whichDimension, Component* compToBeRelativeTo);
// checks recursively whether the comp depends on the given comp for its position
bool dependsOnComponentForRelativePos (Component* comp, Component* possibleDependee) const;
bool isComponentPositionRelative (Component* comp) const;
PopupMenu getRelativeTargetMenu (Component* comp, int whichDimension) const;
void processRelativeTargetMenuResult (Component* comp, int whichDimension, int menuResultID);