aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.h
blob: 66cd566657a72c41e1137030629bc1fc7b0349ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once

#include <QGraphicsObject>

#include <qmlanchors.h>

namespace QmlDesigner {

class AnchorIndicatorGraphicsItem : public QGraphicsObject
{
    Q_OBJECT
public:
    explicit AnchorIndicatorGraphicsItem(QGraphicsItem *parent = nullptr);


    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
    QRectF boundingRect() const override;

    void updateAnchorIndicator(const AnchorLine &sourceAnchorLine, const AnchorLine &targetAnchorLine);

    AnchorLineType sourceAnchorLineType() const;
    void setSourceAnchorLineType(const AnchorLineType &sourceAnchorLineType);

protected:
    void updateBoundingRect();

private:
    QPointF m_startPoint;
    QPointF m_firstControlPoint;
    QPointF m_secondControlPoint;
    QPointF m_endPoint;
    QPointF m_sourceAnchorLineFirstPoint;
    QPointF m_sourceAnchorLineSecondPoint;
    QPointF m_targetAnchorLineFirstPoint;
    QPointF m_targetAnchorLineSecondPoint;
    AnchorLineType m_sourceAnchorLineType = AnchorLineInvalid;
    AnchorLineType m_targetAnchorLineType = AnchorLineInvalid;
    QRectF m_boundingRect;
};

} // namespace QmlDesigner