MythTV master
mythuivideo.cpp
Go to the documentation of this file.
1// C/C++
2#include <cstdlib>
3
4// QT
5#include <QRect>
6#include <QDomDocument>
7
8// Mythui
9#include "mythpainter.h"
10#include "mythmainwindow.h"
11#include "mythuihelper.h"
12#include "mythscreentype.h"
13#include "mythuivideo.h"
14#include "mythimage.h"
15
16#define LOC QString("MythUIVideo(0x%1): ").arg((uint64_t)this, 0, 16)
17
18MythUIVideo::MythUIVideo(MythUIType *parent, const QString &name)
19 : MythUIType(parent, name),
20 m_image(GetMythPainter()->GetFormatImage())
21{
22}
23
25{
26 if (m_image)
27 {
29 m_image = nullptr;
30 }
31}
32
37{
38 if (m_image)
39 {
41 m_image = nullptr;
42 }
43
45
47}
48
50{
51 m_image->Assign(*image);
52
53 SetRedraw();
54}
55
56void MythUIVideo::UpdateFrame(QPixmap *pixmap)
57{
58 m_image->Assign(*pixmap);
59
60 SetRedraw();
61}
62
67{
68
70}
71
75void MythUIVideo::DrawSelf(MythPainter *p, int xoffset, int yoffset,
76 int alphaMod, QRect clipRect)
77{
78 QRect area = GetArea();
79 area.translate(xoffset, yoffset);
80
81 if (!m_image || m_image->isNull())
82 return;
83
84 if (m_image) {
85 p->SetClipRect(clipRect);
86 p->DrawImage(area.x(), area.y(), m_image, alphaMod);
87 }
88}
89
94 const QString &filename, QDomElement &element, bool showWarnings)
95{
96 if (element.tagName() == "backgroundcolor")
97 {
98 m_backgroundColor = QColor(getFirstText(element));
99 }
100 else
101 {
102 return MythUIType::ParseElement(filename, element, showWarnings);
103 }
104
105 return true;
106}
107
112{
114}
115
120{
121 auto *im = new MythUIVideo(parent, objectName());
122 im->CopyFrom(this);
123}
void Assign(const QImage &img)
Definition: mythimage.cpp:77
int DecrRef(void) override
Decrements reference count and deletes on 0.
Definition: mythimage.cpp:52
MythImage * GetFormatImage()
Returns a blank reference counted image in the format required for the Draw functions for this painte...
The base class on which all widgets and screens are based.
Definition: mythuitype.h:86
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
void SetRedraw(void)
Definition: mythuitype.cpp:313
virtual void Pulse(void)
Pulse is called 70 times a second to trigger a single frame of an animation.
Definition: mythuitype.cpp:456
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
Definition: mythuitype.cpp:885
virtual void Reset(void)
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuitype.cpp:73
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
Definition: mythuivideo.cpp:75
MythUIVideo(MythUIType *parent, const QString &name)
Definition: mythuivideo.cpp:18
void UpdateFrame(MythImage *image)
Definition: mythuivideo.cpp:49
QColor m_backgroundColor
Definition: mythuivideo.h:38
bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings) override
Parse the xml definition of this widget setting the state of the object accordingly.
Definition: mythuivideo.cpp:93
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
void Pulse(void) override
Pulse is called 70 times a second to trigger a single frame of an animation.
Definition: mythuivideo.cpp:66
void Reset(void) override
Reset the video back to the default defined in the theme.
Definition: mythuivideo.cpp:36
~MythUIVideo() override
Definition: mythuivideo.cpp:24
MythImage * m_image
Definition: mythuivideo.h:37
static QString getFirstText(QDomElement &element)
MythPainter * GetMythPainter(void)