From ef04a254d7e2276263b1a07c1564d34303773c38 Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Tue, 18 Aug 2009 13:42:23 +0200 Subject: [PATCH] Cleaner code for active item background painting --- src/playlist/PrettyItemDelegate.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/playlist/PrettyItemDelegate.cpp b/src/playlist/PrettyItemDelegate.cpp index aa6fd88..9e0348d 100644 --- a/src/playlist/PrettyItemDelegate.cpp +++ b/src/playlist/PrettyItemDelegate.cpp @@ -183,18 +183,20 @@ QPointF PrettyItemDelegate::centerImage( const QPixmap& pixmap, const QRectF& re void PrettyItemDelegate::paintActiveOverlay( QPainter *painter, qreal x, qreal y, qreal w, qreal h ) const { QPalette palette; - QColor color2 = palette.color(QPalette::Highlight); + QColor highlightColor = palette.color(QPalette::Highlight); QColor backgroundColor = palette.color(QPalette::Base); - float animation = 0.5; - color2 = QColor::fromHsv( - color2.hue(), - (int)(backgroundColor.saturation()*(1.0f-animation)+color2.saturation()*animation), - (int)(backgroundColor.value()*(1.0f-animation)+color2.value()*animation) + const float animation = 0.25; + const int gradientRange = 16; + + QColor color2 = QColor::fromHsv( + highlightColor.hue(), + (int) (backgroundColor.saturation() * (1.0f - animation) + highlightColor.saturation() * animation), + (int) (backgroundColor.value() * (1.0f - animation) + highlightColor.value() * animation) ); QColor color1 = QColor::fromHsv( color2.hue(), - (color2.saturation() - 16 > 0) ? color2.saturation() - 16 : 0, - (color2.value() + 16 < 255) ? color2.value() + 16 : 255 + qMax(color2.saturation() - gradientRange, 0), + qMin(color2.value() + gradientRange, 255) ); QRect rect((int) x, (int) y, (int) w, (int) h); painter->save(); -- 2.39.5