2024-02-25 18:15:55 -06:00
|
|
|
use std::time::Instant;
|
2024-02-25 18:27:25 -06:00
|
|
|
use glam::{vec3, vec4, UVec2};
|
2024-02-17 21:04:02 -06:00
|
|
|
use glium::{backend::glutin::SimpleWindowBuilder, Surface};
|
|
|
|
use winit::{
|
|
|
|
event::{Event, WindowEvent},
|
|
|
|
event_loop::{EventLoopBuilder, ControlFlow}
|
|
|
|
};
|
|
|
|
use hui::{
|
2024-02-20 10:30:26 -06:00
|
|
|
UiInstance,
|
2024-02-17 21:04:02 -06:00
|
|
|
element::{
|
2024-02-26 08:13:03 -06:00
|
|
|
ElementList, UiElementExt,
|
2024-02-20 10:30:26 -06:00
|
|
|
container::Container,
|
2024-02-18 10:22:31 -06:00
|
|
|
text::Text,
|
2024-02-25 18:15:55 -06:00
|
|
|
},
|
|
|
|
layout::{Alignment, UiDirection, UiSize},
|
|
|
|
rectangle::{Corners, Sides},
|
2024-02-17 21:04:02 -06:00
|
|
|
};
|
|
|
|
use hui_glium::GliumUiRenderer;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
kubi_logging::init();
|
|
|
|
|
|
|
|
let event_loop = EventLoopBuilder::new().build().unwrap();
|
|
|
|
let (_window, display) = SimpleWindowBuilder::new().build(&event_loop);
|
|
|
|
|
|
|
|
let mut hui = UiInstance::new();
|
|
|
|
let mut backend = GliumUiRenderer::new(&display);
|
2024-02-25 18:15:55 -06:00
|
|
|
|
2024-02-17 21:04:02 -06:00
|
|
|
event_loop.run(|event, window_target| {
|
|
|
|
window_target.set_control_flow(ControlFlow::Poll);
|
|
|
|
match event {
|
|
|
|
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => {
|
|
|
|
window_target.exit();
|
|
|
|
},
|
|
|
|
Event::AboutToWait => {
|
|
|
|
let mut frame = display.draw();
|
|
|
|
frame.clear_color_srgb(0.5, 0.5, 0.5, 0.);
|
|
|
|
|
|
|
|
let resolution = UVec2::from(display.get_framebuffer_dimensions()).as_vec2();
|
|
|
|
|
|
|
|
hui.begin();
|
|
|
|
|
2024-02-26 08:13:03 -06:00
|
|
|
Container::default()
|
|
|
|
.with_size((UiSize::Fraction(1.), UiSize::Fraction(1.)))
|
|
|
|
.with_padding(Sides::all(5.))
|
|
|
|
.with_background(vec3(1., 0., 0.))
|
|
|
|
.with_children(|ui: &mut ElementList| {
|
|
|
|
Text::default()
|
|
|
|
.with_text("Hello, world")
|
|
|
|
.with_text_size(120)
|
|
|
|
.with_color(vec4(0., 0., 0., 1.))
|
|
|
|
.add_child(ui);
|
|
|
|
})
|
|
|
|
.add_root(&mut hui, resolution);
|
2024-02-17 21:04:02 -06:00
|
|
|
|
|
|
|
hui.end();
|
|
|
|
|
|
|
|
backend.update(&hui);
|
|
|
|
backend.draw(&mut frame, resolution);
|
|
|
|
|
|
|
|
frame.finish().unwrap();
|
|
|
|
}
|
|
|
|
_ => (),
|
|
|
|
}
|
|
|
|
}).unwrap();
|
|
|
|
}
|