#vulkan #graphics #gui #framework #interface

nightly basalt

A window/ui framework built upon vulkan

21 releases (5 breaking)

0.5.0 Oct 7, 2019
0.4.2 Sep 10, 2019
0.1.0 Jul 28, 2019

#74 in GUI

Download history 95/week @ 2019-06-24 5/week @ 2019-07-01 26/week @ 2019-07-08 1/week @ 2019-07-15 53/week @ 2019-07-22 17/week @ 2019-07-29 90/week @ 2019-08-05 26/week @ 2019-08-12 11/week @ 2019-08-19 63/week @ 2019-08-26 85/week @ 2019-09-02 69/week @ 2019-09-09 228/week @ 2019-09-16 70/week @ 2019-09-23 57/week @ 2019-09-30

265 downloads per month
Used in 1 crate

MIT license

570KB
17K SLoC

Basalt is a window/ui framework for building desktop applications or providing a ui a top other applications. In the backend vulkano which is a safe rust wrapper around vulkan. Basalt provides window creation, advance input handling, and along with the ui itself. The UI is based on the idea of a Bin. A Bin can have borders, backgrounds, and text and is the the fundamental element for building any ui widget/element. Currently the amount of provided widgets/elements is limited.

The project is very much a work in progress and is what I work on the side. Some issues exists, but nothing preventing you from creating a full-fledged app!

extern crate basalt;

use basalt::Basalt;
use basalt::interface::bin::{self,BinStyle};
use basalt::input::MouseButton;
use std::sync::Arc;

fn main() {
	let basalt = Basalt::new(
		basalt::Options::default()
			.ignore_dpi(true)
			.window_size(300, 300)
			.title("Basalt")
	).unwrap();
	
	basalt.spawn_app_loop();
	
	let background = basalt.interface_ref().new_bin();
	
	background.style_update(BinStyle {
		pos_from_t: Some(0.0),
		pos_from_b: Some(0.0),
		pos_from_l: Some(0.0),
		pos_from_r: Some(0.0),
		back_color: Some(bin::Color::srgb_hex("f0f0f0")),
		.. BinStyle::default()
	});
	
	let button = basalt.interface_ref().new_bin();
	background.add_child(button.clone());
	
	button.style_update(BinStyle {
		position_t: Some(bin::PositionTy::FromParent),
		pos_from_t: Some(75.0),
		pos_from_l: Some(75.0),
		width: Some(75.0),
		height: Some(30.0),
		back_color: Some(bin::Color::srgb_hex("c0c0c0")),
		border_size_t: Some(1.0),
		border_size_b: Some(1.0),
		border_size_l: Some(1.0),
		border_size_r: Some(1.0),
		border_color_t: Some(bin::Color::srgb_hex("707070")),
		border_color_b: Some(bin::Color::srgb_hex("707070")),
		border_color_l: Some(bin::Color::srgb_hex("707070")),
		border_color_r: Some(bin::Color::srgb_hex("707070")),
		text: String::from("Button"),
		text_size: Some(14),
		pad_t: Some(10.0),
		pad_l: Some(10.0),
		text_color: Some(bin::Color::srgb_hex("303030")),
		.. BinStyle::default()
	});
	
	button.on_mouse_press(MouseButton::Left, Arc::new(move |_button, event_data| {
		println!("press event data: {:?}", event_data);
	}));
	
	basalt.wait_for_exit().unwrap();
}

Dependencies

~35MB
~743K SLoC