mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Update the documentation after the changes to ComponentHandle
This commit is contained in:
parent
55f9641b84
commit
503567d84c
2 changed files with 3 additions and 23 deletions
|
@ -42,6 +42,7 @@ pub mod widgets {
|
||||||
pub mod generated_code {
|
pub mod generated_code {
|
||||||
|
|
||||||
use crate::re_exports;
|
use crate::re_exports;
|
||||||
|
use crate::ComponentHandle;
|
||||||
|
|
||||||
/// This an example of the API that is generated for a component in `.60` design markup. This may help you understand
|
/// This an example of the API that is generated for a component in `.60` design markup. This may help you understand
|
||||||
/// what functions you can call and how you can pass data in and out.
|
/// what functions you can call and how you can pass data in and out.
|
||||||
|
@ -57,26 +58,7 @@ pub mod generated_code {
|
||||||
pub struct SampleComponent {}
|
pub struct SampleComponent {}
|
||||||
impl SampleComponent {
|
impl SampleComponent {
|
||||||
/// Creates a new instance that is reference counted and pinned in memory.
|
/// Creates a new instance that is reference counted and pinned in memory.
|
||||||
pub fn new() -> core::pin::Pin<std::rc::Rc<Self>> {
|
pub fn new() -> ComponentHandle<Self> {
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
/// Creates a window on the screen, renders this component in it and spins an event loop to react
|
|
||||||
/// to user input. A typical sequence of creating an instance and showing it may look like this:
|
|
||||||
/// ```ignore
|
|
||||||
/// fn main() {
|
|
||||||
/// let sample = SampleComponent::new();
|
|
||||||
/// /// other setup code here, connect to signal handlers, set property values
|
|
||||||
/// sample.run();
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
pub fn run(self: core::pin::Pin<std::rc::Rc<Self>>) {}
|
|
||||||
/// Returns a weak pointer for an instance of this component. You can use this to in captures of
|
|
||||||
/// closures, for example signal handlers, to access the component later.
|
|
||||||
///
|
|
||||||
/// The return type [`pin_weak::rc::PinWeak`] is exposed from the [`pin-weak`](https://crates.io/crates/pin-weak) crate
|
|
||||||
///
|
|
||||||
/// See the documentation of [`Self::on_hello`] for an example
|
|
||||||
pub fn as_weak(self: core::pin::Pin<std::rc::Rc<Self>>) -> re_exports::PinWeak<Self> {
|
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
/// A getter is generated for each property declared at the root of the component.
|
/// A getter is generated for each property declared at the root of the component.
|
||||||
|
@ -103,7 +85,7 @@ pub mod generated_code {
|
||||||
/// is generated. This is the function that registers the function f as callback when the
|
/// is generated. This is the function that registers the function f as callback when the
|
||||||
/// signal `hello` is emitted. In order to access
|
/// signal `hello` is emitted. In order to access
|
||||||
/// the component in the callback, you'd typically capture a weak reference obtained using
|
/// the component in the callback, you'd typically capture a weak reference obtained using
|
||||||
/// [`SampleComponent::as_weak`]
|
/// [`ComponentHandle::as_weak`]
|
||||||
/// and then upgrade it to a strong reference when the callback is run:
|
/// and then upgrade it to a strong reference when the callback is run:
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// let sample = SampleComponent::new();
|
/// let sample = SampleComponent::new();
|
||||||
|
|
|
@ -98,8 +98,6 @@ This documentation contains a documented generated component: [`docs::generated_
|
||||||
The following associated function are added to the component:
|
The following associated function are added to the component:
|
||||||
|
|
||||||
- [`fn new() -> Pin<Rc<Self>>`](docs::generated_code::SampleComponent::new): to instantiate the component.
|
- [`fn new() -> Pin<Rc<Self>>`](docs::generated_code::SampleComponent::new): to instantiate the component.
|
||||||
- [`fn run(self: Pin<Rc<Self>>)`](docs::generated_code::SampleComponent::run): to show and start the event loop.
|
|
||||||
- [`fn as_weak(self: Pin<Rc<Self>>)`](docs::generated_code::SampleComponent::as_weak): Convenience to create a weak reference pointer.
|
|
||||||
|
|
||||||
For each top-level property
|
For each top-level property
|
||||||
- A setter [`fn set_<property_name>(&self, value: <PropertyType>)`](docs::generated_code::SampleComponent::set_counter)
|
- A setter [`fn set_<property_name>(&self, value: <PropertyType>)`](docs::generated_code::SampleComponent::set_counter)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue