[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Plasma::Phase proposal
From:       "Andre Magalhaes" <andrunko () gmail ! com>
Date:       2008-01-30 18:12:45
Message-ID: 7b3e4da90801301012j611c6062n9519e8ce09657538 () mail ! gmail ! com
[Download RAW message or body]

Hi all,

After analyzing bug 156844, I saw that Plasma::Phase is still missing
some features,
and I want to improve it, but before I start coding I would like to
know what do you think
about the proposed changes.

First let me explain the problem with bug 156844:
In order to animate the background change (slideshow, ...) I used
Plasma::Phase with
ElementAppear/Disappear animations. The problem is that even when the
animation was finished,
I was still painting using elementAnimationResult as the animation ids
where != 0.
So I tried to connect the signal Plasma::Phase::animationComplete in
order to zero the ids and then
paint the background mormally, but I found that animationComplete
wasn't been emitted for
element animations.

Proposal:
- All animations (Item, Movement, Element, Custom) will return an animation id
- All animations can be stopped using the given id
- All animations will receive animationComplete signal when completed
and the id as argument of the signal

This way, when an animation is finished you can for eg. stop using
elementAnimationResult in case you are using
Element animations, and also you will have a common interface between
all types of animation.

Attached there is a modified phase.h that is not BC, and I would like
to see the comments
If you approve I will implement the necessary changes

BR

-- 
Andre Moreira Magalhaes (andrunko)
--------------------------------------------------------
Jabber: andrunko@gmail.com
MSN:   andremoreira@msn.com
Skype:  andrunko
Blog:    http://andrunko.blogspot.com

["phase.h" (text/x-chdr)]

/*
 * Copyright 2007 Aaron Seigo <aseigo@kde.org>
 *           2007 Alexis Ménard <darktears31@gmail.com>
 *           2008 Andre Moreira Magalhaes <andrunko@gmail.com>
 *
 * 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.
 */

#ifndef PHASE_H
#define PHASE_H

#include <QtGui/QImage>
#include <QtCore/QObject>

#include <plasma/plasma_export.h>

class QGraphicsItem;
class QTimeLine;

namespace Plasma
{

/**
 * @short A system for applying effects to Plasma elements
 */
class PLASMA_EXPORT Phase : public QObject
{
    Q_OBJECT
    Q_ENUMS(ItemAnimation)
    Q_ENUMS(ElementAnimation)
    Q_ENUMS(MovementAnimation)
    Q_ENUMS(CurveShape)

public:
    enum ItemAnimation
    {
        Appear = 0 /*<< When some appears in the Corona */,
        Disappear  /*<< When something is about to disappear */,
        Activate   /*<< When something is activated or launched, such as an app icon \
being clicked */  };

    enum ElementAnimation
    {
        ElementAppear = 0 /*<< Animate the appearance of an element */,
        ElementDisappear  /*<< Animate the disappearance of an element */
    };

    enum MovementAnimation
    {
        SlideIn = 0,
        SlideOut,
        FastSlideIn,
        FastSlideOut
    };

    enum CurveShape
    {
        EaseInCurve = 0,
        EaseOutCurve,
        EaseInOutCurve,
        LinearCurve
    };

    typedef int AnimId;

    /**
     * Singleton accessor
     **/
    static Phase* self();

    explicit Phase(QObject * parent = 0);
    ~Phase();

    Q_INVOKABLE AnimId addItemAnimation(QGraphicsItem* item, ItemAnimation anim);
    Q_INVOKABLE AnimId addMovementAnimation(QGraphicsItem* item, MovementAnimation \
anim, const QPoint &destination);  Q_INVOKABLE AnimId \
addElementAnimation(QGraphicsItem* item, ElementAnimation anim, const QPixmap \
&pixmap);  Q_INVOKABLE QPixmap elementAnimationResult(AnimId id);

    /**
     * Starts a custom animation, preventing the need to create a timeline
     * with its own timer tick.
     *
     * @arg frames the number of frames this animation should persist for
     * @arg duration the length, in milliseconds, the animation will take
     * @arg curve the curve applied to the frame rate
     * @arg receive the object that will handle the actual animation
     * @arg method the method name of slot to be invoked on each update.
     *             It must take a qreal. So if the slot is animate(qreal),
     *             pass in "animate" as the method parameter.
     *
     * @return an id that can be used to identify this animation.
     */
    Q_INVOKABLE AnimId addCustomAnimation(int frames, int duration, Phase::CurveShape \
                curve,
                                          QObject* receiver, const char* method);

    /**
     * Stops an animation. Note that it is not necessary to call
     * this on object destruction, as animations associated with
     * a given QObject are cleaned up automatically on destruction.
     *
     * @arg id the id of the animation
     */
    Q_INVOKABLE void stopAnimation(AnimId id);

    /**
     * Whether an animation is running.
     *
     * @arg id the id of the animation
     */
    Q_INVOKABLE bool animationRunning(AnimId id) const;

Q_SIGNALS:
    void animationComplete(QGraphicsItem *item, Plasma::Phase::AnimId id);

protected:
    void timerEvent(QTimerEvent *event);

protected Q_SLOTS:
    void appletDestroyed(QObject*);
    void customAnimReceiverDestroyed(QObject*);

private:
    void init();

    class Private;
    Private * const d;
};

} // namespace Plasma

#endif



_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic