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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/applets
From:       Marco Martin <notmart () gmail ! com>
Date:       2008-06-13 20:29:42
Message-ID: 1213388982.095769.17133.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 820307 by mart:

enable animations in the taskbar again, this time they are very subtle
(50 ms fade in 100 fade out) and the pixmap used for alpha blending is
one and shared among all task items, that makes the thing a bit faster.
also adjust the pager anim timing to match the taskbar timing


 M  +2 -2      pager/pager.h  
 M  +6 -0      tasks/tasks.cpp  
 M  +2 -0      tasks/tasks.h  
 M  +28 -20    tasks/windowtaskitem.cpp  
 M  +2 -0      tasks/windowtaskitem.h  


--- trunk/KDE/kdebase/workspace/plasma/applets/pager/pager.h #820306:820307
@@ -141,8 +141,8 @@
         int m_dragSwitchDesktop;
         QTimer* m_dragSwitchTimer;
 
-        static const int s_FadeInDuration = 100;
-        static const int s_FadeOutDuration = 200;
+        static const int s_FadeInDuration = 50;
+        static const int s_FadeOutDuration = 100;
     };
 
 K_EXPORT_PLASMA_APPLET(pager, Pager)
--- trunk/KDE/kdebase/workspace/plasma/applets/tasks/tasks.cpp #820306:820307
@@ -41,6 +41,7 @@
  : Plasma::Applet(parent, arguments),
    m_activeTask(0),
    m_taskItemBackground(0),
+   m_taskAlphaPixmap(0),
    m_colorScheme(0),
    m_leftMargin(0),
    m_topMargin(0),
@@ -225,6 +226,11 @@
     return m_taskItemBackground;
 }
 
+QPixmap *Tasks::taskAlphaPixmap()
+{
+    return m_taskAlphaPixmap;
+}
+
 void Tasks::resizeItemBackground(const QSizeF &size)
 {
     if (!m_taskItemBackground) {
--- trunk/KDE/kdebase/workspace/plasma/applets/tasks/tasks.h #820306:820307
@@ -72,6 +72,7 @@
         void constraintsEvent(Plasma::Constraints constraints);
 
         Plasma::PanelSvg *itemBackground();
+        QPixmap *taskAlphaPixmap();
         KColorScheme *colorScheme();
 
         qreal itemLeftMargin() { return m_leftMargin; }
@@ -129,6 +130,7 @@
         QTimer m_screenTimer;
 
         Plasma::PanelSvg *m_taskItemBackground;
+        QPixmap *m_taskAlphaPixmap;
         KColorScheme *m_colorScheme;
         qreal m_leftMargin;
         qreal m_topMargin;
--- trunk/KDE/kdebase/workspace/plasma/applets/tasks/windowtaskitem.cpp \
#820306:820307 @@ -53,7 +53,8 @@
       m_fadeIn(true),
       m_updateTimerId(0),
       m_attentionTimerId(0),
-      m_attentionTicks(0)
+      m_attentionTicks(0),
+      m_alphaPixmap(0)
 {
     m_showTooltip = showTooltip;
     setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
@@ -145,30 +146,28 @@
 
 void WindowTaskItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
 {
-    //const int FadeInDuration = 100;
+    const int FadeInDuration = 50;
 
     if (m_animId) {
         Plasma::Animator::self()->stopCustomAnimation(m_animId);
     }
 
     m_fadeIn = true;
-    //m_animId = Plasma::Animator::self()->customAnimation(40 / (1000 / \
FadeInDuration), FadeInDuration,Plasma::Animator::LinearCurve, this, \
                "animationUpdate");
-    animationUpdate(1);
+    m_animId = Plasma::Animator::self()->customAnimation(40 / (1000 / \
FadeInDuration), FadeInDuration,Plasma::Animator::LinearCurve, this, \
"animationUpdate");  
     QGraphicsWidget::hoverEnterEvent(event);
 }
 
 void WindowTaskItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
 {
-    //const int FadeOutDuration = 200;
+    const int FadeOutDuration = 100;
 
     if (m_animId) {
         Plasma::Animator::self()->stopCustomAnimation(m_animId);
     }
 
     m_fadeIn = false;
-    //m_animId = Plasma::Animator::self()->customAnimation(40 / (1000 / \
FadeOutDuration), FadeOutDuration,Plasma::Animator::LinearCurve, this, \
                "animationUpdate");
