Move Cube effect to trunk
svn path=/trunk/KDE/kdebase/workspace/; revision=832912
This commit is contained in:
parent
8fa675350b
commit
89c2ad7c4b
12 changed files with 2154 additions and 0 deletions
1245
effects/cube.cpp
Normal file
1245
effects/cube.cpp
Normal file
File diff suppressed because it is too large
Load diff
17
effects/cube.desktop
Normal file
17
effects/cube.desktop
Normal file
|
@ -0,0 +1,17 @@
|
|||
[Desktop Entry]
|
||||
Name=Desktop Cube
|
||||
Icon=preferences-system-windows-effect-cube
|
||||
Comment=Map virtual desktops on a cube
|
||||
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KWin/Effect
|
||||
X-KDE-PluginInfo-Author=Martin Gräßlin
|
||||
X-KDE-PluginInfo-Email=ubuntu@martin-graesslin.com
|
||||
X-KDE-PluginInfo-Name=kwin4_effect_cube
|
||||
X-KDE-PluginInfo-Version=0.1.0
|
||||
X-KDE-PluginInfo-Category=Window Management
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=false
|
||||
X-KDE-Library=kwin4_effect_builtins
|
||||
X-KDE-Ordering=50
|
116
effects/cube.h
Normal file
116
effects/cube.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com>
|
||||
|
||||
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_CUBE_H
|
||||
#define KWIN_CUBE_H
|
||||
|
||||
#include <kwineffects.h>
|
||||
#include <kwinglutils.h>
|
||||
#include <QObject>
|
||||
#include <QQueue>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class CubeEffect
|
||||
: public QObject, public Effect
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CubeEffect();
|
||||
~CubeEffect();
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
virtual void postPaintWindow( EffectWindow* w);
|
||||
virtual bool borderActivated( ElectricBorder border );
|
||||
virtual void grabbedKeyboardEvent( QKeyEvent* e );
|
||||
virtual void mouseChanged( const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons,
|
||||
Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers );
|
||||
virtual void desktopChanged( int old );
|
||||
protected slots:
|
||||
void toggle();
|
||||
protected:
|
||||
enum RotationDirection
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Upwards,
|
||||
Downwards
|
||||
};
|
||||
enum VerticalRotationPosition
|
||||
{
|
||||
Up,
|
||||
Normal,
|
||||
Down
|
||||
};
|
||||
void paintScene( int mask, QRegion region, ScreenPaintData& data );
|
||||
void paintCap( float left, float right, float z );
|
||||
void rotateToDesktop( int desktop );
|
||||
void setActive( bool active );
|
||||
bool activated;
|
||||
bool cube_painting;
|
||||
bool keyboard_grab;
|
||||
bool schedule_close;
|
||||
ElectricBorder borderActivate;
|
||||
int painting_desktop;
|
||||
Window input;
|
||||
int frontDesktop;
|
||||
float cubeOpacity;
|
||||
bool displayDesktopName;
|
||||
bool reflection;
|
||||
bool rotating;
|
||||
bool verticalRotating;
|
||||
bool desktopChangedWhileRotating;
|
||||
bool paintCaps;
|
||||
TimeLine timeLine;
|
||||
TimeLine verticalTimeLine;
|
||||
RotationDirection rotationDirection;
|
||||
RotationDirection verticalRotationDirection;
|
||||
VerticalRotationPosition verticalPosition;
|
||||
QQueue<RotationDirection> rotations;
|
||||
QQueue<RotationDirection> verticalRotations;
|
||||
QColor backgroundColor;
|
||||
QColor capColor;
|
||||
GLTexture* wallpaper;
|
||||
float manualAngle;
|
||||
float manualVerticalAngle;
|
||||
TimeLine::CurveShape currentShape;
|
||||
bool start;
|
||||
bool stop;
|
||||
bool reflectionPainting;
|
||||
bool slide;
|
||||
|
||||
// variables for defining the projection matrix
|
||||
float fovy;
|
||||
float aspect;
|
||||
float ymax;
|
||||
float ymin;
|
||||
float xmax;
|
||||
float xmin;
|
||||
float zNear;
|
||||
float zFar;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
197
effects/cube_config.cpp
Normal file
197
effects/cube_config.cpp
Normal file
|
@ -0,0 +1,197 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com>
|
||||
|
||||
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/>.
|
||||
*********************************************************************/
|
||||
#include "cube_config.h"
|
||||
#include <kwineffects.h>
|
||||
|
||||
#include <kconfiggroup.h>
|
||||
#include <kcolorscheme.h>
|
||||
#include <KActionCollection>
|
||||
#include <kaction.h>
|
||||
#include <KGlobalAccel>
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QColor>
|
||||
#ifndef KDE_USE_FINAL
|
||||
KWIN_EFFECT_CONFIG_FACTORY
|
||||
#endif
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
CubeEffectConfigForm::CubeEffectConfigForm(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
CubeEffectConfig::CubeEffectConfig(QWidget* parent, const QVariantList& args) :
|
||||
KCModule(EffectFactory::componentData(), parent, args)
|
||||
{
|
||||
m_ui = new CubeEffectConfigForm(this);
|
||||
|
||||
QGridLayout* layout = new QGridLayout(this);
|
||||
|
||||
layout->addWidget(m_ui, 0, 0);
|
||||
|
||||
m_ui->screenEdgeCombo->addItem(i18n("Top"));
|
||||
m_ui->screenEdgeCombo->addItem(i18n("Top-right"));
|
||||
m_ui->screenEdgeCombo->addItem(i18n("Right"));
|
||||
m_ui->screenEdgeCombo->addItem(i18n("Bottom-right"));
|
||||
m_ui->screenEdgeCombo->addItem(i18n("Bottom"));
|
||||
m_ui->screenEdgeCombo->addItem(i18n("Bottom-left"));
|
||||
m_ui->screenEdgeCombo->addItem(i18n("Left"));
|
||||
m_ui->screenEdgeCombo->addItem(i18n("Top-left"));
|
||||
m_ui->screenEdgeCombo->addItem(i18n("None"));
|
||||
|
||||
m_actionCollection = new KActionCollection( this, componentData() );
|
||||
m_actionCollection->setConfigGroup( "Cube" );
|
||||
m_actionCollection->setConfigGlobal(true);
|
||||
|
||||
KAction* a = (KAction*) m_actionCollection->addAction( "Cube" );
|
||||
a->setText( i18n("Desktop Cube" ));
|
||||
a->setProperty("isConfigurationAction", true);
|
||||
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F11 ));
|
||||
|
||||
m_ui->editor->addCollection(m_actionCollection);
|
||||
|
||||
connect(m_ui->screenEdgeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->rotationDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->cubeOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->cubeOpacitySpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->displayDesktopNameBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->reflectionBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->backgroundColorButton, SIGNAL(changed(QColor)), this, SLOT(changed()));
|
||||
connect(m_ui->cubeCapsBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
||||
connect(m_ui->cubeCapsBox, SIGNAL(stateChanged(int)), this, SLOT(capsSelectionChanged()));
|
||||
connect(m_ui->capColorButton, SIGNAL(changed(QColor)), this, SLOT(changed()));
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
void CubeEffectConfig::load()
|
||||
{
|
||||
KCModule::load();
|
||||
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "Cube" );
|
||||
|
||||
int duration = conf.readEntry( "RotationDuration", 500 );
|
||||
float opacity = conf.readEntry( "Opacity", 80 );
|
||||
bool desktopName = conf.readEntry( "DisplayDesktopName", true );
|
||||
bool reflection = conf.readEntry( "Reflection", true );
|
||||
int activateBorder = conf.readEntry( "BorderActivate", (int)ElectricNone );
|
||||
QColor background = conf.readEntry( "BackgroundColor", QColor( Qt::black ) );
|
||||
QColor capColor = conf.readEntry( "CapColor", KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() );
|
||||
bool caps = conf.readEntry( "Caps", true );
|
||||
if( activateBorder == (int)ElectricNone )
|
||||
activateBorder--;
|
||||
m_ui->screenEdgeCombo->setCurrentIndex( activateBorder );
|
||||
|
||||
m_ui->rotationDurationSpin->setValue( duration );
|
||||
m_ui->cubeOpacitySlider->setValue( opacity );
|
||||
m_ui->cubeOpacitySpin->setValue( opacity );
|
||||
if( desktopName )
|
||||
{
|
||||
m_ui->displayDesktopNameBox->setCheckState( Qt::Checked );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->displayDesktopNameBox->setCheckState( Qt::Unchecked );
|
||||
}
|
||||
if( reflection )
|
||||
{
|
||||
m_ui->reflectionBox->setCheckState( Qt::Checked );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->reflectionBox->setCheckState( Qt::Unchecked );
|
||||
}
|
||||
if( caps )
|
||||
{
|
||||
m_ui->cubeCapsBox->setCheckState( Qt::Checked );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->cubeCapsBox->setCheckState( Qt::Unchecked );
|
||||
}
|
||||
m_ui->backgroundColorButton->setColor( background );
|
||||
m_ui->capColorButton->setColor( capColor );
|
||||
capsSelectionChanged();
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
void CubeEffectConfig::save()
|
||||
{
|
||||
KConfigGroup conf = EffectsHandler::effectConfig( "Cube" );
|
||||
|
||||
conf.writeEntry( "RotationDuration", m_ui->rotationDurationSpin->value() );
|
||||
conf.writeEntry( "DisplayDesktopName", m_ui->displayDesktopNameBox->checkState() == Qt::Checked ? true : false );
|
||||
conf.writeEntry( "Reflection", m_ui->reflectionBox->checkState() == Qt::Checked ? true : false );
|
||||
conf.writeEntry( "Opacity", m_ui->cubeOpacitySpin->value() );
|
||||
conf.writeEntry( "BackgroundColor", m_ui->backgroundColorButton->color() );
|
||||
conf.writeEntry( "Caps", m_ui->cubeCapsBox->checkState() == Qt::Checked ? true : false );
|
||||
conf.writeEntry( "CapColor", m_ui->capColorButton->color() );
|
||||
|
||||
int activateBorder = m_ui->screenEdgeCombo->currentIndex();
|
||||
if( activateBorder == (int)ELECTRIC_COUNT )
|
||||
activateBorder = (int)ElectricNone;
|
||||
conf.writeEntry( "BorderActivate", activateBorder );
|
||||
|
||||
m_ui->editor->save();
|
||||
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
EffectsHandler::sendReloadMessage( "cube" );
|
||||
}
|
||||
|
||||
void CubeEffectConfig::defaults()
|
||||
{
|
||||
m_ui->rotationDurationSpin->setValue( 500 );
|
||||
m_ui->displayDesktopNameBox->setCheckState( Qt::Checked );
|
||||
m_ui->reflectionBox->setCheckState( Qt::Checked );
|
||||
m_ui->cubeOpacitySpin->setValue( 80 );
|
||||
m_ui->cubeOpacitySlider->setValue( 80 );
|
||||
m_ui->screenEdgeCombo->setCurrentIndex( (int)ElectricNone -1 );
|
||||
m_ui->backgroundColorButton->setColor( QColor( Qt::black ) );
|
||||
m_ui->cubeCapsBox->setCheckState( Qt::Checked );
|
||||
m_ui->capColorButton->setColor( KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() );
|
||||
m_ui->editor->allDefault();
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
void CubeEffectConfig::capsSelectionChanged()
|
||||
{
|
||||
if( m_ui->cubeCapsBox->checkState() == Qt::Checked )
|
||||
{
|
||||
// activate cap color
|
||||
m_ui->capColorButton->setEnabled( true );
|
||||
m_ui->capColorLabel->setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
// deactivate cap color
|
||||
m_ui->capColorButton->setEnabled( false );
|
||||
m_ui->capColorLabel->setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "cube_config.moc"
|
9
effects/cube_config.desktop
Normal file
9
effects/cube_config.desktop
Normal file
|
@ -0,0 +1,9 @@
|
|||
[Desktop Entry]
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KCModule
|
||||
|
||||
X-KDE-Library=kcm_kwin4_effect_builtins
|
||||
X-KDE-ParentComponents=kwin4_effect_cube
|
||||
X-KDE-PluginKeyword=cube
|
||||
|
||||
Name=Desktop Cube
|
60
effects/cube_config.h
Normal file
60
effects/cube_config.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com>
|
||||
|
||||
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_CUBE_CONFIG_H
|
||||
#define KWIN_CUBE_CONFIG_H
|
||||
|
||||
#include <kcmodule.h>
|
||||
|
||||
#include "ui_cube_config.h"
|
||||
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class CubeEffectConfigForm : public QWidget, public Ui::CubeEffectConfigForm
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CubeEffectConfigForm(QWidget* parent);
|
||||
};
|
||||
|
||||
class CubeEffectConfig : public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CubeEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
|
||||
|
||||
public slots:
|
||||
virtual void save();
|
||||
virtual void load();
|
||||
virtual void defaults();
|
||||
|
||||
private slots:
|
||||
void capsSelectionChanged();
|
||||
|
||||
private:
|
||||
CubeEffectConfigForm* m_ui;
|
||||
KActionCollection* m_actionCollection;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
249
effects/cube_config.ui
Normal file
249
effects/cube_config.ui
Normal file
|
@ -0,0 +1,249 @@
|
|||
<ui version="4.0" >
|
||||
<class>KWin::CubeEffectConfigForm</class>
|
||||
<widget class="QWidget" name="KWin::CubeEffectConfigForm" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>396</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<string>Appearance</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Rotation &duration:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>rotationDurationSpin</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QSpinBox" name="rotationDurationSpin" >
|
||||
<property name="suffix" >
|
||||
<string> msec</string>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>5000</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>500</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string>Cube &opacity:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>cubeOpacitySpin</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QComboBox" name="screenEdgeCombo" />
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Screen &edge:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>screenEdgeCombo</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" >
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<widget class="QSlider" name="cubeOpacitySlider" >
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep" >
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="tickPosition" >
|
||||
<enum>QSlider::TicksBelow</enum>
|
||||
</property>
|
||||
<property name="tickInterval" >
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string>Fully transparent</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<string>Fully opaque</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="1" >
|
||||
<widget class="QSpinBox" name="cubeOpacitySpin" >
|
||||
<property name="suffix" >
|
||||
<string> %</string>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" >
|
||||
<widget class="QCheckBox" name="displayDesktopNameBox" >
|
||||
<property name="text" >
|
||||
<string>Display desktop &name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" >
|
||||
<widget class="QCheckBox" name="reflectionBox" >
|
||||
<property name="text" >
|
||||
<string>&Reflection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" >
|
||||
<widget class="QLabel" name="label_6" >
|
||||
<property name="text" >
|
||||
<string>&Background Color:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>backgroundColorButton</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1" >
|
||||
<widget class="KColorButton" name="backgroundColorButton" />
|
||||
</item>
|
||||
<item row="10" column="0" >
|
||||
<widget class="QCheckBox" name="cubeCapsBox" >
|
||||
<property name="text" >
|
||||
<string>Cube &Caps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" >
|
||||
<widget class="QLabel" name="capColorLabel" >
|
||||
<property name="text" >
|
||||
<string>C&ap Color:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>capColorButton</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1" >
|
||||
<widget class="KColorButton" name="capColorButton" />
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="KWin::GlobalShortcutsEditor" native="1" name="editor" />
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KColorButton</class>
|
||||
<extends>QPushButton</extends>
|
||||
<header>kcolorbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>KWin::GlobalShortcutsEditor</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global" >kwineffects.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>screenEdgeCombo</tabstop>
|
||||
<tabstop>rotationDurationSpin</tabstop>
|
||||
<tabstop>cubeOpacitySpin</tabstop>
|
||||
<tabstop>cubeOpacitySlider</tabstop>
|
||||
<tabstop>displayDesktopNameBox</tabstop>
|
||||
<tabstop>reflectionBox</tabstop>
|
||||
<tabstop>backgroundColorButton</tabstop>
|
||||
<tabstop>cubeCapsBox</tabstop>
|
||||
<tabstop>capColorButton</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>cubeOpacitySpin</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>cubeOpacitySlider</receiver>
|
||||
<slot>setValue(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>386</x>
|
||||
<y>175</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>235</x>
|
||||
<y>162</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>cubeOpacitySlider</sender>
|
||||
<signal>valueChanged(int)</signal>
|
||||
<receiver>cubeOpacitySpin</receiver>
|
||||
<slot>setValue(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>133</x>
|
||||
<y>162</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>386</x>
|
||||
<y>175</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
123
effects/cylinder.cpp
Normal file
123
effects/cylinder.cpp
Normal file
|
@ -0,0 +1,123 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com>
|
||||
|
||||
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/>.
|
||||
*********************************************************************/
|
||||
#include "cube.h"
|
||||
#include "cylinder.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <KStandardDirs>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
KWIN_EFFECT( cylinder, CylinderEffect )
|
||||
|
||||
CylinderEffect::CylinderEffect()
|
||||
: CubeEffect()
|
||||
, mInited( false )
|
||||
, mValid( true )
|
||||
, mShader( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
CylinderEffect::~CylinderEffect()
|
||||
{
|
||||
delete mShader;
|
||||
}
|
||||
|
||||
bool CylinderEffect::loadData()
|
||||
{
|
||||
mInited = true;
|
||||
QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/cylinder.frag");
|
||||
QString vertexshader = KGlobal::dirs()->findResource("data", "kwin/cylinder.vert");
|
||||
if(fragmentshader.isEmpty() || vertexshader.isEmpty())
|
||||
{
|
||||
kError() << "Couldn't locate shader files" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
mShader = new GLShader(vertexshader, fragmentshader);
|
||||
if(!mShader->isValid())
|
||||
{
|
||||
kError() << "The shader failed to load!" << endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mShader->bind();
|
||||
mShader->setUniform( "winTexture", 0 );
|
||||
mShader->setUniform( "opacity", cubeOpacity );
|
||||
QRect rect = effects->clientArea( FullArea, effects->activeScreen(), effects->currentDesktop());
|
||||
mShader->setUniform( "width", (float)rect.width() );
|
||||
mShader->setUniform( "origWidth", (float) (2.0 * xmax * ( zNear*2+1 + 1.0f * 0.8f ) * tan( fovy * M_PI / 360.0f )/ymax) );
|
||||
mShader->unbind();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void CylinderEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
|
||||
{
|
||||
if( activated )
|
||||
{
|
||||
if( cube_painting )
|
||||
{
|
||||
if( w->isOnDesktop( painting_desktop ))
|
||||
{
|
||||
data.quads = data.quads.makeGrid( 40 );
|
||||
w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP );
|
||||
}
|
||||
else
|
||||
{
|
||||
w->disablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP );
|
||||
}
|
||||
}
|
||||
}
|
||||
effects->prePaintWindow( w, data, time );
|
||||
}
|
||||
|
||||
void CylinderEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
||||
{
|
||||
if( activated && cube_painting )
|
||||
{
|
||||
if( mValid && !mInited )
|
||||
mValid = loadData();
|
||||
bool useShader = mValid;
|
||||
if( useShader )
|
||||
{
|
||||
mShader->bind();
|
||||
mShader->setUniform( "windowWidth", (float)w->width() );
|
||||
mShader->setUniform( "windowHeight", (float)w->height() );
|
||||
mShader->setUniform( "xCoord", (float)w->x() );
|
||||
mShader->setUniform( "cubeAngle", (effects->numberOfDesktops() - 2 )/(float)effects->numberOfDesktops() * 180.0f );
|
||||
data.shader = mShader;
|
||||
}
|
||||
CubeEffect::paintWindow( w, mask, region, data );
|
||||
if( useShader )
|
||||
{
|
||||
mShader->unbind();
|
||||
}
|
||||
}
|
||||
else
|
||||
effects->paintWindow( w, mask, region, data );
|
||||
}
|
||||
|
||||
} // namespace
|
17
effects/cylinder.desktop
Normal file
17
effects/cylinder.desktop
Normal file
|
@ -0,0 +1,17 @@
|
|||
[Desktop Entry]
|
||||
Name=Desktop Cylinder
|
||||
Icon=preferences-system-windows-effect-cylinder
|
||||
Comment=Map virtual desktops on a cylinder
|
||||
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KWin/Effect
|
||||
X-KDE-PluginInfo-Author=Martin Gräßlin
|
||||
X-KDE-PluginInfo-Email=ubuntu@martin-graesslin.com
|
||||
X-KDE-PluginInfo-Name=kwin4_effect_cylinder
|
||||
X-KDE-PluginInfo-Version=0.1.0
|
||||
X-KDE-PluginInfo-Category=Window Management
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=false
|
||||
X-KDE-Library=kwin4_effect_builtins
|
||||
X-KDE-Ordering=50
|
47
effects/cylinder.h
Normal file
47
effects/cylinder.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com>
|
||||
|
||||
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_CYLINDER_H
|
||||
#define KWIN_CYLINDER_H
|
||||
|
||||
#include <kwineffects.h>
|
||||
#include <kwinglutils.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class CylinderEffect
|
||||
: public CubeEffect
|
||||
{
|
||||
public:
|
||||
CylinderEffect();
|
||||
~CylinderEffect();
|
||||
virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
|
||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||
private:
|
||||
bool loadData();
|
||||
bool mInited;
|
||||
bool mValid;
|
||||
GLShader* mShader;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
15
effects/data/cylinder.frag
Normal file
15
effects/data/cylinder.frag
Normal file
|
@ -0,0 +1,15 @@
|
|||
uniform sampler2D winTexture;
|
||||
uniform float windowWidth;
|
||||
uniform float windowHeight;
|
||||
uniform float opacity;
|
||||
|
||||
vec2 pix2tex(vec2 pix)
|
||||
{
|
||||
return vec2(pix.x / windowWidth, pix.y / windowHeight);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor.rgba = texture2D(winTexture, pix2tex(gl_TexCoord[0].xy)).rgba;
|
||||
gl_FragColor.a *= opacity;
|
||||
}
|
59
effects/data/cylinder.vert
Normal file
59
effects/data/cylinder.vert
Normal file
|
@ -0,0 +1,59 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com>
|
||||
|
||||
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/>.
|
||||
*********************************************************************/
|
||||
uniform float width;
|
||||
uniform float cubeAngle;
|
||||
uniform float xCoord;
|
||||
uniform float origWidth;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0].xy = gl_Vertex.xy;
|
||||
vec4 vertex = gl_Vertex.xyzw;
|
||||
float radian = radians(cubeAngle*0.5);
|
||||
// height of the triangle compound of one side of the cube and the two bisecting lines
|
||||
float midpoint = origWidth*0.5*tan(radian);
|
||||
// radius of the circle
|
||||
float radius = (origWidth*0.5)/cos(radian);
|
||||
|
||||
// the calculation does the following:
|
||||
// At every x position we move on to the circle und create a new circular segment
|
||||
// The distance between the new chord and the desktop (z=0) is the wanted z value
|
||||
// The length of the new chord is 2*distance(x,middle of desktop(width*0.5))
|
||||
// Now we calculate the angle between chord and radius as acos(distance/radius)
|
||||
// With this angle we can can calculate the height of the new triangle (radius-distance*2-radius)
|
||||
// The height is the opposite leg of the triangle compound of distance-*height*-radius
|
||||
// New height minus old height (midpoint) is the looked for z-value
|
||||
|
||||
// distance from midpoint of desktop to x coord
|
||||
float distance = width*0.5 - (vertex.x+xCoord);
|
||||
if( (vertex.x+xCoord) > width*0.5 )
|
||||
{
|
||||
distance = (vertex.x+xCoord) - width*0.5;
|
||||
}
|
||||
// distance in correct format
|
||||
distance = distance/(width*0.5)*origWidth*0.5;
|
||||
float angle = acos( distance/radius );
|
||||
float h = radius;
|
||||
// if distance == 0 -> angle=90 -> tan(90) singularity
|
||||
if( distance != 0.0 )
|
||||
h = tan( angle ) * distance;
|
||||
vertex.z = h - midpoint;
|
||||
gl_Position = gl_ModelViewProjectionMatrix * vertex;
|
||||
}
|
Loading…
Reference in a new issue