mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 22:54:36 +00:00
Add a brief overview section to the C++ interpreter namespace
This mirrors the Rust module side. Unfortunately the code examples aren't rendered correctly :(
This commit is contained in:
parent
eab8f733fc
commit
140de87351
2 changed files with 49 additions and 3 deletions
|
@ -30,6 +30,52 @@ struct ErasedComponentBox : vtable::Dyn
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The types in this namespace allow you to load a .60 file at runtime and show its UI.
|
||||||
|
///
|
||||||
|
/// You only need to use thyem if you do not want to use pre-compiled .60 code, which is
|
||||||
|
/// the normal way to use SixtyFPS.
|
||||||
|
///
|
||||||
|
/// The entry point for this namespace is the \ref ComponentCompiler, which you can
|
||||||
|
/// use to create \ref ComponentDefinition instances with the ComponentCompiler::build_from_source()
|
||||||
|
/// or ComponentCompiler::build_from_path() functions.
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
///
|
||||||
|
/// This example loads a `.60` dynamically from a path:
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #include <sixtyfps_interpreter.h>
|
||||||
|
///
|
||||||
|
/// sixtyfps::interpreter::ComponentCompiler compiler;
|
||||||
|
/// auto definition =
|
||||||
|
/// compiler.build_from_path("hello.60");
|
||||||
|
/// if (definition) {
|
||||||
|
/// auto instance = definition->create();
|
||||||
|
/// instance->run();
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// This example loads a `.60` from a string and set some properties:
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #include <sixtyfps_interpreter.h>
|
||||||
|
///
|
||||||
|
/// std::string code = R"(
|
||||||
|
/// MyWin := Window {
|
||||||
|
/// property <string> my_name;
|
||||||
|
/// Text {
|
||||||
|
/// text: "Hello, " + my_name;
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// )";
|
||||||
|
///
|
||||||
|
/// sixtyfps::interpreter::ComponentCompiler compiler;
|
||||||
|
/// auto definition =
|
||||||
|
/// compiler.build_from_source(code, "");
|
||||||
|
/// auto instance = definition->create();
|
||||||
|
/// instance->set_property("my_name",
|
||||||
|
/// sixtyfps::interpreter::Value(sixtyfps::SharedString("World"))); instance->run();
|
||||||
|
/// ```
|
||||||
namespace sixtyfps::interpreter {
|
namespace sixtyfps::interpreter {
|
||||||
|
|
||||||
class Value;
|
class Value;
|
||||||
|
|
|
@ -10,7 +10,7 @@ LICENSE END */
|
||||||
/*!
|
/*!
|
||||||
# SixtyFPS interpreter library
|
# SixtyFPS interpreter library
|
||||||
|
|
||||||
With this crate, you can load a .60 at runtime and show its UI.
|
With this crate, you can load a .60 file at runtime and show its UI.
|
||||||
|
|
||||||
You only need to use this crate if you do not want to use pre-compiled .60
|
You only need to use this crate if you do not want to use pre-compiled .60
|
||||||
code, which is the normal way to use SixtyFPS, using the `sixtyfps` crate
|
code, which is the normal way to use SixtyFPS, using the `sixtyfps` crate
|
||||||
|
@ -27,7 +27,7 @@ executor, such as the one provided by the `spin_on` crate
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
This example load a `.60` dynamically from a path and show error if any
|
This example loads a `.60` dynamically from a path and show errors if any:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler};
|
use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler};
|
||||||
|
@ -43,7 +43,7 @@ if let Some(definition) = definition {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This example load a `.60` from a string and set some properties
|
This example load a `.60` from a string and set some properties:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
use sixtyfps_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue