2009-10-15 21:36:38 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, 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 Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file This file contains the definition for the Fade effect.
|
|
|
|
*/
|
|
|
|
|
2009-12-27 23:16:11 +01:00
|
|
|
#ifndef PLASMA_ANIMATIONS_FADE_P_H
|
|
|
|
#define PLASMA_ANIMATIONS_FADE_P_H
|
2009-10-15 21:36:38 +02:00
|
|
|
|
2010-04-08 19:07:33 +02:00
|
|
|
#include <plasma/animations/easinganimation_p.h>
|
2009-10-15 21:36:38 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class Fade plasma/animations/fade.h
|
|
|
|
* @short Fade effect
|
2009-10-20 20:40:34 +02:00
|
|
|
*
|
2009-12-09 18:56:40 +01:00
|
|
|
* Effect that slowly transforms the opacity of the object from a starting
|
|
|
|
* value to a target value. The range is 0 (full translucent) to 1 (full
|
|
|
|
* opaque).
|
2009-10-15 21:36:38 +02:00
|
|
|
*/
|
2010-04-08 19:07:33 +02:00
|
|
|
class FadeAnimation : public EasingAnimation
|
2009-10-15 21:36:38 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2009-10-22 19:39:43 +02:00
|
|
|
Q_PROPERTY(qreal startOpacity READ startOpacity WRITE setStartOpacity)
|
|
|
|
Q_PROPERTY(qreal targetOpacity READ targetOpacity WRITE setTargetOpacity)
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
public:
|
2009-12-09 18:56:40 +01:00
|
|
|
/** Default constructor */
|
2010-01-12 23:24:58 +01:00
|
|
|
explicit FadeAnimation(QObject *parent = 0);
|
|
|
|
|
2009-12-09 18:56:40 +01:00
|
|
|
/** Destructor */
|
2009-10-21 18:29:00 +02:00
|
|
|
virtual ~FadeAnimation();
|
|
|
|
|
2009-12-09 18:56:40 +01:00
|
|
|
/**
|
|
|
|
* Access start opacity of the target widget.
|
|
|
|
*
|
|
|
|
* You can set both a start and an end opacity for an widget when
|
|
|
|
* using this animation class. See \ref setStartOpacity.
|
|
|
|
* @return The opacity (range is 0 to 1).
|
|
|
|
*/
|
2009-10-22 19:39:43 +02:00
|
|
|
qreal startOpacity() const;
|
2009-12-09 18:56:40 +01:00
|
|
|
/**
|
|
|
|
* Set the start opacity of the target widget.
|
|
|
|
*
|
|
|
|
* See also \ref targetOpacity.
|
|
|
|
* @param qreal The opacity (range is 0 to 1).
|
|
|
|
*/
|
2009-10-22 19:39:43 +02:00
|
|
|
void setStartOpacity(qreal);
|
|
|
|
|
2009-12-09 18:56:40 +01:00
|
|
|
/**
|
|
|
|
* Access final opacity of the target widget.
|
|
|
|
*
|
|
|
|
* You can set both a start and an end opacity for an widget when
|
|
|
|
* using this animation class. See \ref setTargetOpacity.
|
|
|
|
* @return The opacity (range is 0 to 1).
|
|
|
|
*/
|
2009-10-22 19:39:43 +02:00
|
|
|
qreal targetOpacity() const;
|
2009-12-09 18:56:40 +01:00
|
|
|
/**
|
|
|
|
* Set the final opacity of the target widget.
|
|
|
|
*
|
|
|
|
* See also \ref startOpacity.
|
|
|
|
* @param qreal The opacity (range is 0 to 1).
|
|
|
|
*/
|
2009-10-22 19:39:43 +02:00
|
|
|
void setTargetOpacity(qreal);
|
2009-10-22 06:34:03 +02:00
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
protected:
|
2009-12-04 20:06:01 +01:00
|
|
|
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
|
2010-04-08 19:07:33 +02:00
|
|
|
void updateEffectiveTime(int currentTime);
|
2009-10-15 21:36:38 +02:00
|
|
|
|
2009-10-20 23:04:49 +02:00
|
|
|
private:
|
2009-12-09 18:56:40 +01:00
|
|
|
/** Initial opacity */
|
2009-10-22 19:39:43 +02:00
|
|
|
qreal m_startOpacity;
|
2009-12-09 18:56:40 +01:00
|
|
|
/** Final opacity */
|
2009-10-22 19:39:43 +02:00
|
|
|
qreal m_targetOpacity;
|
2009-10-15 21:36:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-12-27 23:16:11 +01:00
|
|
|
#endif // PLASMA_ANIMATIONS_FADE_P_H
|