use crate::{mjrContext, mjUI, mjuiDef, mjuiItem, mjuiThemeColor, mjuiThemeSpacing};
pub fn mjui_themeSpacing(ind: i32) -> mjuiThemeSpacing {
unsafe { crate::bindgen::mjui_themeSpacing(ind) }
}
pub fn mjui_themeColor(ind: i32) -> mjuiThemeColor {
unsafe { crate::bindgen::mjui_themeColor(ind) }
}
pub fn mjui_add(ui: &mut mjUI, def: impl AsRef<[mjuiDef]>) {
let def: &[mjuiDef] = def.as_ref();
if def.last().unwrap().type_() == -1 {
unsafe { crate::bindgen::mjui_add(ui, def.as_ptr()) }
} else {
#[cold]
#[inline(never)]
fn with_dynamically_addiing_terminator(ui: &mut mjUI, def: &[mjuiDef]) {
let mut def = def.to_vec();
def.push(mjuiDef { type_: -1, name: [0; crate::mjMAXUINAME], state: 0, pdata: std::ptr::null_mut(), other: [0; crate::mjMAXUITEXT], otherint: 0 });
unsafe { crate::bindgen::mjui_add(ui, def.as_ptr()); }
}
with_dynamically_addiing_terminator(ui, def);
}
}
pub fn mjui_addToSection(
ui: &mut mjUI,
sect: i32,
def: impl AsRef<[mjuiDef]>,
) {
let def: &[mjuiDef] = def.as_ref();
if def.last().unwrap().type_() == -1 {
unsafe { crate::bindgen::mjui_addToSection(ui, sect, def.as_ptr()) }
} else {
#[cold]
#[inline(never)]
fn with_dynamically_addiing_terminator(
ui: &mut mjUI,
sect: i32,
def: &[mjuiDef],
) {
let mut def = def.to_vec();
def.push(mjuiDef { type_: -1, name: [0; crate::mjMAXUINAME], state: 0, pdata: std::ptr::null_mut(), other: [0; crate::mjMAXUITEXT], otherint: 0 });
unsafe { crate::bindgen::mjui_addToSection(ui, sect, def.as_ptr()); }
}
with_dynamically_addiing_terminator(ui, sect, def);
}
}
pub fn mjui_resize(ui: &mut mjUI, con: &mjrContext) {
unsafe { crate::bindgen::mjui_resize(ui, con.as_ptr()) }
}
pub fn mjui_update(
section: Option<u32>,
item: Option<u32>,
ui: &mjUI,
state: &crate::mjuiState,
con: &mjrContext,
) {
unsafe {
crate::bindgen::mjui_update(
section.map_or(-1, |s| s as i32),
item.map_or(-1, |s| s as i32),
ui,
state,
con.as_ptr(),
)
}
}
pub fn mjui_event<'ui>(
ui: &'ui mut mjUI,
state: &mut crate::mjuiState,
con: &mjrContext,
) -> Option<&'ui mut mjuiItem> {
let item = unsafe { crate::bindgen::mjui_event(ui, state, con.as_ptr()) };
if item.is_null() {None} else {Some(unsafe { &mut *item })}
}
pub fn mjui_render(ui: &mut mjUI, state: &crate::mjuiState, con: &mjrContext) {
unsafe { crate::bindgen::mjui_render(ui, state, con.as_ptr()) }
}