Kirigami2

shadowedrectanglematerial.h
1/*
2 * SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#pragma once
8
9#include <QColor>
10#include <QSGMaterial>
11#include <QSGMaterialShader>
12
13/**
14 * A material rendering a rectangle with a shadow.
15 *
16 * This material uses a distance field shader to render a rectangle with a
17 * shadow below it, optionally with rounded corners.
18 */
20{
21public:
22 enum class ShaderType {
23 Standard,
24 LowPower,
25 };
26
28
29 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override;
30 QSGMaterialType *type() const override;
31 int compare(const QSGMaterial *other) const override;
32
33 QVector2D aspect = QVector2D{1.0, 1.0};
34 float size = 0.0;
35 QVector4D radius = QVector4D{0.0, 0.0, 0.0, 0.0};
36 QColor color = Qt::white;
37 QColor shadowColor = Qt::black;
38 QVector2D offset;
39 ShaderType shaderType = ShaderType::Standard;
40
41 static QSGMaterialType staticType;
42};
43
44class ShadowedRectangleShader : public QSGMaterialShader
45{
46public:
47 ShadowedRectangleShader(ShadowedRectangleMaterial::ShaderType shaderType);
48
49 bool updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
50
51protected:
52 void setShader(ShadowedRectangleMaterial::ShaderType shaderType, const QString &shader);
53};
A material rendering a rectangle with a shadow.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:50:33 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.