From d848f60301192b179d04b19d03f4646f1f2056c9 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Wed, 22 Nov 2023 16:51:59 +0100 Subject: [PATCH] commit --- kubi-ui/src/lib.rs | 10 ++++++++++ kubi/src/guiv2_integration.rs | 7 ++++++- kubi/src/lib.rs | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/kubi-ui/src/lib.rs b/kubi-ui/src/lib.rs index 0f45089..c338c58 100644 --- a/kubi-ui/src/lib.rs +++ b/kubi-ui/src/lib.rs @@ -37,6 +37,16 @@ impl KubiUi { } } + pub fn add(&mut self, element: T, max_size: Vec2) { + let layout = LayoutInfo { + position: Vec2::ZERO, + max_size, + direction: UiDirection::Vertical, + }; + let measure = element.measure(&self.stateful_state, &layout); + element.process(&measure, &mut self.stateful_state, &layout, &mut self.draw_commands.commands); + } + pub fn begin(&mut self) { std::mem::swap(&mut self.prev_draw_commands, &mut self.draw_commands); self.draw_plan_modified = false; diff --git a/kubi/src/guiv2_integration.rs b/kubi/src/guiv2_integration.rs index 562d892..988a22f 100644 --- a/kubi/src/guiv2_integration.rs +++ b/kubi/src/guiv2_integration.rs @@ -1,4 +1,5 @@ -use kubi_ui::{KubiUi, backend::glium::GliumUiRenderer}; +use glam::vec2; +use kubi_ui::{KubiUi, backend::glium::GliumUiRenderer, element::{progress_bar::ProgressBar, UiElement}, UiSize}; use shipyard::{AllStoragesView, Unique, UniqueView, NonSendSync, UniqueViewMut}; use crate::rendering::{Renderer, RenderTarget, WindowSize}; @@ -22,6 +23,10 @@ pub fn kubi_ui_begin( mut ui: NonSendSync> ) { ui.ui.begin(); + ui.ui.add(ProgressBar { + size: (UiSize::Pixels(300.), UiSize::Auto), + ..Default::default() + }, vec2(999., 999.)); } pub fn kubi_ui_end( diff --git a/kubi/src/lib.rs b/kubi/src/lib.rs index 7189640..796719a 100644 --- a/kubi/src/lib.rs +++ b/kubi/src/lib.rs @@ -159,6 +159,7 @@ fn render() -> Workload { render_entities, ).into_sequential_workload().run_if(is_ingame), legacy_ui_render, + kubi_ui_draw, ).into_sequential_workload() }