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 
8 #include "libmythbase/mythdate.h"
10 
11 class MythUIType;
12 
13 class UIEffects
14 {
15  public:
19 
20  UIEffects() = default;
21 
22  QPointF GetCentre(const QRect rect, int xoff, int yoff) const
23  {
24  float x = static_cast<float>(xoff) + static_cast<float>(rect.left());
25  float y = static_cast<float>(yoff) + static_cast<float>(rect.top());
26  if (Middle == m_centre || Top == m_centre || Bottom == m_centre)
27  x += static_cast<float>(rect.width()) / 2.0F;
28  if (Middle == m_centre || Left == m_centre || Right == m_centre)
29  y += static_cast<float>(rect.height()) / 2.0F;
31  x += static_cast<float>(rect.width());
33  y += static_cast<float>(rect.height());
34  return {x, y};
35  }
36 
37  QRect GetExtent(QSize size) const;
38 
39  int m_alpha {255};
40  float m_hzoom {1.0F};
41  float m_vzoom {1.0F};
42  float m_angle {0.0F};
44 };
45 
46 class MythUIAnimation : public QVariantAnimation, XMLParseBase
47 {
48  public:
51 
52  explicit MythUIAnimation(MythUIType* parent = nullptr,
53  Trigger trigger = AboutToShow, Type type = Alpha)
54  : m_parent(parent), m_type(type), m_trigger(trigger) {}
55  void Activate(void);
56  void CopyFrom(const MythUIAnimation* animation);
57  Trigger GetTrigger(void) const { return m_trigger; }
58  QVariant Value() const { return m_value; }
59  bool IsActive() const { return m_active; }
60 
61  void updateCurrentValue(const QVariant& value) override; // QVariantAnimation
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  private:
72  static void ParseSection(const QDomElement &element,
73  MythUIType* parent, Trigger trigger);
74  static void parseAlpha(const QDomElement& element, QVariant& startValue,
75  QVariant& endValue);
76  static void parsePosition(const QDomElement& element, QVariant& startValue,
77  QVariant& endValue, MythUIType *parent);
78  static void parseZoom(const QDomElement& element, QVariant& startValue,
79  QVariant& endValue);
80  static void parseAngle(const QDomElement& element, QVariant& startValue,
81  QVariant& endValue);
82 
83  MythUIType* m_parent {nullptr};
87  QVariant m_value;
88  bool m_active {false};
89  bool m_looped {false};
90  bool m_reversible {false};
92 };
93 
94 #endif // MYTHUIANIMATION_H
MythUIAnimation::m_trigger
Trigger m_trigger
Definition: mythuianimation.h:85
UIEffects::TopLeft
@ TopLeft
Definition: mythuianimation.h:16
UIEffects::m_angle
float m_angle
Definition: mythuianimation.h:42
MythUIAnimation::HorizontalZoom
@ HorizontalZoom
Definition: mythuianimation.h:49
MythUIAnimation::m_value
QVariant m_value
Definition: mythuianimation.h:87
XMLParseBase
Definition: xmlparsebase.h:22
MythUIAnimation::Type
Type
Definition: mythuianimation.h:49
MythUIAnimation::m_active
bool m_active
Definition: mythuianimation.h:88
MythUIAnimation::ParseElement
static void ParseElement(const QDomElement &element, MythUIType *parent)
Definition: mythuianimation.cpp:193
MythUIAnimation::ParseSection
static void ParseSection(const QDomElement &element, MythUIType *parent, Trigger trigger)
Definition: mythuianimation.cpp:212
MythUIAnimation::parseZoom
static void parseZoom(const QDomElement &element, QVariant &startValue, QVariant &endValue)
Definition: mythuianimation.cpp:320
MythUIAnimation::CopyFrom
void CopyFrom(const MythUIAnimation *animation)
Definition: mythuianimation.cpp:80
MythUIAnimation::m_reversible
bool m_reversible
Definition: mythuianimation.h:90
MythUIAnimation::Trigger
Trigger
Definition: mythuianimation.h:50
UIEffects::BottomLeft
@ BottomLeft
Definition: mythuianimation.h:18
MythUIAnimation::MythUIAnimation
MythUIAnimation(MythUIType *parent=nullptr, Trigger trigger=AboutToShow, Type type=Alpha)
Definition: mythuianimation.h:52
MythUIAnimation::Alpha
@ Alpha
Definition: mythuianimation.h:49
MythUIAnimation::m_centre
UIEffects::Centre m_centre
Definition: mythuianimation.h:86
MythUIAnimation::VerticalZoom
@ VerticalZoom
Definition: mythuianimation.h:49
MythUIAnimation::parsePosition
static void parsePosition(const QDomElement &element, QVariant &startValue, QVariant &endValue, MythUIType *parent)
Definition: mythuianimation.cpp:292
mythdate.h
UIEffects::Bottom
@ Bottom
Definition: mythuianimation.h:18
UIEffects::UIEffects
UIEffects()=default
MythUIAnimation::IsActive
bool IsActive() const
Definition: mythuianimation.h:59
MythUIAnimation::AboutToShow
@ AboutToShow
Definition: mythuianimation.h:50
MythUIAnimation::GetTrigger
Trigger GetTrigger(void) const
Definition: mythuianimation.h:57
UIEffects::TopRight
@ TopRight
Definition: mythuianimation.h:16
UIEffects::Middle
@ Middle
Definition: mythuianimation.h:17
MythUIAnimation::m_looped
bool m_looped
Definition: mythuianimation.h:89
UIEffects::BottomRight
@ BottomRight
Definition: mythuianimation.h:18
MythUIAnimation::parseAngle
static void parseAngle(const QDomElement &element, QVariant &startValue, QVariant &endValue)
Definition: mythuianimation.cpp:327
UIEffects::GetCentre
QPointF GetCentre(const QRect rect, int xoff, int yoff) const
Definition: mythuianimation.h:22
MythUIAnimation::SetLooped
void SetLooped(bool looped)
Definition: mythuianimation.h:66
MythUIAnimation::updateCurrentValue
void updateCurrentValue(const QVariant &value) override
Definition: mythuianimation.cpp:55
xmlparsebase.h
UIEffects::Top
@ Top
Definition: mythuianimation.h:16
MythUIAnimation::SetEasingCurve
void SetEasingCurve(const QString &curve)
Definition: mythuianimation.cpp:131
MythUIAnimation::Angle
@ Angle
Definition: mythuianimation.h:49
UIEffects::m_centre
Centre m_centre
Definition: mythuianimation.h:43
UIEffects::m_alpha
int m_alpha
Definition: mythuianimation.h:39
MythUIAnimation::m_type
Type m_type
Definition: mythuianimation.h:84
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:85
MythUIAnimation::parseAlpha
static void parseAlpha(const QDomElement &element, QVariant &startValue, QVariant &endValue)
Definition: mythuianimation.cpp:285
MythDate::currentMSecsSinceEpochAsDuration
std::chrono::milliseconds currentMSecsSinceEpochAsDuration(void)
Definition: mythdate.cpp:199
MythUIAnimation::Position
@ Position
Definition: mythuianimation.h:49
MythUIAnimation::m_parent
MythUIType * m_parent
Definition: mythuianimation.h:83
UIEffects::m_vzoom
float m_vzoom
Definition: mythuianimation.h:41
MythUIAnimation::Zoom
@ Zoom
Definition: mythuianimation.h:49
MythUIAnimation::IncrementCurrentTime
void IncrementCurrentTime(void)
Definition: mythuianimation.cpp:97
MythUIAnimation
Definition: mythuianimation.h:46
UIEffects::Left
@ Left
Definition: mythuianimation.h:17
mythchrono.h
UIEffects::Centre
Centre
Definition: mythuianimation.h:16
UIEffects
Definition: mythuianimation.h:13
MythUIAnimation::SetReversible
void SetReversible(bool rev)
Definition: mythuianimation.h:67
MythUIAnimation::AboutToHide
@ AboutToHide
Definition: mythuianimation.h:50
MythUIAnimation::Activate
void Activate(void)
Definition: mythuianimation.cpp:49
UIEffects::m_hzoom
float m_hzoom
Definition: mythuianimation.h:40
MythUIAnimation::Value
QVariant Value() const
Definition: mythuianimation.h:58
MythUIAnimation::SetCentre
void SetCentre(const QString &centre)
Definition: mythuianimation.cpp:180
UIEffects::Right
@ Right
Definition: mythuianimation.h:17
UIEffects::GetExtent
QRect GetExtent(QSize size) const
Definition: mythuianimation.cpp:7
MythUIAnimation::m_lastUpdate
std::chrono::milliseconds m_lastUpdate
Definition: mythuianimation.h:91