Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
elevation.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025-2026 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-FileCopyrightText: 2024-2025 hypengw <hypengwip@gmail.com>
3// SPDX-License-Identifier: MPL-2.0
4//
5// Originally based on code by hypengw, licensed under the MIT license.
6
7#pragma once
8
9#include <optional>
10
11#include <QQmlEngine>
12#include <QQuickItem>
13
14namespace Fluid {
15
16class Elevation : public QQuickItem
17{
18 Q_OBJECT
19 QML_NAMED_ELEMENT(ElevationImpl)
20 Q_PROPERTY(qreal elevation READ elevation WRITE setElevation NOTIFY elevationChanged FINAL)
21 Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged FINAL)
22 Q_PROPERTY(qreal topLeftRadius READ topLeftRadius WRITE setTopLeftRadius NOTIFY
24 Q_PROPERTY(qreal topRightRadius READ topRightRadius WRITE setTopRightRadius NOTIFY
26 Q_PROPERTY(qreal bottomLeftRadius READ bottomLeftRadius WRITE setBottomLeftRadius NOTIFY
28 Q_PROPERTY(qreal bottomRightRadius READ bottomRightRadius WRITE setBottomRightRadius NOTIFY
30 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
31public:
32 Elevation(QQuickItem *parent = nullptr);
33 ~Elevation() override;
34
35 qreal elevation() const;
36 void setElevation(qreal elevation);
37
38 qreal radius() const;
39 void setRadius(qreal newRadius);
40
41 qreal topLeftRadius() const;
42 void setTopLeftRadius(qreal newTopLeftRadius);
43
44 qreal topRightRadius() const;
45 void setTopRightRadius(qreal newTopRightRadius);
46
47 qreal bottomLeftRadius() const;
48 void setBottomLeftRadius(qreal newBottomLeftRadius);
49
50 qreal bottomRightRadius() const;
51 void setBottomRightRadius(qreal newBottomRightRadius);
52
53 QColor color() const;
54 void setColor(const QColor &newColor);
55
56 void componentComplete() override;
57
58Q_SIGNALS:
60 void radiusChanged(qreal radius);
65 void colorChanged(QColor color);
66
67protected:
68 void itemChange(QQuickItem::ItemChange change,
69 const QQuickItem::ItemChangeData &value) override;
70 QSGNode *updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *data) override;
71
72private:
73 qreal m_elevation = 0.0;
74 qreal m_radius = 0.0;
75 std::optional<qreal> m_topLeftRadius;
76 std::optional<qreal> m_topRightRadius;
77 std::optional<qreal> m_bottomLeftRadius;
78 std::optional<qreal> m_bottomRightRadius;
79 QColor m_color = Qt::black;
80};
81
82} // namespace Fluid
A QQuickItem that renders elevation-based shadow effects.
Definition elevation.h:17
qreal topRightRadius
Definition elevation.h:25
void setColor(const QColor &newColor)
Sets the shadow color.
void setBottomLeftRadius(qreal newBottomLeftRadius)
QSGNode * updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *data) override
Updates the paint node for rendering.
void setElevation(qreal elevation)
Sets the elevation level.
void topLeftRadiusChanged(qreal topLeftRadius)
void radiusChanged(qreal radius)
void setBottomRightRadius(qreal newBottomRightRadius)
void componentComplete() override
Called when the component is complete.
void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override
Handles item changes.
void colorChanged(QColor color)
void setRadius(qreal newRadius)
Sets the radius for all corners.
void setTopLeftRadius(qreal newTopLeftRadius)
void topRightRadiusChanged(qreal topRightRadius)
void bottomLeftRadiusChanged(qreal bottomLeftRadius)
qreal topLeftRadius
Definition elevation.h:23
void elevationChanged(qreal elevation)
void bottomRightRadiusChanged(qreal bottomRightRadius)
qreal bottomRightRadius
Definition elevation.h:29
qreal bottomLeftRadius
Definition elevation.h:27
void setTopRightRadius(qreal newTopRightRadius)