// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
// cSpell: ignore langtype typeregister
/**
This file contains the definition off all builtin items
It is parsed with the normal .slint parser, but the semantic.
`_` means that that this is a langtype::NativeClass with no parent.
Exported components are added to the as BuiltinElement.
comments starting by `//-` have some meanings
Properties with two way bindings (aliases) are deprecated in favor of the property they point to
Properties can have default binding which must be an expression without any reference to
another properties. These binding will be then set by the compiler.
`output` property mean that the property can be modified by the native Item,
otherwise it is assumed the native item don't write to that property.
*/
import { _ } from ""; // just to silence many errors in the LSP
Empty := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
Rectangle := Empty {
in property <brush> background;
in property <brush> color <=> background;
}
BorderRectangle := Rectangle {
in property <length> border-width;
in property <length> border-radius;
in property <brush> border-color;
//-default_size_binding:expands_to_parent_geometry
}
export { BorderRectangle as Rectangle }
ImageItem := Empty {
in property <image> source;
in property <ImageFit> image-fit;
in property <ImageRendering> image-rendering;
in property <brush> colorize;
}
export ClippedImage := ImageItem {
in property <int> source-clip-x;
in property <int> source-clip-y;
in property <int> source-clip-width;
in property <int> source-clip-height;
//-default_size_binding:implicit_size
}
export { ClippedImage as Image }
export Rotate := Empty {
in property <angle> rotation-angle;
in property <length> rotation-origin-x;
in property <length> rotation-origin-y;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export Text := Empty {
in property <string> text;
in property <string> font-family;
in property <length> font-size;
in property <int> font-weight;
in property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
in property <TextHorizontalAlignment> horizontal-alignment;
in property <TextVerticalAlignment> vertical-alignment;
in property <TextOverflow> overflow;
in property <TextWrap> wrap;
in property <length> letter-spacing;
//-default_size_binding:implicit_size
}
export struct PointerEvent := {
//-name:slint::private_api::PointerEvent
button: PointerEventButton,
kind: PointerEventKind,
}
export TouchArea := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
out property <bool> pressed;
out property <bool> has_hover;
out property <length> mouse_x;
out property <length> mouse_y;
out property <length> pressed_x;
out property <length> pressed_y;
in property <MouseCursor> mouse-cursor;
callback clicked;
callback moved;
callback pointer-event(PointerEvent);
//-default_size_binding:expands_to_parent_geometry
}
export struct KeyboardModifiers := {
//-name:slint::private_api::KeyboardModifiers
alt: bool,
control: bool,
shift: bool,
meta: bool,
}
export struct KeyEvent := {
//-name:slint::private_api::KeyEvent
text: string,
modifiers: KeyboardModifiers,
}
export FocusScope := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
out property <bool> has-focus;
callback key_pressed(KeyEvent) -> EventResult;
callback key_released(KeyEvent) -> EventResult;
//-default_size_binding:expands_to_parent_geometry
//-accepts_focus
}
export Flickable := Empty {
// These properties are actually going to be forwarded to the viewport by the
// code generator
in property <length> viewport-height;
in property <length> viewport-width;
in-out property <length> viewport-x;
in-out property <length> viewport-y;
in property <bool> interactive: true;
//-default_size_binding:expands_to_parent_geometry
}
WindowItem := _ {
in-out property <length> width;
in-out property <length> height;
in property <brush> background; // StyleMetrics.window_background set in apply_default_properties_from_style
in property <brush> color <=> background;
in property <string> title: "Slint Window";
in property <bool> no-frame;
in property <string> default-font-family;
in-out property <length> default-font-size; // <=> StyleMetrics.default-font-size set in apply_default_properties_from_style
in property <int> default-font-weight;
in property <image> icon;
}
export Window := WindowItem {}
export BoxShadow := Empty {
in property <length> border_radius;
in property <length> offset_x;
in property <length> offset_y;
in property <color> color;
in property <length> blur;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export struct Point := {
//-name:slint::private_api::Point
x: length,
y: length,
}
export TextInput := _ {
in-out property <string> text;
in property <string> font-family;
in property <length> font-size;
in property <int> font-weight;
in property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
in property <color> selection-foreground-color: #000;
in property <color> selection-background-color: #808080;
in property <TextHorizontalAlignment> horizontal-alignment;
in property <TextVerticalAlignment> vertical-alignment;
in property <TextWrap> wrap;
in property <length> letter-spacing;
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <length> text-cursor-width; // StyleMetrics.text-cursor-width set in apply_default_properties_from_style
in property <InputType> input-type;
// Internal, undocumented property, only exposed for tests.
out property <int> cursor-position_byte-offset;
// Internal, undocumented property, only exposed for tests.
out property <int> anchor-position-byte-offset;
out property <bool> has-focus;
callback accepted;
callback edited;
callback cursor_position_changed(Point);
in property <bool> enabled: true;
in property <bool> single-line: true;
in property <bool> read-only: false;
out property <string> preedit-text;
//-default_size_binding:expands_to_parent_geometry
//-accepts_focus
}
export Clip := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <length> border-radius;
in property <length> border-width;
in property <bool> clip;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export Opacity := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <float> opacity: 1;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export Layer := Empty {
in property <bool> cache-rendering-hint;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
Row := _ {
//-is_non_item_type
}
// Note: layouts are not NativeClass, but this is lowered in lower_layout
export GridLayout := _ {
in property <length> spacing;
// Additional accepted child
Row { }
}
export VerticalLayout := _ {
in property <length> spacing;
in property <LayoutAlignment> alignment;
}
export HorizontalLayout := _ {
in property <length> spacing;
in property <LayoutAlignment> alignment;
}
MoveTo := _ {
in property <float> x;
in property <float> y;
//-rust_type_constructor:slint::re_exports::PathElement::MoveTo(PathMoveTo{{}})
//-cpp_type:slint::private_api::PathMoveTo
//-is_non_item_type
}
LineTo := _ {
in property <float> x;
in property <float> y;
//-rust_type_constructor:slint::re_exports::PathElement::LineTo(PathLineTo{{}})
//-cpp_type:slint::private_api::PathLineTo
//-is_non_item_type
}
ArcTo := _ {
in property <float> x;
in property <float> y;
in property <float> radius-x;
in property <float> radius-y;
in property <float> x-rotation;
in property <bool> large_arc;
in property <bool> sweep;
//-rust_type_constructor:slint::re_exports::PathElement::ArcTo(PathArcTo{{}})
//-cpp_type:slint::private_api::PathArcTo
//-is_non_item_type
}
CubicTo := _ {
in property <float> control-1-x;
in property <float> control-1-y;
in property <float> control-2-x;
in property <float> control-2-y;
in property <float> x;
in property <float> y;
//-rust_type_constructor:slint::re_exports::PathElement::CubicTo(PathCubicTo{{}})
//-cpp_type:slint::private_api::PathCubicTo
//-is_non_item_type
}
QuadraticTo := _ {
in property <float> control-x;
in property <float> control-y;
in property <float> x;
in property <float> y;
//-rust_type_constructor:slint::re_exports::PathElement::QuadraticTo(PathQuadraticTo{{}})
//-cpp_type:slint::private_api::PathQuadraticTo
//-is_non_item_type
}
Close := _ {
//-rust_type_constructor:slint::re_exports::PathElement::Close
//-cpp_type:slint::private_api::PathClose
//-is_non_item_type
//-is_non_item_type
}
export Path := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <brush> fill;
in property <FillRule> fill-rule;
in property <brush> stroke;
in property <length> stroke-width;
in property <string> commands;
in property <float> viewbox-x;
in property <float> viewbox-y;
in property <float> viewbox-width;
in property <float> viewbox-height;
in property <bool> clip;
//-disallow_global_types_as_child_elements
MoveTo {}
LineTo {}
ArcTo {}
CubicTo {}
QuadraticTo {}
Close {}
//-default_size_binding:expands_to_parent_geometry
}
Tab := _ {
in property <string> title;
}
// Note: not a native class, handled in the lower_tabs pass
export TabWidget := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in-out property <int> current-index;
//-disallow_global_types_as_child_elements
Tab {}
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
// Note: not a native class, handled in the lower_popups pass
export PopupWindow := _ {
//property <length> x;
//property <length> y;
in property <length> width;
in property <length> height;
/*property <length> anchor_x;
in property <length> anchor_y;
in property <length> anchor_height;
in property <length> anchor_width;*/
//show() is hardcoded in typeregister.rs
}
export Dialog := WindowItem {}
PropertyAnimation := _ {
in property <duration> delay;
in property <duration> duration;
in property <easing> easing;
in property <float> iteration-count: 1.0;
//-is_non_item_type
}
export struct StandardListViewItem := {
//-name:slint::StandardListViewItem
text: string,
}
export struct TableColumn := {
//-name:slint::private_api::TableColumn
title: string,
min-width: length,
horizontal-stretch: float,
sort-order: SortOrder,
width: length,
}
export struct StateInfo := {
//-name:slint::private_api::StateInfo
current_state: int,
previous_state: int,
//change_time: duration,
//-is_internal
}
export NativeButton := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <string> text;
in property <image> icon;
out property <bool> pressed;
in property <bool> checkable;
in-out property <bool> checked;
out property <bool> has-focus;
callback clicked;
in property <bool> enabled: true;
in property <StandardButtonKind> standard-button-kind;
in property <bool> is-standard-button;
//-is_internal
}
export NativeCheckBox := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
in property <string> text;
in-out property <bool> checked;
out property <bool> has-focus;
callback toggled;
//-is_internal
}
export NativeSpinBox := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
out property <bool> has-focus;
in-out property <int> value;
in property <int> minimum;
in property <int> maximum: 100;
//-is_internal
}
export NativeSlider := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
in-out property <float> value;
in property <float> minimum;
in property <float> maximum: 100;
callback changed(float);
//-is_internal
}
export NativeGroupBox := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <bool> enabled: true;
in property <string> title;
out property <length> native-padding-left;
out property <length> native-padding-right;
out property <length> native-padding-top;
out property <length> native-padding-bottom;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export NativeLineEdit := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
out property <length> native-padding-left;
out property <length> native-padding-right;
out property <length> native-padding-top;
out property <length> native-padding-bottom;
in property <bool> has-focus;
in property <bool> enabled: true;
//-is_internal
}
export NativeScrollView := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <length> horizontal-max;
in property <length> horizontal-page-size;
in property <length> horizontal-value;
in property <length> vertical-max;
in property <length> vertical-page-size;
in-out property <length> vertical-value;
out property <length> native-padding-left;
out property <length> native-padding-right;
out property <length> native-padding-top;
out property <length> native-padding-bottom;
in property <bool> has_focus;
in property <bool> enabled: true;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export NativeStandardListViewItem := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <int> index;
in property <StandardListViewItem> item;
in-out property <bool> is_selected;
in property <bool> has_hover;
//-is_internal
}
export NativeTableHeaderSection := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property <int> index;
in property <TableColumn> item;
in property <bool> has_hover;
//-is_internal
}
export NativeComboBox := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in-out property <string> current_value;
in-out property <bool> is_open;
in property <bool> enabled: true;
callback open_popup;
//-is_internal
}
export NativeComboBoxPopup := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
//-is_internal
}
export NativeTabWidget := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
out property <length> content-x;
out property <length> content-y;
out property <length> content-height;
out property <length> content-width;
out property <length> tabbar-x;
out property <length> tabbar-y;
out property <length> tabbar-height;
out property <length> tabbar-width;
in property <length> tabbar-preferred-height;
in property <length> tabbar-preferred-width;
in property <length> content-min-height;
in property <length> content-min-width;
in property <int> current-index;
in property <int> current-focused;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
}
export NativeTab := _ {
in property <length> x;
in property <length> y;
in property <length> width;
in property <length> height;
in property<string> title;
in property<image> icon;
in property<bool> enabled : true;
in-out property<int> current; // supposed to be a binding to the tab
in property<int> tab-index;
in property<int> current-focused;
in property<int> num-tabs;
//-is_internal
}
export global NativeStyleMetrics := {
out property <length> layout-spacing;
out property <length> layout-padding;
out property <length> text-cursor-width;
out property <color> window-background;
out property <color> default-text-color;
out property <length> default-font-size;
out property <color> textedit-background;
out property <color> textedit-text-color;
out property <color> textedit-background-disabled;
out property <color> textedit-text-color-disabled;
out property <bool> dark-color-scheme;
// specific to the Native one
out property <color> placeholder-color;
out property <color> placeholder-color-disabled;
// Tab Bar metrics:
out property <LayoutAlignment> tab-bar-alignment;
//-is_non_item_type
//-is_internal
}