mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Fix a few nightly clippy lints (#8388)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use emath::GuiRounding as _;
|
use emath::{GuiRounding as _, fast_midpoint};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Align, Direction,
|
Align, Direction,
|
||||||
@@ -477,12 +477,12 @@ impl Layout {
|
|||||||
|
|
||||||
// Make sure it isn't negative:
|
// Make sure it isn't negative:
|
||||||
if avail.max.x < avail.min.x {
|
if avail.max.x < avail.min.x {
|
||||||
let x = 0.5 * (avail.min.x + avail.max.x);
|
let x = fast_midpoint(avail.min.x, avail.max.x);
|
||||||
avail.min.x = x;
|
avail.min.x = x;
|
||||||
avail.max.x = x;
|
avail.max.x = x;
|
||||||
}
|
}
|
||||||
if avail.max.y < avail.min.y {
|
if avail.max.y < avail.min.y {
|
||||||
let y = 0.5 * (avail.min.y + avail.max.y);
|
let y = fast_midpoint(avail.min.y, avail.max.y);
|
||||||
avail.min.y = y;
|
avail.min.y = y;
|
||||||
avail.max.y = y;
|
avail.max.y = y;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,9 +143,7 @@ impl View for MiscDemoWindow {
|
|||||||
)
|
)
|
||||||
.changed()
|
.changed()
|
||||||
{
|
{
|
||||||
for check in &mut self.checklist {
|
self.checklist.fill(all_checked);
|
||||||
*check = all_checked;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (i, checked) in self.checklist.iter_mut().enumerate() {
|
for (i, checked) in self.checklist.iter_mut().enumerate() {
|
||||||
ui.checkbox(checked, format!("Item {}", i + 1));
|
ui.checkbox(checked, format!("Item {}", i + 1));
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
//! Derived from <https://github.com/warrenm/AHEasing/blob/master/AHEasing/easing.c>.
|
//! Derived from <https://github.com/warrenm/AHEasing/blob/master/AHEasing/easing.c>.
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
|
||||||
|
use crate::fast_midpoint;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn powf(base: f32, exp: f32) -> f32 {
|
fn powf(base: f32, exp: f32) -> f32 {
|
||||||
base.powf(exp)
|
base.powf(exp)
|
||||||
@@ -116,7 +118,7 @@ pub fn circular_in_out(t: f32) -> f32 {
|
|||||||
if t < 0.5 {
|
if t < 0.5 {
|
||||||
0.5 * (1. - (1. - 4. * t * t).sqrt())
|
0.5 * (1. - (1. - 4. * t * t).sqrt())
|
||||||
} else {
|
} else {
|
||||||
0.5 * ((-(2. * t - 3.) * (2. * t - 1.)).sqrt() + 1.)
|
fast_midpoint((-(2. * t - 3.) * (2. * t - 1.)).sqrt(), 1.)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
use std::ops::{RangeFrom, RangeFull, RangeInclusive, RangeToInclusive};
|
use std::ops::{RangeFrom, RangeFull, RangeInclusive, RangeToInclusive};
|
||||||
|
|
||||||
|
use crate::fast_midpoint;
|
||||||
|
|
||||||
/// Inclusive range of floats, i.e. `min..=max`, but more ergonomic than [`RangeInclusive`].
|
/// Inclusive range of floats, i.e. `min..=max`, but more ergonomic than [`RangeInclusive`].
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
@@ -52,7 +54,7 @@ impl Rangef {
|
|||||||
/// The center of the range
|
/// The center of the range
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn center(self) -> f32 {
|
pub fn center(self) -> f32 {
|
||||||
0.5 * (self.min + self.max)
|
fast_midpoint(self.min, self.max)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
||||||
use crate::{Color32, PathShape, PathStroke, Shape};
|
use crate::{Color32, PathShape, PathStroke, Shape};
|
||||||
use emath::{Pos2, Rect, RectTransform};
|
use emath::{Pos2, Rect, RectTransform, fast_midpoint};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -689,8 +689,8 @@ fn single_curve_approximation(curve: &CubicBezierShape) -> QuadraticBezierShape
|
|||||||
let c2_x = (curve.points[2].x * 3.0 - curve.points[3].x) * 0.5;
|
let c2_x = (curve.points[2].x * 3.0 - curve.points[3].x) * 0.5;
|
||||||
let c2_y = (curve.points[2].y * 3.0 - curve.points[3].y) * 0.5;
|
let c2_y = (curve.points[2].y * 3.0 - curve.points[3].y) * 0.5;
|
||||||
let c = Pos2 {
|
let c = Pos2 {
|
||||||
x: (c1_x + c2_x) * 0.5,
|
x: fast_midpoint(c1_x, c2_x),
|
||||||
y: (c1_y + c2_y) * 0.5,
|
y: fast_midpoint(c1_y, c2_y),
|
||||||
};
|
};
|
||||||
QuadraticBezierShape {
|
QuadraticBezierShape {
|
||||||
points: [curve.points[0], c, curve.points[3]],
|
points: [curve.points[0], c, curve.points[3]],
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
#![expect(clippy::identity_op)]
|
#![expect(clippy::identity_op)]
|
||||||
|
|
||||||
use emath::{GuiRounding as _, NumExt as _, Pos2, Rect, Rot2, Vec2, pos2, remap, vec2};
|
use emath::{
|
||||||
|
GuiRounding as _, NumExt as _, Pos2, Rect, Rot2, Vec2, fast_midpoint, pos2, remap, vec2,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
CircleShape, ClippedPrimitive, ClippedShape, Color32, CornerRadiusF32, CubicBezierShape,
|
CircleShape, ClippedPrimitive, ClippedShape, Color32, CornerRadiusF32, CubicBezierShape,
|
||||||
@@ -1074,7 +1076,7 @@ fn stroke_and_fill_path(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
let inner_rad = 0.5 * (stroke.width - feathering);
|
let inner_rad = 0.5 * (stroke.width - feathering);
|
||||||
let outer_rad = 0.5 * (stroke.width + feathering);
|
let outer_rad = fast_midpoint(stroke.width, feathering);
|
||||||
|
|
||||||
match path_type {
|
match path_type {
|
||||||
PathType::Closed => {
|
PathType::Closed => {
|
||||||
|
|||||||
Reference in New Issue
Block a user