incorporate Uwe's changes
This commit is contained in:
parent
deb5df8edb
commit
a83df8c6f7
|
@ -30,19 +30,15 @@ QRectF CircularProgressBarSkinlet::subControlRect(
|
|||
QSGNode* CircularProgressBarSkinlet::updateSubNode(
|
||||
const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const
|
||||
{
|
||||
const auto bar = static_cast< const CircularProgressBar* >( skinnable );
|
||||
|
||||
switch( nodeRole )
|
||||
{
|
||||
case GrooveRole:
|
||||
{
|
||||
return updateArcNode( skinnable, node, CircularProgressBar::Groove,
|
||||
bar->window() );
|
||||
return updateArcNode( skinnable, node, CircularProgressBar::Groove );
|
||||
}
|
||||
case BarRole:
|
||||
{
|
||||
return updateArcNode( skinnable, node, CircularProgressBar::Bar,
|
||||
bar->window() );
|
||||
return updateArcNode( skinnable, node, CircularProgressBar::Bar );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,10 +109,10 @@ void Skin::initHints( const Palette& palette )
|
|||
ed.setColor( TopBarItem::Item4 | QskAspect::TextColor, "#6776ff" );
|
||||
|
||||
// conical gradients are counterclockwise, so specify the 2nd color first:
|
||||
ed.setGradient( TopBarItem::Item1, { QskGradient::Conical, "#FF3122", "#FF5C00" } );
|
||||
ed.setGradient( TopBarItem::Item2, { QskGradient::Conical, "#6100FF", "#6776FF" } );
|
||||
ed.setGradient( TopBarItem::Item3, { QskGradient::Conical, "#FF3122", "#FFCE50" } );
|
||||
ed.setGradient( TopBarItem::Item4, { QskGradient::Conical, "#6100FF", "#6776FF" } );
|
||||
ed.setGradient( TopBarItem::Item1, { QskGradient::Horizontal, "#FF3122", "#FF5C00" } );
|
||||
ed.setGradient( TopBarItem::Item2, { QskGradient::Horizontal, "#6100FF", "#6776FF" } );
|
||||
ed.setGradient( TopBarItem::Item3, { QskGradient::Horizontal, "#FF3122", "#FFCE50" } );
|
||||
ed.setGradient( TopBarItem::Item4, { QskGradient::Horizontal, "#6100FF", "#6776FF" } );
|
||||
|
||||
// the bar gradient is defined through the top bar items above
|
||||
ed.setArcMetrics( CircularProgressBar::Groove, { 8.53, 90 * 16, -360 * 16 } );
|
||||
|
|
|
@ -60,7 +60,7 @@ class DaytimeSkin : public Skin
|
|||
: Skin(
|
||||
Skin::Palette( {"#6D7BFB"}, {"#fbfbfb"}, {"#ffffff"},
|
||||
"#ffffff", {"#f7f7f7"}, {"#f4f4f4"}, Qt::black, Qt::black,
|
||||
{ QskGradient::Radial, { { 0.0, 0xc4c4c4 }, { 0.5, 0xf8f8f8 }, { 1.0, 0xc4c4c4 } } } )
|
||||
{ QskGradient::Vertical, { { 0.0, 0xc4c4c4 }, { 0.5, 0xf8f8f8 }, { 1.0, 0xc4c4c4 } } } )
|
||||
, parent )
|
||||
{
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ class NighttimeSkin : public Skin
|
|||
: Skin(
|
||||
Skin::Palette( {"#2937A7"}, {"#040404"}, {"#000000"},
|
||||
"#000000", {"#0a0a0a"}, {"#0c0c0c"}, Qt::white, Qt::white,
|
||||
{ QskGradient::Radial, { { 0.0, 0x666666 }, { 0.5, 0x222222 }, { 1.0, 0x333333 } } } )
|
||||
{ QskGradient::Vertical, { { 0.0, 0x666666 }, { 0.5, 0x222222 }, { 1.0, 0x333333 } } } )
|
||||
, parent )
|
||||
{
|
||||
}
|
||||
|
|
|
@ -50,8 +50,7 @@ class QSK_EXPORT QskAspect
|
|||
|
||||
Shadow,
|
||||
Shape,
|
||||
Border,
|
||||
Arc
|
||||
Border
|
||||
};
|
||||
Q_ENUM( Primitive )
|
||||
|
||||
|
|
|
@ -34,9 +34,7 @@ class QSK_EXPORT QskGradient
|
|||
{
|
||||
Horizontal,
|
||||
Vertical,
|
||||
Diagonal,
|
||||
Radial,
|
||||
Conical
|
||||
Diagonal
|
||||
};
|
||||
|
||||
Q_ENUM( Orientation )
|
||||
|
|
|
@ -109,11 +109,6 @@ namespace
|
|||
{
|
||||
return aspect | QskAspect::Border;
|
||||
}
|
||||
|
||||
inline QskAspect aspectArc( QskAspect aspect )
|
||||
{
|
||||
return aspect | QskAspect::Arc;
|
||||
}
|
||||
}
|
||||
|
||||
QskSkinHintTableEditor::QskSkinHintTableEditor( QskSkinHintTable* table )
|
||||
|
@ -477,23 +472,23 @@ QskBoxBorderColors QskSkinHintTableEditor::boxBorderColors( QskAspect aspect ) c
|
|||
void QskSkinHintTableEditor::setArcMetrics( QskAspect aspect, qreal width,
|
||||
int startAngle, int spanAngle, Qt::SizeMode sizeMode )
|
||||
{
|
||||
setMetricHint( aspectArc( aspect ),
|
||||
setMetricHint( aspectShape( aspect ),
|
||||
QskArcMetrics( width, startAngle, spanAngle, sizeMode ) );
|
||||
}
|
||||
|
||||
void QskSkinHintTableEditor::setArcMetrics( QskAspect aspect,
|
||||
const QskArcMetrics& arcMetrics, QskStateCombination combination )
|
||||
{
|
||||
setMetricHint( aspectArc( aspect ), arcMetrics, combination );
|
||||
setMetricHint( aspectShape( aspect ), arcMetrics, combination );
|
||||
}
|
||||
|
||||
void QskSkinHintTableEditor::removeArcMetrics( QskAspect aspect,
|
||||
QskStateCombination combination )
|
||||
{
|
||||
return removeMetricHint( aspectArc( aspect ), combination );
|
||||
return removeMetricHint( aspectShape( aspect ), combination );
|
||||
}
|
||||
|
||||
QskArcMetrics QskSkinHintTableEditor::arcMetrics( QskAspect aspect ) const
|
||||
{
|
||||
return metricHint< QskArcMetrics >( aspectArc( aspect ) );
|
||||
return metricHint< QskArcMetrics >( aspectShape( aspect ) );
|
||||
}
|
||||
|
|
|
@ -321,26 +321,27 @@ QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable,
|
|||
}
|
||||
|
||||
QSGNode* QskSkinlet::updateArcNode( const QskSkinnable* skinnable,
|
||||
QSGNode* node, QskAspect::Subcontrol subControl,
|
||||
QQuickWindow* window ) const
|
||||
QSGNode* node, QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
const auto rect = qskSubControlRect( this, skinnable, subControl );
|
||||
return updateArcNode( skinnable, node, rect, subControl, window );
|
||||
return updateArcNode( skinnable, node, rect, subControl );
|
||||
}
|
||||
|
||||
QSGNode* QskSkinlet::updateArcNode( const QskSkinnable* skinnable,
|
||||
QSGNode* node, const QRectF& rect, QskAspect::Subcontrol subControl,
|
||||
QQuickWindow* window )
|
||||
QSGNode* node, const QRectF& rect, QskAspect::Subcontrol subControl )
|
||||
{
|
||||
const auto fillGradient = skinnable->gradientHint( subControl );
|
||||
return updateArcNode( skinnable, node, rect, fillGradient, subControl,
|
||||
window );
|
||||
return updateArcNode( skinnable, node, rect, fillGradient, subControl );
|
||||
}
|
||||
|
||||
QSGNode* QskSkinlet::updateArcNode( const QskSkinnable* skinnable,
|
||||
QSGNode* node, const QRectF& rect, const QskGradient& fillGradient,
|
||||
QskAspect::Subcontrol subControl, QQuickWindow* window )
|
||||
QskAspect::Subcontrol subControl )
|
||||
{
|
||||
const auto control = skinnable->owningControl();
|
||||
if ( control == nullptr )
|
||||
return nullptr;
|
||||
|
||||
const auto margins = skinnable->marginHint( subControl );
|
||||
|
||||
const auto arcRect = rect.marginsRemoved( margins );
|
||||
|
@ -359,7 +360,7 @@ QSGNode* QskSkinlet::updateArcNode( const QskSkinnable* skinnable,
|
|||
if ( arcNode == nullptr )
|
||||
arcNode = new QskArcNode();
|
||||
|
||||
arcNode->setArcData( rect, arcMetrics, fillGradient, window );
|
||||
arcNode->setArcData( rect, arcMetrics, fillGradient, control->window() );
|
||||
|
||||
return arcNode;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ class QskGraphic;
|
|||
class QskTextOptions;
|
||||
|
||||
class QSGNode;
|
||||
class QQuickWindow;
|
||||
|
||||
class QSK_EXPORT QskSkinlet
|
||||
{
|
||||
|
@ -54,11 +53,10 @@ class QSK_EXPORT QskSkinlet
|
|||
const QRectF&, const QskGradient&, QskAspect::Subcontrol );
|
||||
|
||||
static QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
|
||||
const QRectF&, QskAspect::Subcontrol, QQuickWindow* );
|
||||
const QRectF&, QskAspect::Subcontrol );
|
||||
|
||||
static QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
|
||||
const QRectF&, const QskGradient&, QskAspect::Subcontrol,
|
||||
QQuickWindow* );
|
||||
const QRectF&, const QskGradient&, QskAspect::Subcontrol );
|
||||
|
||||
static QSGNode* updateTextNode( const QskSkinnable*, QSGNode*,
|
||||
const QRectF&, Qt::Alignment, const QString&, const QskTextOptions&,
|
||||
|
@ -94,7 +92,7 @@ class QSK_EXPORT QskSkinlet
|
|||
QskAspect::Subcontrol ) const;
|
||||
|
||||
QSGNode* updateArcNode( const QskSkinnable*, QSGNode*,
|
||||
QskAspect::Subcontrol, QQuickWindow* ) const;
|
||||
QskAspect::Subcontrol ) const;
|
||||
|
||||
QSGNode* updateBoxClipNode( const QskSkinnable*, QSGNode*,
|
||||
QskAspect::Subcontrol ) const;
|
||||
|
|
|
@ -525,19 +525,19 @@ QskBoxBorderColors QskSkinnable::boxBorderColorsHint(
|
|||
bool QskSkinnable::setArcMetricsHint(
|
||||
const QskAspect aspect, const QskArcMetrics& arc )
|
||||
{
|
||||
return qskSetMetric( this, aspect | QskAspect::Arc, arc );
|
||||
return qskSetMetric( this, aspect | QskAspect::Shape, arc );
|
||||
}
|
||||
|
||||
bool QskSkinnable::resetArcMetricsHint( const QskAspect aspect )
|
||||
{
|
||||
return resetMetric( aspect | QskAspect::Arc );
|
||||
return resetMetric( aspect | QskAspect::Shape );
|
||||
}
|
||||
|
||||
QskArcMetrics QskSkinnable::arcMetricsHint(
|
||||
const QskAspect aspect, QskSkinHintStatus* status ) const
|
||||
{
|
||||
return qskMetric< QskArcMetrics >(
|
||||
this, aspect | QskAspect::Arc, status );
|
||||
this, aspect | QskAspect::Shape, status );
|
||||
}
|
||||
|
||||
bool QskSkinnable::setSpacingHint( const QskAspect aspect, qreal spacing )
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* QSkinny - Copyright (C) 2021 Uwe Rathmann
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
|
@ -36,10 +36,8 @@ uint QskArcNode::hash() const
|
|||
{
|
||||
uint h = m_metrics.hash();
|
||||
|
||||
for( const QskGradientStop& stop : m_gradient.stops() )
|
||||
{
|
||||
for( const auto& stop : m_gradient.stops() )
|
||||
h = stop.hash( h );
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**********************************************************************
|
||||
* QSkinny - Copyright (C) 2021 Uwe Rathmann
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/******************************************************************************
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#include "QskArcRenderer.h"
|
||||
#include "QskArcMetrics.h"
|
||||
#include "QskGradient.h"
|
||||
|
||||
#include <qpainter.h>
|
||||
#include <qrect.h>
|
||||
|
||||
void QskArcRenderer::renderArc(const QRectF& rect,
|
||||
const QskArcMetrics& metrics, const QskGradient& gradient,
|
||||
QPainter* painter )
|
||||
{
|
||||
painter->setRenderHint( QPainter::Antialiasing, true );
|
||||
|
||||
QGradientStops stops;
|
||||
|
||||
for( const QskGradientStop& stop : gradient.stops() )
|
||||
{
|
||||
QGradientStop s( stop.position(), stop.color() );
|
||||
stops.append( s );
|
||||
}
|
||||
|
||||
/*
|
||||
horizontal is interpreted as in direction of the arc,
|
||||
while vertical means from the inner to the outer border
|
||||
*/
|
||||
|
||||
QBrush brush;
|
||||
|
||||
if( gradient.orientation() == QskGradient::Vertical )
|
||||
{
|
||||
QRadialGradient gradient( rect.center(), qMin( rect.width(), rect.height() ) );
|
||||
gradient.setStops( stops );
|
||||
|
||||
brush = gradient;
|
||||
}
|
||||
else
|
||||
{
|
||||
QConicalGradient gradient( rect.center(), metrics.startAngle() / 16.0 );
|
||||
gradient.setStops( stops );
|
||||
|
||||
brush = gradient;
|
||||
}
|
||||
|
||||
painter->setPen( QPen( brush, metrics.width(), Qt::SolidLine, Qt::FlatCap ) );
|
||||
painter->drawArc( rect, metrics.startAngle(), metrics.spanAngle() );
|
||||
}
|
|
@ -1,73 +1,24 @@
|
|||
/******************************************************************************
|
||||
* QSkinny - Copyright (C) 2021 Uwe Rathmann
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the QSkinny License, Version 1.0
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef QSK_ARC_RENDERER_H
|
||||
#define QSK_ARC_RENDERER_H
|
||||
|
||||
#include "QskArcMetrics.h"
|
||||
#include "QskGlobal.h"
|
||||
#include "QskGradient.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
class QskArcMetrics;
|
||||
class QskGradient;
|
||||
|
||||
class QPainter;
|
||||
class QRectF;
|
||||
|
||||
class QSK_EXPORT QskArcRenderer
|
||||
{
|
||||
public:
|
||||
void renderArc( const QRectF& rect, const QskArcMetrics& metrics,
|
||||
const QskGradient& gradient, QPainter* );
|
||||
void renderArc( const QRectF&, const QskArcMetrics&,
|
||||
const QskGradient&, QPainter* );
|
||||
};
|
||||
|
||||
void QskArcRenderer::renderArc(const QRectF& rect,
|
||||
const QskArcMetrics& metrics, const QskGradient& gradient,
|
||||
QPainter* painter )
|
||||
{
|
||||
painter->setRenderHint( QPainter::Antialiasing, true );
|
||||
|
||||
QGradientStops stops;
|
||||
|
||||
for( const QskGradientStop& stop : gradient.stops() )
|
||||
{
|
||||
QGradientStop s( stop.position(), stop.color() );
|
||||
stops.append( s );
|
||||
}
|
||||
|
||||
if( gradient.orientation() == QskGradient::Horizontal
|
||||
|| gradient.orientation() == QskGradient::Vertical )
|
||||
{
|
||||
QPointF finalStop = ( gradient.orientation() == QskGradient::Horizontal )
|
||||
? QPointF( rect.width(), 0 ) : QPointF( 0, rect.height() );
|
||||
|
||||
QLinearGradient linearGradient( { 0, 0 }, finalStop );
|
||||
linearGradient.setStops( stops );
|
||||
painter->setPen( QPen( linearGradient, metrics.width(), Qt::SolidLine,
|
||||
Qt::FlatCap ) );
|
||||
}
|
||||
else if( gradient.orientation() == QskGradient::Diagonal )
|
||||
{
|
||||
qWarning() << "cannot paint a diagonal gradient with QPainter";
|
||||
}
|
||||
else if( gradient.orientation() == QskGradient::Radial )
|
||||
{
|
||||
QRadialGradient radialGradient( rect.center(), qMin( rect.width(),
|
||||
rect.height() ) );
|
||||
radialGradient.setStops( stops );
|
||||
painter->setPen( QPen( radialGradient, metrics.width(), Qt::SolidLine,
|
||||
Qt::FlatCap ) );
|
||||
}
|
||||
else if( gradient.orientation() == QskGradient::Conical )
|
||||
{
|
||||
QConicalGradient conicalGradient( rect.center(),
|
||||
metrics.startAngle() / 16.0 );
|
||||
conicalGradient.setStops( stops );
|
||||
painter->setPen( QPen( conicalGradient, metrics.width(), Qt::SolidLine,
|
||||
Qt::FlatCap ) );
|
||||
}
|
||||
|
||||
painter->drawArc( rect, metrics.startAngle(), metrics.spanAngle() );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "QskBoxRendererColorMap.h"
|
||||
#include "QskBoxShapeMetrics.h"
|
||||
|
||||
#include <qdebug.h>
|
||||
#include <qmath.h>
|
||||
#include <qsggeometry.h>
|
||||
|
||||
|
@ -774,13 +773,6 @@ static inline int qskFillLineCount(
|
|||
|
||||
break;
|
||||
}
|
||||
case QskGradient::Radial: // fall through
|
||||
case QskGradient::Conical:
|
||||
{
|
||||
qWarning() << "radial and conical gradients are only supported"
|
||||
<< "when rendering arcs";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// adding vertexes for the stops - beside the first/last
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "QskGradient.h"
|
||||
#include "QskVertex.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace QskVertex;
|
||||
|
||||
namespace
|
||||
|
@ -378,13 +376,6 @@ static inline void qskCreateFillOrdered( const QskBoxRenderer::Quad& rect,
|
|||
|
||||
break;
|
||||
}
|
||||
case QskGradient::Radial: // fall through
|
||||
case QskGradient::Conical:
|
||||
{
|
||||
qWarning() << "radial and conical gradients are only supported"
|
||||
<< "when rendering arcs";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ HEADERS += \
|
|||
|
||||
SOURCES += \
|
||||
nodes/QskArcNode.cpp \
|
||||
nodes/QskArcRenderer.cpp \
|
||||
nodes/QskBoxNode.cpp \
|
||||
nodes/QskBoxClipNode.cpp \
|
||||
nodes/QskBoxRendererRect.cpp \
|
||||
|
|
Loading…
Reference in New Issue