File indexing completed on 2024-05-19 07:45:59

0001 /*
0002  * SPDX-FileCopyrightText: 2021 Arjen Hiemstra <ahiemstra@heimr.nl>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #ifndef PIECHARTMATERIAL_H
0008 #define PIECHARTMATERIAL_H
0009 
0010 #include <QColor>
0011 #include <QSGMaterial>
0012 #include <QSGMaterialShader>
0013 
0014 #include "SDFShader.h"
0015 
0016 class BarChartMaterial : public QSGMaterial
0017 {
0018 public:
0019     BarChartMaterial();
0020     ~BarChartMaterial();
0021 
0022     QSGMaterialType *type() const override;
0023     QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override;
0024     int compare(const QSGMaterial *other) const override;
0025 
0026     QVector2D aspect = QVector2D{1.0, 1.0};
0027     float radius = 0.0;
0028     QColor backgroundColor = Qt::transparent;
0029 };
0030 
0031 class BarChartShader : public SDFShader
0032 {
0033 public:
0034     BarChartShader();
0035     ~BarChartShader();
0036 
0037     bool updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
0038 };
0039 
0040 #endif // PIECHARTMATERIAL_H