mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-21 14:28:43 -06:00
owo
This commit is contained in:
parent
16ffb6f786
commit
0af548320b
|
@ -1,6 +1,8 @@
|
|||
use std::borrow::Cow;
|
||||
use glam::{Vec2, Vec4, vec2};
|
||||
use crate::text::TextRenderer;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum UiDrawCommand {
|
||||
///Filled, colored rectangle
|
||||
Rectangle {
|
||||
|
@ -10,7 +12,17 @@ pub enum UiDrawCommand {
|
|||
size: Vec2,
|
||||
///Color (RGBA)
|
||||
color: Vec4,
|
||||
}
|
||||
},
|
||||
Text {
|
||||
///Position in pixels
|
||||
position: Vec2,
|
||||
///Font size
|
||||
size: u8,
|
||||
///Color (RGBA)
|
||||
color: Vec4,
|
||||
///Text to draw
|
||||
text: Cow<'static, str>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -25,6 +37,11 @@ pub struct UiDrawCommands {
|
|||
// }
|
||||
// }
|
||||
|
||||
pub enum BindTexture {
|
||||
FontTexture,
|
||||
//UserDefined(usize),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct UiVertex {
|
||||
pub position: Vec2,
|
||||
|
@ -45,7 +62,7 @@ pub struct UiDrawPlan {
|
|||
}
|
||||
|
||||
impl UiDrawPlan {
|
||||
pub fn build(calls: &UiDrawCommands) -> Self {
|
||||
pub fn build(calls: &UiDrawCommands, tr: &mut TextRenderer) -> Self {
|
||||
let mut call = UiDrawCall::default();
|
||||
for command in &calls.commands {
|
||||
match command {
|
||||
|
@ -74,6 +91,9 @@ impl UiDrawPlan {
|
|||
uv: vec2(0.0, 1.0),
|
||||
},
|
||||
]);
|
||||
},
|
||||
UiDrawCommand::Text { position, size, color, text } => {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ use event::UiEvent;
|
|||
use draw::{UiDrawCommands, UiDrawPlan};
|
||||
use text::TextRenderer;
|
||||
|
||||
pub struct ElementContext<'a> {
|
||||
pub state: &'a mut StateRepo,
|
||||
pub draw: &'a mut UiDrawCommands,
|
||||
pub text: &'a mut TextRenderer,
|
||||
}
|
||||
// pub struct ElementContext<'a> {
|
||||
// pub state: &'a mut StateRepo,
|
||||
// pub draw: &'a mut UiDrawCommands,
|
||||
// pub text: &'a mut TextRenderer,
|
||||
// }
|
||||
|
||||
pub struct KubiUi {
|
||||
mouse_position: Vec2,
|
||||
|
@ -67,7 +67,7 @@ impl KubiUi {
|
|||
if self.draw_commands.commands == self.prev_draw_commands.commands {
|
||||
return
|
||||
}
|
||||
self.draw_plan = UiDrawPlan::build(&self.draw_commands);
|
||||
self.draw_plan = UiDrawPlan::build(&self.draw_commands, &mut self.font_renderer);
|
||||
self.draw_plan_modified = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@ const BIN_FONT: &[u8] = include_bytes!("../assets/font/ProggyTiny.ttf");
|
|||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct FontHandle(pub(crate) usize);
|
||||
|
||||
#[cfg(feature = "builtin_font")]
|
||||
pub const BUILTIN_FONT: FontHandle = FontHandle(0);
|
||||
|
||||
#[derive(PartialEq, Eq, Hash)]
|
||||
struct GlyphCacheKey {
|
||||
font_index: usize,
|
||||
|
|
Loading…
Reference in a new issue