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 
18 MythUIVideo::MythUIVideo(MythUIType *parent, const QString &name)
19  : MythUIType(parent, name),
20  m_image(GetMythPainter()->GetFormatImage())
21 {
22 }
23 
25 {
26  if (m_image)
27  {
28  m_image->DecrRef();
29  m_image = nullptr;
30  }
31 }
32 
37 {
38  if (m_image)
39  {
40  m_image->DecrRef();
41  m_image = nullptr;
42  }
43 
45 
47 }
48 
50 {
51  m_image->Assign(*image);
52 
53  SetRedraw();
54 }
55 
56 void MythUIVideo::UpdateFrame(QPixmap *pixmap)
57 {
58  m_image->Assign(*pixmap);
59 
60  SetRedraw();
61 }
62 
67 {
68 
70 }
71 
75 void 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 {
113  MythUIType::CopyFrom(base);
114 }
115 
120 {
121  auto *im = new MythUIVideo(parent, objectName());
122  im->CopyFrom(this);
123 }
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:524
MythUIVideo::CopyFrom
void CopyFrom(MythUIType *base) override
Copy this widgets state from another.
Definition: mythuivideo.cpp:111
MythUIVideo::~MythUIVideo
~MythUIVideo() override
Definition: mythuivideo.cpp:24
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:456
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:885
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:119
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:1171
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:66
MythUIVideo::UpdateFrame
void UpdateFrame(MythImage *image)
Definition: mythuivideo.cpp:49
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:73
MythUIVideo::Reset
void Reset(void) override
Reset the video back to the default defined in the theme.
Definition: mythuivideo.cpp:36
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:75
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:1237
build_compdb.filename
filename
Definition: build_compdb.py:21
mythmainwindow.h
MythUIType::SetRedraw
void SetRedraw(void)
Definition: mythuitype.cpp:313
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:93
mythscreentype.h
MythUIVideo::MythUIVideo
MythUIVideo(MythUIType *parent, const QString &name)
Definition: mythuivideo.cpp:18