use bevy_ecs::prelude::*;
#[derive(Resource, Clone, Copy, Debug, Default)]
pub struct CursorPosition {
pub x: f32,
pub y: f32,
}
#[derive(Resource, Clone, Copy, Debug, Default)]
pub struct MouseInput {
pub left_down: bool,
pub just_pressed: bool,
pub just_released: bool,
pub right_down: bool,
pub scroll: f32,
}
#[derive(Resource, Clone, Copy, Debug)]
pub struct ScreenSize {
pub width: f32,
pub height: f32,
}
impl Default for ScreenSize {
fn default() -> Self {
Self {
width: 800.0,
height: 600.0,
}
}
}
#[derive(Resource, Default)]
pub struct UiDrawList(pub Vec<super::QuadInstance>);
#[derive(Component, Clone, Debug)]
pub struct MenuLayout {
pub panel: Entity,
pub buttons: Vec<Entity>,
pub anchor: super::layout::Anchor,
pub metrics: super::layout::Metrics,
pub offset: (f32, f32),
pub bar: Option<Entity>,
pub close: Option<Entity>,
pub bar_height: f32,
pub submenus: Vec<SubmenuLayout>,
}
#[derive(Clone, Debug)]
pub struct SubmenuLayout {
pub layout: MenuLayout,
pub pointer: Entity,
}
impl MenuLayout {
pub fn entities(&self) -> Vec<Entity> {
let mut entities = vec![self.panel];
entities.extend(self.bar);
entities.extend(self.close);
entities.extend(self.buttons.iter().copied());
for submenu in &self.submenus {
entities.push(submenu.pointer);
entities.extend(submenu.layout.entities());
}
entities
}
}
#[derive(Resource, Clone, Copy, Debug, Default)]
pub struct PointerCapture {
pub over_panel: bool,
}
impl PointerCapture {
pub fn taken(self) -> bool {
self.over_panel
}
}