void QmlAnchorBindingProxy::anchorRight() { m_locked = true; bool rightTargetIsParent = m_rightTarget == m_qmlItemNode.instanceParentItem(); if (m_relativeRightTarget == SameEdge) { qreal rightPos = rightTargetIsParent ? parentBoundingBox().right() : boundingBox(m_rightTarget).right(); qreal rightMargin = rightPos - transformedBoundingBox().right(); m_qmlItemNode.anchors().setMargin( AnchorLineRight, rightMargin); m_qmlItemNode.anchors().setAnchor(AnchorLineRight, m_rightTarget, AnchorLineRight); } else if (m_relativeRightTarget == OppositeEdge) { qreal leftPos = rightTargetIsParent ? parentBoundingBox().left() : boundingBox(m_rightTarget).left(); qreal rightMargin = leftPos - transformedBoundingBox().right(); m_qmlItemNode.anchors().setMargin( AnchorLineRight, rightMargin); m_qmlItemNode.anchors().setAnchor(AnchorLineRight, m_rightTarget, AnchorLineLeft); } else if (m_relativeRightTarget == Center) { qreal centerPos = rightTargetIsParent ? parentBoundingBox().center().x() : boundingBox(m_rightTarget).center().x(); qreal rightMargin = centerPos - transformedBoundingBox().right(); m_qmlItemNode.anchors().setMargin(AnchorLineRight, rightMargin); m_qmlItemNode.anchors().setAnchor(AnchorLineRight, m_rightTarget, AnchorLineHorizontalCenter); } m_locked = false; }
void QmlAnchorBindingProxy::anchorBottom() { m_locked = true; bool bottomTargetIsParent = m_bottomTarget == m_qmlItemNode.instanceParentItem(); if (m_relativeBottomTarget == SameEdge) { qreal bottomPos = bottomTargetIsParent ? parentBoundingBox().bottom() : boundingBox(m_bottomTarget).bottom(); qreal bottomMargin = bottomPos - transformedBoundingBox().bottom(); m_qmlItemNode.anchors().setMargin( AnchorLineBottom, bottomMargin); m_qmlItemNode.anchors().setAnchor(AnchorLineBottom, m_bottomTarget, AnchorLineBottom); } else if (m_relativeBottomTarget == OppositeEdge) { qreal topPos = bottomTargetIsParent ? parentBoundingBox().top() : boundingBox(m_bottomTarget).top(); qreal bottomMargin = topPos - transformedBoundingBox().bottom(); m_qmlItemNode.anchors().setMargin( AnchorLineBottom, bottomMargin); m_qmlItemNode.anchors().setAnchor(AnchorLineBottom, m_bottomTarget, AnchorLineTop); } else if (m_relativeBottomTarget == Center) { qreal centerPos = bottomTargetIsParent ? parentBoundingBox().center().y() : boundingBox(m_bottomTarget).center().y(); qreal bottomMargin = centerPos - transformedBoundingBox().bottom(); m_qmlItemNode.anchors().setMargin(AnchorLineBottom, bottomMargin); m_qmlItemNode.anchors().setAnchor(AnchorLineBottom, m_bottomTarget, AnchorLineVerticalCenter); } m_locked = false; }
void QmlAnchorBindingProxy::calcBottomMargin() { m_locked = true; if (m_bottomTarget.modelNode() == m_fxItemNode.modelNode().parentProperty().parentModelNode()) { qreal bottomMargin = parentBoundingBox().bottom() - transformedBoundingBox().bottom(); m_fxItemNode.anchors().setMargin( AnchorLine::Bottom, bottomMargin); m_fxItemNode.anchors().setAnchor(AnchorLine::Bottom, m_bottomTarget, AnchorLine::Bottom); } else { qreal bottomMargin = boundingBox(m_bottomTarget).top()- boundingBox(m_fxItemNode).bottom(); m_fxItemNode.anchors().setMargin( AnchorLine::Bottom, bottomMargin); m_fxItemNode.anchors().setAnchor(AnchorLine::Bottom, m_bottomTarget, AnchorLine::Top); } m_locked = false; }
void QmlAnchorBindingProxy::calcRightMargin() { m_locked = true; if (m_rightTarget.modelNode() == m_fxItemNode.modelNode().parentProperty().parentModelNode()) { qreal rightMargin = parentBoundingBox().right() - transformedBoundingBox().right(); m_fxItemNode.anchors().setMargin( AnchorLine::Right, rightMargin); m_fxItemNode.anchors().setAnchor(AnchorLine::Right, m_rightTarget, AnchorLine::Right); } else { qreal rightMargin = boundingBox(m_rightTarget).left() - boundingBox(m_fxItemNode).right(); m_fxItemNode.anchors().setMargin( AnchorLine::Right, rightMargin); m_fxItemNode.anchors().setAnchor(AnchorLine::Right, m_rightTarget, AnchorLine::Left); } m_locked = false; }
void QmlAnchorBindingProxy::calcTopMargin() { m_locked = true; if (m_topTarget.modelNode() == m_qmlItemNode.modelNode().parentProperty().parentModelNode()) { qreal topMargin = transformedBoundingBox().top() - parentBoundingBox().top(); m_qmlItemNode.anchors().setMargin( AnchorLineTop, topMargin); m_qmlItemNode.anchors().setAnchor(AnchorLineTop, m_topTarget, AnchorLineTop); } else { qreal topMargin = boundingBox(m_qmlItemNode).top() - boundingBox(m_topTarget).bottom(); m_qmlItemNode.anchors().setMargin( AnchorLineTop, topMargin); m_qmlItemNode.anchors().setAnchor(AnchorLineTop, m_topTarget, AnchorLineBottom); } m_locked = false; }