slint 1.3.2 官方文档翻译04

主要使用 有道翻译。希望能够对 初学者 有所帮助 

翻译自:Builtin Enumerations - Slint 1.3.2 Reference

Builtin Enumerations 内置的枚举

AccessibleRole 可访问角色

This enum represents the different values for the accessible-role property, used to describe the role of an element in the context of assistive technology such as screen readers.

此枚举表示accessible-role属性的不同值,用于描述辅助技术(如屏幕阅读器)上下文中元素的角色。

  • none: The element isn’t accessible.          none:元素不可访问。

  • button: The element is a Button or behaves like one.          button:该元素是button或行为类似于button。

  • checkbox: The element is a CheckBox or behaves like one.         checkbox:该元素是一个checkbox或其行为类似于checkbox。

  • combobox: The element is a ComboBox or behaves like one.          combobox:该元素是一个组合框或其行为类似于一个组合框。

  • slider: The element is a Slider or behaves like one.        slider:该元素是一个slider或其行为类似于slider。

  • spinbox: The element is a SpinBox or behaves like one.          spinbox:该元素是一个spinbox或其行为类似于spinbox。

  • tab: The element is a Tab or behaves like one.           tab:元素是一个tab或其行为类似于一个tab。

  • text: The role for a Text element. It’s automatically applied.          text: text元素的角色。它是自动应用的。

  • progress-indicator: The element is a ProgressIndicator or behaves like one.      progress-indicator 进度指示器:元素是一个ProgressIndicator或其行为类似于ProgressIndicator。

DialogButtonRole 对话框按钮角色

This enum represents the value of the dialog-button-role property which can be added to any element within a Dialog to put that item in the button row, and its exact position depends on the role and the platform.

这个enum表示Dialog -button-role属性的值,可以将该属性添加到Dialog中的任何元素中,以将该项放在按钮行中,它的确切位置取决于角色和平台。

  • none: This isn’t a button meant to go into the bottom row          none:这个按钮不应该放在最下面一排

  • accept: This is the role of the main button to click to accept the dialog. e.g. “Ok” or “Yes”         accept:这是单击接受对话框的主按钮的角色。“Ok”或“Yes”

  • reject: This is the role of the main button to click to reject the dialog. e.g. “Cancel” or “No”           reject:这是单击以拒绝对话框的主按钮的角色。“取消”或“不”

  • apply: This is the role of the “Apply” button       apply:这是“apply”按钮的角色

  • reset: This is the role of the “Reset” button        reset:这是“reset”按钮的作用

  • help: This is the role of the “Help” button            help:这是“帮助”按钮的作用

  • action: This is the role of any other button that performs another action.        action:这是执行其他操作的任何其他按钮的角色。

EventResult 事件结果

This enum describes whether an event was rejected or accepted by an event handler.

此枚举描述事件处理程序是拒绝了事件还是接受了事件。

  • reject: The event is rejected by this event handler and may then be handled by the parent item       reject 拒绝:事件被此事件处理程序拒绝,然后可能由父项处理

  • accept: The event is accepted and won’t be processed further       accept 接受:事件被接受,不会被进一步处理

FillRule 填充规则

This enum describes the different ways of deciding what the inside of a shape described by a path shall be.

此枚举描述了决定路径所描述的形状内部的不同方式。。

  • nonzero: The “nonzero” fill rule as defined in SVG.      nonzero:在SVG中定义的“非零”填充规则。

  • evenodd: The “evenodd” fill rule as defined in SVG       evenodd:在SVG中定义的“偶奇”填充规则

ImageFit 图像适配

This enum defines how the source image shall fit into an Image element.

这个enum定义了源图像如何适应image元素。

  • fill: Scales and stretches the source image to fit the width and height of the Image element.        fill:缩放和拉伸源图像以适应image元素的宽度和高度。

  • contain: The source image is scaled to fit into the Image element’s dimension while preserving the aspect ratio.       contains:源图像被缩放以适应image元素的尺寸,同时保留宽高比。

  • cover: The source image is scaled to cover into the Image element’s dimension while preserving the aspect ratio. If the aspect ratio of the source image doesn’t match the element’s one, then the image will be clipped to fit.     cover:源图像被缩放到覆盖到image元素的尺寸,同时保持长宽比。如果源图像的宽高比与元素的宽高比不匹配,则图像将被剪切以适应。

