QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskStippleMetrics.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_STIPPLE_METRICS_H
7#define QSK_STIPPLE_METRICS_H
8
9#include "QskGlobal.h"
10
11#include <qmetatype.h>
12#include <qvector.h>
13#include <qnamespace.h>
14
15class QPen;
16
17class QSK_EXPORT QskStippleMetrics
18{
19 Q_GADGET
20
21 Q_PROPERTY( qreal offset READ offset WRITE setOffset )
22 Q_PROPERTY( QVector< qreal > pattern READ pattern WRITE setPattern )
23
24 public:
25 QskStippleMetrics( Qt::PenStyle = Qt::SolidLine );
26 QskStippleMetrics( const QPen& );
27 QskStippleMetrics( const QVector< qreal >&, qreal offset = 0.0 );
28
29 bool operator==( const QskStippleMetrics& ) const noexcept;
30 bool operator!=( const QskStippleMetrics& ) const noexcept;
31
32 bool isValid() const noexcept;
33 bool isSolid() const noexcept;
34
35 void setOffset( qreal offset ) noexcept;
36 qreal offset() const noexcept;
37
38 void setPattern( const QVector< qreal >& );
39 QVector< qreal > pattern() const;
40
41 QskStippleMetrics interpolated(
42 const QskStippleMetrics&, qreal value ) const;
43
44 static QVariant interpolate( const QskStippleMetrics&,
45 const QskStippleMetrics&, qreal progress );
46
47 QskHashValue hash( QskHashValue seed = 0 ) const noexcept;
48
49 private:
50 qreal m_offset = 0.0;
51 QVector< qreal > m_pattern;
52};
53
54inline QskStippleMetrics::QskStippleMetrics(
55 const QVector< qreal >& pattern, qreal offset )
56 : m_offset( offset )
57 , m_pattern( pattern )
58{
59}
60
61inline qreal QskStippleMetrics::offset() const noexcept
62{
63 return m_offset;
64}
65
66inline QVector< qreal > QskStippleMetrics::pattern() const
67{
68 return m_pattern;
69}
70
71inline bool QskStippleMetrics::operator==(
72 const QskStippleMetrics& other ) const noexcept
73{
74 return ( m_offset == other.m_offset )
75 && ( m_pattern == other.m_pattern );
76}
77
78inline bool QskStippleMetrics::operator!=(
79 const QskStippleMetrics& other ) const noexcept
80{
81 return !( *this == other );
82}
83
84inline bool QskStippleMetrics::isValid() const noexcept
85{
86 return !m_pattern.isEmpty();
87}
88
89inline bool QskStippleMetrics::isSolid() const noexcept
90{
91 return m_pattern.count() == 1;
92}
93
94QSK_EXPORT QVector< qreal > qskDashPattern( Qt::PenStyle );
95
96#ifndef QT_NO_DEBUG_STREAM
97
98class QDebug;
99QSK_EXPORT QDebug operator<<( QDebug, const QskStippleMetrics& );
100
101#endif
102
103Q_DECLARE_METATYPE( QskStippleMetrics )
104
105#endif