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

List:       kde-commits
Subject:    branches/KDE/4.4/kdebase/workspace/kwin/clients/oxygen
From:       Hugo Pereira Da Costa <hugo.pereira () free ! fr>
Date:       2010-02-12 0:45:39
Message-ID: 1265935539.293914.27122.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1088955 by hpereiradacosta:

backport: r1088954
re-enabled title transition animation. Add animation 'lock' in case title is changed to frequently 
(e.g. in kmail/thunderbird new mail window). Set the lock duration to 300 milliseconds.



 M  +28 -8     oxygenclient.cpp  
 M  +1 -1      oxygenconfiguration.cpp  
 M  +22 -0     oxygentitleanimationdata.cpp  
 M  +29 -1     oxygentitleanimationdata.h  


--- branches/KDE/4.4/kdebase/workspace/kwin/clients/oxygen/oxygenclient.cpp #1088954:1088955
@@ -811,16 +811,36 @@
     if( titleAnimationData_.data()->isDirty() )
     {
 
-        // contrast pixmap
-        titleAnimationData_.data()->setPixmaps(
-            rect,
-            renderTitleText( rect, caption(), color ),
-            renderTitleText( rect, caption(), contrast ) );
-
+        // clear dirty flags
         titleAnimationData_.data()->setDirty( false );
-        titleAnimationData_.data()->startAnimation();
-        renderTitleText( painter, rect, color, contrast );
 
+        // finish current animation if running
+        if( titleAnimationData_.data()->isAnimated() )
+        { titleAnimationData_.data()->finishAnimation(); }
+
+        if( !titleAnimationData_.data()->isLocked() )
+        {
+
+            // set pixmaps
+            titleAnimationData_.data()->setPixmaps(
+                rect,
+                renderTitleText( rect, caption(), color ),
+                renderTitleText( rect, caption(), contrast ) );
+
+            titleAnimationData_.data()->startAnimation();
+            renderTitleText( painter, rect, color, contrast );
+
+        } else if( !caption().isEmpty() ) {
+
+            renderTitleText( painter, rect, caption(), color, contrast );
+
+        }
+
+        // lock animations (this must be done whether or not
+        // animation was actually started, in order to extend locking
+        // every time title get changed too rapidly
+        titleAnimationData_.data()->lockAnimations();
+
     } else if( titleAnimationData_.data()->isAnimated() ) {
 
         if( isMaximized() ) painter->translate( 0, 2 );
--- branches/KDE/4.4/kdebase/workspace/kwin/clients/oxygen/oxygenconfiguration.cpp #1088954:1088955
@@ -42,7 +42,7 @@
     hideTitleBar_( false ),
     useOxygenShadows_( true ),
     useAnimations_( true ),
-    animateTitleChange_( false ),
+    animateTitleChange_( true ),
     animationsDuration_( 150 ),
     tabsEnabled_( true ),
     useNarrowButtonSpacing_( false )
--- branches/KDE/4.4/kdebase/workspace/kwin/clients/oxygen/oxygentitleanimationdata.cpp #1088954:1088955
@@ -33,6 +33,9 @@
 namespace Oxygen
 {
 
+    // use 300 milliseconds for animation lock
+    const int TitleAnimationData::lockTime_ = 300;
+
     //_________________________________________________________
     TitleAnimationData::TitleAnimationData( QObject* parent ):
         QObject( parent ),
@@ -82,6 +85,25 @@
     }
 
     //_________________________________________________________
+    void TitleAnimationData::timerEvent( QTimerEvent* e )
+    {
+
+        if( e->timerId() != animationLockTimer_.timerId() )
+        { return QObject::timerEvent( e ); }
+
+        // stop veto
+        animationLockTimer_.stop();
+
+        if( !isAnimated() )
+        {
+            // triggers pixmap updates
+            reset();
+            emit pixmapsChanged();
+        }
+
+    }
+
+    //_________________________________________________________
     void TitleAnimationData::BlendedPixmap::blend( qreal opacity )
     {
 
--- branches/KDE/4.4/kdebase/workspace/kwin/clients/oxygen/oxygentitleanimationdata.h #1088954:1088955
@@ -33,8 +33,11 @@
 #include <cassert>
 #include <QtCore/QObject>
 #include <QtCore/QWeakPointer>
+#include <QtCore/QBasicTimer>
+#include <QtCore/QTimerEvent>
 #include <QtGui/QPixmap>
 
+
 namespace Oxygen
 {
 
@@ -94,16 +97,32 @@
         //@{
 
 
+        //! returns true if animations are locked
+        bool isLocked( void ) const
+        { return animationLockTimer_.isActive(); }
+
+        //! returns true if title transition animation is currently running
         bool isAnimated( void ) const
         { return animation().data()->isRunning(); }
 
-        //! start animation
+        //! start lock animation timer
+        void lockAnimations( void )
+        { animationLockTimer_.start( lockTime_, this ); }
+
+        //! start title transition animation
         void startAnimation( void )
         {
             assert( !isAnimated() );
             animation().data()->start();
         }
 
+        //! finish title transition animation
+        void finishAnimation( void )
+        {
+            assert( isAnimated() );
+            animation().data()->stop();
+        }
+
         //@}
 
         //!@name opacity
@@ -140,6 +159,9 @@
 
         protected:
 
+        //! timer event
+        void timerEvent( QTimerEvent* );
+
         //! animation object
         const Animation::Pointer& animation( void ) const
         { return animation_; }
@@ -212,6 +234,12 @@
         BlendedPixmap contrastPixmap_;
         BlendedPixmap pixmap_;
 
+        //! lock time (milliseconds
+        static const int lockTime_;
+
+        //! timer used to disable animations when triggered too early
+        QBasicTimer animationLockTimer_;
+
         //! title animation
         Animation::Pointer animation_;
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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