diff --git a/api/cpp/docs/generated_code.md b/api/cpp/docs/generated_code.md index 3d0ab314a..b958fd507 100644 --- a/api/cpp/docs/generated_code.md +++ b/api/cpp/docs/generated_code.md @@ -115,7 +115,7 @@ similar to API that's created for your `.slint` component. For example the following `.slint` markup defines a global `Logic` singleton that's also exported: ```slint,ignore -export global Logic := { +export global Logic { callback to_uppercase(string) -> string; } ``` diff --git a/api/cpp/docs/types.md b/api/cpp/docs/types.md index b297592e7..e09232108 100644 --- a/api/cpp/docs/types.md +++ b/api/cpp/docs/types.md @@ -31,7 +31,7 @@ code. For example, this `struct` in a `.slint` file ```slint,ignore -export struct MyStruct := { +export struct MyStruct { foo: int, bar: string, } diff --git a/api/cpp/include/slint_interpreter.h b/api/cpp/include/slint_interpreter.h index acf9220c9..d94b121e2 100644 --- a/api/cpp/include/slint_interpreter.h +++ b/api/cpp/include/slint_interpreter.h @@ -729,8 +729,8 @@ public: /// /// Example: imagine the .slint file contains the given global: /// ```slint,no-preview - /// export global Logic := { - /// callback to_uppercase(string) -> string; + /// export global Logic { + /// pure callback to_uppercase(string) -> string; /// } /// ``` /// Then you can set the callback handler diff --git a/api/rs/slint/lib.rs b/api/rs/slint/lib.rs index 86eb2f37b..d6dce6d07 100644 --- a/api/rs/slint/lib.rs +++ b/api/rs/slint/lib.rs @@ -114,7 +114,7 @@ as a struct with the same name as the component. For example, if you have ```slint,no-preview -export MyComponent := Window { /*...*/ } +export component MyComponent inherits Window { /*...*/ } ``` in the .slint file, it will create a @@ -189,7 +189,7 @@ The follow table summarizes the entire mapping: For user defined structures in the .slint, an extra struct is generated. For example, if the `.slint` contains ```slint,ignore -export struct MyStruct := { +export struct MyStruct { foo: int, bar: string, } diff --git a/docs/language/src/recipes/recipes.md b/docs/language/src/recipes/recipes.md index aa1453a55..c19228dc0 100644 --- a/docs/language/src/recipes/recipes.md +++ b/docs/language/src/recipes/recipes.md @@ -443,8 +443,8 @@ In Rust you can set the callback like this: slint::slint!{ import { HorizontalBox, VerticalBox, LineEdit } from "std-widgets.slint"; -export global Logic := { - callback to-upper-case(string) -> string; +export global Logic { + pure callback to-upper-case(string) -> string; // You can collect other global properties here } @@ -546,9 +546,9 @@ This example uses [gettext-rs](https://docs.rs/gettext-rs): slint::slint!{ import { HorizontalBox , Button } from "std-widgets.slint"; -export global Tr := { +export global Tr { // Do the translation of the first argument, with an array of string as supstitution - callback gettext(string, [string]) -> string; + pure callback gettext(string, [string]) -> string; } Example := Window { diff --git a/docs/language/src/reference/globals.md b/docs/language/src/reference/globals.md index 6ffd4a902..1d555e0fb 100644 --- a/docs/language/src/reference/globals.md +++ b/docs/language/src/reference/globals.md @@ -1,6 +1,6 @@ # Global Singletons -Declare a global singleton with `global Name := { /* .. properties or callbacks .. */ }` to +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`. For example, this can be useful for a common color palette: @@ -35,12 +35,12 @@ export global Logic { ```rust slint::slint!{ -export global Logic := { - property the-value; - callback magic-operation(int) -> int; +export global Logic { + in-out property the-value; + pure callback magic-operation(int) -> int; } -export App := Window { +export component App inherits Window { // ... } } diff --git a/internal/core/api.rs b/internal/core/api.rs index c77020cc2..24d776219 100644 --- a/internal/core/api.rs +++ b/internal/core/api.rs @@ -492,12 +492,12 @@ pub use crate::SharedString; /// ```rust /// # i_slint_backend_testing::init(); /// slint::slint!{ -/// export global Palette := { -/// property foreground-color; -/// property background-color; +/// export global Palette { +/// in property foreground-color; +/// in property background-color; /// } /// -/// export App := Window { +/// export component App inherits Window { /// background: Palette.background-color; /// Text { /// text: "Hello"; @@ -647,7 +647,7 @@ mod weak_handle { /// # Example /// ```rust /// # i_slint_backend_testing::init(); - /// slint::slint! { MyApp := Window { property foo; /* ... */ } } + /// slint::slint! { export component MyApp inherits Window { in property foo; /* ... */ } } /// let handle = MyApp::new().unwrap(); /// let handle_weak = handle.as_weak(); /// let thread = std::thread::spawn(move || { @@ -701,7 +701,7 @@ pub use weak_handle::*; /// /// # Example /// ```rust -/// slint::slint! { MyApp := Window { property foo; /* ... */ } } +/// slint::slint! { export component MyApp inherits Window { in property foo; /* ... */ } } /// # i_slint_backend_testing::init(); /// let handle = MyApp::new().unwrap(); /// let handle_weak = handle.as_weak(); diff --git a/internal/interpreter/api.rs b/internal/interpreter/api.rs index 63515c380..165452360 100644 --- a/internal/interpreter/api.rs +++ b/internal/interpreter/api.rs @@ -1390,7 +1390,7 @@ fn call_functions() { let definition = spin_on::spin_on( compiler.build_from_source( r#" - export global Gl := { + export global Gl { out property q; public function foo-bar(a-a: string, b-b:int) -> string { q = a-a; @@ -1436,7 +1436,7 @@ fn component_definition_struct_properties() { let comp_def = spin_on::spin_on( compiler.build_from_source( r#" - export struct Settings := { + export struct Settings { string_value: string, } export Dummy := Rectangle {