]> git.sesse.net Git - vlc/commitdiff
Qt: add drow shadow effect
authorLudovic Fauvet <etix@l0cal.com>
Mon, 25 Jan 2010 14:09:25 +0000 (15:09 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 25 Jan 2010 15:06:31 +0000 (16:06 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/gui/qt4/components/playlist/icon_view.cpp

index 2b9f52c68d0d2796df11187d50f17994fad520ca..2169749031d66c39aa9eb2b917d7d642143719e3 100644 (file)
 
 #include "assert.h"
 
-#define RECT_SIZE       100
-#define ART_SIZE        64
-#define OFFSET          (100-64)/2
-#define ITEMS_SPACING   10
+#define RECT_SIZE           100
+#define ART_SIZE            64
+#define OFFSET              (100-64)/2
+#define ITEMS_SPACING       10
+#define ART_RADIUS          7
 
 void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
 {
@@ -62,8 +63,16 @@ void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewIt
 
     QRect artRect = option.rect.adjusted( OFFSET - 1, 0, - OFFSET, - OFFSET *2 );
     QPainterPath artRectPath;
-    artRectPath.addRoundedRect( artRect, 7, 7 );
+    artRectPath.addRoundedRect( artRect, ART_RADIUS, ART_RADIUS );
 
+    // Draw the drop shadow
+    painter->save();
+    painter->setOpacity( 0.7 );
+    painter->setBrush( QBrush( Qt::gray ) );
+    painter->drawRoundedRect( artRect.adjusted( 2, 2, 2, 2 ), ART_RADIUS, ART_RADIUS );
+    painter->restore();
+
+    // Draw the art pixmap
     painter->drawPixmap( artRect, pix );
     painter->setClipPath( artRectPath );
     painter->drawPixmap( artRect, pix );