MythTV master
mythuiimage.h
Go to the documentation of this file.
1#ifndef MYTHUI_IMAGE_H_
2#define MYTHUI_IMAGE_H_
3
4#include <QChar> // Fix Qt6 GCC SFINAE warning
5#include <QDateTime>
6#include <QHash>
7#include <QMutex>
8#include <QWaitCondition>
9#include <QVector>
10#include <QPair>
11
12#include "mythuitype.h"
13#include "mythuihelper.h"
14#include "mythimage.h"
15
17class MythScreenType;
18class ImageLoadThread;
19
25{
26 public:
27 ImageProperties() = default;
28 ImageProperties(const ImageProperties& other);
30
32
33 void SetMaskImage(MythImage *image);
34 void SetMaskImageFilename(const QString &filename)
35 {
37 }
39 {
41 }
42 QRect GetMaskImageRect(void)
43 {
44 QRect rect;
45 if (m_maskImage)
46 rect = m_maskImage->rect();
47 return rect;
48 }
49 QImage GetMaskImageSubset(QRect imageArea)
50 {
51 if (m_maskImage)
52 return m_maskImage->copy(imageArea);
53
54 QImage img(imageArea.size(), QImage::Format_ARGB32);
55 img.fill(0xFFFFFFFF);
56 return img;
57 }
58
59 QString m_filename;
60
62 QSize m_forceSize {0,0};
63
64 bool m_preserveAspect {false};
65 bool m_isGreyscale {false};
66 bool m_isReflected {false};
67 bool m_isMasked {false};
68 bool m_isOriented {false};
69
71 int m_reflectScale {100};
72 int m_reflectLength {100};
75
77
78 bool m_isThemeImage {false};
79
80 private:
81 void Init(void);
82 void Copy(const ImageProperties &other);
83
86};
87
88using AnimationFrame = QPair<MythImage *, std::chrono::milliseconds>;
89using AnimationFrames = QVector<AnimationFrame>;
90
99{
100 Q_OBJECT
101
102 public:
103 MythUIImage(const QString &filepattern, int low, int high, std::chrono::milliseconds delay,
104 MythUIType *parent, const QString &name);
105 MythUIImage(const QString &filename, MythUIType *parent, const QString &name);
106 MythUIImage(MythUIType *parent, const QString &name);
107 ~MythUIImage() override;
108
109 QString GetFilename(void) const { return m_imageProperties.m_filename; }
110
112 void SetFilename(const QString &filename);
113
115 void SetFilepattern(const QString &filepattern, int low, int high);
116
117 void SetImageCount(int low, int high);
118
122 void SetImage(MythImage *img);
123
127 void SetImages(QVector<MythImage *> *images);
128
129 void SetDelay(std::chrono::milliseconds delayms);
130 void SetDelays(const QVector<std::chrono::milliseconds>& delays);
131
132 void Reset(void) override; // MythUIType
133 bool Load(bool allowLoadInBackground = true, bool forceStat = false);
134
135 void Pulse(void) override; // MythUIType
136
137 void LoadNow(void) override; // MythUIType
138
139 void SetSize(QSize size) override; // MythUIType
140 void SetOrientation(int orientation);
141
142 signals:
144
145 protected:
146 void DrawSelf(MythPainter *p, int xoffset, int yoffset,
147 int alphaMod, QRect clipRect) override; // MythUIType
148
149 void Clear(void);
150
151 void SetAnimationFrames(const AnimationFrames& frames);
152 void customEvent(QEvent *event) override; // MythUIType
153
154 bool ParseElement(const QString &filename, QDomElement &element,
155 bool showWarnings) override; // MythUIType
156 void CopyFrom(MythUIType *base) override; // MythUIType
157 void CreateCopy(MythUIType *parent) override; // MythUIType
158 void Finalize(void) override; // MythUIType
159
160 void SetSize(int width, int height);
161 void ForceSize(QSize size);
162
163 void SetCropRect(int x, int y, int width, int height);
164 void SetCropRect(const MythRect &rect);
165
166 void FindRandomImage(void);
167
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:42
ImageProperties()=default
void SetMaskImageFilename(const QString &filename)
Definition: mythuiimage.h:34
MythRect m_cropRect
Definition: mythuiimage.h:61
ReflectAxis m_reflectAxis
Definition: mythuiimage.h:70
MythImage * m_maskImage
Definition: mythuiimage.h:84
void SetMaskImage(MythImage *image)
Definition: mythuiimage.cpp:88
void Copy(const ImageProperties &other)
Definition: mythuiimage.cpp:62
ImageProperties & operator=(const ImageProperties &other)
Definition: mythuiimage.cpp:43
QString GetMaskImageFilename()
Definition: mythuiimage.h:38
QString m_maskImageFilename
Definition: mythuiimage.h:85
QImage GetMaskImageSubset(QRect imageArea)
Definition: mythuiimage.h:49
QString m_filename
Definition: mythuiimage.h:59
bool m_preserveAspect
Definition: mythuiimage.h:64
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:99
QHash< int, MythImage * > m_images
Definition: mythuiimage.h:170
QMutex m_imagesLock
Definition: mythuiimage.h:172
QString m_imageDirectory
Definition: mythuiimage.h:188
QString GetFilename(void) const
Definition: mythuiimage.h:109
QString m_origFilename
Definition: mythuiimage.h:168
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:97
virtual void SetSize(QSize size)
Definition: mythuitype.cpp:555
void customEvent(QEvent *event) override
Definition: mythuitype.cpp:989
virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect)
Definition: mythuitype.cpp:465
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:442
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:71
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:88
QVector< AnimationFrame > AnimationFrames
Definition: mythuiimage.h:89