Changeset View
Changeset View
Standalone View
Standalone View
effects/scale/scale.h
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | ||||
3 | This file is part of the KDE project. | ||||
4 | | ||||
5 | Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
6 | | ||||
7 | This program is free software; you can redistribute it and/or modify | ||||
8 | it under the terms of the GNU General Public License as published by | ||||
9 | the Free Software Foundation; either version 2 of the License, or | ||||
10 | (at your option) any later version. | ||||
11 | | ||||
12 | This program is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | GNU General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU General Public License | ||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | *********************************************************************/ | ||||
20 | | ||||
21 | #ifndef KWIN_SCALE_H | ||||
22 | #define KWIN_SCALE_H | ||||
23 | | ||||
24 | // kwineffects | ||||
25 | #include <kwineffects.h> | ||||
26 | | ||||
27 | namespace KWin | ||||
28 | { | ||||
29 | | ||||
30 | class ScaleEffect : public Effect | ||||
31 | { | ||||
32 | Q_OBJECT | ||||
33 | Q_PROPERTY(int duration READ duration) | ||||
34 | Q_PROPERTY(qreal inScale READ inScale) | ||||
35 | Q_PROPERTY(qreal inOpacity READ inOpacity) | ||||
36 | Q_PROPERTY(qreal outScale READ outScale) | ||||
37 | Q_PROPERTY(qreal outOpacity READ outOpacity) | ||||
38 | | ||||
39 | public: | ||||
40 | ScaleEffect(); | ||||
41 | ~ScaleEffect() override; | ||||
42 | | ||||
43 | void reconfigure(ReconfigureFlags flags) override; | ||||
44 | | ||||
45 | void prePaintScreen(ScreenPrePaintData &data, int time) override; | ||||
46 | void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override; | ||||
47 | void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; | ||||
48 | void postPaintScreen() override; | ||||
49 | | ||||
50 | bool isActive() const override; | ||||
51 | int requestedEffectChainPosition() const override; | ||||
52 | | ||||
53 | static bool supported(); | ||||
54 | | ||||
55 | int duration() const; | ||||
56 | qreal inScale() const; | ||||
57 | qreal inOpacity() const; | ||||
58 | qreal outScale() const; | ||||
59 | qreal outOpacity() const; | ||||
60 | | ||||
61 | private Q_SLOTS: | ||||
62 | void windowAdded(EffectWindow *w); | ||||
63 | void windowClosed(EffectWindow *w); | ||||
64 | void windowDeleted(EffectWindow *w); | ||||
65 | void windowDataChanged(EffectWindow *w, int role); | ||||
66 | | ||||
67 | private: | ||||
68 | bool isScaleWindow(EffectWindow *w) const; | ||||
69 | | ||||
70 | std::chrono::milliseconds m_duration; | ||||
71 | QHash<EffectWindow*, TimeLine> m_animations; | ||||
72 | | ||||
73 | struct ScaleParams { | ||||
74 | struct { | ||||
75 | qreal from; | ||||
76 | qreal to; | ||||
77 | } scale, opacity; | ||||
78 | }; | ||||
79 | | ||||
80 | ScaleParams m_inParams; | ||||
81 | ScaleParams m_outParams; | ||||
82 | }; | ||||
83 | | ||||
84 | inline int ScaleEffect::requestedEffectChainPosition() const | ||||
85 | { | ||||
86 | return 50; | ||||
87 | } | ||||
88 | | ||||
89 | inline int ScaleEffect::duration() const | ||||
90 | { | ||||
91 | return m_duration.count(); | ||||
92 | } | ||||
93 | | ||||
94 | inline qreal ScaleEffect::inScale() const | ||||
95 | { | ||||
96 | return m_inParams.scale.from; | ||||
97 | } | ||||
98 | | ||||
99 | inline qreal ScaleEffect::inOpacity() const | ||||
100 | { | ||||
101 | return m_inParams.opacity.from; | ||||
102 | } | ||||
103 | | ||||
104 | inline qreal ScaleEffect::outScale() const | ||||
105 | { | ||||
106 | return m_outParams.scale.to; | ||||
107 | } | ||||
108 | | ||||
109 | inline qreal ScaleEffect::outOpacity() const | ||||
110 | { | ||||
111 | return m_outParams.opacity.to; | ||||
112 | } | ||||
113 | | ||||
114 | } // namespace KWin | ||||
115 | | ||||
116 | #endif |