slint/tools/lsp/ui/components/widgets/boolean-widget.slint
Nigel Breslaw 2da6bf4add
live-preview data tab floating table editor (#8123)
Adds a table editor based on the color picker floating draggable panel.

This includes behaviours that keep the panel inside the bounds of the live preview window and light / dark mode.
2025-04-13 14:57:50 +03:00

56 lines
1.7 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 { ChildIndicator, NameLabel, ResettingLineEdit } from "./basics.slint";
import { PropertyValue, PropertyValueKind } from "../../api.slint";
import { EditorSizeSettings, EditorSpaceSettings } from "../../components/styling.slint";
import { CheckBox } from "std-widgets.slint";
export component BooleanWidget inherits GridLayout {
in property <bool> enabled;
in property <string> property-name;
in-out property <PropertyValue> property-value;
callback set-bool-binding(value: bool);
callback update-display-string(value: string);
spacing-vertical: EditorSpaceSettings.default-spacing;
width: 100%;
Row {
NameLabel {
col: 1;
property-name: root.property-name;
property-value: root.property-value;
}
}
Row {
childIndicator := ChildIndicator {
horizontal-stretch: 0;
visible: false;
}
checkbox := CheckBox {
enabled: root.enabled;
checked: root.property-value.value-bool;
text: self.display-string();
function display-string() -> string {
return self.checked ? "true" : "false";
}
toggled() => {
root.property-value.value-bool = self.checked;
debug("property-value is now:", root.property-value.value-bool);
root.set-bool-binding(self.checked);
root.update-display-string(self.display-string());
}
}
}
}