mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-26 21:58:20 -06:00
restructure stuff
This commit is contained in:
parent
fef14911d5
commit
cf56bf29fe
|
@ -48,8 +48,9 @@ impl BufferPair {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ensure_buffer_size(&mut self, need_vtx: usize, need_idx: usize) {
|
pub fn ensure_buffer_size(&mut self, need_vtx: usize, need_idx: usize) {
|
||||||
let current_vtx_size = self.vertex_buffer.get_size();
|
let current_vtx_size = self.vertex_buffer.get_size() / std::mem::size_of::<Vertex>();
|
||||||
let current_idx_size = self.index_buffer.get_size();
|
let current_idx_size = self.index_buffer.get_size() / std::mem::size_of::<u32>();
|
||||||
|
//log::debug!("current vtx size: {}, current idx size: {}", current_vtx_size, current_idx_size);
|
||||||
if current_vtx_size >= need_vtx && current_idx_size >= need_idx {
|
if current_vtx_size >= need_vtx && current_idx_size >= need_idx {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -84,9 +85,10 @@ impl BufferPair {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
self.ensure_buffer_size(vtx.len(), idx.len());
|
self.ensure_buffer_size(self.vertex_count, self.index_count);
|
||||||
self.vertex_buffer.slice_mut(0..vtx.len()).unwrap().write(vtx);
|
|
||||||
self.index_buffer.slice_mut(0..idx.len()).unwrap().write(idx);
|
self.vertex_buffer.slice_mut(0..self.vertex_count).unwrap().write(vtx);
|
||||||
|
self.index_buffer.slice_mut(0..self.index_count).unwrap().write(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
|
|
|
@ -6,10 +6,15 @@ use crate::{
|
||||||
state::StateRepo
|
state::StateRepo
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "builtin_elements")] pub mod rect;
|
#[cfg(feature = "builtin")] mod builtin {
|
||||||
#[cfg(feature = "builtin_elements")] pub mod container;
|
pub mod rect;
|
||||||
#[cfg(feature = "builtin_elements")] pub mod spacer;
|
pub mod container;
|
||||||
#[cfg(feature = "builtin_elements")] pub mod progress_bar;
|
pub mod spacer;
|
||||||
|
pub mod progress_bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "builtin")]
|
||||||
|
pub use builtin::*;
|
||||||
|
|
||||||
pub trait UiElement {
|
pub trait UiElement {
|
||||||
fn name(&self) -> &'static str { "UiElement" }
|
fn name(&self) -> &'static str { "UiElement" }
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
use glam::{Vec2, vec2, Vec4};
|
use glam::{Vec2, vec2, Vec4};
|
||||||
use crate::{UiDirection, LayoutInfo, draw::UiDrawCommand, measure::Response, state::StateRepo, UiSize};
|
use crate::{
|
||||||
use super::UiElement;
|
UiDirection,
|
||||||
|
UiSize,
|
||||||
|
LayoutInfo,
|
||||||
|
draw::UiDrawCommand,
|
||||||
|
measure::Response,
|
||||||
|
state::StateRepo,
|
||||||
|
element::UiElement
|
||||||
|
};
|
||||||
|
|
||||||
pub enum Alignment {
|
pub enum Alignment {
|
||||||
Begin,
|
Begin,
|
|
@ -3,9 +3,9 @@ use crate::{
|
||||||
UiSize, LayoutInfo,
|
UiSize, LayoutInfo,
|
||||||
draw::UiDrawCommand,
|
draw::UiDrawCommand,
|
||||||
measure::Response,
|
measure::Response,
|
||||||
state::StateRepo
|
state::StateRepo,
|
||||||
|
element::UiElement
|
||||||
};
|
};
|
||||||
use super::UiElement;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct ProgressBar {
|
pub struct ProgressBar {
|
|
@ -1,6 +1,12 @@
|
||||||
use glam::{vec2, Vec4};
|
use glam::{vec2, Vec4};
|
||||||
use crate::{state::StateRepo, LayoutInfo, measure::Response, draw::UiDrawCommand, UiSize};
|
use crate::{
|
||||||
use super::UiElement;
|
LayoutInfo,
|
||||||
|
UiSize,
|
||||||
|
element::UiElement,
|
||||||
|
state::StateRepo,
|
||||||
|
measure::Response,
|
||||||
|
draw::UiDrawCommand
|
||||||
|
};
|
||||||
|
|
||||||
pub struct Rect {
|
pub struct Rect {
|
||||||
pub size: (UiSize, UiSize),
|
pub size: (UiSize, UiSize),
|
|
@ -1,6 +1,12 @@
|
||||||
use glam::vec2;
|
use glam::vec2;
|
||||||
use crate::{state::StateRepo, LayoutInfo, measure::Response, draw::UiDrawCommand, UiDirection};
|
use crate::{
|
||||||
use super::UiElement;
|
LayoutInfo,
|
||||||
|
UiDirection,
|
||||||
|
element::UiElement,
|
||||||
|
state::StateRepo,
|
||||||
|
measure::Response,
|
||||||
|
draw::UiDrawCommand
|
||||||
|
};
|
||||||
|
|
||||||
pub struct Spacer(f32);
|
pub struct Spacer(f32);
|
||||||
|
|
Loading…
Reference in a new issue