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:
16  enum Centre : std::uint8_t
20 
21  UIEffects() = default;
22 
23  QPointF GetCentre(const QRect rect, int xoff, int yoff) const
24  {
25  float x = static_cast<float>(xoff) + static_cast<float>(rect.left());
26  float y = static_cast<float>(yoff) + static_cast<float>(rect.top());
27  if (Middle == m_centre || Top == m_centre || Bottom == m_centre)
28  x += static_cast<float>(rect.width()) / 2.0F;
29  if (Middle == m_centre || Left == m_centre || Right == m_centre)
30  y += static_cast<float>(rect.height()) / 2.0F;
32  x += static_cast<float>(rect.width());
34  y += static_cast<float>(rect.height());
35  return {x, y};
36  }
37 
38  QRect GetExtent(QSize size) const;
39 
40  int m_alpha {255};
41  float m_hzoom {1.0F};
42  float m_vzoom {1.0F};
43  float m_angle {0.0F};
45 };
46 
47 class MythUIAnimation : public QVariantAnimation, XMLParseBase
48 {
49  public:
50  enum Type : std::uint8_t { Alpha, Position, Zoom, HorizontalZoom, VerticalZoom, Angle };
51  enum Trigger : std::uint8_t { AboutToHide, AboutToShow };
52 
53  explicit MythUIAnimation(MythUIType* parent = nullptr,
54  Trigger trigger = AboutToShow, Type type = Alpha)
55  : m_parent(parent), m_type(type), m_trigger(trigger) {}
56  void Activate(void);
57  void CopyFrom(const MythUIAnimation* animation);
58  Trigger GetTrigger(void) const { return m_trigger; }
59  QVariant Value() const { return m_value; }
60  bool IsActive() const { return m_active; }
61 
62  void updateCurrentValue(const QVariant& value) override; // QVariantAnimation
63 
64  void IncrementCurrentTime(void);
65  void SetEasingCurve(const QString &curve);
66  void SetCentre(const QString &centre);
67  void SetLooped(bool looped) { m_looped = looped; }
68  void SetReversible(bool rev) { m_reversible = rev; }
69 
70  static void ParseElement(const QDomElement& element, MythUIType* parent);
71 
72  private:
73  static void ParseSection(const QDomElement &element,
74  MythUIType* parent, Trigger trigger);
75  static void parseAlpha(const QDomElement& element, QVariant& startValue,
76  QVariant& endValue);
77  static void parsePosition(const QDomElement& element, QVariant& startValue,
78  QVariant& endValue, MythUIType *parent);
79  static void parseZoom(const QDomElement& element, QVariant& startValue,
80  QVariant& endValue);
81  static void parseAngle(const QDomElement& element, QVariant& startValue,
82  QVariant& endValue);
83 
84  MythUIType* m_parent {nullptr};
88  QVariant m_value;
89  bool m_active {false};
90  bool m_looped {false};
91  bool m_reversible {false};
93 };
94 
95 #endif // MYTHUIANIMATION_H
MythUIAnimation::m_trigger
Trigger m_trigger
Definition: mythuianimation.h:86
UIEffects::TopLeft
@ TopLeft
Definition: mythuianimation.h:17
UIEffects::m_angle
float m_angle
Definition: mythuianimation.h:43
MythUIAnimation::Angle
@ Angle
Definition: mythuianimation.h:50
MythUIAnimation::m_value
QVariant m_value
Definition: mythuianimation.h:88
XMLParseBase
Definition: xmlparsebase.h:23
UIEffects::BottomRight
@ BottomRight
Definition: mythuianimation.h:19
MythUIAnimation::m_active
bool m_active
Definition: mythuianimation.h:89
MythUIAnimation::ParseElement
static void ParseElement(const QDomElement &element, MythUIType *parent)
Definition: mythuianimation.cpp:195
MythUIAnimation::ParseSection
static void ParseSection(const QDomElement &element, MythUIType *parent, Trigger trigger)
Definition: mythuianimation.cpp:214
MythUIAnimation::parseZoom
static void parseZoom(const QDomElement &element, QVariant &startValue, QVariant &endValue)
Definition: mythuianimation.cpp:324
MythUIAnimation::CopyFrom
void CopyFrom(const MythUIAnimation *animation)
Definition: mythuianimation.cpp:82
MythUIAnimation::m_reversible
bool m_reversible
Definition: mythuianimation.h:91
UIEffects::Middle
@ Middle
Definition: mythuianimation.h:18
MythUIAnimation::MythUIAnimation
MythUIAnimation(MythUIType *parent=nullptr, Trigger trigger=AboutToShow, Type type=Alpha)
Definition: mythuianimation.h:53
MythUIAnimation::Zoom
@ Zoom
Definition: mythuianimation.h:50
UIEffects::Top
@ Top
Definition: mythuianimation.h:17
MythUIAnimation::m_centre
UIEffects::Centre m_centre
Definition: mythuianimation.h:87
UIEffects::Left
@ Left
Definition: mythuianimation.h:18
MythUIAnimation::parsePosition
static void parsePosition(const QDomElement &element, QVariant &startValue, QVariant &endValue, MythUIType *parent)
Definition: mythuianimation.cpp:296
UIEffects::Bottom
@ Bottom
Definition: mythuianimation.h:19
MythUIAnimation::Alpha
@ Alpha
Definition: mythuianimation.h:50
MythUIAnimation::VerticalZoom
@ VerticalZoom
Definition: mythuianimation.h:50
mythdate.h
UIEffects::UIEffects
UIEffects()=default
MythUIAnimation::IsActive
bool IsActive() const
Definition: mythuianimation.h:60
MythUIAnimation::GetTrigger
Trigger GetTrigger(void) const
Definition: mythuianimation.h:58
UIEffects::BottomLeft
@ BottomLeft
Definition: mythuianimation.h:19
UIEffects::Centre
Centre
Definition: mythuianimation.h:16
MythUIAnimation::m_looped
bool m_looped
Definition: mythuianimation.h:90
MythUIAnimation::parseAngle
static void parseAngle(const QDomElement &element, QVariant &startValue, QVariant &endValue)
Definition: mythuianimation.cpp:331
UIEffects::GetCentre
QPointF GetCentre(const QRect rect, int xoff, int yoff) const
Definition: mythuianimation.h:23
MythUIAnimation::SetLooped
void SetLooped(bool looped)
Definition: mythuianimation.h:67
MythUIAnimation::updateCurrentValue
void updateCurrentValue(const QVariant &value) override
Definition: mythuianimation.cpp:57
xmlparsebase.h
MythUIAnimation::SetEasingCurve
void SetEasingCurve(const QString &curve)
Definition: mythuianimation.cpp:133
UIEffects::TopRight
@ TopRight
Definition: mythuianimation.h:17
UIEffects::m_centre
Centre m_centre
Definition: mythuianimation.h:44
UIEffects::m_alpha
int m_alpha
Definition: mythuianimation.h:40
MythUIAnimation::AboutToShow
@ AboutToShow
Definition: mythuianimation.h:51
MythUIAnimation::m_type
Type m_type
Definition: mythuianimation.h:85
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:289
MythDate::currentMSecsSinceEpochAsDuration
std::chrono::milliseconds currentMSecsSinceEpochAsDuration(void)
Definition: mythdate.cpp:198
MythUIAnimation::m_parent
MythUIType * m_parent
Definition: mythuianimation.h:84
UIEffects::m_vzoom
float m_vzoom
Definition: mythuianimation.h:42
MythUIAnimation::Trigger
Trigger
Definition: mythuianimation.h:51
MythUIAnimation::IncrementCurrentTime
void IncrementCurrentTime(void)
Definition: mythuianimation.cpp:99
MythUIAnimation
Definition: mythuianimation.h:47
MythUIAnimation::Position
@ Position
Definition: mythuianimation.h:50
MythUIAnimation::Type
Type
Definition: mythuianimation.h:50
mythchrono.h
UIEffects
Definition: mythuianimation.h:13
MythUIAnimation::SetReversible
void SetReversible(bool rev)
Definition: mythuianimation.h:68
MythUIAnimation::AboutToHide
@ AboutToHide
Definition: mythuianimation.h:51
UIEffects::Right
@ Right
Definition: mythuianimation.h:18
MythUIAnimation::Activate
void Activate(void)
Definition: mythuianimation.cpp:50
UIEffects::m_hzoom
float m_hzoom
Definition: mythuianimation.h:41
MythUIAnimation::HorizontalZoom
@ HorizontalZoom
Definition: mythuianimation.h:50
MythUIAnimation::Value
QVariant Value() const
Definition: mythuianimation.h:59
MythUIAnimation::SetCentre
void SetCentre(const QString &centre)
Definition: mythuianimation.cpp:182
UIEffects::GetExtent
QRect GetExtent(QSize size) const
Definition: mythuianimation.cpp:8
MythUIAnimation::m_lastUpdate
std::chrono::milliseconds m_lastUpdate
Definition: mythuianimation.h:92