Merge branch 'master' into davidedmundson/framesvg_native

This commit is contained in:
Aleix Pol 2014-07-14 18:52:51 +02:00
commit f9d1bb3452
2 changed files with 26 additions and 31 deletions

View File

@ -807,49 +807,43 @@ void FrameSvgPrivate::generateFrameBackground(FrameData *frame)
return; return;
} }
const QSize contentSize(size.width() - frame->leftWidth - frame->rightWidth, size.height() - frame->topHeight - frame->bottomHeight);
frame->cachedBackground = QPixmap(size); frame->cachedBackground = QPixmap(size);
frame->cachedBackground.fill(Qt::transparent); frame->cachedBackground.fill(Qt::transparent);
QPainter p(&frame->cachedBackground); QPainter p(&frame->cachedBackground);
p.setCompositionMode(QPainter::CompositionMode_Source); p.setCompositionMode(QPainter::CompositionMode_Source);
p.setRenderHint(QPainter::SmoothPixmapTransform); p.setRenderHint(QPainter::SmoothPixmapTransform);
paintCenter(p, frame, contentSize, size); QRect contentRect = contentGeometry(frame, size);
paintCenter(p, frame, contentRect.size(), size);
int contentTop = 0; paintCorner(p, frame, FrameSvg::LeftBorder|FrameSvg::TopBorder, QRect(QPoint(0, 0), QSize(frame->leftWidth, frame->topHeight)));
int contentLeft = 0; paintCorner(p, frame, FrameSvg::RightBorder|FrameSvg::TopBorder, QRect(QPoint(contentRect.right(), 0), QSize(frame->rightWidth, frame->topHeight)));
int rightOffset = contentSize.width(); paintCorner(p, frame, FrameSvg::LeftBorder|FrameSvg::BottomBorder, QRect(QPoint(0, contentRect.bottom()), QSize(frame->leftWidth, frame->bottomHeight)));
int bottomOffset = contentSize.height(); paintCorner(p, frame, FrameSvg::RightBorder|FrameSvg::BottomBorder, QRect(contentRect.bottomRight(), QSize(frame->rightWidth, frame->bottomHeight)));
if (frame->enabledBorders & FrameSvg::LeftBorder && q->hasElement(prefix % "left")) {
rightOffset += frame->leftWidth;
}
// Corners
if (frame->enabledBorders & FrameSvg::TopBorder) {
contentTop = frame->topHeight;
bottomOffset += frame->topHeight;
}
if (frame->enabledBorders & FrameSvg::LeftBorder) {
contentLeft = frame->leftWidth;
}
const int topOffset = 0;
const int leftOffset = 0;
paintCorner(p, frame, FrameSvg::LeftBorder|FrameSvg::TopBorder, QRect(leftOffset, topOffset, frame->leftWidth, frame->topHeight));
paintCorner(p, frame, FrameSvg::RightBorder|FrameSvg::TopBorder, QRect(rightOffset, topOffset, frame->rightWidth, frame->topHeight));
paintCorner(p, frame, FrameSvg::LeftBorder|FrameSvg::BottomBorder, QRect(leftOffset, bottomOffset, frame->leftWidth, frame->bottomHeight));
paintCorner(p, frame, FrameSvg::RightBorder|FrameSvg::BottomBorder, QRect(rightOffset, bottomOffset, frame->rightWidth, frame->bottomHeight));
// Sides // Sides
const int leftHeight = q->elementSize(prefix % "left").height(); const int leftHeight = q->elementSize(prefix % "left").height();
paintBorder(p, frame, FrameSvg::LeftBorder, QSize(frame->leftWidth, leftHeight), QRect(leftOffset, contentTop, frame->leftWidth, contentSize.height())); paintBorder(p, frame, FrameSvg::LeftBorder, QSize(frame->leftWidth, leftHeight), QRect(QPoint(0, contentRect.top()), QSize(frame->leftWidth, contentRect.height())));
paintBorder(p, frame, FrameSvg::RightBorder, QSize(frame->rightWidth, leftHeight), QRect(rightOffset, contentTop, frame->rightWidth, contentSize.height())); paintBorder(p, frame, FrameSvg::RightBorder, QSize(frame->rightWidth, leftHeight), QRect(contentRect.topRight(), QSize(frame->rightWidth, contentRect.height())));
const int topWidth = q->elementSize(prefix % "top").width(); const int topWidth = q->elementSize(prefix % "top").width();
paintBorder(p, frame, FrameSvg::TopBorder, QSize(topWidth, frame->topHeight), QRect(contentLeft, topOffset, contentSize.width(), frame->topHeight)); paintBorder(p, frame, FrameSvg::TopBorder, QSize(topWidth, frame->topHeight), QRect(QPoint(contentRect.left(), 0), QSize(contentRect.width(), frame->topHeight)));
paintBorder(p, frame, FrameSvg::BottomBorder, QSize(topWidth, frame->bottomHeight), QRect(contentLeft, bottomOffset, contentSize.width(), frame->bottomHeight)); paintBorder(p, frame, FrameSvg::BottomBorder, QSize(topWidth, frame->bottomHeight), QRect(contentRect.bottomLeft(), QSize(contentRect.width(), frame->bottomHeight)));
}
QRect FrameSvgPrivate::contentGeometry(FrameData* frame, const QSize& size) const
{
const QSize contentSize(size.width() - frame->leftWidth - frame->rightWidth, size.height() - frame->topHeight - frame->bottomHeight);
QRect contentRect(QPoint(0,0), contentSize);
if (frame->enabledBorders & FrameSvg::LeftBorder && q->hasElement(prefix % "left")) {
contentRect.translate(frame->leftWidth, 0);
}
// Corners
if (frame->enabledBorders & FrameSvg::TopBorder && q->hasElement(prefix % "top")) {
contentRect.translate(0, frame->topHeight);
}
return contentRect;
} }
void FrameSvgPrivate::paintCenter(QPainter& p, FrameData* frame, const QSize& contentSize, const QSize& fullSize) void FrameSvgPrivate::paintCenter(QPainter& p, FrameData* frame, const QSize& contentSize, const QSize& fullSize)

View File

@ -152,6 +152,7 @@ public:
void paintCorner(QPainter& p, FrameData* frame, Plasma::FrameSvg::EnabledBorders border, const QRect& output) const; void paintCorner(QPainter& p, FrameData* frame, Plasma::FrameSvg::EnabledBorders border, const QRect& output) const;
void paintCenter(QPainter& p, FrameData* frame, const QSize& contentSize, const QSize& fullSize); void paintCenter(QPainter& p, FrameData* frame, const QSize& contentSize, const QSize& fullSize);
static QString borderToElementId(Plasma::FrameSvg::EnabledBorders borders); static QString borderToElementId(Plasma::FrameSvg::EnabledBorders borders);
QRect contentGeometry(FrameData* frame, const QSize& size) const;
Types::Location location; Types::Location location;
QString prefix; QString prefix;