Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsvganimate_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QSVGANIMATE_P_H
7#define QSVGANIMATE_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include "qsvgnode_p.h"
21#include <QtSvg/private/qsvgabstractanimation_p.h>
22#include <QtSvg/private/qsvgeasinginterface_p.h>
23#include <QtCore/qminmax.h>
24
26
27class Q_SVG_EXPORT QSvgLinearEasing : public QSvgEasingInterface
28{
29public:
30 virtual qreal progress(qreal t) override
31 {
32 return qBound(0., t, 1.);
33 }
34};
35
36class Q_SVG_EXPORT QSvgAnimateNode : public QSvgNode, public QSvgAbstractAnimation
37{
38public:
39 enum Additive
40 {
41 Sum,
42 Replace
43 };
44 enum Fill
45 {
46 Freeze,
47 Remove
48 };
49
50public:
51 QSvgAnimateNode(QSvgNode *parent = nullptr);
52 virtual ~QSvgAnimateNode() {}
53
54 void setLinkId(const QString &link) { m_linkId = link; }
55 const QString &linkId() const { return m_linkId; }
56
57 virtual AnimationType animationType() const override { return AnimationType::SMIL; }
58 virtual bool isActive() const override { return !finished() || m_fill == Fill::Freeze; }
59
60 void setRunningTime(int startMs, int durMs, int endMs, int by);
61 void setRepeatCount(qreal repeatCount) { setIterationCount(repeatCount); }
62
63 void setFill(Fill fill) { m_fill = fill; }
64 Fill fill() const { return m_fill; }
65
66 void setAdditiveType(Additive additive = Additive::Replace) { m_additive = additive; }
67 Additive additiveType() const { return m_additive; }
68
69 virtual void drawCommand(QPainter *p, QSvgExtraStates &states) override;
70 virtual bool shouldDrawNode(QPainter *p, QSvgExtraStates &states) const override;
71
72protected:
73 qreal m_end;
74 Fill m_fill;
75 Additive m_additive;
76 QString m_linkId;
77};
78
79class Q_SVG_EXPORT QSvgAnimateColor : public QSvgAnimateNode
80{
81public:
82 QSvgAnimateColor(QSvgNode *parent = nullptr) : QSvgAnimateNode(parent) {}
83 virtual Type type() const override { return QSvgNode::AnimateColor; }
84};
85
86class Q_SVG_EXPORT QSvgAnimateTransform : public QSvgAnimateNode
87{
88public:
89 QSvgAnimateTransform(QSvgNode *parent = nullptr) : QSvgAnimateNode(parent) {}
90 virtual Type type() const override { return Type::AnimateTransform; }
91};
92
93QT_END_NAMESPACE
94
95#endif // QSVGANIMATE_P_H
Combined button and popup list for selecting options.