mirror of
https://github.com/Noratrieb/game-wip-dontplay.git
synced 2026-01-16 04:25:00 +01:00
more
This commit is contained in:
parent
e8e276eae2
commit
8f651d1553
2 changed files with 8 additions and 13 deletions
|
|
@ -24,7 +24,7 @@ fn inspect_kind(attrs: &[Attribute]) -> FieldInspectKind {
|
|||
FieldInspectKind::Auto
|
||||
}
|
||||
|
||||
#[proc_macro_derive(Inspect, attributes(opaque, inspect_with))]
|
||||
#[proc_macro_derive(Inspect)]
|
||||
pub fn derive_inspect(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
let ty_ident = input.ident;
|
||||
|
|
@ -36,19 +36,12 @@ pub fn derive_inspect(input: TokenStream) -> TokenStream {
|
|||
Some(ident) => Member::from(ident.clone()),
|
||||
None => Member::from(i),
|
||||
};
|
||||
match inspect_kind(&f.attrs) {
|
||||
FieldInspectKind::Auto => {
|
||||
exprs.push(quote! {
|
||||
ui.horizontal(|ui| {
|
||||
if ui.add(::egui::Label::new(stringify!(#f)).sense(::egui::Sense::click())).clicked() {
|
||||
ui.output_mut(|o| o.copied_text = format!("{:?}", self.#memb));
|
||||
}
|
||||
});
|
||||
|
||||
exprs.push(quote! {
|
||||
if ui.add(::egui::Label::new(stringify!(#f)).sense(::egui::Sense::click())).clicked() {
|
||||
ui.output_mut(|o| o.copied_text = format!("{:?}", self.#memb));
|
||||
}
|
||||
});
|
||||
}
|
||||
FieldInspectKind::Opaque => {}
|
||||
FieldInspectKind::WithFn(_) => {}
|
||||
}
|
||||
}
|
||||
quote! {
|
||||
::egui::CollapsingHeader::new(stringify!(#ty_ident)).id_source(id_source).show(ui, |ui| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue