new QskGradient
This commit is contained in:
parent
38bc3286cd
commit
ad67d035f3
|
|
@ -10,6 +10,21 @@
|
||||||
#include <QskBoxShapeMetrics.h>
|
#include <QskBoxShapeMetrics.h>
|
||||||
#include <QskHctColor.h>
|
#include <QskHctColor.h>
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
|
#include <QskLinearGradient.h>
|
||||||
|
|
||||||
|
static inline void setStartStop( Box::FillType type, QskLinearGradient& gradient )
|
||||||
|
{
|
||||||
|
qreal x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
|
||||||
|
|
||||||
|
if ( type != Box::Horizontal )
|
||||||
|
y2 = 1.0;
|
||||||
|
|
||||||
|
if ( type != Box::Vertical )
|
||||||
|
x2 = 1.0;
|
||||||
|
|
||||||
|
gradient.setStart( x1, y1 );
|
||||||
|
gradient.setStop( x2, y2 );
|
||||||
|
}
|
||||||
|
|
||||||
Box::Box( QQuickItem* parentItem )
|
Box::Box( QQuickItem* parentItem )
|
||||||
: QskBox( parentItem )
|
: QskBox( parentItem )
|
||||||
|
|
@ -20,67 +35,88 @@ Box::Box( QQuickItem* parentItem )
|
||||||
setBoxShapeHint( QskBox::Panel, QskBoxShapeMetrics() );
|
setBoxShapeHint( QskBox::Panel, QskBoxShapeMetrics() );
|
||||||
setBoxBorderMetricsHint( QskBox::Panel, QskBoxBorderMetrics() );
|
setBoxBorderMetricsHint( QskBox::Panel, QskBoxBorderMetrics() );
|
||||||
setBoxBorderColorsHint( QskBox::Panel, QskBoxBorderColors() );
|
setBoxBorderColorsHint( QskBox::Panel, QskBoxBorderColors() );
|
||||||
setGradientHint( QskBox::Panel, QskGradient() );
|
setPanelGradient( QskGradient() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box::setBackground( FillType type, QGradient::Preset preset, bool inverted )
|
void Box::setWebGradient( FillType type, QGradient::Preset preset, bool inverted )
|
||||||
{
|
{
|
||||||
if ( type == Unfilled )
|
if ( type == Unfilled )
|
||||||
{
|
{
|
||||||
setGradient( QskGradient() );
|
setPanelGradient( QskGradient() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradient gradient( preset );
|
QskLinearGradient gradient( preset );
|
||||||
|
|
||||||
if ( type == Solid )
|
if ( type == Solid )
|
||||||
{
|
{
|
||||||
const auto color = QskRgb::interpolated(
|
const auto color = QskRgb::interpolated(
|
||||||
gradient.startColor(), gradient.endColor(), 0.5 );
|
gradient.startColor(), gradient.endColor(), 0.5 );
|
||||||
|
|
||||||
setGradient( QskGradient( color ) );
|
gradient.setStops( color );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
const auto orientation =
|
|
||||||
static_cast< QskGradient::Orientation >( type - 2 );
|
|
||||||
|
|
||||||
gradient.setOrientation( orientation );
|
setStartStop( type, gradient );
|
||||||
|
|
||||||
if ( inverted )
|
if ( inverted )
|
||||||
gradient.reverse();
|
gradient.reverse();
|
||||||
|
|
||||||
setGradient( gradient );
|
setPanelGradient( gradient );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box::setBackground( FillType type, const QRgb base, bool inverted )
|
void Box::setTonalGradient( FillType type, const QRgb base, bool inverted )
|
||||||
{
|
{
|
||||||
if ( type == Unfilled )
|
if ( type == Unfilled )
|
||||||
{
|
{
|
||||||
setGradient( QskGradient() );
|
setPanelGradient( QskGradient() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QskHctColor htcColor( base );
|
QskLinearGradient gradient;
|
||||||
|
|
||||||
|
const QskHctColor htcColor( base );
|
||||||
if ( type == Solid )
|
if ( type == Solid )
|
||||||
{
|
{
|
||||||
setGradient( htcColor.toned( 50 ).rgb() );
|
gradient.setStops( htcColor.toned( 50 ).rgb() );
|
||||||
}
|
}
|
||||||
else
|
else if ( type != Unfilled )
|
||||||
{
|
{
|
||||||
const auto dark = htcColor.toned( 40 ).rgb();
|
gradient.setStops( htcColor.toned( 70 ).rgb(),
|
||||||
const auto light = htcColor.toned( 70 ).rgb();
|
htcColor.toned( 40 ).rgb() );
|
||||||
|
}
|
||||||
|
|
||||||
const auto orientation =
|
setStartStop( type, gradient );
|
||||||
static_cast< QskGradient::Orientation >( type - 2 );
|
|
||||||
|
|
||||||
if ( inverted )
|
if ( inverted )
|
||||||
setGradient( orientation, dark, light );
|
gradient.reverse();
|
||||||
else
|
|
||||||
setGradient( orientation, light, dark );
|
setPanelGradient( gradient );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Box::setTonalPalette( FillType type, const QRgb base )
|
||||||
|
{
|
||||||
|
if ( type == Unfilled || type == Solid )
|
||||||
|
{
|
||||||
|
setTonalGradient( type, base );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QskLinearGradient gradient;
|
||||||
|
setStartStop( type, gradient );
|
||||||
|
|
||||||
|
{
|
||||||
|
const QskHctColor hctColor( base );
|
||||||
|
|
||||||
|
QVector< QRgb > colors;
|
||||||
|
colors.reserve( 10 );
|
||||||
|
|
||||||
|
for ( int i = 0; i < 10; i++ )
|
||||||
|
colors += hctColor.toned( 90 - i * 7 ).rgb();
|
||||||
|
|
||||||
|
gradient.setStops( qskBuildGradientStops( colors, true ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
setPanelGradient( gradient );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box::setBorder( BorderType type, const QRgb base )
|
void Box::setBorder( BorderType type, const QRgb base )
|
||||||
|
|
@ -165,26 +201,30 @@ void Box::setBorderWidth( int width )
|
||||||
|
|
||||||
void Box::setGradient( QRgb rgb )
|
void Box::setGradient( QRgb rgb )
|
||||||
{
|
{
|
||||||
setGradient( QskGradient( QColor::fromRgba( rgb ) ) );
|
setGradient( QColor::fromRgba( rgb ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box::setGradient( Qt::GlobalColor color )
|
void Box::setGradient( Qt::GlobalColor color )
|
||||||
{
|
{
|
||||||
setGradient( QskGradient( color ) );
|
setGradient( QColor( color ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box::setGradient( const QColor& color )
|
void Box::setGradient( const QColor& color )
|
||||||
{
|
{
|
||||||
setGradient( QskGradient( color ) );
|
setPanelGradient( QskLinearGradient( color ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box::setGradient( QskGradient::Orientation orientation,
|
void Box::setGradient( FillType fillType,
|
||||||
const QColor& color1, const QColor& color2 )
|
const QColor& color1, const QColor& color2 )
|
||||||
{
|
{
|
||||||
setGradient( QskGradient( orientation, color1, color2 ) );
|
QskGradientStops stops;
|
||||||
|
stops += QskGradientStop( 0.0, color1 );
|
||||||
|
stops += QskGradientStop( 1.0, color2 );
|
||||||
|
|
||||||
|
setGradient( fillType, stops );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box::setGradient( QskGradient::Orientation orientation,
|
void Box::setGradient( FillType fillType,
|
||||||
const QColor& color1, const QColor& color2, const QColor& color3 )
|
const QColor& color1, const QColor& color2, const QColor& color3 )
|
||||||
{
|
{
|
||||||
QskGradientStops stops;
|
QskGradientStops stops;
|
||||||
|
|
@ -192,24 +232,18 @@ void Box::setGradient( QskGradient::Orientation orientation,
|
||||||
stops += QskGradientStop( 0.5, color2 );
|
stops += QskGradientStop( 0.5, color2 );
|
||||||
stops += QskGradientStop( 1.0, color3 );
|
stops += QskGradientStop( 1.0, color3 );
|
||||||
|
|
||||||
setGradient( QskGradient( orientation, stops ) );
|
setGradient( fillType, stops );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box::setGradient( const QskGradient& gradient )
|
void Box::setGradient( FillType fillType, const QskGradientStops& stops )
|
||||||
|
{
|
||||||
|
QskLinearGradient gradient( stops );
|
||||||
|
setStartStop( fillType, gradient );
|
||||||
|
|
||||||
|
setPanelGradient( gradient );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Box::setPanelGradient( const QskGradient& gradient )
|
||||||
{
|
{
|
||||||
setGradientHint( QskBox::Panel, gradient );
|
setGradientHint( QskBox::Panel, gradient );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box::setGradient(
|
|
||||||
const QskGradient::Orientation orientation, const QRgb base )
|
|
||||||
{
|
|
||||||
const QskHctColor hctColor( base );
|
|
||||||
|
|
||||||
QVector< QRgb > colors;
|
|
||||||
colors.reserve( 10 );
|
|
||||||
|
|
||||||
for ( int i = 0; i < 10; i++ )
|
|
||||||
colors += hctColor.toned( 90 - i * 7 ).rgb();
|
|
||||||
|
|
||||||
setGradient( QskGradient( orientation, qskBuildGradientStops( colors, true ) ) );
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,6 @@ class Box : public QskBox
|
||||||
|
|
||||||
Box( QQuickItem* parentItem = nullptr );
|
Box( QQuickItem* parentItem = nullptr );
|
||||||
|
|
||||||
void setBackground( FillType, QRgb, bool inverted = false );
|
|
||||||
void setBackground( FillType, QGradient::Preset, bool inverted = false );
|
|
||||||
|
|
||||||
void setBorder( BorderType type, QRgb );
|
void setBorder( BorderType type, QRgb );
|
||||||
|
|
||||||
void setShape( const QskBoxShapeMetrics& );
|
void setShape( const QskBoxShapeMetrics& );
|
||||||
|
|
@ -51,11 +48,15 @@ class Box : public QskBox
|
||||||
void setGradient( Qt::GlobalColor );
|
void setGradient( Qt::GlobalColor );
|
||||||
void setGradient( const QColor& );
|
void setGradient( const QColor& );
|
||||||
|
|
||||||
void setGradient( QskGradient::Orientation, const QColor&, const QColor& );
|
void setGradient( FillType, const QColor&, const QColor& );
|
||||||
|
void setGradient( FillType, const QColor&, const QColor&, const QColor& );
|
||||||
|
void setGradient( FillType, const QskGradientStops& );
|
||||||
|
|
||||||
void setGradient( QskGradient::Orientation,
|
void setTonalGradient( FillType, QRgb, bool inverted = false );
|
||||||
const QColor&, const QColor&, const QColor& );
|
void setWebGradient( FillType, QGradient::Preset, bool inverted = false );
|
||||||
|
|
||||||
void setGradient( const QskGradient& );
|
void setTonalPalette( FillType, QRgb );
|
||||||
void setGradient( const QskGradient::Orientation, QRgb );
|
|
||||||
|
private:
|
||||||
|
void setPanelGradient( const QskGradient& );
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
#include <QskBoxBorderColors.h>
|
#include <QskBoxBorderColors.h>
|
||||||
#include <QskBoxBorderMetrics.h>
|
#include <QskBoxBorderMetrics.h>
|
||||||
#include <QskBoxShapeMetrics.h>
|
#include <QskBoxShapeMetrics.h>
|
||||||
#include <QskGradient.h>
|
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
|
|
||||||
#include <QskObjectCounter.h>
|
#include <QskObjectCounter.h>
|
||||||
|
|
@ -75,7 +74,7 @@ static void addTestRectangle( QskLinearBox* parent )
|
||||||
shape.setRadius( Qt::TopRightCorner, 70 );
|
shape.setRadius( Qt::TopRightCorner, 70 );
|
||||||
|
|
||||||
box->setShape( shape );
|
box->setShape( shape );
|
||||||
box->setGradient( QskGradient::Diagonal, QskRgb::DodgerBlue );
|
box->setTonalPalette( Box::Diagonal, QskRgb::DodgerBlue );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addRectangles1( QskLinearBox* parent )
|
static void addRectangles1( QskLinearBox* parent )
|
||||||
|
|
@ -84,7 +83,7 @@ static void addRectangles1( QskLinearBox* parent )
|
||||||
Box::Horizontal, Box::Vertical, Box::Diagonal } )
|
Box::Horizontal, Box::Vertical, Box::Diagonal } )
|
||||||
{
|
{
|
||||||
auto* rectangle = new MyRectangle( parent );
|
auto* rectangle = new MyRectangle( parent );
|
||||||
rectangle->setBackground( type, QskRgb::Teal );
|
rectangle->setTonalGradient( type, QskRgb::Teal );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,7 +94,7 @@ static void addRectangles2( QskLinearBox* parent )
|
||||||
{
|
{
|
||||||
auto* rectangle = new MyRectangle( parent );
|
auto* rectangle = new MyRectangle( parent );
|
||||||
rectangle->setBorder( Box::Flat, QskRgb::SaddleBrown );
|
rectangle->setBorder( Box::Flat, QskRgb::SaddleBrown );
|
||||||
rectangle->setBackground( type, QGradient::SunnyMorning );
|
rectangle->setWebGradient( type, QGradient::SunnyMorning );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,19 +112,19 @@ static void addRectangles3( QskLinearBox* parent )
|
||||||
|
|
||||||
box = new MyRectangle( parent );
|
box = new MyRectangle( parent );
|
||||||
box->setBorder( Box::Sunken1, borderTheme );
|
box->setBorder( Box::Sunken1, borderTheme );
|
||||||
box->setGradient( QskGradient::Diagonal, Grey400, Grey500 );
|
box->setGradient( Box::Diagonal, Grey400, Grey500 );
|
||||||
|
|
||||||
box = new MyRectangle( parent );
|
box = new MyRectangle( parent );
|
||||||
box->setBorder( Box::Raised2, borderTheme );
|
box->setBorder( Box::Raised2, borderTheme );
|
||||||
box->setGradient( QskGradient::Vertical, Grey400, Grey500 );
|
box->setGradient( Box::Vertical, Grey400, Grey500 );
|
||||||
|
|
||||||
box = new MyRectangle( parent );
|
box = new MyRectangle( parent );
|
||||||
box->setBorder( Box::Raised2, borderTheme );
|
box->setBorder( Box::Raised2, borderTheme );
|
||||||
box->setBackground( Box::Vertical, QGradient::RiverCity, true );
|
box->setWebGradient( Box::Vertical, QGradient::RiverCity, true );
|
||||||
|
|
||||||
box = new MyRectangle( parent );
|
box = new MyRectangle( parent );
|
||||||
box->setBorder( Box::Sunken2, borderTheme );
|
box->setBorder( Box::Sunken2, borderTheme );
|
||||||
box->setBackground( Box::Vertical, QGradient::RiverCity, false );
|
box->setWebGradient( Box::Vertical, QGradient::RiverCity, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addRectangles4( QskLinearBox* parent )
|
static void addRectangles4( QskLinearBox* parent )
|
||||||
|
|
@ -134,7 +133,7 @@ static void addRectangles4( QskLinearBox* parent )
|
||||||
Box::Horizontal, Box::Vertical, Box::Diagonal } )
|
Box::Horizontal, Box::Vertical, Box::Diagonal } )
|
||||||
{
|
{
|
||||||
auto* box = new MyRoundedRectangle( parent );
|
auto* box = new MyRoundedRectangle( parent );
|
||||||
box->setBackground( type, QskRgb::OrangeRed );
|
box->setTonalGradient( type, QskRgb::OrangeRed );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,7 +144,7 @@ static void addRectangles5( QskLinearBox* parent )
|
||||||
{
|
{
|
||||||
auto* box = new MyRoundedRectangle( parent );
|
auto* box = new MyRoundedRectangle( parent );
|
||||||
box->setBorder( Box::Flat, QskRgb::RoyalBlue );
|
box->setBorder( Box::Flat, QskRgb::RoyalBlue );
|
||||||
box->setBackground( type, QskRgb::DeepPink );
|
box->setTonalGradient( type, QskRgb::DeepPink );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,19 +162,19 @@ static void addRectangles6( QskLinearBox* parent )
|
||||||
|
|
||||||
box = new MyRoundedRectangle( parent );
|
box = new MyRoundedRectangle( parent );
|
||||||
box->setBorder( Box::Sunken1, borderTheme );
|
box->setBorder( Box::Sunken1, borderTheme );
|
||||||
box->setGradient( QskGradient::Diagonal, Grey400, Grey500 );
|
box->setGradient( Box::Diagonal, Grey400, Grey500 );
|
||||||
|
|
||||||
box = new MyRoundedRectangle( parent );
|
box = new MyRoundedRectangle( parent );
|
||||||
box->setBorder( Box::Raised2, borderTheme );
|
box->setBorder( Box::Raised2, borderTheme );
|
||||||
box->setGradient( QskGradient::Vertical, Grey400, Grey500 );
|
box->setGradient( Box::Vertical, Grey400, Grey500 );
|
||||||
|
|
||||||
box = new MyRoundedRectangle( parent );
|
box = new MyRoundedRectangle( parent );
|
||||||
box->setBorder( Box::Raised2, borderTheme );
|
box->setBorder( Box::Raised2, borderTheme );
|
||||||
box->setGradient( QskGradient::Vertical, Lime300, Lime600 );
|
box->setGradient( Box::Vertical, Lime300, Lime600 );
|
||||||
|
|
||||||
box = new MyRoundedRectangle( parent );
|
box = new MyRoundedRectangle( parent );
|
||||||
box->setBorder( Box::Sunken2, borderTheme );
|
box->setBorder( Box::Sunken2, borderTheme );
|
||||||
box->setGradient( QskGradient::Vertical, Lime600, Lime300 );
|
box->setGradient( Box::Vertical, Lime600, Lime300 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addRectangles7( QskLinearBox* parent )
|
static void addRectangles7( QskLinearBox* parent )
|
||||||
|
|
@ -184,7 +183,7 @@ static void addRectangles7( QskLinearBox* parent )
|
||||||
Box::Horizontal, Box::Vertical, Box::Diagonal } )
|
Box::Horizontal, Box::Vertical, Box::Diagonal } )
|
||||||
{
|
{
|
||||||
auto* box = new MyEllipse( parent );
|
auto* box = new MyEllipse( parent );
|
||||||
box->setBackground( type, QskRgb::SlateGrey );
|
box->setTonalGradient( type, QskRgb::SlateGrey );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,7 +194,7 @@ static void addRectangles8( QskLinearBox* parent )
|
||||||
{
|
{
|
||||||
auto* box = new MyEllipse( parent );
|
auto* box = new MyEllipse( parent );
|
||||||
box->setBorder( Box::Flat, QskRgb::RoyalBlue );
|
box->setBorder( Box::Flat, QskRgb::RoyalBlue );
|
||||||
box->setBackground( type, QskRgb::FireBrick );
|
box->setTonalGradient( type, QskRgb::FireBrick );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,53 +212,60 @@ static void addRectangles9( QskLinearBox* parent )
|
||||||
|
|
||||||
box = new MyEllipse( parent );
|
box = new MyEllipse( parent );
|
||||||
box->setBorder( Box::Sunken1, borderTheme );
|
box->setBorder( Box::Sunken1, borderTheme );
|
||||||
box->setGradient( QskGradient::Diagonal, Grey400, Grey500 );
|
box->setGradient( Box::Diagonal, Grey400, Grey500 );
|
||||||
|
|
||||||
box = new MyEllipse( parent );
|
box = new MyEllipse( parent );
|
||||||
box->setBorder( Box::Raised2, borderTheme );
|
box->setBorder( Box::Raised2, borderTheme );
|
||||||
box->setGradient( QskGradient::Vertical, Grey400, Grey500 );
|
box->setGradient( Box::Vertical, Grey400, Grey500 );
|
||||||
|
|
||||||
box = new MyEllipse( parent );
|
box = new MyEllipse( parent );
|
||||||
box->setBorder( Box::Raised2, borderTheme );
|
box->setBorder( Box::Raised2, borderTheme );
|
||||||
box->setGradient( QskGradient::Vertical, Lime200, Lime600 );
|
box->setGradient( Box::Vertical, Lime200, Lime600 );
|
||||||
|
|
||||||
box = new MyEllipse( parent );
|
box = new MyEllipse( parent );
|
||||||
box->setBorder( Box::Sunken2, borderTheme );
|
box->setBorder( Box::Sunken2, borderTheme );
|
||||||
box->setGradient( QskGradient::Vertical, Lime600, Lime200 );
|
box->setGradient( Box::Vertical, Lime600, Lime200 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addRectangles10( QskLinearBox* parent )
|
static void addRectangles10( QskLinearBox* parent )
|
||||||
{
|
{
|
||||||
QColor borderTheme( "Indigo" );
|
using namespace QskRgb;
|
||||||
|
|
||||||
|
QColor borderTheme( Indigo );
|
||||||
// borderTheme.setAlpha( 100 );
|
// borderTheme.setAlpha( 100 );
|
||||||
|
|
||||||
|
QskGradientStops stops;
|
||||||
|
stops += QskGradientStop( 0.0, DeepPink );
|
||||||
|
stops += QskGradientStop( 0.5, DarkOrange );
|
||||||
|
stops += QskGradientStop( 1.0, HotPink );
|
||||||
|
|
||||||
Box* box;
|
Box* box;
|
||||||
|
|
||||||
box = new Box( parent );
|
box = new Box( parent );
|
||||||
box->setGradient( QskGradient::Horizontal, "DeepPink", "DarkOrange", "HotPink" );
|
box->setGradient( Box::Horizontal, stops );
|
||||||
|
|
||||||
box = new Box( parent );
|
box = new Box( parent );
|
||||||
box->setBorderWidth( 10 );
|
box->setBorderWidth( 10 );
|
||||||
box->setBorderGradient( borderTheme );
|
box->setBorderGradient( borderTheme );
|
||||||
box->setGradient( QskGradient::Diagonal, "DeepPink", "DarkOrange", "HotPink" );
|
box->setGradient( Box::Diagonal, stops );
|
||||||
|
|
||||||
box = new Box( parent );
|
box = new Box( parent );
|
||||||
box->setShape( 100, Qt::RelativeSize );
|
box->setShape( 100, Qt::RelativeSize );
|
||||||
box->setBorderWidth( 5 );
|
box->setBorderWidth( 5 );
|
||||||
box->setBorderGradient( borderTheme );
|
box->setBorderGradient( borderTheme );
|
||||||
box->setGradient( QskGradient::Vertical, "DeepPink", "DarkOrange", "HotPink" );
|
box->setGradient( Box::Vertical, stops );
|
||||||
|
|
||||||
box = new Box( parent );
|
box = new Box( parent );
|
||||||
box->setShape( 100, Qt::RelativeSize );
|
box->setShape( 100, Qt::RelativeSize );
|
||||||
box->setBorderWidth( 5 );
|
box->setBorderWidth( 5 );
|
||||||
box->setBorderGradient( borderTheme );
|
box->setBorderGradient( borderTheme );
|
||||||
box->setGradient( QskGradient::Diagonal, "DeepPink", "DarkOrange", "HotPink" );
|
box->setGradient( Box::Diagonal, stops );
|
||||||
|
|
||||||
box = new Box( parent );
|
box = new Box( parent );
|
||||||
box->setShape( 100, Qt::RelativeSize );
|
box->setShape( 100, Qt::RelativeSize );
|
||||||
box->setBorderWidth( 5, 20, 30, 5 );
|
box->setBorderWidth( 5, 20, 30, 5 );
|
||||||
box->setBorderGradient( borderTheme );
|
box->setBorderGradient( borderTheme );
|
||||||
box->setGradient( QskGradient::Vertical, "DeepPink", "DarkOrange", "HotPink" );
|
box->setGradient( Box::Vertical, stops );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addRectangles11( QskLinearBox* parent )
|
static void addRectangles11( QskLinearBox* parent )
|
||||||
|
|
@ -279,111 +285,109 @@ static void addRectangles11( QskLinearBox* parent )
|
||||||
bw[ i - 1 ] = 0;
|
bw[ i - 1 ] = 0;
|
||||||
|
|
||||||
box->setBorderWidth( bw[ 0 ], bw[ 1 ], bw[ 2 ], bw[ 3 ] );
|
box->setBorderWidth( bw[ 0 ], bw[ 1 ], bw[ 2 ], bw[ 3 ] );
|
||||||
box->setBackground( fillType[ i ], QskRgb::Sienna, i >= 3 );
|
box->setTonalGradient( fillType[ i ], QskRgb::Sienna, i >= 3 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addRectangles12( QskLinearBox* parent )
|
static void addRectangles12( QskLinearBox* parent )
|
||||||
{
|
{
|
||||||
for ( auto orientation : { QskGradient::Vertical,
|
for ( auto fillType : { Box::Vertical, Box::Horizontal, Box::Diagonal } )
|
||||||
QskGradient::Horizontal, QskGradient::Diagonal } )
|
|
||||||
{
|
{
|
||||||
auto* box = new Box( parent );
|
auto* box = new Box( parent );
|
||||||
box->setBorderWidth( 0 );
|
box->setBorderWidth( 0 );
|
||||||
box->setGradient( orientation, QskRgb::LightSlateGray );
|
box->setTonalPalette( fillType, QskRgb::LightSlateGray );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto orientation : { QskGradient::Vertical, QskGradient::Diagonal } )
|
for ( auto fillType : { Box::Vertical, Box::Diagonal } )
|
||||||
{
|
{
|
||||||
auto* box = new Box( parent );
|
auto* box = new Box( parent );
|
||||||
box->setBorder( Box::Flat, QskRgb::OrangeRed );
|
box->setBorder( Box::Flat, QskRgb::OrangeRed );
|
||||||
box->setGradient( orientation, QskRgb::DodgerBlue );
|
box->setTonalPalette( fillType, QskRgb::DodgerBlue );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto orientation : { QskGradient::Vertical,
|
for ( auto fillType : { Box::Vertical, Box::Horizontal, Box::Diagonal } )
|
||||||
QskGradient::Horizontal, QskGradient::Diagonal } )
|
|
||||||
{
|
{
|
||||||
auto* box = new Box( parent );
|
auto* box = new Box( parent );
|
||||||
box->setBorderWidth( 0 );
|
box->setBorderWidth( 0 );
|
||||||
box->setShape( 30, 40, Qt::RelativeSize );
|
box->setShape( 30, 40, Qt::RelativeSize );
|
||||||
box->setGradient( orientation, QskRgb::LightSlateGray );
|
box->setTonalPalette( fillType, QskRgb::LightSlateGray );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto orientation : { QskGradient::Vertical, QskGradient::Diagonal } )
|
for ( auto fillType : { Box::Vertical, Box::Diagonal } )
|
||||||
{
|
{
|
||||||
auto* box = new Box( parent );
|
auto* box = new Box( parent );
|
||||||
box->setBorder( Box::Flat, QskRgb::OrangeRed );
|
box->setBorder( Box::Flat, QskRgb::OrangeRed );
|
||||||
box->setShape( 30, 40, Qt::RelativeSize );
|
box->setShape( 30, 40, Qt::RelativeSize );
|
||||||
box->setGradient( orientation, QskRgb::DodgerBlue );
|
box->setTonalPalette( fillType, QskRgb::DodgerBlue );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto orientation : { QskGradient::Vertical,
|
for ( auto fillType : { Box::Vertical, Box::Horizontal, Box::Diagonal } )
|
||||||
QskGradient::Horizontal, QskGradient::Diagonal } )
|
|
||||||
{
|
{
|
||||||
auto* box = new Box( parent );
|
auto* box = new Box( parent );
|
||||||
box->setBorderWidth( 0 );
|
box->setBorderWidth( 0 );
|
||||||
box->setShape( 100, 100, Qt::RelativeSize );
|
box->setShape( 100, 100, Qt::RelativeSize );
|
||||||
box->setGradient( orientation, QskRgb::LightSlateGray );
|
box->setTonalPalette( fillType, QskRgb::LightSlateGray );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( auto orientation : { QskGradient::Vertical, QskGradient::Diagonal } )
|
for ( auto fillType : { Box::Vertical, Box::Diagonal } )
|
||||||
{
|
{
|
||||||
auto* box = new Box( parent );
|
auto* box = new Box( parent );
|
||||||
box->setBorder( Box::Flat, QskRgb::OrangeRed );
|
box->setBorder( Box::Flat, QskRgb::OrangeRed );
|
||||||
box->setShape( 100, 100, Qt::RelativeSize );
|
box->setShape( 100, 100, Qt::RelativeSize );
|
||||||
box->setGradient( orientation, QskRgb::DodgerBlue );
|
box->setTonalPalette( fillType, QskRgb::DodgerBlue );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addRectanglesRest( QskLinearBox* parent )
|
static void addRectanglesRest( QskLinearBox* parent )
|
||||||
{
|
{
|
||||||
|
using namespace QskRgb;
|
||||||
|
|
||||||
Box* box;
|
Box* box;
|
||||||
|
|
||||||
box = new Box( parent );
|
box = new Box( parent );
|
||||||
box->setBorderWidth( 20, 0, 40, 0 );
|
box->setBorderWidth( 20, 0, 40, 0 );
|
||||||
box->setBorderGradient( { "DarkSeaGreen" } );
|
box->setBorderGradient( DarkSeaGreen );
|
||||||
|
|
||||||
box = new Box( parent );
|
box = new Box( parent );
|
||||||
box->setShape( 40, Qt::RelativeSize );
|
box->setShape( 40, Qt::RelativeSize );
|
||||||
box->setBorderWidth( 20, 10, 30, 15 );
|
box->setBorderWidth( 20, 10, 30, 15 );
|
||||||
box->setBorderGradient( { "DarkOrange" } );
|
box->setBorderGradient( DarkOrange );
|
||||||
box->setGradient( QskGradient::Vertical, "LightSteelBlue", "SteelBlue" );
|
box->setGradient( Box::Vertical, LightSteelBlue, SteelBlue );
|
||||||
|
|
||||||
box = new Box( parent );
|
box = new Box( parent );
|
||||||
box->setBorderWidth( 20, 0, 10, 20 );
|
box->setBorderWidth( 20, 0, 10, 20 );
|
||||||
box->setBorderGradient( { "MediumSeaGreen" } );
|
box->setBorderGradient( MediumSeaGreen );
|
||||||
box->setGradient( "DodgerBlue" );
|
box->setGradient( DodgerBlue );
|
||||||
|
|
||||||
box = new Box( parent );
|
box = new Box( parent );
|
||||||
box->setShape( 20, Qt::AbsoluteSize );
|
box->setShape( 20, Qt::AbsoluteSize );
|
||||||
box->setBorderWidth( 2, 10, 40, 2 );
|
box->setBorderWidth( 2, 10, 40, 2 );
|
||||||
box->setBorderGradient( { "Crimson" } );
|
box->setBorderGradient( Crimson );
|
||||||
box->setGradient( QskRgb::WhiteSmoke );
|
box->setGradient( QskRgb::WhiteSmoke );
|
||||||
|
|
||||||
box = new Box( parent );
|
box = new Box( parent );
|
||||||
box->setShape( 100, Qt::RelativeSize );
|
box->setShape( 100, Qt::RelativeSize );
|
||||||
box->setBorderWidth( 5, 20, 5, 0 );
|
box->setBorderWidth( 5, 20, 5, 0 );
|
||||||
box->setBorderGradient( { "CadetBlue" } );
|
box->setBorderGradient( { CadetBlue } );
|
||||||
box->setGradient( QskGradient::Vertical, "Gainsboro", "Seashell", "LightGray" );
|
box->setGradient( Box::Vertical, Gainsboro, Seashell, LightGray );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addColoredBorderRectangles1( QskLinearBox* parent, bool rounded, Box::FillType fillType )
|
static void addColoredBorderRectangles1( QskLinearBox* parent, bool rounded, Box::FillType fillType )
|
||||||
{
|
{
|
||||||
auto* box = new Box( parent );
|
auto* box = new Box( parent );
|
||||||
box->setBorderWidth( 20 );
|
box->setBorderWidth( 20 );
|
||||||
QskGradient gradient1( Qt::Vertical, { { 0.0, Qt::blue },
|
|
||||||
{ 0.9, Qt::yellow },
|
QskGradientStops stops[4];
|
||||||
{ 1.0, Qt::darkRed } } );
|
|
||||||
QskGradient gradient2( Qt::Vertical, { { 0.0, Qt::black },
|
stops[0] = { { 0.0, Qt::blue }, { 0.9, Qt::yellow }, { 1.0, Qt::darkRed } };
|
||||||
{ 0.3, Qt::white },
|
stops[1] = { { 0.0, Qt::black }, { 0.3, Qt::white }, { 0.7, Qt::white }, { 1.0, Qt::black } };
|
||||||
{ 0.7, Qt::white },
|
stops[2] = { { 0.0, Qt::green }, { 1.0, Qt::green } };
|
||||||
{ 1.0, Qt::black } } );
|
stops[3] = { { 0.0, Qt::magenta }, { 1.0, Qt::cyan } };
|
||||||
QskGradient gradient3( Qt::green );
|
|
||||||
QskGradient gradient4( Qt::Vertical, Qt::magenta, Qt::cyan );
|
box->setBorderGradients( stops[0], stops[1], stops[2], stops[3] );
|
||||||
box->setBorderGradients( gradient1, gradient2, gradient3, gradient4 );
|
|
||||||
|
|
||||||
if( fillType != Box::Unfilled )
|
if( fillType != Box::Unfilled )
|
||||||
box->setBackground( fillType, QskRgb::CornflowerBlue );
|
box->setTonalGradient( fillType, QskRgb::CornflowerBlue );
|
||||||
|
|
||||||
if( rounded )
|
if( rounded )
|
||||||
box->setShape( 30, Qt::AbsoluteSize );
|
box->setShape( 30, Qt::AbsoluteSize );
|
||||||
|
|
@ -396,7 +400,7 @@ static void addColoredBorderRectangles2( QskLinearBox* parent, bool rounded, Box
|
||||||
box->setBorderGradients( Qt::red, Qt::green, Qt::blue, Qt::yellow );
|
box->setBorderGradients( Qt::red, Qt::green, Qt::blue, Qt::yellow );
|
||||||
|
|
||||||
if( fillType != Box::Unfilled )
|
if( fillType != Box::Unfilled )
|
||||||
box->setBackground( fillType, QskRgb::CornflowerBlue );
|
box->setTonalGradient( fillType, QskRgb::CornflowerBlue );
|
||||||
|
|
||||||
if( rounded )
|
if( rounded )
|
||||||
box->setShape( 30, Qt::AbsoluteSize );
|
box->setShape( 30, Qt::AbsoluteSize );
|
||||||
|
|
@ -406,26 +410,25 @@ static void addColoredBorderRectangles3( QskLinearBox* parent, bool rounded, Box
|
||||||
{
|
{
|
||||||
Box* box = new Box( parent );
|
Box* box = new Box( parent );
|
||||||
box->setBorderWidth( 20 );
|
box->setBorderWidth( 20 );
|
||||||
QskGradient gradient1( Qt::Vertical, { { 0.0, Qt::yellow },
|
|
||||||
{ 0.2, Qt::gray },
|
QskGradientStops stops[4];
|
||||||
{ 0.6, Qt::magenta },
|
|
||||||
{ 1.0, Qt::green } } );
|
stops[0] = { { 0.0, Qt::yellow }, { 0.2, Qt::gray },
|
||||||
QskGradient gradient2( Qt::Vertical, { { 0.0, Qt::darkYellow },
|
{ 0.6, Qt::magenta }, { 1.0, Qt::green } };
|
||||||
{ 0.2, Qt::cyan },
|
|
||||||
{ 1.0, Qt::darkMagenta } } );
|
stops[1] = { { 0.0, Qt::darkYellow }, { 0.2, Qt::cyan }, { 1.0, Qt::darkMagenta } };
|
||||||
QskGradient gradient3( Qt::Vertical, { { 0.0, Qt::red },
|
|
||||||
{ 0.25, Qt::green },
|
stops[2] = { { 0.0, Qt::red }, { 0.25, Qt::green },
|
||||||
{ 0.5, Qt::blue },
|
{ 0.5, Qt::blue }, { 0.75, Qt::magenta }, { 1.0, Qt::cyan } };
|
||||||
{ 0.75, Qt::magenta },
|
|
||||||
{ 1.0, Qt::cyan } } );
|
stops[3] = { { 0.0, Qt::red }, { 0.3, Qt::green },
|
||||||
QskGradient gradient4( Qt::Vertical, { { 0.0, Qt::red },
|
{ 0.7, Qt::blue }, { 1.0, Qt::cyan } };
|
||||||
{ 0.3, Qt::green },
|
|
||||||
{ 0.7, Qt::blue },
|
box->setBorderGradients( stops[0], stops[1], stops[2], stops[3] );
|
||||||
{ 1.0, Qt::cyan } } );
|
//box->setBorderGradients( stops[2], stops[2], stops[2], stops[2] );
|
||||||
box->setBorderGradients( gradient3, gradient3, gradient3, gradient3 );
|
|
||||||
|
|
||||||
if( fillType != Box::Unfilled )
|
if( fillType != Box::Unfilled )
|
||||||
box->setBackground( fillType, QskRgb::CornflowerBlue );
|
box->setTonalGradient( fillType, QskRgb::CornflowerBlue );
|
||||||
|
|
||||||
if( rounded )
|
if( rounded )
|
||||||
box->setShape( 30, Qt::AbsoluteSize );
|
box->setShape( 30, Qt::AbsoluteSize );
|
||||||
|
|
@ -435,11 +438,11 @@ static void addColoredBorderRectangles4( QskLinearBox* parent, bool rounded, Box
|
||||||
{
|
{
|
||||||
Box* box = new Box( parent );
|
Box* box = new Box( parent );
|
||||||
box->setBorderWidth( 20 );
|
box->setBorderWidth( 20 );
|
||||||
QskGradient gradient( Qt::Vertical, Qt::magenta, Qt::cyan );
|
|
||||||
box->setBorderGradients( gradient, gradient, gradient, gradient );
|
box->setBorderGradient( QskGradient( Qt::magenta, Qt::cyan ) );
|
||||||
|
|
||||||
if( fillType != Box::Unfilled )
|
if( fillType != Box::Unfilled )
|
||||||
box->setBackground( fillType, QskRgb::CornflowerBlue );
|
box->setTonalGradient( fillType, QskRgb::CornflowerBlue );
|
||||||
|
|
||||||
if( rounded )
|
if( rounded )
|
||||||
box->setShape( 30, Qt::AbsoluteSize );
|
box->setShape( 30, Qt::AbsoluteSize );
|
||||||
|
|
@ -449,14 +452,14 @@ static void addColoredBorderRectangles5( QskLinearBox* parent, bool rounded, Box
|
||||||
{
|
{
|
||||||
Box* box = new Box( parent );
|
Box* box = new Box( parent );
|
||||||
box->setBorderWidth( 20 );
|
box->setBorderWidth( 20 );
|
||||||
QskGradient gradient( Qt::Vertical, { { 0.0, Qt::black },
|
|
||||||
{ 0.3, Qt::white },
|
const QskGradientStops stops = { { 0.0, Qt::black }, { 0.3, Qt::white },
|
||||||
{ 0.7, Qt::white },
|
{ 0.7, Qt::white }, { 1.0, Qt::black } };
|
||||||
{ 1.0, Qt::black } } );
|
|
||||||
box->setBorderGradients( gradient, gradient, gradient, gradient );
|
box->setBorderGradient( stops );
|
||||||
|
|
||||||
if( fillType != Box::Unfilled )
|
if( fillType != Box::Unfilled )
|
||||||
box->setBackground( fillType, QskRgb::CornflowerBlue );
|
box->setTonalGradient( fillType, QskRgb::CornflowerBlue );
|
||||||
|
|
||||||
if( rounded )
|
if( rounded )
|
||||||
box->setShape( { 10, 20, 20, 40 } );
|
box->setShape( { 10, 20, 20, 40 } );
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,14 @@
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
|
||||||
#include <QskAspect.h>
|
#include <QskAspect.h>
|
||||||
#include <QskGradient.h>
|
#include <QskLinearGradient.h>
|
||||||
#include <QskGraphicLabel.h>
|
#include <QskGraphicLabel.h>
|
||||||
#include <QskObjectCounter.h>
|
#include <QskObjectCounter.h>
|
||||||
#include <QskShortcutMap.h>
|
#include <QskShortcutMap.h>
|
||||||
#include <QskSubWindow.h>
|
#include <QskSubWindow.h>
|
||||||
#include <QskSubWindowArea.h>
|
#include <QskSubWindowArea.h>
|
||||||
#include <QskWindow.h>
|
#include <QskWindow.h>
|
||||||
|
#include <QskRgbValue.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
|
@ -59,7 +60,7 @@ int main( int argc, char* argv[] )
|
||||||
|
|
||||||
QskSubWindowArea* area = new QskSubWindowArea();
|
QskSubWindowArea* area = new QskSubWindowArea();
|
||||||
area->setGradientHint( QskSubWindowArea::Panel,
|
area->setGradientHint( QskSubWindowArea::Panel,
|
||||||
QskGradient( QskGradient::Diagonal, "DarkSlateGray", "LightSlateGray" ) );
|
QskLinearGradient( 0.0, 0.0, 1.0, 1.0, QskRgb::DarkSlateGray, QskRgb::LightSlateGray ) );
|
||||||
|
|
||||||
QRectF windowRect( 0, 0, 250, 250 );
|
QRectF windowRect( 0, 0, 250, 250 );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,7 @@ namespace
|
||||||
colors += hctColor.toned( 45 ).rgb();
|
colors += hctColor.toned( 45 ).rgb();
|
||||||
colors += hctColor.toned( 30 ).rgb();
|
colors += hctColor.toned( 30 ).rgb();
|
||||||
|
|
||||||
setBarGradient( QskGradient( orientation(),
|
setBarGradient( qskBuildGradientStops( colors, true ) );
|
||||||
qskBuildGradientStops( colors, true ) ) );
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include <QskBoxShapeMetrics.h>
|
#include <QskBoxShapeMetrics.h>
|
||||||
#include <QskBoxBorderMetrics.h>
|
#include <QskBoxBorderMetrics.h>
|
||||||
#include <QskBoxBorderColors.h>
|
#include <QskBoxBorderColors.h>
|
||||||
|
#include <QskLinearGradient.h>
|
||||||
#include <QskFunctions.h>
|
#include <QskFunctions.h>
|
||||||
#include <QskShadowMetrics.h>
|
#include <QskShadowMetrics.h>
|
||||||
#include <QskSkinHintTableEditor.h>
|
#include <QskSkinHintTableEditor.h>
|
||||||
|
|
@ -111,11 +112,11 @@ void Skin::initHints( const Palette& palette )
|
||||||
ed.setColor( TopBarItem::Item3 | QskAspect::TextColor, 0xfff99055 );
|
ed.setColor( TopBarItem::Item3 | QskAspect::TextColor, 0xfff99055 );
|
||||||
ed.setColor( TopBarItem::Item4 | QskAspect::TextColor, 0xff6776ff );
|
ed.setColor( TopBarItem::Item4 | QskAspect::TextColor, 0xff6776ff );
|
||||||
|
|
||||||
// conical gradients are counterclockwise, so specify the 2nd color first:
|
// arcs are counterclockwise, so specify the 2nd color first:
|
||||||
ed.setHGradient( TopBarItem::Item1, 0xffff3122, 0xffff5c00 );
|
ed.setGradient( TopBarItem::Item1, 0xffff3122, 0xffff5c00 );
|
||||||
ed.setHGradient( TopBarItem::Item2, 0xff6100ff, 0xff6776ff );
|
ed.setGradient( TopBarItem::Item2, 0xff6100ff, 0xff6776ff );
|
||||||
ed.setHGradient( TopBarItem::Item3, 0xffff3122, 0xffffce50 );
|
ed.setGradient( TopBarItem::Item3, 0xffff3122, 0xffffce50 );
|
||||||
ed.setHGradient( TopBarItem::Item4, 0xff6100ff, 0xff6776ff );
|
ed.setGradient( TopBarItem::Item4, 0xff6100ff, 0xff6776ff );
|
||||||
|
|
||||||
// the bar gradient is defined through the top bar items above
|
// the bar gradient is defined through the top bar items above
|
||||||
ed.setArcMetrics( CircularProgressBar::Groove, { 8.53, 90, -360 } );
|
ed.setArcMetrics( CircularProgressBar::Groove, { 8.53, 90, -360 } );
|
||||||
|
|
@ -141,8 +142,8 @@ void Skin::initHints( const Palette& palette )
|
||||||
{
|
{
|
||||||
ed.setBoxShape( subControl, 6 );
|
ed.setBoxShape( subControl, 6 );
|
||||||
|
|
||||||
QskGradient normal( Qt::Vertical, 0xff6776ff, 0xff6100ff );
|
QskLinearGradient normal( Qt::Vertical, 0xff6776ff, 0xff6100ff );
|
||||||
QskGradient bright( Qt::Vertical, 0xffff7d34, 0xffff3122 );
|
QskLinearGradient bright( Qt::Vertical, 0xffff7d34, 0xffff3122 );
|
||||||
|
|
||||||
if ( subControl == RoundedIcon::PalePanel )
|
if ( subControl == RoundedIcon::PalePanel )
|
||||||
{
|
{
|
||||||
|
|
@ -197,9 +198,9 @@ void Skin::initHints( const Palette& palette )
|
||||||
ed.setBoxShape( LightDisplay::Panel, 100, Qt::RelativeSize );
|
ed.setBoxShape( LightDisplay::Panel, 100, Qt::RelativeSize );
|
||||||
|
|
||||||
ed.setArcMetrics( LightDisplay::ColdAndWarmArc, 8.785, 0, 180 );
|
ed.setArcMetrics( LightDisplay::ColdAndWarmArc, 8.785, 0, 180 );
|
||||||
QskGradient coldGradient( Qt::Horizontal,
|
const QskGradient coldGradient(
|
||||||
{ { 0.0, 0xffff3122 }, { 0.2, 0xfffeeeb7 },
|
{ { 0.0, 0xffff3122 }, { 0.2, 0xfffeeeb7 }, { 0.3, 0xffa7b0ff },
|
||||||
{ 0.3, 0xffa7b0ff }, { 0.5, 0xff6776ff }, { 1.0, Qt::black } } );
|
{ 0.5, 0xff6776ff }, { 1.0, Qt::black } } );
|
||||||
ed.setGradient( LightDisplay::ColdAndWarmArc, coldGradient );
|
ed.setGradient( LightDisplay::ColdAndWarmArc, coldGradient );
|
||||||
|
|
||||||
ed.setMetric( LightDisplay::Tickmarks, 1 );
|
ed.setMetric( LightDisplay::Tickmarks, 1 );
|
||||||
|
|
@ -250,7 +251,7 @@ Skin::Palette DaytimeSkin::palette() const
|
||||||
0xfff4f4f4,
|
0xfff4f4f4,
|
||||||
Qt::black,
|
Qt::black,
|
||||||
0xffe5e5e5,
|
0xffe5e5e5,
|
||||||
{ Qt::Vertical, { { 0.0, 0xffc4c4c4 }, { 0.5, 0xfff8f8f8 }, { 1.0, 0xffc4c4c4 } } }
|
{ { { 0.0, 0xffc4c4c4 }, { 0.5, 0xfff8f8f8 }, { 1.0, 0xffc4c4c4 } } }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -264,6 +265,6 @@ Skin::Palette NighttimeSkin::palette() const
|
||||||
0xff0c0c0c,
|
0xff0c0c0c,
|
||||||
Qt::white,
|
Qt::white,
|
||||||
0xff1a1a1a,
|
0xff1a1a1a,
|
||||||
{ Qt::Vertical, { { 0.0, 0xff666666 }, { 0.5, 0xff222222 }, { 1.0, 0xff333333 } } }
|
{ { { 0.0, 0xff666666 }, { 0.5, 0xff222222 }, { 1.0, 0xff333333 } } }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ class GraphicLabel : public QskGraphicLabel
|
||||||
|
|
||||||
const int duration = 500;
|
const int duration = 500;
|
||||||
|
|
||||||
const QskGradient oldGradient = background();
|
const auto oldGradient = background();
|
||||||
setGradientHint( Panel, gradient );
|
setGradientHint( Panel, gradient );
|
||||||
|
|
||||||
// finally setup a smooth transition manually
|
// finally setup a smooth transition manually
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
#include <QskSkin.h>
|
#include <QskSkin.h>
|
||||||
#include <QskPlatform.h>
|
#include <QskPlatform.h>
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
|
#include <QskLinearGradient.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +58,7 @@ namespace
|
||||||
ed.setStrutSize( Q::Knob, 30, 30 );
|
ed.setStrutSize( Q::Knob, 30, 30 );
|
||||||
ed.setBoxShape( Q::Knob, 100, Qt::RelativeSize );
|
ed.setBoxShape( Q::Knob, 100, Qt::RelativeSize );
|
||||||
ed.setGradient( Q::Knob,
|
ed.setGradient( Q::Knob,
|
||||||
QskGradient( QskGradient::Diagonal, rgb2, rgb1 ) );
|
QskLinearGradient( 0.0, 0.0, 1.0, 1.0, rgb2, rgb1 ) );
|
||||||
|
|
||||||
ed.setMetric( Q::Needle | QskAspect::Size, 2 );
|
ed.setMetric( Q::Needle | QskAspect::Size, 2 );
|
||||||
ed.setMetric( Q::Needle | QskAspect::Margin, 10 );
|
ed.setMetric( Q::Needle | QskAspect::Margin, 10 );
|
||||||
|
|
|
||||||
|
|
@ -42,73 +42,6 @@ static inline qreal effectivePenWidth(
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
class ShapeNode : public QskShapeNode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void updateShape( const QPainterPath& path,
|
|
||||||
const QTransform& transform, const QRectF& rect, const Gradient& gradient )
|
|
||||||
{
|
|
||||||
if ( gradient.isMonochrome() )
|
|
||||||
{
|
|
||||||
updateNode( path, transform, gradient.stops().first().color() );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Stupid code to map Gradient -> QGradient
|
|
||||||
Can be removed once Gradient has been merged into QskGradient.
|
|
||||||
*/
|
|
||||||
|
|
||||||
switch( static_cast<int>( gradient.type() ) )
|
|
||||||
{
|
|
||||||
case QGradient::LinearGradient:
|
|
||||||
{
|
|
||||||
const auto& g = gradient.asLinearGradient();
|
|
||||||
|
|
||||||
QLinearGradient qgradient( g.start(), g.stop() );
|
|
||||||
qgradient.setSpread( g.spread() );
|
|
||||||
qgradient.setStops( g.qtStops() );
|
|
||||||
|
|
||||||
updateNode( path, transform, rect, &qgradient );
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case QGradient::RadialGradient:
|
|
||||||
{
|
|
||||||
const auto& g = gradient.asRadialGradient();
|
|
||||||
|
|
||||||
QRadialGradient qgradient( g.center(), g.radius() );
|
|
||||||
qgradient.setSpread( g.spread() );
|
|
||||||
qgradient.setStops( g.qtStops() );
|
|
||||||
|
|
||||||
updateNode( path, transform, rect, &qgradient );
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case QGradient::ConicalGradient:
|
|
||||||
{
|
|
||||||
const auto& g = gradient.asConicGradient();
|
|
||||||
|
|
||||||
QConicalGradient qgradient( g.center(), g.startAngle() );
|
|
||||||
qgradient.setSpread( g.spread() );
|
|
||||||
qgradient.setStops( g.qtStops() );
|
|
||||||
|
|
||||||
/*
|
|
||||||
Once ConicGradient has become QskConicGradient we do not
|
|
||||||
need QConicalGradient anymore and passing the spanAngle
|
|
||||||
as extra parameter can go away.
|
|
||||||
*/
|
|
||||||
updateNode( path, transform, rect, &qgradient, g.spanAngle() );
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
ShapeItem::ShapeItem( QQuickItem* parent )
|
ShapeItem::ShapeItem( QQuickItem* parent )
|
||||||
: QskControl( parent )
|
: QskControl( parent )
|
||||||
{
|
{
|
||||||
|
|
@ -134,7 +67,7 @@ QPen ShapeItem::pen() const
|
||||||
return m_pen;
|
return m_pen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeItem::setGradient( const Gradient& gradient )
|
void ShapeItem::setGradient( const QskGradient& gradient )
|
||||||
{
|
{
|
||||||
if ( gradient != m_gradient )
|
if ( gradient != m_gradient )
|
||||||
{
|
{
|
||||||
|
|
@ -143,7 +76,7 @@ void ShapeItem::setGradient( const Gradient& gradient )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Gradient& ShapeItem::gradient() const
|
const QskGradient& ShapeItem::gradient() const
|
||||||
{
|
{
|
||||||
return m_gradient;
|
return m_gradient;
|
||||||
}
|
}
|
||||||
|
|
@ -173,7 +106,7 @@ void ShapeItem::updateNode( QSGNode* parentNode )
|
||||||
const auto rect = contentsRect();
|
const auto rect = contentsRect();
|
||||||
const auto pathRect = m_path.controlPointRect();
|
const auto pathRect = m_path.controlPointRect();
|
||||||
|
|
||||||
auto fillNode = static_cast< ShapeNode* >(
|
auto fillNode = static_cast< QskShapeNode* >(
|
||||||
QskSGNode::findChildNode( parentNode, FillRole ) );
|
QskSGNode::findChildNode( parentNode, FillRole ) );
|
||||||
|
|
||||||
auto borderNode = static_cast< QskStrokeNode* >(
|
auto borderNode = static_cast< QskStrokeNode* >(
|
||||||
|
|
@ -191,7 +124,7 @@ void ShapeItem::updateNode( QSGNode* parentNode )
|
||||||
{
|
{
|
||||||
if ( fillNode == nullptr )
|
if ( fillNode == nullptr )
|
||||||
{
|
{
|
||||||
fillNode = new ShapeNode;
|
fillNode = new QskShapeNode;
|
||||||
QskSGNode::setNodeRole( fillNode, FillRole );
|
QskSGNode::setNodeRole( fillNode, FillRole );
|
||||||
|
|
||||||
parentNode->prependChildNode( fillNode );
|
parentNode->prependChildNode( fillNode );
|
||||||
|
|
@ -205,7 +138,7 @@ void ShapeItem::updateNode( QSGNode* parentNode )
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto transform = ::transformForRects( pathRect, fillRect );
|
const auto transform = ::transformForRects( pathRect, fillRect );
|
||||||
fillNode->updateShape( m_path, transform, fillRect, m_gradient );
|
fillNode->updateNode( m_path, transform, fillRect, m_gradient );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Gradient.h"
|
#include <QskGradient.h>
|
||||||
#include <QskControl.h>
|
#include <QskControl.h>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
|
||||||
class Gradient;
|
|
||||||
|
|
||||||
class ShapeItem : public QskControl
|
class ShapeItem : public QskControl
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -23,8 +21,8 @@ class ShapeItem : public QskControl
|
||||||
void setPen( const QPen& );
|
void setPen( const QPen& );
|
||||||
QPen pen() const;
|
QPen pen() const;
|
||||||
|
|
||||||
void setGradient( const Gradient& );
|
void setGradient( const QskGradient& );
|
||||||
const Gradient& gradient() const;
|
const QskGradient& gradient() const;
|
||||||
|
|
||||||
void setPath( const QPainterPath& );
|
void setPath( const QPainterPath& );
|
||||||
QPainterPath path() const;
|
QPainterPath path() const;
|
||||||
|
|
@ -36,6 +34,6 @@ class ShapeItem : public QskControl
|
||||||
QPainterPath scaledPath( const QRectF& ) const;
|
QPainterPath scaledPath( const QRectF& ) const;
|
||||||
|
|
||||||
QPen m_pen;
|
QPen m_pen;
|
||||||
Gradient m_gradient;
|
QskGradient m_gradient;
|
||||||
QPainterPath m_path;
|
QPainterPath m_path;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,15 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "ShapeItem.h"
|
#include "ShapeItem.h"
|
||||||
#include "Gradient.h"
|
|
||||||
|
|
||||||
#include <QskObjectCounter.h>
|
#include <QskObjectCounter.h>
|
||||||
#include <QskWindow.h>
|
#include <QskWindow.h>
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
#include <QskLinearBox.h>
|
#include <QskLinearBox.h>
|
||||||
#include <QskTabView.h>
|
#include <QskTabView.h>
|
||||||
|
#include <QskLinearGradient.h>
|
||||||
|
#include <QskRadialGradient.h>
|
||||||
|
#include <QskConicGradient.h>
|
||||||
|
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
#include <SkinnyShapeFactory.h>
|
#include <SkinnyShapeFactory.h>
|
||||||
|
|
@ -63,9 +65,32 @@ namespace
|
||||||
shapeItem->setPath( path( SkinnyShapeFactory::Hexagon ) );
|
shapeItem->setPath( path( SkinnyShapeFactory::Hexagon ) );
|
||||||
shapeItem->setPen( pen( QColorConstants::Svg::indigo ) );
|
shapeItem->setPen( pen( QColorConstants::Svg::indigo ) );
|
||||||
|
|
||||||
LinearGradient gradient( 0.0, 0.0, 0.2, 0.5 );
|
QskLinearGradient gradient( 0.0, 0.0, 0.2, 0.5, QGradient::PhoenixStart );
|
||||||
gradient.setSpread( QGradient::ReflectSpread );
|
gradient.setSpread( QGradient::ReflectSpread );
|
||||||
gradient.setStops( QGradient::PhoenixStart );
|
|
||||||
|
shapeItem->setGradient( gradient );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto shapeItem = new ShapeItem( this );
|
||||||
|
shapeItem->setPath( path( SkinnyShapeFactory::Star ) );
|
||||||
|
|
||||||
|
const QVector< QskGradientStop > stops =
|
||||||
|
{ { 0.5, QskRgb::RoyalBlue }, { 0.5, QskRgb::LemonChiffon } };
|
||||||
|
|
||||||
|
QskLinearGradient gradient( 0.0, 0.0, 0.05, 0.1, stops );
|
||||||
|
gradient.setSpread( QGradient::RepeatSpread );
|
||||||
|
|
||||||
|
shapeItem->setGradient( gradient );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto shapeItem = new ShapeItem( this );
|
||||||
|
shapeItem->setPath( path( SkinnyShapeFactory::Rectangle ) );
|
||||||
|
|
||||||
|
const QVector< QskGradientStop > stops =
|
||||||
|
{ { 0.5, QskRgb::MediumVioletRed }, { 0.5, QskRgb::Navy } };
|
||||||
|
|
||||||
|
QskLinearGradient gradient( 0.5, 0.0, 0.5, 0.5, stops );
|
||||||
|
|
||||||
shapeItem->setGradient( gradient );
|
shapeItem->setGradient( gradient );
|
||||||
}
|
}
|
||||||
|
|
@ -84,11 +109,9 @@ namespace
|
||||||
shapeItem->setPath( path( SkinnyShapeFactory::Rectangle ) );
|
shapeItem->setPath( path( SkinnyShapeFactory::Rectangle ) );
|
||||||
shapeItem->setPen( pen( QColorConstants::Svg::indigo ) );
|
shapeItem->setPen( pen( QColorConstants::Svg::indigo ) );
|
||||||
|
|
||||||
RadialGradient gradient( 0.5, 0.5, 0.5 );
|
QskRadialGradient gradient;
|
||||||
|
gradient.setStops( QskRgb::LightYellow, QskRgb::MidnightBlue );
|
||||||
gradient.setSpread( QGradient::PadSpread );
|
gradient.setSpread( QGradient::PadSpread );
|
||||||
gradient.setStops( QColorConstants::Svg::lightyellow,
|
|
||||||
QColorConstants::Svg::midnightblue );
|
|
||||||
|
|
||||||
shapeItem->setGradient( gradient );
|
shapeItem->setGradient( gradient );
|
||||||
}
|
}
|
||||||
|
|
@ -97,23 +120,22 @@ namespace
|
||||||
|
|
||||||
shapeItem->setPath( path( SkinnyShapeFactory::Ellipse ) );
|
shapeItem->setPath( path( SkinnyShapeFactory::Ellipse ) );
|
||||||
|
|
||||||
RadialGradient gradient( 0.5, 0.5, 0.5 );
|
|
||||||
gradient.setSpread( QGradient::PadSpread );
|
|
||||||
|
|
||||||
QVector< QskGradientStop > stops;
|
QVector< QskGradientStop > stops;
|
||||||
|
|
||||||
stops += QskGradientStop( 0.0, Qt::green );
|
stops += QskGradientStop( 0.0, Qt::green );
|
||||||
stops += QskGradientStop( 0.2, Qt::green );
|
stops += QskGradientStop( 0.2, Qt::green );
|
||||||
stops += QskGradientStop( 0.201, Qt::red );
|
stops += QskGradientStop( 0.2, Qt::red );
|
||||||
stops += QskGradientStop( 0.4, Qt::red );
|
stops += QskGradientStop( 0.4, Qt::red );
|
||||||
stops += QskGradientStop( 0.401, Qt::yellow );
|
stops += QskGradientStop( 0.4, Qt::yellow );
|
||||||
stops += QskGradientStop( 0.6, Qt::yellow );
|
stops += QskGradientStop( 0.6, Qt::yellow );
|
||||||
stops += QskGradientStop( 0.601, Qt::cyan );
|
stops += QskGradientStop( 0.6, Qt::cyan );
|
||||||
stops += QskGradientStop( 0.8, Qt::cyan );
|
stops += QskGradientStop( 0.8, Qt::cyan );
|
||||||
stops += QskGradientStop( 0.801, Qt::darkCyan );
|
stops += QskGradientStop( 0.8, Qt::darkCyan );
|
||||||
stops += QskGradientStop( 1.0, Qt::darkCyan );
|
stops += QskGradientStop( 1.0, Qt::darkCyan );
|
||||||
|
|
||||||
gradient.setStops( stops );
|
QskRadialGradient gradient( stops );
|
||||||
|
gradient.setSpread( QGradient::PadSpread );
|
||||||
|
|
||||||
shapeItem->setGradient( gradient );
|
shapeItem->setGradient( gradient );
|
||||||
}
|
}
|
||||||
|
|
@ -121,13 +143,10 @@ namespace
|
||||||
auto shapeItem = new ShapeItem( this );
|
auto shapeItem = new ShapeItem( this );
|
||||||
|
|
||||||
shapeItem->setPath( path( SkinnyShapeFactory::Rectangle ) );
|
shapeItem->setPath( path( SkinnyShapeFactory::Rectangle ) );
|
||||||
shapeItem->setPen( pen( QColorConstants::Svg::indigo ) );
|
shapeItem->setPen( pen( QskRgb::Indigo ) );
|
||||||
|
|
||||||
RadialGradient gradient( 0.5, 0.5, 0.25 );
|
|
||||||
gradient.setCenter( 0.5, 0.7 );
|
|
||||||
|
|
||||||
|
QskRadialGradient gradient( 0.5, 0.7, 0.25, QGradient::LilyMeadow );
|
||||||
gradient.setSpread( QGradient::RepeatSpread );
|
gradient.setSpread( QGradient::RepeatSpread );
|
||||||
gradient.setStops( QGradient::LilyMeadow );
|
|
||||||
|
|
||||||
shapeItem->setGradient( gradient );
|
shapeItem->setGradient( gradient );
|
||||||
}
|
}
|
||||||
|
|
@ -135,12 +154,10 @@ namespace
|
||||||
auto shapeItem = new ShapeItem( this );
|
auto shapeItem = new ShapeItem( this );
|
||||||
|
|
||||||
shapeItem->setPath( path( SkinnyShapeFactory::Rectangle ) );
|
shapeItem->setPath( path( SkinnyShapeFactory::Rectangle ) );
|
||||||
shapeItem->setPen( pen( QColorConstants::Svg::indigo ) );
|
shapeItem->setPen( pen( QskRgb::Indigo ) );
|
||||||
|
|
||||||
RadialGradient gradient( 0.6, 0.4, 0.1 );
|
|
||||||
|
|
||||||
|
QskRadialGradient gradient( 0.6, 0.4, 0.1, Qt::red, Qt::blue );
|
||||||
gradient.setSpread( QGradient::ReflectSpread );
|
gradient.setSpread( QGradient::ReflectSpread );
|
||||||
gradient.setStops( Qt::red, Qt::blue );
|
|
||||||
|
|
||||||
shapeItem->setGradient( gradient );
|
shapeItem->setGradient( gradient );
|
||||||
}
|
}
|
||||||
|
|
@ -158,7 +175,7 @@ namespace
|
||||||
|
|
||||||
shapeItem->setPath( path( SkinnyShapeFactory::Ellipse ) );
|
shapeItem->setPath( path( SkinnyShapeFactory::Ellipse ) );
|
||||||
|
|
||||||
ConicGradient gradient( 0.5, 0.5, 30.0, 60.0 );
|
QskConicGradient gradient( 0.5, 0.5, 30.0, 60.0 );
|
||||||
gradient.setSpread( QGradient::ReflectSpread );
|
gradient.setSpread( QGradient::ReflectSpread );
|
||||||
gradient.setStops( QGradient::JuicyPeach );
|
gradient.setStops( QGradient::JuicyPeach );
|
||||||
|
|
||||||
|
|
@ -169,7 +186,7 @@ namespace
|
||||||
|
|
||||||
shapeItem->setPath( path( SkinnyShapeFactory::TriangleUp ) );
|
shapeItem->setPath( path( SkinnyShapeFactory::TriangleUp ) );
|
||||||
|
|
||||||
ConicGradient gradient( 0.5, 0.5, 30.0, 60.0 );
|
QskConicGradient gradient( 0.5, 0.5, 30.0, 60.0 );
|
||||||
gradient.setSpread( QGradient::RepeatSpread );
|
gradient.setSpread( QGradient::RepeatSpread );
|
||||||
gradient.setStops( QGradient::WinterNeva );
|
gradient.setStops( QGradient::WinterNeva );
|
||||||
|
|
||||||
|
|
@ -180,7 +197,7 @@ namespace
|
||||||
|
|
||||||
shapeItem->setPath( path( SkinnyShapeFactory::Arc ) );
|
shapeItem->setPath( path( SkinnyShapeFactory::Arc ) );
|
||||||
|
|
||||||
ConicGradient gradient( 0.5, 0.5, 300.0, -240.0 );
|
QskConicGradient gradient( 0.5, 0.5, 300.0, -240.0 );
|
||||||
gradient.setStops( QGradient::SpikyNaga );
|
gradient.setStops( QGradient::SpikyNaga );
|
||||||
|
|
||||||
shapeItem->setGradient( gradient );
|
shapeItem->setGradient( gradient );
|
||||||
|
|
@ -190,7 +207,7 @@ namespace
|
||||||
|
|
||||||
shapeItem->setPath( path( SkinnyShapeFactory::Diamond ) );
|
shapeItem->setPath( path( SkinnyShapeFactory::Diamond ) );
|
||||||
|
|
||||||
ConicGradient gradient( 0.5, 0.5, 45.0, 180.0 );
|
QskConicGradient gradient( 0.5, 0.5, 45.0, 180.0 );
|
||||||
gradient.setStops( QGradient::FabledSunset );
|
gradient.setStops( QGradient::FabledSunset );
|
||||||
gradient.setSpread( QGradient::ReflectSpread );
|
gradient.setSpread( QGradient::ReflectSpread );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
CONFIG += qskexample
|
CONFIG += qskexample
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
Gradient.h \
|
|
||||||
ShapeItem.h \
|
ShapeItem.h \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
Gradient.cpp \
|
|
||||||
ShapeItem.cpp \
|
ShapeItem.cpp \
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
#include <QskBoxBorderMetrics.h>
|
#include <QskBoxBorderMetrics.h>
|
||||||
#include <QskBoxShapeMetrics.h>
|
#include <QskBoxShapeMetrics.h>
|
||||||
#include <QskPlatform.h>
|
#include <QskPlatform.h>
|
||||||
#include <QskGradient.h>
|
#include <QskLinearGradient.h>
|
||||||
#include <QskMargins.h>
|
#include <QskMargins.h>
|
||||||
#include <QskNamespace.h>
|
#include <QskNamespace.h>
|
||||||
#include <QskRgbValue.h>
|
#include <QskRgbValue.h>
|
||||||
|
|
@ -176,10 +176,10 @@ namespace
|
||||||
|
|
||||||
void Editor::setSeparator( QskAspect aspect )
|
void Editor::setSeparator( QskAspect aspect )
|
||||||
{
|
{
|
||||||
QskGradient gradient( QskGradient::Vertical, m_pal.lighter110, m_pal.darker125 );
|
QskLinearGradient gradient( Qt::Vertical, m_pal.lighter110, m_pal.darker125 );
|
||||||
|
|
||||||
if ( aspect.placement() == QskAspect::Vertical )
|
if ( aspect.placement() == QskAspect::Vertical )
|
||||||
gradient.setOrientation( QskGradient::Horizontal );
|
gradient.setOrientation( Qt::Horizontal );
|
||||||
|
|
||||||
setGradient( aspect, gradient );
|
setGradient( aspect, gradient );
|
||||||
setBoxShape( aspect, 0 );
|
setBoxShape( aspect, 0 );
|
||||||
|
|
@ -193,7 +193,7 @@ void Editor::setButton( QskAspect aspect, PanelStyle style, qreal border )
|
||||||
#endif
|
#endif
|
||||||
QskBoxBorderColors borderColors;
|
QskBoxBorderColors borderColors;
|
||||||
|
|
||||||
QskGradient gradient( QskGradient::Vertical );
|
QskLinearGradient gradient( Qt::Vertical );
|
||||||
|
|
||||||
switch ( style )
|
switch ( style )
|
||||||
{
|
{
|
||||||
|
|
@ -637,8 +637,7 @@ void Editor::setupTabButton()
|
||||||
|
|
||||||
for ( auto placement : { A::Top, A::Bottom } )
|
for ( auto placement : { A::Top, A::Bottom } )
|
||||||
{
|
{
|
||||||
setGradient( Q::Panel | placement,
|
setVGradient( Q::Panel | placement, m_pal.lighter125, m_pal.lighter110 );
|
||||||
QskGradient( Qt::Vertical, m_pal.lighter125, m_pal.lighter110 ) );
|
|
||||||
|
|
||||||
for ( const auto state : { Q::Checked | A::NoState, Q::Checked | Q::Pressed } )
|
for ( const auto state : { Q::Checked | A::NoState, Q::Checked | Q::Pressed } )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include "QskGradient.h"
|
#include "QskGradient.h"
|
||||||
#include "QskRgbValue.h"
|
#include "QskRgbValue.h"
|
||||||
|
|
||||||
#include <qhashfunctions.h>
|
|
||||||
#include <qvariant.h>
|
#include <qvariant.h>
|
||||||
|
|
||||||
static void qskRegisterGradient()
|
static void qskRegisterGradient()
|
||||||
|
|
@ -23,12 +22,6 @@ static void qskRegisterGradient()
|
||||||
|
|
||||||
Q_CONSTRUCTOR_FUNCTION( qskRegisterGradient )
|
Q_CONSTRUCTOR_FUNCTION( qskRegisterGradient )
|
||||||
|
|
||||||
static inline QskGradient::Orientation qskOrientation( Qt::Orientation o )
|
|
||||||
{
|
|
||||||
return ( o == Qt::Vertical )
|
|
||||||
? QskGradient::Vertical : QskGradient::Horizontal;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool qskIsGradientValid( const QskGradientStops& stops )
|
static inline bool qskIsGradientValid( const QskGradientStops& stops )
|
||||||
{
|
{
|
||||||
if ( stops.isEmpty() )
|
if ( stops.isEmpty() )
|
||||||
|
|
@ -57,66 +50,74 @@ static inline bool qskCanBeInterpolated( const QskGradient& from, const QskGradi
|
||||||
if ( from.isMonochrome() || to.isMonochrome() )
|
if ( from.isMonochrome() || to.isMonochrome() )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return from.orientation() == to.orientation();
|
return from.type() == to.type();
|
||||||
}
|
|
||||||
|
|
||||||
QskGradient::QskGradient( Orientation orientation ) noexcept
|
|
||||||
: m_orientation( orientation )
|
|
||||||
, m_isDirty( false )
|
|
||||||
, m_isValid( false )
|
|
||||||
, m_isMonchrome( true )
|
|
||||||
, m_isVisible( false )
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradient::QskGradient( const QColor& color )
|
QskGradient::QskGradient( const QColor& color )
|
||||||
: QskGradient( Vertical )
|
|
||||||
{
|
{
|
||||||
setStops( color );
|
setStops( color );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradient::QskGradient( Qt::Orientation orientation,
|
QskGradient::QskGradient( const QColor& color1, const QColor& color2 )
|
||||||
const QColor& startColor, const QColor& stopColor )
|
|
||||||
: QskGradient( qskOrientation( orientation ), startColor, stopColor )
|
|
||||||
{
|
{
|
||||||
|
setStops( color1, color2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradient::QskGradient( Orientation orientation,
|
QskGradient::QskGradient( QGradient::Preset preset )
|
||||||
const QColor& startColor, const QColor& stopColor )
|
|
||||||
: QskGradient( orientation )
|
|
||||||
{
|
{
|
||||||
setStops( startColor, stopColor );
|
setStops( qskBuildGradientStops( QGradient( preset ).stops() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradient::QskGradient( Qt::Orientation orientation, const QskGradientStops& stops )
|
QskGradient::QskGradient( const QVector< QskGradientStop >& stops )
|
||||||
: QskGradient( qskOrientation( orientation ), stops )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QskGradient::QskGradient( Orientation orientation, const QskGradientStops& stops )
|
|
||||||
: QskGradient( orientation )
|
|
||||||
{
|
{
|
||||||
setStops( stops );
|
setStops( stops );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradient::QskGradient( Qt::Orientation orientation, QGradient::Preset preset )
|
QskGradient::QskGradient( const QskGradient& other ) noexcept
|
||||||
: QskGradient( qskOrientation( orientation ), preset )
|
: m_stops( other.m_stops )
|
||||||
|
, m_values{ other.m_values[0], other.m_values[1],
|
||||||
|
other.m_values[2], other.m_values[3], }
|
||||||
|
, m_type( other.m_type )
|
||||||
|
, m_spread( other.m_spread )
|
||||||
|
, m_isDirty( other.m_isDirty )
|
||||||
|
, m_isValid( other.m_isValid )
|
||||||
|
, m_isMonchrome( other.m_isMonchrome )
|
||||||
|
, m_isVisible( other.m_isVisible )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradient::QskGradient( Orientation orientation, QGradient::Preset preset )
|
|
||||||
: QskGradient( orientation )
|
|
||||||
{
|
|
||||||
setStops( qskBuildGradientStops( QGradient( preset ).stops() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
QskGradient::~QskGradient()
|
QskGradient::~QskGradient()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QskGradient& QskGradient::operator=( const QskGradient& other ) noexcept
|
||||||
|
{
|
||||||
|
m_type = other.m_type;
|
||||||
|
m_spread = other.m_spread;
|
||||||
|
m_stops = other.m_stops;
|
||||||
|
|
||||||
|
m_values[0] = other.m_values[0];
|
||||||
|
m_values[1] = other.m_values[1];
|
||||||
|
m_values[2] = other.m_values[2];
|
||||||
|
m_values[3] = other.m_values[3];
|
||||||
|
|
||||||
|
m_isDirty = other.m_isDirty;
|
||||||
|
m_isValid = other.m_isValid;
|
||||||
|
m_isMonchrome = other.m_isMonchrome;
|
||||||
|
m_isVisible = other.m_isVisible;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
bool QskGradient::operator==( const QskGradient& other ) const noexcept
|
bool QskGradient::operator==( const QskGradient& other ) const noexcept
|
||||||
{
|
{
|
||||||
return ( m_orientation == other.m_orientation ) && ( m_stops == other.m_stops );
|
return ( m_type == other.m_type )
|
||||||
|
&& ( m_spread == other.m_spread )
|
||||||
|
&& ( m_values[0] == other.m_values[0] )
|
||||||
|
&& ( m_values[1] == other.m_values[1] )
|
||||||
|
&& ( m_values[2] == other.m_values[2] )
|
||||||
|
&& ( m_values[3] == other.m_values[3] )
|
||||||
|
&& ( m_stops == other.m_stops );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskGradient::updateStatusBits() const
|
void QskGradient::updateStatusBits() const
|
||||||
|
|
@ -162,17 +163,6 @@ bool QskGradient::isVisible() const noexcept
|
||||||
return m_isVisible;
|
return m_isVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskGradient::setOrientation( Qt::Orientation orientation ) noexcept
|
|
||||||
{
|
|
||||||
setOrientation( qskOrientation( orientation ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskGradient::setOrientation( Orientation orientation ) noexcept
|
|
||||||
{
|
|
||||||
// does not change m_isDirty
|
|
||||||
m_orientation = orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QskGradient::setStops( const QColor& color )
|
void QskGradient::setStops( const QColor& color )
|
||||||
{
|
{
|
||||||
m_stops = { { 0.0, color }, { 1.0, color } };
|
m_stops = { { 0.0, color }, { 1.0, color } };
|
||||||
|
|
@ -185,6 +175,12 @@ void QskGradient::setStops( const QColor& color1, const QColor& color2 )
|
||||||
m_isDirty = true;
|
m_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskGradient::setStops( QGradient::Preset preset )
|
||||||
|
{
|
||||||
|
const auto stops = qskBuildGradientStops( QGradient( preset ).stops() );
|
||||||
|
setStops( stops );
|
||||||
|
}
|
||||||
|
|
||||||
void QskGradient::setStops( const QskGradientStops& stops )
|
void QskGradient::setStops( const QskGradientStops& stops )
|
||||||
{
|
{
|
||||||
if ( !stops.isEmpty() && !qskIsGradientValid( stops ) )
|
if ( !stops.isEmpty() && !qskIsGradientValid( stops ) )
|
||||||
|
|
@ -262,6 +258,11 @@ void QskGradient::setAlpha( int alpha )
|
||||||
m_isDirty = true;
|
m_isDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskGradient::setSpread( QGradient::Spread spread )
|
||||||
|
{
|
||||||
|
m_spread = spread;
|
||||||
|
}
|
||||||
|
|
||||||
void QskGradient::reverse()
|
void QskGradient::reverse()
|
||||||
{
|
{
|
||||||
if ( isMonochrome() )
|
if ( isMonochrome() )
|
||||||
|
|
@ -314,13 +315,16 @@ QskGradient QskGradient::interpolated( const QskGradient& to, qreal ratio ) cons
|
||||||
|
|
||||||
if ( qskCanBeInterpolated( *this, to ) )
|
if ( qskCanBeInterpolated( *this, to ) )
|
||||||
{
|
{
|
||||||
// We simply interpolate stops
|
// We simply interpolate stops and values
|
||||||
|
|
||||||
gradient.setOrientation( to.orientation() );
|
gradient = to;
|
||||||
|
|
||||||
gradient.setStops( qskInterpolatedGradientStops(
|
gradient.setStops( qskInterpolatedGradientStops(
|
||||||
m_stops, isMonochrome(),
|
m_stops, isMonochrome(),
|
||||||
to.m_stops, to.isMonochrome(), ratio ) );
|
to.m_stops, to.isMonochrome(), ratio ) );
|
||||||
|
|
||||||
|
for ( uint i = 0; i < sizeof( m_values ) / sizeof( m_values[0] ); i++ )
|
||||||
|
gradient.m_values[i] = m_values[i] + ratio * ( to.m_values[i] - m_values[i] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -338,14 +342,14 @@ QskGradient QskGradient::interpolated( const QskGradient& to, qreal ratio ) cons
|
||||||
{
|
{
|
||||||
const auto r = 2.0 * ratio;
|
const auto r = 2.0 * ratio;
|
||||||
|
|
||||||
gradient.setOrientation( orientation() );
|
gradient = *this;
|
||||||
gradient.setStops( qskInterpolatedGradientStops( m_stops, c, r ) );
|
gradient.setStops( qskInterpolatedGradientStops( m_stops, c, r ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto r = 2.0 * ( ratio - 0.5 );
|
const auto r = 2.0 * ( ratio - 0.5 );
|
||||||
|
|
||||||
gradient.setOrientation( to.orientation() );
|
gradient = to;
|
||||||
gradient.setStops( qskInterpolatedGradientStops( c, to.m_stops, r ) );
|
gradient.setStops( qskInterpolatedGradientStops( c, to.m_stops, r ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -370,15 +374,57 @@ void QskGradient::clearStops()
|
||||||
|
|
||||||
QskHashValue QskGradient::hash( QskHashValue seed ) const
|
QskHashValue QskGradient::hash( QskHashValue seed ) const
|
||||||
{
|
{
|
||||||
const auto o = orientation();
|
auto hash = qHashBits( &m_type, sizeof( m_type ), seed );
|
||||||
|
|
||||||
|
if ( m_type != Stops )
|
||||||
|
hash = qHashBits( m_values, sizeof( m_values ), seed );
|
||||||
|
|
||||||
auto hash = qHashBits( &o, sizeof( o ), seed );
|
|
||||||
for ( const auto& stop : m_stops )
|
for ( const auto& stop : m_stops )
|
||||||
hash = stop.hash( hash );
|
hash = stop.hash( hash );
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "QskLinearGradient.h"
|
||||||
|
#include "QskRadialGradient.h"
|
||||||
|
#include "QskConicGradient.h"
|
||||||
|
|
||||||
|
QskLinearGradient& QskGradient::asLinearGradient()
|
||||||
|
{
|
||||||
|
assert( m_type == QskGradient::Linear );
|
||||||
|
return *reinterpret_cast< QskLinearGradient* >( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
const QskLinearGradient& QskGradient::asLinearGradient() const
|
||||||
|
{
|
||||||
|
assert( m_type == QskGradient::Linear );
|
||||||
|
return *reinterpret_cast< const QskLinearGradient* >( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
QskRadialGradient& QskGradient::asRadialGradient()
|
||||||
|
{
|
||||||
|
assert( m_type == QskGradient::Radial );
|
||||||
|
return *reinterpret_cast< QskRadialGradient* >( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
const QskRadialGradient& QskGradient::asRadialGradient() const
|
||||||
|
{
|
||||||
|
assert( m_type == QskGradient::Radial );
|
||||||
|
return *reinterpret_cast< const QskRadialGradient* >( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
QskConicGradient& QskGradient::asConicGradient()
|
||||||
|
{
|
||||||
|
assert( m_type == QskGradient::Conic );
|
||||||
|
return *reinterpret_cast< QskConicGradient* >( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
const QskConicGradient& QskGradient::asConicGradient() const
|
||||||
|
{
|
||||||
|
assert( m_type == QskGradient::Conic );
|
||||||
|
return *reinterpret_cast< const QskConicGradient* >( this );
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
|
|
@ -388,33 +434,67 @@ QDebug operator<<( QDebug debug, const QskGradient& gradient )
|
||||||
QDebugStateSaver saver( debug );
|
QDebugStateSaver saver( debug );
|
||||||
debug.nospace();
|
debug.nospace();
|
||||||
|
|
||||||
debug << "Gradient";
|
debug << "QskGradient( ";
|
||||||
|
|
||||||
if ( !gradient.isValid() )
|
switch ( gradient.type() )
|
||||||
{
|
{
|
||||||
debug << "()";
|
case QskGradient::Linear:
|
||||||
|
{
|
||||||
|
debug << "L(";
|
||||||
|
|
||||||
|
const auto& g = gradient.asLinearGradient();
|
||||||
|
debug << g.start().x() << "," << g.start().y()
|
||||||
|
<< "," << g.stop().x() << "," << g.stop().y() << ")";
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case QskGradient::Radial:
|
||||||
|
{
|
||||||
|
debug << "R(";
|
||||||
|
|
||||||
|
const auto& g = gradient.asRadialGradient();
|
||||||
|
|
||||||
|
debug << g.center().x() << "," << g.center().y()
|
||||||
|
<< "," << g.radius() << ")";
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case QskGradient::Conic:
|
||||||
|
{
|
||||||
|
debug << "C(";
|
||||||
|
|
||||||
|
const auto& g = gradient.asConicGradient();
|
||||||
|
|
||||||
|
debug << g.center().x() << "," << g.center().y()
|
||||||
|
<< ",[" << g.startAngle() << "," << g.spanAngle() << "])";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case QskGradient::Stops:
|
||||||
|
{
|
||||||
|
debug << "S()";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( gradient.stops().isEmpty() )
|
||||||
|
{
|
||||||
|
debug << " ()";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug << "( ";
|
|
||||||
|
|
||||||
if ( gradient.isMonochrome() )
|
if ( gradient.isMonochrome() )
|
||||||
{
|
{
|
||||||
QskRgb::debugColor( debug, gradient.startColor() );
|
debug << ' ';
|
||||||
|
const auto color = gradient.stops().first().color();
|
||||||
|
QskRgb::debugColor( debug, color );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char o[] = { 'H', 'V', 'D' };
|
debug << " ( ";
|
||||||
debug << o[ gradient.orientation() ] << ", ";
|
|
||||||
|
|
||||||
if ( gradient.stops().count() == 2 )
|
|
||||||
{
|
|
||||||
QskRgb::debugColor( debug, gradient.startColor() );
|
|
||||||
debug << ", ";
|
|
||||||
QskRgb::debugColor( debug, gradient.endColor() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const auto& stops = gradient.stops();
|
const auto& stops = gradient.stops();
|
||||||
for ( int i = 0; i < stops.count(); i++ )
|
for ( int i = 0; i < stops.count(); i++ )
|
||||||
{
|
{
|
||||||
|
|
@ -423,10 +503,26 @@ QDebug operator<<( QDebug debug, const QskGradient& gradient )
|
||||||
|
|
||||||
debug << stops[i];
|
debug << stops[i];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
debug << " )";
|
debug << " )";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( gradient.spread() )
|
||||||
|
{
|
||||||
|
case QGradient::RepeatSpread:
|
||||||
|
debug << " RP";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QGradient::ReflectSpread:
|
||||||
|
debug << " RF";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QGradient::PadSpread:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug << " )";
|
||||||
|
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@
|
||||||
#include <qbrush.h>
|
#include <qbrush.h>
|
||||||
#include <qmetatype.h>
|
#include <qmetatype.h>
|
||||||
|
|
||||||
|
class QskLinearGradient;
|
||||||
|
class QskRadialGradient;
|
||||||
|
class QskConicGradient;
|
||||||
|
|
||||||
class QVariant;
|
class QVariant;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -22,7 +26,6 @@ class QSK_EXPORT QskGradient
|
||||||
{
|
{
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
|
|
||||||
Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
|
|
||||||
Q_PROPERTY( QVector< QskGradientStop > stops READ stops WRITE setStops )
|
Q_PROPERTY( QVector< QskGradientStop > stops READ stops WRITE setStops )
|
||||||
|
|
||||||
Q_PROPERTY( bool valid READ isValid )
|
Q_PROPERTY( bool valid READ isValid )
|
||||||
|
|
@ -30,43 +33,35 @@ class QSK_EXPORT QskGradient
|
||||||
Q_PROPERTY( bool monochrome READ isMonochrome )
|
Q_PROPERTY( bool monochrome READ isMonochrome )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// TODO: radial/canonical gradients + other diagonal linear gradients
|
enum Type
|
||||||
enum Orientation
|
|
||||||
{
|
{
|
||||||
Horizontal,
|
Stops,
|
||||||
Vertical,
|
|
||||||
Diagonal
|
Linear,
|
||||||
|
Radial,
|
||||||
|
Conic
|
||||||
};
|
};
|
||||||
Q_ENUM( Orientation )
|
Q_ENUM( Type )
|
||||||
|
|
||||||
QskGradient() noexcept = default;
|
QskGradient() noexcept = default;
|
||||||
|
|
||||||
QskGradient( Orientation ) noexcept;
|
|
||||||
QskGradient( Qt::GlobalColor );
|
QskGradient( Qt::GlobalColor );
|
||||||
QskGradient( QRgb );
|
QskGradient( QRgb );
|
||||||
QskGradient( const QColor& );
|
QskGradient( const QColor& );
|
||||||
|
QskGradient( const QColor&, const QColor& );
|
||||||
QskGradient( QGradient::Preset );
|
QskGradient( QGradient::Preset );
|
||||||
|
QskGradient( const QVector< QskGradientStop >& );
|
||||||
|
|
||||||
QskGradient( Qt::Orientation, const QVector< QskGradientStop >& );
|
QskGradient( const QskGradient& ) noexcept;
|
||||||
QskGradient( Qt::Orientation, const QColor&, const QColor& );
|
|
||||||
QskGradient( Qt::Orientation, QGradient::Preset );
|
|
||||||
|
|
||||||
QskGradient( Orientation, const QVector< QskGradientStop >& );
|
|
||||||
QskGradient( Orientation, const QColor&, const QColor& );
|
|
||||||
QskGradient( Orientation, QGradient::Preset );
|
|
||||||
|
|
||||||
~QskGradient();
|
~QskGradient();
|
||||||
|
|
||||||
|
QskGradient& operator=( const QskGradient& ) noexcept;
|
||||||
|
|
||||||
bool operator==( const QskGradient& ) const noexcept;
|
bool operator==( const QskGradient& ) const noexcept;
|
||||||
bool operator!=( const QskGradient& ) const noexcept;
|
bool operator!=( const QskGradient& ) const noexcept;
|
||||||
|
|
||||||
void setOrientation( Qt::Orientation ) noexcept;
|
QskGradient::Type type() const noexcept;
|
||||||
void setOrientation( Orientation ) noexcept;
|
|
||||||
Orientation orientation() const noexcept;
|
|
||||||
|
|
||||||
bool isHorizontal() const noexcept;
|
|
||||||
bool isVertical() const noexcept;
|
|
||||||
bool isTilted() const noexcept;
|
|
||||||
|
|
||||||
bool isValid() const noexcept;
|
bool isValid() const noexcept;
|
||||||
bool isMonochrome() const noexcept;
|
bool isMonochrome() const noexcept;
|
||||||
|
|
@ -88,6 +83,9 @@ class QSK_EXPORT QskGradient
|
||||||
|
|
||||||
void setAlpha( int alpha );
|
void setAlpha( int alpha );
|
||||||
|
|
||||||
|
void setSpread( QGradient::Spread );
|
||||||
|
QGradient::Spread spread() const noexcept;
|
||||||
|
|
||||||
void reverse();
|
void reverse();
|
||||||
QskGradient reversed() const;
|
QskGradient reversed() const;
|
||||||
|
|
||||||
|
|
@ -106,13 +104,37 @@ class QSK_EXPORT QskGradient
|
||||||
|
|
||||||
int stepCount() const noexcept;
|
int stepCount() const noexcept;
|
||||||
|
|
||||||
|
QskLinearGradient& asLinearGradient();
|
||||||
|
const QskLinearGradient& asLinearGradient() const;
|
||||||
|
|
||||||
|
QskRadialGradient& asRadialGradient();
|
||||||
|
const QskRadialGradient& asRadialGradient() const;
|
||||||
|
|
||||||
|
QskConicGradient& asConicGradient();
|
||||||
|
const QskConicGradient& asConicGradient() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class QskLinearGradient;
|
||||||
|
friend class QskRadialGradient;
|
||||||
|
friend class QskConicGradient;
|
||||||
|
|
||||||
|
QskGradient( Type ) noexcept;
|
||||||
|
QskGradient( Type, qreal, qreal, qreal, qreal ) noexcept;
|
||||||
|
|
||||||
void updateStatusBits() const;
|
void updateStatusBits() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector< QskGradientStop > m_stops;
|
QVector< QskGradientStop > m_stops;
|
||||||
|
|
||||||
Orientation m_orientation = Vertical;
|
/*
|
||||||
|
Linear: x1, y1, x2, y2
|
||||||
|
Radial: centerX, centerY, radius, n/a
|
||||||
|
Conic: centerX, centerY, startAngle, spanAngle
|
||||||
|
*/
|
||||||
|
qreal m_values[4] = {};
|
||||||
|
|
||||||
|
Type m_type = Stops;
|
||||||
|
QGradient::Spread m_spread = QGradient::PadSpread;
|
||||||
|
|
||||||
mutable bool m_isDirty = false;
|
mutable bool m_isDirty = false;
|
||||||
mutable bool m_isValid = false;
|
mutable bool m_isValid = false;
|
||||||
|
|
@ -122,6 +144,18 @@ class QSK_EXPORT QskGradient
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( QskGradient )
|
Q_DECLARE_METATYPE( QskGradient )
|
||||||
|
|
||||||
|
inline QskGradient::QskGradient( QskGradient::Type type ) noexcept
|
||||||
|
: m_type( type )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QskGradient::QskGradient( QskGradient::Type type,
|
||||||
|
qreal v1, qreal v2, qreal v3, qreal v4 ) noexcept
|
||||||
|
: m_values{ v1, v2, v3, v4 }
|
||||||
|
, m_type( type )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
inline QskGradient::QskGradient( Qt::GlobalColor color )
|
inline QskGradient::QskGradient( Qt::GlobalColor color )
|
||||||
: QskGradient( QColor( color ) )
|
: QskGradient( QColor( color ) )
|
||||||
{
|
{
|
||||||
|
|
@ -132,34 +166,14 @@ inline QskGradient::QskGradient( QRgb rgb )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QskGradient::QskGradient( QGradient::Preset preset )
|
|
||||||
: QskGradient( Vertical, preset )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool QskGradient::operator!=( const QskGradient& other ) const noexcept
|
inline bool QskGradient::operator!=( const QskGradient& other ) const noexcept
|
||||||
{
|
{
|
||||||
return !( *this == other );
|
return !( *this == other );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QskGradient::Orientation QskGradient::orientation() const noexcept
|
inline QskGradient::Type QskGradient::type() const noexcept
|
||||||
{
|
{
|
||||||
return m_orientation;
|
return m_type;
|
||||||
}
|
|
||||||
|
|
||||||
inline bool QskGradient::isHorizontal() const noexcept
|
|
||||||
{
|
|
||||||
return orientation() == Horizontal;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool QskGradient::isVertical() const noexcept
|
|
||||||
{
|
|
||||||
return orientation() == Vertical;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool QskGradient::isTilted() const noexcept
|
|
||||||
{
|
|
||||||
return orientation() == Diagonal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QskGradientStops& QskGradient::stops() const noexcept
|
inline const QskGradientStops& QskGradient::stops() const noexcept
|
||||||
|
|
@ -186,6 +200,11 @@ inline QColor QskGradient::endColor() const noexcept
|
||||||
return m_stops.isEmpty() ? QColor() : m_stops.last().color();
|
return m_stops.isEmpty() ? QColor() : m_stops.last().color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QGradient::Spread QskGradient::spread() const noexcept
|
||||||
|
{
|
||||||
|
return m_spread;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
|
||||||
class QDebug;
|
class QDebug;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include "QskProgressBar.h"
|
#include "QskProgressBar.h"
|
||||||
|
|
||||||
#include "QskIntervalF.h"
|
#include "QskIntervalF.h"
|
||||||
#include "QskGradient.h"
|
|
||||||
#include "QskFunctions.h"
|
#include "QskFunctions.h"
|
||||||
#include "QskAnimator.h"
|
#include "QskAnimator.h"
|
||||||
#include "QskAspect.h"
|
#include "QskAspect.h"
|
||||||
|
|
@ -163,20 +162,12 @@ QskAspect::Placement QskProgressBar::effectivePlacement() const
|
||||||
|
|
||||||
void QskProgressBar::setBarGradient( const QskGradient& gradient )
|
void QskProgressBar::setBarGradient( const QskGradient& gradient )
|
||||||
{
|
{
|
||||||
// An API where we set the stops only would be more accurate TODO ...
|
setGradientHint( Bar, gradient );
|
||||||
auto g = gradient;
|
|
||||||
|
|
||||||
g.setOrientation( Qt::Horizontal );
|
|
||||||
setGradientHint( Bar | QskAspect::Horizontal, g );
|
|
||||||
|
|
||||||
g.setOrientation( Qt::Vertical );
|
|
||||||
setGradientHint( Bar | QskAspect::Vertical, g );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskProgressBar::resetBarGradient()
|
void QskProgressBar::resetBarGradient()
|
||||||
{
|
{
|
||||||
resetColor( Bar | QskAspect::Vertical );
|
resetColor( Bar );
|
||||||
resetColor( Bar | QskAspect::Horizontal );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradient QskProgressBar::barGradient() const
|
QskGradient QskProgressBar::barGradient() const
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include "QskProgressBar.h"
|
#include "QskProgressBar.h"
|
||||||
#include "QskIntervalF.h"
|
#include "QskIntervalF.h"
|
||||||
#include "QskBoxBorderMetrics.h"
|
#include "QskBoxBorderMetrics.h"
|
||||||
|
#include "QskLinearGradient.h"
|
||||||
|
|
||||||
#include <qeasingcurve.h>
|
#include <qeasingcurve.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
@ -124,13 +125,26 @@ QSGNode* QskProgressBarSkinlet::updateBarNode(
|
||||||
if ( !gradient.isVisible() )
|
if ( !gradient.isVisible() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
gradient.setOrientation( bar->orientation() );
|
if ( ( gradient.type() == QskGradient::Stops ) && !gradient.isMonochrome() )
|
||||||
|
|
||||||
if ( !gradient.isMonochrome() )
|
|
||||||
{
|
{
|
||||||
const auto intv = qskBarInterval( bar );
|
/*
|
||||||
gradient = gradient.extracted( intv.lowerBound(), intv.upperBound() );
|
When having stops only we use a linear gradient,
|
||||||
|
where the colors are increasing in direction of the
|
||||||
|
progress value. We interprete the gradient as a
|
||||||
|
definition for the 100% situation and have to adjust
|
||||||
|
the stops for smaller bars.
|
||||||
|
|
||||||
|
For this situation it would be more convenient to
|
||||||
|
adjust the start/stop positions, but the box renderer is
|
||||||
|
not supporting this yet. TODO ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
const auto intv = qskBarInterval( bar );
|
||||||
|
|
||||||
|
auto stops = qskExtractedGradientStops( gradient.stops(),
|
||||||
|
intv.lowerBound(), intv.upperBound() );
|
||||||
|
|
||||||
|
gradient = QskLinearGradient( bar->orientation(), stops );
|
||||||
if ( bar->orientation() == Qt::Vertical || bar->layoutMirroring() )
|
if ( bar->orientation() == Qt::Vertical || bar->layoutMirroring() )
|
||||||
gradient.reverse();
|
gradient.reverse();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#include "QskBoxBorderMetrics.h"
|
#include "QskBoxBorderMetrics.h"
|
||||||
#include "QskBoxBorderColors.h"
|
#include "QskBoxBorderColors.h"
|
||||||
#include "QskShadowMetrics.h"
|
#include "QskShadowMetrics.h"
|
||||||
#include "QskGradient.h"
|
#include "QskLinearGradient.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
@ -225,7 +225,7 @@ void QskSkinHintTableEditor::setHGradient(
|
||||||
QskAspect aspect, const QColor& color1, const QColor& color2,
|
QskAspect aspect, const QColor& color1, const QColor& color2,
|
||||||
QskStateCombination combination )
|
QskStateCombination combination )
|
||||||
{
|
{
|
||||||
const QskGradient gradient( QskGradient::Horizontal, color1, color2 );
|
const QskLinearGradient gradient( Qt::Horizontal, color1, color2 );
|
||||||
setGradient( aspect, gradient, combination );
|
setGradient( aspect, gradient, combination );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,10 +233,18 @@ void QskSkinHintTableEditor::setVGradient(
|
||||||
QskAspect aspect, const QColor& color1, const QColor& color2,
|
QskAspect aspect, const QColor& color1, const QColor& color2,
|
||||||
QskStateCombination combination )
|
QskStateCombination combination )
|
||||||
{
|
{
|
||||||
const QskGradient gradient( QskGradient::Vertical, color1, color2 );
|
const QskLinearGradient gradient( Qt::Vertical, color1, color2 );
|
||||||
setGradient( aspect, gradient, combination );
|
setGradient( aspect, gradient, combination );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskSkinHintTableEditor::setGradient(
|
||||||
|
QskAspect aspect, const QColor& color1, const QColor& color2,
|
||||||
|
QskStateCombination combination )
|
||||||
|
{
|
||||||
|
const QskGradient gradient( color1, color2 );
|
||||||
|
setColorHint( aspect, gradient , combination );
|
||||||
|
}
|
||||||
|
|
||||||
void QskSkinHintTableEditor::setGradient(
|
void QskSkinHintTableEditor::setGradient(
|
||||||
QskAspect aspect, const QskGradient& gradient,
|
QskAspect aspect, const QskGradient& gradient,
|
||||||
QskStateCombination combination )
|
QskStateCombination combination )
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,9 @@ class QSK_EXPORT QskSkinHintTableEditor
|
||||||
void setVGradient( QskAspect, const QColor&, const QColor&,
|
void setVGradient( QskAspect, const QColor&, const QColor&,
|
||||||
QskStateCombination = QskStateCombination() );
|
QskStateCombination = QskStateCombination() );
|
||||||
|
|
||||||
|
void setGradient( QskAspect, const QColor&, const QColor&,
|
||||||
|
QskStateCombination = QskStateCombination() );
|
||||||
|
|
||||||
void setGradient( QskAspect, const QskGradient&,
|
void setGradient( QskAspect, const QskGradient&,
|
||||||
QskStateCombination = QskStateCombination() );
|
QskStateCombination = QskStateCombination() );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,27 +5,30 @@
|
||||||
|
|
||||||
#include "QskArcRenderer.h"
|
#include "QskArcRenderer.h"
|
||||||
#include "QskArcMetrics.h"
|
#include "QskArcMetrics.h"
|
||||||
#include "QskGradient.h"
|
#include "QskLinearGradient.h"
|
||||||
|
|
||||||
#include <qpainter.h>
|
#include <qpainter.h>
|
||||||
#include <qrect.h>
|
#include <qrect.h>
|
||||||
|
|
||||||
void QskArcRenderer::renderArc(const QRectF& rect,
|
void QskArcRenderer::renderArc(const QRectF& rect,
|
||||||
const QskArcMetrics& metrics, const QskGradient& gradient,
|
const QskArcMetrics& metrics, const QskGradient& gradient, QPainter* painter )
|
||||||
QPainter* painter )
|
|
||||||
{
|
{
|
||||||
painter->setRenderHint( QPainter::Antialiasing, true );
|
bool isRadial = false;
|
||||||
|
|
||||||
|
if ( gradient.type() == QskGradient::Linear )
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
horizontal is interpreted as in direction of the arc,
|
Horizontal is interpreted as conic ( in direction of the arc ),
|
||||||
while vertical means from the inner to the outer border
|
while Vertical means radial ( inner to outer border )
|
||||||
*/
|
*/
|
||||||
|
isRadial = gradient.asLinearGradient().isVertical();
|
||||||
|
}
|
||||||
|
|
||||||
QBrush brush;
|
QBrush brush;
|
||||||
|
|
||||||
const auto qStops = qskToQGradientStops( gradient.stops() );
|
const auto qStops = qskToQGradientStops( gradient.stops() );
|
||||||
|
|
||||||
if( gradient.orientation() == QskGradient::Vertical )
|
if( isRadial )
|
||||||
{
|
{
|
||||||
QRadialGradient radial( rect.center(), qMin( rect.width(), rect.height() ) );
|
QRadialGradient radial( rect.center(), qMin( rect.width(), rect.height() ) );
|
||||||
radial.setStops( qStops );
|
radial.setStops( qStops );
|
||||||
|
|
@ -40,6 +43,7 @@ void QskArcRenderer::renderArc(const QRectF& rect,
|
||||||
brush = conical;
|
brush = conical;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
painter->setRenderHint( QPainter::Antialiasing, true );
|
||||||
painter->setPen( QPen( brush, metrics.width(), Qt::SolidLine, Qt::FlatCap ) );
|
painter->setPen( QPen( brush, metrics.width(), Qt::SolidLine, Qt::FlatCap ) );
|
||||||
|
|
||||||
const int startAngle = qRound( metrics.startAngle() * 16 );
|
const int startAngle = qRound( metrics.startAngle() * 16 );
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,66 @@ static inline QskHashValue qskColorsHash(
|
||||||
return fillGradient.hash( hash );
|
return fillGradient.hash( hash );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
#include "QskLinearGradient.h"
|
||||||
|
|
||||||
|
static inline QskLinearGradient qskEffectiveGradient( const QskGradient& gradient )
|
||||||
|
{
|
||||||
|
QskLinearGradient g;
|
||||||
|
|
||||||
|
if ( gradient.isVisible() )
|
||||||
|
{
|
||||||
|
if ( gradient.isMonochrome() )
|
||||||
|
{
|
||||||
|
g.setStops( gradient.startColor() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch( gradient.type() )
|
||||||
|
{
|
||||||
|
case QskGradient::Linear:
|
||||||
|
{
|
||||||
|
const auto& linearGradient = gradient.asLinearGradient();
|
||||||
|
|
||||||
|
if ( linearGradient.isVertical() )
|
||||||
|
{
|
||||||
|
g.setOrientation( Qt::Vertical );
|
||||||
|
}
|
||||||
|
else if ( linearGradient.isHorizontal() )
|
||||||
|
{
|
||||||
|
g.setOrientation( Qt::Horizontal );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g.setStart( 0.0, 0.0 );
|
||||||
|
g.setStop( 1.0, 1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
g.setStops( gradient.stops() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QskGradient::Radial:
|
||||||
|
case QskGradient::Conic:
|
||||||
|
{
|
||||||
|
qWarning() << "QskBoxNode does not support radial/conic gradients";
|
||||||
|
g.setStops( Qt::black );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case QskGradient::Stops:
|
||||||
|
{
|
||||||
|
g.setStops( gradient.stops() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
class QskBoxNodePrivate final : public QSGGeometryNodePrivate
|
class QskBoxNodePrivate final : public QSGGeometryNodePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -79,13 +139,16 @@ void QskBoxNode::setBoxData( const QRectF& rect,
|
||||||
{
|
{
|
||||||
Q_D( QskBoxNode );
|
Q_D( QskBoxNode );
|
||||||
|
|
||||||
QskGradient fillGradient = gradient;
|
/*
|
||||||
|
QskBoxRenderer supports certain linear gradients only.
|
||||||
|
For everything else we would have to use a QskGradientMaterial instead.
|
||||||
|
|
||||||
|
As a temporary solution we simply "convert" gradient into a
|
||||||
|
simple QskLinearGradient so that at least something is happening.
|
||||||
|
TODO ...
|
||||||
|
*/
|
||||||
#if 1
|
#if 1
|
||||||
// Renderer is buggy for monochrome gradients with stops. TODO ...
|
const auto fillGradient = qskEffectiveGradient( gradient );
|
||||||
if ( fillGradient.stops().count() > 2 && fillGradient.isMonochrome() )
|
|
||||||
{
|
|
||||||
fillGradient.setStops( fillGradient.startColor() );
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const auto metricsHash = qskMetricsHash( shape, borderMetrics );
|
const auto metricsHash = qskMetricsHash( shape, borderMetrics );
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
class QskBoxBorderMetrics;
|
class QskBoxBorderMetrics;
|
||||||
class QskBoxBorderColors;
|
class QskBoxBorderColors;
|
||||||
|
class QskLinearGradient;
|
||||||
class QskGradient;
|
class QskGradient;
|
||||||
|
|
||||||
class QSGGeometry;
|
class QSGGeometry;
|
||||||
|
|
@ -32,7 +33,7 @@ class QSK_EXPORT QskBoxRenderer
|
||||||
|
|
||||||
void renderBox( const QRectF&,
|
void renderBox( const QRectF&,
|
||||||
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
|
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
|
||||||
const QskBoxBorderColors&, const QskGradient&, QSGGeometry& );
|
const QskBoxBorderColors&, const QskLinearGradient&, QSGGeometry& );
|
||||||
|
|
||||||
class Quad
|
class Quad
|
||||||
{
|
{
|
||||||
|
|
@ -115,7 +116,7 @@ class QSK_EXPORT QskBoxRenderer
|
||||||
|
|
||||||
void renderRect( const QRectF&,
|
void renderRect( const QRectF&,
|
||||||
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
|
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
|
||||||
const QskBoxBorderColors&, const QskGradient&, QSGGeometry& );
|
const QskBoxBorderColors&, const QskLinearGradient&, QSGGeometry& );
|
||||||
|
|
||||||
void renderRectellipseFill( const QRectF&,
|
void renderRectellipseFill( const QRectF&,
|
||||||
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& );
|
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& );
|
||||||
|
|
@ -125,12 +126,12 @@ class QSK_EXPORT QskBoxRenderer
|
||||||
|
|
||||||
void renderRectellipse( const QRectF&,
|
void renderRectellipse( const QRectF&,
|
||||||
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
|
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
|
||||||
const QskBoxBorderColors&, const QskGradient&, QSGGeometry& );
|
const QskBoxBorderColors&, const QskLinearGradient&, QSGGeometry& );
|
||||||
|
|
||||||
void renderDiagonalFill( const Metrics&, const QskGradient&,
|
void renderDiagonalFill( const Metrics&, const QskGradient&,
|
||||||
int lineCount, QskVertex::ColoredLine* );
|
int lineCount, QskVertex::ColoredLine* );
|
||||||
|
|
||||||
void renderRectFill( const Quad&, const QskGradient&, QskVertex::ColoredLine* );
|
void renderRectFill( const Quad&, const QskLinearGradient&, QskVertex::ColoredLine* );
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void QskBoxRenderer::renderBorder(
|
inline void QskBoxRenderer::renderBorder(
|
||||||
|
|
@ -155,7 +156,7 @@ inline void QskBoxRenderer::renderFill(
|
||||||
|
|
||||||
inline void QskBoxRenderer::renderBox( const QRectF& rect,
|
inline void QskBoxRenderer::renderBox( const QRectF& rect,
|
||||||
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border,
|
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border,
|
||||||
const QskBoxBorderColors& borderColors, const QskGradient& gradient,
|
const QskBoxBorderColors& borderColors, const QskLinearGradient& gradient,
|
||||||
QSGGeometry& geometry )
|
QSGGeometry& geometry )
|
||||||
{
|
{
|
||||||
if ( shape.isRectangle() )
|
if ( shape.isRectangle() )
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "QskBoxRenderer.h"
|
#include "QskBoxRenderer.h"
|
||||||
#include "QskGradient.h"
|
#include "QskLinearGradient.h"
|
||||||
|
|
||||||
#include "QskBoxBorderColors.h"
|
#include "QskBoxBorderColors.h"
|
||||||
#include "QskBoxBorderMetrics.h"
|
#include "QskBoxBorderMetrics.h"
|
||||||
|
|
@ -868,13 +868,13 @@ namespace
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Qt::Orientation qskQtOrientation( const QskGradient& gradient )
|
static inline Qt::Orientation qskQtOrientation( const QskLinearGradient& gradient )
|
||||||
{
|
{
|
||||||
return gradient.isVertical() ? Qt::Vertical : Qt::Horizontal;
|
return gradient.isVertical() ? Qt::Vertical : Qt::Horizontal;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int qskFillLineCount(
|
static inline int qskFillLineCount(
|
||||||
const QskBoxRenderer::Metrics& metrics, const QskGradient& gradient )
|
const QskBoxRenderer::Metrics& metrics, const QskLinearGradient& gradient )
|
||||||
{
|
{
|
||||||
const int stepCount = metrics.corner[ 0 ].stepCount;
|
const int stepCount = metrics.corner[ 0 ].stepCount;
|
||||||
|
|
||||||
|
|
@ -1029,7 +1029,7 @@ static inline void qskRenderBorder( const QskBoxRenderer::Metrics& metrics,
|
||||||
|
|
||||||
static inline void qskRenderFillRandom(
|
static inline void qskRenderFillRandom(
|
||||||
const QskBoxRenderer::Metrics& metrics,
|
const QskBoxRenderer::Metrics& metrics,
|
||||||
const QskGradient& gradient, ColoredLine* line )
|
const QskLinearGradient& gradient, ColoredLine* line )
|
||||||
{
|
{
|
||||||
const auto orientation = qskQtOrientation( gradient );
|
const auto orientation = qskQtOrientation( gradient );
|
||||||
|
|
||||||
|
|
@ -1047,7 +1047,7 @@ static inline void qskRenderFillRandom(
|
||||||
|
|
||||||
static inline void qskRenderBoxRandom(
|
static inline void qskRenderBoxRandom(
|
||||||
const QskBoxRenderer::Metrics& metrics, const QskBoxBorderColors& borderColors,
|
const QskBoxRenderer::Metrics& metrics, const QskBoxBorderColors& borderColors,
|
||||||
const QskGradient& gradient, ColoredLine* fillLine, ColoredLine* borderLine )
|
const QskLinearGradient& gradient, ColoredLine* fillLine, ColoredLine* borderLine )
|
||||||
{
|
{
|
||||||
const auto& bc = borderColors;
|
const auto& bc = borderColors;
|
||||||
|
|
||||||
|
|
@ -1099,7 +1099,7 @@ static inline void qskRenderBoxRandom(
|
||||||
|
|
||||||
static inline void qskRenderFillOrdered(
|
static inline void qskRenderFillOrdered(
|
||||||
const QskBoxRenderer::Metrics& metrics,
|
const QskBoxRenderer::Metrics& metrics,
|
||||||
const QskGradient& gradient, ColoredLine* lines )
|
const QskLinearGradient& gradient, ColoredLine* lines )
|
||||||
{
|
{
|
||||||
const auto& r = metrics.innerQuad;
|
const auto& r = metrics.innerQuad;
|
||||||
|
|
||||||
|
|
@ -1333,7 +1333,7 @@ void QskBoxRenderer::renderRectellipseFill(
|
||||||
|
|
||||||
void QskBoxRenderer::renderRectellipse( const QRectF& rect,
|
void QskBoxRenderer::renderRectellipse( const QRectF& rect,
|
||||||
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border,
|
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border,
|
||||||
const QskBoxBorderColors& borderColors, const QskGradient& gradient,
|
const QskBoxBorderColors& borderColors, const QskLinearGradient& gradient,
|
||||||
QSGGeometry& geometry )
|
QSGGeometry& geometry )
|
||||||
{
|
{
|
||||||
const Metrics metrics( rect, shape, border );
|
const Metrics metrics( rect, shape, border );
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "QskBoxRenderer.h"
|
#include "QskBoxRenderer.h"
|
||||||
#include "QskBoxRendererColorMap.h"
|
#include "QskBoxRendererColorMap.h"
|
||||||
#include "QskFunctions.h"
|
#include "QskFunctions.h"
|
||||||
#include "QskGradient.h"
|
#include "QskLinearGradient.h"
|
||||||
#include "QskVertex.h"
|
#include "QskVertex.h"
|
||||||
|
|
||||||
using namespace QskVertex;
|
using namespace QskVertex;
|
||||||
|
|
@ -343,7 +343,7 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void qskCreateFillOrdered( const QskBoxRenderer::Quad& rect,
|
static inline void qskCreateFillOrdered( const QskBoxRenderer::Quad& rect,
|
||||||
const QskGradient& gradient, ColoredLine* line )
|
const QskLinearGradient& gradient, ColoredLine* line )
|
||||||
{
|
{
|
||||||
if ( gradient.isHorizontal() )
|
if ( gradient.isHorizontal() )
|
||||||
{
|
{
|
||||||
|
|
@ -371,11 +371,10 @@ static inline void qskCreateFillOrdered( const QskBoxRenderer::Quad& rect,
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class ColorMap, class Line >
|
template< class ColorMap, class Line >
|
||||||
static inline void qskCreateFillRandom(
|
static inline void qskCreateFillRandom( Qt::Orientation orientation,
|
||||||
QskGradient::Orientation orientation,
|
|
||||||
const QskBoxRenderer::Quad& r, const ColorMap& map, Line* line )
|
const QskBoxRenderer::Quad& r, const ColorMap& map, Line* line )
|
||||||
{
|
{
|
||||||
if ( orientation == QskGradient::Vertical )
|
if ( orientation == Qt::Vertical )
|
||||||
{
|
{
|
||||||
( line++ )->setLine( r.left, r.top, r.right, r.top, map.colorAt( 0.0 ) );
|
( line++ )->setLine( r.left, r.top, r.right, r.top, map.colorAt( 0.0 ) );
|
||||||
( line++ )->setLine( r.left, r.bottom, r.right, r.bottom, map.colorAt( 1.0 ) );
|
( line++ )->setLine( r.left, r.bottom, r.right, r.bottom, map.colorAt( 1.0 ) );
|
||||||
|
|
@ -549,15 +548,13 @@ void QskBoxRenderer::renderRectFill(
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto line = allocateLines< Line >( geometry, 2 );
|
const auto line = allocateLines< Line >( geometry, 2 );
|
||||||
|
qskCreateFillRandom( Qt::Vertical, in, ColorMapSolid( Color() ), line );
|
||||||
qskCreateFillRandom( QskGradient::Vertical,
|
|
||||||
in, ColorMapSolid( Color() ), line );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskBoxRenderer::renderRect(
|
void QskBoxRenderer::renderRect(
|
||||||
const QRectF& rect, const QskBoxShapeMetrics& shape,
|
const QRectF& rect, const QskBoxShapeMetrics& shape,
|
||||||
const QskBoxBorderMetrics& border, const QskBoxBorderColors& borderColors,
|
const QskBoxBorderMetrics& border, const QskBoxBorderColors& borderColors,
|
||||||
const QskGradient& gradient, QSGGeometry& geometry )
|
const QskLinearGradient& gradient, QSGGeometry& geometry )
|
||||||
{
|
{
|
||||||
Q_UNUSED( shape )
|
Q_UNUSED( shape )
|
||||||
|
|
||||||
|
|
@ -624,7 +621,7 @@ void QskBoxRenderer::renderRect(
|
||||||
if ( gd.isMonochrome() )
|
if ( gd.isMonochrome() )
|
||||||
{
|
{
|
||||||
const ColorMapSolid colorMap( gd.startColor() );
|
const ColorMapSolid colorMap( gd.startColor() );
|
||||||
qskCreateFillRandom( QskGradient::Vertical, in, colorMap, line );
|
qskCreateFillRandom( Qt::Vertical, in, colorMap, line );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -641,8 +638,10 @@ void QskBoxRenderer::renderRect(
|
||||||
|
|
||||||
if ( fillRandom )
|
if ( fillRandom )
|
||||||
{
|
{
|
||||||
|
const auto orientation = gd.isVertical() ? Qt::Vertical : Qt::Horizontal;
|
||||||
|
|
||||||
const ColorMapGradient colorMap( gd.startColor(), gd.endColor() );
|
const ColorMapGradient colorMap( gd.startColor(), gd.endColor() );
|
||||||
qskCreateFillRandom( gd.orientation(), in, colorMap, line );
|
qskCreateFillRandom( orientation, in, colorMap, line );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -669,7 +668,7 @@ void QskBoxRenderer::renderRect(
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskBoxRenderer::renderRectFill( const QskBoxRenderer::Quad& rect,
|
void QskBoxRenderer::renderRectFill( const QskBoxRenderer::Quad& rect,
|
||||||
const QskGradient& gradient, QskVertex::ColoredLine* line )
|
const QskLinearGradient& gradient, QskVertex::ColoredLine* line )
|
||||||
{
|
{
|
||||||
qskCreateFillOrdered( rect, gradient, line );
|
qskCreateFillOrdered( rect, gradient, line );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
#include "QskFunctions.h"
|
#include "QskFunctions.h"
|
||||||
#include "QskRgbValue.h"
|
#include "QskRgbValue.h"
|
||||||
|
|
||||||
#include <qcoreapplication.h>
|
#include "QskLinearGradient.h"
|
||||||
|
#include "QskRadialGradient.h"
|
||||||
|
#include "QskConicGradient.h"
|
||||||
|
|
||||||
QSK_QT_PRIVATE_BEGIN
|
QSK_QT_PRIVATE_BEGIN
|
||||||
#include <private/qrhi_p.h>
|
#include <private/qrhi_p.h>
|
||||||
|
|
@ -15,6 +17,7 @@ QSK_QT_PRIVATE_BEGIN
|
||||||
#include <private/qsgplaintexture_p.h>
|
#include <private/qsgplaintexture_p.h>
|
||||||
QSK_QT_PRIVATE_END
|
QSK_QT_PRIVATE_END
|
||||||
|
|
||||||
|
#include <qcoreapplication.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
// RHI shaders are supported by Qt 5.15 and Qt 6.x
|
// RHI shaders are supported by Qt 5.15 and Qt 6.x
|
||||||
|
|
@ -37,28 +40,15 @@ namespace
|
||||||
class GradientTexture : public QSGPlainTexture
|
class GradientTexture : public QSGPlainTexture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GradientTexture( const QGradientStops& stops, QGradient::Spread spread )
|
GradientTexture( const QskGradientStops& stops, QGradient::Spread spread )
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
/*
|
|
||||||
Once we got rid of QGradient we will have QskGradientStops
|
|
||||||
( like in the gradients branch ). For the moment we have to copy
|
|
||||||
*/
|
|
||||||
|
|
||||||
QskGradientStops qskStops;
|
|
||||||
qskStops.reserve( stops.size() );
|
|
||||||
|
|
||||||
for ( const auto& s : stops )
|
|
||||||
qskStops += QskGradientStop( s.first, s.second );
|
|
||||||
#endif
|
|
||||||
/*
|
/*
|
||||||
Qt creates tables of 1024 colors, while Chrome, Firefox, and Android
|
Qt creates tables of 1024 colors, while Chrome, Firefox, and Android
|
||||||
seem to use 256 colors only ( according to maybe outdated sources
|
seem to use 256 colors only ( according to maybe outdated sources
|
||||||
from the internet ),
|
from the internet ),
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
setImage( QskRgb::colorTable( 256, stops ) );
|
||||||
setImage( QskRgb::colorTable( 256, qskStops ) );
|
|
||||||
|
|
||||||
const auto wrapMode = this->wrapMode( spread );
|
const auto wrapMode = this->wrapMode( spread );
|
||||||
|
|
||||||
|
|
@ -94,7 +84,7 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* rhi;
|
const void* rhi;
|
||||||
const QGradientStops stops;
|
const QskGradientStops stops;
|
||||||
const QGradient::Spread spread;
|
const QGradient::Spread spread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -103,7 +93,7 @@ namespace
|
||||||
size_t valus = seed + key.spread;
|
size_t valus = seed + key.spread;
|
||||||
|
|
||||||
for ( const auto& stop : key.stops )
|
for ( const auto& stop : key.stops )
|
||||||
valus += stop.second.rgba();
|
valus += stop.rgb();
|
||||||
|
|
||||||
return valus;
|
return valus;
|
||||||
}
|
}
|
||||||
|
|
@ -135,7 +125,7 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
GradientTexture* texture( const void* rhi,
|
GradientTexture* texture( const void* rhi,
|
||||||
const QGradientStops& stops, QGradient::Spread spread )
|
const QskGradientStops& stops, QGradient::Spread spread )
|
||||||
{
|
{
|
||||||
const TextureHashKey key { rhi, stops, spread };
|
const TextureHashKey key { rhi, stops, spread };
|
||||||
|
|
||||||
|
|
@ -197,7 +187,7 @@ namespace
|
||||||
class GradientMaterial : public QskGradientMaterial
|
class GradientMaterial : public QskGradientMaterial
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GradientMaterial( QGradient::Type type )
|
GradientMaterial( QskGradient::Type type )
|
||||||
: QskGradientMaterial( type )
|
: QskGradientMaterial( type )
|
||||||
{
|
{
|
||||||
setFlag( Blending | RequiresFullMatrix );
|
setFlag( Blending | RequiresFullMatrix );
|
||||||
|
|
@ -323,11 +313,11 @@ namespace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LinearMaterial()
|
LinearMaterial()
|
||||||
: GradientMaterial( QGradient::LinearGradient )
|
: GradientMaterial( QskGradient::Linear )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setGradient( const QRectF& rect, const QLinearGradient& gradient )
|
bool setGradient( const QRectF& rect, const QskLinearGradient& gradient )
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
|
|
@ -350,8 +340,8 @@ namespace
|
||||||
const QVector4D vector(
|
const QVector4D vector(
|
||||||
rect.left() + gradient.start().x() * rect.width(),
|
rect.left() + gradient.start().x() * rect.width(),
|
||||||
rect.top() + gradient.start().y() * rect.height(),
|
rect.top() + gradient.start().y() * rect.height(),
|
||||||
gradient.finalStop().x() * rect.width(),
|
gradient.stop().x() * rect.width(),
|
||||||
gradient.finalStop().y() * rect.height() );
|
gradient.stop().y() * rect.height() );
|
||||||
|
|
||||||
if ( m_gradientVector != vector )
|
if ( m_gradientVector != vector )
|
||||||
{
|
{
|
||||||
|
|
@ -476,7 +466,7 @@ namespace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RadialMaterial()
|
RadialMaterial()
|
||||||
: GradientMaterial( QGradient::RadialGradient )
|
: GradientMaterial( QskGradient::Radial )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -486,7 +476,7 @@ namespace
|
||||||
return &type;
|
return &type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setGradient( const QRectF& rect, const QRadialGradient& gradient )
|
bool setGradient( const QRectF& rect, const QskRadialGradient& gradient )
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
|
|
@ -647,7 +637,7 @@ namespace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConicMaterial()
|
ConicMaterial()
|
||||||
: GradientMaterial( QGradient::ConicalGradient )
|
: GradientMaterial( QskGradient::Conic )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -657,7 +647,7 @@ namespace
|
||||||
return &type;
|
return &type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setGradient( const QRectF& rect, const QConicalGradient& gradient, qreal spanAngle )
|
bool setGradient( const QRectF& rect, const QskConicGradient& gradient )
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
|
|
@ -679,11 +669,11 @@ namespace
|
||||||
|
|
||||||
// Angles as ratio of a rotation
|
// Angles as ratio of a rotation
|
||||||
|
|
||||||
float start = fmod( gradient.angle(), 360.0 ) / 360.0;
|
float start = fmod( gradient.startAngle(), 360.0 ) / 360.0;
|
||||||
if ( start < 0.0)
|
if ( start < 0.0)
|
||||||
start += 1.0;
|
start += 1.0;
|
||||||
|
|
||||||
const float span = fmod( spanAngle, 360.0 ) / 360.0;
|
const float span = fmod( gradient.spanAngle(), 360.0 ) / 360.0;
|
||||||
|
|
||||||
if ( center != m_center )
|
if ( center != m_center )
|
||||||
{
|
{
|
||||||
|
|
@ -826,7 +816,7 @@ namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradientMaterial::QskGradientMaterial( QGradient::Type type )
|
QskGradientMaterial::QskGradientMaterial( QskGradient::Type type )
|
||||||
: m_gradientType( type )
|
: m_gradientType( type )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -840,59 +830,54 @@ inline Material* qskEnsureMaterial( QskGradientMaterial* material )
|
||||||
return static_cast< Material* >( material );
|
return static_cast< Material* >( material );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QskGradientMaterial::updateGradient(
|
bool QskGradientMaterial::updateGradient( const QRectF& rect, const QskGradient& gradient )
|
||||||
const QRectF& rect, const QGradient* g, qreal extraValue )
|
|
||||||
{
|
{
|
||||||
Q_ASSERT( g );
|
|
||||||
|
|
||||||
if ( g == nullptr )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
auto& gradient = *g;
|
|
||||||
|
|
||||||
Q_ASSERT( gradient.type() == m_gradientType );
|
Q_ASSERT( gradient.type() == m_gradientType );
|
||||||
|
|
||||||
if ( gradient.type() != m_gradientType )
|
if ( gradient.type() != m_gradientType )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch ( static_cast< int >( gradient.type() ) )
|
switch ( gradient.type() )
|
||||||
{
|
{
|
||||||
case QGradient::LinearGradient:
|
case QskGradient::Linear:
|
||||||
{
|
{
|
||||||
auto material = static_cast< LinearMaterial* >( this );
|
auto material = static_cast< LinearMaterial* >( this );
|
||||||
return material->setGradient( rect,
|
return material->setGradient( rect, gradient.asLinearGradient() );
|
||||||
*reinterpret_cast< const QLinearGradient* >( g ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case QGradient::RadialGradient:
|
case QskGradient::Radial:
|
||||||
{
|
{
|
||||||
auto material = static_cast< RadialMaterial* >( this );
|
auto material = static_cast< RadialMaterial* >( this );
|
||||||
return material->setGradient( rect,
|
return material->setGradient( rect, gradient.asRadialGradient() );
|
||||||
*reinterpret_cast< const QRadialGradient* >( g ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case QGradient::ConicalGradient:
|
case QskGradient::Conic:
|
||||||
{
|
{
|
||||||
auto material = static_cast< ConicMaterial* >( this );
|
auto material = static_cast< ConicMaterial* >( this );
|
||||||
return material->setGradient( rect,
|
return material->setGradient( rect, gradient.asConicGradient() );
|
||||||
*reinterpret_cast< const QConicalGradient* >( g ), extraValue );
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
qWarning( "Invalid gradient type" );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskGradientMaterial* QskGradientMaterial::createMaterial( QGradient::Type gradientType )
|
QskGradientMaterial* QskGradientMaterial::createMaterial( QskGradient::Type gradientType )
|
||||||
{
|
{
|
||||||
switch ( gradientType )
|
switch ( gradientType )
|
||||||
{
|
{
|
||||||
case QGradient::LinearGradient:
|
case QskGradient::Linear:
|
||||||
return new LinearMaterial();
|
return new LinearMaterial();
|
||||||
|
|
||||||
case QGradient::RadialGradient:
|
case QskGradient::Radial:
|
||||||
return new RadialMaterial();
|
return new RadialMaterial();
|
||||||
|
|
||||||
case QGradient::ConicalGradient:
|
case QskGradient::Conic:
|
||||||
return new ConicMaterial();
|
return new ConicMaterial();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -7,39 +7,39 @@
|
||||||
#define QSK_GRADIENT_MATERIAL
|
#define QSK_GRADIENT_MATERIAL
|
||||||
|
|
||||||
#include "QskGlobal.h"
|
#include "QskGlobal.h"
|
||||||
#include <qbrush.h>
|
#include "QskGradient.h"
|
||||||
#include <qsgmaterial.h>
|
#include <qsgmaterial.h>
|
||||||
|
|
||||||
class QSK_EXPORT QskGradientMaterial : public QSGMaterial
|
class QSK_EXPORT QskGradientMaterial : public QSGMaterial
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static QskGradientMaterial* createMaterial( QGradient::Type );
|
static QskGradientMaterial* createMaterial( QskGradient::Type );
|
||||||
|
|
||||||
bool updateGradient( const QRectF&, const QGradient*, qreal );
|
bool updateGradient( const QRectF&, const QskGradient& );
|
||||||
QGradient::Type gradientType() const;
|
QskGradient::Type gradientType() const;
|
||||||
|
|
||||||
const QGradientStops& stops() const;
|
const QskGradientStops& stops() const;
|
||||||
QGradient::Spread spread() const;
|
QGradient::Spread spread() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QskGradientMaterial( QGradient::Type );
|
QskGradientMaterial( QskGradient::Type );
|
||||||
|
|
||||||
void setStops( const QGradientStops& );
|
void setStops( const QskGradientStops& );
|
||||||
void setSpread( QGradient::Spread );
|
void setSpread( QGradient::Spread );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QGradient::Type m_gradientType;
|
const QskGradient::Type m_gradientType;
|
||||||
|
|
||||||
QGradientStops m_stops;
|
QskGradientStops m_stops;
|
||||||
QGradient::Spread m_spread = QGradient::PadSpread;
|
QGradient::Spread m_spread = QGradient::PadSpread;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline QGradient::Type QskGradientMaterial::gradientType() const
|
inline QskGradient::Type QskGradientMaterial::gradientType() const
|
||||||
{
|
{
|
||||||
return m_gradientType;
|
return m_gradientType;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QskGradientMaterial::setStops( const QGradientStops& stops )
|
inline void QskGradientMaterial::setStops( const QskGradientStops& stops )
|
||||||
{
|
{
|
||||||
m_stops = stops;
|
m_stops = stops;
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +49,7 @@ inline void QskGradientMaterial::setSpread( QGradient::Spread spread )
|
||||||
m_spread = spread;
|
m_spread = spread;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const QGradientStops& QskGradientMaterial::stops() const
|
inline const QskGradientStops& QskGradientMaterial::stops() const
|
||||||
{
|
{
|
||||||
return m_stops;
|
return m_stops;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@
|
||||||
|
|
||||||
#include "QskShapeNode.h"
|
#include "QskShapeNode.h"
|
||||||
#include "QskGradientMaterial.h"
|
#include "QskGradientMaterial.h"
|
||||||
|
#include "QskGradient.h"
|
||||||
|
#include "QskLinearGradient.h"
|
||||||
|
|
||||||
#include <qbrush.h>
|
|
||||||
#include <qsgflatcolormaterial.h>
|
#include <qsgflatcolormaterial.h>
|
||||||
|
|
||||||
QSK_QT_PRIVATE_BEGIN
|
QSK_QT_PRIVATE_BEGIN
|
||||||
|
|
@ -15,6 +16,14 @@ QSK_QT_PRIVATE_BEGIN
|
||||||
#include <private/qtriangulator_p.h>
|
#include <private/qtriangulator_p.h>
|
||||||
QSK_QT_PRIVATE_END
|
QSK_QT_PRIVATE_END
|
||||||
|
|
||||||
|
static inline QskGradient qskEffectiveGradient( const QskGradient& gradient )
|
||||||
|
{
|
||||||
|
if ( gradient.type() == QskGradient::Stops )
|
||||||
|
return QskLinearGradient( Qt::Vertical, gradient.stops() );
|
||||||
|
|
||||||
|
return gradient;
|
||||||
|
}
|
||||||
|
|
||||||
static void qskUpdateGeometry( const QPainterPath& path,
|
static void qskUpdateGeometry( const QPainterPath& path,
|
||||||
const QTransform& transform, QSGGeometry& geometry )
|
const QTransform& transform, QSGGeometry& geometry )
|
||||||
{
|
{
|
||||||
|
|
@ -67,36 +76,6 @@ static inline void qskResetGeometry( QskShapeNode* node )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool qskIsGradientVisible( const QGradient* gradient )
|
|
||||||
{
|
|
||||||
if ( gradient && gradient->type() != QGradient::NoGradient )
|
|
||||||
{
|
|
||||||
for ( const auto& stop : gradient->stops() )
|
|
||||||
{
|
|
||||||
if ( stop.second.alpha() > 0 )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool qskIsGradientMonochrome( const QGradient* gradient )
|
|
||||||
{
|
|
||||||
if ( gradient && gradient->type() != QGradient::NoGradient )
|
|
||||||
{
|
|
||||||
const auto stops = gradient->stops();
|
|
||||||
|
|
||||||
for ( int i = 1; i < stops.count(); i++ )
|
|
||||||
{
|
|
||||||
if ( stops[i].second != stops[i - 1].second )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
class QskShapeNodePrivate final : public QSGGeometryNodePrivate
|
class QskShapeNodePrivate final : public QSGGeometryNodePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -107,7 +86,7 @@ class QskShapeNodePrivate final : public QSGGeometryNodePrivate
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGGeometry geometry;
|
QSGGeometry geometry;
|
||||||
QGradient::Type gradientType = QGradient::NoGradient;
|
int gradientType = -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Is there a better way to find out if the path has changed
|
Is there a better way to find out if the path has changed
|
||||||
|
|
@ -149,10 +128,10 @@ void QskShapeNode::updateNode( const QPainterPath& path,
|
||||||
markDirty( QSGNode::DirtyGeometry );
|
markDirty( QSGNode::DirtyGeometry );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( material() == nullptr || d->gradientType != QGradient::NoGradient )
|
if ( material() == nullptr || d->gradientType >= 0 )
|
||||||
{
|
{
|
||||||
setMaterial( new QSGFlatColorMaterial() );
|
setMaterial( new QSGFlatColorMaterial() );
|
||||||
d->gradientType = QGradient::NoGradient;
|
d->gradientType = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto c = color.toRgb();
|
const auto c = color.toRgb();
|
||||||
|
|
@ -166,12 +145,11 @@ void QskShapeNode::updateNode( const QPainterPath& path,
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskShapeNode::updateNode( const QPainterPath& path,
|
void QskShapeNode::updateNode( const QPainterPath& path,
|
||||||
const QTransform& transform, const QRectF& rect,
|
const QTransform& transform, const QRectF& rect, const QskGradient& gradient )
|
||||||
const QGradient* gradient, qreal extraValue )
|
|
||||||
{
|
{
|
||||||
Q_D( QskShapeNode );
|
Q_D( QskShapeNode );
|
||||||
|
|
||||||
if ( path.isEmpty() || !qskIsGradientVisible( gradient ) )
|
if ( path.isEmpty() || !gradient.isVisible() )
|
||||||
{
|
{
|
||||||
d->path = QPainterPath();
|
d->path = QPainterPath();
|
||||||
qskResetGeometry( this );
|
qskResetGeometry( this );
|
||||||
|
|
@ -179,9 +157,9 @@ void QskShapeNode::updateNode( const QPainterPath& path,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( qskIsGradientMonochrome( gradient ) )
|
if ( gradient.isMonochrome() )
|
||||||
{
|
{
|
||||||
updateNode( path, transform, gradient->stops().first().first );
|
updateNode( path, transform, gradient.stops().first().color() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,14 +172,18 @@ void QskShapeNode::updateNode( const QPainterPath& path,
|
||||||
markDirty( QSGNode::DirtyGeometry );
|
markDirty( QSGNode::DirtyGeometry );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( material() == nullptr ) || ( gradient->type() != d->gradientType ) )
|
const auto effectiveGradient = qskEffectiveGradient( gradient );
|
||||||
|
|
||||||
|
const auto gradientType = effectiveGradient.type();
|
||||||
|
|
||||||
|
if ( ( material() == nullptr ) || ( gradientType != d->gradientType ) )
|
||||||
{
|
{
|
||||||
setMaterial( QskGradientMaterial::createMaterial( gradient->type() ) );
|
setMaterial( QskGradientMaterial::createMaterial( gradientType ) );
|
||||||
d->gradientType = gradient->type();
|
d->gradientType = gradientType;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto gradientMaterial = static_cast< QskGradientMaterial* >( material() );
|
auto gradientMaterial = static_cast< QskGradientMaterial* >( material() );
|
||||||
if ( gradientMaterial->updateGradient( rect, gradient, extraValue ) )
|
if ( gradientMaterial->updateGradient( rect, effectiveGradient ) )
|
||||||
markDirty( QSGNode::DirtyMaterial );
|
markDirty( QSGNode::DirtyMaterial );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include "QskGlobal.h"
|
#include "QskGlobal.h"
|
||||||
#include <qsgnode.h>
|
#include <qsgnode.h>
|
||||||
|
|
||||||
class QGradient;
|
class QskGradient;
|
||||||
class QColor;
|
class QColor;
|
||||||
class QPainterPath;
|
class QPainterPath;
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ class QSK_EXPORT QskShapeNode : public QSGGeometryNode
|
||||||
QskShapeNode();
|
QskShapeNode();
|
||||||
|
|
||||||
void updateNode( const QPainterPath&, const QTransform&,
|
void updateNode( const QPainterPath&, const QTransform&,
|
||||||
const QRectF&, const QGradient*, qreal = 0.0 );
|
const QRectF&, const QskGradient& );
|
||||||
|
|
||||||
void updateNode( const QPainterPath&,
|
void updateNode( const QPainterPath&,
|
||||||
const QTransform&, const QColor& );
|
const QTransform&, const QColor& );
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -27,6 +27,9 @@ HEADERS += \
|
||||||
common/QskGlobal.h \
|
common/QskGlobal.h \
|
||||||
common/QskGradient.h \
|
common/QskGradient.h \
|
||||||
common/QskGradientStop.h \
|
common/QskGradientStop.h \
|
||||||
|
common/QskConicGradient.h \
|
||||||
|
common/QskLinearGradient.h \
|
||||||
|
common/QskRadialGradient.h \
|
||||||
common/QskHctColor.h \
|
common/QskHctColor.h \
|
||||||
common/QskIntervalF.h \
|
common/QskIntervalF.h \
|
||||||
common/QskMargins.h \
|
common/QskMargins.h \
|
||||||
|
|
@ -55,6 +58,9 @@ SOURCES += \
|
||||||
common/QskBoxHints.cpp \
|
common/QskBoxHints.cpp \
|
||||||
common/QskFunctions.cpp \
|
common/QskFunctions.cpp \
|
||||||
common/QskGradient.cpp \
|
common/QskGradient.cpp \
|
||||||
|
common/QskConicGradient.cpp \
|
||||||
|
common/QskLinearGradient.cpp \
|
||||||
|
common/QskRadialGradient.cpp \
|
||||||
common/QskGradientStop.cpp \
|
common/QskGradientStop.cpp \
|
||||||
common/QskHctColor.cpp \
|
common/QskHctColor.cpp \
|
||||||
common/QskIntervalF.cpp \
|
common/QskIntervalF.cpp \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue