Struct sixtyfps::docs::generated_code::SampleComponent[][src]

pub struct SampleComponent {}
Expand description

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. This is the source code:

SampleComponent := Window {
    property<int> counter;
    property<string> user_name;
    callback hello;
    /// ... maybe more elements here
}

Implementations

Creates a new instance that is reference counted and pinned in memory.

A getter is generated for each property declared at the root of the component. In this case, this is the getter that returns the value of the counter property declared in the .60 design markup.

A setter is generated for each property declared at the root of the component, In this case, this is the setter that sets the value of the counter property declared in the .60 design markup.

Returns the value of the user_name property declared in the .60 design markup.

Assigns a new value to the user_name property.

For each callback declared at the root of the component, a function to call that callback is generated. This is the function that calls the hello callback declared in the .60 design markup.

For each callback declared at the root of the component, a function connect to that callback is generated. This is the function that registers the function f as callback when the callback hello is emitted. In order to access the component in the callback, you’d typically capture a weak reference obtained using ComponentHandle::as_weak and then upgrade it to a strong reference when the callback is run:

    let sample = SampleComponent::new();
    let sample_weak = sample.as_weak();
    sample.as_ref().on_hello(move || {
        let sample = sample_weak.unwrap();
        sample.as_ref().set_counter(42);
    });

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns a new weak pointer.

Returns a clone of this handle that’s a strong reference.

Marks the window of this component to be shown on the screen. This registers the window with the windowing system. In order to react to events from the windowing system, such as draw requests or mouse/touch input, it is still necessary to spin the event loop, using crate::run_event_loop.

Marks the window of this component to be hidden on the screen. This de-registers the window from the windowing system and it will not receive any further events.

This is a convenience function that first calls Self::show, followed by crate::run_event_loop() and Self::hide.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.