use waterui_layout::padding::EdgeInsets;
use waterui_layout::safe_area::SafeAreaInsets;
use crate::{IntoFFI, IntoRust, WuiEnv, reactive::WuiComputed};
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct WuiEdgeInsets {
pub top: f32,
pub bottom: f32,
pub leading: f32,
pub trailing: f32,
}
impl IntoFFI for EdgeInsets {
type FFI = WuiEdgeInsets;
fn into_ffi(self) -> Self::FFI {
WuiEdgeInsets {
top: self.top(),
bottom: self.bottom(),
leading: self.leading(),
trailing: self.trailing(),
}
}
}
impl IntoRust for WuiEdgeInsets {
type Rust = EdgeInsets;
unsafe fn into_rust(self) -> Self::Rust {
EdgeInsets::new(self.top, self.bottom, self.leading, self.trailing)
}
}
crate::ffi_computed!(EdgeInsets, WuiEdgeInsets, edge_insets);
crate::ffi_computed_ctor!(EdgeInsets, WuiEdgeInsets, edge_insets);
#[unsafe(no_mangle)]
pub unsafe extern "C" fn waterui_env_install_safe_area(
env: *mut WuiEnv,
signal: *mut WuiComputed<EdgeInsets>,
) {
let env = unsafe { crate::borrow_ffi_mut(env) };
let computed = unsafe { alloc::boxed::Box::from_raw(signal) }.0;
SafeAreaInsets::install(env, computed);
}
crate::ffi_watcher_notify!(EdgeInsets, WuiEdgeInsets, edge_insets);