ImageRendering 图像渲染

This enum specifies how the source image will be scaled.

此enum指定源图像将如何缩放。

  • smooth: The image is scaled with a linear interpolation algorithm.       平滑:使用线性插值算法缩放图像。

  • pixelated: The image is scaled with the nearest neighbor algorithm.      pixelated:使用最近邻算法缩放图像。

InputType 输入类型

This enum is used to define the type of the input field.

此枚举用于定义输入域的类型。

  • text: The default value. This will render all characters normally       text:默认值。这将正常渲染所有字符

  • password: This will render all characters with a character that defaults to “*”       password:这将显示所有默认为“*”的字符。

  • number: This will only accept and render number characters (0-9)           number:这将只接受和呈现数字字符(0-9)

  • decimal: This will accept and render characters if it’s valid part of a decimal       decimal:decimal:如果字符是十进制的有效部分,它将接受并呈现字符

LayoutAlignment 布局对齐方式

Enum representing the alignment property of a HorizontalBox, a VerticalBox, a HorizontalLayout, or VerticalLayout.

枚举,表示HorizontalBox、VerticalBox、HorizontalLayout或VerticalLayout的对齐属性。

  • stretch: Use the minimum size of all elements in a layout, distribute remaining space based on *-stretch among all elements.          stretch:使用布局中所有元素的最小尺寸,根据*-stretch在所有元素之间分配剩余空间。

  • center: Use the preferred size for all elements,  distribute remaining space evenly before the first and after the last element.        center:所有元素使用首选大小,剩余空间均匀分布在第一个元素之前和最后一个元素之后。

  • start: Use the preferred size for all elements, put remaining space after the last element.         start:对所有元素使用首选的大小,将剩余的空间放在最后一个元素之后。

  • end: Use the preferred size for all elements, put remaining space before the first element.           end:对所有元素使用首选大小,将剩余空间放在第一个元素之前。

  • space-between: Use the preferred size for all elements, distribute remaining space evenly between elements.       space-between:所有元素使用首选大小,元素之间均匀分配剩余空间。

  • space-around: Use the preferred size for all elements, distribute remaining space evenly before the first element, after the last element and between elements.        space-around:对所有元素使用首选大小,在第一个元素之前、最后一个元素之后和元素之间均匀分配剩余空间。

MouseCursor 鼠标光标

This enum represents different types of mouse cursors. It’s a subset of the mouse cursors available in CSS. For details and pictograms see the MDN Documentation for cursor. Depending on the backend and used OS unidirectional resize cursors may be replaced with bidirectional ones.

