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

List:       kde-commits
Subject:    KDE
From:       Marco Martin <notmart () gmail ! com>
Date:       2009-11-26 21:57:37
Message-ID: 1259272657.588261.8370.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1054830 by mart:

move halopainter unchanged in libplasma, keep it private and expose
drawhalo in PaintUtils
iconwidgets uses it if there is no backgroundcolor explicitly setted
CCMAIL:fredrik@kde.org


 M  +0 -1      kdebase/apps/plasma/applets/folderview/CMakeLists.txt  
 M  +1 -2      kdebase/apps/plasma/applets/folderview/abstractitemview.cpp  
 D             kdebase/apps/plasma/applets/folderview/halopainter.cpp  
 D             kdebase/apps/plasma/applets/folderview/halopainter.h  
 M  +1 -0      kdebase/runtime/knotify/notifybypopup.cpp  
 M  +1 -0      kdelibs/plasma/CMakeLists.txt  
 M  +6 -0      kdelibs/plasma/paintutils.cpp  
 M  +2 -0      kdelibs/plasma/paintutils.h  
 M  +38 -18    kdelibs/plasma/widgets/iconwidget.cpp  
 M  +1 -0      kdelibs/plasma/widgets/iconwidget_p.h  


--- trunk/KDE/kdebase/apps/plasma/applets/folderview/CMakeLists.txt #1054829:1054830
@@ -20,7 +20,6 @@
     tooltipwidget.cpp
     style.cpp
     itemeditor.cpp
-    halopainter.cpp
     animator.cpp
     actionoverlay.cpp)
 
--- trunk/KDE/kdebase/apps/plasma/applets/folderview/abstractitemview.cpp #1054829:1054830
@@ -22,7 +22,6 @@
  */
 
 #include "abstractitemview.h"
-#include "halopainter.h"
 #include "proxymodel.h"
 #include "style.h"
 
@@ -436,7 +435,7 @@
         if (qGray(color.rgb()) < 192) {
             // Draw halos
             foreach (const QRect &haloRect, haloRects) {
-                HaloPainter::drawHalo(painter, haloRect.translated(rect.topLeft()));
+                Plasma::PaintUtils::drawHalo(painter, haloRect.translated(rect.topLeft()));
             }
         } else {
             // Draw shadow
--- trunk/KDE/kdebase/runtime/knotify/notifybypopup.cpp #1054829:1054830
@@ -402,6 +402,7 @@
 #endif
 			m_idMap.insert(id, dbus_id);
 			kDebug(300) << "mapping knotify id to dbus id:"<< id << "=>" << dbus_id;
+
 			return true;
 		} else {
 			kDebug(300) << "error: received reply with no arguments";
--- trunk/KDE/kdelibs/plasma/CMakeLists.txt #1054829:1054830
@@ -107,6 +107,7 @@
     private/windowpreview.cpp
     private/kineticscroll.cpp
     private/pulsershadow.cpp
+    private/effects/halopainter.cpp
     querymatch.cpp
     remote/accessmanager.cpp
     remote/accessappletjob.cpp
--- trunk/KDE/kdelibs/plasma/paintutils.cpp #1054829:1054830
@@ -26,6 +26,7 @@
 #include <QPixmap>
 
 #include "private/effects/blur.cpp"
+#include "private/effects/halopainter_p.h"
 
 namespace Plasma
 {
@@ -121,6 +122,11 @@
     return finalPixmap;
 }
 
+void drawHalo(QPainter *painter, const QRectF &rect)
+{
+    HaloPainter::instance()->drawHalo(painter, rect.toRect());
+}
+
 QPainterPath roundedRectangle(const QRectF &rect, qreal radius)
 {
     QPainterPath path(QPointF(rect.left(), rect.top() + radius));
--- trunk/KDE/kdelibs/plasma/paintutils.h #1054829:1054830
@@ -61,6 +61,8 @@
     QPoint offset = QPoint(1,1),
     int radius = 2);
 
+PLASMA_EXPORT void drawHalo(QPainter *painter, const QRectF &rect);
+
 /**
  * Returns a nicely rounded rectanglular path for painting.
  */
--- trunk/KDE/kdelibs/plasma/widgets/iconwidget.cpp #1054829:1054830
@@ -95,7 +95,7 @@
     }
 
     if (!textBgCustomized) {
-        textBgColor = Theme::defaultTheme()->color(Theme::HighlightColor);
+        textBgColor = QColor();
     }
 }
 
