diff --git a/src/common/QskGradientDirection.cpp b/src/common/QskGradientDirection.cpp index 7ca00e6b..cab879c4 100644 --- a/src/common/QskGradientDirection.cpp +++ b/src/common/QskGradientDirection.cpp @@ -18,12 +18,43 @@ Q_CONSTRUCTOR_FUNCTION( qskRegisterGradientDirection ) void QskLinearDirection::setOrientation( Qt::Orientation orientation ) noexcept { + m_x1 = m_y1 = 0.0; setStart( 0.0, 0.0 ); if ( orientation == Qt::Vertical ) - setStop( 0.0, 1.0 ); + { + m_x2 = 0.0; + m_y2 = 1.0; + } else - setStop( 1.0, 0.0 ); + { + m_x2 = 1.0; + m_y2 = 0.0; + } +} + +void QskLinearDirection::setVector( const QLineF& vector ) noexcept +{ + m_x1 = vector.x1(); + m_y1 = vector.y1(); + m_x2 = vector.x2(); + m_y2 = vector.y2(); +} + +void QskLinearDirection::setVector( const QPointF& start, const QPointF& stop ) noexcept +{ + m_x1 = start.x(); + m_y1 = start.y(); + m_x2 = stop.x(); + m_y2 = stop.y(); +} + +void QskLinearDirection::setVector( qreal x1, qreal y1, qreal x2, qreal y2 ) noexcept +{ + m_x1 = x1; + m_y1 = y1; + m_x2 = x2; + m_y2 = y2; } void QskLinearDirection::setStart( const QPointF& pos ) noexcept diff --git a/src/common/QskGradientDirection.h b/src/common/QskGradientDirection.h index 36df36b2..ff89b4bd 100644 --- a/src/common/QskGradientDirection.h +++ b/src/common/QskGradientDirection.h @@ -10,6 +10,9 @@ #include #include +#include + +class QLineF; class QSK_EXPORT QskLinearDirection { @@ -25,9 +28,16 @@ class QSK_EXPORT QskLinearDirection constexpr QskLinearDirection( Qt::Orientation ) noexcept; + constexpr QskLinearDirection( const QLineF& ) noexcept; constexpr QskLinearDirection( const QPointF&, const QPointF& ) noexcept; constexpr QskLinearDirection( qreal x1, qreal y1, qreal x2, qreal y2 ) noexcept; + void setVector( const QLineF& ) noexcept; + void setVector( const QPointF&, const QPointF& ) noexcept; + void setVector( qreal x1, qreal y1, qreal x2, qreal y2 ) noexcept; + + constexpr QLineF vector() const noexcept; + void setStart( const QPointF& ) noexcept; void setStart( qreal x, qreal y ) noexcept; @@ -156,6 +166,11 @@ inline constexpr QskLinearDirection::QskLinearDirection( { } +inline constexpr QskLinearDirection::QskLinearDirection( const QLineF& vector ) noexcept + : QskLinearDirection( vector.x1(), vector.y1(), vector.x2(), vector.y2() ) +{ +} + inline constexpr QskLinearDirection::QskLinearDirection( const QPointF& start, const QPointF& stop ) noexcept : QskLinearDirection( start.x(), start.y(), stop.x(), stop.y() ) @@ -191,6 +206,11 @@ inline constexpr qreal QskLinearDirection::y2() const noexcept return m_y2; } +inline constexpr QLineF QskLinearDirection::vector() const noexcept +{ + return QLineF( m_x1, m_y1, m_x2, m_y2 ); +} + inline constexpr QPointF QskLinearDirection::start() const noexcept { return QPointF( m_x1, m_y1 );