use nami::Computed;
use waterui_core::Environment;
use waterui_core::interaction::Disabled;
pub(crate) fn widget_disabled(env: &Environment) -> Computed<bool> {
env.get::<Disabled>()
.map_or_else(|| Computed::constant(false), |scope| scope.signal().clone())
}
pub(crate) fn inset_rect(rect: vello::kurbo::Rect, dx: f64, dy: f64) -> vello::kurbo::Rect {
vello::kurbo::Rect::new(
rect.x0 + dx,
rect.y0 + dy,
(rect.x1 - dx).max(rect.x0 + dx),
(rect.y1 - dy).max(rect.y0 + dy),
)
}
pub(crate) fn label_beside_control_bounds(
x0: f64,
x1: f64,
row: vello::kurbo::Rect,
control: vello::kurbo::Rect,
label_height: f64,
) -> vello::kurbo::Rect {
let height = label_height.min(row.height());
let y0 = (control.y0 + control.y1 - height) * 0.5;
vello::kurbo::Rect::new(x0, y0, x1, y0 + height)
}