#immediate-mode #widgets #ui #macroquad #setup #dear-imgui

bin+lib amberwindow

An easy to use ImmediateMode gui library for Rust

23 releases

0.3.61 Jul 16, 2024
0.3.14 Oct 4, 2024
0.3.8 Sep 5, 2024
0.3.7 Jul 19, 2024
0.1.2 Jul 1, 2024

#150 in GUI

Download history 54/week @ 2024-07-22 98/week @ 2024-09-02 5/week @ 2024-09-16 67/week @ 2024-09-23 664/week @ 2024-09-30 64/week @ 2024-10-07 61/week @ 2024-10-14 19/week @ 2024-11-04

87 downloads per month

MIT license

195KB
2.5K SLoC

AmberWindow

'amberwindow' is an easy to use ImmediateMode gui library for Rust.

Uses macroquad as a backend. Inspired by libraries like DearImgui.

Supported Platforms

  • Windows / PC
  • Linux (untested)
  • MacOS (untested)

Features

  • Easy to setup
  • Getting windows working is easy
  • Many pre-made widgets to use

Examples

Macroquad App

use macroquad::prelude::*;

#[macroquad::main("MACROQUAD")]
async fn main() {
    loop { next_frame().await }
}

Hello Window

use amberwindow::WindowManager;
use macroquad::prelude::*;

#[macroquad::main("Hello")]
async fn main() {
    let mut windows = WindowManager::new();
    loop {
        windows.begin("");
        windows.end_windows();
        next_frame().await;
    }
}

Hello World

use amberwindow::WindowManager;
use macroquad::prelude::*;

#[macroquad::main("Hello")]
async fn main() {
    let mut windows = WindowManager::new();

    loop {
        if let Some(win) = windows.begin("") {
            win.Text("Hello world", WHITE);
        }

        windows.end_windows();
        next_frame().await;
    }
}

For all of you who love dearimgui's styling, using the custom styling features in AmberWindow can let you "remake" dearimgui.

(Add this to satisfy all the style imports.)

use amberwindow::*;
if let Some(win) = windows.begin("") {
    win.name("Debug");
    win.Text("Hello, world 123", WHITE);
    win.Button("Save");
    win.Slider_float(0., 100., None, vec2(win.rect.w - 20.0, 15f32));
    win.Checkbox("Auto update", false);
    win.button_style(ButtonStyle{
        font: None,
        color: WHITE,
        bg_color: Color::from_hex(0x274972),
        hover_bg_color: Color::from_hex(0x496994),
        pressed_bg_color: Color::from_hex(0x274972)
    });
    win.slider_style(SliderStyle{
        color: WHITE,
        bg_color: Color::from_hex(0x163861),
        hover_bg_color: Color::from_hex(0x274972),
        value_color: SKYBLUE,
    });
    win.style(WindowStyle{
        font: None,
        bg_color: Color::from_hex(0x151617),
        tb_color: Color::from_hex(0x294a7a),
        deselected_tb_color: BLACK,
        border_color: BLANK,
        selected_border_color: Color::new(1.,1.,1., 0.7),
        title_color: WHITE,
        scale_color: Color::from_hex(0x294a7a),
        minimize_color: WHITE,
        close_color: WHITE
    });
    for i in win.widgets.iter_mut() {
        if let Widget::Checkbox(i) = i {
            i.bg_color = Color::from_hex(0x385884);
        }
    }
}

It will make this: https://i.imgur.com/du1M7wV.png (Without the crab image.)

Dependencies

~12MB
~265K SLoC