MythTV  master
glsingleview.h
Go to the documentation of this file.
1 /* ============================================================
2  * File : glsingleview.h
3  * Author: Renchi Raju <renchi@pooh.tam.uiuc.edu>
4  * Date : 2004-01-13
5  * Description :
6  *
7  * Copyright 2004 by Renchi Raju
8 
9  * This program is free software; you can redistribute it
10  * and/or modify it under the terms of the GNU General
11  * Public License as published bythe Free Software Foundation;
12  * either version 2, or (at your option)
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * ============================================================ */
21 
22 #ifndef GLSINGLEVIEW_H
23 #define GLSINGLEVIEW_H
24 #ifdef USING_OPENGL
25 
26 // MythTV plugin headers
27 #include <mthread.h>
28 #include <mythdate.h>
29 
30 // MythGallery headers
31 #include "mythdialogs.h"
32 #include "imageview.h"
33 #include "iconview.h"
34 #include "sequence.h"
35 #include "gltexture.h"
36 
37 // QT headers
38 #include <QGLWidget>
39 
40 class QImage;
41 class QTimer;
42 
43 class GLSingleView;
45 
46 class GLSDialog : public MythDialog
47 {
48  public:
49  GLSDialog(const ThumbList& itemList,
50  int *pos, int slideShow, int sortOrder,
51  MythMainWindow *parent, const char *name="GLSDialog");
52 
53  protected:
54  void closeEvent(QCloseEvent *e) override; // QWidget
55 
56  private:
57  GLSingleView *m_view {nullptr};
58 };
59 
60 class GLSingleView : public QGLWidget, public ImageView
61 {
62  Q_OBJECT
63 
64  public:
65  GLSingleView(const ThumbList& itemList, int *pos, int slideShow, int sortorder,
66  QWidget *parent);
67  ~GLSingleView();
68 
69  void CleanUp(void);
71  void LoadImage(QImage image, QSize origSize);
72 
73 
74  protected:
75  void initializeGL(void) override; // QGLWidget
76 
77  // Commands
78  void Rotate(int angle) override; // ImageView
79  void DisplayNext(bool reset, bool loadImage) override; // ImageView
80  void DisplayPrev(bool reset, bool loadImage) override; // ImageView
81  void Load(void) override; // ImageView
82  void resizeGL(int w, int h) override; // QGLWidget
83 
84  void paintGL(void) override; // QGLWidget
85  void paintTexture(void);
86  void createTexInfo(void);
87  void keyPressEvent(QKeyEvent *e) override; // QWidget
88  void checkPosition(void);
89 
90  // Sets
91  void SetZoom(float zoom) override; // ImageView
92  void SetTransitionTimeout(int timeout);
93 
94  // Gets
95  int GetNearestGLTextureSize(int) const;
96 
97  void RegisterEffects(void) override; // ImageView
98  void RunEffect(const QString &effect) override; // ImageView
99 
100  void EffectNone(void);
101  void EffectBlend(void);
102  void EffectZoomBlend(void);
103  void EffectFade(void);
104  void EffectRotate(void);
105  void EffectBend(void);
106  void EffectInOut(void);
107  void EffectSlide(void);
108  void EffectFlutter(void);
109  void EffectCube(void);
110  void EffectKenBurns(void);
111 
112  private:
113  float FindMaxScale(float x_loc, float y_loc);
114  void FindRandXY(float &x_loc, float &y_loc);
115 
116  private slots:
117  void SlideTimeout(void);
118 
119  private:
120  // General
121  float m_source_x {0.0F};
122  float m_source_y {0.0F};
124 
125  // Texture variables (for display and effects)
126  int m_texMaxDim {512};
127  QSize m_texSize {512,512};
129  int m_texCur {0};
130  bool m_tex1First {true};
131 
132  // Info variables
133  GLuint m_texInfo {0};
134 
135  // Common effect state variables
139  float m_effect_transition_timeout_inv {1.0F / 2000};
140 
141  // Unshared effect state variables
142  float m_effect_flutter_points[40][40][3];
143  float m_effect_cube_xrot {0.0F};
144  float m_effect_cube_yrot {0.0F};
145  float m_effect_cube_zrot {0.0F};
158 
159 };
160 
162 {
163 public:
164  KenBurnsImageLoader(GLSingleView *singleView, QSize texSize, QSize screenSize)
165  : MThread("KenBurnsImageLoader"),
166  m_singleView(singleView),
167  m_screenSize(screenSize),
168  m_texSize(texSize) {}
169  void run() override; // MThread
170 private:
173  QSize m_texSize;
174 
175 };
176 
177 #endif // USING_OPENGL
178 #endif // GLSINGLEVIEW_H
QImage m_effect_kenBurns_image
Definition: glsingleview.h:153
GLSingleView(const ThumbList &itemList, int *pos, int slideShow, int sortorder, QWidget *parent)
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
unsigned int slots[4]
Definition: element.c:38
A QElapsedTimer based timer to replace use of QTime as a timer.
Definition: mythtimer.h:13
GLTexture m_texItem[2]
Definition: glsingleview.h:128
float m_source_x
Definition: glsingleview.h:121
void FindRandXY(float &x_loc, float &y_loc)
void EffectNone(void)
float m_source_y
Definition: glsingleview.h:122
bool m_effect_kenBurns_new_image_started
Definition: glsingleview.h:157
void createTexInfo(void)
void RegisterEffects(void) override
void keyPressEvent(QKeyEvent *e) override
float m_effect_kenBurns_image_timeout
Definition: glsingleview.h:150
void EffectCube(void)
void resizeGL(int w, int h) override
KenBurnsImageLoader(GLSingleView *singleView, QSize texSize, QSize screenSize)
Definition: glsingleview.h:164
GLuint m_texInfo
Definition: glsingleview.h:133
void CleanUp(void)
void RunEffect(const QString &effect) override
ThumbItem * m_effect_kenBurns_item
Definition: glsingleview.h:155
QList< ThumbItem * > ThumbList
Definition: thumbview.h:78
void EffectInOut(void)
int m_effect_kenBurns_projection[2]
Definition: glsingleview.h:148
bool m_effect_kenBurns_image_ready
Definition: glsingleview.h:152
GLSDialog(const ThumbList &itemList, int *pos, int slideShow, int sortOrder, MythMainWindow *parent, const char *name="GLSDialog")
void SetZoom(float zoom) override
void SetTransitionTimeout(int timeout)
void paintTexture(void)
QSize m_effect_kenBurns_orig_image_size
Definition: glsingleview.h:154
void closeEvent(QCloseEvent *e) override
void EffectRotate(void)
KenBurnsImageLoader * m_effect_kenBurns_imageLoadThread
Definition: glsingleview.h:151
void checkPosition(void)
void EffectKenBurns(void)
void Ready()
Definition: glsingleview.h:70
float m_effect_kenBurns_location_y[2]
Definition: glsingleview.h:147
bool m_effect_kenBurns_initialized
Definition: glsingleview.h:156
void EffectFlutter(void)
float FindMaxScale(float x_loc, float y_loc)
void EffectZoomBlend(void)
void DisplayNext(bool reset, bool loadImage) override
void SlideTimeout(void)
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
void initializeGL(void) override
const char * name
Definition: ParseText.cpp:328
void LoadImage(QImage image, QSize origSize)
GLSingleView * m_singleView
Definition: glsingleview.h:171
ScaleMax m_scaleMax
Definition: glsingleview.h:123
int m_effect_rotate_direction
Definition: glsingleview.h:136
Base dialog for most dialogs in MythTV using the old UI.
Definition: mythdialogs.h:40
ScaleMax
Definition: galleryutil.h:28
void EffectFade(void)
MythTimer m_effect_frame_time
Definition: glsingleview.h:137
void paintGL(void) override
int GetNearestGLTextureSize(int) const
int m_effect_transition_timeout
Definition: glsingleview.h:138
float m_effect_cube_zrot
Definition: glsingleview.h:145
void EffectSlide(void)
void Rotate(int angle) override
GLSingleView * m_view
Definition: glsingleview.h:57
float m_effect_cube_xrot
Definition: glsingleview.h:143
MythTimer m_effect_kenBurns_image_time[2]
Definition: glsingleview.h:149
void EffectBlend(void)
void Load(void) override
float m_effect_flutter_points[40][40][3]
Definition: glsingleview.h:142
float m_effect_cube_yrot
Definition: glsingleview.h:144
float m_effect_transition_timeout_inv
Definition: glsingleview.h:139
void DisplayPrev(bool reset, bool loadImage) override
float m_effect_kenBurns_location_x[2]
Definition: glsingleview.h:146
void EffectBend(void)