mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-21 14:48:42 -06:00
fix most warnings
This commit is contained in:
parent
41049e5f59
commit
f24bff2755
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>>,
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue