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

List:       koffice-devel
Subject:    RFC: kpresenter object effects clean up
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2004-04-29 12:22:59
Message-ID: 200404291422.59880.t.zachmann () zagge ! de
[Download RAW message or body]

Hello all,

proposal for cleaning up the object effects. 

Problems of the old implementation:
- effects can not be stopped
- if you are to press two times space very fast it can happen that you get 
race conditions as doObjEffects gets called during it is running, as effects 
are processed within doObjEffects. If this happens the effect is very slow
- there are also some repainting problems with the old implementation

My proposal is to do the single steps of the effects as an event. So it is 
possible to react on other events during the objects effects are active.

I have implemented a prototype which uses events for displaying object 
effects. Up to now I have only implemented the effects appear, come from 
left, disappear and disappear to right, just to show that it works.

If an event (e.g. press space bar) occurs during an object effect the objects 
will be shown on there finial position.

The object effects are all handeld in the new class EffectHandler. 

The patch is tested and works well.

I try only to repaint the part of the screen as it was done before. But this 
is problematic if shadows are used. How expensive is it to bitblt the hole 
screen (seeEffectHandler::doEffect) ? If that is not to expensive I would 
like to do it for the hole screen as it would make the handling mutch easier.

What do you think about my patch. If you think I should go on I will commit 
(with #if around the patch) and go on with implementing all the other 
effects. 

Have a nice day

Thorsten

["effects.diff" (text/x-diff)]

Index: effecthandler.h
===================================================================
RCS file: effecthandler.h
diff -N effecthandler.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ effecthandler.h	29 Apr 2004 11:30:30 -0000
@@ -0,0 +1,183 @@
+#ifndef EFFECTHANDLER_H
+#define EFFECTHANDLER_H
+
+#include <qpixmap.h>
+#include <qptrlist.h>
+#include <qstring.h>
+
+#include "global.h"
+
+class QPaintDevice;
+class KPObject;
+class KPresenterView;
+
+class EffectHandler 
+{
+public:
+  /**
+   * Creates an EffectsHandler for the effect step step and the effect sub step \
subStep. +   * step    the effect step for which the effect should be displayed  
+   * subStep the sub effect step for which the effect should be displayed  
+   * back    set to true if the effect step was reached by going backwards
+   * dst     the paint device on which the Effects will be shown
+   * src     this pixmap holds the pixmap before any effects are started
+   * objects all objects of the page 
+   * view    pointer to the active KPresenterView 
+   */
+  EffectHandler( int step, int subStep, bool back, QPaintDevice *dst, QPixmap *src, \
const QPtrList<KPObject> &objects, KPresenterView *view ); +
+  /**
+   * Delete the EffectHandler.
+   */
+  ~EffectHandler();
+
+  /**
+   * doEffect handle the next step of the object effect. 
+   * Returns true if all effects in the current step are finished.
+   * In automatic presentation mode:
+   * On the first step it stops the automatic presentation timer.
+   * The automatic presentation timer will be restared when all 
+   * effects are done.
+   */
+  bool doEffect();
+
+  /**
+   * Ends the effect for the current step by displaying all objects 
+   * on their final position.
+   * In automatic presentation mode:
+   * Restarts the automatic presentation timer.
+   */
+  void finish();
+protected:
+  /**
+   * Calls the right appear effect method for the object object.
+   * Returns true if the effect for the object is finished.
+   */
+  bool doAppearEffectStep( KPObject *object );
+  
+  /**
+   * Calls the right disappear effect method for the object object.
+   * Returns true if the effect for the object is finished.
+   */
+  bool doDisappearEffectStep( KPObject *object );
+
+  /**
+   * Effect None
+   * The object just appears on its position
+   * Returns allways true as the object is in is final position.
+   */
+  bool appearNone( KPObject *object );
+
+  /**
+   * Effect Come For Left
+   * The object comes in from the left to its position
+   * Returns true if the object is on its final position.
+   */
+  bool appearComeLeft( KPObject *object );
+
+  /**
+   * Effect Disappear To Right
+   * The object moves from it's position to the rigth out of the screen
+   * Returns true if the object is out of the screen.
+   */
+  bool disappearGoRight( KPObject *object );
+
+  /**
+   * Draws the object object to the pixmap screen with the offset defined 
+   * in x and y. 
+   */
+  void drawObject( KPObject *object, int x, int y, QPixmap *screen );
+  
+  /**
+   * The internal step of the effect. This is used to calculate the position
+   * of the object.
+   */
+  int m_effectStep;
+
+  /**
+   * The effect step which should be animated.
+   */
+  int m_step;
+
+  /**
+   * The effect sub step which should be animated.
+   */
+  int m_subStep;
+
+  /**
+   * True when the effect step was reached by going backwards
+   */
+  bool m_back;
+
+  /**
+   * Paint device on which the effects will be displayed
+   */
+  QPaintDevice *m_dst;
+
+  /**
+   * Pixmap used as source for displaying on.
+   * m_src contains all objects which are allready on the 
+   * final position. 
+   */
+  QPixmap *m_src;
+
+  /**
+   * Is used for printing all objects before bitblt to m_dst
+   */
+  QPixmap m_paint;
+
+  /**
+   * List of all objects of the current page
+   */
+  QPtrList<KPObject> m_objects;
+  
+  /**
+   * List of all objects which appear in the current step.
+   * If a object has reached its final position it is removed from 
+   * this list
+   */
+  QPtrList<KPObject> m_appearEffectObjects;
+
+  /**
+   * List of all objects which disappear in the current step.
+   * If a object has disappeared it is removed from this list
+   */
+  QPtrList<KPObject> m_disappearEffectObjects;
+
+  /// the active KPresenterView
+  KPresenterView *m_view;
+  
+  /**
+   * The width of a step.
+   */
+  int m_stepWidth;
+  
+  /**
+   * The height of a step.
+   */
+  int m_stepHeight;
+  
+  /**
+   * The rects which have to be bitblt
+   */
+  QPtrList<QRect> m_repaintRects;
+  
+  /**
+   * The rects which have to be bitblt as the objects
+   * are no longer there.
+   */
+  QPtrList<QRect> m_lastRepaintRects;
+
+  /**
+   * The filename of the sound file which should be played during the effect.
+   */
+  QString m_soundEffect;
+
+  /**
+   * Used the set the autopresentation timer.
+   */
+  int m_objectTimer;
+};
+
+
+#endif /* EFFECTHANDLER_H */
Index: effecthandler.cc
===================================================================
RCS file: effecthandler.cc
diff -N effecthandler.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ effecthandler.cc	29 Apr 2004 11:30:30 -0000
@@ -0,0 +1,443 @@
+#include "effecthandler.h"
+
+#include "kpobject.h"
+#include "kpresenter_doc.h"
+#include "kpresenter_view.h"
+#include "kprcanvas.h"
+
+#include <kozoomhandler.h>
+
+#include <kapplication.h>
+
+#include <qpainter.h>
+#include <qpaintdevice.h>
+
+
+EffectHandler::EffectHandler( int step, int subStep, bool back, QPaintDevice *dst, \
QPixmap *src,  +//EffectHandler::EffectHandler( int step, int subStep, bool back, \
QWidget *dst, QPixmap *src,  +                              const QPtrList<KPObject> \
&objects, KPresenterView *view ) +: m_effectStep(0), m_step(step), \
m_subStep(subStep), m_back(back), m_dst(dst),  +  m_paint(*src), m_objects(objects), \
m_view(view), m_soundEffect(QString::null), +  m_objectTimer(0)
+{
+    m_src = new QPixmap( *src );
+
+    QPtrListIterator<KPObject> it( m_objects );
+    for ( ; it.current(); ++it )
+    {
+        KPObject *object = it.current();
+        if ( object->getAppearStep() == m_step 
+          && ( m_subStep == 0 
+            || ( object->getType() == OT_TEXT 
+              && object->getEffect2() == EF2T_PARA ) ) )
+        {
+            m_appearEffectObjects.append( object );
+            if ( object->getEffect() != EF_NONE && object->getAppearSoundEffect() )
+            {
+                m_soundEffect = object->getAppearSoundEffectFileName();
+            }
+
+            if ( object->getAppearTimer() > m_objectTimer )
+            {
+                m_objectTimer = object->getAppearTimer();
+            }
+        }
+        else if ( object->getDisappear() && object->getDisappearStep() == m_step ) 
+        {
+            m_disappearEffectObjects.append( object );
+            if ( object->getEffect3() != EF3_NONE && \
object->getDisappearSoundEffect() ) +            {
+                m_soundEffect = object->getDisappearSoundEffectFileName();
+            }
+
+            if ( object->getDisappearTimer() > m_objectTimer )
+            {
+                m_objectTimer = object->getDisappearTimer();
+            }
+        }
+    }
+
+    float speedFactor = 150.0 / static_cast<float>( \
m_view->kPresenterDoc()->getPresSpeed() + 2 ); +    m_stepWidth = static_cast<int>( \
m_src->width() / speedFactor ); +    m_stepHeight = static_cast<int>( m_src->height() \
/ speedFactor ); +    m_lastRepaintRects.setAutoDelete( true );
+}
+
+
+EffectHandler::~EffectHandler()
+{
+    delete m_src;
+}
+
+
+bool EffectHandler::doEffect()
+{
+    if ( m_effectStep == 0 ) 
+    {
+        if ( !m_view->kPresenterDoc()->spManualSwitch() && m_objectTimer > 0 )
+        {
+            m_view->stopAutoPresTimer();
+        }
+
+        if ( !m_soundEffect.isNull() )
+        {
+            m_view->getCanvas()->stopSound();
+            m_view->getCanvas()->playSound( m_soundEffect );
+        }
+    }
+    if ( !m_appearEffectObjects.isEmpty() || !m_disappearEffectObjects.isEmpty() )
+    {
+        QPtrList<QRect> m_removeRects;
+        KPObject *appearObject = m_appearEffectObjects.first();
+        KPObject *disappearObject = m_disappearEffectObjects.first();
+        QPtrListIterator<KPObject> it( m_objects );
+        KPObject *object;
+
+        while ( ( object = it.current() ) != 0 )
+        {
+            ++it;
+            if ( object == appearObject )
+            {
+                bool next = true;
+
+                if ( doAppearEffectStep( object ) )
+                {
+                    m_removeRects.append( m_repaintRects.getLast() );
+                    if ( appearObject != m_appearEffectObjects.getLast() )
+                    {
+                        next = false;
+                    }
+                    m_appearEffectObjects.remove();
+
+                    // add object to src
+                    drawObject( object, 0, 0, m_src );
+                }
+                if ( next )
+                    appearObject = m_appearEffectObjects.next();
+                else
+                    appearObject = m_appearEffectObjects.current();
+            }
+            else if ( object == disappearObject )
+            {
+                bool next = true;
+                if ( doDisappearEffectStep( object ) )
+                {
+                    if ( disappearObject != m_disappearEffectObjects.getLast() )
+                    {
+                        next = false;
+                    }
+                    m_disappearEffectObjects.remove();
+                }
+                
+                if ( next )
+                    disappearObject = m_disappearEffectObjects.next();
+                else
+                    disappearObject = m_disappearEffectObjects.current();
+            }
+        }
+
+        ++m_effectStep;
+        QPtrListIterator<QRect> it_r(m_repaintRects);
+        QRect *r;
+        while( ( r = it_r.current() ) != 0 )
+        {
+            ++it_r;
+            //bitBlt( m_dst, r->x(), r->y(), &m_paint, r->x(), r->y(), r->width(), \
r->height() ); +            bitBlt( m_dst, r->x() - 5, r->y() - 5, &m_paint, r->x() - \
5, r->y() - 5, r->width() + 10, r->height() + 10 ); +        }
+
+        QPtrListIterator<QRect> it2(m_lastRepaintRects);
+        while( ( r = it2.current() ) != 0 )
+        {
+            ++it2;
+            //bitBlt( m_dst, r->x(), r->y(), &m_paint, r->x(), r->y(), r->width(), \
r->height() ); +            bitBlt( m_dst, r->x() - 5, r->y() - 5, &m_paint, r->x() - \
5, r->y() - 5, r->width() + 10, r->height() + 10 ); +        }
+#if 0
+        bitBlt( m_dst, 0, 0, &m_paint);
+#endif
+
+        m_lastRepaintRects = m_repaintRects;
+        QPtrListIterator<QRect> it3(m_removeRects);
+        while( ( r = it3.current() ) != 0 )
+        {
+            ++it3;
+            m_lastRepaintRects.remove( r );
+        }
+
+        m_repaintRects.clear();
+
+        kapp->flush();
+        m_paint = *m_src;
+
+    }
+    bool retval = ( m_appearEffectObjects.isEmpty() && \
m_disappearEffectObjects.isEmpty() ); +    
+    if ( retval && !m_view->kPresenterDoc()->spManualSwitch() && m_objectTimer > 0 )
+    {
+        m_view->setAutoPresTimer( m_objectTimer );
+    }
+    return retval;
+}
+
+
+void EffectHandler::finish()
+{
+    KPObject *appearObject = m_appearEffectObjects.first();
+    KPObject *disappearObject = m_disappearEffectObjects.first();
+    QPtrListIterator<KPObject> it( m_objects );
+    KPObject *object;
+
+    while ( ( object = it.current() ) != 0 )
+    {
+        ++it;
+        if ( object == appearObject )
+        {
+            bool next = true;
+
+            QRect objectRect = m_view->zoomHandler()->zoomRect( \
object->getRealRect() ); +            m_repaintRects.append( new QRect( objectRect ) \
); +
+            if ( appearObject != m_appearEffectObjects.getLast() )
+            {
+                next = false;
+            }
+            m_appearEffectObjects.remove();
+
+            // add object to src
+            drawObject( object, 0, 0, m_src );
+
+            if ( next )
+                appearObject = m_appearEffectObjects.next();
+            else
+                appearObject = m_appearEffectObjects.current();
+        }
+        else if ( object == disappearObject )
+        {
+            bool next = true;
+
+            if ( disappearObject != m_disappearEffectObjects.getLast() )
+            {
+                next = false;
+            }
+            m_disappearEffectObjects.remove();
+            
+            if ( next )
+                disappearObject = m_disappearEffectObjects.next();
+            else
+                disappearObject = m_disappearEffectObjects.current();
+        }
+    }
+    bitBlt( m_dst, 0, 0, m_src );
+    kapp->flush();
+
+    if ( !m_view->kPresenterDoc()->spManualSwitch() && m_objectTimer > 0 )
+    {
+        m_view->setAutoPresTimer( m_objectTimer );
+    }
+}
+
+
+bool EffectHandler::doAppearEffectStep( KPObject *object )
+{
+    bool positionReached = true;
+
+    switch( object->getEffect() )
+    {
+        case EF_NONE:
+            positionReached = appearNone( object );
+            break;
+        case EF_COME_LEFT:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_COME_TOP:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_COME_RIGHT:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_COME_BOTTOM:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_COME_LEFT_TOP:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_COME_LEFT_BOTTOM:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_COME_RIGHT_TOP:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_COME_RIGHT_BOTTOM:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_WIPE_LEFT:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_WIPE_RIGHT:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_WIPE_TOP:
+            positionReached = appearComeLeft( object );
+            break;
+        case EF_WIPE_BOTTOM:
+            positionReached = appearComeLeft( object );
+            break;
+        default: 
+            break;
+    }
+    return positionReached;
+}
+
+
+bool EffectHandler::doDisappearEffectStep( KPObject *object )
+{
+    bool positionReached = true;
+
+    switch( object->getEffect3() )
+    {
+        case EF3_NONE:
+            break;
+        case EF3_GO_LEFT:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_GO_TOP:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_GO_RIGHT:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_GO_BOTTOM:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_GO_LEFT_TOP:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_GO_LEFT_BOTTOM:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_GO_RIGHT_TOP:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_GO_RIGHT_BOTTOM:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_WIPE_LEFT:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_WIPE_RIGHT:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_WIPE_TOP:
+            positionReached = disappearGoRight( object );
+            break;
+        case EF3_WIPE_BOTTOM:
+            positionReached = disappearGoRight( object );
+            break;
+        default: 
+            break;
+    }
+    return positionReached;
+}
+
+bool EffectHandler::appearNone( KPObject *object )
+{
+    QRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
+    m_repaintRects.append( new QRect( objectRect ) );
+    drawObject( object, 0, 0, &m_paint );
+    return true;
+}
+
+
+bool EffectHandler::appearComeLeft( KPObject *object )
+{
+    QRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
+    int ox = objectRect.x();
+    
+    bool positionReached = false;
+    int x = m_effectStep * m_stepWidth - objectRect.width();
+    if ( x > ox )
+    {
+        x = ox;
+        positionReached = true;
+    }
+    objectRect.setX( x );
+    m_repaintRects.append( new QRect( objectRect ) );
+
+    //kdDebug(33001) << "EffectHandler appearComeLeft x = " << x << " " << \
positionReached << endl; +    drawObject( object, x - ox, 0, &m_paint );
+
+    return positionReached;
+}
+
+
+bool EffectHandler::disappearGoRight( KPObject *object )
+{
+    QRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
+    int ox = objectRect.x();
+    
+    bool positionReached = false;
+    int x = m_effectStep * m_stepWidth;
+    if ( x + ox > m_src->width() )
+    {
+        positionReached = true;
+    }
+    else
+    {
+        objectRect.moveBy( x, 0 );
+        m_repaintRects.append( new QRect( objectRect ) );
+        //kdDebug(33001) << "EffectHandler disappearGoRight x = " << x + ox << " " \
<< positionReached << endl; +        drawObject( object, x, 0, &m_paint );
+    }
+
+    return positionReached;
+}
+
+
+void EffectHandler::drawObject( KPObject *object, int x, int y, QPixmap *screen )
+{
+    QPainter p;
+    p.begin( screen );
+    p.translate( x, y );
+
+    if ( object->getAppearStep() == m_step && ! m_back ) 
+    {
+        object->setSubPresStep( m_subStep );
+        object->doSpecificEffects( true );
+    }
+
+    object->draw( &p, m_view->zoomHandler(), SM_NONE, false );
+
+    if ( object->getAppearStep() == m_step && ! m_back ) 
+    {
+        object->setSubPresStep( 0 );
+        object->doSpecificEffects( false );
+    }
+    
+    p.translate( -x, -y );
+
+    m_objects.findRef( object );
+    KPObject *obj;
+    while ( ( obj = m_objects.next() ) != 0 )
+    {
+        if ( ( obj->getAppearStep() < m_step 
+            || obj->getAppearStep() == m_step && !m_appearEffectObjects.containsRef( \
obj ) ) +            && ( ( obj->getDisappear() && obj->getDisappearStep() > m_step ) \
|| ! obj->getDisappear() ) +            && m_view->zoomHandler()->zoomRect( \
obj->getRealRect()).intersects(*m_repaintRects.getLast()) ) +        {
+            if ( obj->getAppearStep() == m_step && ! m_back ) 
+            {
+                obj->setSubPresStep( m_subStep );
+                obj->doSpecificEffects( true );
+            }
+            obj->draw( &p, m_view->zoomHandler(), SM_NONE, false );
+            if ( obj->getAppearStep() == m_step && ! m_back ) 
+            {
+                obj->setSubPresStep( 0 );
+                obj->doSpecificEffects( false );
+            }
+        }
+    }
+
+    p.end();
+}
Index: kprcanvas.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kprcanvas.h,v
retrieving revision 1.156
diff -u -3 -p -r1.156 kprcanvas.h
--- kprcanvas.h	10 Apr 2004 06:00:30 -0000	1.156
+++ kprcanvas.h	29 Apr 2004 11:30:30 -0000
@@ -31,6 +31,7 @@
 #include <qpixmap.h>
 #include <qpointarray.h>
 #include <qvaluevector.h>
