MythTV master
mythuiimage.h
Go to the documentation of this file.
1#ifndef MYTHUI_IMAGE_H_
2#define MYTHUI_IMAGE_H_
3
4#include <QDateTime>
5#include <QHash>
6#include <QMutex>
7#include <QWaitCondition>
8#include <QVector>
9#include <QPair>
10
11#include "mythuitype.h"
12#include "mythuihelper.h"
13#include "mythimage.h"
14
16class MythScreenType;
17class ImageLoadThread;
18
24{
25 public:
26 ImageProperties() = default;
27 ImageProperties(const ImageProperties& other);
29
31
32 void SetMaskImage(MythImage *image);
33 void SetMaskImageFilename(const QString &filename)
34 {
36 }
38 {
40 }
41 QRect GetMaskImageRect(void)
42 {
43 QRect rect;
44 if (m_maskImage)
45 rect = m_maskImage->rect();
46 return rect;
47 }
48 QImage GetMaskImageSubset(QRect imageArea)
49 {
50 if (m_maskImage)
51 return m_maskImage->copy(imageArea);
52
53 QImage img(imageArea.size(), QImage::Format_ARGB32);
54 img.fill(0xFFFFFFFF);
55 return img;
56 }
57
58 QString m_filename;
59
61 QSize m_forceSize {0,0};
62
63 bool m_preserveAspect {false};
64 bool m_isGreyscale {false};
65 bool m_isReflected {false};
66 bool m_isMasked {false};
67 bool m_isOriented {false};
68
70 int m_reflectScale {100};
71 int m_reflectLength {100};
74
76
77 bool m_isThemeImage {false};
78
79 private:
80 void Init(void);
81 void Copy(const ImageProperties &other);
82
85};
86
87using AnimationFrame = QPair<MythImage *, std::chrono::milliseconds>;
88using AnimationFrames = QVector<AnimationFrame>;
89
98{
99 Q_OBJECT
100
101 public:
102 MythUIImage(const QString &filepattern, int low, int high, std::chrono::milliseconds delay,
103 MythUIType *parent, const QString &name);
104 MythUIImage(const QString &filename, MythUIType *parent, const QString &name);
105 MythUIImage(MythUIType *parent, const QString &name);
106 ~MythUIImage() override;
107
108 QString GetFilename(void) { return m_filename; }
109
111 void SetFilename(const QString &filename);
112
114 void SetFilepattern(const QString &filepattern, int low, int high);
115
116 void SetImageCount(int low, int high);
117
121 void SetImage(MythImage *img);
122
126 void SetImages(QVector<MythImage *> *images);
127
128 void SetDelay(std::chrono::milliseconds delayms);
129 void SetDelays(const QVector<std::chrono::milliseconds>& delays);
130
131 void Reset(void) override; // MythUIType
132 bool Load(bool allowLoadInBackground = true, bool forceStat = false);
133
134 void Pulse(void) override; // MythUIType
135
136 void LoadNow(void) override; // MythUIType
137
138 void SetOrientation(int orientation);
139
140 signals:
142
143 protected:
144 void DrawSelf(MythPainter *p, int xoffset, int yoffset,
145 int alphaMod, QRect clipRect) override; // MythUIType
146
147 void Clear(void);
148
149 void SetAnimationFrames(const AnimationFrames& frames);
150 void customEvent(QEvent *event) override; // MythUIType
151
152 bool ParseElement(const QString &filename, QDomElement &element,
153 bool showWarnings) override; // MythUIType
154 void CopyFrom(MythUIType *base) override; // MythUIType
155 void CreateCopy(MythUIType *parent) override; // MythUIType
156 void Finalize(void) override; // MythUIType
157
158 void SetSize(int width, int height);
159 void SetSize(QSize size) override; // MythUIType
160 void ForceSize(QSize size);
161
162 void SetCropRect(int x, int y, int width, int height);
163 void SetCropRect(const MythRect &rect);
164
165 void FindRandomImage(void);
166
167 QString m_filename;
169
170 QHash<int, MythImage *> m_images;
171 QHash<int, std::chrono::milliseconds> m_delays;
173
174 std::chrono::milliseconds m_delay { -1ms };
175 int m_lowNum {0};
176 int m_highNum {0};
177
178 unsigned int m_curPos {0};
179 QTime m_lastDisplay {QTime::currentTime()};
180
181 bool m_needLoad {false};
182
184
185 int m_runningThreads {0};
186
187 bool m_showingRandomImage {false};
189 QStringList m_imageList;
190 int m_imageListIndex {0};
191
192 MythUIImagePrivate *d {nullptr}; // NOLINT(readability-identifier-naming)
193
194 enum AnimationCycle : std::uint8_t {kCycleStart, kCycleReverse};
195 AnimationCycle m_animationCycle {kCycleStart};
196 bool m_animationReverse {false};
197 bool m_animatedImage {false};
198
199 friend class MythUIImagePrivate;
200 friend class MythThemeBase;
202 friend class MythUIProgressBar;
203 friend class MythUIEditBar;
204 friend class MythUITextEdit;
205 friend class ImageLoadThread;
206 friend class MythUIGuideGrid;
207
208 private:
209 Q_DISABLE_COPY(MythUIImage)
210};
211
212#endif
#define Clear(a)
void Init(void)
QRect GetMaskImageRect(void)
Definition: mythuiimage.h:41
ImageProperties()=default
void SetMaskImageFilename(const QString &filename)
Definition: mythuiimage.h:33
MythRect m_cropRect
Definition: mythuiimage.h:60
ReflectAxis m_reflectAxis
Definition: mythuiimage.h:69
MythImage * m_maskImage
Definition: mythuiimage.h:83
void SetMaskImage(MythImage *image)
Definition: mythuiimage.cpp:91
void Copy(const ImageProperties &other)
Definition: mythuiimage.cpp:65
ImageProperties & operator=(const ImageProperties &other)
Definition: mythuiimage.cpp:46
QString GetMaskImageFilename()
Definition: mythuiimage.h:37
QString m_maskImageFilename
Definition: mythuiimage.h:84
QImage GetMaskImageSubset(QRect imageArea)
Definition: mythuiimage.h:48
QString m_filename
Definition: mythuiimage.h:58
bool m_preserveAspect
Definition: mythuiimage.h:63
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:18
Screen in which all other widgets are contained and rendered.
A narrow purpose widget used to represent cut positions and regions when editing a video.
Definition: mythuieditbar.h:17
A narrow purpose widget used to show television programs and the timeslots they occupy on channels.
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:98
QHash< int, MythImage * > m_images
Definition: mythuiimage.h:170
QMutex m_imagesLock
Definition: mythuiimage.h:172
QString m_imageDirectory
Definition: mythuiimage.h:188
QString m_filename
Definition: mythuiimage.h:167
QString m_origFilename
Definition: mythuiimage.h:168
QString GetFilename(void)
Definition: mythuiimage.h:108
void LoadComplete()
ImageProperties m_imageProperties
Definition: mythuiimage.h:183
QHash< int, std::chrono::milliseconds > m_delays
Definition: mythuiimage.h:171
QStringList m_imageList
Definition: mythuiimage.h:189
Progress bar widget.
A text entry and edit widget.
The base class on which all widgets and screens are based.
Definition: mythuitype.h:86
virtual void SetSize(QSize size)
Definition: mythuitype.cpp:569
void customEvent(QEvent *event) override
virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect)
Definition: mythuitype.cpp:479
virtual void LoadNow(void)
Cause images in this and child widgets to be loaded.
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
virtual void Finalize(void)
Perform any post-xml parsing initialisation tasks.
virtual void Pulse(void)
Pulse is called 70 times a second to trigger a single frame of an animation.
Definition: mythuitype.cpp:456
virtual void CreateCopy(MythUIType *parent)
Copy the state of this widget to the one given, it must be of the same type.
virtual void Reset(void)
Reset the widget to it's original state, should not reset changes made by the theme.
Definition: mythuitype.cpp:73
virtual bool ParseElement(const QString &filename, QDomElement &element, bool showWarnings)
Parse the xml definition of this widget setting the state of the object accordingly.
static const iso6937table * d
ReflectAxis
Definition: mythimage.h:18
#define MUI_PUBLIC
Definition: mythuiexp.h:9
QPair< MythImage *, std::chrono::milliseconds > AnimationFrame
Definition: mythuiimage.h:87
QVector< AnimationFrame > AnimationFrames
Definition: mythuiimage.h:88