~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/effects/cube/cube.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
 Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.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_CUBE_H
 
22
#define KWIN_CUBE_H
 
23
 
 
24
#include <kwineffects.h>
 
25
#include <kwinglutils.h>
 
26
#include <kshortcut.h>
 
27
#include <QObject>
 
28
#include <QQueue>
 
29
#include <QMatrix4x4>
 
30
#include <QTimeLine>
 
31
#include "cube_inside.h"
 
32
#include "cube_proxy.h"
 
33
 
 
34
namespace KWin
 
35
{
 
36
 
 
37
class CubeEffect
 
38
    : public Effect
 
39
{
 
40
    Q_OBJECT
 
41
public:
 
42
    CubeEffect();
 
43
    ~CubeEffect();
 
44
    virtual void reconfigure(ReconfigureFlags);
 
45
    virtual void prePaintScreen(ScreenPrePaintData& data, int time);
 
46
    virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data);
 
47
    virtual void postPaintScreen();
 
48
    virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time);
 
49
    virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data);
 
50
    virtual bool borderActivated(ElectricBorder border);
 
51
    virtual void grabbedKeyboardEvent(QKeyEvent* e);
 
52
    virtual void windowInputMouseEvent(Window w, QEvent* e);
 
53
 
 
54
    // proxy functions
 
55
    virtual void* proxy();
 
56
    void registerCubeInsideEffect(CubeInsideEffect* effect);
 
57
    void unregisterCubeInsideEffect(CubeInsideEffect* effect);
 
58
 
 
59
    static bool supported();
 
60
private slots:
 
61
    void toggleCube();
 
62
    void toggleCylinder();
 
63
    void toggleSphere();
 
64
    // slots for global shortcut changed
 
65
    // needed to toggle the effect
 
66
    void cubeShortcutChanged(const QKeySequence& seq);
 
67
    void cylinderShortcutChanged(const QKeySequence& seq);
 
68
    void sphereShortcutChanged(const QKeySequence& seq);
 
69
    void slotTabBoxAdded(int mode);
 
70
    void slotTabBoxUpdated();
 
71
    void slotTabBoxClosed();
 
72
    void slotMouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons,
 
73
                              Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
 
74
private:
 
75
    enum RotationDirection {
 
76
        Left,
 
77
        Right,
 
78
        Upwards,
 
79
        Downwards
 
80
    };
 
81
    enum VerticalRotationPosition {
 
82
        Up,
 
83
        Normal,
 
84
        Down
 
85
    };
 
86
    enum CubeMode {
 
87
        Cube,
 
88
        Cylinder,
 
89
        Sphere
 
90
    };
 
91
    void toggle(CubeMode newMode = Cube);
 
92
    void paintCube(int mask, QRegion region, ScreenPaintData& data);
 
93
    void paintCap(bool frontFirst, float zOffset);
 
94
    void paintCubeCap();
 
95
    void paintCylinderCap();
 
96
    void paintSphereCap();
 
97
    bool loadShader();
 
98
    void loadConfig(QString config);
 
99
    void rotateCube();
 
100
    void rotateToDesktop(int desktop);
 
101
    void setActive(bool active);
 
102
    bool activated;
 
103
    bool mousePolling;
 
104
    bool cube_painting;
 
105
    bool keyboard_grab;
 
106
    bool schedule_close;
 
107
    QList<ElectricBorder> borderActivate;
 
108
    QList<ElectricBorder> borderActivateCylinder;
 
109
    QList<ElectricBorder> borderActivateSphere;
 
110
    int painting_desktop;
 
111
    Window input;
 
112
    int frontDesktop;
 
113
    float cubeOpacity;
 
114
    bool opacityDesktopOnly;
 
115
    bool displayDesktopName;
 
116
    EffectFrame* desktopNameFrame;
 
117
    QFont desktopNameFont;
 
118
    bool reflection;
 
119
    bool rotating;
 
120
    bool verticalRotating;
 
121
    bool desktopChangedWhileRotating;
 
122
    bool paintCaps;
 
123
    QTimeLine timeLine;
 
124
    QTimeLine verticalTimeLine;
 
125
    RotationDirection rotationDirection;
 
126
    RotationDirection verticalRotationDirection;
 
127
    VerticalRotationPosition verticalPosition;
 
128
    QQueue<RotationDirection> rotations;
 
129
    QQueue<RotationDirection> verticalRotations;
 
130
    QColor backgroundColor;
 
131
    QColor capColor;
 
132
    GLTexture* wallpaper;
 
133
    bool texturedCaps;
 
134
    GLTexture* capTexture;
 
135
    float manualAngle;
 
136
    float manualVerticalAngle;
 
137
    QTimeLine::CurveShape currentShape;
 
138
    bool start;
 
139
    bool stop;
 
140
    bool reflectionPainting;
 
141
    int rotationDuration;
 
142
    int activeScreen;
 
143
    bool bottomCap;
 
144
    bool closeOnMouseRelease;
 
145
    float zoom;
 
146
    float zPosition;
 
147
    bool useForTabBox;
 
148
    bool invertKeys;
 
149
    bool invertMouse;
 
150
    bool tabBoxMode;
 
151
    bool shortcutsRegistered;
 
152
    CubeMode mode;
 
153
    bool useShaders;
 
154
    GLShader* cylinderShader;
 
155
    GLShader* sphereShader;
 
156
    GLShader* m_reflectionShader;
 
157
    GLShader* m_capShader;
 
158
    float capDeformationFactor;
 
159
    bool useZOrdering;
 
160
    float zOrderingFactor;
 
161
    bool useList;
 
162
    // needed for reflection
 
163
    float mAddedHeightCoeff1;
 
164
    float mAddedHeightCoeff2;
 
165
 
 
166
    QMatrix4x4 m_rotationMatrix;
 
167
    QMatrix4x4 m_reflectionMatrix;
 
168
    QMatrix4x4 m_textureMirrorMatrix;
 
169
    GLVertexBuffer *m_cubeCapBuffer;
 
170
 
 
171
    // Shortcuts - needed to toggle the effect
 
172
    KShortcut cubeShortcut;
 
173
    KShortcut cylinderShortcut;
 
174
    KShortcut sphereShortcut;
 
175
 
 
176
    // proxy
 
177
    CubeEffectProxy m_proxy;
 
178
    QList< CubeInsideEffect* > m_cubeInsideEffects;
 
179
};
 
180
 
 
181
} // namespace
 
182
 
 
183
#endif