mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 22:31:14 +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(ComponentInstance &) = delete;
|
||||||
ComponentInstance &operator=(ComponentInstance &) = delete;
|
ComponentInstance &operator=(ComponentInstance &) = delete;
|
||||||
public:
|
public:
|
||||||
void show() const;
|
void show() const {
|
||||||
void hide() const;
|
cbindgen_private::sixtyfps_interpreter_component_instance_show(&inner, true);
|
||||||
void run() const;
|
}
|
||||||
|
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 {
|
bool set_property(std::string_view name, const Value &value) const {
|
||||||
cbindgen_private::Slice<uint8_t> name_view {
|
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()
|
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]
|
#[vtable::vtable]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ModelAdaptorVTable {
|
pub struct ModelAdaptorVTable {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue