qskinny/src/common/QskFunctions.h

63 lines
1.8 KiB
C
Raw Normal View History

2017-07-21 16:21:34 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef QSK_FUNCTIONS_H
#define QSK_FUNCTIONS_H
#include "QskGlobal.h"
2018-07-19 12:10:48 +00:00
#include <qmargins.h>
#include <qrect.h>
2017-07-21 16:21:34 +00:00
2020-03-13 12:32:22 +00:00
class QFont;
class QFontMetricsF;
class QString;
2017-07-21 16:21:34 +00:00
QSK_EXPORT QRect qskAlignedRect( const QRect& outerRect,
int width, int height, Qt::Alignment alignment );
QSK_EXPORT QRectF qskAlignedRectF( const QRectF& outerRect,
qreal width, qreal height, Qt::Alignment alignment );
QSK_EXPORT QRect qskInnerRect( const QRectF& rect );
2019-04-10 17:37:59 +00:00
QSK_EXPORT QRectF qskInnerRectF( const QRectF& rect );
2017-07-21 16:21:34 +00:00
QSK_EXPORT QRectF qskValidOrEmptyInnerRect(
const QRectF& rect, const QMarginsF& margins );
2020-03-13 12:32:22 +00:00
QSK_EXPORT qreal qskHorizontalAdvance( const QFont&, const QString& );
QSK_EXPORT qreal qskHorizontalAdvance( const QFontMetricsF&, const QString& );
2021-12-29 14:30:44 +00:00
QSK_EXPORT QRectF qskInterpolatedRect(
const QRectF& from, const QRectF& to, qreal progress );
2022-01-04 12:46:54 +00:00
QSK_EXPORT QSizeF qskInterpolatedSize(
const QSizeF& from, const QSizeF& to, qreal progress );
2021-05-26 11:06:50 +00:00
inline QMarginsF qskMargins( const QRectF& rect, const QRectF& innerRect )
{
return QMarginsF(
innerRect.left() - rect.left(),
innerRect.top() - rect.top(),
rect.right() - innerRect.right(),
rect.bottom() - innerRect.bottom() );
}
2017-07-21 16:21:34 +00:00
inline bool qskFuzzyCompare( qreal value1, qreal value2 )
{
if ( qFuzzyIsNull( value1 ) )
return qFuzzyIsNull( value2 );
if ( qFuzzyIsNull( value2 ) )
return false;
return qFuzzyCompare( value1, value2 );
}
2021-05-26 11:06:50 +00:00
QSK_EXPORT qreal qskFuzzyFloor( qreal value, qreal stepSize );
QSK_EXPORT qreal qskFuzzyCeil( qreal value, qreal stepSize );
2017-07-21 16:21:34 +00:00
#endif