mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 22:31:14 +00:00
135 lines
4.2 KiB
Text
135 lines
4.2 KiB
Text
/* LICENSE BEGIN
|
|
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
|
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
|
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
|
|
|
SPDX-License-Identifier: GPL-3.0-only
|
|
This file is also available under commercial licensing terms.
|
|
Please contact info@sixtyfps.io for more information.
|
|
LICENSE END */
|
|
|
|
import { LineEditInner, TextEdit, AboutSixtyFPS } from "../common/common.60";
|
|
import { StyleMetrics, ScrollView } from "sixtyfps_widgets_impl.60";
|
|
export { StyleMetrics, ScrollView, TextEdit, AboutSixtyFPS }
|
|
|
|
// FIXME: the font-size should be removed but is required right now to compile the printer-demo
|
|
export Button := NativeButton {
|
|
property<length> font-size;
|
|
enabled: true;
|
|
}
|
|
|
|
export StandardButton := NativeButton {
|
|
property<StandardButtonKind> kind <=> self.standard-button-kind;
|
|
is-standard-button: true;
|
|
}
|
|
export CheckBox := NativeCheckBox { }
|
|
export SpinBox := NativeSpinBox { property<length> font-size; }
|
|
export Slider := NativeSlider { }
|
|
export GroupBox := NativeGroupBox {
|
|
GridLayout {
|
|
padding-left: root.native-padding-left;
|
|
padding-right: root.native-padding-right;
|
|
padding-top: root.native-padding-top;
|
|
padding-bottom: root.native-padding-bottom;
|
|
@children
|
|
}
|
|
}
|
|
export LineEdit := NativeLineEdit {
|
|
property <string> text <=> inner.text;
|
|
property <string> placeholder-text <=> inner.placeholder-text;
|
|
enabled: true;
|
|
has-focus <=> inner.has-focus;
|
|
forward-focus: inner;
|
|
callback accepted <=> inner.accepted;
|
|
callback edited <=> inner.edited;
|
|
horizontal-stretch: 1;
|
|
vertical-stretch: 0;
|
|
|
|
HorizontalLayout {
|
|
padding-left: root.native-padding-left;
|
|
padding-right: root.native-padding-right;
|
|
padding-top: root.native-padding-top;
|
|
padding-bottom: root.native-padding-bottom;
|
|
inner := LineEditInner {
|
|
placeholder-color: enabled ? StyleMetrics.placeholder-color : StyleMetrics.placeholder-color-disabled;
|
|
enabled <=> root.enabled;
|
|
}
|
|
}
|
|
}
|
|
|
|
export ListView := ScrollView {
|
|
@children
|
|
}
|
|
|
|
export StandardListView := ListView {
|
|
property<[StandardListViewItem]> model;
|
|
property<int> current-item: -1;
|
|
for item[i] in model : NativeStandardListViewItem {
|
|
item: item;
|
|
index: i;
|
|
is-selected: current-item == i;
|
|
TouchArea {
|
|
clicked => { current-item = i; }
|
|
has-hover <=> parent.has-hover;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
export ComboBox := NativeComboBox {
|
|
property <[string]> model;
|
|
property <int> current-index : -1;
|
|
enabled: true;
|
|
open-popup => { popup.show(); }
|
|
callback selected(string);
|
|
|
|
popup := PopupWindow {
|
|
Rectangle { background: NativeStyleMetrics.window-background; }
|
|
NativeComboBoxPopup {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
y: root.height;
|
|
width: root.width;
|
|
VerticalLayout {
|
|
spacing: 0px;
|
|
for value[i] in root.model: NativeStandardListViewItem {
|
|
item: { text: value };
|
|
is-selected: current-index == i;
|
|
TouchArea {
|
|
has-hover <=> parent.has-hover;
|
|
clicked => {
|
|
if (root.enabled) {
|
|
current-index = i;
|
|
current-value = value;
|
|
selected(current-value);
|
|
}
|
|
//is-open = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export TabWidgetImpl := NativeTabWidget {
|
|
property <int> current-index;
|
|
}
|
|
export TabImpl := NativeTab {}
|
|
export TabBarImpl := HorizontalLayout {
|
|
alignment: start;
|
|
}
|
|
export TabWidget := TabWidget {}
|
|
|
|
export VerticalBox := VerticalLayout {
|
|
spacing: NativeStyleMetrics.layout-spacing;
|
|
padding: NativeStyleMetrics.layout-spacing;
|
|
}
|
|
export HorizontalBox := HorizontalLayout {
|
|
spacing: NativeStyleMetrics.layout-spacing;
|
|
padding: NativeStyleMetrics.layout-spacing;
|
|
}
|
|
export GridBox := GridLayout {
|
|
spacing: NativeStyleMetrics.layout-spacing;
|
|
padding: NativeStyleMetrics.layout-spacing;
|
|
}
|