aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/curveeditor/detail/handleitem.h
blob: 47351abb1f0e8f82acbc78b05735506789bfbd02 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (C) 2019 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 "curveeditorstyle.h"
#include "selectableitem.h"

namespace QmlDesigner {

class KeyframeItem;
class CurveSegment;

class HandleItem : public SelectableItem
{
    Q_OBJECT

public:
    enum { Type = ItemTypeHandle };

    enum class Slot { Undefined, Left, Right };

    HandleItem(QGraphicsItem *parent, HandleItem::Slot slot);

    ~HandleItem() override;

    int type() const override;

    QRectF boundingRect() const override;

    bool contains(const QPointF &point) const override;

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

    void underMouseCallback() override;

    bool keyframeSelected() const;

    CurveSegment segment() const;

    KeyframeItem *keyframe() const;

    Slot slot() const;

    void setStyle(const CurveEditorStyle &style);

protected:
    QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) override;

private:
    Slot m_slot;

    HandleItemStyleOption m_style;

    QPointF m_validPos;
};

} // End namespace QmlDesigner.