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(const 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 *, int>;
88 using AnimationFrames = QVector<AnimationFrame>;
89 
98 {
99  Q_OBJECT
100 
101  public:
102  MythUIImage(const QString &filepattern, int low, int high, int delayms,
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(int delayms);
129  void SetDelays(const QVector<int>& 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(const QSize &size) override; // MythUIType
160  void ForceSize(const 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, int> m_Delays;
172  QMutex m_ImagesLock;
173 
174  int m_Delay;
175  int m_LowNum;
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 
190  MythUIImagePrivate *d {nullptr}; // NOLINT(readability-identifier-naming)
191 
192  enum AnimationCycle {kCycleStart, kCycleReverse};
193  AnimationCycle m_animationCycle {kCycleStart};
194  bool m_animationReverse {false};
195  bool m_animatedImage {false};
196 
197  friend class MythUIImagePrivate;
198  friend class MythThemeBase;
199  friend class MythUIButtonListItem;
200  friend class MythUIProgressBar;
201  friend class MythUIEditBar;
202  friend class MythUITextEdit;
203  friend class ImageLoadThread;
204  friend class MythUIGuideGrid;
205 
206  private:
207  Q_DISABLE_COPY(MythUIImage)
208 };
209 
210 #endif
ImageProperties::SetMaskImage
void SetMaskImage(MythImage *image)
Definition: mythuiimage.cpp:87
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::AnimationCycle
AnimationCycle
Definition: mythuiimage.h:192
MythUIImage::m_HighNum
int m_HighNum
Definition: mythuiimage.h:176
MythUIImage::m_LowNum
int m_LowNum
Definition: mythuiimage.h:175
ImageProperties::m_reflectSpacing
int m_reflectSpacing
Definition: mythuiimage.h:73
ImageProperties::m_isThemeImage
bool m_isThemeImage
Definition: mythuiimage.h:77
d
static const uint16_t * d
Definition: iso6937tables.cpp:1025
MythUIEditBar
A narrow purpose widget used to represent cut positions and regions when editing a video.
Definition: mythuieditbar.h:16
ImageProperties::m_reflectAxis
ReflectAxis m_reflectAxis
Definition: mythuiimage.h:69
MythUIType::customEvent
void customEvent(QEvent *event) override
Definition: mythuitype.cpp:978
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:32
MythUIType::SetSize
virtual void SetSize(const QSize &size)
Definition: mythuitype.cpp:548
ImageProperties::m_reflectScale
int m_reflectScale
Definition: mythuiimage.h:70
AnimationFrame
QPair< MythImage *, int > AnimationFrame
Definition: mythuiimage.h:87
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:44
MythUIImage::m_Filename
QString m_Filename
Definition: mythuiimage.h:167
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:41
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:440
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:1204
ImageProperties
Definition: mythuiimage.h:23
MythUIType::DrawSelf
virtual void DrawSelf(MythPainter *p, int xoffset, int yoffset, int alphaMod, QRect clipRect)
Definition: mythuitype.cpp:463
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
ImageProperties::GetMaskImageSubset
QImage GetMaskImageSubset(const QRect &imageArea)
Definition: mythuiimage.h:48
ReflectAxis
ReflectAxis
Definition: mythimage.h:18
MythUIImage::m_OrigFilename
QString m_OrigFilename
Definition: mythuiimage.h:168
MythThemeBase
Definition: myththemebase.h:8
MythUIButtonListItem
Definition: mythuibuttonlist.h:27
ImageProperties::m_maskImage
MythImage * m_maskImage
Definition: mythuiimage.h:83
ImageProperties::m_maskImageFilename
QString m_maskImageFilename
Definition: mythuiimage.h:84
ImageProperties::operator=
ImageProperties & operator=(const ImageProperties &other)
Definition: mythuiimage.cpp:45
MythUIProgressBar
Progress bar widget.
Definition: mythuiprogressbar.h:12
hardwareprofile.config.p
p
Definition: config.py:33
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:634
MythUIImage::m_Images
QHash< int, MythImage * > m_Images
Definition: mythuiimage.h:170
MythUIType::CopyFrom
virtual void CopyFrom(MythUIType *base)
Copy this widgets state from another.
Definition: mythuitype.cpp:1147
ImageProperties::m_isOriented
bool m_isOriented
Definition: mythuiimage.h:67
ImageProperties::Copy
void Copy(const ImageProperties &other)
Definition: mythuiimage.cpp:61
MythUIImage::m_imageDirectory
QString m_imageDirectory
Definition: mythuiimage.h:188
MythUIImage::kCycleStart
@ kCycleStart
Definition: mythuiimage.h:192
ImageProperties::SetMaskImageFilename
void SetMaskImageFilename(const QString &filename)
Definition: mythuiimage.h:33
MythUIImage::m_ImagesLock
QMutex m_ImagesLock
Definition: mythuiimage.h:172
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:69
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:63
MythUIImage::m_Delay
int m_Delay
Definition: mythuiimage.h:174
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:541
ImageProperties::GetMaskImageRect
QRect GetMaskImageRect(void)
Definition: mythuiimage.h:41
Clear
#define Clear(a)
Definition: audiooutputopensles.cpp:49
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:1376
ImageProperties::ImageProperties
ImageProperties()=default
MythPainter
Definition: mythpainter.h:32
MythImage
Definition: mythimage.h:36
ImageProperties::m_reflectLength
int m_reflectLength
Definition: mythuiimage.h:71
ImageProperties::~ImageProperties
~ImageProperties()
Definition: mythuiimage.cpp:55
MythUIImage::m_Delays
QHash< int, int > m_Delays
Definition: mythuiimage.h:171
ImageProperties::Init
void Init(void)
ImageProperties::GetMaskImageFilename
QString GetMaskImageFilename()
Definition: mythuiimage.h:37
MythUIImage::GetFilename
QString GetFilename(void)
Definition: mythuiimage.h:108
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:1213
ImageLoadThread
Definition: mythuiimage.cpp:482
MythUIType::Finalize
virtual void Finalize(void)
Perform any post-xml parsing initialisation tasks.
Definition: mythuitype.cpp:1289
mythuitype.h