From 2eedfcc1a21ff5302c620c4dd6abc6246306f7db Mon Sep 17 00:00:00 2001 From: Nigel Breslaw Date: Wed, 11 Dec 2024 01:20:02 +0200 Subject: [PATCH] 1.9 Docs: Turn on link validator (#7057) --- docs/astro/astro.config.mjs | 8 +- .../{backend_qt.md => backend_qt.mdx} | 5 +- ...enderers.md => backends_and_renderers.mdx} | 12 +- .../docs/guide/language/coding/animation.mdx | 4 +- .../docs/guide/language/coding/file.mdx | 5 +- .../coding/functions-and-callbacks.mdx | 6 +- .../docs/guide/language/coding/globals.mdx | 3 +- .../docs/guide/language/coding/properties.mdx | 4 +- .../coding/repetition-and-data-models.mdx | 4 +- .../language/concepts/component-property.mdx | 110 +++++++++++++++++- docs/astro/src/content/docs/index.mdx | 13 +-- .../docs/reference/colors-and-brushes.mdx | 4 +- .../src/content/docs/reference/common.mdx | 90 +++++++++++--- .../docs/reference/elements/textinput.mdx | 7 +- .../docs/reference/gestures/focusscope.mdx | 13 ++- .../content/docs/reference/gestures/key.mdx | 4 +- .../content/docs/reference/slint-language.mdx | 7 -- .../docs/reference/std-widgets/lineedit.mdx | 5 +- docs/astro/src/utils/link-data.json | 44 ++++++- docs/astro/tests/smoke-test.spec.ts | 5 +- internal/common/enums.rs | 90 +++++++------- 21 files changed, 325 insertions(+), 118 deletions(-) rename docs/astro/src/content/docs/guide/backends-and-renderers/{backend_qt.md => backend_qt.mdx} (88%) rename docs/astro/src/content/docs/guide/backends-and-renderers/{backends_and_renderers.md => backends_and_renderers.mdx} (93%) delete mode 100644 docs/astro/src/content/docs/reference/slint-language.mdx diff --git a/docs/astro/astro.config.mjs b/docs/astro/astro.config.mjs index 8c41a93b8e4..a2b4858fe05 100644 --- a/docs/astro/astro.config.mjs +++ b/docs/astro/astro.config.mjs @@ -173,13 +173,9 @@ export default defineConfig({ }, { label: "Reference", - link: "reference/slint-language", + link: "reference/primitive-types", icon: "information", items: [ - { - label: "Slint Language", - slug: "reference/slint-language", - }, { label: "Primitive Types", slug: "reference/primitive-types", @@ -355,8 +351,8 @@ export default defineConfig({ }, ]), starlightLinksValidator({ - errorOnRelativeLinks: false, errorOnLocalLinks: false, + exclude: ["**/index.mdx"], }), ], social: { diff --git a/docs/astro/src/content/docs/guide/backends-and-renderers/backend_qt.md b/docs/astro/src/content/docs/guide/backends-and-renderers/backend_qt.mdx similarity index 88% rename from docs/astro/src/content/docs/guide/backends-and-renderers/backend_qt.md rename to docs/astro/src/content/docs/guide/backends-and-renderers/backend_qt.mdx index 62b1f20cbdf..58f7a097126 100644 --- a/docs/astro/src/content/docs/guide/backends-and-renderers/backend_qt.md +++ b/docs/astro/src/content/docs/guide/backends-and-renderers/backend_qt.mdx @@ -3,8 +3,9 @@ title: Qt Backend description: Qt Backend --- +import Link from '/src/components/Link.astro'; +// cSpell: ignore qttype qttypes - The Qt backend uses the [Qt](https://www.qt.io) library to interact with the windowing system, for rendering, as well as widget style for a native look and feel. @@ -19,7 +20,7 @@ The compilation step will detect whether Qt is installed or not using the qttype See the instructions in the [qttypes documentation](https://docs.rs/qttypes/latest/qttypes/#finding-qt) on how to set environment variables to point to the Qt installation. -If Qt is not installed, the backend will be disabled, and Slint will fallback to another backend, usually the [Winit backend](backend_winit.md). +If Qt is not installed, the backend will be disabled, and Slint will fallback to another backend, usually the . ## Configuration Options diff --git a/docs/astro/src/content/docs/guide/backends-and-renderers/backends_and_renderers.md b/docs/astro/src/content/docs/guide/backends-and-renderers/backends_and_renderers.mdx similarity index 93% rename from docs/astro/src/content/docs/guide/backends-and-renderers/backends_and_renderers.md rename to docs/astro/src/content/docs/guide/backends-and-renderers/backends_and_renderers.mdx index 946ef994742..dece8e237e4 100644 --- a/docs/astro/src/content/docs/guide/backends-and-renderers/backends_and_renderers.md +++ b/docs/astro/src/content/docs/guide/backends-and-renderers/backends_and_renderers.mdx @@ -4,7 +4,9 @@ title: Backends & Renderers description: Backends & Renderers --- - +import Link from '/src/components/Link.astro'; +// cSpell: ignore linuxkms mfloat BINDGEN OECORE CCARGS xcrun gnueabi + In Slint, a backend is the module that encapsulates the interaction with the operating system, in particular the windowing sub-system. Multiple backends can be compiled into Slint and one @@ -46,7 +48,7 @@ as well as the features you've selected at Slint compilation time. ### Qt Renderer -The Qt renderer comes with the [Qt backend](backend_qt.md) and renders using QPainter: +The Qt renderer comes with the and renders using QPainter: - Software rendering, no GPU acceleration. - Available only in the Qt backend. @@ -66,7 +68,7 @@ The Qt renderer comes with the [Qt backend](backend_qt.md) and renders using QPa * No circular gradients. * No text stroking/outlining. - Text rendering currently limited to western scripts. -- Available in the [Winit backend](backend_winit.md). +- Available in the . - Public [Rust](slint-rust:platform/software_renderer/) and [C++](slint-cpp:api/classslint_1_1platform_1_1SoftwareRenderer) API. ### FemtoVG Renderer @@ -74,14 +76,14 @@ The Qt renderer comes with the [Qt backend](backend_qt.md) and renders using QPa - Highly portable. - GPU acceleration with OpenGL (required). - Text and path rendering quality sometimes sub-optimal. - - Available in the [Winit backend](backend_winit.md) and [LinuxKMS backend](backend_linuxkms.md). + - Available in the and . - Public [Rust](slint-rust:platform/femtovg_renderer/) API. ### Skia Renderer - Sophisticated GPU acceleration with OpenGL, Metal, Vulkan, and Direct3D. - Heavy disk-footprint compared to other renderers. - - Available in the [Winit backend](backend_winit.md) and [LinuxKMS backend](backend_linuxkms.md). + - Available in the and . - Public [C++](slint-cpp:api/classslint_1_1platform_1_1SkiaRenderer) API. #### Troubleshooting diff --git a/docs/astro/src/content/docs/guide/language/coding/animation.mdx b/docs/astro/src/content/docs/guide/language/coding/animation.mdx index b3e09369821..231a91076a5 100644 --- a/docs/astro/src/content/docs/guide/language/coding/animation.mdx +++ b/docs/astro/src/content/docs/guide/language/coding/animation.mdx @@ -4,6 +4,8 @@ title: Animations description: UI Animations. --- +import Link from '/src/components/Link.astro'; + Declare animations for properties with the `animate` keyword like this: ```slint @@ -28,7 +30,7 @@ Fine-tune animations using the following parameters: - `duration`: the amount of time it takes for the animation to complete - `iteration-count`: The number of times an animation should run. A negative value specifies infinite reruns. Fractional values are possible. - For permanently running animations, see [`animation-tick()`](../language/builtins/functions.md#animation-tick-duration). + For permanently running animations, see . - `easing`: can be any of the following. See [`easings.net`](https://easings.net/) for a visual reference: - `linear` diff --git a/docs/astro/src/content/docs/guide/language/coding/file.mdx b/docs/astro/src/content/docs/guide/language/coding/file.mdx index 853abfa392c..bb498803ae1 100644 --- a/docs/astro/src/content/docs/guide/language/coding/file.mdx +++ b/docs/astro/src/content/docs/guide/language/coding/file.mdx @@ -5,6 +5,7 @@ description: The `.slint` File --- import CodeSnippetMD from '/src/components/CodeSnippetMD.astro'; +import Link from '/src/components/Link.astro'; You write user interfaces in the Slint language and saved in files with the `.slint` extension. @@ -75,7 +76,7 @@ export component MyApp inherits Window { ``` :::note{Note} -Names have to be valid [identifiers](../syntax/identifiers.md). +Names have to be valid [identifiers](#identifiers). ::: Some elements are also accessible under pre-defined names: @@ -276,7 +277,7 @@ export component App inherits Rectangle { Elements, globals and structs can be exported and imported. -It's also possible to export globals (see [Global Singletons](globals.md)) imported from +It's also possible to export globals (see ) imported from other files: ```slint no-test diff --git a/docs/astro/src/content/docs/guide/language/coding/functions-and-callbacks.mdx b/docs/astro/src/content/docs/guide/language/coding/functions-and-callbacks.mdx index 9baa2e12f39..3ae8ae3fe23 100644 --- a/docs/astro/src/content/docs/guide/language/coding/functions-and-callbacks.mdx +++ b/docs/astro/src/content/docs/guide/language/coding/functions-and-callbacks.mdx @@ -4,6 +4,8 @@ title: Functions description: Functions --- +import Link from '/src/components/Link.astro'; + Similar to other programming languages, functions in Slint are way to name, organize and reuse a piece of logic/code. @@ -35,7 +37,7 @@ If a function does not explicitly return a value, the value of the last statemen Functions can be annotated with the `pure` keyword. This indicates that the function does not cause any side effects. -More details can be found in the [Purity](../concepts/purity.md) chapter. +More details can be found in the chapter. ## Calling a function @@ -125,7 +127,7 @@ See the language-specific documentation for the generated code to use. ## Functions vs. callbacks -There are a lot of similarities between functions and [callbacks](callbacks.md): +There are a lot of similarities between functions and [callbacks](#callbacks): - They are both callable blocks of logic/code - They are invoked in the same way diff --git a/docs/astro/src/content/docs/guide/language/coding/globals.mdx b/docs/astro/src/content/docs/guide/language/coding/globals.mdx index 30f38a769bc..930873a1767 100644 --- a/docs/astro/src/content/docs/guide/language/coding/globals.mdx +++ b/docs/astro/src/content/docs/guide/language/coding/globals.mdx @@ -3,6 +3,7 @@ title: Globals description: Globals --- +import Link from '/src/components/Link.astro'; Declare a global singleton with `global Name { /* .. properties or callbacks .. */ }` to make properties and callbacks available throughout the entire project. Access them using `Name.property`. @@ -22,7 +23,7 @@ export component Example inherits Rectangle { } ``` -Export a global to make it accessible from other files (see [Modules](modules.md)). Export a global from +Export a global to make it accessible from other files (see ). Export a global from the file also exporting the main application component to make it visible to native code in the business logic. diff --git a/docs/astro/src/content/docs/guide/language/coding/properties.mdx b/docs/astro/src/content/docs/guide/language/coding/properties.mdx index 3e566e25bc6..3dd1b017a62 100644 --- a/docs/astro/src/content/docs/guide/language/coding/properties.mdx +++ b/docs/astro/src/content/docs/guide/language/coding/properties.mdx @@ -4,9 +4,11 @@ title: Properties description: Properties --- +import Link from '/src/components/Link.astro'; + All elements have properties. Built-in elements come with common properties such as color or dimensional properties. You can assign values or entire -[expressions](expressions.md) to them: + to them: ```slint export component Example inherits Window { diff --git a/docs/astro/src/content/docs/guide/language/coding/repetition-and-data-models.mdx b/docs/astro/src/content/docs/guide/language/coding/repetition-and-data-models.mdx index 743d10bc582..53016b45adc 100644 --- a/docs/astro/src/content/docs/guide/language/coding/repetition-and-data-models.mdx +++ b/docs/astro/src/content/docs/guide/language/coding/repetition-and-data-models.mdx @@ -11,7 +11,7 @@ The syntax looks like this: `for name[index] in model : id := Element { ... }` The _model_ can be of the following type: - an integer, in which case the element will be repeated that amount of time -- an [array type or a model](types.md#arrays-and-models) declared natively, in which case the element will be instantiated for each element in the array or model. +- an [array type or a model](#models) declared natively, in which case the element will be instantiated for each element in the array or model. The _name_ will be available for lookup within the element and is going to be like a pseudo-property set to the value of the model. The _index_ is optional and will be set to the index of this element in the model. @@ -48,3 +48,5 @@ export component Example inherits Window { } } ``` + +## Models diff --git a/docs/astro/src/content/docs/guide/language/concepts/component-property.mdx b/docs/astro/src/content/docs/guide/language/concepts/component-property.mdx index 790ca547e6d..8faba585ed1 100644 --- a/docs/astro/src/content/docs/guide/language/concepts/component-property.mdx +++ b/docs/astro/src/content/docs/guide/language/concepts/component-property.mdx @@ -4,4 +4,112 @@ title: Components, Properties, and Functions description: Components, Properties, and Functions --- -Component basics. It's components all the way down... \ No newline at end of file +import CodeSnippetMD from '/src/components/CodeSnippetMD.astro'; + +The Slint language is designed around components that vary in complexity. The simplest can be a label +which could be nothing more than a text element with a predefined font and point size. The most complex +being a view or even the entire app. But regardless of the complexity they always can be broken down +into smaller components. + +To understand this lets start from the opposite perspective. You build an app in a single file as one +very complex component. It will require a lot of time to manage and edit that file. It's state will +be hard to understand and reason about. It will easily have parts that depend on each other so changing +one part might cause unexpected behavior in another. Building an application this way doesn't work. + +## Slint Components + +Instead an app can be broken down into smaller components. Each one that has its own state and behavior. +They can be independent of each other and not necessarily depend on any other part of the app. In many +cases more complex components can be simply built by just composing multiple components together. + +It then becomes easier to reason about the state and behavior of the app. While a single complex app +can seem smart the reality is it doesn't scale. While apps built from many dumb - or less smart - +components can be used to build seemingly complex apps. But the reality is simple components leading +to complex behaviors or interfaces. One's that are easier to iterate on and reason about. + +## Quick Example + +The following example shows how to build a simple button. + + +```slint no-test +component MyButton { +} +``` + + +This component has a name, but nothing more. However it automaticaly gains some common properties. + + +```slint no-test +component MyButton { + width: 200px; + height: 50px; +} +``` + + +This allows a default width and height to be set. It still won't show anything though. + + +```slint no-test +component MyButton { + width: 200px; + height: 50px; + Rectangle { + background: lightseagreen; + } +} +``` + + + + +```slint no-test +component MyButton { + width: 200px; + height: 50px; + Rectangle { + border-width: 2px; + border-color: black; + background: lightseagreen; + } + Text { + text: "Hello World"; + color: white; + } +} +``` + + +A button needs a border so this gives it a black border. It also adds some text. + + + +```slint no-test +component MyButton { + width: 200px; + height: 50px; + Rectangle { + border-width: 2px; + border-color: black; + background: lightseagreen; + + } + Text { + text: "Hello World"; + color: white; + } + TouchArea { + clicked => { + debug("clicked"); + } + } +} +``` + + +To add touch you can use Slints built in `TouchArea` component. It automatically fills its parent +and when touched or clicked it will call its built in 'callback' function called `clicked`. + +To then create a more complex component with multiple buttons it will look like this. \ No newline at end of file diff --git a/docs/astro/src/content/docs/index.mdx b/docs/astro/src/content/docs/index.mdx index cda0e424fa1..097ee84de72 100644 --- a/docs/astro/src/content/docs/index.mdx +++ b/docs/astro/src/content/docs/index.mdx @@ -34,7 +34,7 @@ The documentation is split into several sections: description="This will get you up and running with the tooling for Slint development including the IDE integration via the Slint Language Server (LSP) and Slint Viewer.

It then offers a guide explaining all the key concepts of Slint and how to understand and use the Slint language." - href="guide/getting-started" + href="/master/docs/slint" > @@ -42,7 +42,7 @@ The documentation is split into several sections: title="Reference" description="This contains the API reference for all aspects of the Slint language. All the elements, properties, functions, callbacks and namespaces. It also contains the API reference for the `std-widgets` library. A set of cross platform components that can be used to build desktop applications." - href="reference/overview" + href="/master/docs/slint/reference/primitive-types" > @@ -50,15 +50,14 @@ API reference for the `std-widgets` library. A set of cross platform components title="Tutorial" description="For those that like to learn by example or want to see how to structure a simple application, this section contains a step-by-step tutorial that walks you through the creation of a simple memory game example." -href="tutorial/quickstart" +href="/master/docs/slint/tutorial/quickstart/" > diff --git a/docs/astro/src/content/docs/reference/colors-and-brushes.mdx b/docs/astro/src/content/docs/reference/colors-and-brushes.mdx index b99b9240b35..5492554d725 100644 --- a/docs/astro/src/content/docs/reference/colors-and-brushes.mdx +++ b/docs/astro/src/content/docs/reference/colors-and-brushes.mdx @@ -4,7 +4,7 @@ title: Colors & Brushes description: Colors Namespaces --- - +import Link from '/src/components/Link.astro'; Color literals follow the syntax of CSS: @@ -113,7 +113,7 @@ that is rotated by the specified angle. This is called a linear gradient and is ### @linear-gradient(angle, color percentage, color percentage, ...) -The first parameter to the macro is an angle (see [Types](types.md)). The gradient line's starting point +The first parameter to the macro is an angle (see ). The gradient line's starting point will be rotated by the specified value. Following the initial angle is one or multiple color stops, describe as a space separated pair of a diff --git a/docs/astro/src/content/docs/reference/common.mdx b/docs/astro/src/content/docs/reference/common.mdx index 96dbbef8d08..425e3fbe2b6 100644 --- a/docs/astro/src/content/docs/reference/common.mdx +++ b/docs/astro/src/content/docs/reference/common.mdx @@ -189,27 +189,85 @@ Specify that this is a button in a `Dialog`. - ## Accessibility Use the following `accessible-` properties to make your items interact well with software like screen readers, braille terminals and other software to make your application accessible. `accessible-role` must be set in order to be able to set any other accessible property or callback. -- **`accessible-role`** (_in_ _enum [`AccessibleRole`](enums.md#accessiblerole)_): The role of the element. This property is mandatory to be able to use any other accessible properties. It should be set to a constant value. (default value: `none` for most elements, but `text` for the Text element) -- **`accessible-checkable`** (_in_ _bool_): Whether the element is can be checked or not. -- **`accessible-checked`** (_in_ _bool_): Whether the element is checked or not. This maps to the "checked" state of checkboxes, radio buttons, and other widgets. -- **`accessible-description`** (_in_ _string_): The description for the current element. -- **`accessible-enabled`** (_in_ _bool_): Whether the element is enabled or not. This maps to the "enabled" state of most widgets. (default value: `true`) -- **`accessible-label`** (_in_ _string_): The label for an interactive element. (default value: empty for most elements, or the value of the `text` property for Text elements) -- **`accessible-value-maximum`** (_in_ _float_): The maximum value of the item. This is used for example by spin boxes. -- **`accessible-value-minimum`** (_in_ _float_): The minimum value of the item. -- **`accessible-value-step`** (_in_ _float_) The smallest increment or decrement by which the current value can change. This corresponds to the step by which a handle on a slider can be dragged. -- **`accessible-value`** (_in_ _string_): The current value of the item. -- **`accessible-placeholder-text`** (_in_ _string_): A placeholder text to use when the item's value is empty. Applies to text elements. -- **`accessible-item-selectable`** (_in_ _bool_): Whether the element can be selected or not. -- **`accessible-item-selected`** (_in_ _bool_): Whether the element is selected or not. This maps to the "is-selected" state of listview items. -- **`accessible-item-index`** (_in_ _int_): The index (starting from 0) of this element in a group of similar elements. Applies to list items, radio buttons and other elements. -- **`accessible-item-count`** (_in_ _int_): The total number of elements in a group. Applies to the parent container of a group of element such as list views, radio button groups or other grouping elements. +### accessible-role + +The role of the element. This property is mandatory to be able to use any other accessible properties. It should be set to a constant value. (default value: `none` for most elements, but `text` for the Text element) + + +### accessible-checkable + +Whether the element is can be checked or not. + + +### accessible-checked + +Whether the element is checked or not. This maps to the "checked" state of checkboxes, radio buttons, and other widgets. + + +### accessible-description + +The description for the current element. + + +### accessible-enabled + +Whether the element is enabled or not. This maps to the "enabled" state of most widgets. (default value: `true`) + + +### accessible-label + +The label for an interactive element. (default value: empty for most elements, or the value of the `text` property for Text elements) + + +### accessible-value-maximum + +The maximum value of the item. This is used for example by spin boxes. + + +### accessible-value-minimum + +The minimum value of the item. + + +### accessible-value-step + +The smallest increment or decrement by which the current value can change. This corresponds to the step by which a handle on a slider can be dragged. + + +### accessible-value + +The current value of the item. + + +### accessible-placeholder-text + +A placeholder text to use when the item's value is empty. Applies to text elements. + + +### accessible-item-selectable + +Whether the element can be selected or not. + + +### accessible-item-selected + +Whether the element is selected or not. This maps to the "is-selected" state of listview items. + + +### accessible-item-index + + The index (starting from 0) of this element in a group of similar elements. Applies to list items, radio buttons and other elements. + + +### accessible-item-count + +The total number of elements in a group. Applies to the parent container of a group of element such as list views, radio button groups or other grouping elements. + You can also use the following callbacks that are going to be called by the accessibility framework: diff --git a/docs/astro/src/content/docs/reference/elements/textinput.mdx b/docs/astro/src/content/docs/reference/elements/textinput.mdx index e4f3884ccc4..0a91da68847 100644 --- a/docs/astro/src/content/docs/reference/elements/textinput.mdx +++ b/docs/astro/src/content/docs/reference/elements/textinput.mdx @@ -4,6 +4,7 @@ title: TextInput description: TextInput element api. --- import SlintProperty from '/src/components/SlintProperty.astro'; +import Link from '/src/components/Link.astro'; ```slint playground export component Example inherits Window { @@ -54,7 +55,7 @@ The design metrics of the font scaled to the font pixel size used by the element ### has-focus -`TextInput` sets this to `true` when it's focused. Only then it receives [`KeyEvent`](../language/builtins/structs.md#keyevent)s. +`TextInput` sets this to `true` when it's focused. Only then it receives s. ### horizontal-alignment @@ -118,7 +119,7 @@ The way the text input wraps. Only makes sense when `single-line` is false. Call this function to focus the text input and make it receive future keyboard events. ### clear-focus() -Call this function to remove keyboard focus from this `TextInput` if it currently has the focus. See also [](../concepts/focus.md). +Call this function to remove keyboard focus from this `TextInput` if it currently has the focus. See also . ### set-selection-offsets(int, int) Selects the text between two UTF-8 offsets. @@ -145,7 +146,7 @@ Invoked when the enter key is pressed. ### cursor-position-changed(Point) The cursor was moved to the new (x, y) position -described by the [_`Point`_](../language/builtins/structs.md#point) argument. +described by the `Point` argument. ### edited() Invoked when the text has changed because the user modified it. diff --git a/docs/astro/src/content/docs/reference/gestures/focusscope.mdx b/docs/astro/src/content/docs/reference/gestures/focusscope.mdx index 7961715f2b8..3f75b70111b 100644 --- a/docs/astro/src/content/docs/reference/gestures/focusscope.mdx +++ b/docs/astro/src/content/docs/reference/gestures/focusscope.mdx @@ -4,6 +4,7 @@ title: FocusScope description: FocusScope element api. --- import SlintProperty from '/src/components/SlintProperty.astro'; +import Link from '/src/components/Link.astro'; ```slint playground export component Example inherits Window { @@ -28,9 +29,9 @@ export component Example inherits Window { The `FocusScope` exposes callbacks to intercept key events. Note that `FocusScope` will only invoke them when it `has-focus`. -The [`KeyEvent`](structs.md#keyevent) has a text property, which is a character of the key entered. +The has a text property, which is a character of the key entered. When a non-printable key is pressed, the character will be either a control character, -or it will be mapped to a private unicode character. The mapping of these non-printable, special characters is available in the [`Key`](namespaces.md#key) namespace +or it will be mapped to a private unicode character. The mapping of these non-printable, special characters is available in the namespace ## Properties @@ -49,19 +50,19 @@ Is `true` when the element has keyboard focus. ## Functions ### focus() -Call this function to transfer keyboard focus to this `FocusScope`, to receive future [`KeyEvent`](structs.md#keyevent)s. +Call this function to transfer keyboard focus to this `FocusScope`, to receive future s. ### clear-focus() -Call this function to remove keyboard focus from this `FocusScope` if it currently has the focus. See also [](../concepts/focus.md). +Call this function to remove keyboard focus from this `FocusScope` if it currently has the focus. See also . ## Callbacks ### key-pressed(KeyEvent) -> EventResult -Invoked when a key is pressed, the argument is a [`KeyEvent`](structs.md#keyevent) struct. The returned [`EventResult`](enums.md#eventresult) +Invoked when a key is pressed, the argument is a struct. The returned `EventResult` indicates whether to accept or ignore the event. Ignored events are forwarded to the parent element. ### key-released(KeyEvent) -> EventResult -Invoked when a key is released, the argument is a [`KeyEvent`](structs.md#keyevent) struct. The returned [`EventResult`](enums.md#eventresult) +Invoked when a key is released, the argument is a struct. The returned `EventResult` indicates whether to accept or ignore the event. Ignored events are forwarded to the parent element. ### focus-changed-event() diff --git a/docs/astro/src/content/docs/reference/gestures/key.mdx b/docs/astro/src/content/docs/reference/gestures/key.mdx index 57c76ea38ac..1adf4901064 100644 --- a/docs/astro/src/content/docs/reference/gestures/key.mdx +++ b/docs/astro/src/content/docs/reference/gestures/key.mdx @@ -4,7 +4,9 @@ title: Key Namespace description: Key Namespace --- -Use the constants in the `Key` namespace to handle pressing of keys that don't have a printable character. Check the value of [`KeyEvent`](structs.md#keyevent)'s `text` property +import Link from '/src/components/Link.astro'; + +Use the constants in the `Key` namespace to handle pressing of keys that don't have a printable character. Check the value of 's `text` property against the constants below. - **`Backspace`** diff --git a/docs/astro/src/content/docs/reference/slint-language.mdx b/docs/astro/src/content/docs/reference/slint-language.mdx deleted file mode 100644 index 998d1e8e3e5..00000000000 --- a/docs/astro/src/content/docs/reference/slint-language.mdx +++ /dev/null @@ -1,7 +0,0 @@ ---- - -title: Slint Language -description: Slint Language ---- - -Syntax (.slint file Comments, Identifiers, declaring functions,statements, struct and enums) diff --git a/docs/astro/src/content/docs/reference/std-widgets/lineedit.mdx b/docs/astro/src/content/docs/reference/std-widgets/lineedit.mdx index bc784b3f538..e5aa8b3a7c8 100644 --- a/docs/astro/src/content/docs/reference/std-widgets/lineedit.mdx +++ b/docs/astro/src/content/docs/reference/std-widgets/lineedit.mdx @@ -6,6 +6,7 @@ description: LineEdit api. import SlintProperty from '/src/components/SlintProperty.astro'; import CodeSnippetMD from '/src/components/CodeSnippetMD.astro'; +import Link from '/src/components/Link.astro'; ```slint playground @@ -23,7 +24,7 @@ export component Example inherits Window { ``` -A widget used to enter a single line of text. See [`TextEdit`](master/docs/slint/reference/std-widgets/textedit) for +A widget used to enter a single line of text. See for a widget able to handle several lines of text. ## Properties @@ -85,7 +86,7 @@ LineEdit { Call this function to focus the LineEdit and make it receive future keyboard events. ### clear-focus() -Call this function to remove keyboard focus from this `LineEdit` if it currently has the focus. See also [Focus Handling](../concepts/focus.md). +Call this function to remove keyboard focus from this `LineEdit` if it currently has the focus. See also . ### set-selection-offsets(int, int) Selects the text between two UTF-8 offsets. diff --git a/docs/astro/src/utils/link-data.json b/docs/astro/src/utils/link-data.json index bab9410a9e5..2195cba2519 100644 --- a/docs/astro/src/utils/link-data.json +++ b/docs/astro/src/utils/link-data.json @@ -2,14 +2,17 @@ "AnimationRef": { "href": "/reference/primitive-types#animation" }, + "AnimationTick": { + "href": "/reference/global-functions-enums/builtinfunctions/#animation-tick---duration" + }, "angle": { - "href": "/reference/primitive-types##angle" + "href": "/reference/primitive-types#angle" }, "bool": { - "href": "/reference/primitive-types##bool" + "href": "/reference/primitive-types#bool" }, "brush": { - "href": "/reference/primitive-types##brush" + "href": "/reference/primitive-types#brush" }, "BorderRadiusRectangle": { "href": "/reference/elements/rectangle#border-radius-properties" @@ -38,9 +41,10 @@ "EnumType": { "href": "/reference/global-structs-enums" }, - "slintFile": { - "href": "/guide/language/coding/file" + "Expressions": { + "href": "/guide/language/coding/expressions-and-statements/" }, + "float": { "href": "/reference/primitive-types#float" }, @@ -50,6 +54,9 @@ "GridLayout": { "href": "/reference/layouts/gridlayout" }, + "Globals": { + "href": "/reference/global-structs-enums" + }, "HorizontalBox": { "href": "/reference/std-widgets/horizontalbox" }, @@ -65,6 +72,9 @@ "int": { "href": "/reference/primitive-types#int" }, + "KeyEvent": { + "href": "/reference/gestures/key" + }, "length": { "href": "/reference/primitive-types#length" }, @@ -74,6 +84,15 @@ "LineEdit": { "href": "/reference/std-widgets/lineedit" }, + "LinuxkmsBackend": { + "href": "/guide/backends-and-renderers/backend_linuxkms" + }, + "Modules": { + "href": "/guide/language/coding/file/#modules" + }, + "Models": { + "href": "/guide/language/coding/repetition-and-data-models#models" + }, "NumericTypes": { "href": "/reference/primitive-types#numeric-types" }, @@ -89,12 +108,18 @@ "ProgressIndicator": { "href": "/reference/std-widgets/progressindicator" }, + "Purity": { + "href": "/guide/language/concepts/reactivity" + }, "Rectangle": { "href": "/reference/elements/rectangle" }, "relativeFontSize": { "href": "/reference/primitive-types#relative-font-size" }, + "slintFile": { + "href": "/guide/language/coding/file" + }, "ScrollView": { "href": "/reference/std-widgets/scrollview" }, @@ -113,6 +138,9 @@ "Text": { "href": "/reference/elements/text/" }, + "TextEdit": { + "href": "/reference/std-widgets/textedit" + }, "TextInput": { "href": "/reference/elements/textinput/" }, @@ -127,5 +155,11 @@ }, "VerticalLayout": { "href": "/reference/layouts/verticallayout" + }, + "QtBackend": { + "href": "/guide/backends-and-renderers/backend_qt" + }, + "WinitBackend": { + "href": "/guide/backends-and-renderers/backend_winit/" } } \ No newline at end of file diff --git a/docs/astro/tests/smoke-test.spec.ts b/docs/astro/tests/smoke-test.spec.ts index 4b4958ece77..9308592555e 100644 --- a/docs/astro/tests/smoke-test.spec.ts +++ b/docs/astro/tests/smoke-test.spec.ts @@ -9,8 +9,9 @@ test("smoke test", async ({ page }) => { .getByLabel("Main") .getByRole("link", { name: "Reference" }) .click(); - await page.locator("summary").filter({ hasText: "Elements" }).click(); - await page.getByRole("link", { name: "Image" }).click(); + await page.locator("summary").filter({ hasText: "Basic Elements" }).click(); + await page.getByRole("link", { name: "Image", exact: true }).click(); await page.getByRole("link", { name: "colorize" }).click(); await expect(page.locator("#colorize")).toContainText("colorize"); + await page.getByRole("link", { name: "brush", exact: true }).click(); }); diff --git a/internal/common/enums.rs b/internal/common/enums.rs index b4794a1adc4..3c329b9ac27 100644 --- a/internal/common/enums.rs +++ b/internal/common/enums.rs @@ -20,7 +20,7 @@ macro_rules! for_each_enums { ($macro:ident) => { $macro![ - /// This enum describes the different types of alignment of text along the horizontal axis of a [`Text`](elements.md#text) element. + /// This enum describes the different types of alignment of text along the horizontal axis of a `Text` element. enum TextHorizontalAlignment { /// The text will be aligned with the left edge of the containing box. Left, @@ -30,7 +30,7 @@ macro_rules! for_each_enums { Right, } - /// This enum describes the different types of alignment of text along the vertical axis of a [`Text`](elements.md#text) element. + /// This enum describes the different types of alignment of text along the vertical axis of a `Text` element. enum TextVerticalAlignment { /// The text will be aligned to the top of the containing box. Top, @@ -40,7 +40,7 @@ macro_rules! for_each_enums { Bottom, } - /// This enum describes the how the text wrap if it is too wide to fit in the [`Text`](elements.md#text) width. + /// This enum describes the how the text wrap if it is too wide to fit in the `Text` width. enum TextWrap { /// The text won't wrap, but instead will overflow. NoWrap, @@ -50,7 +50,7 @@ macro_rules! for_each_enums { CharWrap, } - /// This enum describes the how the text appear if it is too wide to fit in the [`Text`](elements.md#text) width. + /// This enum describes the how the text appear if it is too wide to fit in the `Text` width. enum TextOverflow { /// The text will simply be clipped. Clip, @@ -58,7 +58,7 @@ macro_rules! for_each_enums { Elide, } - /// This enum describes the positioning of a text stroke relative to the border of the glyphs in a [`Text`](elements.md#text). + /// This enum describes the positioning of a text stroke relative to the border of the glyphs in a `Text`. enum TextStrokeStyle { /// The inside edge of the stroke is at the outer edge of the text. Outside, @@ -82,20 +82,20 @@ macro_rules! for_each_enums { Evenodd, } - /// Use this enum to add standard buttons to a [`Dialog`](elements.md#dialog). The look and positioning - /// of these [`StandardButton`](../widgets/standardbutton.md)s depends on the environment + /// Use this enum to add standard buttons to a `Dialog`. The look and positioning + /// of these `StandardButton`s depends on the environment /// (OS, UI environment, etc.) the application runs in. enum StandardButtonKind { - /// A "OK" button that accepts a [`Dialog`](elements.md#dialog), closing it when clicked. + /// A "OK" button that accepts a `Dialog`, closing it when clicked. Ok, - /// A "Cancel" button that rejects a [`Dialog`](elements.md#dialog), closing it when clicked. + /// A "Cancel" button that rejects a `Dialog`, closing it when clicked. Cancel, /// A "Apply" button that should accept values from a - /// [`Dialog`](elements.md#dialog) without closing it. + /// `Dialog` without closing it. Apply, - /// A "Close" button, which should close a [`Dialog`](elements.md#dialog) without looking at values. + /// A "Close" button, which should close a `Dialog` without looking at values. Close, - /// A "Reset" button, which should reset the [`Dialog`](elements.md#dialog) to its initial state. + /// A "Reset" button, which should reset the `Dialog` to its initial state. Reset, /// A "Help" button, which should bring up context related documentation when clicked. Help, @@ -112,7 +112,7 @@ macro_rules! for_each_enums { } /// This enum represents the value of the `dialog-button-role` property which can be added to - /// any element within a [`Dialog`](elements.md#dialog) to put that item in the button row, and its exact position + /// 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 DialogButtonRole { /// This isn't a button meant to go into the bottom row @@ -232,13 +232,13 @@ macro_rules! for_each_enums { //zoom_out, } - /// This enum defines how the source image shall fit into an [`Image`](elements.md#image) element. + /// This enum defines how the source image shall fit into an `Image` element. enum ImageFit { - /// Scales and stretches the source image to fit the width and height of the [`Image`](elements.md#image) element. + /// Scales and stretches the source image to fit the width and height of the `Image` element. Fill, - /// The source image is scaled to fit into the [`Image`](elements.md#image) element's dimension while preserving the aspect ratio. + /// The source image is scaled to fit into the `Image` element's dimension while preserving the aspect ratio. Contain, - /// The source image is scaled to cover into the [`Image`](elements.md#image) element's dimension while preserving the aspect ratio. + /// 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, /// Preserves the size of the source image in logical pixels. @@ -249,21 +249,21 @@ macro_rules! for_each_enums { /// This enum specifies the horizontal alignment of the source image. enum ImageHorizontalAlignment { - /// Aligns the source image at the center of the [`Image`](elements.md#image) element. + /// Aligns the source image at the center of the `Image` element. Center, - /// Aligns the source image at the left of the [`Image`](elements.md#image) element. + /// Aligns the source image at the left of the `Image` element. Left, - /// Aligns the source image at the right of the [`Image`](elements.md#image) element. + /// Aligns the source image at the right of the `Image` element. Right, } /// This enum specifies the vertical alignment of the source image. enum ImageVerticalAlignment { - /// Aligns the source image at the center of the [`Image`](elements.md#image) element. + /// Aligns the source image at the center of the `Image` element. Center, - /// Aligns the source image at the top of the [`Image`](elements.md#image) element. + /// Aligns the source image at the top of the `Image` element. Top, - /// Aligns the source image at the bottom of the [`Image`](elements.md#image) element. + /// Aligns the source image at the bottom of the `Image` element. Bottom, } @@ -279,9 +279,9 @@ macro_rules! for_each_enums { enum ImageTiling { /// The source image will not be tiled. None, - /// The source image will be repeated to fill the [`Image`](elements.md#image) element. + /// The source image will be repeated to fill the `Image` element. Repeat, - /// The source image will be repeated and scaled to fill the [`Image`](elements.md#image) element, ensuring an integer number of repetitions. + /// The source image will be repeated and scaled to fill the `Image` element, ensuring an integer number of repetitions. Round, } @@ -298,9 +298,9 @@ macro_rules! for_each_enums { Decimal, } - /// Enum representing the [alignment](../concepts/layouting.md#alignment) property of a - /// [`HorizontalBox`](../widgets/horizontalbox.md), a [`VerticalBox`](../widgets/verticalbox.md), - /// a [`HorizontalLayout`, or `VerticalLayout`](elements.md#verticallayout-and-horizontallayout). + /// Enum representing the `alignment` property of a + /// `HorizontalBox`, a `VerticalBox`, + /// a `HorizontalLayout`, or `VerticalLayout`. enum LayoutAlignment { /// Use the minimum size of all elements in a layout, distribute remaining space /// based on `*-stretch` among all elements. @@ -344,41 +344,41 @@ macro_rules! for_each_enums { enum AccessibleRole { /// The element isn't accessible. None, - /// The element is a [`Button`](slint-reference:src/language/widgets/button) or behaves like one. + /// The element is a `Button` or behaves like one. Button, - /// The element is a [`CheckBox`](slint-reference:src/language/widgets/checkbox) or behaves like one. + /// The element is a `CheckBox` or behaves like one. Checkbox, - /// The element is a [`ComboBox`](slint-reference:src/language/widgets/combobox) or behaves like one. + /// The element is a `ComboBox` or behaves like one. Combobox, - /// The element is a [`ListView`](slint-reference:src/language/widgets/listview) or behaves like one. + /// The element is a `ListView` or behaves like one. List, - /// The element is a [`Slider`](slint-reference:src/language/widgets/slider) or behaves like one. + /// The element is a `Slider` or behaves like one. Slider, - /// The element is a [`SpinBox`](slint-reference:src/language/widgets/spinbox) or behaves like one. + /// The element is a `SpinBox` or behaves like one. Spinbox, - /// The element is a [`Tab`](slint-reference:src/language/widgets/tabwidget) or behaves like one. + /// The element is a `Tab` or behaves like one. Tab, - /// The element is similar to the tab bar in a [`TabWidget`](slint-reference:src/language/widgets/tabwidget). + /// The element is similar to the tab bar in a `TabWidget`. TabList, - /// The role for a [`Text`](slint-reference:src/language/builtins/elements#text) element. It's automatically applied. + /// The role for a `Text` element. It's automatically applied. Text, - /// The role for a [`TableView`](slint-reference:src/language/widgets/standardtableview ) or behaves like one. + /// The role for a `TableView` or behaves like one. Table, /// The role for a TreeView or behaves like one. (Not provided yet) Tree, - /// The element is a [`ProgressIndicator`](slint-reference:src/language/widgets/progressindicator) or behaves like one. + /// The element is a `ProgressIndicator` or behaves like one. ProgressIndicator, /// The role for widget with editable text such as a - /// [`LineEdit`](slint-reference:src/language/widgets/lineedit) or a [`TextEdit`](slint-reference:src/language/widgets/textedit) + /// `LineEdit` or a `TextEdit` TextInput, - /// The element is a [`Switch`](slint-reference:src/language/widgets/switch) or behaves like one. + /// The element is a `Switch` or behaves like one. Switch, - /// The element is an item in a [`ListView`](slint-reference:src/language/widgets/listview). + /// The element is an item in a `ListView`. ListItem, } /// This enum represents the different values of the `sort-order` property. - /// It's used to sort a [`StandardTableView`](../widgets/standardtableview.md) by a column. + /// It's used to sort a `StandardTableView` by a column. enum SortOrder { /// The column is unsorted. Unsorted, @@ -390,7 +390,7 @@ macro_rules! for_each_enums { Descending, } - /// Represents the orientation of an element or widget such as the [`Slider`](../widgets/slider.md). + /// Represents the orientation of an element or widget such as the `Slider`. enum Orientation { /// Element is oriented horizontally. Horizontal, @@ -432,7 +432,7 @@ macro_rules! for_each_enums { AlwaysOn, } - // This enum describes the close behaviour of [`PopupWindow`](elements.md#popupwindow) + // This enum describes the close behavior of `PopupWindow` enum PopupClosePolicy { /// Closes the `PopupWindow` when user clicks or presses the escape key. CloseOnClick,