WindowShadow: Strength can be set.

pull/3/head
cutefishd 5 years ago
parent 733c34680b
commit 1b436e900e

@ -8,12 +8,13 @@ Meui.MenuPopupWindow {
default property alias content : _mainLayout.data
Rectangle {
Meui.RoundedRect {
id: _background
anchors.fill: parent
opacity: 0.6
color: Meui.Theme.backgroundColor
radius: Meui.Theme.mediumRadius
// opacity: 0.6
// color: Meui.Theme.backgroundColor
// radius: Meui.Theme.mediumRadius
backgroundOpacity: 0.6
Meui.WindowShadow {
view: control

@ -132,6 +132,23 @@ void WindowShadow::setRadius(qreal value)
}
}
qreal WindowShadow::strength() const
{
return m_strength;
}
void WindowShadow::setStrength(qreal strength)
{
if (m_strength != strength) {
m_strength = strength;
this->classBegin();
configureTiles();
emit strengthChanged();
}
}
void WindowShadow::onViewVisibleChanged(bool visible)
{
if (visible && m_view) {
@ -181,7 +198,7 @@ TileSet WindowShadow::shadowTiles()
};
const QColor color = Qt::black;
const qreal strength = 1.5;
const qreal strength = m_strength;
const QSize boxSize = BoxShadowRenderer::calculateMinimumBoxSize(params.shadow1.radius)
.expandedTo(BoxShadowRenderer::calculateMinimumBoxSize(params.shadow2.radius));

@ -60,6 +60,7 @@ class WindowShadow : public QObject, public QQmlParserStatus
Q_PROPERTY(QWindow *view READ view WRITE setView NOTIFY viewChanged)
Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
public:
WindowShadow(QObject *parent = nullptr) noexcept;
@ -79,6 +80,9 @@ public:
void setRadius(qreal value);
qreal radius() { return m_radius; }
qreal strength() const;
void setStrength(qreal strength);
private slots:
void onViewVisibleChanged(bool);
@ -95,6 +99,7 @@ signals:
void viewChanged();
void edgesChanged();
void radiusChanged();
void strengthChanged();
private:
QWindow *m_view;
@ -103,6 +108,7 @@ private:
QVector<KWindowShadowTile::Ptr> m_tile;
TileSet m_shadowTiles;
qreal m_radius = 10;
qreal m_strength = 1.3;
};
#endif

Loading…
Cancel
Save