slint/internal/compiler/widgets/fluent-base/components.slint
2023-11-21 14:45:07 +01:00

100 lines
3.1 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 { FluentPalette, FluentFontSettings } from "styling.slint";
export component FocusBorder inherits Rectangle {
border-width: 2px;
border-color: FluentPalette.focus-stroke-outer;
Rectangle {
x: parent.border-width;
y: parent.border-width;
width: parent.width - 2 * parent.border-width;
height: parent.height - 2 * parent.border-width;
border-width: 1px;
border-radius: parent.border-radius - 2px;
border-color: FluentPalette.focus-stroke-inner;
}
}
export component MenuBorder inherits Rectangle {
border-radius: 7px;
background: FluentPalette.background-alt;
drop-shadow-blur: 16px;
drop-shadow-offset-y: 8px;
drop-shadow-color: FluentPalette.shadow;
Rectangle {
border-width: 1px;
border-radius: parent.border-radius;
border-color: FluentPalette.surface-stroke-flyout;
}
}
export component ListItem {
in property <bool> selected;
in property <string> text <=> i-text.text;
out property <length> mouse-x <=> i-touch-area.mouse-x;
out property <length> mouse-y <=> i-touch-area.mouse-y;
callback clicked <=> i-touch-area.clicked;
callback pointer-event <=> i-touch-area.pointer-event;
min-width: i-layout.min-width;
min-height: max(34px, i-layout.min-height);
vertical-stretch: 0;
horizontal-stretch: 1;
states [
pressed when i-touch-area.pressed : {
i-background.background: selected ? FluentPalette.subtle-secondary : FluentPalette.subtle-tertiary;
}
hover when i-touch-area.has-hover : {
i-text.color: FluentPalette.text-secondary;
i-background.background: selected ? FluentPalette.subtle-tertiary : FluentPalette.subtle-secondary;
i-selector.height: root.selected ? 16px : 0;
}
selected when root.selected : {
i-background.background: FluentPalette.subtle-secondary;
i-selector.height: 16px;
}
]
i-background := Rectangle {
background: transparent;
border-radius: 4px;
animate background { duration: 150ms; }
i-layout := HorizontalLayout {
padding-left: 16px;
padding-right: 16px;
spacing: 4px;
i-text := Text {
color: FluentPalette.on-surface;
font-size: FluentFontSettings.body.font-size;
font-weight: FluentFontSettings.body.font-weight;
vertical-alignment: center;
horizontal-alignment: left;
overflow: elide;
animate color { duration: 200ms; }
}
}
i-selector := Rectangle {
x: 0px;
y: (parent.height - self.height) / 2;
width: 3px;
height: 0px;
background: FluentPalette.accent;
border-radius: 2px;
animate height { duration: 150ms; easing: ease-out; }
}
}
i-touch-area := TouchArea {}
}