此枚举表示不同类型的鼠标光标。它是CSS中可用的鼠标光标的子集。有关详细信息和象形图,请参阅光标的MDN文档。根据后端和使用的操作系统的不同,单向调整大小光标可能会被双向光标所取代。。

  • default: The systems default cursor.      default:系统默认光标。

  • none: No cursor is displayed.     none:不显示光标。

  • help: A cursor indicating help information.     help:表示帮助信息的光标。

  • pointer: A pointing hand indicating a link.    指针:指示链接的指针。

  • progress: The program is busy but can still be interacted with.     progress:程序很忙,但仍然可以进行交互。

  • wait: The program is busy.      等待:程序正忙。

  • crosshair: A crosshair.      准星:准星。

  • text: A cursor indicating selectable text.      text:指示可选择文本的光标。

  • alias: An alias or shortcut is being created.       alias:正在创建别名或快捷方式。

  • copy: A copy is being created.       copy:正在创建副本。

  • move: Something is to be moved.      移动:某物要被移动。

  • no-drop: Something can’t be dropped here. 这里不能拖入东西。

  • not-allowed: An action isn’t allowed          not-allowed:不允许的动作

  • grab: Something is grabbable.         抓取:某物是可抓取的。

  • grabbing: Something is being grabbed.     抓取中:某物正在被抓取。

  • col-resize: Indicating that a column is resizable horizontally.       color -resize:表示可以水平调整列的大小。

  • row-resize: Indicating that a row is resizable vertically.      row-resize:表示一行可以垂直调整大小。

  • n-resize: Unidirectional resize north.        n-resize:向北单向调整大小。

  • e-resize: Unidirectional resize east.          e-resize:单向向东调整大小。

  • s-resize: Unidirectional resize south.        s-resize:向南单向调整大小。

  • w-resize: Unidirectional resize west.          w-resize:向西单向调整大小。

  • ne-resize: Unidirectional resize north-east.       ne-resize:单向调整东北方向的大小。

  • nw-resize: Unidirectional resize north-west.      nw-resize:向西北方向调整大小。

  • se-resize: Unidirectional resize south-east.      se-resize:单向调整东南方向的大小。

  • sw-resize: Unidirectional resize south-west.      sw-resize:单向调整西南方向的大小。

  • ew-resize: Bidirectional resize east-west.          ew-resize:东西双向调整大小。

  • ns-resize: Bidirectional resize north-south.        ns-resize:南北双向调整大小。

  • nesw-resize: Bidirectional resize north-east-south-west.      new-resize:双向调整大小东北-西南。

  • nwse-resize: Bidirectional resize north-west-south-east.     nwse-resize:双向调整大小西北-东南。

Orientation 方向

Represents the orientation of an element or widget such as the Slider.

表示元素或小部件(如Slider)的方向。

  • horizontal: Element is oriented horizontally.   水平:元素水平方向。

  • vertical: Element is oriented vertically.           垂直:元素垂直方向。

PathEvent 路径事件

PathEvent is a low-level data structure describing the composition of a path. Typically it is generated at compile time from a higher-level description, such as SVG commands.

PathEvent是一个描述路径组成的底层数据结构。通常,它是在编译时从更高级的描述(如SVG命令)生成的。

  • begin: The beginning of the path.     开始:路径的开始。

  • line: A straight line on the path.      直线:路径上的一条直线。

  • quadratic: A quadratic bezier curve on the path.  二次曲线:路径上的二次贝塞尔曲线。

  • cubic: A cubic bezier curve on the path.      cubic:路径上的三次贝塞尔曲线。

  • end-open: The end of the path that remains open.     end-open:路径的尽头仍然是开放的。

  • end-closed: The end of a path that is closed.            end-closed:道路的尽头是关闭的。

PointerEventButton 指针事件按钮

This enum describes the different types of buttons for a pointer event, typically on a mouse or a pencil.

此枚举描述指针事件(通常在鼠标或铅笔上)的不同类型的按钮。

  • other: A button that is none of left, right or middle. For example this is used for a fourth button on a mouse with many buttons.        其他:不是左、右或中间的按钮。例如,这用于具有多个按钮的鼠标上的第四个按钮。。

  • left: The left button.       left:左键。

  • right: The right button.    right:右键。

  • middle: The center button.    middle:中间按钮。

PointerEventKind 指针事件类型

The enum reports what happened to the PointerEventButton in the event

枚举报告事件中PointerEventButton的情况

  • cancel: The action was cancelled.    cancel:操作被取消。

  • down: The button was pressed.          down:按钮按下了。

  • up: The button was released.             up:按钮被释放。

SortOrder 排序方式

This enum represents the different values of the sort-order property. It’s used to sort a StandardTableView by a column.

此枚举表示排序顺序属性的不同值。它用于按列排序StandardTableView 标准桌面视图。

  • unsorted: The column is unsorted.     unsorted:该列未排序。

  • ascending: The column is sorted in ascending order.     ascending:按升序排序。

  • descending: The column is sorted in descending order.      降序:按降序排序。

StandardButtonKind 标准按钮类型

Use this enum to add standard buttons to a Dialog. The look and positioning of these StandardButtons depends on the environment (OS, UI environment, etc.) the application runs in.

