slint/demos/home-automation/ui/components/general/innerShadowRectangle.slint
2025-05-09 14:12:59 +03:00

45 lines
1.5 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT
import { Palette } from "../../common.slint";
export component InnerShadowRectangle inherits Rectangle {
in property <length> inner-shadow-blur: 7px;
in property <brush> inner-color: Palette.background;
in property <brush> inner-shadow-color: Palette.shadow-color;
in property <bool> nine-slice: true;
clip: true;
if nine-slice:
Rectangle {
clip: true;
width: 100%;
height: 100%;
background: inner-color;
animate background, border-color, drop-shadow-blur, drop-shadow-color {
duration: 0;
easing: ease-in-out-sine;
}
Image {
source: @image-url("../../images/inner-shadow-box-soft.png", nine-slice(60));
colorize: inner-shadow-color;
opacity: 0.6;
width: 100%;
height: 100%;
}
}
if !nine-slice:
Rectangle {
height: root.height;
width: root.width;
clip: true;
border-color: Palette.alternate-background;
background: inner-shadow-color;
Rectangle {
border-radius: parent.border-radius;
background: transparent;
drop-shadow-blur: inner-shadow-blur + 0.01px;
drop-shadow-color: inner-color;
width: parent.width - (inner-shadow-blur + 0.01px) * 2;
height: parent.height - (inner-shadow-blur + 0.01px) * 2;
}
}
}