1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef QmlAnchorBindingProxy_h
35 #define QmlAnchorBindingProxy_h
38 #include <modelnode.h>
39 #include <nodeinstanceview.h>
41 #include <qmlitemnode.h>
43 namespace QmlDesigner {
45 class NodeInstanceView;
49 class QmlAnchorBindingProxy : public QObject
53 Q_PROPERTY(bool topAnchored READ topAnchored WRITE setTopAnchor NOTIFY topAnchorChanged)
54 Q_PROPERTY(bool bottomAnchored READ bottomAnchored WRITE setBottomAnchor NOTIFY bottomAnchorChanged)
55 Q_PROPERTY(bool leftAnchored READ leftAnchored WRITE setLeftAnchor NOTIFY leftAnchorChanged)
56 Q_PROPERTY(bool rightAnchored READ rightAnchored WRITE setRightAnchor NOTIFY rightAnchorChanged)
57 Q_PROPERTY(bool hasParent READ hasParent NOTIFY parentChanged)
59 Q_PROPERTY(QVariant topTarget READ topTarget WRITE setTopTarget NOTIFY topTargetChanged)
60 Q_PROPERTY(QVariant bottomTarget READ bottomTarget WRITE setBottomTarget NOTIFY bottomTargetChanged)
61 Q_PROPERTY(QVariant leftTarget READ leftTarget WRITE setLeftTarget NOTIFY leftTargetChanged)
62 Q_PROPERTY(QVariant rightTarget READ rightTarget WRITE setRightTarget NOTIFY rightTargetChanged)
64 Q_PROPERTY(QVariant verticalTarget READ verticalTarget WRITE setVerticalTarget NOTIFY verticalTargetChanged)
65 Q_PROPERTY(QVariant horizontalTarget READ horizontalTarget WRITE setHorizontalTarget NOTIFY horizontalTargetChanged)
67 Q_PROPERTY(bool hasAnchors READ hasAnchors NOTIFY anchorsChanged)
68 Q_PROPERTY(bool isFilled READ isFilled NOTIFY anchorsChanged)
70 Q_PROPERTY(bool horizontalCentered READ horizontalCentered WRITE setHorizontalCentered NOTIFY centeredHChanged)
71 Q_PROPERTY(bool verticalCentered READ verticalCentered WRITE setVerticalCentered NOTIFY centeredVChanged)
72 Q_PROPERTY(QVariant itemNode READ itemNode NOTIFY itemNodeChanged)
75 //only enable if node has parent
77 QmlAnchorBindingProxy(QObject *parent = 0);
78 ~QmlAnchorBindingProxy();
80 void setup(const QmlItemNode &itemNode);
81 void invalidate(const QmlItemNode &itemNode);
84 bool bottomAnchored();
91 void removeTopAnchor();
92 void removeBottomAnchor();
93 void removeLeftAnchor();
94 void removeRightAnchor();
97 bool horizontalCentered();
98 bool verticalCentered();
99 QVariant itemNode() const { return QVariant::fromValue(m_fxItemNode.modelNode()); }
101 QVariant topTarget() const { return QVariant::fromValue(m_topTarget.modelNode()); }
102 QVariant bottomTarget() const { return QVariant::fromValue(m_bottomTarget.modelNode()); }
103 QVariant leftTarget() const { return QVariant::fromValue(m_leftTarget.modelNode()); }
104 QVariant rightTarget() const { return QVariant::fromValue(m_rightTarget.modelNode()); }
106 QVariant verticalTarget() const { return QVariant::fromValue(m_verticalTarget.modelNode()); }
107 QVariant horizontalTarget() const { return QVariant::fromValue(m_horizontalTarget.modelNode()); }
110 void setTopTarget(const QVariant &target);
111 void setBottomTarget(const QVariant &target);
112 void setLeftTarget(const QVariant &target);
113 void setRightTarget(const QVariant &target);
114 void setVerticalTarget(const QVariant &target);
115 void setHorizontalTarget(const QVariant &target);
121 void setTopAnchor(bool anchor =true);
122 void setBottomAnchor(bool anchor = true);
123 void setLeftAnchor(bool anchor = true);
124 void setRightAnchor(bool anchor = true);
126 void setVerticalCentered(bool centered = true);
127 void setHorizontalCentered(bool centered = true);
130 void parentChanged();
132 void topAnchorChanged();
133 void bottomAnchorChanged();
134 void leftAnchorChanged();
135 void rightAnchorChanged();
136 void centeredVChanged();
137 void centeredHChanged();
138 void anchorsChanged();
139 void itemNodeChanged();
141 void topTargetChanged();
142 void bottomTargetChanged();
143 void leftTargetChanged();
144 void rightTargetChanged();
146 void verticalTargetChanged();
147 void horizontalTargetChanged();
151 void calcTopMargin();
152 void calcBottomMargin();
153 void calcLeftMargin();
154 void calcRightMargin();
156 QmlItemNode m_fxItemNode;
158 QRectF parentBoundingBox();
160 QRectF boundingBox(QmlItemNode node);
162 QRectF transformedBoundingBox();
164 QmlItemNode m_topTarget;
165 QmlItemNode m_bottomTarget;
166 QmlItemNode m_leftTarget;
167 QmlItemNode m_rightTarget;
169 QmlItemNode m_verticalTarget;
170 QmlItemNode m_horizontalTarget;
175 } // namespace Internal
176 } // namespace QmlDesigner
179 #endif //QmlAnchorBindingProxy