使用此enum可向对话框添加标准按钮。这些StandardButtons的外观和定位取决于应用程序运行的环境(操作系统、UI环境等)。

  • ok: A “OK” button that accepts a Dialog, closing it when clicked.     ok:一个接受对话框的“ok”按钮,点击后关闭对话框。

  • cancel: A “Cancel” button that rejects a Dialog, closing it when clicked.      取消:一个“取消”按钮,拒绝一个对话框,当点击时关闭它。

  • apply: A “Apply” button that should accept values from a Dialog without closing it.       apply:一个“apply”按钮,它应该从对话框中接受值而不关闭它。

  • close: A “Close” button, which should close a Dialog without looking at values.       close:一个“关闭”按钮,它应该关闭对话框而不查看值。

  • reset: A “Reset” button, which should reset the Dialog to its initial state.        reset:一个“reset”按钮,它将把对话框重置到初始状态。

  • help: A “Help” button, which should bring up context related documentation when clicked.          help:一个“帮助”按钮,当点击它时,会显示与上下文相关的文档。

  • yes: A “Yes” button, used to confirm an action.      yes:“是”按钮,用于确认操作。

  • no: A “No” button, used to deny an action.             no:“no”按钮,用于拒绝某个操作。

  • abort: A “Abort” button, used to abort an action.      abort:一个“中止”按钮,用于中止一个操作。

  • retry: A “Retry” button, used to retry a failed action.       重试:“重试”按钮,用于重试失败的操作。

  • ignore: A “Ignore” button, used to ignore a failed action.       ignore:“忽略”按钮,用于忽略失败的操作。

TextHorizontalAlignment 文本水平对齐方式

This enum describes the different types of alignment of text along the horizontal axis of a Text element.

此枚举描述文本沿着text元素的水平轴的不同对齐类型。

  • left: The text will be aligned with the left edge of the containing box.      左:文本将与包含框的左边缘对齐。

  • center: The text will be horizontally centered within the containing box.     center:文本将在包含框内水平居中。

  • right: The text will be aligned to the right of the containing box.        右:文本将在包含框的右侧对齐。

TextOverflow 文本溢出

This enum describes the how the text appear if it is too wide to fit in the Text width.

此枚举描述如果文本太宽而无法适应文本宽度时的显示方式。

  • clip: The text will simply be clipped.      clip:文本将被简单地剪切。

  • elide: The text will be elided with .      elide:文本将用....省略

TextVerticalAlignment 文本垂直对齐方式

This enum describes the different types of alignment of text along the vertical axis of a Text element.

此枚举描述文本沿着text元素的垂直轴的不同对齐类型。

  • top: The text will be aligned to the top of the containing box.       top:文本将与包含框的顶部对齐。

  • center: The text will be vertically centered within the containing box.       center:文本将在包含框内垂直居中。

  • bottom: The text will be aligned to the bottom of the containing box.      bottom:文本将与包含框的底部对齐。

TextWrap 文本换行

This enum describes the how the text wrap if it is too wide to fit in the Text width.

此枚举描述如果文本太宽而无法适应文本宽度时如何换行。

  • no-wrap: The text won’t wrap, but instead will overflow.        no-wrap:文本不换行,但会溢出。

  • word-wrap: The text will be wrapped at word boundaries.      word-wrap:文本将在单词边界处换行。

Next 下一个

Builtin Functions 内装式功能


Builtin Functions - Slint 1.3.2 Reference

Builtin Functions 内置功能

animation-tick() -> duration // 持续时间

This function returns a monotonically increasing time, which can be used for animations. Calling this function from a binding will constantly re-evaluate the binding. It can be used like so:x: 1000px + sin(animation-tick() / 1s * 360deg) * 100px; 

or y: 20px * mod(animation-tick(), 2s) / 2s

这个函数返回一个单调递增的时间,可以用于动画。从绑定中调用此函数将不断地重新计算绑定。它可以这样使用:x: 1000px + sin(animation-tick() / 1s * 360°)* 100px;或者y: 20px * mod(animation-tick(), 2s) / 2s

export component Example inherits Window {
    preferred-width: 100px;
    preferred-height: 100px;

    Rectangle {
        y:0;
        background: red;
        height: 50px;
        width: parent.width * mod(animation-tick(), 2s) / 2s;
    }

    Rectangle {
        background: blue;
        height: 50px;
        y: 50px;
        width: parent.width * abs(sin(360deg * animation-tick() / 3s));
    }
}

slint 1.3.2 官方文档翻译04_第1张图片

(其实是个动态图,看原网页吧)

debug(...) 调试(…)

The debug function can take one or multiple values as arguments, prints them, and returns nothing.

调试函数可以接受一个或多个值作为参数,打印它们,不返回任何值。

Next 下一个

Builtin Global Singletons 构建全局单例


Builtin Global Singletons - Slint 1.3.2 Reference

Builtin Global Singletons 构建全局单例

TextInputInterface 文本输入接口

The TextInputInterface.text-input-focused property can be used to find out if a TextInput element has the focus. If you’re implementing your own virtual keyboard, this property is an indicator whether the virtual keyboard should be shown or hidden. TextInputInterface。

 TextInputInterface.text-input-focused属性可用于查明TextInput元素是否具有焦点。如果要实现自己的虚拟键盘,则此属性是显示还是隐藏虚拟键盘的指示符。

Properties 属性

  • text-input-focused (bool): True if an TextInput element has the focus; false otherwise.            text-input-focused (bool):如果TextInput元素具有焦点,则为True;否则false。

Example 例子

import { LineEdit } from "std-widgets.slint";

component VKB {
    Rectangle { background: yellow; }
}

export component Example inherits Window {
    width: 200px;
    height: 100px;
    VerticalLayout {
        LineEdit {}
        FocusScope {}
        if TextInputInterface.text-input-focused: VKB {}
    }
}

Next 下一个

Builtin Namespaces 内置命名空间


Builtin Namespaces - Slint 1.3.2 Reference

Builtin Namespaces 内置命名空间

The following namespaces provide access to common constants such as special keys or named colors.

下面的命名空间提供了对常用常量的访问,如特殊键或命名颜色。

Colors 颜色

Use the colors namespace to select colors by their name. For example you can use Colors.aquamarine or Colors.bisque. The entire list of names is very long. You can find a complete list in the CSS Specification.

使用colors名称空间按名称选择颜色。例如,你可以使用Colors.aquamarine 颜色.海蓝宝石 或Colors.bisque。整个名单都很长。你可以在CSS规范中找到一个完整的列表。

These functions are available both in the global scope, and in the Colors namespace.

这些函数在全局作用域和Colors命名空间中都可用。

  • rgb(int, int, int) -> color,       rgba(int, int, int, float) -> color 

Return the color as in CSS. Like in CSS, these two functions are actually aliases that can take three or four parameters.

返回CSS中的颜色。与CSS一样,这两个函数实际上是别名,可以接受三到四个参数。

The first 3 parameters can be either number between 0 and 255, or a percentage with a % unit. The fourth value, if present, is an alpha value between 0 and 1.

前3个参数可以是0到255之间的数字,也可以是一个以%为单位的百分比。第四个值(如果存在)是介于0和1之间的alpha值。

Unlike in CSS, the commas are mandatory.

与CSS不同,逗号是强制性的。

Key 键

Use the constants in the Key namespace to handle pressing of keys that don’t have a printable character. Check the value of KeyEvent’s text property against the constants below.

