use crate::{components::Ui, Id, Padding, Rect, Vec2};
pub(super) fn with_region<R>(
ui: &mut Ui<'_>,
scope: Id,
rect: Rect,
clip: Rect,
enabled: bool,
build: impl FnOnce(&mut Ui<'_>) -> R,
) -> R {
ui.region(scope, rect, clip, enabled, build)
}
pub(super) fn safe_content(bounds: Rect, padding: Padding, rounding: f32) -> Rect {
let arc = rounding.max(0.0) * (1.0 - std::f32::consts::FRAC_1_SQRT_2);
let rect = Padding {
left: padding.left.max(arc),
right: padding.right.max(arc),
top: padding.top.max(arc),
bottom: padding.bottom.max(arc),
}
.inset(bounds);
if rect.size().min_element() <= 0.0 {
Rect::from_min_size(bounds.center(), Vec2::ZERO)
} else {
rect
}
}