fix some warnings

This commit is contained in:
griffi-gh 2024-12-11 20:36:14 +01:00
parent 1fea554560
commit 292dda66d1
13 changed files with 27 additions and 19 deletions

View file

@ -1,11 +1,15 @@
use std::time::Instant;
use hui::{
color, element::{
color,
element::{
container::Container,
progress_bar::ProgressBar,
text::Text,
UiElementExt,
}, frame::RectFrame, rect_frame, layout::{Alignment, Direction}, size
},
layout::{Alignment, Direction},
rect_frame,
size
};
#[path = "../boilerplate.rs"]

View file

@ -1,7 +1,6 @@
use hui::{
color, size, rect_frame,
element::{container::Container, text::Text, UiElementExt},
frame::RectFrame,
layout::Alignment,
};

View file

@ -8,7 +8,6 @@ use hui::{
text::Text,
UiElementExt
},
frame::RectFrame,
layout::Alignment,
rect::Corners,
text::FontHandle

View file

@ -7,7 +7,12 @@ use hui::{
text::Text,
transformer::ElementTransformExt,
UiElementExt
}, frame::RectFrame, rect_frame, layout::Alignment, rect::Corners, size, text::FontHandle
},
layout::Alignment,
rect::Corners,
text::FontHandle,
rect_frame,
size,
};
#[path = "../boilerplate.rs"]

View file

@ -1,5 +1,5 @@
use std::num::NonZeroU16;
use glam::{vec2, Vec2, Vec4};
use glam::{vec2, Vec2};
use hui_shared::{color, rect::{Corners, FillColor}};
use crate::{
paint::{
@ -99,8 +99,7 @@ impl PaintCommand for PaintRectangle {
// Otherwise, if texture handle is not set or invalid, use the bottom left
// corner of the texture which contains a white pixel.
let uvs = self.texture
.map(|handle| ctx.atlas.get_uv(handle))
.flatten()
.and_then(|handle| ctx.atlas.get_uv(handle))
.map(|global_uv| {
let texture_uv = self.texture_uv;
let texture_uv_is_default =
@ -155,7 +154,7 @@ impl PaintCommand for PaintRectangle {
// No border radius:
// Draw a simple quad (2 tris)
let indices = Corners {
top_left: idx_base + 0,
top_left: idx_base,
top_right: idx_base + 1,
bottom_left: idx_base + 2,
bottom_right: idx_base + 3,

View file

@ -43,7 +43,7 @@ impl PaintText {
fn build_layout(&self, font_array: &[&fontdue::Font]) -> Layout {
let mut layout = Layout::new(CoordinateSystem::PositiveYDown);
layout.append(
&font_array,
font_array,
&fontdue::layout::TextStyle::new(
&self.text.text,
self.text.size,

View file

@ -83,7 +83,7 @@ impl FontTextureManager {
let itm = RasterizedGlyphInternal { handle, metrics };
unsafe { partition.insert_unique_unchecked(config, itm); }
return handle;
handle
}
}

View file

@ -145,8 +145,8 @@ impl UiDrawCall {
//Kinda a hack:
//We want to apply the transform aronnd the center, so we need to compute the center of the vertices
//We won't actually do that, we will compute the center of the bounding box of the vertices
let mut min = Vec2::splat(std::f32::INFINITY);
let mut max = Vec2::splat(std::f32::NEG_INFINITY);
let mut min = Vec2::splat(f32::INFINITY);
let mut max = Vec2::splat(f32::NEG_INFINITY);
for v in &draw_call.vertices[idx as usize..] {
min = min.min(v.position);
max = max.max(v.position);

View file

@ -4,10 +4,13 @@ use derive_setters::Setters;
use glam::{Vec2, vec2};
use crate::{
draw::UiDrawCommand, element::{MeasureContext, ProcessContext, UiElement}, frame::{Frame, RectFrame}, layout::{compute_size, Size2d}, measure::Response, rect::FillColor, signal::{trigger::SignalTriggerArg, Signal}
element::{MeasureContext, ProcessContext, UiElement},
frame::{Frame, RectFrame},
layout::{compute_size, Size2d},
measure::Response,
signal::{trigger::SignalTriggerArg, Signal},
};
//TODO: use state for slider?
// ^ useful if the user only hanldes the drag end event or has large step sizes with relative mode

View file

@ -2,7 +2,7 @@
use std::borrow::Cow;
use derive_setters::Setters;
use glam::{vec2, Vec4};
use glam::Vec4;
use crate::{
draw::UiDrawCommand,
element::{MeasureContext, ProcessContext, UiElement},

View file

@ -256,7 +256,7 @@ pub struct ActiveCheckResponse {
#[derive(Clone, Copy)]
pub struct InputCtx<'a>(&'a UiInputState);
impl<'a> InputCtx<'a> {
impl InputCtx<'_> {
/// Get the current position of the mouse pointer
///
/// Do not use this function to check for hover, use [`InputCtx::check_hover`] instead

View file

@ -1,4 +1,3 @@
use glam::Vec2;
use crate::{
element::{MeasureContext, ProcessContext, UiElement},
layout::{Direction, LayoutInfo},

View file

@ -74,7 +74,7 @@ pub struct TextMeasureResponse {
#[derive(Clone, Copy)]
pub struct TextMeasure<'a>(&'a TextRenderer);
impl<'a> TextMeasure<'a> {
impl TextMeasure<'_> {
/// Measure the given string of text with the given font and size
pub fn measure(&self, font: FontHandle, size: u16, text: &str) -> TextMeasureResponse {
use fontdue::layout::{Layout, CoordinateSystem, TextStyle};