使用Key名称空间中的常量来处理按下没有可打印字符的键。根据下面的常量检查KeyEvent的text属性的值。

  • Backspace 退格

  • Tab 

  • Return 返回

  • Escape 

  • Backtab

  • Delete 删除

  • Shift 上档

  • Control 控制

  • Alt

  • AltGr

  • CapsLock 大写锁定

  • ShiftR

  • ControlR

  • Meta 元

  • MetaR 

  • UpArrow 向上光标

  • DownArrow

  • LeftArrow

  • RightArrow

  • F1

  • F2

  • F3

  • F4

  • F5

  • F6

  • F7

  • F8

  • F9

  • F10

  • F11 

  • F12

  • F13

  • F14

  • F15

  • F16

  • F17

  • F18

  • F19

  • F20

  • F21

  • F22 

  • F23

  • F24

  • Insert 插入

  • Home 首页

  • End 结束

  • PageUp 上页

  • PageDown 下页

  • ScrollLock

  • Pause 暂停

  • SysReq

  • Stop 停止

  • Menu 菜单

Math 数学

These functions are available both in the global scope and in the Math namespace.

这些函数在全局作用域和Math名称空间中都可用。

abs(float) -> float

Return the absolute value. 返回绝对值。

acos(float) -> angle,     asin(float) -> angle

atan(float) -> angle,     cos(angle) -> float

sin(angle) -> float,       tan(angle) -> float

The trigonometry function. Note that the should be typed with deg or rad unit (for example cos(90deg) or sin(slider.value * 1deg)).

三角函数。请注意,应使用deg或rad单位键入(例如cos(90deg)或sin(slider.value*1deg))。

ceil(float) -> int  and  floor(float) -> int

Return the ceiling or floor 返回 最高值 或最低值

clamp(T, T, T) -> T

Takes a valueminimum and maximum and returns maximum if value > maximumminimum if value < minimum, or value in all other cases. 取一个值,最小值和最大值,如果值>最大值,则返回最大值,当值<最小值时返回最小值,或者在所有其他情况下返回值。

log(float, float) -> float

Return the log of the first value with a base of the second value

返回以第二个值为基数的第一个值的日志

max(T, T) -> T  and  min(T, T) -> T

Return the arguments with the minimum (or maximum) value. All arguments must be of the same numeric type     

返回具有最小(或最大值)值的参数。所有参数必须具有相同的数字类型

mod(T, T) -> T

Perform a modulo operation, where T is some numeric type.

执行取模操作,其中T是某种数字类型。

round(float) -> int

Return the value rounded to the nearest integer

返回四舍五入到最接近的整数的值

sqrt(float) -> float

Square root

平方根

pow(float, float) -> float

Return the value of the first value raised to the second

将第一个值的值返回到第二个值

Next 下一个

Builtin Structures 内置结构体


Builtin Structures - Slint 1.3.2 Reference

Builtin Structures 内置结构体

KeyEvent 键盘事件

This structure is generated and passed to the key press and release callbacks of the FocusScope element.

该结构被生成并传递给FocusScope元素的按键和释放回调函数。

Fields 字段

  • text (string): The unicode representation of the key pressed.        text (string):按下的键的unicode表示。

  • modifiers (KeyboardModifiers): The keyboard modifiers active at the time of the key press event.         修饰符(KeyboardModifiers):在按键事件时激活的键盘修饰符。

  • repeat (bool): This field is set to true for key press events that are repeated, i.e. the key is held down. It’s always false for key release events.      repeat (bool):对于重复的按键事件,即按下按键,此字段设置为true。对于键释放事件,它总是false。

KeyboardModifiers 键盘修饰符

KeyboardModifier provides booleans to indicate possible modifier keys on a keyboard, such as Shift, Control, etc. This structure is generated as part of KeyEvent On macOS, the command key is mapped to the meta modifier. On Windows, the windows key is mapped to the meta modifier.

KeyboardModifier提供布尔值来指示键盘上可能的修饰符,如Shift、Control等。这个结构是作为KeyEvent的一部分生成的。在macOS上,命令键被映射到元修饰符。在Windows上,Windows键映射到元修饰符。

Fields 字段

  • alt (bool): Indicates the alt key on a keyboard.      alt (bool):表示键盘上的alt键。

  • control (bool): Indicates the control key on a keyboard.      control (bool):键盘上的控制键。

  • shift (bool): Indicates the shift key on a keyboard.      shift (bool):键盘上的shift键。

  • meta (bool): Indicates the command key on macos.      meta (bool): macos上的命令键。

