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