qskinny/src/nodes/QskArcNode.cpp
Peter Hartmann b89621a3d4
Iot dashboard arc rendering (#134)
* add QskArcNode and QskArcRenderer

* IOT example: Use QskArcNode instead of own arc node

* move some functionality to the arc renderer

* add QskArcMetrics

* add methods to QskSkinlet

* remove circular bar graph node

We can now use updateArcNode() and don't need our own method.

* support linear gradients in the arc renderer

* clean up

* incorporate Uwe's changes

* add overloads for updateArcNode() when the angles are set dynamically

The angles don't always come from the style, so we need overloads
in QskSkinlet to set them dynamically.
2021-10-20 07:50:25 +02:00

44 lines
1.1 KiB
C++

/**********************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskArcNode.h"
#include "QskArcRenderer.h"
QskArcNode::QskArcNode()
{
}
QskArcNode::~QskArcNode()
{
}
void QskArcNode::setArcData( const QRectF& rect, const QskArcMetrics& metrics,
const QskGradient &gradient, QQuickWindow* window )
{
m_metrics = metrics;
m_gradient = gradient;
update( window, QskTextureRenderer::AutoDetect, rect.toRect() );
}
void QskArcNode::paint( QPainter* painter, const QSizeF &size )
{
const qreal w = m_metrics.width();
const QRectF rect( 0.5 * w, 0.5 * w, size.width() - w, size.height() - w );
QskArcRenderer renderer;
renderer.renderArc( rect, m_metrics, m_gradient, painter );
}
uint QskArcNode::hash() const
{
uint h = m_metrics.hash();
for( const auto& stop : m_gradient.stops() )
h = stop.hash( h );
return h;
}