debug operators improved
This commit is contained in:
parent
511c6ddcd3
commit
baee63ea6b
|
@ -165,6 +165,14 @@ bool QskBoxBorderColors::isMonochrome() const
|
|||
&& m_gradients[ 3 ].isMonochrome();
|
||||
}
|
||||
|
||||
bool QskBoxBorderColors::isValid() const
|
||||
{
|
||||
return m_gradients[ 0 ].isValid()
|
||||
|| m_gradients[ 1 ].isValid()
|
||||
|| m_gradients[ 2 ].isValid()
|
||||
|| m_gradients[ 3 ].isValid();
|
||||
}
|
||||
|
||||
QskBoxBorderColors QskBoxBorderColors::interpolated(
|
||||
const QskBoxBorderColors& to, qreal ratio ) const
|
||||
{
|
||||
|
@ -210,14 +218,44 @@ QDebug operator<<( QDebug debug, const QskBoxBorderColors& colors )
|
|||
QDebugStateSaver saver( debug );
|
||||
debug.nospace();
|
||||
|
||||
debug << "BoxBorderColors" << '(';
|
||||
debug << "BoxBorderColors";
|
||||
|
||||
debug << " L" << colors.gradient( Qsk::Left );
|
||||
debug << ", T" << colors.gradient( Qsk::Top );
|
||||
debug << ", R" << colors.gradient( Qsk::Right );
|
||||
debug << ", B" << colors.gradient( Qsk::Bottom );
|
||||
if ( !colors.isValid() )
|
||||
{
|
||||
debug << "()";
|
||||
}
|
||||
else
|
||||
{
|
||||
debug << "( ";
|
||||
|
||||
debug << " )";
|
||||
if ( colors.isMonochrome() )
|
||||
{
|
||||
const auto& gradient = colors.gradient( Qsk::Left );
|
||||
QskRgb::debugColor( debug, gradient.startColor() );
|
||||
}
|
||||
else
|
||||
{
|
||||
const char prompts[] = { 'L', 'T', 'R', 'B' };
|
||||
|
||||
for ( int i = 0; i <= Qsk::Bottom; i++ )
|
||||
{
|
||||
if ( i != 0 )
|
||||
debug << ", ";
|
||||
|
||||
const auto& gradient = colors.gradient(
|
||||
static_cast< Qsk::Position >( i ) );
|
||||
|
||||
debug << prompts[ i ] << ": ";
|
||||
|
||||
if ( gradient.isValid() && gradient.isMonochrome() )
|
||||
QskRgb::debugColor( debug, gradient.startColor() );
|
||||
else
|
||||
debug << gradient;
|
||||
}
|
||||
}
|
||||
|
||||
debug << " )";
|
||||
}
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include <qcolor.h>
|
||||
#include <qmetatype.h>
|
||||
|
||||
class QDebug;
|
||||
|
||||
class QSK_EXPORT QskBoxBorderColors
|
||||
{
|
||||
public:
|
||||
|
@ -53,6 +51,7 @@ class QSK_EXPORT QskBoxBorderColors
|
|||
|
||||
bool isMonochrome() const;
|
||||
bool isVisible() const;
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
QskGradient m_gradients[ 4 ];
|
||||
|
@ -80,6 +79,7 @@ inline const QskGradient& QskBoxBorderColors::gradient( Qsk::Position position )
|
|||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
|
||||
class QDebug;
|
||||
QSK_EXPORT QDebug operator<<( QDebug, const QskBoxBorderColors& );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -109,9 +109,24 @@ QDebug operator<<( QDebug debug, const QskBoxBorderMetrics& metrics )
|
|||
QDebugStateSaver saver( debug );
|
||||
debug.nospace();
|
||||
|
||||
debug << "BoxBorder" << '(';
|
||||
debug << metrics.sizeMode() << ',' << metrics.widths();
|
||||
debug << ')';
|
||||
debug << "BoxBorder" << "( ";
|
||||
|
||||
if ( metrics.sizeMode() != Qt::AbsoluteSize )
|
||||
debug << metrics.sizeMode() << ", ";
|
||||
|
||||
const auto& w = metrics.widths();
|
||||
|
||||
if ( metrics.isEquidistant() )
|
||||
{
|
||||
debug << w.left();
|
||||
}
|
||||
else
|
||||
{
|
||||
const char s[] = ", ";
|
||||
debug << w.left() << s << w.top() << s << w.right() << s << w.bottom();
|
||||
}
|
||||
|
||||
debug << " )";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ class QSK_EXPORT QskBoxBorderMetrics
|
|||
static QVariant interpolate( const QskBoxBorderMetrics&,
|
||||
const QskBoxBorderMetrics&, qreal progress );
|
||||
|
||||
constexpr bool isEquidistant() const noexcept;
|
||||
|
||||
private:
|
||||
QskMargins m_widths;
|
||||
Qt::SizeMode m_sizeMode;
|
||||
|
@ -115,6 +117,11 @@ inline constexpr bool QskBoxBorderMetrics::isNull() const noexcept
|
|||
return m_widths.isNull();
|
||||
}
|
||||
|
||||
inline constexpr bool QskBoxBorderMetrics::isEquidistant() const noexcept
|
||||
{
|
||||
return m_widths.isEquidistant();
|
||||
}
|
||||
|
||||
inline constexpr const QskMargins& QskBoxBorderMetrics::widths() const noexcept
|
||||
{
|
||||
return m_widths;
|
||||
|
|
|
@ -229,6 +229,11 @@ QskGradient::QskGradient( Orientation orientation, const QskGradientStops& stops
|
|||
setStops( stops );
|
||||
}
|
||||
|
||||
QskGradient::QskGradient( Qt::Orientation orientation, QGradient::Preset preset )
|
||||
: QskGradient( qskOrientation( orientation ), preset )
|
||||
{
|
||||
}
|
||||
|
||||
QskGradient::QskGradient( Orientation orientation, QGradient::Preset preset )
|
||||
: QskGradient( orientation )
|
||||
{
|
||||
|
@ -632,7 +637,49 @@ void QskGradient::updateStatusBits() const
|
|||
|
||||
QDebug operator<<( QDebug debug, const QskGradient& gradient )
|
||||
{
|
||||
debug << "GR:" << gradient.orientation() << gradient.stops().count();
|
||||
QDebugStateSaver saver( debug );
|
||||
debug.nospace();
|
||||
|
||||
debug << "Gradient";
|
||||
|
||||
if ( !gradient.isValid() )
|
||||
{
|
||||
debug << "()";
|
||||
}
|
||||
else
|
||||
{
|
||||
debug << "( ";
|
||||
|
||||
if ( gradient.isMonochrome() )
|
||||
{
|
||||
QskRgb::debugColor( debug, gradient.startColor() );
|
||||
}
|
||||
else
|
||||
{
|
||||
const char o[] = { 'H', 'V', 'D' };
|
||||
debug << o[ gradient.orientation() ] << ", ";
|
||||
|
||||
if ( gradient.stops().count() == 2 )
|
||||
{
|
||||
QskRgb::debugColor( debug, gradient.startColor() );
|
||||
debug << ", ";
|
||||
QskRgb::debugColor( debug, gradient.endColor() );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& s = gradient.stops();
|
||||
for ( int i = 0; i < s.count(); i++ )
|
||||
{
|
||||
if ( i != 0 )
|
||||
debug << ", ";
|
||||
|
||||
debug << s[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
debug << " )";
|
||||
}
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ class QSK_EXPORT QskGradient
|
|||
|
||||
QskGradient( Qt::Orientation, const QVector< QskGradientStop >& );
|
||||
QskGradient( Qt::Orientation, const QColor&, const QColor& );
|
||||
QskGradient( Qt::Orientation, QGradient::Preset );
|
||||
|
||||
QskGradient( Orientation, const QVector< QskGradientStop >& );
|
||||
QskGradient( Orientation, const QColor&, const QColor& );
|
||||
|
|
|
@ -78,7 +78,12 @@ QColor QskGradientStop::interpolated(
|
|||
|
||||
QDebug operator<<( QDebug debug, const QskGradientStop& stop )
|
||||
{
|
||||
debug << stop.position() << ": " << stop.color();
|
||||
QDebugStateSaver saver( debug );
|
||||
debug.nospace();
|
||||
|
||||
debug << stop.position() << ": ";
|
||||
QskRgb::debugColor( debug, stop.color() );
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ class QSK_EXPORT QskMargins : public QMarginsF
|
|||
QskMargins interpolated( const QskMargins&, qreal progress ) const noexcept;
|
||||
|
||||
constexpr bool isExpanding() const noexcept;
|
||||
constexpr bool isEquidistant() const noexcept;
|
||||
|
||||
static QVariant interpolate( const QskMargins&,
|
||||
const QskMargins&, qreal progress ) noexcept;
|
||||
|
@ -181,6 +182,11 @@ constexpr inline qreal QskMargins::height() const noexcept
|
|||
return top() + bottom();
|
||||
}
|
||||
|
||||
inline constexpr bool QskMargins::isEquidistant() const noexcept
|
||||
{
|
||||
return ( left() == top() ) && ( left() == right() ) && ( left() == bottom() );
|
||||
}
|
||||
|
||||
Q_DECLARE_TYPEINFO( QskMargins, Q_MOVABLE_TYPE );
|
||||
Q_DECLARE_METATYPE( QskMargins )
|
||||
|
||||
|
|
|
@ -172,3 +172,29 @@ QRgb QskRgb::darker( QRgb rgb, int factor ) noexcept
|
|||
return QColor::fromRgba( rgb ).darker( factor ).rgba();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
|
||||
#include <qdebug.h>
|
||||
|
||||
void QskRgb::debugColor( QDebug debug, const QColor& color )
|
||||
{
|
||||
debugColor( debug, color.rgba() );
|
||||
}
|
||||
|
||||
void QskRgb::debugColor( QDebug debug, QRgb rgb )
|
||||
{
|
||||
QDebugStateSaver saver( debug );
|
||||
debug.nospace();
|
||||
|
||||
debug << '[';
|
||||
|
||||
debug << qRed( rgb ) << "r," << qGreen( rgb ) << "g,"
|
||||
<< qBlue( rgb ) << 'b';
|
||||
|
||||
if ( qAlpha( rgb ) != 255 )
|
||||
debug << ',' << qAlpha( rgb ) << 'a';
|
||||
|
||||
debug << ']';
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -480,4 +480,16 @@ namespace QskRgb
|
|||
QSK_EXPORT QRgb darker( QRgb, int factor = 200 ) noexcept;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
|
||||
class QDebug;
|
||||
|
||||
namespace QskRgb
|
||||
{
|
||||
QSK_EXPORT void debugColor( QDebug, const QColor& );
|
||||
QSK_EXPORT void debugColor( QDebug, QRgb );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue