1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use super::InspectorOptionsType;
macro_rules! impl_options {
($ty:ty => $options:ty) => {
impl InspectorOptionsType for $ty {
type TypedOptions = $options;
type Options = $options;
}
};
}
#[derive(Clone)]
pub struct NumberOptions<T> {
pub min: Option<T>,
pub max: Option<T>,
pub speed: f32,
pub prefix: String,
pub suffix: String,
}
impl<T> Default for NumberOptions<T> {
fn default() -> Self {
Self {
min: Default::default(),
max: Default::default(),
speed: 0.0,
prefix: String::new(),
suffix: String::new(),
}
}
}
impl<T> NumberOptions<T> {
pub fn between(min: T, max: T) -> NumberOptions<T> {
NumberOptions {
min: Some(min),
max: Some(max),
speed: 0.0,
prefix: String::new(),
suffix: String::new(),
}
}
pub fn at_least(min: T) -> NumberOptions<T> {
NumberOptions {
min: Some(min),
max: None,
speed: 0.0,
prefix: String::new(),
suffix: String::new(),
}
}
}
impl<T: egui::emath::Numeric> NumberOptions<T> {
pub fn positive() -> NumberOptions<T> {
NumberOptions {
min: Some(T::from_f64(0.0)),
max: None,
speed: 0.0,
prefix: String::new(),
suffix: String::new(),
}
}
}
impl NumberOptions<f32> {
pub fn normalized() -> Self {
NumberOptions {
min: Some(0.0),
max: Some(1.0),
speed: 0.01,
prefix: String::new(),
suffix: String::new(),
}
}
}
impl NumberOptions<f64> {
pub fn normalized() -> Self {
NumberOptions {
min: Some(0.0),
max: Some(1.0),
speed: 0.01,
prefix: String::new(),
suffix: String::new(),
}
}
}
impl_options!(f32 => NumberOptions<f32>);
impl_options!(usize => NumberOptions<usize>);
impl<T> InspectorOptionsType for Option<T> {
type TypedOptions = ();
type Options = ();
}
#[derive(Clone)]
pub struct QuatOptions {
pub display: QuatDisplay,
}
#[derive(Copy, Clone, Debug)]
pub enum QuatDisplay {
Raw,
Euler,
YawPitchRoll,
AxisAngle,
}
impl Default for QuatOptions {
fn default() -> Self {
QuatOptions {
display: QuatDisplay::Euler,
}
}
}