use crate::ffi;
use crate::ffi::{Rectangle, Vector2};
use crate::rgui::scratch::{scratch_txt, scratch_txt_opt, scratch_txt_slice};
pub trait RaylibGuiContainers {
#[inline]
fn gui_window_box(&mut self, bounds: impl Into<Rectangle>, title: impl AsRef<str>) -> bool {
unsafe { ffi::GuiWindowBox(bounds.into(), scratch_txt(title)) > 0 }
}
#[inline]
fn gui_group_box(&mut self, bounds: impl Into<Rectangle>, text: impl AsRef<str>) -> bool {
unsafe { ffi::GuiGroupBox(bounds.into(), scratch_txt(text)) > 0 }
}
#[inline]
fn gui_line(&mut self, bounds: impl Into<Rectangle>, text: Option<impl AsRef<str>>) -> bool {
unsafe { ffi::GuiLine(bounds.into(), scratch_txt_opt(text)) > 0 }
}
#[inline]
fn gui_panel(&mut self, bounds: impl Into<Rectangle>, text: Option<impl AsRef<str>>) -> bool {
unsafe { ffi::GuiPanel(bounds.into(), scratch_txt_opt(text)) > 0 }
}
#[inline]
fn gui_scroll_panel(
&mut self,
bounds: impl Into<Rectangle>,
text: Option<impl AsRef<str>>,
content: impl Into<Rectangle>,
scroll: impl Into<Vector2>,
view: impl Into<Rectangle>,
) -> (bool, Rectangle, Vector2) {
let mut scroll = scroll.into();
let mut view = view.into();
let result = unsafe {
ffi::GuiScrollPanel(
bounds.into(),
scratch_txt_opt(text),
content.into(),
&mut scroll,
&mut view,
)
};
(result > 0, view, scroll)
}
#[inline]
fn gui_tab_bar(
&mut self,
bounds: impl Into<Rectangle>,
text: &[impl AsRef<str>],
active: &mut i32,
) -> i32 {
let mut ptrs = scratch_txt_slice(text);
unsafe { ffi::GuiTabBar(bounds.into(), ptrs.as_mut_ptr(), ptrs.len() as i32, active) }
}
}