1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
/* ============================================================
*
* This file is a part of kipi-plugins project
* http://www.kipi-plugins.org
*
* Date : 2007-11-14
* Description : a kipi plugin to slide images.
*
* Copyright (C) 2007 by Valerio Fuoglio <valerio dot fuoglio at gmail dot com>
*
* Parts of this code are based on smoothslidesaver by Carsten Weinhold
* <carsten dot weinhold at gmx dot de> and slideshowgl.{cpp|h} by Renchi Raju
* <renchi@pooh.tam.uiuc.edu>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef SLIDESHOWKB_H
#define SLIDESHOWKB_H
// C++ includes.
#include <cstdlib>
// Qt includes.
#include <qgl.h>
#include <qtimer.h>
#include <qvaluelist.h>
#include <qpair.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qevent.h>
#include <qmap.h>
// KDE includes.
#include <kconfig.h>
// Local includes.
#include "kbeffect.h"
#include "screenproperties.h"
namespace KIPISlideShowPlugin
{
class SmoothSlideSaver;
class ImageLoadThread;
// -------------------------------------------------------------------------
class ViewTrans
{
public:
ViewTrans(bool m_zoomIn, float relAspect);
float transX(float pos) const { return m_baseX + m_deltaX * pos; };
float transY(float pos) const { return m_baseY + m_deltaY * pos; };
float scale (float pos) const { return m_baseScale * (1.0 + m_deltaScale * pos); };
float m_xScaleCorrect() { return m_xScale; };
float m_yScaleCorrect() { return m_yScale; };
private:
double rnd() const { return (double)rand() / (double)RAND_MAX; };
double rndSign() const { return (rand() < RAND_MAX / 2) ? 1.0 : -1.0; };
private:
// delta and scale values (begin to end) and the needed offsets
double m_deltaX, m_deltaY, m_deltaScale;
double m_baseScale, m_baseX, m_baseY;
float m_xScale, m_yScale;
};
// -------------------------------------------------------------------------
class Image
{
public:
Image(ViewTrans *viewTrans, float aspect = 1.0);
~Image();
ViewTrans* m_viewTrans;
float m_aspect;
float m_pos;
float m_opacity;
bool m_paint;
GLuint m_texture;
};
// -------------------------------------------------------------------------
class SlideShowKB : public QGLWidget
{
Q_OBJECT
public:
SlideShowKB(const QValueList<QPair<QString, int> >& fileList,
const QStringList& commentsList, bool ImagesHasComments);
~SlideShowKB();
static QStringList effectNames();
static QMap<QString,QString> effectNamesI18N();
private:
float aspect() { return (float)width() / (float)height(); };
bool setupNewImage(int imageIndex);
void startSlideShowOnce();
void swapImages();
void setNewKBEffect();
void endOfShow();
void initializeGL();
void paintGL();
void resizeGL(int w, int h);
void applyTexture(Image *img, const QImage &image);
void paintTexture(Image *img);
unsigned suggestFrameRate(unsigned forceRate);
void readSettings();
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *);
private slots:
void moveSlot();
void slotEndOfShow();
void slotMouseMoveTimeOut();
void slotClose();
private:
int m_deskX;
int m_deskY;
int m_deskWidth;
int m_deskHeight;
KConfig* m_config;
bool m_imagesHasComments;
QStringList m_commentsList;
ScreenProperties* m_screen;
QTimer *m_timer;
QTimer *m_mouseMoveTimer;
ImageLoadThread *m_imageLoadThread;
bool m_haveImages;
Image *m_image[2];
KBEffect *m_effect;
int m_numKBEffectRepeated;
bool m_zoomIn, m_initialized;
float m_step;
bool m_endOfShow;
bool m_showingEnd;
// settings from config file
int m_delay;
bool m_disableFadeInOut;
bool m_disableCrossFade;
unsigned m_forceFrameRate;
friend class KBEffect;
};
} // NameSpace KIPISlideShowPlugin
#endif // SLIDESHOWKB_H
|