mirror of
https://github.com/slint-ui/slint.git
synced 2025-07-12 23:55:23 +00:00
54 lines
1.4 KiB
Text
54 lines
1.4 KiB
Text
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import { TodoPalette, AnimationSettings } from "styling.slint";
|
|
|
|
export component StateLayer {
|
|
// styling
|
|
in property <length> border-radius <=> state-layer.border-radius;
|
|
|
|
// states
|
|
in property <bool> pressed;
|
|
in property <bool> has-hover;
|
|
in property <bool> has-focus;
|
|
in property <length> focus-padding: 2px;
|
|
|
|
focus-border := Rectangle {
|
|
x: (root.width - self.width) / 2;
|
|
y: (root.height - self.height) / 2;
|
|
width: root.width + 2 * root.focus-padding;
|
|
height: root.height + 2 * root.focus-padding;
|
|
border-radius: state-layer.border-radius + root.focus-padding;
|
|
border-width: 1px;
|
|
border-color: TodoPalette.focus-border;
|
|
opacity: 0;
|
|
|
|
states [
|
|
focused when root.has-focus : {
|
|
opacity: 1;
|
|
}
|
|
]
|
|
|
|
animate opacity {
|
|
duration: AnimationSettings.color-duration;
|
|
}
|
|
}
|
|
|
|
state-layer := Rectangle {
|
|
width: 100%;
|
|
height: 100%;
|
|
|
|
animate background {
|
|
duration: AnimationSettings.color-duration;
|
|
}
|
|
}
|
|
|
|
states [
|
|
pressed when root.pressed : {
|
|
state-layer.background: TodoPalette.state-pressed;
|
|
}
|
|
hoverd when root.has-hover: {
|
|
state-layer.background: TodoPalette.state-hovered;
|
|
}
|
|
]
|
|
}
|