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 std::time::Instant;
use hui::{ use hui::{
color, element::{ color,
element::{
container::Container, container::Container,
progress_bar::ProgressBar, progress_bar::ProgressBar,
text::Text, text::Text,
UiElementExt, UiElementExt,
}, frame::RectFrame, rect_frame, layout::{Alignment, Direction}, size },
layout::{Alignment, Direction},
rect_frame,
size
}; };
#[path = "../boilerplate.rs"] #[path = "../boilerplate.rs"]

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -145,8 +145,8 @@ impl UiDrawCall {
//Kinda a hack: //Kinda a hack:
//We want to apply the transform aronnd the center, so we need to compute the center of the vertices //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 //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 min = Vec2::splat(f32::INFINITY);
let mut max = Vec2::splat(std::f32::NEG_INFINITY); let mut max = Vec2::splat(f32::NEG_INFINITY);
for v in &draw_call.vertices[idx as usize..] { for v in &draw_call.vertices[idx as usize..] {
min = min.min(v.position); min = min.min(v.position);
max = max.max(v.position); max = max.max(v.position);

View file

@ -4,10 +4,13 @@ use derive_setters::Setters;
use glam::{Vec2, vec2}; use glam::{Vec2, vec2};
use crate::{ 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? //TODO: use state for slider?
// ^ useful if the user only hanldes the drag end event or has large step sizes with relative mode // ^ 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 std::borrow::Cow;
use derive_setters::Setters; use derive_setters::Setters;
use glam::{vec2, Vec4}; use glam::Vec4;
use crate::{ use crate::{
draw::UiDrawCommand, draw::UiDrawCommand,
element::{MeasureContext, ProcessContext, UiElement}, element::{MeasureContext, ProcessContext, UiElement},

View file

@ -256,7 +256,7 @@ pub struct ActiveCheckResponse {
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub struct InputCtx<'a>(&'a UiInputState); pub struct InputCtx<'a>(&'a UiInputState);
impl<'a> InputCtx<'a> { impl InputCtx<'_> {
/// Get the current position of the mouse pointer /// Get the current position of the mouse pointer
/// ///
/// Do not use this function to check for hover, use [`InputCtx::check_hover`] instead /// 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::{ use crate::{
element::{MeasureContext, ProcessContext, UiElement}, element::{MeasureContext, ProcessContext, UiElement},
layout::{Direction, LayoutInfo}, layout::{Direction, LayoutInfo},

View file

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