use crate::Ui;
use crate::sys;
fn assert_finite_f32(caller: &str, name: &str, value: f32) {
assert!(value.is_finite(), "{caller} {name} must be finite");
}
fn assert_unit_ratio(caller: &str, name: &str, value: f32) {
assert_finite_f32(caller, name, value);
assert!(
(0.0..=1.0).contains(&value),
"{caller} {name} must be between 0.0 and 1.0"
);
}
impl Ui {
#[doc(alias = "GetScrollX")]
pub fn scroll_x(&self) -> f32 {
unsafe { sys::igGetScrollX() }
}
#[doc(alias = "GetScrollY")]
pub fn scroll_y(&self) -> f32 {
unsafe { sys::igGetScrollY() }
}
#[doc(alias = "GetScrollMaxX")]
pub fn scroll_max_x(&self) -> f32 {
unsafe { sys::igGetScrollMaxX() }
}
#[doc(alias = "GetScrollMaxY")]
pub fn scroll_max_y(&self) -> f32 {
unsafe { sys::igGetScrollMaxY() }
}
#[doc(alias = "SetScrollX")]
pub fn set_scroll_x(&self, scroll_x: f32) {
assert_finite_f32("Ui::set_scroll_x()", "scroll_x", scroll_x);
unsafe {
sys::igSetScrollX_Float(scroll_x);
}
}
#[doc(alias = "SetScrollY")]
pub fn set_scroll_y(&self, scroll_y: f32) {
assert_finite_f32("Ui::set_scroll_y()", "scroll_y", scroll_y);
unsafe {
sys::igSetScrollY_Float(scroll_y);
}
}
#[doc(alias = "SetScrollFromPosX")]
pub fn set_scroll_from_pos_x(&self, local_x: f32, center_x_ratio: f32) {
assert_finite_f32("Ui::set_scroll_from_pos_x()", "local_x", local_x);
assert_unit_ratio(
"Ui::set_scroll_from_pos_x()",
"center_x_ratio",
center_x_ratio,
);
unsafe {
sys::igSetScrollFromPosX_Float(local_x, center_x_ratio);
}
}
#[doc(alias = "SetScrollFromPosY")]
pub fn set_scroll_from_pos_y(&self, local_y: f32, center_y_ratio: f32) {
assert_finite_f32("Ui::set_scroll_from_pos_y()", "local_y", local_y);
assert_unit_ratio(
"Ui::set_scroll_from_pos_y()",
"center_y_ratio",
center_y_ratio,
);
unsafe {
sys::igSetScrollFromPosY_Float(local_y, center_y_ratio);
}
}
#[doc(alias = "SetScrollHereX")]
pub fn set_scroll_here_x(&self, center_x_ratio: f32) {
assert_unit_ratio("Ui::set_scroll_here_x()", "center_x_ratio", center_x_ratio);
unsafe {
sys::igSetScrollHereX(center_x_ratio);
}
}
#[doc(alias = "SetScrollHereY")]
pub fn set_scroll_here_y(&self, center_y_ratio: f32) {
assert_unit_ratio("Ui::set_scroll_here_y()", "center_y_ratio", center_y_ratio);
unsafe {
sys::igSetScrollHereY(center_y_ratio);
}
}
}