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) const
19  {
20  float x = static_cast<float>(xoff) + static_cast<float>(rect.left());
21  float y = static_cast<float>(yoff) + static_cast<float>(rect.top());
22  if (Middle == m_centre || Top == m_centre || Bottom == m_centre)
23  x += static_cast<float>(rect.width()) / 2.0F;
24  if (Middle == m_centre || Left == m_centre || Right == m_centre)
25  y += static_cast<float>(rect.height()) / 2.0F;
27  x += static_cast<float>(rect.width());
29  y += static_cast<float>(rect.height());
30  return {x, y};
31  }
32 
33  QRect GetExtent(const QSize &size) const;
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  explicit 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
MythUIAnimation::m_trigger
Trigger m_trigger
Definition: mythuianimation.h:81
UIEffects::TopLeft
@ TopLeft
Definition: mythuianimation.h:12
UIEffects::m_angle
float m_angle
Definition: mythuianimation.h:38
MythUIAnimation::HorizontalZoom
@ HorizontalZoom
Definition: mythuianimation.h:45
MythUIAnimation::m_value
QVariant m_value
Definition: mythuianimation.h:83
XMLParseBase
Definition: xmlparsebase.h:23
UIEffects::GetExtent
QRect GetExtent(const QSize &size) const
Definition: mythuianimation.cpp:7
MythUIAnimation::Type
Type
Definition: mythuianimation.h:45
MythUIAnimation::m_active
bool m_active
Definition: mythuianimation.h:84
MythUIAnimation::ParseElement
static void ParseElement(const QDomElement &element, MythUIType *parent)
Definition: mythuianimation.cpp:194
MythUIAnimation::ParseSection
static void ParseSection(const QDomElement &element, MythUIType *parent, Trigger trigger)
Definition: mythuianimation.cpp:213
MythUIAnimation::parseZoom
static void parseZoom(const QDomElement &element, QVariant &startValue, QVariant &endValue)
Definition: mythuianimation.cpp:321
MythUIAnimation::CopyFrom
void CopyFrom(const MythUIAnimation *animation)
Definition: mythuianimation.cpp:80
MythUIAnimation::m_reversible
bool m_reversible
Definition: mythuianimation.h:86
MythUIAnimation::Trigger
Trigger
Definition: mythuianimation.h:46
UIEffects::BottomLeft
@ BottomLeft
Definition: mythuianimation.h:14
MythUIAnimation::MythUIAnimation
MythUIAnimation(MythUIType *parent=nullptr, Trigger trigger=AboutToShow, Type type=Alpha)
Definition: mythuianimation.h:48
MythUIAnimation::Alpha
@ Alpha
Definition: mythuianimation.h:45
MythUIAnimation::m_centre
UIEffects::Centre m_centre
Definition: mythuianimation.h:82
MythUIAnimation::VerticalZoom
@ VerticalZoom
Definition: mythuianimation.h:45
MythUIAnimation::parsePosition
static void parsePosition(const QDomElement &element, QVariant &startValue, QVariant &endValue, MythUIType *parent)
Definition: mythuianimation.cpp:293
UIEffects::Bottom
@ Bottom
Definition: mythuianimation.h:14
UIEffects::UIEffects
UIEffects()=default
MythUIAnimation::IsActive
bool IsActive() const
Definition: mythuianimation.h:55
MythUIAnimation::AboutToShow
@ AboutToShow
Definition: mythuianimation.h:46
MythUIAnimation::GetTrigger
Trigger GetTrigger(void) const
Definition: mythuianimation.h:53
UIEffects::TopRight
@ TopRight
Definition: mythuianimation.h:12
UIEffects::Middle
@ Middle
Definition: mythuianimation.h:13
MythUIAnimation::m_looped
bool m_looped
Definition: mythuianimation.h:85
UIEffects::BottomRight
@ BottomRight
Definition: mythuianimation.h:14
MythUIAnimation::parseAngle
static void parseAngle(const QDomElement &element, QVariant &startValue, QVariant &endValue)
Definition: mythuianimation.cpp:328
MythUIAnimation::SetLooped
void SetLooped(bool looped)
Definition: mythuianimation.h:62
MythUIAnimation::updateCurrentValue
void updateCurrentValue(const QVariant &value) override
Definition: mythuianimation.cpp:55
xmlparsebase.h
UIEffects::Top
@ Top
Definition: mythuianimation.h:12
MythUIAnimation::SetEasingCurve
void SetEasingCurve(const QString &curve)
Definition: mythuianimation.cpp:132
MythUIAnimation::Angle
@ Angle
Definition: mythuianimation.h:45
UIEffects::m_centre
Centre m_centre
Definition: mythuianimation.h:39
UIEffects::m_alpha
int m_alpha
Definition: mythuianimation.h:35
MythUIAnimation::m_type
Type m_type
Definition: mythuianimation.h:80
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:64
MythUIAnimation::parseAlpha
static void parseAlpha(const QDomElement &element, QVariant &startValue, QVariant &endValue)
Definition: mythuianimation.cpp:286
MythUIAnimation::Position
@ Position
Definition: mythuianimation.h:45
MythUIAnimation::m_parent
MythUIType * m_parent
Definition: mythuianimation.h:79
UIEffects::m_vzoom
float m_vzoom
Definition: mythuianimation.h:37
MythUIAnimation::Zoom
@ Zoom
Definition: mythuianimation.h:45
MythUIAnimation::IncrementCurrentTime
void IncrementCurrentTime(void)
Definition: mythuianimation.cpp:97
MythUIAnimation
Definition: mythuianimation.h:43
UIEffects::Left
@ Left
Definition: mythuianimation.h:13
UIEffects::Centre
Centre
Definition: mythuianimation.h:12
UIEffects
Definition: mythuianimation.h:10
MythUIAnimation::SetReversible
void SetReversible(bool rev)
Definition: mythuianimation.h:63
MythUIAnimation::AboutToHide
@ AboutToHide
Definition: mythuianimation.h:46
MythUIAnimation::Activate
void Activate(void)
Definition: mythuianimation.cpp:49
UIEffects::m_hzoom
float m_hzoom
Definition: mythuianimation.h:36
MythUIAnimation::Value
QVariant Value() const
Definition: mythuianimation.h:54
MythUIAnimation::SetCentre
void SetCentre(const QString &centre)
Definition: mythuianimation.cpp:181
UIEffects::Right
@ Right
Definition: mythuianimation.h:13
UIEffects::GetCentre
QPointF GetCentre(const QRect &rect, int xoff, int yoff) const
Definition: mythuianimation.h:18