mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 22:01:13 +00:00
ComponentInstance show/hide/run
This commit is contained in:
parent
9cc69d73a1
commit
63460c1a24
2 changed files with 24 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue