Trait sixtyfps::Global [−][src]
Expand description
This trait is used to obtain references to global singletons exported in .60
markup. Alternatively, you can use ComponentHandle::global
to obtain access.
This trait is implemented by the compiler for each global singleton that’s exported.
Example
The following example of .60
markup defines a global singleton called Palette
, exports
it and modifies it from Rust code:
sixtyfps::sixtyfps!{
export global Palette := {
property<color> foreground-color;
property<color> background-color;
}
export App := Window {
background: Palette.background-color;
Text {
text: "Hello";
color: Palette.foreground-color;
}
// ...
}
}
let app = App::new();
app.global::<Palette>().set_background_color(sixtyfps::Color::from_rgb_u8(0, 0, 0));
// alternate way to access the global singleton:
Palette::get(&app).set_foreground_color(sixtyfps::Color::from_rgb_u8(255, 255, 255));
See also the language reference for global singletons for more information.