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 // libmythbase
9 #include "mythlogging.h"
10 
11 // Mythui
12 #include "mythpainter.h"
13 #include "mythmainwindow.h"
14 #include "mythuihelper.h"
15 #include "mythscreentype.h"
16 #include "mythuivideo.h"
17 #include "mythimage.h"
18 
19 #define LOC QString("MythUIVideo(0x%1): ").arg((uint64_t)this, 0, 16)
20 
21 MythUIVideo::MythUIVideo(MythUIType *parent, const QString &name)
22  : MythUIType(parent, name)
23 {
25 }
26 
28 {
29  if (m_image)
30  {
31  m_image->DecrRef();
32  m_image = nullptr;
33  }
34 }
35 
40 {
41  if (m_image)
42  {
43  m_image->DecrRef();
44  m_image = nullptr;
45  }
46 
48 
50 }
51 
53 {
54  m_image->Assign(*image);
55 
56  SetRedraw();
57 }
58 
59 void MythUIVideo::UpdateFrame(QPixmap *pixmap)
60 {
61  m_image->Assign(*pixmap);
62 
63  SetRedraw();
64 }
65 
70 {
71 
73 }
74 
78 void MythUIVideo::DrawSelf(MythPainter *p, int xoffset, int yoffset,
79  int alphaMod, QRect clipRect)
80 {
81  QRect area = GetArea();
82  area.translate(xoffset, yoffset);
83 
84  if (!m_image || m_image->isNull())
85  return;
86 
87  if (m_image) {
88  p->SetClipRect(clipRect);
89  p->DrawImage(area.x(), area.y(), m_image, alphaMod);
90  }
91 }
92 
97  const QString &filename, QDomElement &element, bool showWarnings)
98 {
99  if (element.tagName() == "backgroundcolor")
100  {
101  m_backgroundColor = QColor(getFirstText(element));
102  }
103  else
104  return MythUIType::ParseElement(filename, element, showWarnings);
105 
106  return true;
107 }
108 
113 {
114  MythUIType::CopyFrom(base);
115 }
116 
121 {
122  MythUIVideo *im = new MythUIVideo(parent, objectName());
123  im->CopyFrom(this);
124 }
void SetRedraw(void)
Definition: mythuitype.cpp:295
int DecrRef(void) override
Decrements reference count and deletes on 0.
Definition: mythimage.cpp:55
MythPainter * GetMythPainter(void)
The base class on which all widgets and screens are based.
Definition: mythuitype.h:63
MythImage * m_image
Definition: mythuivideo.h:37
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
Definition: mythuitype.cpp:863
static QString getFirstText(QDomElement &element)
QColor m_backgroundColor
Definition: mythuivideo.h:38
virtual void Pulse(void)
Pulse is called 70 times a second to trigger a single frame of an animation.
Definition: mythuitype.cpp:442
Video widget, displays raw image data.
Definition: mythuivideo.h:14
const char * name
Definition: ParseText.cpp:328
virtual void DrawImage(const QRect &dest, MythImage *im, const QRect &src, int alpha)=0
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:96
virtual void Reset(void)
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuitype.cpp:69
void UpdateFrame(MythImage *image)
Definition: mythuivideo.cpp:52
void Pulse(void) override
Pulse is called 70 times a second to trigger a single frame of an animation.
Definition: mythuivideo.cpp:69
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
MythUIVideo(MythUIType *parent, const QString &name)
Definition: mythuivideo.cpp:21
void Reset(void) override
Reset the video back to the default defined in the theme.
Definition: mythuivideo.cpp:39
void Assign(const QImage &img)
Definition: mythimage.cpp:80
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
Definition: mythuivideo.cpp:78
MythImage * GetFormatImage()
Returns a blank reference counted image in the format required for the Draw functions for this painte...
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
virtual void SetClipRect(const QRect &clipRect)
Definition: mythpainter.cpp:48
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.