This commit is contained in:
griffi-gh 2023-12-02 21:20:20 +01:00
parent f15ae91155
commit 726dfa4b52
2 changed files with 21 additions and 17 deletions

View file

@ -1,4 +1,4 @@
use std::time::Instant; use std::{time::Instant, vec};
use glam::{UVec2, vec4}; use glam::{UVec2, vec4};
use glium::{backend::glutin::SimpleWindowBuilder, Surface}; use glium::{backend::glutin::SimpleWindowBuilder, Surface};
use winit::{ use winit::{
@ -10,7 +10,7 @@ use kubi_ui::{
element::{ element::{
progress_bar::ProgressBar, progress_bar::ProgressBar,
container::{Container, Sides, Alignment}, container::{Container, Sides, Alignment},
text::Text, rect::Rect text::Text, rect::Rect, spacer::Spacer
}, },
UiSize, UiSize,
elements, elements,
@ -28,6 +28,7 @@ fn main() {
let mut backend = GliumUiRenderer::new(&display); let mut backend = GliumUiRenderer::new(&display);
let font_handle = kui.add_font_from_bytes(include_bytes!("../../assets/fonts/roboto/Roboto-Regular.ttf")); let font_handle = kui.add_font_from_bytes(include_bytes!("../../assets/fonts/roboto/Roboto-Regular.ttf"));
let instant = Instant::now();
event_loop.run(|event, window_target| { event_loop.run(|event, window_target| {
window_target.set_control_flow(ControlFlow::Poll); window_target.set_control_flow(ControlFlow::Poll);
@ -81,6 +82,7 @@ fn main() {
text_size: 32, text_size: 32,
..Default::default() ..Default::default()
}); });
if instant.elapsed().as_secs() & 1 != 0 {
elem.add(Rect { elem.add(Rect {
size: (UiSize::Percentage(1.), UiSize::Pixels(10.)), size: (UiSize::Percentage(1.), UiSize::Pixels(10.)),
color: Some(vec4(1., 0., 0., 1.)), color: Some(vec4(1., 0., 0., 1.)),
@ -89,12 +91,14 @@ fn main() {
size: (UiSize::Percentage(1.), UiSize::Pixels(10.)), size: (UiSize::Percentage(1.), UiSize::Pixels(10.)),
color: Some(vec4(0., 0., 0., 1.)), color: Some(vec4(0., 0., 0., 1.)),
}); });
elem.add(Spacer(100.));
elem.add(Text { elem.add(Text {
text: "OVERLAP TEST".into(), text: "FLAG SHOULD NOT OVERLAP".into(),
font: font_handle, text_size: 64,
text_size: 15, color: vec4(1., 0., 1., 1.),
..Default::default() ..Default::default()
}); });
}
}), }),
..Default::default() ..Default::default()
}, resolution); }, resolution);

View file

@ -8,7 +8,7 @@ use crate::{
draw::{UiDrawCommand, UiDrawCommands} draw::{UiDrawCommand, UiDrawCommands}
}; };
pub struct Spacer(f32); pub struct Spacer(pub f32);
impl Default for Spacer { impl Default for Spacer {
fn default() -> Self { fn default() -> Self {