Point 点

This structure represents a point with x and y coordinate

这个结构表示一个有x和y坐标的点

Fields 字段

  • x (length)    x(长度)

  • y (length)    y(长度)

PointerEvent 指针事件

Represents a Pointer event sent by the windowing system. This structure is passed to the pointer-event callback of the TouchArea element.

表示窗口系统发送的指针事件。这个结构被传递给TouchArea元素的指针事件回调。

Fields 字段

  • button (PointerEventButton): The button that was pressed or released              button (PointerEventButton):被按下或释放的按钮

  • kind (PointerEventKind): The kind of the event           kind (PointerEventKind):事件的类型

  • modifiers (KeyboardModifiers): The keyboard modifiers pressed during the event        modifiers (KeyboardModifiers):事件期间按下的键盘修饰符

PointerScrollEvent 指针滚动事件

Represents a Pointer scroll (or wheel) event sent by the windowing system. This structure is passed to the scroll-event callback of the TouchArea element.

表示窗口系统发送的指针滚动(或滚轮)事件。这个结构被传递给TouchArea元素的滚动事件回调。

Fields 字段

  • delta_x (length): The amount of pixel in the horizontal direction           delta_x (length):水平方向上的像素量

  • delta_y (length): The amount of pixel in the vertical direction               delta_y (length):垂直方向上的像素量

  • modifiers (KeyboardModifiers): The keyboard modifiers pressed during the event                  modifiers (KeyboardModifiers):事件期间按下的键盘修饰符

StandardListViewItem 标准列表视图项目

Represents an item in a StandardListView and a StandardTableView.

代表一个在StandardListView和StandardTableView中的项。

Fields 字段

  • text (string): The text content of the item          text (string):项目的文本内容

TableColumn 表格列

This is used to define the column and the column header of a TableView

这是用来定义一个TableView的列和列头

Fields 字段

  • title (string): The title of the column header        title(字符串):列头部的标题

  • min_width (length): The minimum column width (logical length)              min_width (length):最小列宽度(逻辑长度)

  • horizontal_stretch (float): The horizontal column stretch            horizontal_stretch (float):水平列拉伸

  • sort_order (SortOrder): Sorts the column                sort_order (SortOrder):对列排序

  • width (length): the actual width of the column (logical length)           宽度(长度):列的实际宽度(逻辑长度)

Next 下一个

Widgets 小部件


Widgets - Slint 1.3.2 Reference

Widgets 小部件

Slint provides a series of built-in widgets that can be imported from "std-widgets.slint".

Slint提供了一系列可以从“std-widgets.slint”导入的内置小部件。

The widget appearance depends on the selected style. See Selecting a Widget Style for details how to select the style. If no style is selected, native is the default. If native isn’t available, fluent is the default.

小部件的外观取决于所选的样式。有关如何选择小部件样式的详细信息,请参见选择小部件样式。如果没有选择样式,则默认为native。如果native不可用,那么fluent是默认的。

All widgets support all properties common to builtin elements.

所有小部件都支持内置元素的所有通用属性。

Next

AboutSlint


AboutSlint - Slint 1.3.2 Reference

AboutSlint

This element displays a “Made with Slint” badge. 

此元素显示“Made with Slint”徽章。

import { AboutSlint } from "std-widgets.slint";
export component Example inherits Window {
    height: 175px;
    AboutSlint {
    }
}

slint 1.3.2 官方文档翻译04_第2张图片

Next 下一个

Button 按钮


Button - Slint 1.3.2 Reference

Button 按钮

A simple button. Common types of buttons can also be created with StandardButton.

一个简单的按钮。常用类型的按钮也可以用StandardButton创建。

