QskBoxHints introduced

This commit is contained in:
Uwe Rathmann 2022-01-04 13:44:53 +01:00
parent 4a3f56e842
commit 1d7b551b05
7 changed files with 182 additions and 0 deletions

View File

@ -0,0 +1,52 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskBoxHints.h"
QskBoxHints::QskBoxHints()
{
}
QskBoxHints::QskBoxHints(
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& borderMetrics,
const QskBoxBorderColors& borderColors, const QskGradient& gradient )
: shape( shape )
, borderMetrics( borderMetrics )
, borderColors( borderColors )
, gradient( gradient )
{
}
QskBoxHints QskBoxHints::toAbsolute( const QSizeF& size ) const noexcept
{
return QskBoxHints( shape.toAbsolute( size ),
borderMetrics.toAbsolute( size ), borderColors, gradient );
}
QskBoxHints QskBoxHints::interpolated(
const QskBoxHints& to, qreal value ) const noexcept
{
return QskBoxHints(
shape.interpolated( to.shape, value ),
borderMetrics.interpolated( to.borderMetrics, value ),
borderColors.interpolated( to.borderColors, value ),
gradient.interpolated( to.gradient, value ) );
}
#ifndef QT_NO_DEBUG_STREAM
#include <qdebug.h>
QDebug operator<<( QDebug debug, const QskBoxHints& hints )
{
debug << hints.shape << hints.borderMetrics
<< hints.borderColors << hints.gradient;
return debug;
}
#endif
#include "moc_QskBoxHints.cpp"

46
src/common/QskBoxHints.h Normal file
View File

@ -0,0 +1,46 @@
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef QSK_BOX_HINTS_H
#define QSK_BOX_HINTS_H
#include "QskBoxBorderMetrics.h"
#include "QskBoxBorderColors.h"
#include "QskBoxShapeMetrics.h"
#include "QskGradient.h"
class QSK_EXPORT QskBoxHints
{
Q_GADGET
Q_PROPERTY( QskBoxShapeMetrics shape MEMBER shape )
Q_PROPERTY( QskBoxBorderMetrics borderMetrics MEMBER borderMetrics )
Q_PROPERTY( QskBoxBorderColors borderColors MEMBER borderColors )
Q_PROPERTY( QskGradient gradient MEMBER gradient )
public:
QskBoxHints();
QskBoxHints( const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
const QskBoxBorderColors&, const QskGradient& );
QskBoxHints toAbsolute( const QSizeF& ) const noexcept;
QskBoxHints interpolated(
const QskBoxHints&, qreal value ) const noexcept;
QskBoxShapeMetrics shape;
QskBoxBorderMetrics borderMetrics;
QskBoxBorderColors borderColors;
QskGradient gradient;
};
#ifndef QT_NO_DEBUG_STREAM
class QDebug;
QSK_EXPORT QDebug operator<<( QDebug, const QskBoxHints& );
#endif
#endif

View File

@ -12,6 +12,7 @@
#include "QskBoxClipNode.h"
#include "QskBoxNode.h"
#include "QskBoxShapeMetrics.h"
#include "QskBoxHints.h"
#include "QskColorFilter.h"
#include "QskControl.h"
#include "QskFunctions.h"
@ -368,6 +369,61 @@ QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable,
boxRect, shape, borderMetrics, borderColors, fillGradient );
}
QSGNode* QskSkinlet::updateBoxNode(
const QskSkinnable* skinnable, QSGNode* node, const QRectF& rect,
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& borderMetrics,
const QskBoxBorderColors& borderColors, const QskGradient& fillGradient )
{
return qskUpdateBoxNode( skinnable, node,
rect, shape, borderMetrics, borderColors, fillGradient );
}
QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable,
QSGNode* node, const QRectF& rect, const QskBoxHints& hints )
{
return qskUpdateBoxNode( skinnable, node, rect,
hints.shape, hints.borderMetrics, hints.borderColors, hints.gradient );
}
QSGNode* QskSkinlet::updateInterpolatedBoxNode(
const QskSkinnable* skinnable, QSGNode* node, const QRectF& rect,
QskAspect aspect1, QskAspect aspect2, qreal ratio )
{
QskBoxHints boxHints;
QRectF r;
ratio = qBound( 0.0, ratio, 1.0 );
if ( qFuzzyIsNull( ratio ) )
{
const auto margins = skinnable->marginHint( aspect1 );
r = rect.marginsRemoved( margins );
boxHints = skinnable->boxHints( aspect1 ).toAbsolute( r.size() );
}
else if ( qFuzzyCompare( ratio, 1.0 ) )
{
const auto margins = skinnable->marginHint( aspect2 );
r = rect.marginsRemoved( margins );
boxHints = skinnable->boxHints( aspect2 ).toAbsolute( r.size() );
}
else
{
QskMargins margins = skinnable->marginHint( aspect1 );
margins = margins.interpolated( skinnable->marginHint( aspect2 ), ratio );
r = rect.marginsRemoved( margins );
const auto boxHints1 = skinnable->boxHints( aspect1 ).toAbsolute( r.size() );
const auto boxHints2 = skinnable->boxHints( aspect2 ).toAbsolute( r.size() );
boxHints = boxHints1.interpolated( boxHints2, ratio );
}
return QskSkinlet::updateBoxNode( skinnable, node, r, boxHints );
}
QSGNode* QskSkinlet::updateArcNode( const QskSkinnable* skinnable,
QSGNode* node, QskAspect::Subcontrol subControl ) const
{

View File

@ -21,6 +21,10 @@ class QskGradient;
class QskColorFilter;
class QskGraphic;
class QskTextOptions;
class QskBoxShapeMetrics;
class QskBoxBorderMetrics;
class QskBoxBorderColors;
class QskBoxHints;
class QSGNode;
@ -73,6 +77,17 @@ class QSK_EXPORT QskSkinlet
static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
const QRectF&, const QskGradient&, QskAspect::Subcontrol );
static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
const QRectF&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
const QskBoxBorderColors&, const QskGradient& );
static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
const QRectF&, const QskBoxHints& );
static QSGNode* updateInterpolatedBoxNode(
const QskSkinnable*, QSGNode*, const QRectF&,
QskAspect aspect1, QskAspect aspect2, qreal ratio );
static QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
const QRectF&, QskAspect::Subcontrol );

View File

@ -22,6 +22,7 @@
#include "QskBoxShapeMetrics.h"
#include "QskBoxBorderMetrics.h"
#include "QskBoxBorderColors.h"
#include "QskBoxHints.h"
#include "QskGradient.h"
#include <qfont.h>
@ -595,6 +596,13 @@ QskBoxBorderColors QskSkinnable::boxBorderColorsHint(
this, aspect | QskAspect::Border, status );
}
QskBoxHints QskSkinnable::boxHints( QskAspect aspect ) const
{
return QskBoxHints(
boxShapeHint( aspect ), boxBorderMetricsHint( aspect ),
boxBorderColorsHint( aspect ), gradientHint( aspect ) );
}
bool QskSkinnable::setArcMetricsHint(
const QskAspect aspect, const QskArcMetrics& arc )
{

View File

@ -28,6 +28,7 @@ class QskColorFilter;
class QskBoxShapeMetrics;
class QskBoxBorderMetrics;
class QskBoxBorderColors;
class QskBoxHints;
class QskGradient;
class QskSkin;
@ -207,6 +208,8 @@ class QSK_EXPORT QskSkinnable
bool resetBoxBorderColorsHint( QskAspect );
QskBoxBorderColors boxBorderColorsHint( QskAspect, QskSkinHintStatus* = nullptr ) const;
QskBoxHints boxHints( QskAspect ) const;
bool setArcMetricsHint( QskAspect, const QskArcMetrics& );
bool resetArcMetricsHint( QskAspect );
QskArcMetrics arcMetricsHint( QskAspect, QskSkinHintStatus* = nullptr ) const;

View File

@ -17,6 +17,7 @@ HEADERS += \
common/QskBoxBorderColors.h \
common/QskBoxBorderMetrics.h \
common/QskBoxShapeMetrics.h \
common/QskBoxHints.h \
common/QskFunctions.h \
common/QskGlobal.h \
common/QskGradient.h \
@ -45,6 +46,7 @@ SOURCES += \
common/QskBoxBorderColors.cpp \
common/QskBoxBorderMetrics.cpp \
common/QskBoxShapeMetrics.cpp \
common/QskBoxHints.cpp \
common/QskFunctions.cpp \
common/QskGradient.cpp \
common/QskGradientStop.cpp \