From 1c8cf9e3d59d8aee4c073b9e17695ee85c40bdbf Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 21 Nov 2022 14:14:33 +0100 Subject: [PATCH] Move egui::util::History to emath::History (#2329) * Move egui::util::History to emath::History It is a nice thing to use outside of egui, and it is more math-related than gui-related. * Fix doctest --- crates/egui/src/util/mod.rs | 3 +-- crates/{egui/src/util => emath/src}/history.rs | 4 ++-- crates/emath/src/lib.rs | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) rename crates/{egui/src/util => emath/src}/history.rs (98%) diff --git a/crates/egui/src/util/mod.rs b/crates/egui/src/util/mod.rs index ea83ea61..55e93eb0 100644 --- a/crates/egui/src/util/mod.rs +++ b/crates/egui/src/util/mod.rs @@ -2,11 +2,10 @@ pub mod cache; pub(crate) mod fixed_cache; -mod history; pub mod id_type_map; pub mod undoer; -pub use history::History; pub use id_type_map::IdTypeMap; +pub use epaint::emath::History; pub use epaint::util::{hash, hash_with}; diff --git a/crates/egui/src/util/history.rs b/crates/emath/src/history.rs similarity index 98% rename from crates/egui/src/util/history.rs rename to crates/emath/src/history.rs index 26e9443d..482db925 100644 --- a/crates/egui/src/util/history.rs +++ b/crates/emath/src/history.rs @@ -41,7 +41,7 @@ where { /// Example: /// ``` - /// # use egui::util::History; + /// # use emath::History; /// # fn now() -> f64 { 0.0 } /// // Drop events that are older than one second, /// // as long we keep at least two events. Never keep more than a hundred events. @@ -125,7 +125,7 @@ where /// Values must be added with a monotonically increasing time, or at least not decreasing. pub fn add(&mut self, now: f64, value: T) { if let Some((last_time, _)) = self.values.back() { - crate::egui_assert!(now >= *last_time, "Time shouldn't move backwards"); + crate::emath_assert!(now >= *last_time, "Time shouldn't move backwards"); } self.total_count += 1; self.values.push_back((now, value)); diff --git a/crates/emath/src/lib.rs b/crates/emath/src/lib.rs index 016e3e8d..7b679cbf 100644 --- a/crates/emath/src/lib.rs +++ b/crates/emath/src/lib.rs @@ -27,6 +27,7 @@ use std::ops::{Add, Div, Mul, RangeInclusive, Sub}; // ---------------------------------------------------------------------------- pub mod align; +mod history; mod numeric; mod pos2; mod rect; @@ -37,6 +38,7 @@ mod vec2; pub use { align::{Align, Align2}, + history::History, numeric::*, pos2::*, rect::*,