mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-03 18:29:09 +00:00

* Add `AccessibleRole::Image` * Improve accessibility of the `AboutSlint` widget * Filter out some images from the accessibility tree
131 lines
4.1 KiB
Text
131 lines
4.1 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 { FluentPalette, FluentFontSettings, Icons } from "styling.slint";
|
|
import { SpinBoxBase } from "../common/spinbox-base.slint";
|
|
|
|
component SpinBoxButton {
|
|
callback clicked <=> touch-area.clicked;
|
|
|
|
in property <image> icon <=> icon.source;
|
|
|
|
min-width: 28px;
|
|
horizontal-stretch: 0;
|
|
|
|
states [
|
|
pressed when touch-area.pressed : {
|
|
background.background: FluentPalette.subtle;
|
|
}
|
|
]
|
|
|
|
background := Rectangle {
|
|
border-radius: 3px;
|
|
|
|
icon := Image {
|
|
image-fit: contain;
|
|
colorize: FluentPalette.text-secondary;
|
|
width: 12px;
|
|
accessible-role: none;
|
|
|
|
animate colorize { duration: 150ms; }
|
|
}
|
|
}
|
|
|
|
touch-area := TouchArea {}
|
|
}
|
|
|
|
export component SpinBox {
|
|
in property <int> minimum <=> base.minimum;
|
|
in property <int> maximum <=> base.maximum;
|
|
in property <bool> enabled <=> base.enabled;
|
|
in property <int> step-size <=> base.step-size;
|
|
in property <TextHorizontalAlignment> horizontal-alignment <=> base.horizontal-alignment;
|
|
out property <bool> has-focus <=> base.has-focus;
|
|
in-out property <int> value <=> base.value;
|
|
|
|
callback edited <=> base.edited;
|
|
|
|
min-width: max(128px, layout.min-width);
|
|
min-height: max(30px, layout.min-height);
|
|
vertical-stretch: 0;
|
|
horizontal-stretch: 1;
|
|
forward-focus: base;
|
|
|
|
accessible-role: spinbox;
|
|
accessible-enabled: root.enabled;
|
|
accessible-value: root.value;
|
|
accessible-value-minimum: root.minimum;
|
|
accessible-value-maximum: root.maximum;
|
|
accessible-value-step: (root.maximum - root.minimum) / 100;
|
|
accessible-action-set-value(v) => { if v.is-float() { base.update-value(v.to-float()); } }
|
|
accessible-action-increment => { base.increment(); }
|
|
accessible-action-decrement => { base.decrement(); }
|
|
|
|
states [
|
|
disabled when !root.enabled : {
|
|
background.background: FluentPalette.control-disabled;
|
|
background.border-color: FluentPalette.border;
|
|
base.color: FluentPalette.text-disabled;
|
|
base.selection-foreground-color: FluentPalette.text-accent-foreground-disabled;
|
|
}
|
|
focused when root.has-focus : {
|
|
background.background: FluentPalette.control-input-active;
|
|
background.border-color: FluentPalette.border;
|
|
focus-border.background: FluentPalette.accent-background;
|
|
}
|
|
]
|
|
|
|
background := Rectangle {
|
|
border-radius: 4px;
|
|
background: FluentPalette.control-background;
|
|
border-width: 1px;
|
|
border-color: FluentPalette.text-control-border;
|
|
|
|
layout := HorizontalLayout {
|
|
padding-left: 12px;
|
|
padding-right: 2px;
|
|
padding-top: 4px;
|
|
padding-bottom: 4px;
|
|
spacing: 4px;
|
|
|
|
Rectangle {
|
|
clip: true;
|
|
horizontal-stretch: 1;
|
|
|
|
base := SpinBoxBase {
|
|
width: 100%;
|
|
color: FluentPalette.control-foreground;
|
|
font-size: FluentFontSettings.body.font-size;
|
|
font-weight: FluentFontSettings.body.font-weight;
|
|
selection-background-color: FluentPalette.selection-background;
|
|
selection-foreground-color: FluentPalette.accent-foreground;
|
|
}
|
|
}
|
|
|
|
SpinBoxButton {
|
|
visible: root.enabled;
|
|
icon: Icons.chevron-up;
|
|
|
|
clicked => {
|
|
base.increment();
|
|
}
|
|
}
|
|
|
|
SpinBoxButton {
|
|
visible: root.enabled;
|
|
icon: Icons.chevron-down;
|
|
|
|
clicked => {
|
|
base.decrement();
|
|
}
|
|
}
|
|
}
|
|
|
|
focus-border := Rectangle {
|
|
x: parent.border-radius;
|
|
y: parent.height - self.height;
|
|
width: parent.width - 2 * parent.border-radius;
|
|
height: 2px;
|
|
}
|
|
}
|
|
}
|