+#include <qtimer.h>
 
 #include <koRuler.h>
 #include <koQueryTrader.h>
@@ -70,6 +71,7 @@ class KPrinter;
 class KPTextView;
 class KPPartObject;
 class KCommand;
+class EffectHandler;
 /**
  * Class KPCanvas - There is a single instance of this class for a given view.
  *
@@ -251,6 +253,7 @@ exportPage( 0, s, 800, 600, "/home/khz/p
     // get - set data
     const QPtrList<KPObject> & getObjectList() const;
 
+    void playSound( const QString &soundFileName );
     void stopSound();
 
     ///for KPTextView
@@ -526,6 +529,12 @@ protected:
     /// draw grid
     void drawGrid(QPainter *painter, const QRect &rect2) const;
 
+    /**
+     * Finish the object effects.
+     * This shown the last step of the effect. It stops the effect timer and 
+     * disconnect it and the effect handler deleted.
+     */
+    void finishObjectEffects();
 
     QRect getOldBoundingRect( const KPObject *obj );
 
@@ -640,8 +649,6 @@ private:
 
     bool nextPageTimer;
 
-    void playSound( const QString &soundFileName );
-
     void drawPolygon( const KoPoint &startPoint, const KoPoint &endPoint );
 
     void drawPieObject(QPainter *p,  const QRect & );
