summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-08-05 03:06:22 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-08-05 03:06:22 +0800
commit65ac0ee2724acc68cc5dd6101b06a4ebc779d3aa (patch)
tree31f38cfd489de9a98dfce6ab9af40de8178c59e2
parentbefecf7fdbf3172bd3315498a331f612cb35e19b (diff)
downloadhoverfx-65ac0ee2724acc68cc5dd6101b06a4ebc779d3aa.tar.gz
hoverfx-65ac0ee2724acc68cc5dd6101b06a4ebc779d3aa.tar.bz2
Add the beginning of a "levels" mode, currently broken
-rw-r--r--hoverfx.xml.in30
-rw-r--r--src/hoverfx.cpp86
2 files changed, 92 insertions, 24 deletions
diff --git a/hoverfx.xml.in b/hoverfx.xml.in
index e7efdc8..5555df6 100644
--- a/hoverfx.xml.in
+++ b/hoverfx.xml.in
@@ -1,5 +1,7 @@
<compiz>
<plugin name="hoverfx" useBcop="true">
+ <_short>Hover Effects</_short>
+ <_long>Window effects on hover</_long>
<deps>
<requirement>
<plugin>opengl</plugin>
@@ -16,6 +18,10 @@
<value>0</value>
<_name>Scale</_name>
</desc>
+ <desc>
+ <value>1</value>
+ <_name>Levels</_name>
+ </desc>
</option>
<subgroup>
<_short>Scale</_short>
@@ -27,6 +33,30 @@
<default>1.1</default>
</option>
</subgroup>
+ <subgroup>
+ <_short>Levels</_short>
+ <option name="brightness" type="int">
+ <_short>Brightness</_short>
+ <_long>Brightness of faded windows</_long>
+ <default>30</default>
+ <min>1</min>
+ <max>100</max>
+ </option>
+ <option name="saturation" type="int">
+ <_short>Saturation</_short>
+ <_long>Saturation of faded windows</_long>
+ <default>50</default>
+ <min>0</min>
+ <max>100</max>
+ </option>
+ <option name="opacity" type="int">
+ <_short>Opacity</_short>
+ <_long>Opacity of faded windows</_long>
+ <default>100</default>
+ <min>1</min>
+ <max>100</max>
+ </option>
+ </subgroup>
<option name="time" type="int">
<_short>Animation time</_short>
<_long>How long the animation should run for (ms)</_long>
diff --git a/src/hoverfx.cpp b/src/hoverfx.cpp
index e7b20a6..493ada2 100644
--- a/src/hoverfx.cpp
+++ b/src/hoverfx.cpp
@@ -60,9 +60,17 @@ HoverScreen::handleEvent (XEvent *event)
if (w && HoverWindow::get (w)->shouldAnimate () && HoverWindow::get (w)->mIsHovered)
{
HOVER_WINDOW (w);
-
- hw->mOld = hw->mCurrent;
- hw->mTarget = 1.0f;
+
+ if (optionGetEffectType () == HoverfxOptions::EffectTypeScale)
+ {
+ hw->mOld = hw->mCurrent;
+ hw->mTarget = 1.0f;
+ }
+ else if (optionGetEffectType () == HoverfxOptions::EffectTypeLevels)
+ {
+ hw->mOld = hw->mCurrent;
+ hw->mTarget = 0.0f;
+ }
hw->mAnimate = true;
hw->toggleFunctions (true);
hw->cWindow->addDamage ();
@@ -79,8 +87,16 @@ HoverScreen::handleEvent (XEvent *event)
HOVER_WINDOW (w);
hw->mAnimate = true;
- hw->mOld = hw->mCurrent;
- hw->mTarget = optionGetScaleFactor ();
+ if (optionGetEffectType () == HoverfxOptions::EffectTypeScale)
+ {
+ hw->mOld = hw->mCurrent;
+ hw->mTarget = optionGetScaleFactor ();
+ }
+ else if (optionGetEffectType () == HoverfxOptions::EffectTypeLevels)
+ {
+ hw->mOld = hw->mCurrent;
+ hw->mTarget = 1.0f;
+ }
hw->mIsHovered = true;
mHoveredWindows.push_back (w);
hw->toggleFunctions (true);
@@ -99,8 +115,16 @@ HoverScreen::handleEvent (XEvent *event)
HOVER_WINDOW (w);
hw->mAnimate = true;
- hw->mOld = hw->mCurrent;
- hw->mTarget = 1.0f;
+ if (optionGetEffectType () == HoverfxOptions::EffectTypeScale)
+ {
+ hw->mOld = hw->mCurrent;
+ hw->mTarget = 1.0f;
+ }
+ else if (optionGetEffectType () == HoverfxOptions::EffectTypeLevels)
+ {
+ hw->mOld = hw->mCurrent;
+ hw->mTarget = 1.0f;
+ }
hw->toggleFunctions (true);
hw->mIsHovered = false;
@@ -139,7 +163,7 @@ HoverScreen::preparePaint (int ms)
hw->mCurrent += steps * (hw->mTarget - hw->mCurrent);
if (fabsf (hw->mTarget - hw->mCurrent) < 0.005)
{
- hw->mAnimate = false;
+ hw->mAnimate = false;
hw->mCurrent = hw->mTarget;
}
if (hw->mCurrent == 1.0f)
@@ -162,7 +186,7 @@ HoverScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
CompOutput *output,
unsigned int mask)
{
- if (mHoveredWindows.size ())
+ if (mHoveredWindows.size () && optionGetEffectType () == HoverfxOptions::EffectTypeScale)
mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
return gScreen->glPaintOutput (attrib, transform, region, output, mask);
@@ -175,23 +199,37 @@ HoverWindow::glPaint (const GLWindowPaintAttrib &attrib,
const CompRegion &region,
unsigned int mask)
{
+ HOVER_SCREEN (screen);
+
if (mIsHovered || mAnimate)
{
- GLMatrix wTransform (transform);
- GLWindowPaintAttrib wAttrib (attrib);
-
- wTransform.translate (window->inputRect ().centerX (),
- window->inputRect ().centerY (),
- 0.0f);
- wTransform.scale (mCurrent, mCurrent, 1.0f);
- wTransform.translate (-window->inputRect ().centerX (),
- -window->inputRect ().centerY (),
- 0.0f);
-
- mask |= PAINT_WINDOW_TRANSFORMED_MASK;
-
-
- return gWindow->glPaint (attrib, wTransform, region, mask);
+ if (hs->optionGetEffectType () == HoverfxOptions::EffectTypeScale)
+ {
+ GLMatrix wTransform (transform);
+ GLWindowPaintAttrib wAttrib (attrib);
+
+ wTransform.translate (window->inputRect ().centerX (),
+ window->inputRect ().centerY (),
+ 0.0f);
+ wTransform.scale (mCurrent, mCurrent, 1.0f);
+ wTransform.translate (-window->inputRect ().centerX (),
+ -window->inputRect ().centerY (),
+ 0.0f);
+
+ mask |= PAINT_WINDOW_TRANSFORMED_MASK;
+
+ return gWindow->glPaint (attrib, wTransform, region, mask);
+ }
+ else if (hs->optionGetEffectType () == HoverfxOptions::EffectTypeLevels)
+ {
+ GLWindowPaintAttrib wAttrib (attrib);
+
+ wAttrib.brightness -= mCurrent * ((float) (100 - hs->optionGetBrightness ()) / (float) 100) * BRIGHT;
+ wAttrib.opacity -= mCurrent * ((float) (100 - hs->optionGetOpacity ()) / (float) 100) * OPAQUE;
+ wAttrib.saturation -= mCurrent * ((float) (100 - hs->optionGetSaturation ()) / (float) 100) * COLOR; wAttrib.saturation, wAttrib.opacity);
+
+ return gWindow->glPaint (wAttrib, transform, region, mask);
+ }
}
return gWindow->glPaint (attrib, transform, region, mask);