QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskBoxBorderColors.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_BOX_BORDER_COLORS_H
7#define QSK_BOX_BORDER_COLORS_H
8
9#include "QskGradient.h"
10#include "QskNamespace.h"
11
12#include <qcolor.h>
13#include <qmetatype.h>
14
15class QSK_EXPORT QskBoxBorderColors
16{
17 Q_GADGET
18
19 Q_PROPERTY( QskGradient left READ left WRITE setLeft )
20 Q_PROPERTY( QskGradient top READ top WRITE setTop )
21 Q_PROPERTY( QskGradient right READ right WRITE setRight )
22 Q_PROPERTY( QskGradient bottom READ bottom WRITE setBottom )
23
24 public:
26
27 QskBoxBorderColors( const QskGradient& left, const QskGradient& top,
28 const QskGradient& right, const QskGradient& bottom );
29
30 QskBoxBorderColors( Qt::GlobalColor );
31 QskBoxBorderColors( QRgb );
32 QskBoxBorderColors( const QColor& );
34
36
37 bool operator==( const QskBoxBorderColors& ) const;
38 bool operator!=( const QskBoxBorderColors& ) const;
39
40 void setAlpha( int alpha );
41
42 void setGradients( const QskGradient& );
43 void setGradients( const QskGradient& left, const QskGradient& top,
44 const QskGradient& right, const QskGradient& bottom );
45
46 void setGradientAt( Qt::Edges, const QskGradient& );
47 const QskGradient& gradientAt( Qt::Edge ) const;
48
49 void setLeft( const QskGradient& );
50 const QskGradient& left() const;
51
52 void setTop( const QskGradient& );
53 const QskGradient& top() const;
54
55 void setRight( const QskGradient& );
56 const QskGradient& right() const;
57
58 void setBottom( const QskGradient& );
59 const QskGradient& bottom() const;
60
61 QskBoxBorderColors interpolated( const QskBoxBorderColors&, qreal value ) const;
62
63 static QVariant interpolate( const QskBoxBorderColors&,
64 const QskBoxBorderColors&, qreal ratio );
65
66 QskHashValue hash( QskHashValue seed = 0 ) const;
67
68 bool isMonochrome() const;
69 bool isVisible() const;
70 bool isValid() const;
71
72 private:
73 enum
74 {
75 // in order of Qt::Edge
76 Top = 0,
77 Left = 1,
78 Right = 2,
79 Bottom = 3
80 };
81 QskGradient m_gradients[ 4 ];
82};
83
84inline QskBoxBorderColors::QskBoxBorderColors( Qt::GlobalColor color )
85 : QskBoxBorderColors( QskGradient( QColor( color ) ) )
86{
87}
88
89inline QskBoxBorderColors::QskBoxBorderColors( QRgb rgb )
90 : QskBoxBorderColors( QskGradient( QColor::fromRgba( rgb ) ) )
91{
92}
93
94inline QskBoxBorderColors::QskBoxBorderColors( const QColor& color )
96{
97}
98
99inline bool QskBoxBorderColors::operator!=( const QskBoxBorderColors& other ) const
100{
101 return !( *this == other );
102}
103
104inline const QskGradient& QskBoxBorderColors::left() const
105{
106 return m_gradients[ Left ];
107}
108
109inline const QskGradient& QskBoxBorderColors::top() const
110{
111 return m_gradients[ Top ];
112}
113
114inline const QskGradient& QskBoxBorderColors::right() const
115{
116 return m_gradients[ Right ];
117}
118
119inline const QskGradient& QskBoxBorderColors::bottom() const
120{
121 return m_gradients[ Bottom ];
122}
123
124#ifndef QT_NO_DEBUG_STREAM
125
126class QDebug;
127QSK_EXPORT QDebug operator<<( QDebug, const QskBoxBorderColors& );
128
129#endif
130
131Q_DECLARE_METATYPE( QskBoxBorderColors )
132
133#endif