2023-11-21 07:08:22 -06:00
|
|
|
use std::collections::VecDeque;
|
|
|
|
use glam::Vec2;
|
|
|
|
|
|
|
|
pub mod element;
|
|
|
|
pub mod event;
|
|
|
|
pub mod draw;
|
|
|
|
pub mod backend;
|
|
|
|
pub mod measure;
|
|
|
|
pub mod state;
|
|
|
|
|
|
|
|
use state::StateRepo;
|
|
|
|
|
|
|
|
pub struct KubiUi {
|
|
|
|
mouse_position: Vec2,
|
|
|
|
stateful_state: StateRepo,
|
|
|
|
event_queue: VecDeque<event::UiEvent>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl KubiUi {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
KubiUi {
|
|
|
|
mouse_position: Vec2::ZERO,
|
|
|
|
stateful_state: StateRepo::default(),
|
|
|
|
event_queue: VecDeque::new(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for KubiUi {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self::new()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-21 09:14:26 -06:00
|
|
|
#[derive(Default)]
|
2023-11-21 07:08:22 -06:00
|
|
|
pub enum UiSize {
|
2023-11-21 09:14:26 -06:00
|
|
|
#[default]
|
2023-11-21 07:08:22 -06:00
|
|
|
Auto,
|
|
|
|
Percentage(f32),
|
|
|
|
Pixels(f32),
|
|
|
|
}
|
|
|
|
|
2023-11-21 09:14:26 -06:00
|
|
|
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
2023-11-21 07:08:22 -06:00
|
|
|
pub enum UiDirection {
|
|
|
|
#[default]
|
|
|
|
Vertical,
|
|
|
|
Horizontal,
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LayoutInfo {
|
2023-11-21 09:14:26 -06:00
|
|
|
///Not availabe during measuring step
|
2023-11-21 07:08:22 -06:00
|
|
|
position: Vec2,
|
|
|
|
max_size: Vec2,
|
|
|
|
direction: UiDirection,
|
|
|
|
}
|