mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Use Rust edition 2024 (#7280)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use criterion::{Criterion, black_box, criterion_group, criterion_main};
|
||||
|
||||
use epaint::{
|
||||
pos2, tessellator::Path, ClippedShape, Color32, Mesh, PathStroke, Pos2, Rect, Shape, Stroke,
|
||||
TessellationOptions, Tessellator, TextureAtlas, Vec2,
|
||||
ClippedShape, Color32, Mesh, PathStroke, Pos2, Rect, Shape, Stroke, TessellationOptions,
|
||||
Tessellator, TextureAtlas, Vec2, pos2, tessellator::Path,
|
||||
};
|
||||
|
||||
#[global_allocator]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use emath::Vec2;
|
||||
|
||||
use crate::{textures::TextureOptions, Color32};
|
||||
use crate::{Color32, textures::TextureOptions};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// An image stored in RAM.
|
||||
|
||||
@@ -73,7 +73,7 @@ pub use self::{
|
||||
pub type Rounding = CornerRadius;
|
||||
|
||||
pub use ecolor::{Color32, Hsva, HsvaGamma, Rgba};
|
||||
pub use emath::{pos2, vec2, Pos2, Rect, Vec2};
|
||||
pub use emath::{Pos2, Rect, Vec2, pos2, vec2};
|
||||
|
||||
#[deprecated = "Use the ahash crate directly."]
|
||||
pub use ahash;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use emath::{vec2, Rect, Vec2};
|
||||
use emath::{Rect, Vec2, vec2};
|
||||
|
||||
/// A value for all four sides of a rectangle,
|
||||
/// often used to express padding or spacing.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use emath::{vec2, Rect, Vec2};
|
||||
use emath::{Rect, Vec2, vec2};
|
||||
|
||||
use crate::Margin;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{emath, Color32, TextureId, WHITE_UV};
|
||||
use crate::{Color32, TextureId, WHITE_UV, emath};
|
||||
use emath::{Pos2, Rect, Rot2, TSTransform, Vec2};
|
||||
|
||||
/// The 2D vertex type.
|
||||
|
||||
@@ -29,7 +29,8 @@ pub struct Shadow {
|
||||
#[test]
|
||||
fn shadow_size() {
|
||||
assert_eq!(
|
||||
std::mem::size_of::<Shadow>(), 8,
|
||||
std::mem::size_of::<Shadow>(),
|
||||
8,
|
||||
"Shadow changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
color, CircleShape, Color32, ColorMode, CubicBezierShape, EllipseShape, Mesh, PathShape,
|
||||
QuadraticBezierShape, RectShape, Shape, TextShape,
|
||||
CircleShape, Color32, ColorMode, CubicBezierShape, EllipseShape, Mesh, PathShape,
|
||||
QuadraticBezierShape, RectShape, Shape, TextShape, color,
|
||||
};
|
||||
|
||||
/// Remember to handle [`Color32::PLACEHOLDER`] specially!
|
||||
|
||||
@@ -59,7 +59,8 @@ pub struct RectShape {
|
||||
#[test]
|
||||
fn rect_shape_size() {
|
||||
assert_eq!(
|
||||
std::mem::size_of::<RectShape>(), 48,
|
||||
std::mem::size_of::<RectShape>(),
|
||||
48,
|
||||
"RectShape changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it."
|
||||
);
|
||||
assert!(
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use emath::{pos2, Align2, Pos2, Rangef, Rect, TSTransform, Vec2};
|
||||
use emath::{Align2, Pos2, Rangef, Rect, TSTransform, Vec2, pos2};
|
||||
|
||||
use crate::{
|
||||
Color32, CornerRadius, Mesh, Stroke, StrokeKind, TextureId,
|
||||
stroke::PathStroke,
|
||||
text::{FontId, Fonts, Galley},
|
||||
Color32, CornerRadius, Mesh, Stroke, StrokeKind, TextureId,
|
||||
};
|
||||
|
||||
use super::{
|
||||
@@ -73,7 +73,8 @@ pub enum Shape {
|
||||
#[test]
|
||||
fn shape_size() {
|
||||
assert_eq!(
|
||||
std::mem::size_of::<Shape>(), 64,
|
||||
std::mem::size_of::<Shape>(),
|
||||
64,
|
||||
"Shape changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it."
|
||||
);
|
||||
assert!(
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::{fmt::Debug, sync::Arc};
|
||||
|
||||
use emath::GuiRounding as _;
|
||||
|
||||
use super::{emath, Color32, ColorMode, Pos2, Rect};
|
||||
use super::{Color32, ColorMode, Pos2, Rect, emath};
|
||||
|
||||
/// Describes the width and color of a line.
|
||||
///
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
|
||||
#![allow(clippy::identity_op)]
|
||||
|
||||
use emath::{pos2, remap, vec2, GuiRounding as _, NumExt as _, Pos2, Rect, Rot2, Vec2};
|
||||
use emath::{GuiRounding as _, NumExt as _, Pos2, Rect, Rot2, Vec2, pos2, remap, vec2};
|
||||
|
||||
use crate::{
|
||||
color::ColorMode, emath, stroke::PathStroke, texture_atlas::PreparedDisc, CircleShape,
|
||||
ClippedPrimitive, ClippedShape, Color32, CornerRadiusF32, CubicBezierShape, EllipseShape, Mesh,
|
||||
PathShape, Primitive, QuadraticBezierShape, RectShape, Shape, Stroke, StrokeKind, TextShape,
|
||||
TextureId, Vertex, WHITE_UV,
|
||||
CircleShape, ClippedPrimitive, ClippedShape, Color32, CornerRadiusF32, CubicBezierShape,
|
||||
EllipseShape, Mesh, PathShape, Primitive, QuadraticBezierShape, RectShape, Shape, Stroke,
|
||||
StrokeKind, TextShape, TextureId, Vertex, WHITE_UV, color::ColorMode, emath,
|
||||
stroke::PathStroke, texture_atlas::PreparedDisc,
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -28,7 +28,7 @@ mod precomputed_vertices {
|
||||
// println!("];")
|
||||
// }
|
||||
|
||||
use emath::{vec2, Vec2};
|
||||
use emath::{Vec2, vec2};
|
||||
|
||||
pub const CIRCLE_8: [Vec2; 9] = [
|
||||
vec2(1.000000, 0.000000),
|
||||
@@ -340,7 +340,7 @@ impl Path {
|
||||
}
|
||||
|
||||
pub fn add_circle(&mut self, center: Pos2, radius: f32) {
|
||||
use precomputed_vertices::{CIRCLE_128, CIRCLE_16, CIRCLE_32, CIRCLE_64, CIRCLE_8};
|
||||
use precomputed_vertices::{CIRCLE_8, CIRCLE_16, CIRCLE_32, CIRCLE_64, CIRCLE_128};
|
||||
|
||||
// These cutoffs are based on a high-dpi display. TODO(emilk): use pixels_per_point here?
|
||||
// same cutoffs as in add_circle_quadrant
|
||||
@@ -535,7 +535,7 @@ impl Path {
|
||||
pub mod path {
|
||||
//! Helpers for constructing paths
|
||||
use crate::CornerRadiusF32;
|
||||
use emath::{pos2, Pos2, Rect};
|
||||
use emath::{Pos2, Rect, pos2};
|
||||
|
||||
/// overwrites existing points
|
||||
pub fn rounded_rectangle(path: &mut Vec<Pos2>, rect: Rect, cr: CornerRadiusF32) {
|
||||
@@ -602,7 +602,7 @@ pub mod path {
|
||||
// - quadrant 3: right top
|
||||
// * angle 4 * TAU / 4 = right
|
||||
pub fn add_circle_quadrant(path: &mut Vec<Pos2>, center: Pos2, radius: f32, quadrant: f32) {
|
||||
use super::precomputed_vertices::{CIRCLE_128, CIRCLE_16, CIRCLE_32, CIRCLE_64, CIRCLE_8};
|
||||
use super::precomputed_vertices::{CIRCLE_8, CIRCLE_16, CIRCLE_32, CIRCLE_64, CIRCLE_128};
|
||||
|
||||
// These cutoffs are based on a high-dpi display. TODO(emilk): use pixels_per_point here?
|
||||
// same cutoffs as in add_circle
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use emath::{vec2, GuiRounding as _, Vec2};
|
||||
use emath::{GuiRounding as _, Vec2, vec2};
|
||||
|
||||
use crate::{
|
||||
TextureAtlas,
|
||||
mutex::{Mutex, RwLock},
|
||||
text::FontTweak,
|
||||
TextureAtlas,
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use std::{collections::BTreeMap, sync::Arc};
|
||||
|
||||
use crate::{
|
||||
TextureAtlas,
|
||||
mutex::{Mutex, MutexGuard},
|
||||
text::{
|
||||
font::{Font, FontImpl},
|
||||
Galley, LayoutJob, LayoutSection,
|
||||
font::{Font, FontImpl},
|
||||
},
|
||||
TextureAtlas,
|
||||
};
|
||||
use emath::{NumExt as _, OrderedFloat};
|
||||
|
||||
@@ -680,7 +680,8 @@ impl FontsImpl {
|
||||
|
||||
/// Get the right font implementation from size and [`FontFamily`].
|
||||
pub fn font(&mut self, font_id: &FontId) -> &mut Font {
|
||||
let FontId { mut size, family } = font_id;
|
||||
let FontId { size, family } = font_id;
|
||||
let mut size = *size;
|
||||
size = size.at_least(0.1).at_most(2048.0);
|
||||
|
||||
self.sized_family
|
||||
@@ -1050,7 +1051,7 @@ mod tests {
|
||||
use core::f32;
|
||||
|
||||
use super::*;
|
||||
use crate::{text::TextFormat, Stroke};
|
||||
use crate::{Stroke, text::TextFormat};
|
||||
use ecolor::Color32;
|
||||
use emath::Align;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use emath::{pos2, vec2, Align, GuiRounding as _, NumExt as _, Pos2, Rect, Vec2};
|
||||
use emath::{Align, GuiRounding as _, NumExt as _, Pos2, Rect, Vec2, pos2, vec2};
|
||||
|
||||
use crate::{stroke::PathStroke, text::font::Font, Color32, Mesh, Stroke, Vertex};
|
||||
use crate::{Color32, Mesh, Stroke, Vertex, stroke::PathStroke, text::font::Font};
|
||||
|
||||
use super::{FontsImpl, Galley, Glyph, LayoutJob, LayoutSection, PlacedRow, Row, RowVisuals};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use super::{
|
||||
font::UvRect,
|
||||
};
|
||||
use crate::{Color32, FontId, Mesh, Stroke};
|
||||
use emath::{pos2, vec2, Align, GuiRounding as _, NumExt as _, OrderedFloat, Pos2, Rect, Vec2};
|
||||
use emath::{Align, GuiRounding as _, NumExt as _, OrderedFloat, Pos2, Rect, Vec2, pos2, vec2};
|
||||
|
||||
/// Describes the task of laying out text.
|
||||
///
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use emath::{remap_clamp, Rect};
|
||||
use emath::{Rect, remap_clamp};
|
||||
|
||||
use crate::{FontImage, ImageDelta};
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{
|
||||
emath::NumExt as _, mutex::RwLock, textures::TextureOptions, ImageData, ImageDelta, TextureId,
|
||||
TextureManager,
|
||||
ImageData, ImageDelta, TextureId, TextureManager, emath::NumExt as _, mutex::RwLock,
|
||||
textures::TextureOptions,
|
||||
};
|
||||
|
||||
/// Used to paint images.
|
||||
|
||||
Reference in New Issue
Block a user