mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-23 08:42:20 +00:00

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.
65 lines
1.8 KiB
Text
65 lines
1.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 { ChildIndicator, CodeButton, NameLabel, ResetButton } from "./basics.slint";
|
|
|
|
import { PropertyValue } from "../../api.slint";
|
|
import { EditorSpaceSettings } from "../../components/styling.slint";
|
|
|
|
export component CodeWidget inherits GridLayout {
|
|
in property <bool> enabled;
|
|
in property <string> property-name;
|
|
in property <PropertyValue> property-value;
|
|
|
|
callback update-display-string(value: string);
|
|
|
|
callback code-action();
|
|
callback reset-action();
|
|
|
|
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;
|
|
}
|
|
|
|
HorizontalLayout {
|
|
if property-value.code == "": Text {
|
|
horizontal-alignment: left;
|
|
vertical-alignment: center;
|
|
text: @tr("Not Set");
|
|
font-italic: true;
|
|
}
|
|
|
|
if property-value.code != "": HorizontalLayout {
|
|
spacing: EditorSpaceSettings.default-spacing;
|
|
|
|
ResetButton {
|
|
enabled: root.enabled;
|
|
clicked() => {
|
|
root.reset-action();
|
|
}
|
|
}
|
|
|
|
CodeButton {
|
|
enabled: root.enabled;
|
|
clicked() => {
|
|
root.code-action();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|