Properties 属性

  • checkable (in bool): Shows whether the button can be checked or not. This enables the checked property to possibly become true.          checkable (in bool):显示按钮是否可以被选中。这使得选中的属性可能变为true。

  • checked (inout bool): Shows whether the button is checked or not. Needs checkable to be true to work.     checked (inout bool):显示按钮是否被选中。需要checkable是true才能工作。

  • enabled: (in bool): Defaults to true. When false, the button cannot be pressed                           enabled:(in bool):默认为true。当为false时,按钮无法按下

  • has-focus: (out bool): Set to true when the button has keyboard focus.                                 has-focus:(out bool):当按钮有键盘焦点时设置为true。

  • icon (in image): The image to show in the button. Note that not all styles support drawing icons.           icon (in image):要在按钮中显示的图像。注意,并非所有样式都支持绘制图标。

  • pressed: (out bool): Set to true when the button is pressed.           pressed:(out bool):按钮被按下时设置为true。

  • text (in string): The text written in the button.         text (in string):按钮上写的文本。

  • primary (in bool): If set to true the button is displayed with the primary accent color (default: false).        primary (in bool):如果设置为true,按钮将以主色调显示(默认:false)。

Callbacks 回调

  • clicked()    点击,选中

Example 例子

import { Button, VerticalBox } from "std-widgets.slint";
export component Example inherits Window {
    VerticalBox {
        Button {
            text: "Click Me";
            clicked => { self.text = "Clicked"; }
        }
    }
}


 

CheckBox 复选框


CheckBox - Slint 1.3.2 Reference

CheckBox 复选框

Use a CheckBox to let the user select or deselect values, for example in a list with multiple options. Consider using a Switch element instead if the action resembles more something that’s turned on or off.

使用CheckBox让用户选择或取消选择值,例如在具有多个选项的列表中。如果动作更像是打开或关闭的东西,可以考虑使用Switch元素。

Properties 属性

  • checked: (inout bool): Whether the checkbox is checked or not (default: false).           checked:(inout bool):复选框是否被选中(默认:false)。

  • enabled: (in bool): Defaults to true. When false, the checkbox can’t be pressed (default: true)         enabled:(in bool):默认为true。当为false时,复选框不能被选中(默认值:true)

  • has-focus: (out bool): Set to true when the checkbox has keyboard focus (default: false).            has-focus:(out bool):当复选框具有键盘焦点时设置为true(默认:false)。

  • text (in string): The text written next to the checkbox.      text (in string):复选框旁边的文本。

Callbacks 回调

  • toggled(): The checkbox value changed         toggle():复选框的值被改变

Example 例子

import { CheckBox } from "std-widgets.slint";
export component Example inherits Window {
    width: 200px;
    height: 25px;
    CheckBox {
        width: parent.width;
        height: parent.height;
        text: "Hello World";
    }
}


 

ComboBox 组合框


ComboBox - Slint 1.3.2 Reference

ComboBox 组合框

A button that, when clicked, opens a popup to select a value.

当单击该按钮时,将打开一个弹出窗口以选择一个值。

Properties 属性

  • current-index: (in-out int): The index of the selected value (-1 if no value is selected)                 current-index:(in-out int):所选值的索引(未选则为-1)

  • current-value: (in-out string): The currently selected text           current-value:(in-out string):当前选择的文本

  • enabled: (in bool): Defaults to true. When false, the combobox can’t be interacted with              enabled:(in bool):默认为true。当为false时,无法与组合框进行交互

  • has-focus: (out bool): Set to true when the combobox has keyboard focus.           has-focus:(out bool):当组合框具有键盘焦点时设置为true。

  • model (in [string]): The list of possible values           model (in [string]):可能值的列表

Callbacks 回调

  • selected(string): A value was selected from the combo box. The argument is the currently selected value.            selected(string):从组合框中选择了一个值。参数是当前选定的值。

Example 例子

import { ComboBox } from "std-widgets.slint";
export component Example inherits Window {
    width: 200px;
    height: 130px;
    ComboBox {
        y: 0px;
        width: self.preferred-width;
        height: self.preferred-height;
        model: ["first", "second", "third"];
        current-value: "first";
    }
}

slint 1.3.2 官方文档翻译04_第3张图片





Next 下一个

GridBox 格子里

你可能感兴趣的:(slint,学习,前端,slint,学习)