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