Move scaledRect,roundVector,flooredPoint to globals.h
This commit is contained in:
parent
bec9ffeacd
commit
0a2ed7d1c8
2 changed files with 28 additions and 27 deletions
|
@ -102,33 +102,6 @@ enum DataRole {
|
|||
WindowForceBackgroundContrastRole, ///< For fullscreen effects to enforce the background contrast,
|
||||
};
|
||||
|
||||
/**
|
||||
* Scale a rect by a scalar.
|
||||
*/
|
||||
KWIN_EXPORT inline QRectF scaledRect(const QRectF &rect, qreal scale)
|
||||
{
|
||||
return QRectF{rect.x() * scale, rect.y() * scale, rect.width() * scale, rect.height() * scale};
|
||||
}
|
||||
|
||||
/**
|
||||
* Round a vector to nearest integer.
|
||||
*/
|
||||
KWIN_EXPORT inline QVector2D roundVector(const QVector2D &input)
|
||||
{
|
||||
return QVector2D(std::round(input.x()), std::round(input.y()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a QPointF to a QPoint by flooring instead of rounding.
|
||||
*
|
||||
* By default, QPointF::toPoint() rounds which can cause problems in certain
|
||||
* cases.
|
||||
*/
|
||||
KWIN_EXPORT inline QPoint flooredPoint(const QPointF &point)
|
||||
{
|
||||
return QPoint(std::floor(point.x()), std::floor(point.y()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @short Manager class that handles all the effects.
|
||||
*
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <QImage>
|
||||
#include <QPoint>
|
||||
#include <QVariant>
|
||||
#include <QVector2D>
|
||||
|
||||
#include <kwin_export.h>
|
||||
|
||||
|
@ -237,6 +238,33 @@ inline KWIN_EXPORT QRect infiniteRegion()
|
|||
return QRect(INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale a rect by a scalar.
|
||||
*/
|
||||
KWIN_EXPORT inline QRectF scaledRect(const QRectF &rect, qreal scale)
|
||||
{
|
||||
return QRectF{rect.x() * scale, rect.y() * scale, rect.width() * scale, rect.height() * scale};
|
||||
}
|
||||
|
||||
/**
|
||||
* Round a vector to nearest integer.
|
||||
*/
|
||||
KWIN_EXPORT inline QVector2D roundVector(const QVector2D &input)
|
||||
{
|
||||
return QVector2D(std::round(input.x()), std::round(input.y()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a QPointF to a QPoint by flooring instead of rounding.
|
||||
*
|
||||
* By default, QPointF::toPoint() rounds which can cause problems in certain
|
||||
* cases.
|
||||
*/
|
||||
KWIN_EXPORT inline QPoint flooredPoint(const QPointF &point)
|
||||
{
|
||||
return QPoint(std::floor(point.x()), std::floor(point.y()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns if @a point is contained in @a rect, including the left and top borders
|
||||
* but excluding the right and bottom borders
|
||||
|
|
Loading…
Reference in a new issue