[FrameSvg*] Rename shadowMargins to inset

This commit is contained in:
Mikel Johnson 2020-11-25 20:39:12 +03:00 committed by Marco Martin
parent 2f7563d6eb
commit c8e563efa7
5 changed files with 63 additions and 63 deletions

View File

@ -168,7 +168,7 @@ FrameSvgItemMargins::FrameSvgItemMargins(Plasma::FrameSvg *frameSvg, QObject *pa
: QObject(parent), : QObject(parent),
m_frameSvg(frameSvg), m_frameSvg(frameSvg),
m_fixed(false), m_fixed(false),
m_shadow(false) m_inset(false)
{ {
//qDebug() << "margins at: " << left() << top() << right() << bottom(); //qDebug() << "margins at: " << left() << top() << right() << bottom();
} }
@ -177,8 +177,8 @@ qreal FrameSvgItemMargins::left() const
{ {
if (m_fixed) { if (m_fixed) {
return m_frameSvg->fixedMarginSize(Types::LeftMargin); return m_frameSvg->fixedMarginSize(Types::LeftMargin);
} else if(m_shadow){ } else if(m_inset){
return m_frameSvg->shadowMarginSize(Types::LeftMargin); return m_frameSvg->insetMarginSize(Types::LeftMargin);
} else { } else {
return m_frameSvg->marginSize(Types::LeftMargin); return m_frameSvg->marginSize(Types::LeftMargin);
} }
@ -188,8 +188,8 @@ qreal FrameSvgItemMargins::top() const
{ {
if (m_fixed) { if (m_fixed) {
return m_frameSvg->fixedMarginSize(Types::TopMargin); return m_frameSvg->fixedMarginSize(Types::TopMargin);
} else if(m_shadow){ } else if(m_inset){
return m_frameSvg->shadowMarginSize(Types::TopMargin); return m_frameSvg->insetMarginSize(Types::TopMargin);
} else { } else {
return m_frameSvg->marginSize(Types::TopMargin); return m_frameSvg->marginSize(Types::TopMargin);
} }
@ -199,8 +199,8 @@ qreal FrameSvgItemMargins::right() const
{ {
if (m_fixed) { if (m_fixed) {
return m_frameSvg->fixedMarginSize(Types::RightMargin); return m_frameSvg->fixedMarginSize(Types::RightMargin);
} else if(m_shadow){ } else if(m_inset){
return m_frameSvg->shadowMarginSize(Types::RightMargin); return m_frameSvg->insetMarginSize(Types::RightMargin);
} else { } else {
return m_frameSvg->marginSize(Types::RightMargin); return m_frameSvg->marginSize(Types::RightMargin);
} }
@ -210,8 +210,8 @@ qreal FrameSvgItemMargins::bottom() const
{ {
if (m_fixed) { if (m_fixed) {
return m_frameSvg->fixedMarginSize(Types::BottomMargin); return m_frameSvg->fixedMarginSize(Types::BottomMargin);
} else if(m_shadow){ } else if(m_inset){
return m_frameSvg->shadowMarginSize(Types::BottomMargin); return m_frameSvg->insetMarginSize(Types::BottomMargin);
} else { } else {
return m_frameSvg->marginSize(Types::BottomMargin); return m_frameSvg->marginSize(Types::BottomMargin);
} }
@ -254,26 +254,26 @@ bool FrameSvgItemMargins::isFixed() const
return m_fixed; return m_fixed;
} }
void FrameSvgItemMargins::setShadow(bool shadow) void FrameSvgItemMargins::setInset(bool inset)
{ {
if (shadow == m_shadow) { if (inset == m_inset) {
return; return;
} }
m_shadow = shadow; m_inset = inset;
emit marginsChanged(); emit marginsChanged();
} }
bool FrameSvgItemMargins::isShadow() const bool FrameSvgItemMargins::isInset() const
{ {
return m_shadow; return m_inset;
} }
FrameSvgItem::FrameSvgItem(QQuickItem *parent) FrameSvgItem::FrameSvgItem(QQuickItem *parent)
: QQuickItem(parent), : QQuickItem(parent),
m_margins(nullptr), m_margins(nullptr),
m_fixedMargins(nullptr), m_fixedMargins(nullptr),
m_shadowMargins(nullptr), m_insetMargins(nullptr),
m_textureChanged(false), m_textureChanged(false),
m_sizeChanged(false), m_sizeChanged(false),
m_fastPath(true) m_fastPath(true)
@ -320,7 +320,7 @@ void FrameSvgItem::setImagePath(const QString &path)
CheckMarginsChange checkMargins(m_oldMargins, m_margins); CheckMarginsChange checkMargins(m_oldMargins, m_margins);
CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins); CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins);
CheckMarginsChange checkShadowMargins(m_oldShadowMargins, m_shadowMargins); CheckMarginsChange checkInsetMargins(m_oldInsetMargins, m_insetMargins);
updateDevicePixelRatio(); updateDevicePixelRatio();
m_frameSvg->setImagePath(path); m_frameSvg->setImagePath(path);
@ -365,7 +365,7 @@ void FrameSvgItem::setPrefix(const QVariant &prefixes)
CheckMarginsChange checkMargins(m_oldMargins, m_margins); CheckMarginsChange checkMargins(m_oldMargins, m_margins);
CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins); CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins);
CheckMarginsChange checkShadowMargins(m_oldShadowMargins, m_shadowMargins); CheckMarginsChange checkInsetMargins(m_oldInsetMargins, m_insetMargins);
m_prefixes = prefixList; m_prefixes = prefixList;
applyPrefixes(); applyPrefixes();
@ -414,13 +414,13 @@ FrameSvgItemMargins *FrameSvgItem::fixedMargins()
return m_fixedMargins; return m_fixedMargins;
} }
FrameSvgItemMargins *FrameSvgItem::shadowMargins() FrameSvgItemMargins *FrameSvgItem::inset()
{ {
if (!m_shadowMargins) { if (!m_insetMargins) {
m_shadowMargins = new FrameSvgItemMargins(m_frameSvg, this); m_insetMargins = new FrameSvgItemMargins(m_frameSvg, this);
m_shadowMargins->setShadow(true); m_insetMargins->setInset(true);
} }
return m_shadowMargins; return m_insetMargins;
} }
void FrameSvgItem::setColorGroup(Plasma::Theme::ColorGroup group) void FrameSvgItem::setColorGroup(Plasma::Theme::ColorGroup group)
@ -510,7 +510,7 @@ void FrameSvgItem::doUpdate()
CheckMarginsChange checkMargins(m_oldMargins, m_margins); CheckMarginsChange checkMargins(m_oldMargins, m_margins);
CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins); CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins);
CheckMarginsChange checkShadowMargins(m_oldShadowMargins, m_shadowMargins); CheckMarginsChange checkInsetMargins(m_oldInsetMargins, m_insetMargins);
//if the theme changed, the available prefix may have changed as well //if the theme changed, the available prefix may have changed as well
applyPrefixes(); applyPrefixes();
@ -655,7 +655,7 @@ void FrameSvgItem::componentComplete()
{ {
CheckMarginsChange checkMargins(m_oldMargins, m_margins); CheckMarginsChange checkMargins(m_oldMargins, m_margins);
CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins); CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins);
CheckMarginsChange checkShadowMargins(m_oldShadowMargins, m_shadowMargins); CheckMarginsChange checkInsetMargins(m_oldInsetMargins, m_insetMargins);
QQuickItem::componentComplete(); QQuickItem::componentComplete();
m_frameSvg->resizeFrame(QSize(width(), height())); m_frameSvg->resizeFrame(QSize(width(), height()));

