hUI/hui/src/lib.rs

47 lines
1.2 KiB
Rust
Raw Normal View History

2024-02-17 16:06:11 -06:00
#![doc(html_logo_url = "https://raw.githubusercontent.com/griffi-gh/hui/master/.assets/hui.svg")]
//!
//! Simple UI library for games and other interactive applications
//!
//! # Features
#![doc = document_features::document_features!()]
#![forbid(unsafe_code)]
#![forbid(unsafe_op_in_unsafe_fn)]
2024-02-17 14:43:46 -06:00
2024-02-20 10:49:44 -06:00
mod instance;
2024-02-20 10:30:26 -06:00
pub mod layout;
pub mod rectangle;
2024-02-17 14:43:46 -06:00
pub mod element;
pub mod event;
2024-02-19 12:40:18 -06:00
pub mod input;
2024-02-17 14:43:46 -06:00
pub mod draw;
pub mod measure;
pub mod state;
pub mod text;
2024-02-20 10:49:44 -06:00
pub use instance::UiInstance;
2024-02-17 14:43:46 -06:00
pub trait IfModified<T> {
fn if_modified(&self) -> Option<&T>;
}
2024-02-20 10:30:26 -06:00
#[allow(deprecated)]
#[deprecated(since = "0.1.0-alpha.3", note = "will be removed in the next release")]
2024-02-20 10:49:44 -06:00
pub struct ElementList(Vec<Box<dyn element::UiElement>>);
2024-02-17 14:43:46 -06:00
2024-02-20 10:30:26 -06:00
#[allow(deprecated)]
#[deprecated(since = "0.1.0-alpha.3", note = "will be removed in the next release")]
2024-02-17 14:43:46 -06:00
impl ElementList {
2024-02-20 10:49:44 -06:00
pub fn add(&mut self, element: impl element::UiElement + 'static) {
2024-02-17 14:43:46 -06:00
self.0.push(Box::new(element));
}
}
2024-02-20 10:30:26 -06:00
#[allow(deprecated)]
#[deprecated(since = "0.1.0-alpha.3", note = "will be removed in the next release")]
2024-02-20 10:49:44 -06:00
pub fn elements(f: impl FnOnce(&mut ElementList)) -> Vec<Box<dyn element::UiElement>> {
2024-02-17 14:43:46 -06:00
let mut elements = ElementList(Vec::new());
f(&mut elements);
elements.0
}