From 0d43c491604554f5f00e558a907b4050d9fb387f Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Fri, 6 Aug 2010 22:01:07 +0800 Subject: Remove "levels" and add "opacity", "brightness", and "saturation" --- hoverfx.xml.in | 12 ++++++++++-- src/hoverfx.cpp | 51 ++++++++++++++++++++++++++++++++++++++++----------- src/hoverfx.h | 1 + 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/hoverfx.xml.in b/hoverfx.xml.in index 5555df6..722a0b4 100644 --- a/hoverfx.xml.in +++ b/hoverfx.xml.in @@ -12,7 +12,7 @@ <_short>Effect Type <_long>What effect to use on hover 0 - 2 + 3 0 0 @@ -20,7 +20,15 @@ 1 - <_name>Levels + <_name>Opacity + + + 2 + <_name>Brightness + + + 3 + <_name>Saturation diff --git a/src/hoverfx.cpp b/src/hoverfx.cpp index 401aa6e..b8fbd95 100644 --- a/src/hoverfx.cpp +++ b/src/hoverfx.cpp @@ -66,10 +66,12 @@ HoverScreen::handleEvent (XEvent *event) hw->mOld = hw->mCurrent; hw->mTarget = 1.0f; } - else if (optionGetEffectType () == HoverfxOptions::EffectTypeLevels) + else if (optionGetEffectType () == HoverfxOptions::EffectTypeOpacity || + optionGetEffectType () == HoverfxOptions::EffectTypeBrightness || + optionGetEffectType () == HoverfxOptions::EffectTypeSaturation) { hw->mOld = hw->mCurrent; - hw->mTarget = 0.0f; + hw->mTarget = 100.0f; } hw->mAnimate = true; hw->toggleFunctions (true); @@ -89,13 +91,27 @@ HoverScreen::handleEvent (XEvent *event) hw->mAnimate = true; if (optionGetEffectType () == HoverfxOptions::EffectTypeScale) { + hw->mDefault = 1.0f; hw->mOld = hw->mCurrent; hw->mTarget = optionGetScaleFactor (); } - else if (optionGetEffectType () == HoverfxOptions::EffectTypeLevels) + else if (optionGetEffectType () == HoverfxOptions::EffectTypeOpacity) { + hw->mDefault = 1.0f; hw->mOld = hw->mCurrent; - hw->mTarget = 1.0f; + hw->mTarget = optionGetOpacity (); + } + else if (optionGetEffectType () == HoverfxOptions::EffectTypeBrightness) + { + hw->mDefault = 1.0f; + hw->mOld = hw->mCurrent; + hw->mTarget = optionGetBrightness (); + } + else if (optionGetEffectType () == HoverfxOptions::EffectTypeSaturation) + { + hw->mDefault = 1.0f; + hw->mOld = hw->mCurrent; + hw->mTarget = optionGetSaturation (); } hw->mIsHovered = true; mHoveredWindows.push_back (w); @@ -120,10 +136,12 @@ HoverScreen::handleEvent (XEvent *event) hw->mOld = hw->mCurrent; hw->mTarget = 1.0f; } - else if (optionGetEffectType () == HoverfxOptions::EffectTypeLevels) + else if (optionGetEffectType () == HoverfxOptions::EffectTypeOpacity || + optionGetEffectType () == HoverfxOptions::EffectTypeBrightness || + optionGetEffectType () == HoverfxOptions::EffectTypeSaturation) { hw->mOld = hw->mCurrent; - hw->mTarget = 1.0f; + hw->mTarget = 100.0f; } hw->toggleFunctions (true); hw->mIsHovered = false; @@ -166,7 +184,7 @@ HoverScreen::preparePaint (int ms) hw->mAnimate = false; hw->mCurrent = hw->mTarget; } - if (hw->mCurrent == 1.0f) + if (hw->mCurrent == hw->mDefault) { hw->mAnimate = false; mHoveredWindows.remove (w); @@ -220,13 +238,24 @@ HoverWindow::glPaint (const GLWindowPaintAttrib &attrib, return gWindow->glPaint (attrib, wTransform, region, mask); } - else if (hs->optionGetEffectType () == HoverfxOptions::EffectTypeLevels) + else if (hs->optionGetEffectType () == HoverfxOptions::EffectTypeOpacity) { GLWindowPaintAttrib wAttrib (attrib); + wAttrib.opacity = (float) (mCurrent * OPAQUE) / 100; - 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; + return gWindow->glPaint (wAttrib, transform, region, mask); + } + else if (hs->optionGetEffectType () == HoverfxOptions::EffectTypeBrightness) + { + GLWindowPaintAttrib wAttrib (attrib); + wAttrib.brightness = (float) (mCurrent * BRIGHT) / 100; + + return gWindow->glPaint (wAttrib, transform, region, mask); + } + else if (hs->optionGetEffectType () == HoverfxOptions::EffectTypeSaturation) + { + GLWindowPaintAttrib wAttrib (attrib); + wAttrib.saturation = (float) (mCurrent * COLOR) / 100; return gWindow->glPaint (wAttrib, transform, region, mask); } diff --git a/src/hoverfx.h b/src/hoverfx.h index 6e216ab..a2ac065 100644 --- a/src/hoverfx.h +++ b/src/hoverfx.h @@ -62,6 +62,7 @@ class HoverWindow : bool mIsHovered; bool mAnimate; + float mDefault; float mOld; float mCurrent; float mTarget; -- cgit v1.1