MythTV master
mythuianimation.h
Go to the documentation of this file.
1#ifndef MYTHUIANIMATION_H
2#define MYTHUIANIMATION_H
3
4#include <QDateTime>
5#include <QVariantAnimation>
6
10
11class MythUIType;
12
14{
15 public:
16 enum Centre : std::uint8_t
20
21 UIEffects() = default;
22
23 QPointF GetCentre(const QRect rect, int xoff, int yoff) const
24 {
25 qreal x = static_cast<qreal>(xoff) + rect.left();
26 qreal y = static_cast<qreal>(yoff) + rect.top();
27 if (Middle == m_centre || Top == m_centre || Bottom == m_centre)
28 x += rect.width() / 2.0;
29 if (Middle == m_centre || Left == m_centre || Right == m_centre)
30 y += rect.height() / 2.0;
32 x += rect.width();
34 y += rect.height();
35 return {x, y};
36 }
37
38 QRect GetExtent(QSize size) const;
39
40 int m_alpha {255};
41 float m_hzoom {1.0F};
42 float m_vzoom {1.0F};
43 float m_angle {0.0F};
45};
46
47class MythUIAnimation : public QVariantAnimation, XMLParseBase
48{
49 public:
50 enum Type : std::uint8_t { Alpha, Position, Zoom, HorizontalZoom, VerticalZoom, Angle };
51 enum Trigger : std::uint8_t { AboutToHide, AboutToShow };
52
53 explicit MythUIAnimation(MythUIType* parent = nullptr,
54 Trigger trigger = AboutToShow, Type type = Alpha)
55 : m_parent(parent), m_type(type), m_trigger(trigger) {}
56 void Activate(void);
57 void CopyFrom(const MythUIAnimation* animation);
58 Trigger GetTrigger(void) const { return m_trigger; }
59 QVariant Value() const { return m_value; }
60 bool IsActive() const { return m_active; }
61
62 void updateCurrentValue(const QVariant& value) override; // QVariantAnimation
63
64 void IncrementCurrentTime(void);
65 void SetEasingCurve(const QString &curve);
66 void SetCentre(const QString &centre);
67 void SetLooped(bool looped) { m_looped = looped; }
68 void SetReversible(bool rev) { m_reversible = rev; }
69
70 static void ParseElement(const QDomElement& element, MythUIType* parent);
71
72 private:
73 static void ParseSection(const QDomElement &element,
74 MythUIType* parent, Trigger trigger);
75 static void parseAlpha(const QDomElement& element, QVariant& startValue,
76 QVariant& endValue);
77 static void parsePosition(const QDomElement& element, QVariant& startValue,
78 QVariant& endValue, MythUIType *parent);
79 static void parseZoom(const QDomElement& element, QVariant& startValue,
80 QVariant& endValue);
81 static void parseAngle(const QDomElement& element, QVariant& startValue,
82 QVariant& endValue);
83
84 MythUIType* m_parent {nullptr};
88 QVariant m_value;
89 bool m_active {false};
90 bool m_looped {false};
91 bool m_reversible {false};
93};
94
95#endif // MYTHUIANIMATION_H
void SetLooped(bool looped)
bool IsActive() const
void CopyFrom(const MythUIAnimation *animation)
static void ParseSection(const QDomElement &element, MythUIType *parent, Trigger trigger)
void SetReversible(bool rev)
static void parseAngle(const QDomElement &element, QVariant &startValue, QVariant &endValue)
void SetEasingCurve(const QString &curve)
void SetCentre(const QString &centre)
UIEffects::Centre m_centre
static void ParseElement(const QDomElement &element, MythUIType *parent)
MythUIType * m_parent
MythUIAnimation(MythUIType *parent=nullptr, Trigger trigger=AboutToShow, Type type=Alpha)
static void parseZoom(const QDomElement &element, QVariant &startValue, QVariant &endValue)
static void parsePosition(const QDomElement &element, QVariant &startValue, QVariant &endValue, MythUIType *parent)
static void parseAlpha(const QDomElement &element, QVariant &startValue, QVariant &endValue)
void updateCurrentValue(const QVariant &value) override
void IncrementCurrentTime(void)
Trigger GetTrigger(void) const
QVariant Value() const
std::chrono::milliseconds m_lastUpdate
The base class on which all widgets and screens are based.
Definition: mythuitype.h:86
Centre m_centre
QRect GetExtent(QSize size) const
QPointF GetCentre(const QRect rect, int xoff, int yoff) const
UIEffects()=default
std::chrono::milliseconds currentMSecsSinceEpochAsDuration(void)
Definition: mythdate.cpp:207