Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add the beginnings of a general purpose video widget.
At the moment it just allows you to pass a MythImage or QPixmap to display for each frame and isn't very efficient but I'm sure it can be improved by someone more familiar with the painters. It's what I've been using to test the MythUI friendly visualisers in MythMusic. Refs ticket 5763.
- Loading branch information
Paul Harrison
committed
Dec 19, 2010
1 parent
66defe9
commit 6fd3876
Showing
4 changed files
with
186 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// C/C++ | ||
#include <cstdlib> | ||
|
||
// QT | ||
#include <QRect> | ||
#include <QDomDocument> | ||
|
||
// 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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef MYTHUI_VIDEO_H_ | ||
#define MYTHUI_VIDEO_H_ | ||
|
||
#include <QString> | ||
#include <QColor> | ||
|
||
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters