tickWidth moved into QskGraduationMetrics
This commit is contained in:
parent
3fabf3ee03
commit
6c826c3adc
@ -26,6 +26,7 @@
|
||||
#include <QskRgbValue.h>
|
||||
#include <QskBoxBorderColors.h>
|
||||
#include <QskBoxShapeMetrics.h>
|
||||
#include <QskGraduationMetrics.h>
|
||||
#include <QskStippleMetrics.h>
|
||||
|
||||
#include <QskGraduationRenderer.h>
|
||||
@ -101,7 +102,7 @@ void SkinEditor::setupPlotHints()
|
||||
setFlag( Q::AxisScale | A::Style, QskGraduationRenderer::Backbone );
|
||||
|
||||
// thickness/length of the major ticks
|
||||
setStrutSize( Q::AxisScale, 1.0, 8.0 );
|
||||
setGraduationMetrics( Q::AxisScale, { 4.0, 6.0, 8.0, 1.0 } );
|
||||
|
||||
// spacing between ticks and labels
|
||||
setSpacing( Q::AxisScale, 5 );
|
||||
|
@ -78,14 +78,10 @@ namespace
|
||||
|
||||
setTickColor( view->color( aspect ) );
|
||||
|
||||
const auto tickSize = view->strutSizeHint( aspect );
|
||||
setTickWidth( tickSize.width() );
|
||||
const auto graduation = view->effectiveSkinHint(
|
||||
aspect | QskAspect::Metric | QskAspect::Graduation );
|
||||
|
||||
#if 1
|
||||
const QskGraduationMetrics tickMetrics( qRound( 0.7 * tickSize.height() ),
|
||||
qRound( 0.85 * tickSize.height() ), tickSize.height() );
|
||||
setTickMetrics( tickMetrics );
|
||||
#endif
|
||||
setTickMetrics( graduation.value< QskGraduationMetrics >() );
|
||||
|
||||
setSpacing( view->spacingHint( aspect ) );
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "QskGraduationMetrics.h"
|
||||
|
||||
#include <qvariant.h>
|
||||
|
||||
static void qskRegisterGraduationMetrics()
|
||||
@ -26,7 +25,8 @@ QskGraduationMetrics QskGraduationMetrics::interpolated(
|
||||
|
||||
return { qskInterpolated( m_tickLengths[0], to.m_tickLengths[0], ratio ),
|
||||
qskInterpolated( m_tickLengths[1], to.m_tickLengths[1], ratio ),
|
||||
qskInterpolated( m_tickLengths[2], to.m_tickLengths[2], ratio ) };
|
||||
qskInterpolated( m_tickLengths[2], to.m_tickLengths[2], ratio ),
|
||||
qskInterpolated( m_tickWidth, to.m_tickWidth, ratio ) };
|
||||
}
|
||||
|
||||
QVariant QskGraduationMetrics::interpolate(
|
||||
@ -49,7 +49,7 @@ QDebug operator<<( QDebug debug, const QskGraduationMetrics& metrics )
|
||||
debug << "Graduation";
|
||||
debug << '(';
|
||||
debug << metrics.minorTickLength() << s << metrics.mediumTickLength()
|
||||
<< s << metrics.majorTickLength();
|
||||
<< s << metrics.majorTickLength() << "W:" << metrics.tickWidth();
|
||||
debug << ')';
|
||||
|
||||
return debug;
|
||||
|
@ -17,21 +17,22 @@ class QSK_EXPORT QskGraduationMetrics
|
||||
Q_PROPERTY( qreal majorTickLength READ majorTickLength WRITE setMajorTickLength )
|
||||
Q_PROPERTY( qreal mediumTickLength READ mediumTickLength WRITE setMediumTickLength )
|
||||
Q_PROPERTY( qreal minorTickLength READ minorTickLength WRITE setMinorTickLength )
|
||||
Q_PROPERTY( qreal tickWidth READ tickWidth WRITE setTickWidth )
|
||||
|
||||
public:
|
||||
using TickType = QskTickmarks::TickType;
|
||||
|
||||
constexpr QskGraduationMetrics() noexcept = default;
|
||||
|
||||
constexpr QskGraduationMetrics( qreal minorTickLength,
|
||||
qreal mediumTickLength, qreal majorTickLength ) noexcept;
|
||||
constexpr QskGraduationMetrics( const QskGraduationMetrics& ) noexcept = default;
|
||||
constexpr QskGraduationMetrics( QskGraduationMetrics&& ) noexcept = default;
|
||||
qreal mediumTickLength, qreal majorTickLength,
|
||||
qreal tickWidth = 1.0 ) noexcept;
|
||||
|
||||
constexpr QskGraduationMetrics& operator=( const QskGraduationMetrics& ) noexcept = default;
|
||||
constexpr QskGraduationMetrics& operator=( QskGraduationMetrics&& ) noexcept = default;
|
||||
[[nodiscard]] constexpr bool operator==( const QskGraduationMetrics& ) const noexcept;
|
||||
[[nodiscard]] constexpr bool operator!=( const QskGraduationMetrics& ) const noexcept;
|
||||
|
||||
[[nodiscard]] constexpr bool operator==( const QskGraduationMetrics& rhs ) const noexcept;
|
||||
[[nodiscard]] constexpr bool operator!=( const QskGraduationMetrics& rhs ) const noexcept;
|
||||
constexpr void setTickWidth( qreal ) noexcept;
|
||||
[[nodiscard]] constexpr qreal tickWidth() const noexcept;
|
||||
|
||||
constexpr void setTickLength( TickType, qreal ) noexcept;
|
||||
[[nodiscard]] constexpr qreal tickLength( TickType ) const noexcept;
|
||||
@ -56,57 +57,61 @@ class QSK_EXPORT QskGraduationMetrics
|
||||
[[nodiscard]] constexpr qreal maxLength() const noexcept;
|
||||
|
||||
private:
|
||||
static inline constexpr qreal constrainedLength( qreal length )
|
||||
static inline constexpr qreal validated( qreal value )
|
||||
{
|
||||
return std::max( 0.0, length );
|
||||
return std::max( 0.0, value );
|
||||
}
|
||||
|
||||
qreal m_tickLengths[3] = {};
|
||||
qreal m_tickWidth = 1.0;
|
||||
};
|
||||
|
||||
inline constexpr QskGraduationMetrics::QskGraduationMetrics(
|
||||
qreal minorTickLength, qreal mediumTickLength, qreal majorTickLength ) noexcept
|
||||
: m_tickLengths{ constrainedLength( minorTickLength ),
|
||||
constrainedLength( mediumTickLength ), constrainedLength( majorTickLength ) }
|
||||
qreal minorTickLength, qreal mediumTickLength, qreal majorTickLength,
|
||||
qreal tickWidth ) noexcept
|
||||
: m_tickLengths{ validated( minorTickLength ),
|
||||
validated( mediumTickLength ), validated( majorTickLength ) }
|
||||
, m_tickWidth( tickWidth )
|
||||
{
|
||||
}
|
||||
|
||||
inline constexpr qreal QskGraduationMetrics::majorTickLength() const noexcept
|
||||
{
|
||||
return tickLength( QskTickmarks::MajorTick );
|
||||
}
|
||||
|
||||
inline constexpr qreal QskGraduationMetrics::mediumTickLength() const noexcept
|
||||
{
|
||||
return tickLength( QskTickmarks::MediumTick );
|
||||
}
|
||||
|
||||
inline constexpr qreal QskGraduationMetrics::minorTickLength() const noexcept
|
||||
{
|
||||
return tickLength( QskTickmarks::MinorTick );
|
||||
}
|
||||
|
||||
inline constexpr void QskGraduationMetrics::setMajorTickLength( qreal length ) noexcept
|
||||
{
|
||||
setTickLength( QskTickmarks::MajorTick, length );
|
||||
}
|
||||
|
||||
inline constexpr qreal QskGraduationMetrics::majorTickLength() const noexcept
|
||||
{
|
||||
return tickLength( QskTickmarks::MajorTick );
|
||||
}
|
||||
|
||||
inline constexpr void QskGraduationMetrics::setMediumTickLength( qreal length ) noexcept
|
||||
{
|
||||
setTickLength( QskTickmarks::MediumTick, length );
|
||||
}
|
||||
|
||||
inline constexpr qreal QskGraduationMetrics::mediumTickLength() const noexcept
|
||||
{
|
||||
return tickLength( QskTickmarks::MediumTick );
|
||||
}
|
||||
|
||||
inline constexpr void QskGraduationMetrics::setMinorTickLength( qreal length ) noexcept
|
||||
{
|
||||
setTickLength( QskTickmarks::MinorTick, length );
|
||||
}
|
||||
|
||||
inline constexpr qreal QskGraduationMetrics::minorTickLength() const noexcept
|
||||
{
|
||||
return tickLength( QskTickmarks::MinorTick );
|
||||
}
|
||||
|
||||
inline constexpr bool QskGraduationMetrics::operator==(
|
||||
const QskGraduationMetrics& other ) const noexcept
|
||||
{
|
||||
return qskFuzzyCompare( m_tickLengths[0], other.m_tickLengths[0] ) &&
|
||||
qskFuzzyCompare( m_tickLengths[1], other.m_tickLengths[1] ) &&
|
||||
qskFuzzyCompare( m_tickLengths[2], other.m_tickLengths[2] );
|
||||
qskFuzzyCompare( m_tickLengths[2], other.m_tickLengths[2] &&
|
||||
qskFuzzyCompare( m_tickWidth, other.m_tickWidth ) );
|
||||
}
|
||||
|
||||
inline constexpr bool QskGraduationMetrics::operator!=(
|
||||
@ -115,16 +120,26 @@ inline constexpr bool QskGraduationMetrics::operator!=(
|
||||
return !( *this == rhs );
|
||||
}
|
||||
|
||||
inline constexpr qreal QskGraduationMetrics::tickLength(
|
||||
const QskTickmarks::TickType type ) const noexcept
|
||||
inline constexpr void QskGraduationMetrics::setTickWidth( qreal width ) noexcept
|
||||
{
|
||||
return m_tickLengths[ type ];
|
||||
m_tickWidth = validated( width );
|
||||
}
|
||||
|
||||
inline constexpr qreal QskGraduationMetrics::tickWidth() const noexcept
|
||||
{
|
||||
return m_tickWidth;
|
||||
}
|
||||
|
||||
inline constexpr void QskGraduationMetrics::setTickLength(
|
||||
TickType type, qreal length ) noexcept
|
||||
{
|
||||
m_tickLengths[ type ] = constrainedLength( length );
|
||||
m_tickLengths[ type ] = validated( length );
|
||||
}
|
||||
|
||||
inline constexpr qreal QskGraduationMetrics::tickLength(
|
||||
const QskTickmarks::TickType type ) const noexcept
|
||||
{
|
||||
return m_tickLengths[ type ];
|
||||
}
|
||||
|
||||
inline constexpr qreal QskGraduationMetrics::maxLength() const noexcept
|
||||
@ -138,6 +153,7 @@ inline QskHashValue QskGraduationMetrics::hash( const QskHashValue seed ) const
|
||||
auto hash = qHash( m_tickLengths[0], seed );
|
||||
hash = qHash( m_tickLengths[1], hash );
|
||||
hash = qHash( m_tickLengths[2], hash );
|
||||
hash = qHash( m_tickWidth, hash );
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "QskBoxShapeMetrics.h"
|
||||
#include "QskBoxBorderMetrics.h"
|
||||
#include "QskBoxBorderColors.h"
|
||||
#include "QskGraduationMetrics.h"
|
||||
#include "QskShadowMetrics.h"
|
||||
#include "QskStippleMetrics.h"
|
||||
#include "QskGraphic.h"
|
||||
@ -136,6 +137,11 @@ namespace
|
||||
{
|
||||
return aspect | QskAspect::Style;
|
||||
}
|
||||
|
||||
inline QskAspect aspectGraduation( QskAspect aspect )
|
||||
{
|
||||
return aspect | QskAspect::Graduation;
|
||||
}
|
||||
}
|
||||
|
||||
QskSkinHintTableEditor::QskSkinHintTableEditor( QskSkinHintTable* table )
|
||||
@ -629,6 +635,23 @@ QskStippleMetrics QskSkinHintTableEditor::stippleMetrics( QskAspect aspect ) con
|
||||
return metricHint< QskStippleMetrics >( aspectStipple( aspect ) );
|
||||
}
|
||||
|
||||
void QskSkinHintTableEditor::setGraduationMetrics( QskAspect aspect,
|
||||
const QskGraduationMetrics& metrics, QskStateCombination combination )
|
||||
{
|
||||
setMetricHint( aspectGraduation( aspect ), metrics, combination );
|
||||
}
|
||||
|
||||
bool QskSkinHintTableEditor::removeGraduationMetrics(
|
||||
QskAspect aspect, QskStateCombination combination )
|
||||
{
|
||||
return removeMetricHint( aspectGraduation( aspect ), combination );
|
||||
}
|
||||
|
||||
QskGraduationMetrics QskSkinHintTableEditor::graduationMetrics( QskAspect aspect ) const
|
||||
{
|
||||
return metricHint< QskGraduationMetrics >( aspectGraduation( aspect ) );
|
||||
}
|
||||
|
||||
void QskSkinHintTableEditor::setTextOptions( QskAspect aspect,
|
||||
Qt::TextElideMode elideMode, QskTextOptions::WrapMode wrapMode,
|
||||
QskStateCombination combination )
|
||||
|
@ -22,6 +22,7 @@ class QskGradient;
|
||||
class QskBoxShapeMetrics;
|
||||
class QskBoxBorderMetrics;
|
||||
class QskBoxBorderColors;
|
||||
class QskGraduationMetrics;
|
||||
class QskShadowMetrics;
|
||||
class QskStippleMetrics;
|
||||
class QskGraphic;
|
||||
@ -282,6 +283,15 @@ class QSK_EXPORT QskSkinHintTableEditor
|
||||
|
||||
QskStippleMetrics stippleMetrics( QskAspect ) const;
|
||||
|
||||
// graduation metrics
|
||||
|
||||
void setGraduationMetrics( QskAspect, const QskGraduationMetrics&,
|
||||
QskStateCombination = QskStateCombination() );
|
||||
|
||||
bool removeGraduationMetrics( QskAspect, QskStateCombination = QskStateCombination() );
|
||||
|
||||
QskGraduationMetrics graduationMetrics( QskAspect ) const;
|
||||
|
||||
// text options flag
|
||||
|
||||
void setTextOptions( QskAspect,
|
||||
|
@ -122,13 +122,14 @@ void QskGraduationNode::setAxis( Qt::Orientation orientation,
|
||||
}
|
||||
}
|
||||
|
||||
void QskGraduationNode::setTickGeometry(
|
||||
Alignment alignment, const QskGraduationMetrics& metrics, qreal tickWidth )
|
||||
void QskGraduationNode::setTickMetrics(
|
||||
Alignment alignment, const QskGraduationMetrics& metrics )
|
||||
{
|
||||
setLineWidth( tickWidth );
|
||||
|
||||
if( metrics != m_data->graduationMetrics || alignment != m_data->alignment )
|
||||
{
|
||||
setLineWidth( metrics.tickWidth() );
|
||||
|
||||
m_data->graduationMetrics = metrics;
|
||||
m_data->alignment = alignment;
|
||||
|
||||
|
@ -34,7 +34,7 @@ class QSK_EXPORT QskGraduationNode : public QskBasicLinesNode
|
||||
#if 1
|
||||
// finding better names
|
||||
void setAxis( Qt::Orientation, qreal pos, const QTransform& );
|
||||
void setTickGeometry( Alignment, const QskGraduationMetrics&, qreal tickWidth );
|
||||
void setTickMetrics( Alignment, const QskGraduationMetrics& );
|
||||
#endif
|
||||
|
||||
void update( const QskTickmarks&, const QskIntervalF& );
|
||||
|
@ -108,7 +108,6 @@ class QskGraduationRenderer::PrivateData
|
||||
QColor tickColor = Qt::black; // rgb value ???
|
||||
#endif
|
||||
|
||||
qreal tickWidth = 1.0;
|
||||
QskGraduationMetrics metrics = { 4, 6, 8 };
|
||||
qreal spacing = 5.0;
|
||||
|
||||
@ -238,16 +237,6 @@ const QskGraduationMetrics& QskGraduationRenderer::tickMetrics() const
|
||||
return m_data->metrics;
|
||||
}
|
||||
|
||||
void QskGraduationRenderer::setTickWidth( qreal width )
|
||||
{
|
||||
m_data->tickWidth = qMax( width, 0.0 );
|
||||
}
|
||||
|
||||
qreal QskGraduationRenderer::tickWidth() const
|
||||
{
|
||||
return m_data->tickWidth;
|
||||
}
|
||||
|
||||
void QskGraduationRenderer::setFont( const QFont& font )
|
||||
{
|
||||
m_data->font = font;
|
||||
@ -335,7 +324,7 @@ QSGNode* QskGraduationRenderer::updateTicksNode(
|
||||
|
||||
graduationNode->setColor( m_data->tickColor );
|
||||
graduationNode->setAxis( orientation, m_data->position, transform );
|
||||
graduationNode->setTickGeometry( alignment, m_data->metrics, m_data->tickWidth );
|
||||
graduationNode->setTickMetrics( alignment, m_data->metrics );
|
||||
graduationNode->setPixelAlignment( Qt::Horizontal | Qt::Vertical );
|
||||
|
||||
graduationNode->update( m_data->tickmarks, backbone );
|
||||
|
@ -79,9 +79,6 @@ class QSK_EXPORT QskGraduationRenderer
|
||||
void setTickMetrics( const QskGraduationMetrics& );
|
||||
const QskGraduationMetrics& tickMetrics() const;
|
||||
|
||||
void setTickWidth( qreal );
|
||||
qreal tickWidth() const;
|
||||
|
||||
void setFont( const QFont& );
|
||||
QFont font() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user