ComponentInstance show/hide/run

This commit is contained in:
Olivier Goffart 2021-03-18 16:37:01 +01:00
parent 9cc69d73a1
commit 63460c1a24
2 changed files with 24 additions and 3 deletions

View file

@ -355,9 +355,17 @@ class ComponentInstance {
ComponentInstance(ComponentInstance &) = delete;
ComponentInstance &operator=(ComponentInstance &) = delete;
public:
void show() const;
void hide() const;
void run() const;
void show() const {
cbindgen_private::sixtyfps_interpreter_component_instance_show(&inner, true);
}
void hide() const {
cbindgen_private::sixtyfps_interpreter_component_instance_show(&inner, false);
}
void run() const {
show();
cbindgen_private::sixtyfps_run_event_loop();
hide();
}
bool set_property(std::string_view name, const Value &value) const {
cbindgen_private::Slice<uint8_t> name_view {

View file

@ -1131,6 +1131,19 @@ pub(crate) mod ffi {
inst.set_callback(std::str::from_utf8(&name).unwrap(), callback).is_ok()
}
/// Show or hide
#[no_mangle]
pub extern "C" fn sixtyfps_interpreter_component_instance_show(
inst: &ComponentInstance,
is_visible: bool,
) {
if is_visible {
inst.show();
} else {
inst.hide();
}
}
#[vtable::vtable]
#[repr(C)]
pub struct ModelAdaptorVTable {