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-2021 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 #include "transitionmngr_p.h"
24 
25 namespace Digikam
26 {
27 
transitionSlideL2R(bool aInit)28 int TransitionMngr::Private::transitionSlideL2R(bool aInit)
29 {
30     if (aInit)
31     {
32         eff_fx = eff_outSize.width() / 25.0;
33         eff_i  = 0;
34     }
35 
36     QPainter bufferPainter(&eff_curFrame);
37     bufferPainter.drawImage(0,     0, eff_outImage);
38     bufferPainter.drawImage(eff_i, 0, eff_inImage);
39     bufferPainter.end();
40 
41     eff_i = eff_i + lround(eff_fx);
42 
43     if (eff_i <= eff_outSize.width())
44     {
45         return 15;
46     }
47 
48     eff_curFrame = eff_outImage;
49 
50     return -1;
51 }
52 
transitionSlideR2L(bool aInit)53 int TransitionMngr::Private::transitionSlideR2L(bool aInit)
54 {
55     if (aInit)
56     {
57         eff_fx = eff_outSize.width() / 25.0;
58         eff_i  = 0;
59     }
60 
61     QPainter bufferPainter(&eff_curFrame);
62     bufferPainter.drawImage(0,     0, eff_outImage);
63     bufferPainter.drawImage(eff_i, 0, eff_inImage);
64     bufferPainter.end();
65 
66     eff_i = eff_i - lround(eff_fx);
67 
68     if (eff_i >= -eff_outSize.width())
69     {
70         return 15;
71     }
72 
73     eff_curFrame = eff_outImage;
74 
75     return -1;
76 }
77 
transitionSlideT2B(bool aInit)78 int TransitionMngr::Private::transitionSlideT2B(bool aInit)
79 {
80     if (aInit)
81     {
82         eff_fy = eff_outSize.height() / 25.0;
83         eff_i  = 0;
84     }
85 
86     QPainter bufferPainter(&eff_curFrame);
87     bufferPainter.drawImage(0, 0,     eff_outImage);
88     bufferPainter.drawImage(0, eff_i, eff_inImage);
89     bufferPainter.end();
90 
91     eff_i = eff_i + lround(eff_fy);
92 
93     if (eff_i <= eff_outSize.height())
94     {
95         return 15;
96     }
97 
98     eff_curFrame = eff_outImage;
99 
100     return -1;
101 }
102 
transitionSlideB2T(bool aInit)103 int TransitionMngr::Private::transitionSlideB2T(bool aInit)
104 {
105     if (aInit)
106     {
107         eff_fy = eff_outSize.height() / 25.0;
108         eff_i  = 0;
109     }
110 
111     QPainter bufferPainter(&eff_curFrame);
112     bufferPainter.drawImage(0, 0,     eff_outImage);
113     bufferPainter.drawImage(0, eff_i, eff_inImage);
114     bufferPainter.end();
115 
116     eff_i = eff_i - lround(eff_fy);
117 
118     if (eff_i >= -eff_outSize.height())
119     {
120         return 15;
121     }
122 
123     eff_curFrame = eff_outImage;
124 
125     return -1;
126 }
127 
128 } // namespace Digikam
129