slint/internal/compiler/widgets/fluent/time-picker.slint

105 lines
3.8 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
import { Time, TimePickerBase } from "../common/time-picker-base.slint";
import { VerticalBox } from "../common/layout.slint";
import { Button } from "./button.slint";
import { FluentPalette, FluentFontSettings, Icons } from "styling.slint";
import { MenuBorder } from "./components.slint";
import { StandardButton } from "../common/standardbutton.slint";
export { Time }
export component TimePickerPopup inherits PopupWindow {
in property <bool> use-24-hour-format <=> base.use-24-hour-format;
in property <string> title: "Select time";
in property <Time> time <=> base.time;
callback canceled();
callback accepted(/* current-time */ Time);
close-policy: PopupClosePolicy.no-auto-close;
background-layer := MenuBorder {
width: dialog.width;
height: dialog.height;
}
dialog := Dialog {
padding: 8px;
base := TimePickerBase {
title: root.title;
style: {
foreground: FluentPalette.foreground,
vertical-spacing: 8px,
horizontal-spacing: 4px,
clock-style: {
background: FluentPalette.background,
foreground: FluentPalette.accent-background,
time-selector-style: {
foreground: FluentPalette.foreground,
foreground-selected: FluentPalette.accent-foreground,
font-size: FluentFontSettings.body-strong.font-size,
font-weight: FluentFontSettings.body-strong.font-weight
}
},
input-style: {
background: FluentPalette.control-background,
background-selected: FluentPalette.accent-background,
foreground: FluentPalette.foreground,
foreground-selected: FluentPalette.accent-foreground,
border-radius: 8px,
font-size: 57 * 0.0625rem,
font-weight: 400
},
period-selector-style: {
border-radius: 8px,
border-width: 1px,
border-brush: FluentPalette.border,
item-style: {
font-size: FluentFontSettings.body-strong.font-size,
font-weight: FluentFontSettings.body-strong.font-weight,
foreground: FluentPalette.foreground,
background-selected: FluentPalette.accent-background,
foreground-selected: FluentPalette.accent-foreground
}
},
title-style: {
font-size: FluentFontSettings.body.font-size,
font-weight: FluentFontSettings.body.font-weight,
foreground: FluentPalette.foreground,
},
};
}
Button {
icon: base.selection-mode ? Icons.keyboard : Icons.clock;
colorize-icon: true;
accessible-label: "Toggle input picker";
dialog-button-role: action;
clicked => {
base.selection-mode = !base.selection-mode;
}
}
StandardButton {
kind: cancel;
clicked => {
root.close();
root.canceled();
}
}
StandardButton {
enabled: base.ok-enabled();
kind: ok;
clicked => {
root.close();
root.accepted(base.get-current-time());
}
}
}
}