slint/internal/compiler/widgets/cupertino-base/components.slint
2023-09-14 11:05:03 +02:00

103 lines
2.8 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
import { Palette, Typography, Icons } from "styling.slint";
export component FocusBorder inherits Rectangle {
in property <bool> has-focus;
background: Palette.accent-tertiary;
opacity: 0;
animate opacity { duration: 150ms; }
states [
focused when root.has-focus : {
opacity: 1;
}
]
}
export component MenuBorder inherits Rectangle {
drop-shadow-blur: 22px;
drop-shadow-color: #00000066;
drop-shadow-offset-y: 0.5px;
background: Palette.background;
border-radius: 6px;
Rectangle {
width: 100%;
height: 100%;
border-radius: parent.border-radius;
background: Palette.background;
@children
}
Rectangle {
width: 100%;
height: 100%;
border-radius: parent.border-radius;
border-width: 1px;
border-color: Palette.popup-border;
}
}
export component ListItem {
callback clicked <=> i-touch-area.clicked;
callback pointer-event <=> i-touch-area.pointer-event;
in property <bool> selected;
in property <string> text <=> i-text.text;
in property <length> padding-horizontal: 12px;
out property <length> mouse-x <=> i-touch-area.mouse-x;
out property <length> mouse-y <=> i-touch-area.mouse-y;
min-width: i-layout.min-width;
min-height: max(22px, i-layout.min-height);
vertical-stretch: 0;
horizontal-stretch: 1;
i-layout := VerticalLayout {
padding-left: root.padding-horizontal;
padding-right: root.padding-horizontal;
i-background := Rectangle {
background: transparent;
border-radius: 5px;
HorizontalLayout {
spacing: 4px;
padding-left: 4px;
padding-right: 4px;
i-icon := Image {
image-fit: contain;
source: Icons.check-mark;
colorize: Palette.foreground;
visible: root.selected;
width: 10px;
}
i-text := Text {
color: Palette.foreground;
font-size: Typography.body.font-size;
font-weight: Typography.body.font-weight;
vertical-alignment: center;
horizontal-alignment: left;
overflow: elide;
}
}
}
}
i-touch-area := TouchArea {}
states [
hover when i-touch-area.has-hover : {
i-background.background: Palette.accent;
i-text.color: Palette.on-surface;
i-icon.colorize: Palette.on-surface;
}
]
}