#[derive(EguiStruct)]
{
// Attributes available to this derive:
#[eguis]
#[eguisM]
}
Expand description
Derive EguiStruct, EguiStructClone & EguiStructEq for struct/enum
#[derive(EguiStruct)]
#[eguis(rename_all = "Upper")]
struct Data{
#[eguis(hint = "This is field")]
field: usize
}Atributtes eguis & eguisM are supported on either enum/struct, field or variant level
to configure trait implementation and may take following values:
- enum/struct level:
rename_all = "str"- renames all fields/variants to selected case (recognized values:"Upper","Lower","Title","Toggle","Camel","Pascal","UpperCamel","Snake","UpperSnake","ScreamingSnake","Kebab","Cobol","UpperKebab","Train","Flat","UpperFlat","Alternating","Sentence")prefix = "str"- add this prefix when generatingrust-i18nkeysno_mut- do not generateEguiStructimplementationno_eclone- do not generateEguiStructCloneimplementationno_eeq- do not generateEguiStructEqimplementationstart_collapsed = "Expr"- setsstart_collapsed()implementation (should returnbool; can useself)resetable = "val"ORresetable(with_expr = Expr)- all fields/variants will be resetable according to provieded value (val:"not_resetable","field_default","struct_default","follow_arg"(use value passed on runtime through reset2 arg))
- variant level:
rename ="str"- Name of the field to be displayed on UI labels or variantName in i18n keyskip- Don’t generate code for the given varianthint ="str"- add on hover hintimut- variant will be shown as immutablei18n ="i18n_key"- normally i18n keys are in format “prefix.enumName.variantName”, override this with “i18n_key”resetable- overides enum/struct level resetable
- field level
rename,skip,hint,imut,i18n- see variant levelresetable- overides enum/struct & variant level resetableon_change = "expr"- Use function (expr: closure surounded by()OR function path) callback (when value has been changed; signature:fn(&mut field_type))on_change_struct = "expr"- Similar toon_changebut takes whole struct: signature:fn(&mut self)config- pass format/config object to customise how field is displayedstart_collapsed = true/false- field always starts collapsed/uncollapsed (overides fieldsstart_collapsed()return)map_pre- Expression (closure surounded by()OR function path) called to map field to another type before displaying- this allows displaying fields that does not implement EguiStruct or overiding how field is shown
- function shall take
& field_typeor&mut field_typeAND return either mutable reference or owned value of selected type (that implementsEguiStruct) - ! beware, because (if
map_pre_refis not set) this will make field work only with resetable values: {NonResetable, WithExpr, FieldDefault} - defaults to
map_pre_ref(so if&mutis not needed for map, can be left unused)
map_pre_ref- similar tomap_pre, but takes immutable reference (signature:fn(&field_type)->mapped),- used to convert default/reset2 and inside eguis_eq (if eeq not specified)
map_post- Expression (closure surounded by()OR function path) called to map mapped field back to field_type after displaying- only used if
map_preis set - signature:
fn(&mut field_type, &mapped)(withmappedtype matching return frommap_pre) - expresion should assign new value to
&mut field_type
- only used if
eeq- overrideeguis_eqfunction for field (signature fn(&field_type, &field_type))- if either
field_type : EguiStructEqORmap_pre_refis specified can be unused
- if either
eclone- overrideeguis_eclonefunction for field (signature fn(&mut field_type, &field_type))- if
field_type : EguiStructClonecan be unused
- if