diff --git a/egui/src/animation_manager.rs b/egui/src/animation_manager.rs index eef722b9..e28ffa1b 100644 --- a/egui/src/animation_manager.rs +++ b/egui/src/animation_manager.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use crate::{math::remap_clamp, Id, InputState}; +use crate::{emath::remap_clamp, Id, InputState}; #[derive(Clone, Default)] pub(crate) struct AnimationManager { diff --git a/egui/src/containers/collapsing_header.rs b/egui/src/containers/collapsing_header.rs index 62946b09..923982dc 100644 --- a/egui/src/containers/collapsing_header.rs +++ b/egui/src/containers/collapsing_header.rs @@ -116,7 +116,7 @@ pub(crate) fn paint_icon(ui: &mut Ui, openness: f32, response: &Response) { let rect = rect.expand(visuals.expansion); let mut points = vec![rect.left_top(), rect.right_top(), rect.center_bottom()]; use std::f32::consts::TAU; - let rotation = math::Rot2::from_angle(remap(openness, 0.0..=1.0, -TAU / 4.0..=0.0)); + let rotation = emath::Rot2::from_angle(remap(openness, 0.0..=1.0, -TAU / 4.0..=0.0)); for p in &mut points { *p = rect.center() + rotation * (*p - rect.center()); } diff --git a/egui/src/containers/window.rs b/egui/src/containers/window.rs index 95b5758f..7b0f7f68 100644 --- a/egui/src/containers/window.rs +++ b/egui/src/containers/window.rs @@ -749,7 +749,7 @@ impl TitleBar { self.title_label = self.title_label.text_color(style.fg_stroke.color); let full_top_rect = Rect::from_x_y_ranges(self.rect.x_range(), self.min_rect.y_range()); - let text_pos = math::align::center_size_in_rect(self.title_galley.size, full_top_rect); + let text_pos = emath::align::center_size_in_rect(self.title_galley.size, full_top_rect); let text_pos = text_pos.left_top() - 1.5 * Vec2::Y; // HACK: center on x-height of text (looks better) self.title_label .paint_galley(ui, text_pos, self.title_galley); diff --git a/egui/src/data/input.rs b/egui/src/data/input.rs index fc72a1c1..8795f7a1 100644 --- a/egui/src/data/input.rs +++ b/egui/src/data/input.rs @@ -1,6 +1,6 @@ //! The input needed by egui. -use crate::math::*; +use crate::emath::*; /// What the integrations provides to egui at the start of each frame. /// diff --git a/egui/src/input_state.rs b/egui/src/input_state.rs index b6b3623f..7262a325 100644 --- a/egui/src/input_state.rs +++ b/egui/src/input_state.rs @@ -1,7 +1,6 @@ -use crate::{math::*, util::History}; -use std::collections::HashSet; - use crate::data::input::*; +use crate::{emath::*, util::History}; +use std::collections::HashSet; pub use crate::data::input::Key; diff --git a/egui/src/layers.rs b/egui/src/layers.rs index d420645c..6d56f85d 100644 --- a/egui/src/layers.rs +++ b/egui/src/layers.rs @@ -1,7 +1,7 @@ //! Handles paint layers, i.e. how things //! are sometimes painted behind or in front of other things. -use crate::{math::Rect, Id, *}; +use crate::{Id, *}; use epaint::ahash::AHashMap; use epaint::{ClippedShape, Shape}; diff --git a/egui/src/layout.rs b/egui/src/layout.rs index e9c6cf7a..9a2bb1e2 100644 --- a/egui/src/layout.rs +++ b/egui/src/layout.rs @@ -1,4 +1,4 @@ -use crate::{math::*, Align}; +use crate::{emath::*, Align}; // ---------------------------------------------------------------------------- diff --git a/egui/src/lib.rs b/egui/src/lib.rs index a2e25a8d..76159b84 100644 --- a/egui/src/lib.rs +++ b/egui/src/lib.rs @@ -121,10 +121,12 @@ mod ui; pub mod util; pub mod widgets; -pub use emath as math; pub use epaint as paint; pub use epaint::emath; +// Can't add deprecation notice due to https://github.com/rust-lang/rust/issues/30827 +pub use emath as math; + pub use emath::{ clamp, lerp, pos2, remap, remap_clamp, vec2, Align, Align2, NumExt, Pos2, Rect, Vec2, }; diff --git a/egui/src/painter.rs b/egui/src/painter.rs index ca0ae33a..6b023f61 100644 --- a/egui/src/painter.rs +++ b/egui/src/painter.rs @@ -1,6 +1,6 @@ use crate::{ + emath::{Align2, Pos2, Rect, Vec2}, layers::{LayerId, ShapeIdx}, - math::{Align2, Pos2, Rect, Vec2}, paint::{ text::{Fonts, Galley, TextStyle}, Shape, Stroke, @@ -264,7 +264,7 @@ impl Painter { /// Show an arrow starting at `origin` and going in the direction of `vec`, with the length `vec.length()`. pub fn arrow(&self, origin: Pos2, vec: Vec2, stroke: Stroke) { - use crate::math::*; + use crate::emath::*; let rot = Rot2::from_angle(std::f32::consts::TAU / 10.0); let tip_length = vec.length() / 4.0; let tip = origin + vec; diff --git a/egui/src/response.rs b/egui/src/response.rs index a324e4a7..a1765b47 100644 --- a/egui/src/response.rs +++ b/egui/src/response.rs @@ -1,5 +1,5 @@ use crate::{ - math::{lerp, Align, Pos2, Rect}, + emath::{lerp, Align, Pos2, Rect}, PointerButton, NUM_POINTER_BUTTONS, }; use crate::{CtxRef, Id, LayerId, Sense, Ui}; diff --git a/egui/src/style.rs b/egui/src/style.rs index 74d41da9..1d821a02 100644 --- a/egui/src/style.rs +++ b/egui/src/style.rs @@ -4,7 +4,7 @@ use crate::{ color::*, - math::*, + emath::*, paint::{Shadow, Stroke, TextStyle}, Response, }; diff --git a/egui/src/widgets/drag_value.rs b/egui/src/widgets/drag_value.rs index 4def2111..4498f7a0 100644 --- a/egui/src/widgets/drag_value.rs +++ b/egui/src/widgets/drag_value.rs @@ -156,7 +156,7 @@ impl<'a> Widget for DragValue<'a> { let auto_decimals = (aim_rad / speed.abs()).log10().ceil().at_least(0.0) as usize; let max_decimals = max_decimals.unwrap_or(auto_decimals + 2); let auto_decimals = clamp(auto_decimals, min_decimals..=max_decimals); - let value_text = math::format_with_decimals_in_range(value, auto_decimals..=max_decimals); + let value_text = emath::format_with_decimals_in_range(value, auto_decimals..=max_decimals); let kb_edit_id = ui.auto_id_with("edit"); let is_kb_editing = ui.memory().has_kb_focus(kb_edit_id); @@ -200,7 +200,7 @@ impl<'a> Widget for DragValue<'a> { let delta_value = speed * delta_points; if delta_value != 0.0 { let new_value = value + delta_value as f64; - let new_value = math::round_to_decimals(new_value, auto_decimals); + let new_value = emath::round_to_decimals(new_value, auto_decimals); let new_value = clamp(new_value, clamp_range); set(&mut value_function, new_value); // TODO: To make use or `smart_aim` for `DragValue` we need to store some state somewhere, diff --git a/egui/src/widgets/slider.rs b/egui/src/widgets/slider.rs index 4e370af7..1276b902 100644 --- a/egui/src/widgets/slider.rs +++ b/egui/src/widgets/slider.rs @@ -246,7 +246,7 @@ impl<'a> Slider<'a> { value = clamp(value, self.range.clone()); } if let Some(max_decimals) = self.max_decimals { - value = math::round_to_decimals(value, max_decimals); + value = emath::round_to_decimals(value, max_decimals); } set(&mut self.get_set_value, value); } @@ -291,7 +291,7 @@ impl<'a> Slider<'a> { if let Some(pointer_pos) = response.interact_pointer_pos() { let new_value = if self.smart_aim { let aim_radius = ui.input().aim_radius(); - crate::math::smart_aim::best_in_range_f64( + emath::smart_aim::best_in_range_f64( self.value_from_x(pointer_pos.x - aim_radius, x_range.clone()), self.value_from_x(pointer_pos.x + aim_radius, x_range.clone()), ) @@ -400,13 +400,13 @@ impl<'a> Slider<'a> { let auto_decimals = clamp(auto_decimals, min_decimals..=max_decimals); if min_decimals == max_decimals { - math::format_with_minimum_decimals(value, max_decimals) + emath::format_with_minimum_decimals(value, max_decimals) } else if value == 0.0 { "0".to_owned() } else if range == 0.0 { value.to_string() } else { - math::format_with_decimals_in_range(value, auto_decimals..=max_decimals) + emath::format_with_decimals_in_range(value, auto_decimals..=max_decimals) } } } @@ -439,7 +439,7 @@ impl<'a> Widget for Slider<'a> { // Helpers for converting slider range to/from normalized [0-1] range. // Always clamps. // Logarithmic sliders are allowed to include zero and infinity, -// even though mathematically it doesn't make sense. +// even though emathematically it doesn't make sense. use std::f64::INFINITY; diff --git a/egui_demo_lib/src/apps/demo/dancing_strings.rs b/egui_demo_lib/src/apps/demo/dancing_strings.rs index e277d196..6c0e81fc 100644 --- a/egui_demo_lib/src/apps/demo/dancing_strings.rs +++ b/egui_demo_lib/src/apps/demo/dancing_strings.rs @@ -35,7 +35,7 @@ impl super::View for DancingStrings { let (_id, rect) = ui.allocate_space(desired_size); let to_screen = - math::RectTransform::from_to(Rect::from_x_y_ranges(0.0..=1.0, -1.0..=1.0), rect); + emath::RectTransform::from_to(Rect::from_x_y_ranges(0.0..=1.0, -1.0..=1.0), rect); let mut shapes = vec![]; diff --git a/egui_demo_lib/src/apps/fractal_clock.rs b/egui_demo_lib/src/apps/fractal_clock.rs index a174e7e2..f5022c16 100644 --- a/egui_demo_lib/src/apps/fractal_clock.rs +++ b/egui_demo_lib/src/apps/fractal_clock.rs @@ -151,8 +151,8 @@ impl FractalClock { ]; let hand_rotors = [ - hands[0].length * math::Rot2::from_angle(hand_rotations[0]), - hands[1].length * math::Rot2::from_angle(hand_rotations[1]), + hands[0].length * emath::Rot2::from_angle(hand_rotations[0]), + hands[1].length * emath::Rot2::from_angle(hand_rotations[1]), ]; #[derive(Clone, Copy)] diff --git a/egui_glium/src/painter.rs b/egui_glium/src/painter.rs index 03515a2d..82011b28 100644 --- a/egui_glium/src/painter.rs +++ b/egui_glium/src/painter.rs @@ -1,7 +1,7 @@ #![allow(deprecated)] // legacy implement_vertex macro use { - egui::{math::clamp, paint::Mesh, Color32, Rect}, + egui::{emath::clamp, paint::Mesh, Color32, Rect}, glium::{ implement_vertex, index::PrimitiveType, diff --git a/egui_web/src/webgl1.rs b/egui_web/src/webgl1.rs index 21aec2a0..89d8656d 100644 --- a/egui_web/src/webgl1.rs +++ b/egui_web/src/webgl1.rs @@ -5,7 +5,7 @@ use { }; use egui::{ - math::clamp, + emath::clamp, paint::{Color32, Texture}, vec2, }; diff --git a/egui_web/src/webgl2.rs b/egui_web/src/webgl2.rs index 2d380859..cfd7bc8b 100644 --- a/egui_web/src/webgl2.rs +++ b/egui_web/src/webgl2.rs @@ -7,7 +7,7 @@ use { }; use egui::{ - math::clamp, + emath::clamp, paint::{Color32, Texture}, vec2, };