use teksilo_canvas::{Rect, Size};
use crate::arena::WidgetArena;
use crate::widget_id::WidgetId;
pub struct PaintContext<'a> {
pub theme: &'a crate::styles::Theme,
pub scale_factor: f32,
pub text_scale: f32,
pub layout_direction: crate::environment::LayoutDirection,
pub effective_enabled: bool,
pub prefers_high_contrast: bool,
pub prefers_reduced_motion: bool,
pub prefers_large_text: bool,
pub window_active: bool,
pub clip_bounds: Option<Rect>,
}
pub struct WidgetTreeView<'a> {
arena: &'a WidgetArena,
overlay_rects: &'a [Rect],
}
impl<'a> WidgetTreeView<'a> {
pub(crate) fn new(arena: &'a WidgetArena, overlay_rects: &'a [Rect]) -> Self {
Self {
arena,
overlay_rects,
}
}
pub fn bounds(&self, id: WidgetId) -> Rect {
self.arena.bounds(id)
}
pub fn children(&self, id: WidgetId) -> &[WidgetId] {
self.arena.children(id)
}
pub fn is_gesture_dead_zone(&self, id: WidgetId) -> bool {
self.arena
.get(id)
.map(|n| n.gesture_dead_zone)
.unwrap_or(false)
}
pub fn is_active(&self, id: WidgetId) -> bool {
self.arena.is_active(id)
}
pub fn overlay_rects(&self) -> &[Rect] {
self.overlay_rects
}
}
#[derive(Debug, Clone, Copy)]
pub struct WidgetPlacement {
pub id: WidgetId,
pub origin: teksilo_canvas::Point,
pub size: Size,
}