@@ -913,8 +913,18 @@
         QStyle::alignedRect(iconDirection(option), alignment, size.toSize(), textRect.toRect());
 
     // Compute the positions where we should draw the layouts
+    haloRects.clear();
     labelLayout->setPosition(QPointF(textRect.x(), textBoundingRect->y()));
+    QTextLine line;
+    for (int i = 0; i < labelLayout->lineCount(); ++i) {
+        line = labelLayout->lineAt(i);
+        haloRects.append(line.naturalTextRect().translated(labelLayout->position().toPoint()).toRect());
+    }
     infoLayout->setPosition(QPointF(textRect.x(), textBoundingRect->y() + labelSize.height()));
+    for (int i = 0; i < infoLayout->lineCount(); ++i) {
+        line = infoLayout->lineAt(i);
+        haloRects.append(line.naturalTextRect().translated(infoLayout->position().toPoint()).toRect());
+    }
     //kDebug() << "final position is" << labelLayout->position();
 }
 
@@ -1010,21 +1020,6 @@
 
     d->layoutTextItems(option, icon, &labelLayout, &infoLayout, &textBoundingRect);
 
-    QImage shadow(textBoundingRect.size().toSize() + QSize(4, 4),
-                  QImage::Format_ARGB32_Premultiplied);
-    shadow.fill(Qt::transparent);
-    {
-        QPainter buffPainter(&shadow);
-        buffPainter.translate(-textBoundingRect.x(), -textBoundingRect.y());
-        d->drawTextItems(&buffPainter, option, labelLayout, infoLayout);
-    }
-
-    QPoint shadowOffset = QPoint(1, 2);
-    if (d->shadowColor.value() > 128) {
-        shadowOffset = QPoint(0, 1);
-    }
-
-
     if (d->textBgColor != QColor() &&
         !(d->text.isEmpty() && d->infoText.isEmpty()) &&
         !textBoundingRect.isEmpty() &&
@@ -1044,8 +1039,33 @@
         painter->drawPath(PaintUtils::roundedRectangle(rect.translated(0.5, 0.5), 4));
     }
 
-    PaintUtils::shadowBlur(shadow, 2, d->shadowColor);
-    painter->drawImage(textBoundingRect.topLeft() + shadowOffset, shadow);
+
+    if (d->shadowColor.value() < 128 || textBackgroundColor() != QColor()) {
+        QPoint shadowPos;
+        if (d->shadowColor.value() < 128) {
+            shadowPos = QPoint(1, 2);
+        } else {
+            shadowPos = QPoint(0, 0);
+        }
+
+        QImage shadow(textBoundingRect.size().toSize() + QSize(4, 4),
+                    QImage::Format_ARGB32_Premultiplied);
+        shadow.fill(Qt::transparent);
+        {
+            QPainter buffPainter(&shadow);
+            buffPainter.translate(-textBoundingRect.x(), -textBoundingRect.y());
+            d->drawTextItems(&buffPainter, option, labelLayout, infoLayout);
+        }
+
+        PaintUtils::shadowBlur(shadow, 2, d->shadowColor);
+        painter->drawImage(textBoundingRect.topLeft() + shadowPos, shadow);
+    } else if (!(d->text.isEmpty() && d->infoText.isEmpty())) {
+        QRect labelRect = d->labelRectangle(option, icon, d->text).toRect();
+
+        foreach (QRect rect, d->haloRects) {
+            Plasma::PaintUtils::drawHalo(painter, rect);
+        }
+    }
     d->drawTextItems(painter, option, labelLayout, infoLayout);
 }
 
--- trunk/KDE/kdelibs/plasma/widgets/iconwidget_p.h #1054829:1054830
@@ -212,6 +212,7 @@
     int numDisplayLines;
     QSizeF currentSize;
     QPointF clickStartPos;
+    mutable QList<QRect> haloRects;
 
     QList<IconAction*> cornerActions;
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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