mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-02 21:03:00 +00:00
Builtin elements: use the input output syntax
This commit is contained in:
parent
63cd49fb46
commit
8dbe745fc4
5 changed files with 342 additions and 329 deletions
|
|
@ -16,73 +16,72 @@
|
|||
|
||||
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.
|
||||
Or they can have a binding `native_output` which mean that the property can be modified
|
||||
by the native Item. If they don't have that, it is assumed the native item don't write
|
||||
to that property.
|
||||
`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 := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
//-is_internal
|
||||
|
||||
}
|
||||
|
||||
Rectangle := Empty {
|
||||
property <brush> background;
|
||||
property <brush> color <=> background;
|
||||
input property <brush> background;
|
||||
input property <brush> color <=> background;
|
||||
}
|
||||
|
||||
BorderRectangle := Rectangle {
|
||||
property <length> border-width;
|
||||
property <length> border-radius;
|
||||
property <brush> border-color;
|
||||
input property <length> border-width;
|
||||
input property <length> border-radius;
|
||||
input property <brush> border-color;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
}
|
||||
|
||||
export { BorderRectangle as Rectangle }
|
||||
|
||||
ImageItem := Empty {
|
||||
property <image> source;
|
||||
property <ImageFit> image-fit;
|
||||
property <ImageRendering> image-rendering;
|
||||
input property <image> source;
|
||||
input property <ImageFit> image-fit;
|
||||
input property <ImageRendering> image-rendering;
|
||||
}
|
||||
|
||||
export ClippedImage := ImageItem {
|
||||
property <int> source-clip-x;
|
||||
property <int> source-clip-y;
|
||||
property <int> source-clip-width;
|
||||
property <int> source-clip-height;
|
||||
property <brush> colorize;
|
||||
input property <int> source-clip-x;
|
||||
input property <int> source-clip-y;
|
||||
input property <int> source-clip-width;
|
||||
input property <int> source-clip-height;
|
||||
input property <brush> colorize;
|
||||
//-default_size_binding:implicit_size
|
||||
}
|
||||
|
||||
export { ClippedImage as Image }
|
||||
|
||||
export Rotate := Empty {
|
||||
property <angle> rotation-angle;
|
||||
property <length> rotation-origin-x;
|
||||
property <length> rotation-origin-y;
|
||||
input property <angle> rotation-angle;
|
||||
input property <length> rotation-origin-x;
|
||||
input property <length> rotation-origin-y;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export Text := Empty {
|
||||
property <string> text;
|
||||
property <string> font-family;
|
||||
property <length> font-size;
|
||||
property <int> font-weight;
|
||||
property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
|
||||
property <TextHorizontalAlignment> horizontal-alignment;
|
||||
property <TextVerticalAlignment> vertical-alignment;
|
||||
property <TextOverflow> overflow;
|
||||
property <TextWrap> wrap;
|
||||
property <length> letter-spacing;
|
||||
input property <string> text;
|
||||
input property <string> font-family;
|
||||
input property <length> font-size;
|
||||
input property <int> font-weight;
|
||||
input property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
|
||||
input property <TextHorizontalAlignment> horizontal-alignment;
|
||||
input property <TextVerticalAlignment> vertical-alignment;
|
||||
input property <TextOverflow> overflow;
|
||||
input property <TextWrap> wrap;
|
||||
input property <length> letter-spacing;
|
||||
//-default_size_binding:implicit_size
|
||||
}
|
||||
|
||||
|
|
@ -94,18 +93,18 @@ export struct PointerEvent := {
|
|||
}
|
||||
|
||||
export TouchArea := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <bool> enabled: true;
|
||||
property <bool> pressed: native_output;
|
||||
property <bool> has_hover: native_output;
|
||||
property <length> mouse_x: native_output;
|
||||
property <length> mouse_y: native_output;
|
||||
property <length> pressed_x: native_output;
|
||||
property <length> pressed_y: native_output;
|
||||
property <MouseCursor> mouse-cursor;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <bool> enabled: true;
|
||||
output property <bool> pressed;
|
||||
output property <bool> has_hover;
|
||||
output property <length> mouse_x;
|
||||
output property <length> mouse_y;
|
||||
output property <length> pressed_x;
|
||||
output property <length> pressed_y;
|
||||
input property <MouseCursor> mouse-cursor;
|
||||
callback clicked;
|
||||
callback moved;
|
||||
callback pointer-event(PointerEvent);
|
||||
|
|
@ -127,12 +126,12 @@ export struct KeyEvent := {
|
|||
}
|
||||
|
||||
export FocusScope := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <bool> enabled: true;
|
||||
property <bool> has-focus: native_output;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <bool> enabled: true;
|
||||
output property <bool> has-focus;
|
||||
callback key_pressed(KeyEvent) -> EventResult;
|
||||
callback key_released(KeyEvent) -> EventResult;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
|
|
@ -142,35 +141,35 @@ export FocusScope := _ {
|
|||
export Flickable := Empty {
|
||||
// These properties are actually going to be forwarded to the viewport by the
|
||||
// code generator
|
||||
property <length> viewport-height;
|
||||
property <length> viewport-width;
|
||||
property <length> viewport-x: native_output;
|
||||
property <length> viewport-y: native_output;
|
||||
property <bool> interactive: true;
|
||||
input property <length> viewport-height;
|
||||
input property <length> viewport-width;
|
||||
input output property <length> viewport-x;
|
||||
input output property <length> viewport-y;
|
||||
input property <bool> interactive: true;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
}
|
||||
|
||||
WindowItem := _ {
|
||||
property <length> width: native_output;
|
||||
property <length> height: native_output;
|
||||
property <brush> background; // StyleMetrics.window_background set in apply_default_properties_from_style
|
||||
property <brush> color <=> background;
|
||||
property <string> title: "Slint Window";
|
||||
property <bool> no-frame;
|
||||
property <string> default-font-family;
|
||||
property <length> default-font-size;
|
||||
property <int> default-font-weight;
|
||||
property <image> icon;
|
||||
input output property <length> width;
|
||||
input output property <length> height;
|
||||
input property <brush> background; // StyleMetrics.window_background set in apply_default_properties_from_style
|
||||
input property <brush> color <=> background;
|
||||
input property <string> title: "Slint Window";
|
||||
input property <bool> no-frame;
|
||||
input property <string> default-font-family;
|
||||
input property <length> default-font-size;
|
||||
input property <int> default-font-weight;
|
||||
input property <image> icon;
|
||||
}
|
||||
|
||||
export Window := WindowItem {}
|
||||
|
||||
export BoxShadow := Empty {
|
||||
property <length> border_radius;
|
||||
property <length> offset_x;
|
||||
property <length> offset_y;
|
||||
property <color> color;
|
||||
property <length> blur;
|
||||
input property <length> border_radius;
|
||||
input property <length> offset_x;
|
||||
input property <length> offset_y;
|
||||
input property <color> color;
|
||||
input property <length> blur;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
//-is_internal
|
||||
}
|
||||
|
|
@ -182,63 +181,63 @@ export struct Point := {
|
|||
}
|
||||
|
||||
export TextInput := _ {
|
||||
property <string> text: native_output;
|
||||
property <string> font-family;
|
||||
property <length> font-size;
|
||||
property <int> font-weight;
|
||||
property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
|
||||
property <color> selection-foreground-color: #000;
|
||||
property <color> selection-background-color: #808080;
|
||||
property <TextHorizontalAlignment> horizontal-alignment;
|
||||
property <TextVerticalAlignment> vertical-alignment;
|
||||
property <TextWrap> wrap;
|
||||
property <length> letter-spacing;
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <length> text-cursor-width; // StyleMetrics.text-cursor-width set in apply_default_properties_from_style
|
||||
property <InputType> input-type;
|
||||
input output property <string> text;
|
||||
input property <string> font-family;
|
||||
input property <length> font-size;
|
||||
input property <int> font-weight;
|
||||
input property <brush> color; // StyleMetrics.default-text-color set in apply_default_properties_from_style
|
||||
input property <color> selection-foreground-color: #000;
|
||||
input property <color> selection-background-color: #808080;
|
||||
input property <TextHorizontalAlignment> horizontal-alignment;
|
||||
input property <TextVerticalAlignment> vertical-alignment;
|
||||
input property <TextWrap> wrap;
|
||||
input property <length> letter-spacing;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <length> text-cursor-width; // StyleMetrics.text-cursor-width set in apply_default_properties_from_style
|
||||
input property <InputType> input-type;
|
||||
// Internal, undocumented property, only exposed for tests.
|
||||
property <int> cursor-position_byte-offset: native_output;
|
||||
output property <int> cursor-position_byte-offset;
|
||||
// Internal, undocumented property, only exposed for tests.
|
||||
property <int> anchor-position-byte-offset: native_output;
|
||||
property <bool> has-focus: native_output;
|
||||
output property <int> anchor-position-byte-offset;
|
||||
output property <bool> has-focus;
|
||||
callback accepted;
|
||||
callback edited;
|
||||
callback cursor_position_changed(Point);
|
||||
property <bool> enabled: true;
|
||||
property <bool> single-line: true;
|
||||
property <bool> read-only: false;
|
||||
property <string> preedit-text: native_output;
|
||||
input property <bool> enabled: true;
|
||||
input property <bool> single-line: true;
|
||||
input property <bool> read-only: false;
|
||||
output property <string> preedit-text;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
//-accepts_focus
|
||||
}
|
||||
|
||||
export Clip := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <length> border-radius;
|
||||
property <length> border-width;
|
||||
property <bool> clip;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <length> border-radius;
|
||||
input property <length> border-width;
|
||||
input property <bool> clip;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export Opacity := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <float> opacity: 1;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <float> opacity: 1;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export Layer := Empty {
|
||||
property <bool> cache-rendering-hint;
|
||||
input property <bool> cache-rendering-hint;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
//-is_internal
|
||||
}
|
||||
|
|
@ -249,25 +248,25 @@ Row := _ {
|
|||
|
||||
// Note: layouts are not NativeClass, but this is lowered in lower_layout
|
||||
export GridLayout := _ {
|
||||
property <length> spacing;
|
||||
input property <length> spacing;
|
||||
|
||||
// Additional accepted child
|
||||
Row { }
|
||||
}
|
||||
|
||||
export VerticalLayout := _ {
|
||||
property <length> spacing;
|
||||
property <LayoutAlignment> alignment;
|
||||
input property <length> spacing;
|
||||
input property <LayoutAlignment> alignment;
|
||||
}
|
||||
|
||||
export HorizontalLayout := _ {
|
||||
property <length> spacing;
|
||||
property <LayoutAlignment> alignment;
|
||||
input property <length> spacing;
|
||||
input property <LayoutAlignment> alignment;
|
||||
}
|
||||
|
||||
MoveTo := _ {
|
||||
property <float> x;
|
||||
property <float> y;
|
||||
input property <float> x;
|
||||
input property <float> y;
|
||||
|
||||
//-rust_type_constructor:slint::re_exports::PathElement::MoveTo(PathMoveTo{{}})
|
||||
//-cpp_type:slint::private_api::PathMoveTo
|
||||
|
|
@ -275,8 +274,8 @@ MoveTo := _ {
|
|||
}
|
||||
|
||||
LineTo := _ {
|
||||
property <float> x;
|
||||
property <float> y;
|
||||
input property <float> x;
|
||||
input property <float> y;
|
||||
|
||||
//-rust_type_constructor:slint::re_exports::PathElement::LineTo(PathLineTo{{}})
|
||||
//-cpp_type:slint::private_api::PathLineTo
|
||||
|
|
@ -284,13 +283,13 @@ LineTo := _ {
|
|||
}
|
||||
|
||||
ArcTo := _ {
|
||||
property <float> x;
|
||||
property <float> y;
|
||||
property <float> radius-x;
|
||||
property <float> radius-y;
|
||||
property <float> x-rotation;
|
||||
property <bool> large_arc;
|
||||
property <bool> sweep;
|
||||
input property <float> x;
|
||||
input property <float> y;
|
||||
input property <float> radius-x;
|
||||
input property <float> radius-y;
|
||||
input property <float> x-rotation;
|
||||
input property <bool> large_arc;
|
||||
input property <bool> sweep;
|
||||
|
||||
//-rust_type_constructor:slint::re_exports::PathElement::ArcTo(PathArcTo{{}})
|
||||
//-cpp_type:slint::private_api::PathArcTo
|
||||
|
|
@ -298,12 +297,12 @@ ArcTo := _ {
|
|||
}
|
||||
|
||||
CubicTo := _ {
|
||||
property <float> control-1-x;
|
||||
property <float> control-1-y;
|
||||
property <float> control-2-x;
|
||||
property <float> control-2-y;
|
||||
property <float> x;
|
||||
property <float> y;
|
||||
input property <float> control-1-x;
|
||||
input property <float> control-1-y;
|
||||
input property <float> control-2-x;
|
||||
input property <float> control-2-y;
|
||||
input property <float> x;
|
||||
input property <float> y;
|
||||
|
||||
//-rust_type_constructor:slint::re_exports::PathElement::CubicTo(PathCubicTo{{}})
|
||||
//-cpp_type:slint::private_api::PathCubicTo
|
||||
|
|
@ -311,10 +310,10 @@ CubicTo := _ {
|
|||
}
|
||||
|
||||
QuadraticTo := _ {
|
||||
property <float> control-x;
|
||||
property <float> control-y;
|
||||
property <float> x;
|
||||
property <float> y;
|
||||
input property <float> control-x;
|
||||
input property <float> control-y;
|
||||
input property <float> x;
|
||||
input property <float> y;
|
||||
|
||||
//-rust_type_constructor:slint::re_exports::PathElement::QuadraticTo(PathQuadraticTo{{}})
|
||||
//-cpp_type:slint::private_api::PathQuadraticTo
|
||||
|
|
@ -329,20 +328,20 @@ Close := _ {
|
|||
}
|
||||
|
||||
export Path := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <brush> fill;
|
||||
property <FillRule> fill-rule;
|
||||
property <brush> stroke;
|
||||
property <length> stroke-width;
|
||||
property <string> commands;
|
||||
property <float> viewbox-x;
|
||||
property <float> viewbox-y;
|
||||
property <float> viewbox-width;
|
||||
property <float> viewbox-height;
|
||||
property <bool> clip;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <brush> fill;
|
||||
input property <FillRule> fill-rule;
|
||||
input property <brush> stroke;
|
||||
input property <length> stroke-width;
|
||||
input property <string> commands;
|
||||
input property <float> viewbox-x;
|
||||
input property <float> viewbox-y;
|
||||
input property <float> viewbox-width;
|
||||
input property <float> viewbox-height;
|
||||
input property <bool> clip;
|
||||
|
||||
//-disallow_global_types_as_child_elements
|
||||
MoveTo {}
|
||||
|
|
@ -356,12 +355,12 @@ export Path := _ {
|
|||
}
|
||||
|
||||
export PathLayout := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <string> commands;
|
||||
property <float> offset;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <string> commands;
|
||||
input property <float> offset;
|
||||
|
||||
MoveTo {}
|
||||
LineTo {}
|
||||
|
|
@ -372,18 +371,18 @@ export PathLayout := _ {
|
|||
}
|
||||
|
||||
Tab := _ {
|
||||
property <string> title;
|
||||
input property <string> title;
|
||||
}
|
||||
|
||||
// Note: not a native class, handled in the lower_tabs pass
|
||||
export TabWidget := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
|
||||
property <int> current-index;
|
||||
property <int> current-focused;
|
||||
input property <int> current-index;
|
||||
input property <int> current-focused;
|
||||
|
||||
//-disallow_global_types_as_child_elements
|
||||
Tab {}
|
||||
|
|
@ -395,22 +394,22 @@ export TabWidget := _ {
|
|||
export PopupWindow := _ {
|
||||
//property <length> x;
|
||||
//property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
/*property <length> anchor_x;
|
||||
property <length> anchor_y;
|
||||
property <length> anchor_height;
|
||||
property <length> anchor_width;*/
|
||||
input property <length> anchor_y;
|
||||
input property <length> anchor_height;
|
||||
input property <length> anchor_width;*/
|
||||
//show() is hardcoded in typeregister.rs
|
||||
}
|
||||
|
||||
export Dialog := WindowItem {}
|
||||
|
||||
PropertyAnimation := _ {
|
||||
property <duration> delay;
|
||||
property <duration> duration;
|
||||
property <easing> easing;
|
||||
property <float> iteration-count: 1.0;
|
||||
input property <duration> delay;
|
||||
input property <duration> duration;
|
||||
input property <easing> easing;
|
||||
input property <float> iteration-count: 1.0;
|
||||
//-is_non_item_type
|
||||
}
|
||||
|
||||
|
|
@ -428,205 +427,205 @@ export struct StateInfo := {
|
|||
}
|
||||
|
||||
export NativeButton := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <string> text;
|
||||
property <image> icon;
|
||||
property <bool> pressed: native_output;
|
||||
property <bool> checkable;
|
||||
property <bool> checked: native_output;
|
||||
property <bool> has-focus: native_output;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <string> text;
|
||||
input property <image> icon;
|
||||
output property <bool> pressed;
|
||||
input property <bool> checkable;
|
||||
input output property <bool> checked;
|
||||
output property <bool> has-focus;
|
||||
callback clicked;
|
||||
property <bool> enabled: true;
|
||||
property <StandardButtonKind> standard-button-kind;
|
||||
property <bool> is-standard-button;
|
||||
input property <bool> enabled: true;
|
||||
input property <StandardButtonKind> standard-button-kind;
|
||||
input property <bool> is-standard-button;
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeCheckBox := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <bool> enabled: true;
|
||||
property <string> text;
|
||||
property <bool> checked: native_output;
|
||||
property <bool> has-focus: native_output;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <bool> enabled: true;
|
||||
input property <string> text;
|
||||
input output property <bool> checked;
|
||||
output property <bool> has-focus;
|
||||
callback toggled;
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeSpinBox := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <bool> enabled: true;
|
||||
property <bool> has-focus: native_output;
|
||||
property <int> value: native_output;
|
||||
property <int> minimum;
|
||||
property <int> maximum: 100;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <bool> enabled: true;
|
||||
output property <bool> has-focus;
|
||||
input output property <int> value;
|
||||
input property <int> minimum;
|
||||
input property <int> maximum: 100;
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeSlider := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <bool> enabled: true;
|
||||
property <float> value: native_output;
|
||||
property <float> minimum;
|
||||
property <float> maximum: 100;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <bool> enabled: true;
|
||||
input output property <float> value;
|
||||
input property <float> minimum;
|
||||
input property <float> maximum: 100;
|
||||
callback changed(float);
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeGroupBox := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <bool> enabled: true;
|
||||
property <string> title;
|
||||
property <length> native-padding-left: native_output;
|
||||
property <length> native-padding-right: native_output;
|
||||
property <length> native-padding-top: native_output;
|
||||
property <length> native-padding-bottom: native_output;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <bool> enabled: true;
|
||||
input property <string> title;
|
||||
output property <length> native-padding-left;
|
||||
output property <length> native-padding-right;
|
||||
output property <length> native-padding-top;
|
||||
output property <length> native-padding-bottom;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeLineEdit := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <length> native-padding-left: native_output;
|
||||
property <length> native-padding-right: native_output;
|
||||
property <length> native-padding-top: native_output;
|
||||
property <length> native-padding-bottom: native_output;
|
||||
property <bool> has-focus;
|
||||
property <bool> enabled: true;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
output property <length> native-padding-left;
|
||||
output property <length> native-padding-right;
|
||||
output property <length> native-padding-top;
|
||||
output property <length> native-padding-bottom;
|
||||
input property <bool> has-focus;
|
||||
input property <bool> enabled: true;
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeScrollView := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <length> horizontal-max;
|
||||
property <length> horizontal-page-size;
|
||||
property <length> horizontal-value;
|
||||
property <length> vertical-max;
|
||||
property <length> vertical-page-size;
|
||||
property <length> vertical-value: native_output;
|
||||
property <length> native-padding-left: native_output;
|
||||
property <length> native-padding-right: native_output;
|
||||
property <length> native-padding-top: native_output;
|
||||
property <length> native-padding-bottom: native_output;
|
||||
property <bool> has_focus: native_output;
|
||||
property <bool> enabled: true;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <length> horizontal-max;
|
||||
input property <length> horizontal-page-size;
|
||||
input property <length> horizontal-value;
|
||||
input property <length> vertical-max;
|
||||
input property <length> vertical-page-size;
|
||||
input output property <length> vertical-value;
|
||||
output property <length> native-padding-left;
|
||||
output property <length> native-padding-right;
|
||||
output property <length> native-padding-top;
|
||||
output property <length> native-padding-bottom;
|
||||
input property <bool> has_focus;
|
||||
input property <bool> enabled: true;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeStandardListViewItem := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <int> index;
|
||||
property <StandardListViewItem> item;
|
||||
property <bool> is_selected: native_output;
|
||||
property <bool> has_hover;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <int> index;
|
||||
input property <StandardListViewItem> item;
|
||||
input output property <bool> is_selected;
|
||||
input property <bool> has_hover;
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeComboBox := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
property <string> current_value;
|
||||
property <bool> is_open: native_output;
|
||||
property <bool> enabled: true;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
input property <string> current_value;
|
||||
input output property <bool> is_open;
|
||||
input property <bool> enabled: true;
|
||||
callback open_popup;
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeComboBoxPopup := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeTabWidget := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
|
||||
property <length> content-x: native_output;
|
||||
property <length> content-y: native_output;
|
||||
property <length> content-height: native_output;
|
||||
property <length> content-width: native_output;
|
||||
property <length> tabbar-x: native_output;
|
||||
property <length> tabbar-y: native_output;
|
||||
property <length> tabbar-height: native_output;
|
||||
property <length> tabbar-width: native_output;
|
||||
property <length> tabbar-preferred-height;
|
||||
property <length> tabbar-preferred-width;
|
||||
property <length> content-min-height;
|
||||
property <length> content-min-width;
|
||||
output property <length> content-x;
|
||||
output property <length> content-y;
|
||||
output property <length> content-height;
|
||||
output property <length> content-width;
|
||||
output property <length> tabbar-x;
|
||||
output property <length> tabbar-y;
|
||||
output property <length> tabbar-height;
|
||||
output property <length> tabbar-width;
|
||||
input property <length> tabbar-preferred-height;
|
||||
input property <length> tabbar-preferred-width;
|
||||
input property <length> content-min-height;
|
||||
input property <length> content-min-width;
|
||||
|
||||
property <int> current-index;
|
||||
property <int> current-focused;
|
||||
input property <int> current-index;
|
||||
input property <int> current-focused;
|
||||
//-default_size_binding:expands_to_parent_geometry
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export NativeTab := _ {
|
||||
property <length> x;
|
||||
property <length> y;
|
||||
property <length> width;
|
||||
property <length> height;
|
||||
input property <length> x;
|
||||
input property <length> y;
|
||||
input property <length> width;
|
||||
input property <length> height;
|
||||
|
||||
property<string> title;
|
||||
property<image> icon;
|
||||
property<bool> enabled : true;
|
||||
property<bool> pressed : native_output;
|
||||
property<int> current: native_output; // supposed to be a binding to the tab
|
||||
property<int> tab-index;
|
||||
property<int> current-focused;
|
||||
property<int> num-tabs;
|
||||
input property<string> title;
|
||||
input property<image> icon;
|
||||
input property<bool> enabled : true;
|
||||
output property<bool> pressed;
|
||||
output property<int> current; // supposed to be a binding to the tab
|
||||
input property<int> tab-index;
|
||||
input property<int> current-focused;
|
||||
input property<int> num-tabs;
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
export global NativeStyleMetrics := {
|
||||
property <length> layout-spacing : native_output;
|
||||
property <length> layout-padding : native_output;
|
||||
property <length> text-cursor-width : native_output;
|
||||
property <color> window-background : native_output;
|
||||
property <color> default-text-color : native_output;
|
||||
property <color> textedit-background : native_output;
|
||||
property <color> textedit-text-color : native_output;
|
||||
property <color> textedit-background-disabled : native_output;
|
||||
property <color> textedit-text-color-disabled : native_output;
|
||||
output property <length> layout-spacing;
|
||||
output property <length> layout-padding;
|
||||
output property <length> text-cursor-width;
|
||||
output property <color> window-background;
|
||||
output property <color> default-text-color;
|
||||
output property <color> textedit-background;
|
||||
output property <color> textedit-text-color;
|
||||
output property <color> textedit-background-disabled;
|
||||
output property <color> textedit-text-color-disabled;
|
||||
|
||||
property <bool> dark-color-scheme : native_output;
|
||||
output property <bool> dark-color-scheme;
|
||||
|
||||
// specific to the Native one
|
||||
property <color> placeholder-color : native_output;
|
||||
property <color> placeholder-color-disabled : native_output;
|
||||
output property <color> placeholder-color;
|
||||
output property <color> placeholder-color-disabled;
|
||||
|
||||
// Tab Bar metrics:
|
||||
property <LayoutAlignment> tab-bar-alignment : native_output;
|
||||
output property <LayoutAlignment> tab-bar-alignment;
|
||||
|
||||
//-is_non_item_type
|
||||
//-is_internal
|
||||
|
|
|
|||
|
|
@ -341,16 +341,16 @@ pub struct BuiltinPropertyInfo {
|
|||
pub ty: Type,
|
||||
/// When set, this is the initial value that we will have to set if no other binding were specified
|
||||
pub default_value: Option<Expression>,
|
||||
/// Most properties are just set from the .slint code and never modified by the native code.
|
||||
/// But some properties, such as `TouchArea::pressed` are being set by the native code, these
|
||||
/// are output properties which are meant to be read by the .slint.
|
||||
/// `is_native_output` is true if the native item can modify the property.
|
||||
pub is_native_output: bool,
|
||||
pub property_visibility: PropertyVisibility,
|
||||
}
|
||||
|
||||
impl BuiltinPropertyInfo {
|
||||
pub fn new(ty: Type) -> Self {
|
||||
Self { ty, default_value: None, is_native_output: false }
|
||||
Self { ty, default_value: None, property_visibility: PropertyVisibility::Private }
|
||||
}
|
||||
|
||||
pub fn is_native_output(&self) -> bool {
|
||||
matches!(self.property_visibility, PropertyVisibility::InOut | PropertyVisibility::Output)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ fn get_property_analysis(elem: &ElementRc, p: &str) -> crate::object_tree::Prope
|
|||
let base = elem.borrow().base_type.clone();
|
||||
match base {
|
||||
ElementType::Native(n) => {
|
||||
if n.properties.get(p).map_or(false, |p| p.is_native_output) {
|
||||
if n.properties.get(p).map_or(false, |p| p.is_native_output()) {
|
||||
a.is_set = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use crate::typeregister::TypeRegister;
|
|||
pub fn load_builtins(register: &mut TypeRegister) {
|
||||
let mut diag = crate::diagnostics::BuildDiagnostics::default();
|
||||
let node = crate::parser::parse(include_str!("builtins.slint").into(), None, &mut diag);
|
||||
if !diag.is_empty() {
|
||||
if !diag.is_empty() && crate::parser::enable_experimental() {
|
||||
let vec = diag.to_string_vec();
|
||||
#[cfg(feature = "display-diagnostics")]
|
||||
diag.print();
|
||||
|
|
@ -78,26 +78,40 @@ pub fn load_builtins(register: &mut TypeRegister) {
|
|||
e.PropertyDeclaration()
|
||||
.filter(|p| p.TwoWayBinding().is_none()) // aliases are handled further down
|
||||
.map(|p| {
|
||||
let prop_name = identifier_text(&p.DeclaredIdentifier()).unwrap();
|
||||
|
||||
let mut info = BuiltinPropertyInfo::new(object_tree::type_from_node(
|
||||
p.Type().unwrap(),
|
||||
*diag.borrow_mut(),
|
||||
register,
|
||||
));
|
||||
|
||||
for token in p.children_with_tokens() {
|
||||
if token.kind() != SyntaxKind::Identifier {
|
||||
continue;
|
||||
}
|
||||
match (token.as_token().unwrap().text(), info.property_visibility) {
|
||||
("input", PropertyVisibility::Private) => {
|
||||
info.property_visibility = PropertyVisibility::Input
|
||||
}
|
||||
("output", PropertyVisibility::Private) => {
|
||||
info.property_visibility = PropertyVisibility::Output
|
||||
}
|
||||
("input", PropertyVisibility::Output)
|
||||
| ("output", PropertyVisibility::Input) => {
|
||||
info.property_visibility = PropertyVisibility::InOut
|
||||
}
|
||||
("property", _) => (),
|
||||
_ => unreachable!("invalid property keyword when parsing builtin file for property {id}::{prop_name}"),
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(e) = p.BindingExpression() {
|
||||
if e.Expression()
|
||||
.and_then(|e| e.QualifiedName())
|
||||
.and_then(|q| q.child_text(SyntaxKind::Identifier))
|
||||
.map(|s| s == "native_output")
|
||||
== Some(true)
|
||||
{
|
||||
info.is_native_output = true;
|
||||
} else {
|
||||
let ty = info.ty.clone();
|
||||
info.default_value = Some(compiled(e, register, ty));
|
||||
}
|
||||
}
|
||||
(identifier_text(&p.DeclaredIdentifier()).unwrap(), info)
|
||||
|
||||
(prop_name, info)
|
||||
})
|
||||
.chain(e.CallbackDeclaration().map(|s| {
|
||||
(
|
||||
|
|
@ -211,7 +225,7 @@ pub fn load_builtins(register: &mut TypeRegister) {
|
|||
|
||||
register.empty_type = ElementType::Builtin(natives.remove("Empty").unwrap());
|
||||
|
||||
if !diag.is_empty() {
|
||||
if !diag.is_empty() && crate::parser::enable_experimental() {
|
||||
let vec = diag.to_string_vec();
|
||||
#[cfg(feature = "display-diagnostics")]
|
||||
diag.print();
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ impl NamedReference {
|
|||
continue;
|
||||
}
|
||||
ElementType::Builtin(b) => {
|
||||
return b.properties.get(self.name()).map_or(true, |pi| !pi.is_native_output)
|
||||
return b.properties.get(self.name()).map_or(true, |pi| !pi.is_native_output())
|
||||
}
|
||||
ElementType::Native(n) => {
|
||||
return n.properties.get(self.name()).map_or(true, |pi| !pi.is_native_output)
|
||||
return n.properties.get(self.name()).map_or(true, |pi| !pi.is_native_output())
|
||||
}
|
||||
crate::langtype::ElementType::Error | crate::langtype::ElementType::Global => {
|
||||
return true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue