Envision
A visual programming IDE for object-oriented languages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
Visualization::AnchorLayoutFormElement Class Reference
Inheritance diagram for Visualization::AnchorLayoutFormElement:
Visualization::SuperLayoutElement< AnchorLayoutFormElement, LayoutFormElement > Visualization::SuperFormElement< NewFormElement, BaseFormElement >

Public Member Functions

 AnchorLayoutFormElement ()
 
 AnchorLayoutFormElement (const AnchorLayoutFormElement &other)
 
virtual ~AnchorLayoutFormElement ()
 
virtual AnchorLayoutFormElementclone () const override
 
virtual void computeSize (Item *item, int availableWidth, int availableHeight) override
 
AnchorLayoutFormElementoperator= (const AnchorLayoutFormElement &)=delete
 
AnchorLayoutFormElementput (PlaceEdge placeEdge, FormElement *placeElement, AtEdge atEdge, FormElement *fixedElement)
 Add an anchor to the layout, placing the placeEdge of the placeElement at the atEdge of the fixedElement. More...
 
AnchorLayoutFormElementput (PlaceEdge placeEdge, FormElement *placeElement, float relativeEdgePosition, FormElement *fixedElement)
 Add an anchor to the layout, placing the placeEdge of the placeElement at the position fixedElement.position + fixedElement.size * relativeEdge in the axis given by the placeEdge. More...
 
AnchorLayoutFormElementput (PlaceEdge placeEdge, FormElement *placeElement, int offset, FromEdge fromEdge, FormElement *fixedElement)
 Add an anchor to the layout, placing the placeEdge of the placeElement offset units from the fromEdge of the fixedElement. More...
 
virtual bool sizeDependsOnParent (const Item *item) const override
 
- Public Member Functions inherited from Visualization::SuperLayoutElement< AnchorLayoutFormElement, LayoutFormElement >
AnchorLayoutFormElementsetHasCursorWhenEmpty (std::function< bool(Item *item)> hasCursorWhenEmptyGetter)
 Sets a getter (cursorWhenEmptyGetter) for checking if the element should have cursors when empty dynamically while rendering. More...
 
AnchorLayoutFormElementsetNoBoundaryCursors (std::function< bool(Item *item)> noBoundaryCursorsGetter)
 Sets a getter (noBoundaryCursorsGetter) for checking if the element should not have any boundary cursors dynamically while rendering. More...
 
AnchorLayoutFormElementsetNoInnerCursors (std::function< bool(Item *item)> noInnerCursorsGetter)
 Sets a getter (noInnerCursorsGetter) for checking if the element should not have any inner cursors dynamically while rendering. More...
 
AnchorLayoutFormElementsetNotLocationEquivalentCursors (std::function< bool(Item *item)> notLocationEquivalentCursorsGetter)
 Sets a getter (notLocationEquivalentGetter) for checking if the element's cursors are not location equivalent dynamically while rendering. More...
 
- Public Member Functions inherited from Visualization::SuperFormElement< NewFormElement, BaseFormElement >
NewFormElement * setBottomMargin (int bottom)
 Sets the bottom margin of this form element. More...
 
NewFormElement * setLeftMargin (int left)
 Sets the left margin of this form element. More...
 
NewFormElement * setMargins (int left, int top, int right, int bottom)
 Sets the left, top, right and bottom margins to the respective values. More...
 
NewFormElement * setMargins (int margin)
 Sets all the margins of this form element to the value specified as margin. More...
 
NewFormElement * setRightMargin (int right)
 Sets the right margin of this form element. More...
 
NewFormElement * setTopMargin (int top)
 Sets the top margin of this form element. More...
 

Private Types

enum  Edge { Left , Right , Center , VCenter , HCenter , Top , Bottom }
 

Private Member Functions

void addConstraint (QList< AnchorLayoutAnchor * > &constraints, AnchorLayoutAnchor::Orientation orientation, float relativePlaceEdgePosition, FormElement *placeElement, int offset, float relativeFixedEdgePosition, FormElement *fixedElement)
 Adds a constraint, consisting of the orientation, the relativePlaceEdgePosition, the placeElement, the offset, the relativeFixedEdgePosition, and the fixedElement to the list of constraints. More...
 
void cloneConstraints (QList< AnchorLayoutAnchor * > &thisConstraints, const QList< AnchorLayoutAnchor * > &otherConstraints, QMap< FormElement *, FormElement * > &matching)
 Clones one set of constraints. More...
 
FormElementfindChildMatch (FormElement *element)
 Finds the proper match for element when putting it into the anchor layout. More...
 
AnchorLayoutAnchor::Orientation inferOrientation (Edge firstEdge, Edge secondEdge)
 Computes orientation of firstEdge and secondEdge, fails if orientation cannot be inferred (both are Center) of if the edges have conflicting orientations (e.g. More...
 
AnchorLayoutAnchor::Orientation orientation (Edge edge)
 Returns the orientation of the given edge. More...
 
int placeElements (QList< AnchorLayoutAnchor * > &constraints, AnchorLayoutAnchor::Orientation orientation, Item *item)
 Computes the positions in the orientation of all the elements for this item, using the list of constraints. More...
 
AnchorLayoutFormElementput (AnchorLayoutAnchor::Orientation orientation, float relativePlaceEdgePosition, FormElement *placeElement, int offset, float relativeFixedEdgePosition, FormElement *fixedElement)
 General method, that all the other put methods get translated to. More...
 
float relativePosition (Edge edge)
 Returns the relative position in an element of this edge. More...
 
void sortConstraints (QList< AnchorLayoutAnchor * > &constraints, AnchorLayoutAnchor::Orientation orientation)
 Sorts the constraints by what needs to be done first. More...
 

Private Attributes

BorderFormElementborderFormElement_ {}
 
QMap< FormElement *, FormElement * > externalMatches_ {}
 
QList< AnchorLayoutAnchor * > horizontalConstraints_ {}
 
AnchorLayoutConstraintSolverhorizontalSolver_ {}
 
bool needsHorizontalSolver_ {}
 
bool needsVerticalSolver_ {}
 
QList< AnchorLayoutAnchor * > verticalConstraints_ {}
 
AnchorLayoutConstraintSolververticalSolver_ {}
 

Member Enumeration Documentation

◆ Edge

Enumerator
Left 
Right 
Center 
VCenter 
HCenter 
Top 
Bottom 

Constructor & Destructor Documentation

◆ AnchorLayoutFormElement() [1/2]

Visualization::AnchorLayoutFormElement::AnchorLayoutFormElement ( )

◆ AnchorLayoutFormElement() [2/2]

Visualization::AnchorLayoutFormElement::AnchorLayoutFormElement ( const AnchorLayoutFormElement other)

◆ ~AnchorLayoutFormElement()

Visualization::AnchorLayoutFormElement::~AnchorLayoutFormElement ( )
virtual

Member Function Documentation

◆ addConstraint()

void Visualization::AnchorLayoutFormElement::addConstraint ( QList< AnchorLayoutAnchor * > &  constraints,
AnchorLayoutAnchor::Orientation  orientation,
float  relativePlaceEdgePosition,
FormElement placeElement,
int  offset,
float  relativeFixedEdgePosition,
FormElement fixedElement 
)
private

Adds a constraint, consisting of the orientation, the relativePlaceEdgePosition, the placeElement, the offset, the relativeFixedEdgePosition, and the fixedElement to the list of constraints.

◆ clone()

AnchorLayoutFormElement * Visualization::AnchorLayoutFormElement::clone ( ) const
overridevirtual

◆ cloneConstraints()

void Visualization::AnchorLayoutFormElement::cloneConstraints ( QList< AnchorLayoutAnchor * > &  thisConstraints,
const QList< AnchorLayoutAnchor * > &  otherConstraints,
QMap< FormElement *, FormElement * > &  matching 
)
private

Clones one set of constraints.

◆ computeSize()

void Visualization::AnchorLayoutFormElement::computeSize ( Item item,
int  availableWidth,
int  availableHeight 
)
overridevirtual

◆ findChildMatch()

FormElement * Visualization::AnchorLayoutFormElement::findChildMatch ( FormElement element)
private

Finds the proper match for element when putting it into the anchor layout.

When putting an element into an Anchor layout sveral situations can occur:

  • The element is not yet used anywhere (it has no parent and is not a root form). In this case this method simply returns the element itself.
  • The element is already used by this Anchor layout. In this case the element itself is returned.
  • The element is already used by another layout or is a form root. In this case the element is cloned the first time this method is called and the clone is always returned when the method is called for the same element argument.

◆ inferOrientation()

AnchorLayoutAnchor::Orientation Visualization::AnchorLayoutFormElement::inferOrientation ( Edge  firstEdge,
Edge  secondEdge 
)
private

Computes orientation of firstEdge and secondEdge, fails if orientation cannot be inferred (both are Center) of if the edges have conflicting orientations (e.g.

Orientation::Left and Orientation::Top). Returns either Orientation::Horizontal or Orientation::Vertical.

◆ operator=()

AnchorLayoutFormElement& Visualization::AnchorLayoutFormElement::operator= ( const AnchorLayoutFormElement )
delete

◆ orientation()

AnchorLayoutAnchor::Orientation Visualization::AnchorLayoutFormElement::orientation ( Edge  edge)
private

Returns the orientation of the given edge.

(E.g. horizontal for left, vertical for top, ...) If the orientation is not given for this edge (i.e. it is center), returns Orientation::Auto.

◆ placeElements()

int Visualization::AnchorLayoutFormElement::placeElements ( QList< AnchorLayoutAnchor * > &  constraints,
AnchorLayoutAnchor::Orientation  orientation,
Item item 
)
private

Computes the positions in the orientation of all the elements for this item, using the list of constraints.

◆ put() [1/4]

AnchorLayoutFormElement * Visualization::AnchorLayoutFormElement::put ( AnchorLayoutAnchor::Orientation  orientation,
float  relativePlaceEdgePosition,
FormElement placeElement,
int  offset,
float  relativeFixedEdgePosition,
FormElement fixedElement 
)
private

General method, that all the other put methods get translated to.

It puts an anchor in the orientation, and places the relativePlaceEdgePosition of placeElement offset from the relativeFixedEdgePositon of the fixedElement.

If any of placeElement or fixedElement are already used elsewhere (have a parent or are a form root) then they are first cloned, and the corresponding clone is used for the anchor instead.

Returns a pointer to this AnchorLayoutElement.

◆ put() [2/4]

AnchorLayoutFormElement * Visualization::AnchorLayoutFormElement::put ( PlaceEdge  placeEdge,
FormElement placeElement,
AtEdge  atEdge,
FormElement fixedElement 
)

Add an anchor to the layout, placing the placeEdge of the placeElement at the atEdge of the fixedElement.

Returns a pointer to this AnchorLayoutElement.

◆ put() [3/4]

AnchorLayoutFormElement * Visualization::AnchorLayoutFormElement::put ( PlaceEdge  placeEdge,
FormElement placeElement,
float  relativeEdgePosition,
FormElement fixedElement 
)

Add an anchor to the layout, placing the placeEdge of the placeElement at the position fixedElement.position + fixedElement.size * relativeEdge in the axis given by the placeEdge.

Returns a pointer to this AnchorLayoutElement.

◆ put() [4/4]

AnchorLayoutFormElement * Visualization::AnchorLayoutFormElement::put ( PlaceEdge  placeEdge,
FormElement placeElement,
int  offset,
FromEdge  fromEdge,
FormElement fixedElement 
)

Add an anchor to the layout, placing the placeEdge of the placeElement offset units from the fromEdge of the fixedElement.

Returns a pointer to this AnchorLayoutElement.

◆ relativePosition()

float Visualization::AnchorLayoutFormElement::relativePosition ( Edge  edge)
private

Returns the relative position in an element of this edge.

(0 for left, 0.5 for center, 1 for right, ...)

◆ sizeDependsOnParent()

bool Visualization::AnchorLayoutFormElement::sizeDependsOnParent ( const Item item) const
overridevirtual

◆ sortConstraints()

void Visualization::AnchorLayoutFormElement::sortConstraints ( QList< AnchorLayoutAnchor * > &  constraints,
AnchorLayoutAnchor::Orientation  orientation 
)
private

Sorts the constraints by what needs to be done first.

Also detects if there is a circular dependency, and the linear programming solver needs to be used.

Member Data Documentation

◆ borderFormElement_

BorderFormElement* Visualization::AnchorLayoutFormElement::borderFormElement_ {}
private

◆ externalMatches_

QMap<FormElement*, FormElement*> Visualization::AnchorLayoutFormElement::externalMatches_ {}
private

◆ horizontalConstraints_

QList<AnchorLayoutAnchor*> Visualization::AnchorLayoutFormElement::horizontalConstraints_ {}
private

◆ horizontalSolver_

AnchorLayoutConstraintSolver* Visualization::AnchorLayoutFormElement::horizontalSolver_ {}
private

◆ needsHorizontalSolver_

bool Visualization::AnchorLayoutFormElement::needsHorizontalSolver_ {}
private

◆ needsVerticalSolver_

bool Visualization::AnchorLayoutFormElement::needsVerticalSolver_ {}
private

◆ verticalConstraints_

QList<AnchorLayoutAnchor*> Visualization::AnchorLayoutFormElement::verticalConstraints_ {}
private

◆ verticalSolver_

AnchorLayoutConstraintSolver* Visualization::AnchorLayoutFormElement::verticalSolver_ {}
private