@@ -688,6 +695,14 @@ private slots:
     void slotExitPres();
     void terminateEditing( KPTextObject * );
 
+    /**
+     * Do the next step of the object effect.
+     * This restarts the effect tmer. If the effects are
+     * completed the timer is disconnected and the effect handler
+     * deleted.
+     */
+    void slotDoEffect();
+
 private:
     // variables
     /// Popup menu used in presentation mode.
@@ -741,6 +756,10 @@ private:
     QValueList<int> m_presentationSlides;
     /// Iterator over the slides of a presentation
     QValueList<int>::Iterator m_presentationSlidesIterator;
+    /// EffectHandler for object effects
+    EffectHandler *m_effectHandler;
+    /// EffectTimer
+    QTimer m_effectTimer;
     /// menu identifier for draw mode
     int PM_DM;
     int firstX, firstY;
Index: kprcanvas.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kprcanvas.cc,v
retrieving revision 1.403
diff -u -3 -p -r1.403 kprcanvas.cc
--- kprcanvas.cc	26 Apr 2004 12:35:57 -0000	1.403
+++ kprcanvas.cc	29 Apr 2004 11:30:30 -0000
@@ -85,6 +85,9 @@
 #include "kprcanvas.h"
 #include "kprcanvas.moc"
 
+#include "effecthandler.h"
+#include <unistd.h>
+
 
 KPrCanvas::KPrCanvas( QWidget *parent, const char *name, KPresenterView *_view )
     : QWidget( parent, name, WStaticContents|WResizeNoErase|WRepaintNoErase ), \
