From aa33e4ade0e51062892e377869fc6acca45c6d12 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 6 May 2010 14:16:03 +0000 Subject: [PATCH] a new hint: hint-compose-over-border the centr element will be rendered as big as the image, cropped with the alpha mask and the borderssuperimposed over it. slightly slower but it's the only way to have radial gradients in the center element and have them rendered in a correct way svn path=/trunk/KDE/kdelibs/; revision=1123651 --- framesvg.cpp | 27 +++++++++++++++++++++++---- private/framesvg_p.h | 4 +++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/framesvg.cpp b/framesvg.cpp index f2b1dc7c1..177897253 100644 --- a/framesvg.cpp +++ b/framesvg.cpp @@ -526,17 +526,32 @@ void FrameSvgPrivate::generateFrameBackground(FrameData *frame) q->paint(¢erPainter, QRect(QPoint(0, 0), q->elementSize(prefix + "center")), prefix + "center"); } - p.drawTiledPixmap(QRect(frame->leftWidth, frame->topHeight, - contentWidth, contentHeight), center); + if (frame->composeOverBorder) { + p.drawTiledPixmap(QRect(QPoint(0, 0), size.toSize()), center); + } else { + p.drawTiledPixmap(QRect(frame->leftWidth, frame->topHeight, + contentWidth, contentHeight), center); + } } } else { if (contentHeight > 0 && contentWidth > 0) { - q->paint(&p, QRect(frame->leftWidth, frame->topHeight, - contentWidth, contentHeight), + if (frame->composeOverBorder) { + q->paint(&p, QRect(QPoint(0, 0), size.toSize()), prefix + "center"); + } else { + q->paint(&p, QRect(frame->leftWidth, frame->topHeight, + contentWidth, contentHeight), + prefix + "center"); + } } } + if (frame->composeOverBorder) { + p.setCompositionMode(QPainter::CompositionMode_DestinationIn); + p.drawPixmap(QRect(QPoint(0, 0), size.toSize()), alphaMask()); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + } + if (frame->enabledBorders & FrameSvg::LeftBorder && q->hasElement(prefix + "left")) { rightOffset += frame->leftWidth; } @@ -738,7 +753,11 @@ void FrameSvgPrivate::updateSizes() const frame->bottomMargin = frame->bottomHeight = 0; } + frame->composeOverBorder = (q->hasElement(prefix + "hint-compose-over-border") && + q->hasElement(prefix + "mask-center")); + //since it's rectangular, topWidth and bottomWidth must be the same + //the ones that don't have a prefix is for retrocompatibility frame->tileCenter = q->hasElement("hint-tile-center"); frame->noBorderPadding = q->hasElement("hint-no-border-padding"); frame->stretchBorders = q->hasElement("hint-stretch-borders"); diff --git a/private/framesvg_p.h b/private/framesvg_p.h index 2f66b2616..e51cddb89 100644 --- a/private/framesvg_p.h +++ b/private/framesvg_p.h @@ -58,7 +58,8 @@ public: bottomMargin(0), noBorderPadding(false), stretchBorders(false), - tileCenter(false) + tileCenter(false), + composeOverBorder(false) { } @@ -88,6 +89,7 @@ public: bool noBorderPadding : 1; bool stretchBorders : 1; bool tileCenter : 1; + bool composeOverBorder : 1; }; class FrameSvgPrivate