mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 22:01:13 +00:00
Create a new crate to expose the C++
This commit is contained in:
parent
705b76d2bd
commit
0e351de1a6
10 changed files with 88 additions and 54 deletions
|
@ -77,37 +77,3 @@ pub fn use_modules() {
|
|||
#[cfg(feature = "sixtyfps-rendering-backend-gl")]
|
||||
sixtyfps_rendering_backend_gl::use_modules();
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub mod ffi {
|
||||
use sixtyfps_corelib::window::ffi::ComponentWindowOpaque;
|
||||
use sixtyfps_corelib::window::ComponentWindow;
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sixtyfps_component_window_init(out: *mut ComponentWindowOpaque) {
|
||||
assert_eq!(
|
||||
core::mem::size_of::<ComponentWindow>(),
|
||||
core::mem::size_of::<ComponentWindowOpaque>()
|
||||
);
|
||||
core::ptr::write(out as *mut ComponentWindow, crate::backend().create_window());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sixtyfps_run_event_loop() {
|
||||
crate::backend().run_event_loop();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn sixtyfps_register_font_from_path(
|
||||
path: &sixtyfps_corelib::SharedString,
|
||||
error_str: *mut sixtyfps_corelib::SharedString,
|
||||
) {
|
||||
core::ptr::write(
|
||||
error_str,
|
||||
match crate::backend().register_font_from_path(std::path::Path::new(path.as_str())) {
|
||||
Ok(()) => Default::default(),
|
||||
Err(err) => err.to_string().into(),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue