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
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  auto *im = new MythUIVideo(parent, objectName());
123  im->CopyFrom(this);
124 }
mythuivideo.h
MythPainter::GetFormatImage
MythImage * GetFormatImage()
Returns a blank reference counted image in the format required for the Draw functions for this painte...
Definition: mythpainter.cpp:528
MythUIVideo::CopyFrom
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
Definition: mythuivideo.cpp:112
MythUIVideo::~MythUIVideo
~MythUIVideo() override
Definition: mythuivideo.cpp:27
MythUIVideo::m_backgroundColor
QColor m_backgroundColor
Definition: mythuivideo.h:38
MythUIType::Pulse
virtual void Pulse(void)
Pulse is called 70 times a second to trigger a single frame of an animation.
Definition: mythuitype.cpp:457
MythUIType::GetArea
virtual MythRect GetArea(void) const
If the object has a minimum area defined, return it, other wise return the default area.
Definition: mythuitype.cpp:886
mythlogging.h
hardwareprofile.config.p
p
Definition: config.py:33
XMLParseBase::getFirstText
static QString getFirstText(QDomElement &element)
Definition: xmlparsebase.cpp:52
MythUIVideo::CreateCopy
void CreateCopy(MythUIType *parent) override
Copy the state of this widget to the one given, it must be of the same type.
Definition: mythuivideo.cpp:120
MythImage::DecrRef
int DecrRef(void) override
Decrements reference count and deletes on 0.
Definition: mythimage.cpp:52
MythUIType::CopyFrom
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
Definition: mythuitype.cpp:1176
mythpainter.h
MythUIVideo::Pulse
void Pulse(void) override
Pulse is called 70 times a second to trigger a single frame of an animation.
Definition: mythuivideo.cpp:69
MythUIVideo::UpdateFrame
void UpdateFrame(MythImage *image)
Definition: mythuivideo.cpp:52
MythUIVideo::m_image
MythImage * m_image
Definition: mythuivideo.h:37
MythUIType::Reset
virtual void Reset(void)
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuitype.cpp:72
MythUIVideo::Reset
void Reset(void) override
Reset the video back to the default defined in the theme.
Definition: mythuivideo.cpp:39
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:85
mythuihelper.h
mythimage.h
MythPainter
Definition: mythpainter.h:34
MythImage
Definition: mythimage.h:36
MythUIVideo::DrawSelf
void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect) override
Definition: mythuivideo.cpp:78
MythImage::Assign
void Assign(const QImage &img)
Definition: mythimage.cpp:77
GetMythPainter
MythPainter * GetMythPainter(void)
Definition: mythmainwindow.cpp:119
MythUIType::ParseElement
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
Definition: mythuitype.cpp:1242
build_compdb.filename
filename
Definition: build_compdb.py:21
mythmainwindow.h
MythUIType::SetRedraw
void SetRedraw(void)
Definition: mythuitype.cpp:310
MythUIVideo::ParseElement
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
mythscreentype.h
MythUIVideo::MythUIVideo
MythUIVideo(MythUIType *parent, const QString &name)
Definition: mythuivideo.cpp:21