buffer( size() ) @@ -142,6 +145,7 @@ KPrCanvas::KPrCanvas( QWidget *parent, c
         m_drawLineWithCubicBezierCurve = true;
         m_oldCubicBezierPointArray.putPoints( 0, 4, 0.0, 0.0, 0.0, 0.0,
                                               0.0, 0.0, 0.0, 0.0 );
+        m_effectHandler = 0;
     } else {
         m_view = 0;
         hide();
@@ -1129,7 +1133,10 @@ void KPrCanvas::mousePressEvent( QMouseE
             m_view->screenPrev();
         else if ( e->button() == RightButton ) {
             if ( !m_drawMode && !spManualSwitch() )
+            {
+                finishObjectEffects();
                 m_view->stopAutoPresTimer();
+            }
 
             setCursor( arrowCursor );
             QPoint pnt = QCursor::pos();
@@ -2094,10 +2101,12 @@ void KPrCanvas::keyPressEvent( QKeyEvent
             break;
         case Key_Backspace: case Key_Left: case Key_Up: case Key_Prior:
             setSwitchingMode( false );
+            finishObjectEffects();
             m_view->screenPrev();
             break;
         case Key_Escape: case Key_Q: case Key_X:
             setSwitchingMode( false );
+            finishObjectEffects();
             m_view->screenStop();
             break;
         case Key_G:
@@ -3518,6 +3527,16 @@ void KPrCanvas::printPage( QPainter* pai
 
 void KPrCanvas::doObjEffects()
 {
+    if ( m_effectHandler )
+    {
+        m_effectTimer.stop();
+        QObject::disconnect( &m_effectTimer, SIGNAL( timeout() ), this, SLOT( \
slotDoEffect() ) ); +
+        m_effectHandler->finish();
+        delete m_effectHandler;
+        m_effectHandler = 0;
+    }
+    
     /// ### Note: this is for full-screen mode only.
     /// ### There should be NO use of diffx(), diffy() anywhere in this method!
 
@@ -3539,6 +3558,7 @@ void KPrCanvas::doObjEffects()
         drawn = true;
     }
 
+
     QPtrList<KPObject> _objList;
     QTime _time;
     int _step = 0, _steps1 = 0, _steps2 = 0, x_pos1 = 0, y_pos1 = 0;
@@ -3551,8 +3571,21 @@ void KPrCanvas::doObjEffects()
     QString _soundFileName = QString::null;
     if ( !drawn )
         bitBlt( &screen_orig, 0, 0, this, 0, 0, kapp->desktop()->width(), \
                kapp->desktop()->height() );
-    QPixmap *screen = new QPixmap( screen_orig );
+    //QPixmap *screen = new QPixmap( screen_orig );
+
+    m_effectHandler = new EffectHandler( m_step.m_step, m_step.m_subStep, goingBack, \
this, &screen_orig, objectList(), m_view ); +    if ( m_effectHandler->doEffect() )
+    {
+        delete m_effectHandler;
+        m_effectHandler = 0;
+    }
+    else
+    {
+        connect( &m_effectTimer, SIGNAL( timeout() ), SLOT( slotDoEffect() ) );
+        m_effectTimer.start( 100, true );
+    }
 
+#if 0
     QPtrListIterator<KPObject> oit(getObjectList());
     for ( int i = 0 ; oit.current(); ++oit, ++i )
     {
@@ -4216,8 +4249,38 @@ void KPrCanvas::doObjEffects()
         m_view->setAutoPresTimer( timer );
 
     delete screen;
+#endif
+}
+
+void KPrCanvas::slotDoEffect()
+{
+    if ( m_effectHandler->doEffect() )
+    {
+        m_effectTimer.stop();
+        QObject::disconnect( &m_effectTimer, SIGNAL( timeout() ), this, SLOT( \
slotDoEffect() ) ); +        delete m_effectHandler;
+        m_effectHandler = 0;
+    }
+    else
+    {
+        m_effectTimer.start( 100, true );
+    }
+}
+
+
+void KPrCanvas::finishObjectEffects()
+{
+    if ( m_effectHandler )
+    {
+        m_effectTimer.stop();
+        QObject::disconnect( &m_effectTimer, SIGNAL( timeout() ), this, SLOT( \
slotDoEffect() ) ); +        m_effectHandler->finish();
+        delete m_effectHandler;
+        m_effectHandler = 0;
+    }
 }
 
+
 void KPrCanvas::drawObject( KPObject *kpobject, QPixmap *screen, int _x, int _y, int \
_w, int _h,  int _cx, int _cy )
 {
@@ -4253,6 +4316,8 @@ void KPrCanvas::drawObject( KPObject *kp
     kpobject->doSpecificEffects( false );
     kpobject->setOwnClipping( true );
 
+    p.translate(-_x,-_y);
+
     KPObject *obj = 0;
     for ( unsigned int i = tmpObjs.findRef( kpobject ) +1 ; i < tmpObjs.count(); i++ \
) {  obj = tmpObjs.at( i );
@@ -4964,6 +5029,7 @@ void KPrCanvas::gotoPage( int pg )
     if ( page != m_step.m_pageNumber || m_step.m_step != *m_pageEffectSteps.begin() \
|| m_step.m_subStep != 0 ) {  // clear drawed lines
         m_drawModeLines.clear();
+        goingBack = false;
 
         m_step.m_pageNumber = page;
         kdDebug(33001) << "Page::gotoPage m_step.m_pageNumber =" << \
m_step.m_pageNumber << endl;



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


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

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