digiKam
transitionmngr_p.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2017-05-24
7  * Description : images transition manager.
8  *
9  * Copyright (C) 2017-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * ============================================================ */
22 
23 #ifndef DIGIKAM_TRANSITION_MNGR_PRIVATE_H
24 #define DIGIKAM_TRANSITION_MNGR_PRIVATE_H
25 
26 // C++ includes
27 
28 #include <cmath>
29 
30 // Qt includes
31 
32 #include <QPainter>
33 #include <QPainterPath>
34 #include <QPolygon>
35 #include <QRandomGenerator>
36 
37 // Local includes
38 
39 #include "transitionmngr.h"
40 #include "digikam_config.h"
41 #include "digikam_debug.h"
42 
43 namespace Digikam
44 {
45 
46 class Q_DECL_HIDDEN TransitionMngr::Private
47 {
48 public:
49 
50  typedef int (TransitionMngr::Private::*TransMethod)(bool);
51 
52 public:
53 
54  explicit Private()
55  : eff_isRunning (false),
56  eff_curTransition(TransitionMngr::None),
57  eff_x (0),
58  eff_y (0),
59  eff_w (0),
60  eff_h (0),
61  eff_dx (0),
62  eff_dy (0),
63  eff_ix (0),
64  eff_iy (0),
65  eff_i (0),
66  eff_j (0),
67  eff_subType (0),
68  eff_x0 (0),
69  eff_y0 (0),
70  eff_x1 (0),
71  eff_y1 (0),
72  eff_wait (0),
73  eff_fx (0),
74  eff_fy (0),
75  eff_alpha (0),
76  eff_fd (0),
77  eff_intArray (nullptr),
78  eff_pdone (0),
79  eff_pixelMatrix (nullptr),
80  eff_pa (QPolygon(4)),
81  eff_px (0),
82  eff_py (0),
83  eff_psx (0),
84  eff_psy (0)
85  {
86  registerTransitions();
87  randomGenerator = QRandomGenerator::global();
88  }
89 
91  {
92  if (eff_intArray)
93  {
94  delete [] eff_intArray;
95  }
96  }
97 
98  QMap<TransitionMngr::TransType, TransMethod> eff_transList;
99 
100  QImage eff_inImage;
101  QImage eff_outImage;
102  QImage eff_curFrame;
103  QSize eff_outSize;
104 
107 
108  // values for state of various transitions:
109  int eff_x;
110  int eff_y;
111  int eff_w;
112  int eff_h;
113  int eff_dx;
114  int eff_dy;
115  int eff_ix;
116  int eff_iy;
117  int eff_i;
118  int eff_j;
120  int eff_x0;
121  int eff_y0;
122  int eff_x1;
123  int eff_y1;
124  int eff_wait;
125  double eff_fx;
126  double eff_fy;
127  double eff_alpha;
128  double eff_fd;
130  bool eff_pdone;
132 
133  //static
134  QPolygon eff_pa;
135 
136  int eff_px;
137  int eff_py;
138  int eff_psx;
139  int eff_psy;
140 
141 public:
142 
143  void registerTransitions();
144 
145  TransitionMngr::TransType getRandomTransition() const;
146 
147 private:
148 
149  // Internal functions to render an effect frame.
150  // aInit is to true when effect is initialized (first call).
151  // The integer value is a tempo in ms to wait between frames,
152  // or -1 if the effect is completed.
153 
154  int transitionNone(bool aInit);
155  int transitionChessboard(bool aInit);
156  int transitionMeltdown(bool aInit);
157  int transitionSweep(bool aInit);
158  int transitionMosaic(bool aInit);
159  int transitionCubism(bool aInit);
160  int transitionRandom(bool aInit);
161  int transitionGrowing(bool aInit);
162  int transitionHorizLines(bool aInit);
163  int transitionVertLines(bool aInit);
164  int transitionMultiCircleOut(bool aInit);
165  int transitionSpiralIn(bool aInit);
166  int transitionCircleOut(bool aInit);
167  int transitionBlobs(bool aInit);
168  int transitionFade(bool aInit);
169  int transitionSlideL2R(bool aInit);
170  int transitionSlideR2L(bool aInit);
171  int transitionSlideT2B(bool aInit);
172  int transitionSlideB2T(bool aInit);
173  int transitionPushL2R(bool aInit);
174  int transitionPushR2L(bool aInit);
175  int transitionPushT2B(bool aInit);
176  int transitionPushB2T(bool aInit);
177  int transitionSwapL2R(bool aInit);
178  int transitionSwapR2L(bool aInit);
179  int transitionSwapT2B(bool aInit);
180  int transitionSwapB2T(bool aInit);
181  int transitionBlurIn(bool aInit);
182  int transitionBlurOut(bool aInit);
183 
184 private:
185 
186  QRgb convertFromPremult(const QRgb& p) const;
187  QImage fastBlur(const QImage& img, int radius) const;
188  QRandomGenerator *randomGenerator;
189 };
190 
191 } // namespace Digikam
192 
193 #endif // DIGIKAM_TRANSITION_MNGR_PRIVATE_H
Definition: transitionmngr_p.h:47
int eff_y0
Definition: transitionmngr_p.h:121
int eff_j
Definition: transitionmngr_p.h:118
int eff_dx
Definition: transitionmngr_p.h:113
int eff_dy
Definition: transitionmngr_p.h:114
int eff_y
Definition: transitionmngr_p.h:110
QMap< TransitionMngr::TransType, TransMethod > eff_transList
Definition: transitionmngr_p.h:98
int eff_w
Definition: transitionmngr_p.h:111
bool ** eff_pixelMatrix
Definition: transitionmngr_p.h:131
int eff_iy
Definition: transitionmngr_p.h:116
int eff_i
Definition: transitionmngr_p.h:117
QSize eff_outSize
Definition: transitionmngr_p.h:103
QImage eff_curFrame
Definition: transitionmngr_p.h:102
bool eff_isRunning
Definition: transitionmngr_p.h:105
QImage eff_outImage
Definition: transitionmngr_p.h:101
int eff_psy
Definition: transitionmngr_p.h:139
int eff_wait
Definition: transitionmngr_p.h:124
double eff_fd
Definition: transitionmngr_p.h:128
int eff_x
Definition: transitionmngr_p.h:109
double eff_fy
Definition: transitionmngr_p.h:126
int eff_x0
Definition: transitionmngr_p.h:120
double eff_fx
Definition: transitionmngr_p.h:125
int eff_px
Definition: transitionmngr_p.h:136
~Private()
Definition: transitionmngr_p.h:90
int eff_psx
Definition: transitionmngr_p.h:138
int eff_ix
Definition: transitionmngr_p.h:115
double eff_alpha
Definition: transitionmngr_p.h:127
int eff_h
Definition: transitionmngr_p.h:112
int eff_py
Definition: transitionmngr_p.h:137
int * eff_intArray
Definition: transitionmngr_p.h:129
QImage eff_inImage
Definition: transitionmngr_p.h:100
bool eff_pdone
Definition: transitionmngr_p.h:130
int eff_subType
Definition: transitionmngr_p.h:119
QPolygon eff_pa
Definition: transitionmngr_p.h:134
int eff_y1
Definition: transitionmngr_p.h:123
Private()
Definition: transitionmngr_p.h:54
int eff_x1
Definition: transitionmngr_p.h:122
TransitionMngr::TransType eff_curTransition
Definition: transitionmngr_p.h:106
Definition: transitionmngr.h:40
TransType
Definition: transitionmngr.h:44
Definition: datefolderview.cpp:43