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