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

List:       kde-commits
Subject:    kdeartwork/styles/plastik
From:       Sandro Giessl <sandro () giessl ! com>
Date:       2004-05-02 17:19:36
Message-ID: 20040502171936.D7B229A72 () office ! kde ! org
[Download RAW message or body]

CVS commit by giessl: 

Patch by Wilfried Huss which improves the progress bar animation:
- animation moves from right to left in reverse layout
- animation is turned off if disabled or if the progress is 100%
- animation offset is calculated separately for different progress bars

CCMAIL: Wilfried.Huss@gmx.at
Thank you!


  M +38 -11    plastik.cpp   1.72
  M +1 -2      plastik.h   1.23


--- kdeartwork/styles/plastik/plastik.cpp  #1.71:1.72
@@ -157,5 +157,4 @@ PlastikStyle::PlastikStyle() : KStyle( A
     hoverWidget = 0;
     focusWidget = 0;
-    progAnimShift = 0;
 
     QSettings settings;
@@ -189,12 +188,21 @@ PlastikStyle::PlastikStyle() : KStyle( A
 void PlastikStyle::updateProgressPos()
 {
-    progAnimShift++;
-    if (progAnimShift == 20)
-        progAnimShift = 0;
-
+    QProgressBar* pb;
     //Update the registered progressbars.
-    QMap<QWidget*, bool>::iterator iter;
+    QMap<QWidget*, int>::iterator iter;
     for (iter = progAnimWidgets.begin(); iter != progAnimWidgets.end(); iter++)
+    {   
+        if ( !::qt_cast<QProgressBar*>(iter.key()) ) 
+            continue; 
+        
+        pb = dynamic_cast<QProgressBar*>(iter.key());
+        if ( iter.key() -> isEnabled() && 
+             pb -> progress() != pb->totalSteps() )
+        {
+            // update animation Offset of the current Widget
+            iter.data() = (iter.data() + 1) % 20;
         iter.key()->update();
+        }
+    }
 }
 
@@ -241,5 +249,5 @@ void PlastikStyle::polish(QWidget* widge
     if( _animateProgressBar && ::qt_cast<QProgressBar*>(widget) )
     {
-        progAnimWidgets[widget] = true;
+        progAnimWidgets[widget] = 0;
         connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(progressBarDestroyed(QObject*)));
     }
@@ -2114,11 +2122,30 @@ void PlastikStyle::drawControl(ControlEl
                                 : Draw_Right|Draw_Left|Draw_Top|Draw_Bottom|
                                         Round_UpperRight|Round_BottomRight|Is_Horizontal);
+
                 surfacePainter.end();
+                int staticShift = 0;
+                int animShift = 0;
+                if (!_animateProgressBar) {
+                    staticShift = (reverseLayout ? Rsurface.left() : Rsurface.right()) % 40 - 40;
+                } else {
+                    // find the animation Offset for the current Widget
+                    QWidget* nonConstWidget = const_cast<QWidget*>(widget);
+                    QMapConstIterator<QWidget*, int> iter = progAnimWidgets.find(nonConstWidget);
+                    if (iter != progAnimWidgets.end())
+                        animShift = iter.data();
+                }
                 while((counter*10) < (Rsurface.width()+20)) {
                     counter++;
+                    if (reverseLayout) {    
                     // from right to left, overlap 1 pixel with the previously drawn tile
-                    p->drawPixmap(Rsurface.right()-counter*20+progAnimShift, r.top()+1,
+                        p->drawPixmap(Rsurface.right()-counter*20-animShift+40+staticShift, r.top()+1,
+                                    surfaceTile);
+                    } else {
+                        // from left to right, overlap 1 pixel with the previously drawn tile
+                        p->drawPixmap(Rsurface.left()+counter*20+animShift-40+staticShift, r.top()+1,
                                   surfaceTile);
                 }
+                }
+        
                 p->setClipping(false);
             }

--- kdeartwork/styles/plastik/plastik.h  #1.22:1.23
@@ -284,6 +284,5 @@ private:
 
     //Animation support.
-    QMap<QWidget*, bool> progAnimWidgets;
-    int progAnimShift;
+    QMap<QWidget*, int> progAnimWidgets;
 
     // pixmap cache.


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

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