mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 12:25:02 +01:00
103 lines
2.7 KiB
Rust
103 lines
2.7 KiB
Rust
use egui::Ui;
|
|
#[cfg(feature = "derive")]
|
|
pub use egui_inspect_derive as derive;
|
|
use std::{
|
|
collections::{HashMap, HashSet},
|
|
ffi::OsString,
|
|
fmt::Debug,
|
|
marker::PhantomData,
|
|
};
|
|
pub trait Inspect: Debug {
|
|
fn inspect(&self, ui: &mut Ui, id_source: u64);
|
|
fn inspect_mut(&mut self, ui: &mut Ui, id_source: u64) {
|
|
loop {}
|
|
}
|
|
}
|
|
|
|
macro_rules! impl_num_inspect {
|
|
($($ty:ty),*) => {
|
|
$(impl Inspect for $ty { fn inspect_mut(& mut self, ui : & mut Ui, _id_source :
|
|
u64) { ui.add(egui::DragValue::new(self)); } fn inspect(& self, ui : & mut Ui,
|
|
_id_source : u64) { ui.label(self.to_string()); } })*
|
|
};
|
|
}
|
|
impl_num_inspect!(i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, usize, isize);
|
|
impl<T, U> Inspect for (T, U)
|
|
where
|
|
T: Inspect,
|
|
U: Inspect,
|
|
{
|
|
fn inspect_mut(&mut self, ui: &mut Ui, id_source: u64) {
|
|
loop {}
|
|
}
|
|
fn inspect(&self, ui: &mut Ui, id_source: u64) {
|
|
loop {}
|
|
}
|
|
}
|
|
pub trait UiExt {
|
|
fn inspect<T: Inspect>(&mut self, what: &T, id_source: &mut u64);
|
|
fn inspect_iter_with<'a, I, T, F>(
|
|
&mut self,
|
|
title: &str,
|
|
into_iter: I,
|
|
id_source: &mut u64,
|
|
fun: F,
|
|
) where
|
|
I: IntoIterator<Item = &'a T>,
|
|
T: 'a,
|
|
F: FnMut(&mut Ui, usize, &T, &mut u64);
|
|
fn inspect_iter_with_mut<'a, I, T, F>(
|
|
&mut self,
|
|
title: &str,
|
|
into_iter: I,
|
|
id_source: &mut u64,
|
|
fun: F,
|
|
) where
|
|
I: IntoIterator<Item = &'a mut T>,
|
|
T: 'a,
|
|
F: FnMut(&mut Ui, usize, &mut T, &mut u64);
|
|
fn inspect_mut<T: Inspect>(&mut self, what: &mut T, id_source: &mut u64);
|
|
fn property<T: Inspect>(&mut self, name: &str, what: &mut T, id_source: &mut u64);
|
|
}
|
|
impl UiExt for Ui {
|
|
fn inspect<T: Inspect>(&mut self, what: &T, id_source: &mut u64) {
|
|
loop {}
|
|
}
|
|
fn inspect_iter_with<'a, I, T, F>(
|
|
&mut self,
|
|
title: &str,
|
|
into_iter: I,
|
|
id_source: &mut u64,
|
|
mut fun: F,
|
|
) where
|
|
I: IntoIterator<Item = &'a T>,
|
|
T: 'a,
|
|
F: FnMut(&mut Ui, usize, &T, &mut u64),
|
|
{
|
|
loop {}
|
|
}
|
|
fn inspect_iter_with_mut<'a, I, T, F>(
|
|
&mut self,
|
|
title: &str,
|
|
into_iter: I,
|
|
id_source: &mut u64,
|
|
mut fun: F,
|
|
) where
|
|
I: IntoIterator<Item = &'a mut T>,
|
|
T: 'a,
|
|
F: FnMut(&mut Ui, usize, &mut T, &mut u64),
|
|
{
|
|
loop {}
|
|
}
|
|
fn inspect_mut<T: Inspect>(&mut self, what: &mut T, id_source: &mut u64) {
|
|
loop {}
|
|
}
|
|
fn property<T: Inspect>(&mut self, name: &str, what: &mut T, id_source: &mut u64) {
|
|
loop {}
|
|
}
|
|
}
|
|
impl Inspect for () {
|
|
fn inspect(&self, ui: &mut Ui, _id_source: u64) {
|
|
loop {}
|
|
}
|
|
}
|