minifb_ui/lib.rs
1//! # Minifb-UI
2//!
3//! This is a crate aiming to make usage of the minifb crate easier than it already is,
4//! by providing abstractions and features for easy creation and management of windows
5//! and UI elements.
6//!
7//! # Example Usage
8//!
9//! ```rust
10//! use minifb_ui;
11//!
12//! fn main() {
13//! let mut window = minifb_ui::window::Window::custom("TestWindow", 1920, 1080, false, false);
14//!
15//! let font = minifb_ui::ttf::Font::new("assets/Dico.ttf");
16//! let text = minifb_ui::ui::text::Text::new(
17//! "The quick brown fox jumps over the lazy dog !\"ยง$%&/()=?+~*#'-_.:,;<>|",
18//! font,
19//! );
20//!
21//! let mut button = minifb_ui::ui::button::Button::default()
22//! .label(
23//! "Press Me!",
24//! minifb_ui::ttf::Font::new("assets/whitrabt.ttf"),
25//! 20.0
26//! )
27//! .idle_label_col(minifb_ui::color::Color::from(0xCCCCCC))
28//! .hover_label_col(minifb_ui::color::Color::from(0xDDDDDD))
29//! .click_label_col(minifb_ui::color::Color::from(0xAAFFAA))
30//! .label_alignment(minifb_ui::ui::button::Alignment::Center)
31//! .position(100, 100)
32//! .size(150, 33)
33//! .border(2)
34//! .idle_shadow(5, 10)
35//! .hover_shadow(7, 20)
36//! .click_shadow(10, 10)
37//! .border_color(minifb_ui::color::Color::from(0x444444))
38//! .background(minifb_ui::color::Color::from(0x222222))
39//! .hover_bg(minifb_ui::color::Color::from(0x333333));
40//!
41//! while window.window.is_open() {
42//! window.clear(&minifb_ui::color::Color::from(0x0));
43//! window.draw_text(
44//! 10,
45//! 10,
46//! &text,
47//! 16.0,
48//! &minifb_ui::color::Color::from(0xFFFFFF),
49//! );
50//! button.draw(&mut window);
51//! window.update();
52//! }
53//! }
54//! ```
55
56/// Provides necessary things to work with ttf and otf fonts
57pub mod ttf;
58/// Provides the Window struct and gives you everything you need to create one and draw in it
59pub mod window;
60/// Provides the Color RGBA struct
61pub mod color;
62/// Provides UI elements you can draw in a Window
63pub mod ui;
64
65pub use minifb::{Key, KeyRepeat};