mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Add Rangef to emath
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap, HashSet},
|
||||
ops::RangeInclusive,
|
||||
};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
|
||||
use egui::{pos2, vec2, Rect};
|
||||
use egui::{emath::Rangef, pos2, vec2, Rect};
|
||||
use itertools::Itertools as _;
|
||||
|
||||
use crate::dock::{
|
||||
@@ -11,46 +8,6 @@ use crate::dock::{
|
||||
ResizeState,
|
||||
};
|
||||
|
||||
/// Includive range of floats, i.e. `min..=max`, but more ergonomic than [`RangeInclusive`].
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
struct Rangef {
|
||||
pub min: f32,
|
||||
pub max: f32,
|
||||
}
|
||||
|
||||
impl Rangef {
|
||||
#[inline]
|
||||
pub fn new(min: f32, max: f32) -> Self {
|
||||
Self { min, max }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> f32 {
|
||||
self.max - self.min
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RangeInclusive<f32>> for Rangef {
|
||||
#[inline]
|
||||
fn from(range: RangeInclusive<f32>) -> Self {
|
||||
Self::new(*range.start(), *range.end())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&RangeInclusive<f32>> for Rangef {
|
||||
#[inline]
|
||||
fn from(range: &RangeInclusive<f32>) -> Self {
|
||||
Self::new(*range.start(), *range.end())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Rangef> for RangeInclusive<f32> {
|
||||
#[inline]
|
||||
fn from(Rangef { min, max }: Rangef) -> Self {
|
||||
min..=max
|
||||
}
|
||||
}
|
||||
|
||||
/// Where in a grid?
|
||||
#[derive(
|
||||
Clone,
|
||||
|
||||
Reference in New Issue
Block a user