qskinny/src/common/QskBoxBorderColors.h

134 lines
3.3 KiB
C
Raw Normal View History

/******************************************************************************
2024-01-17 13:31:45 +00:00
* QSkinny - Copyright (C) The authors
2023-04-06 07:23:37 +00:00
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/
#ifndef QSK_BOX_BORDER_COLORS_H
#define QSK_BOX_BORDER_COLORS_H
#include "QskGradient.h"
#include "QskNamespace.h"
2018-07-19 12:10:48 +00:00
#include <qcolor.h>
#include <qmetatype.h>
class QSK_EXPORT QskBoxBorderColors
{
2022-03-30 16:30:22 +00:00
Q_GADGET
Q_PROPERTY( QskGradient left READ left WRITE setLeft )
Q_PROPERTY( QskGradient top READ top WRITE setTop )
Q_PROPERTY( QskGradient right READ right WRITE setRight )
Q_PROPERTY( QskGradient bottom READ bottom WRITE setBottom )
2018-08-03 06:15:28 +00:00
public:
QskBoxBorderColors();
2018-08-03 06:15:28 +00:00
QskBoxBorderColors( const QskGradient& left, const QskGradient& top,
const QskGradient& right, const QskGradient& bottom );
QskBoxBorderColors( Qt::GlobalColor );
QskBoxBorderColors( QRgb );
QskBoxBorderColors( const QColor& );
QskBoxBorderColors( const QskGradient& );
~QskBoxBorderColors();
bool operator==( const QskBoxBorderColors& ) const;
bool operator!=( const QskBoxBorderColors& ) const;
void setAlpha( int alpha );
void setGradients( const QskGradient& );
void setGradients( const QskGradient& left, const QskGradient& top,
const QskGradient& right, const QskGradient& bottom );
void setGradientAt( Qt::Edges, const QskGradient& );
const QskGradient& gradientAt( Qt::Edge ) const;
2022-03-30 16:30:22 +00:00
void setLeft( const QskGradient& );
const QskGradient& left() const;
void setTop( const QskGradient& );
const QskGradient& top() const;
void setRight( const QskGradient& );
const QskGradient& right() const;
void setBottom( const QskGradient& );
const QskGradient& bottom() const;
QskBoxBorderColors interpolated( const QskBoxBorderColors&, qreal value ) const;
static QVariant interpolate( const QskBoxBorderColors&,
const QskBoxBorderColors&, qreal ratio );
QskHashValue hash( QskHashValue seed = 0 ) const;
bool isMonochrome() const;
bool isVisible() const;
2022-03-30 10:28:45 +00:00
bool isValid() const;
2018-08-03 06:15:28 +00:00
private:
enum
{
// in order of Qt::Edge
Top = 0,
Left = 1,
Right = 2,
Bottom = 3
};
QskGradient m_gradients[ 4 ];
};
2018-08-03 06:15:28 +00:00
inline QskBoxBorderColors::QskBoxBorderColors( Qt::GlobalColor color )
: QskBoxBorderColors( QskGradient( QColor( color ) ) )
{
}
2018-08-03 06:15:28 +00:00
inline QskBoxBorderColors::QskBoxBorderColors( QRgb rgb )
: QskBoxBorderColors( QskGradient( QColor::fromRgba( rgb ) ) )
{
}
inline QskBoxBorderColors::QskBoxBorderColors( const QColor& color )
: QskBoxBorderColors( QskGradient( color ) )
{
}
inline bool QskBoxBorderColors::operator!=( const QskBoxBorderColors& other ) const
{
return !( *this == other );
}
2022-03-30 16:30:22 +00:00
inline const QskGradient& QskBoxBorderColors::left() const
{
return m_gradients[ Left ];
2022-03-30 16:30:22 +00:00
}
inline const QskGradient& QskBoxBorderColors::top() const
{
return m_gradients[ Top ];
2022-03-30 16:30:22 +00:00
}
inline const QskGradient& QskBoxBorderColors::right() const
{
return m_gradients[ Right ];
2022-03-30 16:30:22 +00:00
}
inline const QskGradient& QskBoxBorderColors::bottom() const
{
return m_gradients[ Bottom ];
2022-03-30 16:30:22 +00:00
}
#ifndef QT_NO_DEBUG_STREAM
2022-03-30 10:28:45 +00:00
class QDebug;
QSK_EXPORT QDebug operator<<( QDebug, const QskBoxBorderColors& );
#endif
Q_DECLARE_METATYPE( QskBoxBorderColors )
#endif