diff --git a/mythtv/libs/libmythui/libmythui.pro b/mythtv/libs/libmythui/libmythui.pro index a6153e6c6d3..75b9a161447 100644 --- a/mythtv/libs/libmythui/libmythui.pro +++ b/mythtv/libs/libmythui/libmythui.pro @@ -29,7 +29,7 @@ HEADERS += themeinfo.h mythxdisplay.h DisplayRes.h DisplayResScreen.h HEADERS += mythgenerictree.h mythuibuttontree.h mythuiutils.h HEADERS += mythvirtualkeyboard.h mythuishape.h mythuiguidegrid.h HEADERS += mythrender_base.h mythfontmanager.h mythuieditbar.h -HEADERS += mythdisplay.h +HEADERS += mythdisplay.h mythuivideo.h SOURCES = mythmainwindow.cpp mythpainter.cpp mythimage.cpp mythrect.cpp SOURCES += myththemebase.cpp mythpainter_qimage.cpp mythpainter_yuva.cpp @@ -46,7 +46,8 @@ SOURCES += themeinfo.cpp mythxdisplay.cpp DisplayRes.cpp DisplayResScreen.cpp SOURCES += mythgenerictree.cpp mythuibuttontree.cpp mythuiutils.cpp SOURCES += mythvirtualkeyboard.cpp mythuishape.cpp mythuiguidegrid.cpp SOURCES += mythfontmanager.cpp mythuieditbar.cpp -SOURCES += mythdisplay.cpp +SOURCES += mythdisplay.cpp mythuivideo.cpp + inc.path = $${PREFIX}/include/mythtv/libmythui/ @@ -60,8 +61,9 @@ inc.files += mythuiclock.h mythgesture.h mythuitextedit.h mythprogressdialog.h inc.files += mythuispinbox.h mythuicheckbox.h mythuibuttonlist.h mythuigroup.h inc.files += mythuiprogressbar.h mythuiwebbrowser.h mythuiutils.h inc.files += x11colors.h mythgenerictree.h mythuibuttontree.h -inc.files += mythvirtualkeyboard.h mythuishape.h mythuiguidegrid.h +inc.files += mythvirtualkeyboard.h mythuishape.h mythuiguidegrid.h inc.files += mythuieditbar.h +inc.files += mythuivideo.h INSTALLS += inc diff --git a/mythtv/libs/libmythui/mythuivideo.cpp b/mythtv/libs/libmythui/mythuivideo.cpp new file mode 100644 index 00000000000..bc5c18a7d3e --- /dev/null +++ b/mythtv/libs/libmythui/mythuivideo.cpp @@ -0,0 +1,131 @@ +// C/C++ +#include + +// QT +#include +#include + +// Libmythdb +#include "mythverbose.h" + +// Mythui +#include "mythpainter.h" +#include "mythmainwindow.h" +#include "mythuihelper.h" +#include "mythscreentype.h" +#include "mythuivideo.h" +#include "mythimage.h" + +#define LOC QString("MythUIVideo(%1): ").arg((long long)this) +#define LOC_ERR QString("MythUIVideo(%1) ERROR: ").arg((long long)this) +#define LOC_WARN QString("MythUIVideo(%1) WARNING: ").arg((long long)this) + +MythUIVideo::MythUIVideo(MythUIType *parent, const QString &name) + : MythUIType(parent, name) +{ + m_image = NULL; + m_backgroundColor = QColor(Qt::black); +} + +MythUIVideo::~MythUIVideo() +{ + if (m_image) + { + m_image->DownRef(); + m_image = NULL; + } +} + +/** + * \brief Reset the video back to the default defined in the theme + */ +void MythUIVideo::Reset(void) +{ + if (m_image) + { + m_image->DownRef(); + m_image = NULL; + } + MythUIType::Reset(); +} + +void MythUIVideo::UpdateFrame(MythImage *image) +{ + if (m_image) + m_image->DownRef(); + + m_image = image; + m_image->UpRef(); + + SetRedraw(); +} + +void MythUIVideo::UpdateFrame(QPixmap *pixmap) +{ + if (m_image) + m_image->DownRef(); + + m_image = GetMythPainter()->GetFormatImage(); + m_image->Assign(*pixmap); + m_image->UpRef(); + + SetRedraw(); +} + +/** + * \copydoc MythUIType::Pulse() + */ +void MythUIVideo::Pulse(void) +{ + + MythUIType::Pulse(); +} + +/** + * \copydoc MythUIType::DrawSelf() + */ +void MythUIVideo::DrawSelf(MythPainter *p, int xoffset, int yoffset, + int alphaMod, QRect clipRect) +{ + QRect area = GetArea(); + area.translate(xoffset, yoffset); + + if (!m_image || m_image->isNull()) + return; + + if (m_image) + p->DrawImage(area.x(), area.y(), m_image, alphaMod); +} + +/** + * \copydoc MythUIType::ParseElement() + */ +bool MythUIVideo::ParseElement( + const QString &filename, QDomElement &element, bool showWarnings) +{ + if (element.tagName() == "backgroundcolor") + { + m_backgroundColor = QColor(getFirstText(element)); + } + else + return MythUIType::ParseElement(filename, element, showWarnings); + + return true; +} + +/** + * \copydoc MythUIType::CopyFrom() + */ +void MythUIVideo::CopyFrom(MythUIType *base) +{ + MythUIType::CopyFrom(base); +} + +/** + * \copydoc MythUIType::CreateCopy() + */ +void MythUIVideo::CreateCopy(MythUIType *parent) +{ + MythUIVideo *im = new MythUIVideo(parent, objectName()); + im->CopyFrom(this); +} diff --git a/mythtv/libs/libmythui/mythuivideo.h b/mythtv/libs/libmythui/mythuivideo.h new file mode 100644 index 00000000000..c5d2f38d7ce --- /dev/null +++ b/mythtv/libs/libmythui/mythuivideo.h @@ -0,0 +1,41 @@ +#ifndef MYTHUI_VIDEO_H_ +#define MYTHUI_VIDEO_H_ + +#include +#include + +#include "mythuitype.h" + +/** + * \class MythUIVideo + * + * \brief Video widget, displays raw image data + */ +class MPUBLIC MythUIVideo : public MythUIType +{ + public: + MythUIVideo(MythUIType *parent, const QString &name); + ~MythUIVideo(); + + void UpdateFrame(MythImage *image); + void UpdateFrame(QPixmap *pixmap); + + QColor GetBackgroundColor(void) { return m_backgroundColor; } + + void Reset(void); + virtual void Pulse(void); + + protected: + virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, + int alphaMod, QRect clipRect); + + virtual bool ParseElement( + const QString &filename, QDomElement &element, bool showWarnings); + virtual void CopyFrom(MythUIType *base); + virtual void CreateCopy(MythUIType *parent); + + MythImage *m_image; + QColor m_backgroundColor; +}; + +#endif diff --git a/mythtv/libs/libmythui/xmlparsebase.cpp b/mythtv/libs/libmythui/xmlparsebase.cpp index e6b074afd89..99e3958bb67 100644 --- a/mythtv/libs/libmythui/xmlparsebase.cpp +++ b/mythtv/libs/libmythui/xmlparsebase.cpp @@ -35,6 +35,7 @@ #include "mythuiguidegrid.h" #include "mythuishape.h" #include "mythuibuttontree.h" +#include "mythuivideo.h" #include "mythuieditbar.h" #include "mythfontproperties.h" @@ -352,7 +353,8 @@ void XMLParseBase::ParseChildren(const QString &filename, type == "webbrowser" || type == "guidegrid" || type == "shape" || - type == "editbar") + type == "editbar" || + type == "video") { ParseUIType(filename, info, type, parent, NULL, showWarnings); } @@ -452,6 +454,8 @@ MythUIType *XMLParseBase::ParseUIType( uitype = new MythUIShape(parent, name); else if (type == "editbar") uitype = new MythUIEditBar(parent, name); + else if (type == "video") + uitype = new MythUIVideo(parent, name); else if (type == "window" && parent == GetGlobalObjectStore()) uitype = new MythScreenType(parent, name); else @@ -538,7 +542,8 @@ MythUIType *XMLParseBase::ParseUIType( info.tagName() == "webbrowser" || info.tagName() == "guidegrid" || info.tagName() == "shape" || - info.tagName() == "editbar") + info.tagName() == "editbar" || + info.tagName() == "video") { ParseUIType(filename, info, info.tagName(), uitype, screen, showWarnings); @@ -724,7 +729,8 @@ bool XMLParseBase::doLoad(const QString &windowname, type == "webbrowser" || type == "guidegrid" || type == "shape" || - type == "editbar") + type == "editbar" || + type == "video") { ParseUIType(filename, e, type, parent, NULL, showWarnings); }