blob: 0a0f3537175e231b51ddc891ecdd23a3778e0e47 (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef ROWTIMELINE_H
#define ROWTIMELINE_H
#include "InteractiveTimelineItem.h"
#include "RowTypes.h"
#include "Bindings/Qt3DSDMTimelineItemProperty.h"
#include <QtCore/qpointer.h>
#include "RowTimelineCommentItem.h"
class RowTree;
class RowTimelinePropertyGraph;
struct Keyframe;
class RowTimeline : public InteractiveTimelineItem
{
Q_OBJECT
public:
explicit RowTimeline();
~RowTimeline();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) override;
void setState(State state) override;
void setRowTree(RowTree *rowTree);
void updatePosition();
void startDurationMove(double clickX);
void updateBoundChildren(bool start);
void clearBoundChildren();
void moveDurationBy(double dx);
void moveDurationTo(double newX);
void setStartTime(long startTime);
void setEndTime(long endTime);
void setStartX(double startX);
void setEndX(double endX);
void setBarColor(const QColor &color);
void setControllerText(const QString &controller);
void putSelectedKeyframesOnTop();
void updateKeyframes();
void insertKeyframe(Keyframe *keyframe);
void removeKeyframe(Keyframe *keyframe);
void updateKeyframesFromBinding(const QList<int> &properties);
void updateDurationFromBinding();
TimelineControlType getClickedControl(const QPointF &scenePos) const;
double getStartX() const;
double getEndX() const;
long getStartTime() const;
long getEndTime() const;
long getDurationMoveTime() const; // the time a row duration has moved (to commit to binding)
double getDurationMoveOffsetX() const;
long getDuration() const;
QColor barColor() const;
int type() const override;
RowTimeline *parentRow() const;
RowTree *rowTree() const;
Keyframe *getClickedKeyframe(const QPointF &scenePos);
QList<Keyframe *> getKeyframesInRange(const QRectF &rect) const;
QList<Keyframe *> keyframes() const;
void showToolTip(const QPointF &pos);
protected:
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
private:
void initialize();
void updateChildrenStartRecursive();
void updateChildrenEndRecursive();
void updateChildrenMinStartXRecursive(RowTree *rowTree);
void updateChildrenMaxEndXRecursive(RowTree *rowTree);
void updateCommentItem();
void updateCommentItemPos();
void drawColorPropertyGradient(QPainter *painter, int width);
bool isColorProperty() const;
QString formatTime(long millis) const;
double timeToX(long time) const;
long xToTime(double xPos) const;
void collectChildKeyframeTimes(QVector<long> &childKeyframeTimes);
RowTree *m_rowTree;
RowTimelinePropertyGraph *m_propertyGraph = nullptr;
RowTimelineCommentItem *m_commentItem = nullptr;
long m_startTime = 0;
long m_startDurationMoveStartTime = 0;
double m_startDurationMoveOffsetX = 0;
long m_endTime = 0;
double m_startX = 0;
double m_endX = 0;
double m_minStartX = 0;
double m_maxEndX = 0;
bool m_isProperty = false; // used in the destructor
QString m_controllerDataInput;
QList<Keyframe *> m_keyframes;
QColor m_barColor;
QVector<QPointer<RowTimeline>> m_boundChildrenStart;
QVector<QPointer<RowTimeline>> m_boundChildrenEnd;
friend class RowTree;
};
#endif // ROWTIMELINE_H
|