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
This commit is contained in:
parent
f4d8ab9779
commit
1c8cf9e3d5
3 changed files with 5 additions and 4 deletions
|
@ -2,11 +2,10 @@
|
||||||
|
|
||||||
pub mod cache;
|
pub mod cache;
|
||||||
pub(crate) mod fixed_cache;
|
pub(crate) mod fixed_cache;
|
||||||
mod history;
|
|
||||||
pub mod id_type_map;
|
pub mod id_type_map;
|
||||||
pub mod undoer;
|
pub mod undoer;
|
||||||
|
|
||||||
pub use history::History;
|
|
||||||
pub use id_type_map::IdTypeMap;
|
pub use id_type_map::IdTypeMap;
|
||||||
|
|
||||||
|
pub use epaint::emath::History;
|
||||||
pub use epaint::util::{hash, hash_with};
|
pub use epaint::util::{hash, hash_with};
|
||||||
|
|
|
@ -41,7 +41,7 @@ where
|
||||||
{
|
{
|
||||||
/// Example:
|
/// Example:
|
||||||
/// ```
|
/// ```
|
||||||
/// # use egui::util::History;
|
/// # use emath::History;
|
||||||
/// # fn now() -> f64 { 0.0 }
|
/// # fn now() -> f64 { 0.0 }
|
||||||
/// // Drop events that are older than one second,
|
/// // Drop events that are older than one second,
|
||||||
/// // as long we keep at least two events. Never keep more than a hundred events.
|
/// // 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.
|
/// Values must be added with a monotonically increasing time, or at least not decreasing.
|
||||||
pub fn add(&mut self, now: f64, value: T) {
|
pub fn add(&mut self, now: f64, value: T) {
|
||||||
if let Some((last_time, _)) = self.values.back() {
|
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.total_count += 1;
|
||||||
self.values.push_back((now, value));
|
self.values.push_back((now, value));
|
|
@ -27,6 +27,7 @@ use std::ops::{Add, Div, Mul, RangeInclusive, Sub};
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub mod align;
|
pub mod align;
|
||||||
|
mod history;
|
||||||
mod numeric;
|
mod numeric;
|
||||||
mod pos2;
|
mod pos2;
|
||||||
mod rect;
|
mod rect;
|
||||||
|
@ -37,6 +38,7 @@ mod vec2;
|
||||||
|
|
||||||
pub use {
|
pub use {
|
||||||
align::{Align, Align2},
|
align::{Align, Align2},
|
||||||
|
history::History,
|
||||||
numeric::*,
|
numeric::*,
|
||||||
pos2::*,
|
pos2::*,
|
||||||
rect::*,
|
rect::*,
|
||||||
|
|
Loading…
Reference in a new issue