Allow tiled svg center element.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=783642
This commit is contained in:
parent
674d90f382
commit
4626ee4e45
23
svgpanel.cpp
23
svgpanel.cpp
@ -61,6 +61,7 @@ public:
|
|||||||
//element is contentWidth x contentHeight
|
//element is contentWidth x contentHeight
|
||||||
bool noBorderPadding : 1;
|
bool noBorderPadding : 1;
|
||||||
bool stretchBorders : 1;
|
bool stretchBorders : 1;
|
||||||
|
bool tileCenter : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
SvgPanel::SvgPanel(const QString& imagePath, QObject* parent)
|
SvgPanel::SvgPanel(const QString& imagePath, QObject* parent)
|
||||||
@ -199,6 +200,25 @@ void SvgPanel::Private::generateBackground()
|
|||||||
|
|
||||||
|
|
||||||
//CENTER
|
//CENTER
|
||||||
|
if (tileCenter) {
|
||||||
|
if (contentHeight > 0 && contentWidth > 0) {
|
||||||
|
int centerTileHeight;
|
||||||
|
int centerTileWidth;
|
||||||
|
centerTileHeight = background->elementSize("center").height();
|
||||||
|
centerTileWidth = background->elementSize("center").width();
|
||||||
|
QPixmap center(centerTileWidth, centerTileHeight);
|
||||||
|
center.fill(Qt::transparent);
|
||||||
|
|
||||||
|
{
|
||||||
|
QPainter centerPainter(¢er);
|
||||||
|
centerPainter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
|
background->paint(¢erPainter, QPoint(0, 0), "center");
|
||||||
|
}
|
||||||
|
|
||||||
|
p.drawTiledPixmap(QRect(contentLeft - leftWidth, contentTop - topHeight,
|
||||||
|
contentWidth + leftWidth*2, contentHeight + topHeight*2), center);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (contentHeight > 0 && contentWidth > 0) {
|
if (contentHeight > 0 && contentWidth > 0) {
|
||||||
QSizeF scaledSize = QSizeF(panelSize.width() -
|
QSizeF scaledSize = QSizeF(panelSize.width() -
|
||||||
(leftWidth + rightWidth) +
|
(leftWidth + rightWidth) +
|
||||||
@ -213,6 +233,8 @@ void SvgPanel::Private::generateBackground()
|
|||||||
"center");
|
"center");
|
||||||
background->resize();
|
background->resize();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Corners
|
// Corners
|
||||||
if (bFlags & DrawTopBorder) {
|
if (bFlags & DrawTopBorder) {
|
||||||
@ -373,6 +395,7 @@ void SvgPanel::updateSizes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//since it's rectangular, topWidth and bottomWidth must be the same
|
//since it's rectangular, topWidth and bottomWidth must be the same
|
||||||
|
d->tileCenter = d->background->elementExists("hint-tile-center");
|
||||||
d->noBorderPadding = d->background->elementExists("hint-no-border-padding");
|
d->noBorderPadding = d->background->elementExists("hint-no-border-padding");
|
||||||
d->stretchBorders = d->background->elementExists("hint-stretch-borders");
|
d->stretchBorders = d->background->elementExists("hint-stretch-borders");
|
||||||
emit repaintNeeded();
|
emit repaintNeeded();
|
||||||
|
Loading…
Reference in New Issue
Block a user