Fluid
Loading...
Searching...
No Matches
elevation.h
Go to the documentation of this file.
1/*
2 * This file is part of Fluid.
3 *
4 * Copyright (C) 2025 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
5 * Copyright (C) 2024-2025 hypengw <hypengwip@gmail.com>
6 *
7 * $BEGIN_LICENSE:MPL2$
8 *
9 * This Source Code Form is subject to the terms of the Mozilla Public
10 * License, v. 2.0. If a copy of the MPL was not distributed with this
11 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 *
13 * $END_LICENSE$
14 */
15
16#pragma once
17
18#include <QQmlEngine>
19#include <QQuickItem>
20
21#include "cornersgroup.h"
22
23namespace Fluid {
24
25class Elevation : public QQuickItem
26{
27 Q_OBJECT
28 QML_NAMED_ELEMENT(ElevationImpl)
29 Q_PROPERTY(qreal elevation READ elevation WRITE setElevation NOTIFY elevationChanged FINAL)
30 Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged FINAL)
31 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
32 Q_PROPERTY(CornersGroup corners READ corners WRITE setCorners NOTIFY cornersChanged FINAL)
33public:
34 Elevation(QQuickItem *parent = nullptr);
35 ~Elevation() override;
36
37 qreal elevation() const;
38 void setElevation(qreal elevation);
39 Q_SIGNAL void elevationChanged(qreal elevation);
40
41 const CornersGroup &corners() const;
42 void setCorners(const CornersGroup &);
44
45 qreal radius() const;
46 void setRadius(qreal newRadius);
47 Q_SIGNAL void radiusChanged(qreal radius);
48
49 QColor color() const;
50 void setColor(const QColor &newColor);
51 Q_SIGNAL void colorChanged(QColor color);
52
53 void componentComplete() override;
54
55protected:
56 void itemChange(QQuickItem::ItemChange change,
57 const QQuickItem::ItemChangeData &value) override;
58 QSGNode *updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *data) override;
59
60private:
61 qreal m_elevation;
62 CornersGroup m_corners;
63 qreal m_radius;
64 QColor m_color;
65};
66
67} // namespace Fluid
Represents the corner radii for a rectangular material-design shape.
Definition cornersgroup.h:24
A QQuickItem that renders elevation-based shadow effects.
Definition elevation.h:26
qreal radius
Definition elevation.h:30
Q_SIGNAL void elevationChanged(qreal elevation)
void setColor(const QColor &newColor)
Sets the shadow color.
Definition elevation.cpp:216
QSGNode * updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *data) override
Updates the paint node for rendering.
Definition elevation.cpp:254
CornersGroup corners
Definition elevation.h:32
void setElevation(qreal elevation)
Sets the elevation level.
Definition elevation.cpp:152
void componentComplete() override
Called when the component is complete.
Definition elevation.cpp:229
Q_SIGNAL void colorChanged(QColor color)
QColor color
Definition elevation.h:31
void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override
Handles item changes.
Definition elevation.cpp:239
void setRadius(qreal newRadius)
Sets the radius for all corners.
Definition elevation.cpp:192
void setCorners(const CornersGroup &)
Sets the corners group.
Definition elevation.cpp:173
qreal elevation
Definition elevation.h:29
Q_SIGNAL void radiusChanged(qreal radius)
Q_SIGNAL void cornersChanged(CornersGroup)
Definition rectangle.cpp:26