8#include <QSGFlatColorMaterial>
10#include <QSGRendererInterface>
36 setFlags(QSGNode::OwnsGeometry | QSGNode::OwnsMaterial);
39 void init(QQuickItem *item)
41 static_cast<ElevationMaterial *
>(material())->init_fadeoff_texture(item->window());
64 for (
int i = 0; i < 4; i++) {
70 markDirty(QSGNode::DirtyGeometry);
109 : QQuickItem(parentItem)
111 setFlag(QQuickItem::ItemHasContents,
true);
142 if (!qFuzzyCompare(l, m_elevation)) {
158 if (m_topLeftRadius.has_value() || m_topRightRadius.has_value()
159 || m_bottomLeftRadius.has_value() || m_bottomRightRadius.has_value()) {
181 const bool changed = !qFuzzyCompare(m_radius, newRadius);
182 m_radius = newRadius;
185 m_topLeftRadius.reset();
186 m_topRightRadius.reset();
187 m_bottomLeftRadius.reset();
188 m_bottomRightRadius.reset();
192 if (!qFuzzyCompare(oldTL, m_radius))
194 if (!qFuzzyCompare(oldTR, m_radius))
196 if (!qFuzzyCompare(oldBL, m_radius))
198 if (!qFuzzyCompare(oldBR, m_radius))
204 return m_topLeftRadius.value_or(m_radius);
212 const qreal oldRadius =
radius();
213 m_topLeftRadius = newTopLeftRadius;
215 if (!qFuzzyCompare(
radius(), oldRadius))
221 return m_topRightRadius.value_or(m_radius);
229 const qreal oldRadius =
radius();
230 m_topRightRadius = newTopRightRadius;
232 if (!qFuzzyCompare(
radius(), oldRadius))
238 return m_bottomLeftRadius.value_or(m_radius);
246 const qreal oldRadius =
radius();
247 m_bottomLeftRadius = newBottomLeftRadius;
249 if (!qFuzzyCompare(
radius(), oldRadius))
255 return m_bottomRightRadius.value_or(m_radius);
263 const qreal oldRadius =
radius();
264 m_bottomRightRadius = newBottomRightRadius;
266 if (!qFuzzyCompare(
radius(), oldRadius))
285 if (newColor == m_color) {
298 QQuickItem::componentComplete();
308 if (change == QQuickItem::ItemSceneChange && value.window) {
312 QQuickItem::itemChange(change, value);
325 if (boundingRect().isEmpty()) {
333 shadowNode->
init(
this);
335 shadowNode->rect = boundingRect();
336 shadowNode->elevation = m_elevation;
339 shadowNode->color = m_color.rgb();
340 shadowNode->updateGeometry();
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)
Elevation(QQuickItem *parent=nullptr)
Constructs an Elevation item with an optional parent.
void setRadius(qreal newRadius)
Sets the radius for all corners.
void setTopLeftRadius(qreal newTopLeftRadius)
~Elevation() override
Destructor for the Elevation item.
void topRightRadiusChanged(qreal topRightRadius)
void bottomLeftRadiusChanged(qreal bottomLeftRadius)
void elevationChanged(qreal elevation)
void bottomRightRadiusChanged(qreal bottomRightRadius)
void setTopRightRadius(qreal newTopRightRadius)
void init(QQuickItem *item)
constexpr float kAmbientAlpha
constexpr float kShadowLightRadius
constexpr float kShadowLightHeight
constexpr QVector3D kLightPos
constexpr float kSpotAlpha
@ DirectionalLight_ShadowFlag
@ TransparentOccluder_ShadowFlag
std::unique_ptr< QSGGeometry, std::default_delete< QSGGeometry > > createShadowGeometry()
void updateShadowGeometry(QSGGeometry *geo, const ShadowParams ¶ms, const QRectF &rect)