use egui::Vec2;
#[derive(Debug, Clone)]
pub struct LayoutContext {
pub screen_size: Vec2,
pub scale_factor: f32,
}
impl LayoutContext {
pub fn from_egui(ctx: &egui::Context) -> Self {
let screen = ctx.input(|i| i.viewport().outer_rect.unwrap_or(egui::Rect::EVERYTHING));
Self {
screen_size: screen.size(),
scale_factor: ctx.pixels_per_point(),
}
}
pub fn physical_width(&self) -> f32 {
self.screen_size.x
}
pub fn physical_height(&self) -> f32 {
self.screen_size.y
}
pub fn min_touch_target(&self) -> f32 {
24.0
}
}