QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskTextColors.cpp
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#include "QskTextColors.h"
7#include "QskRgbValue.h"
8
9#include <qhashfunctions.h>
10#include <qvariant.h>
11
12QskHashValue QskTextColors::hash( QskHashValue seed ) const noexcept
13{
14 const QRgb rgb[] = { textColor.rgba(), styleColor.rgba(), linkColor.rgba() };
15 return qHashBits( rgb, sizeof( rgb ), seed );
16}
17
18QskTextColors QskTextColors::interpolated(
19 const QskTextColors& to, qreal ratio ) const
20{
21 QskTextColors colors;
22 colors.textColor = QskRgb::interpolated( textColor, to.textColor, ratio );
23 colors.styleColor = QskRgb::interpolated( styleColor, to.styleColor, ratio );
24 colors.linkColor = QskRgb::interpolated( linkColor, to.linkColor, ratio );
25
26 return colors;
27}
28
29QVariant QskTextColors::interpolate(
30 const QskTextColors& from, const QskTextColors& to, qreal ratio )
31{
32 return QVariant::fromValue( from.interpolated( to, ratio ) );
33}
34
35#ifndef QT_NO_DEBUG_STREAM
36
37#include <qdebug.h>
38
39static inline void qskDebugColor( QDebug debug, const QColor& c )
40{
41 debug << '(' << c.red() << ',' << c.green() << ','
42 << c.blue() << ',' << c.alpha() << ')';
43}
44
45QDebug operator<<( QDebug debug, const QskTextColors& colors )
46{
47 QDebugStateSaver saver( debug );
48 debug.nospace();
49
50 debug << "TextColors" << '(';
51
52 debug << " T";
53 qskDebugColor( debug, colors.textColor );
54
55 debug << ", S";
56 qskDebugColor( debug, colors.styleColor );
57
58 debug << ", L";
59 qskDebugColor( debug, colors.linkColor );
60
61 debug << " )";
62
63 return debug;
64}
65
66#endif