View File

@ -75,8 +75,8 @@ public:
void setFixed(bool fixed); void setFixed(bool fixed);
bool isFixed() const; bool isFixed() const;
void setShadow(bool shadow); void setInset(bool inset);
bool isShadow() const; bool isInset() const;
public Q_SLOTS: public Q_SLOTS:
void update(); void update();
@ -87,7 +87,7 @@ Q_SIGNALS:
private: private:
FrameSvg *m_frameSvg; FrameSvg *m_frameSvg;
bool m_fixed; bool m_fixed;
bool m_shadow; bool m_inset;
}; };
@ -139,12 +139,12 @@ class FrameSvgItem : public QQuickItem
Q_PROPERTY(QObject *fixedMargins READ fixedMargins CONSTANT) Q_PROPERTY(QObject *fixedMargins READ fixedMargins CONSTANT)
/** /**
* The margins of the shadow * The margins of the inset
* read only * read only
* @see FrameSvgItemMargins * @see FrameSvgItemMargins
* @since 5.77 * @since 5.77
*/ */
Q_PROPERTY(QObject *shadowMargins READ shadowMargins CONSTANT) Q_PROPERTY(QObject *inset READ inset CONSTANT)
/** /**
* The borders that will be rendered, it's a flag combination of: * The borders that will be rendered, it's a flag combination of:
@ -212,7 +212,7 @@ public:
FrameSvgItemMargins *margins(); FrameSvgItemMargins *margins();
FrameSvgItemMargins *fixedMargins(); FrameSvgItemMargins *fixedMargins();
FrameSvgItemMargins *shadowMargins(); FrameSvgItemMargins *inset();
void setColorGroup(Plasma::Theme::ColorGroup group); void setColorGroup(Plasma::Theme::ColorGroup group);
Plasma::Theme::ColorGroup colorGroup() const; Plasma::Theme::ColorGroup colorGroup() const;
@ -263,11 +263,11 @@ private:
Plasma::FrameSvg *m_frameSvg; Plasma::FrameSvg *m_frameSvg;
FrameSvgItemMargins *m_margins; FrameSvgItemMargins *m_margins;
FrameSvgItemMargins *m_fixedMargins; FrameSvgItemMargins *m_fixedMargins;
FrameSvgItemMargins *m_shadowMargins; FrameSvgItemMargins *m_insetMargins;
// logged margins to check for changes // logged margins to check for changes
QVector<qreal> m_oldMargins; QVector<qreal> m_oldMargins;
QVector<qreal> m_oldFixedMargins; QVector<qreal> m_oldFixedMargins;
QVector<qreal> m_oldShadowMargins; QVector<qreal> m_oldInsetMargins;
QStringList m_prefixes; QStringList m_prefixes;
bool m_textureChanged; bool m_textureChanged;
bool m_sizeChanged; bool m_sizeChanged;

View File

@ -218,7 +218,7 @@ qreal FrameSvg::marginSize(const Plasma::Types::MarginEdge edge) const
} }
} }
qreal FrameSvg::shadowMarginSize(const Plasma::Types::MarginEdge edge) const qreal FrameSvg::insetMarginSize(const Plasma::Types::MarginEdge edge) const
{ {
if (!d->frame) { if (!d->frame) {
return .0; return .0;
@ -230,17 +230,17 @@ qreal FrameSvg::shadowMarginSize(const Plasma::Types::MarginEdge edge) const
switch (edge) { switch (edge) {
case Plasma::Types::TopMargin: case Plasma::Types::TopMargin:
return d->frame->shadowTopMargin; return d->frame->insetTopMargin;
case Plasma::Types::LeftMargin: case Plasma::Types::LeftMargin:
return d->frame->shadowLeftMargin; return d->frame->insetLeftMargin;
case Plasma::Types::RightMargin: case Plasma::Types::RightMargin:
return d->frame->shadowRightMargin; return d->frame->insetRightMargin;
//Plasma::BottomMargin //Plasma::BottomMargin
default: default:
return d->frame->shadowBottomMargin; return d->frame->insetBottomMargin;
} }
} }
@ -296,17 +296,17 @@ void FrameSvg::getFixedMargins(qreal &left, qreal &top, qreal &right, qreal &bot
bottom = d->frame->fixedBottomMargin; bottom = d->frame->fixedBottomMargin;
} }
void FrameSvg::getShadowMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const void FrameSvg::getInsetMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const
{ {
if (!d->frame || d->frame->noBorderPadding) { if (!d->frame || d->frame->noBorderPadding) {
left = top = right = bottom = 0; left = top = right = bottom = 0;
return; return;
} }
top = d->frame->shadowTopMargin; top = d->frame->insetTopMargin;
left = d->frame->shadowLeftMargin; left = d->frame->insetLeftMargin;
right = d->frame->shadowRightMargin; right = d->frame->insetRightMargin;
bottom = d->frame->shadowBottomMargin; bottom = d->frame->insetBottomMargin;
} }
QRectF FrameSvg::contentsRect() const QRectF FrameSvg::contentsRect() const
@ -810,10 +810,10 @@ void FrameSvgPrivate::updateSizes(FrameData *frame) const
frame->topMargin = frame->topHeight = 0; frame->topMargin = frame->topHeight = 0;
} }
if (q->hasElement(frame->prefix % QLatin1String("hint-shadow-top-margin"))) { if (q->hasElement(frame->prefix % QLatin1String("hint-inset-top-margin"))) {
frame->shadowTopMargin = q->elementSize(frame->prefix % QLatin1String("hint-shadow-top-margin")).height(); frame->insetTopMargin = q->elementSize(frame->prefix % QLatin1String("hint-inset-top-margin")).height();
} else { } else {
frame->shadowTopMargin = 0; frame->insetTopMargin = -1;
} }
frame->fixedLeftWidth = q->elementSize(frame->prefix % QLatin1String("left")).width(); frame->fixedLeftWidth = q->elementSize(frame->prefix % QLatin1String("left")).width();
@ -831,10 +831,10 @@ void FrameSvgPrivate::updateSizes(FrameData *frame) const
frame->leftMargin = frame->leftWidth = 0; frame->leftMargin = frame->leftWidth = 0;
} }
if (q->hasElement(frame->prefix % QLatin1String("hint-shadow-left-margin"))) { if (q->hasElement(frame->prefix % QLatin1String("hint-inset-left-margin"))) {
frame->shadowLeftMargin = q->elementSize(frame->prefix % QLatin1String("hint-shadow-left-margin")).width(); frame->insetLeftMargin = q->elementSize(frame->prefix % QLatin1String("hint-inset-left-margin")).width();
} else { } else {
frame->shadowLeftMargin = 0; frame->insetLeftMargin = -1;
} }
frame->fixedRightWidth = q->elementSize(frame->prefix % QLatin1String("right")).width(); frame->fixedRightWidth = q->elementSize(frame->prefix % QLatin1String("right")).width();
@ -852,10 +852,10 @@ void FrameSvgPrivate::updateSizes(FrameData *frame) const
frame->rightMargin = frame->rightWidth = 0; frame->rightMargin = frame->rightWidth = 0;
} }
if (q->hasElement(frame->prefix % QLatin1String("hint-shadow-right-margin"))) { if (q->hasElement(frame->prefix % QLatin1String("hint-inset-right-margin"))) {
frame->shadowRightMargin = q->elementSize(frame->prefix % QLatin1String("hint-shadow-right-margin")).width(); frame->insetRightMargin = q->elementSize(frame->prefix % QLatin1String("hint-inset-right-margin")).width();
} else { } else {
frame->shadowRightMargin = 0; frame->insetRightMargin = -1;
} }
frame->fixedBottomHeight = q->elementSize(frame->prefix % QLatin1String("bottom")).height(); frame->fixedBottomHeight = q->elementSize(frame->prefix % QLatin1String("bottom")).height();
@ -873,10 +873,10 @@ void FrameSvgPrivate::updateSizes(FrameData *frame) const
frame->bottomMargin = frame->bottomHeight = 0; frame->bottomMargin = frame->bottomHeight = 0;
} }
if (q->hasElement(frame->prefix % QLatin1String("hint-shadow-bottom-margin"))) { if (q->hasElement(frame->prefix % QLatin1String("hint-inset-bottom-margin"))) {
frame->shadowBottomMargin = q->elementSize(frame->prefix % QLatin1String("hint-shadow-bottom-margin")).height(); frame->insetBottomMargin = q->elementSize(frame->prefix % QLatin1String("hint-inset-bottom-margin")).height();
} else { } else {
frame->shadowBottomMargin = 0; frame->insetBottomMargin = -1;
} }
frame->composeOverBorder = (q->hasElement(frame->prefix % QLatin1String("hint-compose-over-border")) && frame->composeOverBorder = (q->hasElement(frame->prefix % QLatin1String("hint-compose-over-border")) &&

View File

@ -163,15 +163,15 @@ public:
Q_INVOKABLE void getFixedMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const; Q_INVOKABLE void getFixedMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const;
/** /**
* Returns the shadows margin size given the margin edge we want. * Returns the insets margin size given the margin edge we want.
* @param edge the margin edge we want, top, bottom, left or right * @param edge the margin edge we want, top, bottom, left or right
* @return the margin size * @return the margin size
* @since 5.77 * @since 5.77
*/ */
Q_INVOKABLE qreal shadowMarginSize(const Plasma::Types::MarginEdge edge) const; Q_INVOKABLE qreal insetMarginSize(const Plasma::Types::MarginEdge edge) const;
/** /**
* Convenience method that extracts the size of the four shadow margins * Convenience method that extracts the size of the four inset margins
* in the four output parameters * in the four output parameters
* @param left left margin size * @param left left margin size
* @param top top margin size * @param top top margin size
@ -179,7 +179,7 @@ public:
* @param bottom bottom margin size * @param bottom bottom margin size
* @since 5.77 * @since 5.77
*/ */
Q_INVOKABLE void getShadowMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const; Q_INVOKABLE void getInsetMargins(qreal &left, qreal &top, qreal &right, qreal &bottom) const;
/** /**
* @return the rectangle of the center element, taking the margins into account. * @return the rectangle of the center element, taking the margins into account.

View File

@ -104,11 +104,11 @@ public:
int fixedRightMargin; int fixedRightMargin;
int fixedBottomMargin; int fixedBottomMargin;
//margins, we only have the hint for shadows //margins, we only have the hint for insets
int shadowTopMargin; int insetTopMargin;
int shadowLeftMargin; int insetLeftMargin;
int shadowRightMargin; int insetRightMargin;
int shadowBottomMargin; int insetBottomMargin;
qreal devicePixelRatio; qreal devicePixelRatio;