Expand description
§Minifb-UI
This is a crate aiming to make usage of the minifb crate easier than it already is, by providing abstractions and features for easy creation and management of windows and UI elements.
§Example Usage
use minifb_ui;
fn main() {
let mut window = minifb_ui::window::Window::custom("TestWindow", 1920, 1080, false, false);
let font = minifb_ui::ttf::Font::new("assets/Dico.ttf").unwrap();
let text = minifb_ui::ui::text::Text::new(
"The quick brown fox jumps over the lazy dog !\"§$%&/()=?+~*#'-_.:,;<>|",
font,
);
let mut button = minifb_ui::ui::button::Button::default()
.label(
"Press Me!",
minifb_ui::ttf::Font::new("assets/whitrabt.ttf").unwrap(),
20.0
)
.idle_label_col(minifb_ui::color::Color::from(0xCCCCCC))
.hover_label_col(minifb_ui::color::Color::from(0xDDDDDD))
.click_label_col(minifb_ui::color::Color::from(0xAAFFAA))
.label_alignment(minifb_ui::ui::button::Alignment::Center)
.position(100, 100)
.size(150, 33)
.border(2)
.idle_shadow(5, 10)
.hover_shadow(7, 20)
.click_shadow(10, 10)
.border_color(minifb_ui::color::Color::from(0x444444))
.background(minifb_ui::color::Color::from(0x222222))
.hover_bg(minifb_ui::color::Color::from(0x333333));
while window.window.is_open() {
window.clear(&minifb_ui::color::Color::from(0x0));
window.draw_text(
10,
10,
&text,
16.0,
&minifb_ui::color::Color::from(0xFFFFFF),
);
button.draw(&mut window);
window.update();
}
}Re-exports§
pub use color::Color;pub use ttf::Font;pub use window::Window;pub use theme::Theme;pub use anim::Tween;pub use anim::Easing;pub use layout::VStack;pub use layout::HStack;pub use ui::Text;pub use ui::Button;pub use ui::ButtonType;pub use ui::Alignment;pub use ui::Slider;pub use ui::TextInput;pub use ui::Switch;pub use ui::Checkbox;pub use ui::ProgressBar;pub use ui::Dropdown;pub use ui::Tooltip;pub use ui::ScrollArea;pub use ui::Tabs;pub use ui::ContextMenu;
Modules§
- anim
- Provides animation/tween utilities
- color
- Provides the Color RGBA struct
- layout
- Provides layout helpers (VStack, HStack)
- theme
- Provides a Theme struct with dark/light presets
- ttf
- Provides necessary things to work with ttf and otf fonts
- ui
- Provides UI elements you can draw in a Window
- window
- Provides the Window struct and gives you everything you need to create one and draw in it