fix most warnings

This commit is contained in:
griffi-gh 2024-02-18 17:22:31 +01:00
parent 41049e5f59
commit f24bff2755
11 changed files with 32 additions and 28 deletions

View file

@ -1,5 +1,5 @@
use std::time::Instant;
use glam::{Vec2, IVec2, UVec2};
use glam::UVec2;
use glium::{backend::glutin::SimpleWindowBuilder, Surface};
use winit::{
event::{Event, WindowEvent},
@ -20,7 +20,7 @@ fn main() {
kubi_logging::init();
let event_loop = EventLoopBuilder::new().build().unwrap();
let (window, display) = SimpleWindowBuilder::new().build(&event_loop);
let (_window, display) = SimpleWindowBuilder::new().build(&event_loop);
let mut hui = UiInstance::new();
let mut backend = GliumUiRenderer::new(&display);

View file

@ -14,8 +14,7 @@ use hui::{
rect::Rect
},
interaction::IntoInteractable,
UiSize,
UiDirection, IfModified,
UiSize, UiDirection,
};
use hui_glium::GliumUiRenderer;
@ -23,7 +22,7 @@ fn main() {
kubi_logging::init();
let event_loop = EventLoopBuilder::new().build().unwrap();
let (window, display) = SimpleWindowBuilder::new().build(&event_loop);
let (_window, display) = SimpleWindowBuilder::new().build(&event_loop);
let mut hui = UiInstance::new();
let mut backend = GliumUiRenderer::new(&display);

View file

@ -1,14 +1,15 @@
use std::time::Instant;
use glam::{UVec2, vec4};
use glam::UVec2;
use glium::{backend::glutin::SimpleWindowBuilder, Surface};
use winit::{
event::{Event, WindowEvent},
event_loop::{EventLoopBuilder, ControlFlow}
};
use hui::{
UiInstance, UiSize,
element::{
container::{Alignment, Container, Sides}, progress_bar::ProgressBar, rect::Rect, text::Text, UiElement
}, interaction::IntoInteractable, IfModified, UiDirection, UiInstance, UiSize
container::{Alignment, Container, Sides},
text::Text,
}
};
use hui_glium::GliumUiRenderer;

View file

@ -94,7 +94,7 @@ impl CallSwapper {
}
pub fn swap(&mut self) {
self.calls.push(std::mem::replace(&mut self.call, UiDrawCall::default()));
self.calls.push(std::mem::take(&mut self.call));
}
pub fn finish(mut self) -> Vec<UiDrawCall> {

View file

@ -1,6 +1,9 @@
use glam::{Vec2, vec2, Vec4};
use crate::{
draw::{UiDrawCommand, UiDrawCommands}, element::{MeasureContext, ProcessContext, UiElement}, measure::{Hints, Response}, state::StateRepo, LayoutInfo, UiDirection, UiSize
draw::UiDrawCommand,
element::{MeasureContext, ProcessContext, UiElement},
measure::{Hints, Response},
LayoutInfo, UiDirection, UiSize
};
#[derive(Clone, Copy, PartialEq, Eq, Debug)]

View file

@ -1,10 +1,8 @@
use glam::{vec2, Vec4, vec4};
use crate::{
draw::{UiDrawCommand, UiDrawCommands},
draw::UiDrawCommand,
element::{MeasureContext, ProcessContext, UiElement},
measure::Response,
state::StateRepo,
LayoutInfo,
UiSize
};

View file

@ -1,10 +1,9 @@
use glam::{vec2, Vec4};
use crate::{
draw::{UiDrawCommand, UiDrawCommands},
draw::UiDrawCommand,
element::{MeasureContext, ProcessContext, UiElement},
measure::Response,
state::StateRepo,
LayoutInfo, UiSize
UiSize
};
pub struct Rect {

View file

@ -1,12 +1,11 @@
use std::borrow::Cow;
use glam::{vec2, Vec4};
use crate::{
draw::{UiDrawCommand, UiDrawCommands},
draw::UiDrawCommand,
element::{MeasureContext, ProcessContext, UiElement},
measure::Response,
state::StateRepo,
text::FontHandle,
LayoutInfo, UiSize
text::{FontHandle, BUILTIN_FONT},
UiSize
};
pub struct Text {
@ -23,7 +22,7 @@ impl Default for Text {
text: "".into(),
size: (UiSize::Auto, UiSize::Auto),
color: Vec4::new(1., 1., 1., 1.),
font: FontHandle(0),
font: BUILTIN_FONT,
text_size: 16,
}
}

View file

@ -2,6 +2,8 @@ use hashbrown::{HashMap, HashSet};
use nohash_hasher::BuildNoHashHasher;
use std::any::Any;
//TODO impl StateRepo functions and automatic cleanup of inactive ids
#[derive(Default)]
pub struct StateRepo {
state: HashMap<u64, Box<dyn Any>, BuildNoHashHasher<u64>>,

View file

@ -4,7 +4,7 @@ mod font;
mod ftm;
use font::FontManager;
pub use font::FontHandle;
pub use font::{FontHandle, BUILTIN_FONT};
use fontdue::{Font, FontSettings};
use ftm::FontTextureManager;
pub use ftm::{FontTextureInfo, GlyphCacheEntry};
@ -72,7 +72,7 @@ impl<'a> TextMeasure<'a> {
acc.max(glyph.x + glyph.width as f32)
})
}).unwrap_or(0.),
height: layout.height() as f32,
height: layout.height(),
}
}
}

View file

@ -1,14 +1,14 @@
use fontdue::Font;
#[cfg(feature = "builtin_font")]
const BIN_FONT: &[u8] = include_bytes!("../../assets/font/ProggyTiny.ttf");
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub struct FontHandle(pub(crate) usize);
#[cfg(feature = "builtin_font")]
pub const BUILTIN_FONT: FontHandle = FontHandle(0);
#[cfg(feature = "builtin_font")]
const BUILTIN_FONT_DATA: &[u8] = include_bytes!("../../assets/font/ProggyTiny.ttf");
pub struct FontManager {
fonts: Vec<Font>,
}
@ -20,7 +20,10 @@ impl FontManager {
};
#[cfg(feature = "builtin_font")]
{
let font = Font::from_bytes(BIN_FONT, fontdue::FontSettings::default()).unwrap();
let font = Font::from_bytes(
BUILTIN_FONT_DATA,
fontdue::FontSettings::default()
).unwrap();
this.add_font(font);
};
this