1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2017-05-24
7  * Description : video frame effects 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 #ifndef DIGIKAM_EFFECT_MNGR_PRIVATE_H
24 #define DIGIKAM_EFFECT_MNGR_PRIVATE_H
25 
26 // C++ includes
27 
28 #include <cmath>
29 
30 // Qt includes
31 
32 #include <QPointF>
33 #include <QRect>
34 #include <QRectF>
35 #include <QImage>
36 
37 // Local includes
38 
39 #include "effectmngr.h"
40 #include "digikam_config.h"
41 #include "digikam_debug.h"
42 
43 namespace Digikam
44 {
45 
46 class Q_DECL_HIDDEN EffectMngr::Private
47 {
48 public:
49 
50     typedef int (EffectMngr::Private::*EffectMethod)(bool);
51 
52 public:
53 
Private()54     explicit Private()
55       : eff_isRunning(false),
56         eff_curEffect(EffectMngr::None),
57         eff_step(0),
58         eff_imgFrames(125)
59     {
60         registerEffects();
61     }
62 
~Private()63     ~Private()
64     {
65     }
66 
67     QMap<EffectMngr::EffectType, EffectMethod>    eff_effectList;
68 
69     QImage                                        eff_image;
70     QImage                                        eff_curFrame;
71     QSize                                         eff_outSize;
72 
73     bool                                          eff_isRunning;
74     EffectMngr::EffectType                        eff_curEffect;
75 
76     int                                           eff_step;
77     int                                           eff_imgFrames;
78 
79 public:
80 
81     void registerEffects();
82 
83     EffectMngr::EffectType getRandomEffect() const;
84 
85 private:
86 
87     /**
88      * Internal functions to render an effect frame.
89      * The effect movement must be adjusted accordingly with amount of image frames to encode.
90      * aInit is to true when effect is initialized (first call).
91      * The integer value is a tempo in ms to wait between frames,
92      * or -1 if the effect is completed.
93      */
94 
95     int effectNone(bool aInit);
96     int effectRandom(bool aInit);
97     int effectKenBurnsZoomIn(bool aInit);
98     int effectKenBurnsZoomOut(bool aInit);
99     int effectKenBurnsPanLR(bool aInit);
100     int effectKenBurnsPanRL(bool aInit);
101     int effectKenBurnsPanTB(bool aInit);
102     int effectKenBurnsPanBT(bool aInit);
103 
104     void updateCurrentFrame(const QRectF& area);
105 };
106 
107 } // namespace Digikam
108 
109 #endif // DIGIKAM_EFFECT_MNGR_PRIVATE_H
110