mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 10:50:00 +00:00
[reorg]: Set up and populate the internal
directory
Move "internal" crates into the `internal` directory. This first batch includes most of sixtyfps_runtime but leaves the rendering backends alone for now. pre-commit applied some cleanups to the moved files: - Consistent newline at end of file policy - trimming trailing whitespace - Formatting Cargo.toml files.
This commit is contained in:
parent
d22c8bd3df
commit
e6b24bceec
288 changed files with 248 additions and 228 deletions
105
internal/compiler/widgets/common/common.60
Normal file
105
internal/compiler/widgets/common/common.60
Normal file
|
@ -0,0 +1,105 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
import { StyleMetrics, ScrollView } from "sixtyfps_widgets_impl.60";
|
||||
|
||||
export LineEditInner := Rectangle {
|
||||
callback accepted(string);
|
||||
callback edited(string);
|
||||
property <string> placeholder-text;
|
||||
property font-size <=> input.font-size;
|
||||
property text <=> input.text;
|
||||
property placeholder-color <=> placeholder.color;
|
||||
property enabled <=> input.enabled;
|
||||
property has-focus <=> input.has-focus;
|
||||
min-height: input.preferred-height;
|
||||
min-width: max(50px, placeholder.min-width);
|
||||
clip: true;
|
||||
forward-focus: input;
|
||||
input := TextInput {
|
||||
property <length> computed_x;
|
||||
x: min(0px, max(parent.width - width, computed_x));
|
||||
width: max(parent.width, preferred-width);
|
||||
height: 100%;
|
||||
color: enabled ? StyleMetrics.textedit-text-color : StyleMetrics.textedit-text-color-disabled;
|
||||
cursor-position-changed(cpos) => {
|
||||
if (cpos.x + computed_x < StyleMetrics.layout-padding) {
|
||||
computed_x = - cpos.x + StyleMetrics.layout-padding;
|
||||
} else if (cpos.x + computed_x > parent.width - StyleMetrics.layout-padding) {
|
||||
computed_x = parent.width - cpos.x - StyleMetrics.layout-padding;
|
||||
}
|
||||
}
|
||||
accepted => { root.accepted(self.text); }
|
||||
edited => { root.edited(self.text); }
|
||||
vertical-alignment: center;
|
||||
single-line: true;
|
||||
}
|
||||
placeholder := Text {
|
||||
height: 100%; width: 100%;
|
||||
vertical-alignment: center;
|
||||
text: root.text == "" ? root.placeholder-text : "";
|
||||
}
|
||||
}
|
||||
|
||||
export TextEdit := ScrollView {
|
||||
property <length> font-size <=> input.font-size;
|
||||
property <string> text <=> input.text;
|
||||
has-focus <=> input.has-focus;
|
||||
enabled <=> input.enabled;
|
||||
property <TextWrap> wrap <=> input.wrap;
|
||||
callback edited(string);
|
||||
forward-focus: input;
|
||||
|
||||
horizontal-stretch: 1;
|
||||
vertical-stretch: 1;
|
||||
|
||||
viewport-width: wrap == TextWrap.word-wrap ? root.visible-width : max(root.visible-width, input.preferred-width);
|
||||
viewport-height: max(self.visible-height, input.preferred-height);
|
||||
|
||||
Rectangle {
|
||||
background: enabled ? StyleMetrics.textedit-background : StyleMetrics.textedit-background-disabled;
|
||||
}
|
||||
|
||||
input := TextInput {
|
||||
edited => { root.edited(self.text); }
|
||||
color: enabled ? StyleMetrics.textedit-text-color : StyleMetrics.textedit-text-color-disabled;
|
||||
single-line: false;
|
||||
wrap: word-wrap;
|
||||
cursor-position-changed(cpos) => {
|
||||
if (cpos.x + viewport-x < StyleMetrics.layout-padding) {
|
||||
viewport-x = min(0px, max(parent.visible-width - width, - cpos.x + StyleMetrics.layout-padding ));
|
||||
} else if (cpos.x + viewport-x > parent.visible-width - StyleMetrics.layout-padding) {
|
||||
viewport-x = min(0px, max(parent.visible-width - width, parent.visible-width - cpos.x - StyleMetrics.layout-padding ));
|
||||
}
|
||||
if (cpos.y + viewport-y < StyleMetrics.layout-padding) {
|
||||
viewport-y = min(0px, max(parent.visible-height - height, - cpos.y + StyleMetrics.layout-padding ));
|
||||
} else if (cpos.y + viewport-y > parent.visible-height - StyleMetrics.layout-padding - 20px) {
|
||||
// FIXME: font-height hardcoded to 20px
|
||||
viewport-y = min(0px, max(parent.visible-height - height, parent.visible-height - cpos.y - StyleMetrics.layout-padding - 20px));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export AboutSixtyFPS := Rectangle {
|
||||
VerticalLayout {
|
||||
padding: 12px;
|
||||
spacing: 8px;
|
||||
alignment: start;
|
||||
Text {
|
||||
text: "Made with";
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
Image {
|
||||
source: @image-url("sixtyfps_logo.svg");
|
||||
preferred-width: 128px;
|
||||
}
|
||||
Text {
|
||||
text: "Version 0.2.0\nhttps://sixtyfps.io/";
|
||||
font-size: 10px;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
3
internal/compiler/widgets/common/sixtyfps_logo.svg
Normal file
3
internal/compiler/widgets/common/sixtyfps_logo.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 6.7 KiB |
|
@ -0,0 +1,3 @@
|
|||
Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
|
||||
SPDX-License-Identifier: CC-BY-ND-4.0
|
20
internal/compiler/widgets/common/standardbutton.60
Normal file
20
internal/compiler/widgets/common/standardbutton.60
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
import { StyleMetrics, Button } from "sixtyfps_widgets_impl.60";
|
||||
|
||||
export StandardButton := Button {
|
||||
property <StandardButtonKind> kind;
|
||||
text:
|
||||
kind == StandardButtonKind.ok ? "OK" :
|
||||
kind == StandardButtonKind.cancel ? "Cancel" :
|
||||
kind == StandardButtonKind.apply ? "Apply" :
|
||||
kind == StandardButtonKind.close ? "Close" :
|
||||
kind == StandardButtonKind.reset ? "Reset" :
|
||||
kind == StandardButtonKind.help ? "Help" :
|
||||
kind == StandardButtonKind.yes ? "Yes" :
|
||||
kind == StandardButtonKind.no ? "No" :
|
||||
kind == StandardButtonKind.abort ? "Abort" :
|
||||
kind == StandardButtonKind.retry ? "Retry" :
|
||||
kind == StandardButtonKind.ignore ? "Ignore" : "";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue