2008-01-08 15:47:31 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
2008-10-13 03:29:07 +00:00
|
|
|
Copyright (C) 2007 Martin Gräßlin <ubuntu@martin-graesslin.com>
|
|
|
|
Copyright (C) 2008 Torgny Johansson <torgny.johansson@gmail.com>
|
2008-01-08 15:47:31 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef KWIN_SNOW_H
|
|
|
|
#define KWIN_SNOW_H
|
|
|
|
|
|
|
|
#include <kwineffects.h>
|
|
|
|
#include <kwinglutils.h>
|
|
|
|
#include <qobject.h>
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2008-10-13 03:29:07 +00:00
|
|
|
class SnowFlake
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SnowFlake(int x, int y, int width, int height, int maxVSpeed, int maxHSpeed);
|
|
|
|
virtual ~SnowFlake();
|
|
|
|
int getHSpeed();
|
|
|
|
int getVSpeed();
|
|
|
|
float getRotationAngle();
|
2008-11-14 16:18:34 +00:00
|
|
|
float getRotationSpeed();
|
2008-10-13 03:29:07 +00:00
|
|
|
void updateSpeedAndRotation();
|
2008-11-14 16:18:34 +00:00
|
|
|
int addFrame();
|
2008-10-13 03:29:07 +00:00
|
|
|
int getHeight();
|
|
|
|
int getWidth();
|
|
|
|
int getX();
|
|
|
|
int getY();
|
2008-11-14 16:18:34 +00:00
|
|
|
int getFrames();
|
2008-10-13 03:29:07 +00:00
|
|
|
QRect getRect();
|
|
|
|
void setHeight(int height);
|
|
|
|
void setWidth(int width);
|
|
|
|
void setX(int x);
|
|
|
|
void setY(int y);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QRect rect;
|
|
|
|
int vSpeed;
|
|
|
|
int hSpeed;
|
2008-11-14 16:18:34 +00:00
|
|
|
int frameCounter;
|
|
|
|
int maxFrames;
|
2008-10-13 03:29:07 +00:00
|
|
|
float rotationAngle;
|
|
|
|
float rotationSpeed;
|
|
|
|
};
|
|
|
|
|
2008-01-08 15:47:31 +00:00
|
|
|
class SnowEffect
|
|
|
|
: public QObject, public Effect
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
SnowEffect();
|
|
|
|
virtual ~SnowEffect();
|
2008-10-02 09:27:32 +00:00
|
|
|
virtual void reconfigure( ReconfigureFlags );
|
2008-01-08 15:47:31 +00:00
|
|
|
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
|
|
|
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
|
|
|
virtual void postPaintScreen();
|
2008-11-11 11:31:12 +00:00
|
|
|
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
2008-01-08 15:47:31 +00:00
|
|
|
|
2008-12-04 08:47:07 +00:00
|
|
|
static bool supported();
|
2008-01-08 15:47:31 +00:00
|
|
|
private slots:
|
|
|
|
void toggle();
|
|
|
|
private:
|
|
|
|
void loadTexture();
|
2008-11-11 11:31:12 +00:00
|
|
|
void snowing( QRegion& region );
|
2008-11-12 18:38:36 +00:00
|
|
|
bool loadShader();
|
2008-01-08 15:47:31 +00:00
|
|
|
GLTexture* texture;
|
2008-11-14 16:18:34 +00:00
|
|
|
QList<SnowFlake> flakes;
|
2008-01-08 15:47:31 +00:00
|
|
|
long nextFlakeMillis;
|
|
|
|
int mNumberFlakes;
|
|
|
|
int mMinFlakeSize;
|
|
|
|
int mMaxFlakeSize;
|
2008-10-13 03:29:07 +00:00
|
|
|
int mMaxVSpeed;
|
|
|
|
int mMaxHSpeed;
|
2008-01-08 15:47:31 +00:00
|
|
|
bool active;
|
2008-11-11 11:31:12 +00:00
|
|
|
GLuint list;
|
|
|
|
bool snowBehindWindows;
|
2008-11-12 18:38:36 +00:00
|
|
|
GLShader* mShader;
|
|
|
|
bool mInited;
|
|
|
|
bool mUseShader;
|
2008-11-14 16:18:34 +00:00
|
|
|
QRegion repaintRegion;
|
2008-11-30 13:11:11 +00:00
|
|
|
bool hasSnown;
|
2008-01-08 15:47:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|