Fluid
Loading...
Searching...
No Matches
rectangle.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 Rectangle : public QQuickItem
26{
27 Q_OBJECT
28 QML_NAMED_ELEMENT(RectangleImpl)
29
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 Rectangle(QQuickItem *parent = nullptr);
35 ~Rectangle() override;
36
37 auto corners() const -> CornersGroup;
38 void setCorners(const CornersGroup &);
39 Q_SIGNAL void cornersChanged();
40
41 qreal radius() const;
42 void setRadius(qreal newRadius);
43 Q_SIGNAL void radiusChanged();
44
45 QColor color() const;
46 void setColor(const QColor &newColor);
47 Q_SIGNAL void colorChanged();
48
49 void componentComplete() override;
50
51protected:
52 void itemChange(QQuickItem::ItemChange change,
53 const QQuickItem::ItemChangeData &value) override;
54 QSGNode *updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *data) override;
55
56private:
57 CornersGroup m_corners;
58 qreal m_radius;
59 QColor m_color;
60};
61
62} // namespace Fluid
Represents the corner radii for a rectangular material-design shape.
Definition cornersgroup.h:24
Definition rectangle.h:26
void setColor(const QColor &newColor)
Definition rectangle.cpp:104
void setRadius(qreal newRadius)
Definition rectangle.cpp:89
Q_SIGNAL void colorChanged()
void componentComplete() override
Definition rectangle.cpp:114
qreal radius
Definition rectangle.h:30
Q_SIGNAL void cornersChanged()
CornersGroup corners
Definition rectangle.h:32
void setCorners(const CornersGroup &)
Definition rectangle.cpp:78
void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override
Definition rectangle.cpp:119
QColor color
Definition rectangle.h:31
Q_SIGNAL void radiusChanged()
QSGNode * updatePaintNode(QSGNode *node, QQuickItem::UpdatePaintNodeData *data) override
Definition rectangle.cpp:128
Definition rectangle.cpp:26