-    animationUpdate(1);
+    m_animId = Plasma::Animator::self()->customAnimation(40 / (1000 / \
FadeOutDuration), FadeOutDuration,Plasma::Animator::LinearCurve, this, \
"animationUpdate");  
     QGraphicsWidget::hoverLeaveEvent(event);
 }
@@ -232,6 +231,7 @@
     bool hasSvg = false;
 
     Plasma::PanelSvg *itemBackground = m_applet->itemBackground();
+    QPixmap *alphaPixmap = m_applet->taskAlphaPixmap();
 
     if ((m_flags & TaskWantsAttention) && !(m_attentionTicks % 2)) {
         if (itemBackground && itemBackground->hasElementPrefix("attention")) {
@@ -297,43 +297,51 @@
                  itemBackground->paintPanel(painter, option->rect);
              }
         } else {
-            QPixmap pixmap(option->rect.size());
-    
-            pixmap.fill(QColor(0,0,0,255*(1-m_alpha)));
-    
+            if (!alphaPixmap || alphaPixmap->size() != option->rect.size()) {
+                delete m_alphaPixmap;
+                alphaPixmap = new QPixmap(option->rect.size());
+                alphaPixmap->fill(Qt::transparent);
+            }
+
+            alphaPixmap->fill(QColor(0,0,0,255*(1.0-m_alpha)));
+
             {
-                QPainter buffPainter(&pixmap);
+                QPainter buffPainter(alphaPixmap);
                 buffPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
                 itemBackground->paintPanel(&buffPainter, option->rect);
             }
-    
-            painter->drawPixmap(option->rect.topLeft(), pixmap);
+
+            painter->drawPixmap(option->rect.topLeft(), *alphaPixmap);
         }
     }
 
     if (option->state & QStyle::State_MouseOver || m_animId) {
         if (itemBackground && itemBackground->hasElementPrefix("hover")) {
-            if (!m_animId) {
+            if (!m_animId && (~option->state & QStyle::State_Sunken)) {
                 itemBackground->setElementPrefix("hover");
                 itemBackground->paintPanel(painter, option->rect);
             } else {
                 //Draw task background from theme svg "hover" element
-                QPixmap pixmap(option->rect.size());
+                if (!alphaPixmap || alphaPixmap->size() != option->rect.size()) {
+                    delete alphaPixmap;
+                    alphaPixmap = new QPixmap(option->rect.size());
+                    alphaPixmap->fill(Qt::transparent);
+                }
     
                 if (option->state & QStyle::State_Sunken) {
-                    pixmap.fill(QColor(0,0,0,50));
+                    alphaPixmap->fill(QColor(0,0,0,50));
                 } else {
-                    pixmap.fill(QColor(0,0,0,255*m_alpha));
+                    alphaPixmap->fill(QColor(0,0,0,255*m_alpha));
                 }
     
                 {
-                    QPainter buffPainter(&pixmap);
+                    QPainter buffPainter(alphaPixmap);
                     \
buffPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);  \
                itemBackground->setElementPrefix("hover");
                     itemBackground->paintPanel(&buffPainter, option->rect);
                 }
     
-                painter->drawPixmap(option->rect.topLeft(), pixmap);
+                painter->drawPixmap(option->rect.topLeft(), *alphaPixmap);
             }
         } else {
             //Draw task background without svg theming
--- trunk/KDE/kdebase/workspace/plasma/applets/tasks/windowtaskitem.h #820306:820307
@@ -200,6 +200,8 @@
     int m_attentionTimerId;
     int m_attentionTicks;
 
+    QPixmap *m_alphaPixmap;
+
     // distance (in pixels) between a task's icon and its text
     static const int IconTextSpacing = 4;
 


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

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