Browse Source

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

tags/2021-05-28
ed 6 years ago
parent
commit
7f4b094018
3 changed files with 11 additions and 1 deletions
  1. +1
    -1
      extras/Projucer/Source/ComponentEditor/Components/jucer_ComponentTypeHandler.cpp
  2. +9
    -0
      extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.cpp
  3. +1
    -0
      extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.h

+ 1
- 1
extras/Projucer/Source/ComponentEditor/Components/jucer_ComponentTypeHandler.cpp 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;


+ 9
- 0
extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.cpp 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


+ 1
- 0
extras/Projucer/Source/ComponentEditor/jucer_ComponentLayout.h 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);


Loading…
Cancel
Save