| Crates.io | dear_mirl_gui |
| lib.rs | dear_mirl_gui |
| version | 2.2.0 |
| created_at | 2025-10-05 18:33:48.518224+00 |
| updated_at | 2025-12-01 10:43:12.98074+00 |
| description | A 'Dear ImGui' inspired RmGui lib for 'Mirl' |
| homepage | |
| repository | https://github.com/Miner3D-Gamer/dear_mirl_gui |
| max_upload_size | |
| id | 1869311 |
| size | 426,311 |
A registry-based, retained-mode, modular GUI library for Mirl, inspired by Dear ImGui.
Or in simpler terms: A debug window crate designed and tailored to work with Mirl. It can be implemented in around 20 lines of code (If you don't use fancy bracket formatting)
It is by no means as good as Dear Imgui or its native rust ports but I have yet to see one of them run smoothly on the cpu.
Default modules are listed at the bottom
Further infos about every available module can be found within the docstring of that module.
How to use:
use mirl::platform::framework_traits::*;
use dear_mirl_gui::module_manager::*;
use dear_mirl_gui::modules;
fn run_loop(buffer: &mut mirl::Buffer, window: &mut dyn mirl::platform::framework_traits::ExtendedFramework, font: &fontdue::Font){
// Important! This formatting will be referenced a lot to avoid duplicate code
set_formatting(dear_mirl_gui::Formatting::default(&font, 20)); // 20 Being the height in pixels
// Define your module - Module struct - Displayed text
let text_display = // v v
register_module(modules::Text::new("Hello World!"));
// If you wanna use multiple guis use the WindowManager, otherwise use the DearMirlGui directly. The .update() functions are identical.
// In the ::<const FAST: bool, const USE_CACHE: bool> I've set to
// - FAST: true -> You probably don't need this but who doesn't enjoy free frame time (at the cost of visual output)
// - USE_CACHE: true -> This is honestly a must, it reduces redraw so much that on flamegraph, the only visible module for the test scene is a single animated widget
let mut window_manager: dear_mirl_gui::WindowManager<true, true> = dear_mirl_gui::WindowManager::new(
Vec::from([
dear_mirl_gui::DearMirlGui::new_simple("Gui Window", (100, 10), &vec![text_display.id()])
])
);
while window.is_open() {
// Clearing last frame
buffer.clear();
// Gathering data
let mouse_scroll = window
.get_mouse_scroll()
.map(mirl::extensions::Tuple2Into::try_tuple_into).unwrap_or_default();
let mouse_pos = window.get_mouse_position();
let pressed_keys = window.get_all_keys_down();
// Using the data to update all/the window(s)
let gui_output = window_manager.update(
mouse_pos,
mouse_scroll,
window.is_mouse_down(mirl::platform::MouseButton::Left),
window.is_mouse_down(mirl::platform::MouseButton::Middle),
window.is_mouse_down(mirl::platform::MouseButton::Right),
&pressed_keys,
0.0, // Delta time - Required for animated components
&None,
);
// Standard drawing routine
// ...
// Automatic drawing, for manual drawing use window_manager.draw()
window_manager.draw_on_buffer(buffer);
// Update framework
window.update(buffer);
}
}
Just remember the reason only the bugs are highlighted: there are way more things that work than things that don't.
The goal of the lib is to be both as extendable as possible (using a single trait) while also providing seamless working conditions for devs. It's built with these purposes in mind: