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 
15 class MythUIImagePrivate;
16 class MythScreenType;
17 class 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  {
39  return m_maskImageFilename;
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 
60  MythRect m_cropRect {0,0,0,0};
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};
72  int m_reflectShear {0};
74 
75  int m_orientation {1};
76 
77  bool m_isThemeImage {false};
78 
79  private:
80  void Init(void);
81  void Copy(const ImageProperties &other);
82 
83  MythImage *m_maskImage {nullptr};
85 };
86 
87 using AnimationFrame = QPair<MythImage *, std::chrono::milliseconds>;
88 using 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:
141  void LoadComplete();
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;
168  QString m_origFilename;
169 
170  QHash<int, MythImage *> m_images;
171  QHash<int, std::chrono::milliseconds> m_delays;
172  QMutex m_imagesLock;
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 {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;
201  friend class MythUIButtonListItem;
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
MythUIImage::m_origFilename
QString m_origFilename
Definition: mythuiimage.h:168
MythUIImage::m_imagesLock
QMutex m_imagesLock
Definition: mythuiimage.h:172
ImageProperties::SetMaskImage
void SetMaskImage(MythImage *image)
Definition: mythuiimage.cpp:92
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
ImageProperties::m_cropRect
MythRect m_cropRect
Definition: mythuiimage.h:60
MythUIImage::m_images
QHash< int, MythImage * > m_images
Definition: mythuiimage.h:170
MythUIImage::AnimationCycle
AnimationCycle
Definition: mythuiimage.h:194
ImageProperties::m_reflectSpacing
int m_reflectSpacing
Definition: mythuiimage.h:73
ImageProperties::m_isThemeImage
bool m_isThemeImage
Definition: mythuiimage.h:77
MythUIEditBar
A narrow purpose widget used to represent cut positions and regions when editing a video.
Definition: mythuieditbar.h:16
MythUIImage::m_delays
QHash< int, std::chrono::milliseconds > m_delays
Definition: mythuiimage.h:171
ImageProperties::m_reflectAxis
ReflectAxis m_reflectAxis
Definition: mythuiimage.h:69
MythUIType::customEvent
void customEvent(QEvent *event) override
Definition: mythuitype.cpp:1006
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:34
ImageProperties::m_reflectScale
int m_reflectScale
Definition: mythuiimage.h:70
ImageProperties::GetMaskImageSubset
QImage GetMaskImageSubset(QRect imageArea)
Definition: mythuiimage.h:48
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
ImageProperties::m_orientation
int m_orientation
Definition: mythuiimage.h:75
MythUIGuideGrid
A narrow purpose widget used to show television programs and the timeslots they occupy on channels....
Definition: mythuiguidegrid.h:43
MythRect
Wrapper around QRect allowing us to handle percentage and other relative values for areas in mythui.
Definition: mythrect.h:17
MythUIType::Pulse
virtual void Pulse(void)
Pulse is called 70 times a second to trigger a single frame of an animation.
Definition: mythuitype.cpp:455
MythUIType::CreateCopy
virtual void CreateCopy(MythUIType *parent)
Copy the state of this widget to the one given, it must be of the same type.
Definition: mythuitype.cpp:1231
ImageProperties
Definition: mythuiimage.h:23
MythUIType::DrawSelf
virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect)
Definition: mythuitype.cpp:478
AnimationFrames
QVector< AnimationFrame > AnimationFrames
Definition: mythuiimage.h:88
ImageProperties::m_forceSize
QSize m_forceSize
Definition: mythuiimage.h:61
ImageProperties::m_preserveAspect
bool m_preserveAspect
Definition: mythuiimage.h:63
ImageProperties::m_filename
QString m_filename
Definition: mythuiimage.h:58
ReflectAxis
ReflectAxis
Definition: mythimage.h:18
MythThemeBase
Definition: myththemebase.h:11
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
ImageProperties::m_maskImage
MythImage * m_maskImage
Definition: mythuiimage.h:83
ImageProperties::m_maskImageFilename
QString m_maskImageFilename
Definition: mythuiimage.h:84
MythUIImage::m_imageList
QStringList m_imageList
Definition: mythuiimage.h:189
ImageProperties::operator=
ImageProperties & operator=(const ImageProperties &other)
Definition: mythuiimage.cpp:47
MythUIProgressBar
Progress bar widget.
Definition: mythuiprogressbar.h:12
hardwareprofile.config.p
p
Definition: config.py:33
MythUIType::CopyFrom
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
Definition: mythuitype.cpp:1174
ImageProperties::m_isOriented
bool m_isOriented
Definition: mythuiimage.h:67
ImageProperties::Copy
void Copy(const ImageProperties &other)
Definition: mythuiimage.cpp:66
MythUIImage::m_imageDirectory
QString m_imageDirectory
Definition: mythuiimage.h:188
MythUIImage::kCycleStart
@ kCycleStart
Definition: mythuiimage.h:194
ImageProperties::SetMaskImageFilename
void SetMaskImageFilename(const QString &filename)
Definition: mythuiimage.h:33
ImageProperties::m_isMasked
bool m_isMasked
Definition: mythuiimage.h:66
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:72
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:85
ImageProperties::m_reflectShear
int m_reflectShear
Definition: mythuiimage.h:72
mythuihelper.h
mythimage.h
ImageProperties::m_isReflected
bool m_isReflected
Definition: mythuiimage.h:65
MythUIImagePrivate
Definition: mythuiimage.cpp:546
ImageProperties::GetMaskImageRect
QRect GetMaskImageRect(void)
Definition: mythuiimage.h:41
Clear
#define Clear(a)
Definition: audiooutputopensles.cpp:54
ImageProperties::m_isGreyscale
bool m_isGreyscale
Definition: mythuiimage.h:64
MythUIType::LoadNow
virtual void LoadNow(void)
Cause images in this and child widgets to be loaded.
Definition: mythuitype.cpp:1403
ImageProperties::ImageProperties
ImageProperties()=default
MythPainter
Definition: mythpainter.h:34
MythImage
Definition: mythimage.h:36
MythUIType::SetSize
virtual void SetSize(QSize size)
Definition: mythuitype.cpp:568
ImageProperties::m_reflectLength
int m_reflectLength
Definition: mythuiimage.h:71
ImageProperties::~ImageProperties
~ImageProperties()
Definition: mythuiimage.cpp:57
ImageProperties::Init
void Init(void)
ImageProperties::GetMaskImageFilename
QString GetMaskImageFilename()
Definition: mythuiimage.h:37
MythUIImage::m_filename
QString m_filename
Definition: mythuiimage.h:167
MythUIImage::GetFilename
QString GetFilename(void)
Definition: mythuiimage.h:108
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
MythUIImage::m_imageProperties
ImageProperties m_imageProperties
Definition: mythuiimage.h:183
ReflectAxis::Vertical
@ Vertical
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:1240
build_compdb.filename
filename
Definition: build_compdb.py:21
ImageLoadThread
Definition: mythuiimage.cpp:487
MythUIType::Finalize
virtual void Finalize(void)
Perform any post-xml parsing initialisation tasks.
Definition: mythuitype.cpp:1316
mythuitype.h
AnimationFrame
QPair< MythImage *, std::chrono::milliseconds > AnimationFrame
Definition: mythuiimage.h:87