correctly add egui lints and fix all warnings
This commit is contained in:
parent
8a78302bd0
commit
eeb79c0f88
7 changed files with 37 additions and 36 deletions
|
@ -114,7 +114,7 @@ impl<'a> Widget for DatePickerButton<'a> {
|
|||
calendar: self.calendar,
|
||||
calendar_week: self.calendar_week,
|
||||
}
|
||||
.draw(ui)
|
||||
.draw(ui);
|
||||
})
|
||||
})
|
||||
.response;
|
||||
|
|
|
@ -130,7 +130,7 @@ impl<'a> DatePickerPopup<'a> {
|
|||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ impl<'a> DatePickerPopup<'a> {
|
|||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ impl<'a> DatePickerPopup<'a> {
|
|||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ pub struct GridBuilder<'a> {
|
|||
|
||||
impl<'a> GridBuilder<'a> {
|
||||
/// Create new grid builder
|
||||
/// After adding size hints with [Self::column]/[Self::columns] the grid can be build with [Self::horizontal]/[Self::vertical]
|
||||
/// After adding size hints with `[Self::column]`/`[Self::columns]` the grid can be build with `[Self::horizontal]`/`[Self::vertical]`
|
||||
pub fn new(ui: &'a mut Ui, padding: Padding) -> Self {
|
||||
let sizing = Sizing::new();
|
||||
|
||||
|
@ -38,7 +38,7 @@ impl<'a> GridBuilder<'a> {
|
|||
/// Add size hint for columns/rows [count] times
|
||||
pub fn sizes(mut self, size: Size, count: usize) -> Self {
|
||||
for _ in 0..count {
|
||||
self.sizing.add_size(size.clone());
|
||||
self.sizing.add_size(size);
|
||||
}
|
||||
self
|
||||
}
|
||||
|
@ -134,20 +134,20 @@ impl<'a, 'b> Grid<'a, 'b> {
|
|||
self._cell(false, add_contents);
|
||||
}
|
||||
|
||||
pub fn _grid(&mut self, clip: bool, grid_builder: impl FnOnce(GridBuilder)) {
|
||||
pub fn _grid(&mut self, clip: bool, grid_builder: impl FnOnce(GridBuilder<'_>)) {
|
||||
let padding = self.padding.clone();
|
||||
self._cell(clip, |ui| {
|
||||
grid_builder(GridBuilder::new(ui, padding));
|
||||
});
|
||||
}
|
||||
/// Add grid as cell, content is clipped
|
||||
pub fn grid(&mut self, grid_builder: impl FnOnce(GridBuilder)) {
|
||||
self._grid(true, grid_builder)
|
||||
pub fn grid(&mut self, grid_builder: impl FnOnce(GridBuilder<'_>)) {
|
||||
self._grid(true, grid_builder);
|
||||
}
|
||||
|
||||
/// Add grid as cell, content is not clipped
|
||||
pub fn grid_noclip(&mut self, grid_builder: impl FnOnce(GridBuilder)) {
|
||||
self._grid(false, grid_builder)
|
||||
pub fn grid_noclip(&mut self, grid_builder: impl FnOnce(GridBuilder<'_>)) {
|
||||
self._grid(false, grid_builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::Padding;
|
||||
use egui::{Pos2, Rect, Response, Rgba, Sense, Ui, Vec2};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(crate) enum CellSize {
|
||||
/// Absolute size in points
|
||||
Absolute(f32),
|
||||
|
@ -15,7 +16,7 @@ pub(crate) enum LineDirection {
|
|||
TopToBottom,
|
||||
}
|
||||
|
||||
/// Positions cells in [LineDirection] and starts a new line on [Layout::end_line]
|
||||
/// Positions cells in `[LineDirection]` and starts a new line on `[Layout::end_line]`
|
||||
pub struct Layout<'l> {
|
||||
ui: &'l mut Ui,
|
||||
padding: Padding,
|
||||
|
@ -153,12 +154,12 @@ impl<'l> Layout<'l> {
|
|||
child_ui.set_clip_rect(clip_rect);
|
||||
}
|
||||
|
||||
add_contents(&mut child_ui)
|
||||
add_contents(&mut child_ui);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for Layout<'a> {
|
||||
fn drop(&mut self) {
|
||||
self.set_rect()
|
||||
self.set_rect();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,3 @@
|
|||
#[cfg(feature = "chrono")]
|
||||
mod datepicker;
|
||||
|
||||
mod grid;
|
||||
mod layout;
|
||||
mod padding;
|
||||
mod sizing;
|
||||
mod table;
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
pub use datepicker::DatePickerButton;
|
||||
|
||||
pub use grid::*;
|
||||
pub(crate) use layout::Layout;
|
||||
pub use padding::Padding;
|
||||
pub use sizing::Size;
|
||||
pub use table::*;
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![warn(
|
||||
clippy::all,
|
||||
|
@ -95,3 +77,21 @@ pub use table::*;
|
|||
)]
|
||||
#![allow(clippy::float_cmp)]
|
||||
#![allow(clippy::manual_range_contains)]
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
mod datepicker;
|
||||
|
||||
mod grid;
|
||||
mod layout;
|
||||
mod padding;
|
||||
mod sizing;
|
||||
mod table;
|
||||
|
||||
#[cfg(feature = "chrono")]
|
||||
pub use datepicker::DatePickerButton;
|
||||
|
||||
pub use grid::*;
|
||||
pub(crate) use layout::Layout;
|
||||
pub use padding::Padding;
|
||||
pub use sizing::Size;
|
||||
pub use table::*;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/// Size hint for table column/grid cell
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Copy)]
|
||||
pub enum Size {
|
||||
/// Absolute size in points
|
||||
Absolute(f32),
|
||||
|
|
|
@ -53,7 +53,7 @@ impl<'a> TableBuilder<'a> {
|
|||
/// Add size hint for column [count] times
|
||||
pub fn columns(mut self, size: Size, count: usize) -> Self {
|
||||
for _ in 0..count {
|
||||
self.sizing.add_size(size.clone());
|
||||
self.sizing.add_size(size);
|
||||
}
|
||||
self
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ impl<'a> TableBuilder<'a> {
|
|||
scroll: self.scroll,
|
||||
striped: self.striped,
|
||||
}
|
||||
.body(body)
|
||||
.body(body);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ pub struct TableBody<'a> {
|
|||
impl<'a> TableBody<'a> {
|
||||
/// Add rows with same height
|
||||
/// Is a lot more performant than adding each individual row as non visible rows must not be rendered
|
||||
pub fn rows(mut self, height: f32, rows: usize, mut row: impl FnMut(usize, TableRow)) {
|
||||
pub fn rows(mut self, height: f32, rows: usize, mut row: impl FnMut(usize, TableRow<'_, '_>)) {
|
||||
let delta = self.layout.current_y() - self.start_y;
|
||||
let mut start = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue