QskInterval::center(), QskInterval::stretch removed as they the
implementation is only handling normalized intervals
This commit is contained in:
parent
494c370e61
commit
ea3d7a5e69
@ -36,8 +36,6 @@ class QSK_EXPORT QskIntervalF
|
|||||||
constexpr qreal upperBound() const noexcept;
|
constexpr qreal upperBound() const noexcept;
|
||||||
void setUpperBound( qreal ) noexcept;
|
void setUpperBound( qreal ) noexcept;
|
||||||
|
|
||||||
constexpr qreal center() const noexcept;
|
|
||||||
|
|
||||||
void spanFromLowerBound( qreal ) noexcept;
|
void spanFromLowerBound( qreal ) noexcept;
|
||||||
void spanFromUpperBound( qreal ) noexcept;
|
void spanFromUpperBound( qreal ) noexcept;
|
||||||
|
|
||||||
@ -68,9 +66,6 @@ class QSK_EXPORT QskIntervalF
|
|||||||
void extend( qreal value ) noexcept;
|
void extend( qreal value ) noexcept;
|
||||||
QskIntervalF extended( qreal value ) const noexcept;
|
QskIntervalF extended( qreal value ) const noexcept;
|
||||||
|
|
||||||
void stretch( qreal length ) noexcept;
|
|
||||||
constexpr QskIntervalF stretched( qreal length ) const noexcept;
|
|
||||||
|
|
||||||
QskIntervalF operator|( const QskIntervalF& ) const noexcept;
|
QskIntervalF operator|( const QskIntervalF& ) const noexcept;
|
||||||
QskIntervalF operator&( const QskIntervalF& ) const noexcept;
|
QskIntervalF operator&( const QskIntervalF& ) const noexcept;
|
||||||
|
|
||||||
@ -140,11 +135,6 @@ inline constexpr qreal QskIntervalF::upperBound() const noexcept
|
|||||||
return m_upperBound;
|
return m_upperBound;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr qreal QskIntervalF::center() const noexcept
|
|
||||||
{
|
|
||||||
return m_lowerBound + 0.5 * ( m_upperBound - m_lowerBound );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr qreal QskIntervalF::length() const noexcept
|
inline constexpr qreal QskIntervalF::length() const noexcept
|
||||||
{
|
{
|
||||||
return ( m_upperBound > m_lowerBound ) ? ( m_upperBound - m_lowerBound ) : 0.0;
|
return ( m_upperBound > m_lowerBound ) ? ( m_upperBound - m_lowerBound ) : 0.0;
|
||||||
@ -208,18 +198,6 @@ inline constexpr QskIntervalF QskIntervalF::normalized( qreal value1, qreal valu
|
|||||||
return ( value1 < value2 ) ? QskIntervalF( value1, value2 ) : QskIntervalF( value2, value1 );
|
return ( value1 < value2 ) ? QskIntervalF( value1, value2 ) : QskIntervalF( value2, value1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QskIntervalF::stretch( qreal length ) noexcept
|
|
||||||
{
|
|
||||||
m_lowerBound = center() - 0.5 * length;
|
|
||||||
m_upperBound = m_lowerBound + length;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr QskIntervalF QskIntervalF::stretched( qreal length ) const noexcept
|
|
||||||
{
|
|
||||||
const auto lowerBound = center() - 0.5 * length;
|
|
||||||
return QskIntervalF( lowerBound, lowerBound + length );
|
|
||||||
}
|
|
||||||
|
|
||||||
inline QskIntervalF QskIntervalF::operator&( const QskIntervalF& other ) const noexcept
|
inline QskIntervalF QskIntervalF::operator&( const QskIntervalF& other ) const noexcept
|
||||||
{
|
{
|
||||||
return intersected( other );
|
return intersected( other );
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
#include "QskSliderSkinlet.h"
|
#include "QskSliderSkinlet.h"
|
||||||
#include "QskSlider.h"
|
#include "QskSlider.h"
|
||||||
#include "QskFunctions.h"
|
#include "QskFunctions.h"
|
||||||
#include "QskIntervalF.h"
|
|
||||||
|
|
||||||
#include <qvector.h>
|
#include <qvector.h>
|
||||||
|
#include <qpair.h>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
|
||||||
// the color of graduation ticks might different, when being on top of the filling
|
// the color of graduation ticks might different, when being on top of the filling
|
||||||
@ -65,6 +65,19 @@ static inline bool qskHasGraduation( const QskSlider* slider )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline QPair< qreal, qreal > qskTickSpan( qreal min, qreal max, qreal length )
|
||||||
|
{
|
||||||
|
if ( length >= 0.0 )
|
||||||
|
{
|
||||||
|
// using the center of [min,max]
|
||||||
|
min += 0.5 * ( max - min - length );
|
||||||
|
max = min + length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { min, max };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QskSliderSkinlet::QskSliderSkinlet( QskSkin* skin )
|
QskSliderSkinlet::QskSliderSkinlet( QskSkin* skin )
|
||||||
: Inherited( skin )
|
: Inherited( skin )
|
||||||
{
|
{
|
||||||
@ -285,23 +298,21 @@ QRectF QskSliderSkinlet::tickRect( const QskSlider* slider,
|
|||||||
{
|
{
|
||||||
const auto x = tickPos * r.width() - 0.5 * size.width();
|
const auto x = tickPos * r.width() - 0.5 * size.width();
|
||||||
|
|
||||||
QskIntervalF intv( padding.top(), r.height() - padding.bottom() );
|
const auto span = qskTickSpan(
|
||||||
if ( size.height() >= 0.0 )
|
padding.top(), r.height() - padding.bottom(), size.height() );
|
||||||
intv.stretch( size.height() );
|
|
||||||
|
|
||||||
return QRectF( r.x() + x, r.y() + intv.lowerBound(),
|
return QRectF( r.x() + x, r.y() + span.first,
|
||||||
size.width(), intv.length() );
|
size.width(), span.second - span.first );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto y = tickPos * r.height() + 0.5 * size.height();
|
const auto y = tickPos * r.height() + 0.5 * size.height();
|
||||||
|
|
||||||
QskIntervalF intv( padding.left(), r.width() - padding.right() );
|
const auto span = qskTickSpan(
|
||||||
if ( size.width() >= 0.0 )
|
padding.left(), r.width() - padding.right(), size.width() );
|
||||||
intv.stretch( size.width() );
|
|
||||||
|
|
||||||
return QRectF( r.x() + intv.lowerBound(), r.bottom() - y,
|
return QRectF( r.x() + span.first, r.bottom() - y,
|
||||||
intv.length(), size.height() );
|
span.second - span.first, size.height() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user