KSvg
framesvg.cpp
318 return rect.adjusted(d->frame->leftMargin, d->frame->topMargin, -d->frame->rightMargin, -d->frame->bottomMargin);
461 const QString maskRequestedPrefix = requestedPrefix.isEmpty() ? QStringLiteral("mask") : maskPrefix % requestedPrefix;
493FrameSvgPrivate::lookupOrCreateMaskFrame(const QSharedPointer<FrameData> &frame, const QString &maskPrefix, const QString &maskRequestedPrefix)
529 const bool overlayAvailable = !frame->prefix.startsWith(QLatin1String("mask-")) && q->hasElement(frame->prefix % QLatin1String("overlay"));
532 frameCached = q->imageSet()->d->findInCache(QString::number(id), frame->cachedBackground, frame->lastModified) && !frame->cachedBackground.isNull();
538 const size_t overlayId = qHash(cacheId(frame.data(), frame->prefix % QLatin1String("overlay")));
539 overlayCached = q->imageSet()->d->findInCache(QString::number(overlayId), overlay, frame->lastModified) && !overlay.isNull();
581 overlayPainter.drawTiledPixmap(QRectF(QPointF(0, 0), overlaySize), q->pixmap(frame->prefix % QLatin1String("overlay")));
584 q->paint(&overlayPainter, QRectF(actualOverlayPos, overlaySize), frame->prefix % QLatin1String("overlay"));
613 qCWarning(LOG_KSVG) << "Not generating frame background for a size whose width or height is more than" << MAX_FRAME_SIZE << size;
634 paintBorder(p, frame, FrameSvg::LeftBorder, QSizeF(frame->leftWidth, leftHeight) * q->devicePixelRatio(), contentRect);
636 paintBorder(p, frame, FrameSvg::RightBorder, QSizeF(frame->rightWidth, rightHeight) * q->devicePixelRatio(), contentRect);
639 paintBorder(p, frame, FrameSvg::TopBorder, QSizeF(topWidth, frame->topHeight) * q->devicePixelRatio(), contentRect);
641 paintBorder(p, frame, FrameSvg::BottomBorder, QSizeF(bottomWidth, frame->bottomHeight) * q->devicePixelRatio(), contentRect);
648QRectF FrameSvgPrivate::contentGeometry(const QSharedPointer<FrameData> &frame, const QSizeF &size) const
650 const QSizeF contentSize(size.width() - frame->leftWidth * q->devicePixelRatio() - frame->rightWidth * q->devicePixelRatio(),
651 size.height() - frame->topHeight * q->devicePixelRatio() - frame->bottomHeight * q->devicePixelRatio());
653 if (frame->enabledBorders & FrameSvg::LeftBorder && q->hasElement(frame->prefix % QLatin1String("left"))) {
658 if (frame->enabledBorders & FrameSvg::TopBorder && q->hasElement(frame->prefix % QLatin1String("top"))) {
731void FrameSvgPrivate::paintCenter(QPainter &p, const QSharedPointer<FrameData> &frame, const QRectF &contentRect, const QSizeF &fullSize)
748 p.drawTiledPixmap(FrameSvgHelpers::sectionRect(FrameSvg::NoBorder, contentRect, fullSize * q->devicePixelRatio()), center);
754 q->paint(&p, FrameSvgHelpers::sectionRect(FrameSvg::NoBorder, contentRect, fullSize * q->devicePixelRatio()), centerElementId);
761 p.drawPixmap(QRectF(QPointF(0, 0), fullSize), alphaMask(), QRectF(QPointF(0, 0), alphaMask().size()));
776 q->paint(&p, FrameSvgHelpers::sectionRect(borders, contentRect, frame->frameSize * q->devicePixelRatio()), side);
785 // A QRect as we have to exactly fill a QPixmap of integer size, prefer going slightly outside it to not have empty edges in the pixmap to tile
790 auto r = FrameSvgHelpers::sectionRect(borders, contentRect, frame->frameSize * q->devicePixelRatio());
799void FrameSvgPrivate::paintCorner(QPainter &p, const QSharedPointer<FrameData> &frame, KSvg::FrameSvg::EnabledBorders border, const QRectF &contentRect) const
808 auto r = FrameSvgHelpers::sectionRect(border, contentRect, frame->frameSize * q->devicePixelRatio());
817SvgPrivate::CacheId FrameSvgPrivate::cacheId(FrameData *frame, const QString &prefixToSave) const
832void FrameSvgPrivate::cacheFrame(const QString &prefixToSave, const QPixmap &background, const QPixmap &overlay)
847 q->imageSet()->d->insertIntoCache(QString::number(id), background, QString::number((qint64)q, 16) % prefixToSave);
851 const size_t overlayId = qHash(cacheId(frame.data(), frame->prefix % QLatin1String("overlay")));
852 q->imageSet()->d->insertIntoCache(QString::number(overlayId), overlay, QString::number((qint64)q, 16) % prefixToSave % QLatin1String("overlay"));
932 if (auto rightMargin = q->elementRect(createName(u"hint-right-margin")); rightMargin.isValid()) {
953 if (auto bottomMargin = q->elementRect(createName(u"hint-bottom-margin")); bottomMargin.isValid()) {
966 if (auto bottomInset = q->elementRect(createName(u"hint-bottom-inset")); bottomInset.isValid()) {
977 frame->composeOverBorder = (q->hasElement(createName(u"hint-compose-over-border")) && q->hasElement(maskPrefix % createName(u"center")));
981 frame->tileCenter = (q->hasElement(hintTileCenter) || q->hasElement(createName(u"hint-tile-center")));
982 frame->noBorderPadding = (q->hasElement(hintNoBorderPadding) || q->hasElement(createName(u"hint-no-border-padding")));
983 frame->stretchBorders = (q->hasElement(hintStretchBorders) || q->hasElement(createName(u"hint-stretch-borders")));
Q_INVOKABLE bool hasElementPrefix(const QString &prefix) const
This method returns whether the SVG has the necessary elements with the given prefix to draw a frame.
Definition framesvg.cpp:130
Q_INVOKABLE QRectF contentsRect() const
This method returns the rectangle of the center element, taking the margins into account.
Definition framesvg.cpp:314
bool isRepaintBlocked() const
This method returns whether we are in a transaction of many changes at once.
Definition framesvg.cpp:1027
Q_INVOKABLE void paintFrame(QPainter *painter, const QRectF &target, const QRectF &source=QRectF())
This method paints the loaded SVG with the elements that represents the border.
Definition framesvg.cpp:401
Q_INVOKABLE int minimumDrawingHeight()
This method returns the minimum height required to correctly draw this SVG.
Definition framesvg.cpp:425
Q_INVOKABLE void setCacheAllRenderedFrames(bool cache)
This method sets whether saving all the rendered prefixes in a cache or not.
Definition framesvg.cpp:366
Q_INVOKABLE int minimumDrawingWidth()
This method returns the minimum width required to correctly draw this SVG.
Definition framesvg.cpp:433
Q_INVOKABLE qreal marginSize(const FrameSvg::MarginEdge edge) const
This method returns the margin size for the given edge.
Definition framesvg.cpp:197
QString actualPrefix() const
This method returns the prefix that is actually being used (including a '-' at the end if not empty).
Definition framesvg.cpp:1022
void setRepaintBlocked(bool blocked)
This method sets whether we should block rebuilding generated graphics for each change made.
Definition framesvg.cpp:1032
Q_INVOKABLE QRegion mask() const
This method returns a mask that tightly contains the fully opaque areas of the SVG.
Definition framesvg.cpp:330
Q_INVOKABLE void getInset(qreal &left, qreal &top, qreal &right, qreal &bottom) const
This is a convenience method that extracts the size of the four inset margins and saves their size in...
Definition framesvg.cpp:301
void setEnabledBorders(const EnabledBorders borders)
This method sets which borders should be painted.
Definition framesvg.cpp:70
Q_INVOKABLE qreal insetSize(const FrameSvg::MarginEdge edge) const
This method returns the insets margin size for the specified edge.
Definition framesvg.cpp:223
Q_INVOKABLE void getMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const
This is a convenience method that extracts the size of the four margins and saves their size into the...
Definition framesvg.cpp:275
Q_INVOKABLE QString prefix()
This method returns the prefix for SVG elements of the FrameSvg (including a '-' at the end if not em...
Definition framesvg.cpp:160
Q_INVOKABLE void setElementPrefix(KSvg::FrameSvg::LocationPrefix location)
This method sets the prefix (.
Definition framesvg.cpp:88
Q_INVOKABLE void setImagePath(const QString &path) override
Loads a new Svg.
Definition framesvg.cpp:55
Q_INVOKABLE QPixmap framePixmap()
This method returns a pixmap of the SVG represented by this object.
Definition framesvg.cpp:392
Q_INVOKABLE void getFixedMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const
This is a convenience method that extracts the size of the four margins and saves their size into the...
Definition framesvg.cpp:288
QPixmap alphaMask() const
This method returns a pixmap whose alpha channel is the opacity of the frame.
Definition framesvg.cpp:324
Q_INVOKABLE void resizeFrame(const QSizeF &size)
This method resizes the frame, maintaining the same border size.
Definition framesvg.cpp:165
Q_INVOKABLE qreal fixedMarginSize(const FrameSvg::MarginEdge edge) const
This method returns the margin size for the specified edge.
Definition framesvg.cpp:249
Q_INVOKABLE bool cacheAllRenderedFrames() const
This method returns whether all the different prefixes should be kept in a cache when rendered.
Definition framesvg.cpp:375
void setContainsMultipleImages(bool multiple)
This method sets whether the SVG contains a single image or multiple ones.
Definition svg.cpp:1029
void repaintNeeded()
This signal is emitted whenever the SVG data has changed in such a way that a repaint is required.
Q_INVOKABLE bool hasElement(const QString &elementId) const
This method checks whether an element exists in the loaded SVG.
Definition svg.cpp:996
KTEXTEDITOR_EXPORT size_t qHash(KTextEditor::Cursor cursor, size_t seed=0) noexcept
iterator insert(const Key &key, const T &value)
bool remove(const Key &key)
T value(const Key &key) const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
CompositionMode_SourceIn
SmoothPixmapTransform
void drawPixmap(const QPoint &point, const QPixmap &pixmap)
void drawTiledPixmap(const QRect &rectangle, const QPixmap &pixmap, const QPoint &position)
void setCompositionMode(CompositionMode mode)
qreal devicePixelRatio() const const
bool hasAlphaChannel() const const
int height() const const
bool isNull() const const
QBitmap mask() const const
QRect rect() const const
QPixmap scaled(const QSize &size, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const const
void setDevicePixelRatio(qreal scaleFactor)
int width() const const
void setX(qreal x)
void setY(qreal y)
QRectF adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const const
bool isEmpty() const const
bool isValid() const const
void translate(const QPointF &offset)
int height() const const
int width() const const
qreal height() const const
bool isEmpty() const const
bool isValid() const const
void setHeight(qreal height)
void setWidth(qreal width)
QSize toSize() const const
qreal width() const const
QString & append(QChar ch)
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
bool isNull() const const
qsizetype length() const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
void reserve(qsizetype size)
QStringView mid(qsizetype start, qsizetype length) const const
transparent
QTextStream & center(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:13:51 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:13:51 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.