mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-25 16:38:42 -06:00
fix most warnings
This commit is contained in:
parent
41049e5f59
commit
f24bff2755
|
@ -1,5 +1,5 @@
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use glam::{Vec2, IVec2, UVec2};
|
use glam::UVec2;
|
||||||
use glium::{backend::glutin::SimpleWindowBuilder, Surface};
|
use glium::{backend::glutin::SimpleWindowBuilder, Surface};
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
|
@ -20,7 +20,7 @@ fn main() {
|
||||||
kubi_logging::init();
|
kubi_logging::init();
|
||||||
|
|
||||||
let event_loop = EventLoopBuilder::new().build().unwrap();
|
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 hui = UiInstance::new();
|
||||||
let mut backend = GliumUiRenderer::new(&display);
|
let mut backend = GliumUiRenderer::new(&display);
|
||||||
|
|
|
@ -14,8 +14,7 @@ use hui::{
|
||||||
rect::Rect
|
rect::Rect
|
||||||
},
|
},
|
||||||
interaction::IntoInteractable,
|
interaction::IntoInteractable,
|
||||||
UiSize,
|
UiSize, UiDirection,
|
||||||
UiDirection, IfModified,
|
|
||||||
};
|
};
|
||||||
use hui_glium::GliumUiRenderer;
|
use hui_glium::GliumUiRenderer;
|
||||||
|
|
||||||
|
@ -23,7 +22,7 @@ fn main() {
|
||||||
kubi_logging::init();
|
kubi_logging::init();
|
||||||
|
|
||||||
let event_loop = EventLoopBuilder::new().build().unwrap();
|
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 hui = UiInstance::new();
|
||||||
let mut backend = GliumUiRenderer::new(&display);
|
let mut backend = GliumUiRenderer::new(&display);
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
use std::time::Instant;
|
use glam::UVec2;
|
||||||
use glam::{UVec2, vec4};
|
|
||||||
use glium::{backend::glutin::SimpleWindowBuilder, Surface};
|
use glium::{backend::glutin::SimpleWindowBuilder, Surface};
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{EventLoopBuilder, ControlFlow}
|
event_loop::{EventLoopBuilder, ControlFlow}
|
||||||
};
|
};
|
||||||
use hui::{
|
use hui::{
|
||||||
|
UiInstance, UiSize,
|
||||||
element::{
|
element::{
|
||||||
container::{Alignment, Container, Sides}, progress_bar::ProgressBar, rect::Rect, text::Text, UiElement
|
container::{Alignment, Container, Sides},
|
||||||
}, interaction::IntoInteractable, IfModified, UiDirection, UiInstance, UiSize
|
text::Text,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
use hui_glium::GliumUiRenderer;
|
use hui_glium::GliumUiRenderer;
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ impl CallSwapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn swap(&mut self) {
|
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> {
|
pub fn finish(mut self) -> Vec<UiDrawCall> {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
use glam::{Vec2, vec2, Vec4};
|
use glam::{Vec2, vec2, Vec4};
|
||||||
use crate::{
|
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)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
use glam::{vec2, Vec4, vec4};
|
use glam::{vec2, Vec4, vec4};
|
||||||
use crate::{
|
use crate::{
|
||||||
draw::{UiDrawCommand, UiDrawCommands},
|
draw::UiDrawCommand,
|
||||||
element::{MeasureContext, ProcessContext, UiElement},
|
element::{MeasureContext, ProcessContext, UiElement},
|
||||||
measure::Response,
|
measure::Response,
|
||||||
state::StateRepo,
|
|
||||||
LayoutInfo,
|
|
||||||
UiSize
|
UiSize
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
use glam::{vec2, Vec4};
|
use glam::{vec2, Vec4};
|
||||||
use crate::{
|
use crate::{
|
||||||
draw::{UiDrawCommand, UiDrawCommands},
|
draw::UiDrawCommand,
|
||||||
element::{MeasureContext, ProcessContext, UiElement},
|
element::{MeasureContext, ProcessContext, UiElement},
|
||||||
measure::Response,
|
measure::Response,
|
||||||
state::StateRepo,
|
UiSize
|
||||||
LayoutInfo, UiSize
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Rect {
|
pub struct Rect {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use glam::{vec2, Vec4};
|
use glam::{vec2, Vec4};
|
||||||
use crate::{
|
use crate::{
|
||||||
draw::{UiDrawCommand, UiDrawCommands},
|
draw::UiDrawCommand,
|
||||||
element::{MeasureContext, ProcessContext, UiElement},
|
element::{MeasureContext, ProcessContext, UiElement},
|
||||||
measure::Response,
|
measure::Response,
|
||||||
state::StateRepo,
|
text::{FontHandle, BUILTIN_FONT},
|
||||||
text::FontHandle,
|
UiSize
|
||||||
LayoutInfo, UiSize
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Text {
|
pub struct Text {
|
||||||
|
@ -23,7 +22,7 @@ impl Default for Text {
|
||||||
text: "".into(),
|
text: "".into(),
|
||||||
size: (UiSize::Auto, UiSize::Auto),
|
size: (UiSize::Auto, UiSize::Auto),
|
||||||
color: Vec4::new(1., 1., 1., 1.),
|
color: Vec4::new(1., 1., 1., 1.),
|
||||||
font: FontHandle(0),
|
font: BUILTIN_FONT,
|
||||||
text_size: 16,
|
text_size: 16,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ use hashbrown::{HashMap, HashSet};
|
||||||
use nohash_hasher::BuildNoHashHasher;
|
use nohash_hasher::BuildNoHashHasher;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
|
//TODO impl StateRepo functions and automatic cleanup of inactive ids
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct StateRepo {
|
pub struct StateRepo {
|
||||||
state: HashMap<u64, Box<dyn Any>, BuildNoHashHasher<u64>>,
|
state: HashMap<u64, Box<dyn Any>, BuildNoHashHasher<u64>>,
|
||||||
|
|
|
@ -4,7 +4,7 @@ mod font;
|
||||||
mod ftm;
|
mod ftm;
|
||||||
|
|
||||||
use font::FontManager;
|
use font::FontManager;
|
||||||
pub use font::FontHandle;
|
pub use font::{FontHandle, BUILTIN_FONT};
|
||||||
use fontdue::{Font, FontSettings};
|
use fontdue::{Font, FontSettings};
|
||||||
use ftm::FontTextureManager;
|
use ftm::FontTextureManager;
|
||||||
pub use ftm::{FontTextureInfo, GlyphCacheEntry};
|
pub use ftm::{FontTextureInfo, GlyphCacheEntry};
|
||||||
|
@ -72,7 +72,7 @@ impl<'a> TextMeasure<'a> {
|
||||||
acc.max(glyph.x + glyph.width as f32)
|
acc.max(glyph.x + glyph.width as f32)
|
||||||
})
|
})
|
||||||
}).unwrap_or(0.),
|
}).unwrap_or(0.),
|
||||||
height: layout.height() as f32,
|
height: layout.height(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
use fontdue::Font;
|
use fontdue::Font;
|
||||||
|
|
||||||
#[cfg(feature = "builtin_font")]
|
|
||||||
const BIN_FONT: &[u8] = include_bytes!("../../assets/font/ProggyTiny.ttf");
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct FontHandle(pub(crate) usize);
|
pub struct FontHandle(pub(crate) usize);
|
||||||
|
|
||||||
#[cfg(feature = "builtin_font")]
|
#[cfg(feature = "builtin_font")]
|
||||||
pub const BUILTIN_FONT: FontHandle = FontHandle(0);
|
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 {
|
pub struct FontManager {
|
||||||
fonts: Vec<Font>,
|
fonts: Vec<Font>,
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,10 @@ impl FontManager {
|
||||||
};
|
};
|
||||||
#[cfg(feature = "builtin_font")]
|
#[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.add_font(font);
|
||||||
};
|
};
|
||||||
this
|
this
|
||||||
|
|
Loading…
Reference in a new issue